瀏覽代碼

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>
Simon Glass 12 年之前
父節點
當前提交
1b1d3e6461
共有 3 個文件被更改,包括 22 次插入10 次删除
  1. 9 4
      drivers/input/input.c
  2. 3 2
      drivers/input/tegra-kbc.c
  3. 10 4
      include/input.h

+ 9 - 4
drivers/input/input.c

@@ -356,7 +356,8 @@ int input_send_keycodes(struct input_config *config,
 		 * insert another character if we later realise that we
 		 * insert another character if we later realise that we
 		 * have missed a repeat slot.
 		 * have missed a repeat slot.
 		 */
 		 */
-		is_repeat = (int)get_timer(config->next_repeat_ms) >= 0;
+		is_repeat = config->repeat_rate_ms &&
+			(int)get_timer(config->next_repeat_ms) >= 0;
 		if (!is_repeat)
 		if (!is_repeat)
 			return 0;
 			return 0;
 	}
 	}
@@ -392,13 +393,17 @@ int input_add_table(struct input_config *config, int left_keycode,
 	return 0;
 	return 0;
 }
 }
 
 
-int input_init(struct input_config *config, int leds, int repeat_delay_ms,
+void input_set_delays(struct input_config *config, int repeat_delay_ms,
 	       int repeat_rate_ms)
 	       int repeat_rate_ms)
 {
 {
-	memset(config, '\0', sizeof(*config));
-	config->leds = leds;
 	config->repeat_delay_ms = repeat_delay_ms;
 	config->repeat_delay_ms = repeat_delay_ms;
 	config->repeat_rate_ms = repeat_rate_ms;
 	config->repeat_rate_ms = repeat_rate_ms;
+}
+
+int input_init(struct input_config *config, int leds)
+{
+	memset(config, '\0', sizeof(*config));
+	config->leds = leds;
 	if (input_add_table(config, -1, -1,
 	if (input_add_table(config, -1, -1,
 			kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate)) ||
 			kbd_plain_xlate, ARRAY_SIZE(kbd_plain_xlate)) ||
 		input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,
 		input_add_table(config, KEY_LEFTSHIFT, KEY_RIGHTSHIFT,

+ 3 - 2
drivers/input/tegra-kbc.c

@@ -321,6 +321,8 @@ static int init_tegra_keyboard(void)
 		debug("%s: No keyboard register found\n", __func__);
 		debug("%s: No keyboard register found\n", __func__);
 		return -1;
 		return -1;
 	}
 	}
+	input_set_delays(&config.input, KBC_REPEAT_DELAY_MS,
+			KBC_REPEAT_RATE_MS);
 
 
 	/* Decode the keyboard matrix information (16 rows, 8 columns) */
 	/* Decode the keyboard matrix information (16 rows, 8 columns) */
 	if (key_matrix_init(&config.matrix, 16, 8)) {
 	if (key_matrix_init(&config.matrix, 16, 8)) {
@@ -356,8 +358,7 @@ int drv_keyboard_init(void)
 {
 {
 	struct stdio_dev dev;
 	struct stdio_dev dev;
 
 
-	if (input_init(&config.input, 0, KBC_REPEAT_DELAY_MS,
-			KBC_REPEAT_RATE_MS)) {
+	if (input_init(&config.input, 0)) {
 		debug("%s: Cannot set up input\n", __func__);
 		debug("%s: Cannot set up input\n", __func__);
 		return -1;
 		return -1;
 	}
 	}

+ 10 - 4
include/input.h

@@ -125,17 +125,23 @@ int input_getc(struct input_config *config);
  */
  */
 int input_stdio_register(struct stdio_dev *dev);
 int input_stdio_register(struct stdio_dev *dev);
 
 
+/**
+ * Set up the keyboard autorepeat delays
+ *
+ * @param repeat_delay_ms	Delay before key auto-repeat starts (in ms)
+ * @param repeat_rate_ms	Delay between successive key repeats (in ms)
+ */
+void input_set_delays(struct input_config *config, int repeat_delay_ms,
+	       int repeat_rate_ms);
+
 /**
 /**
  * Set up the input handler with basic key maps.
  * Set up the input handler with basic key maps.
  *
  *
  * @param config	Input state
  * @param config	Input state
  * @param leds		Initial LED value (INPUT_LED_ mask), 0 suggested
  * @param leds		Initial LED value (INPUT_LED_ mask), 0 suggested
- * @param repeat_delay_ms	Delay before key auto-repeat starts (in ms)
- * @param repeat_rate_ms	Delay between successive key repeats (in ms)
  * @return 0 if ok, -1 on error
  * @return 0 if ok, -1 on error
  */
  */
-int input_init(struct input_config *config, int leds, int repeat_delay_ms,
-	       int repeat_rate_ms);
+int input_init(struct input_config *config, int leds);
 
 
 #ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
 #ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
 extern int overwrite_console(void);
 extern int overwrite_console(void);