Commit 1b1d3e6461e9195f825d6d8aa6a2a0e1e3188f62
Committed by
Tom Rini
1 parent
00f1099e09
Exists in
master
and in
54 other branches
input: Separate out keyboard repeat/delay from init
It is inconvenient to have to specify the keyboard repeat and delay at init time if it is not yet available, so move this into a separate function. Some drivers will want to do this when their keyboard init routine is actually called. Signed-off-by: Simon Glass <sjg@chromium.org>
Showing 3 changed files with 22 additions and 10 deletions Side-by-side Diff
drivers/input/input.c
... | ... | @@ -356,7 +356,8 @@ |
356 | 356 | * insert another character if we later realise that we |
357 | 357 | * have missed a repeat slot. |
358 | 358 | */ |
359 | - is_repeat = (int)get_timer(config->next_repeat_ms) >= 0; | |
359 | + is_repeat = config->repeat_rate_ms && | |
360 | + (int)get_timer(config->next_repeat_ms) >= 0; | |
360 | 361 | if (!is_repeat) |
361 | 362 | return 0; |
362 | 363 | } |
363 | 364 | |
364 | 365 | |
... | ... | @@ -392,13 +393,17 @@ |
392 | 393 | return 0; |
393 | 394 | } |
394 | 395 | |
395 | -int input_init(struct input_config *config, int leds, int repeat_delay_ms, | |
396 | +void input_set_delays(struct input_config *config, int repeat_delay_ms, | |
396 | 397 | int repeat_rate_ms) |
397 | 398 | { |
398 | - memset(config, '\0', sizeof(*config)); | |
399 | - config->leds = leds; | |
400 | 399 | config->repeat_delay_ms = repeat_delay_ms; |
401 | 400 | config->repeat_rate_ms = repeat_rate_ms; |
401 | +} | |
402 | + | |
403 | +int input_init(struct input_config *config, int leds) | |
404 | +{ | |
405 | + memset(config, '\0', sizeof(*config)); | |
406 | + config->leds = leds; | |
402 | 407 | if (input_add_table(config, -1, -1, |
403 | 408 | kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate)) || |
404 | 409 | input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT, |
drivers/input/tegra-kbc.c
... | ... | @@ -321,6 +321,8 @@ |
321 | 321 | debug("%s: No keyboard register found\n", __func__); |
322 | 322 | return -1; |
323 | 323 | } |
324 | + input_set_delays(&config.input, KBC_REPEAT_DELAY_MS, | |
325 | + KBC_REPEAT_RATE_MS); | |
324 | 326 | |
325 | 327 | /* Decode the keyboard matrix information (16 rows, 8 columns) */ |
326 | 328 | if (key_matrix_init(&config.matrix, 16, 8)) { |
... | ... | @@ -356,8 +358,7 @@ |
356 | 358 | { |
357 | 359 | struct stdio_dev dev; |
358 | 360 | |
359 | - if (input_init(&config.input, 0, KBC_REPEAT_DELAY_MS, | |
360 | - KBC_REPEAT_RATE_MS)) { | |
361 | + if (input_init(&config.input, 0)) { | |
361 | 362 | debug("%s: Cannot set up input\n", __func__); |
362 | 363 | return -1; |
363 | 364 | } |
include/input.h
... | ... | @@ -126,16 +126,22 @@ |
126 | 126 | int input_stdio_register(struct stdio_dev *dev); |
127 | 127 | |
128 | 128 | /** |
129 | + * Set up the keyboard autorepeat delays | |
130 | + * | |
131 | + * @param repeat_delay_ms Delay before key auto-repeat starts (in ms) | |
132 | + * @param repeat_rate_ms Delay between successive key repeats (in ms) | |
133 | + */ | |
134 | +void input_set_delays(struct input_config *config, int repeat_delay_ms, | |
135 | + int repeat_rate_ms); | |
136 | + | |
137 | +/** | |
129 | 138 | * Set up the input handler with basic key maps. |
130 | 139 | * |
131 | 140 | * @param config Input state |
132 | 141 | * @param leds Initial LED value (INPUT_LED_ mask), 0 suggested |
133 | - * @param repeat_delay_ms Delay before key auto-repeat starts (in ms) | |
134 | - * @param repeat_rate_ms Delay between successive key repeats (in ms) | |
135 | 142 | * @return 0 if ok, -1 on error |
136 | 143 | */ |
137 | -int input_init(struct input_config *config, int leds, int repeat_delay_ms, | |
138 | - int repeat_rate_ms); | |
144 | +int input_init(struct input_config *config, int leds); | |
139 | 145 | |
140 | 146 | #ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE |
141 | 147 | extern int overwrite_console(void); |