input: Allow key ghosting filter to be disabled
Some keyboards will not need a key ghosting filter, so make this feature optional. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
1b1d3e6461
commit
71dc6bca4e
|
@ -46,6 +46,9 @@ static int has_ghosting(struct key_matrix *config, struct key_matrix_key *keys,
|
||||||
int key_in_same_col = 0, key_in_same_row = 0;
|
int key_in_same_col = 0, key_in_same_row = 0;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
|
if (!config->ghost_filter || valid < 3)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < valid; i++) {
|
for (i = 0; i < valid; i++) {
|
||||||
/*
|
/*
|
||||||
* Find 2 keys such that one key is in the same row
|
* Find 2 keys such that one key is in the same row
|
||||||
|
@ -92,7 +95,7 @@ int key_matrix_decode(struct key_matrix *config, struct key_matrix_key keys[],
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For a ghost key config, ignore the keypresses for this iteration. */
|
/* For a ghost key config, ignore the keypresses for this iteration. */
|
||||||
if (valid >= 3 && has_ghosting(config, keys, valid)) {
|
if (has_ghosting(config, keys, valid)) {
|
||||||
valid = 0;
|
valid = 0;
|
||||||
debug(" ghosting detected!\n");
|
debug(" ghosting detected!\n");
|
||||||
}
|
}
|
||||||
|
@ -200,12 +203,14 @@ int key_matrix_decode_fdt(struct key_matrix *config, const void *blob,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int key_matrix_init(struct key_matrix *config, int rows, int cols)
|
int key_matrix_init(struct key_matrix *config, int rows, int cols,
|
||||||
|
int ghost_filter)
|
||||||
{
|
{
|
||||||
memset(config, '\0', sizeof(*config));
|
memset(config, '\0', sizeof(*config));
|
||||||
config->num_rows = rows;
|
config->num_rows = rows;
|
||||||
config->num_cols = cols;
|
config->num_cols = cols;
|
||||||
config->key_count = rows * cols;
|
config->key_count = rows * cols;
|
||||||
|
config->ghost_filter = ghost_filter;
|
||||||
assert(config->key_count > 0);
|
assert(config->key_count > 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -325,7 +325,7 @@ static int init_tegra_keyboard(void)
|
||||||
KBC_REPEAT_RATE_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, 1)) {
|
||||||
debug("%s: Could not init key matrix\n", __func__);
|
debug("%s: Could not init key matrix\n", __func__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ struct key_matrix {
|
||||||
const u8 *plain_keycode; /* key code for each row / column */
|
const u8 *plain_keycode; /* key code for each row / column */
|
||||||
const u8 *fn_keycode; /* ...when Fn held down */
|
const u8 *fn_keycode; /* ...when Fn held down */
|
||||||
int fn_pos; /* position of Fn key in key (or -1) */
|
int fn_pos; /* position of Fn key in key (or -1) */
|
||||||
|
int ghost_filter; /* non-zero to enable ghost filter */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Information about a particular key (row, column pair) in the matrix */
|
/* Information about a particular key (row, column pair) in the matrix */
|
||||||
|
@ -92,8 +93,10 @@ int key_matrix_decode_fdt(struct key_matrix *config, const void *blob,
|
||||||
* @param config Keyboard matrix config
|
* @param config Keyboard matrix config
|
||||||
* @param rows Number of rows in key matrix
|
* @param rows Number of rows in key matrix
|
||||||
* @param cols Number of columns in key matrix
|
* @param cols Number of columns in key matrix
|
||||||
|
* @param ghost_filter Non-zero to enable ghost filtering
|
||||||
* @return 0 if ok, -1 on error
|
* @return 0 if ok, -1 on error
|
||||||
*/
|
*/
|
||||||
int key_matrix_init(struct key_matrix *config, int rows, int cols);
|
int key_matrix_init(struct key_matrix *config, int rows, int cols,
|
||||||
|
int ghost_filter);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue