Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 250497
b: refs/heads/master
c: 34abeeb
h: refs/heads/master
i:
  250495: 768805a
v: v3
  • Loading branch information
Rakesh Iyer authored and Dmitry Torokhov committed Apr 28, 2011
1 parent 2ae357c commit 5639b64
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5c9db64888ecabfb170081335f30e3d7192fbcf4
refs/heads/master: 34abeeb23575c9c25b8c582d582e5bcfcd1cf338
1 change: 1 addition & 0 deletions trunk/arch/arm/mach-tegra/include/mach/kbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ struct tegra_kbc_platform_data {

bool wakeup;
bool use_fn_map;
bool use_ghost_filter;
};
#endif
36 changes: 36 additions & 0 deletions trunk/drivers/input/keyboard/tegra-kbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct tegra_kbc {
unsigned int repoll_dly;
unsigned long cp_dly_jiffies;
bool use_fn_map;
bool use_ghost_filter;
const struct tegra_kbc_platform_data *pdata;
unsigned short keycode[KBC_MAX_KEY * 2];
unsigned short current_keys[KBC_MAX_KPENT];
Expand Down Expand Up @@ -260,6 +261,8 @@ static void tegra_kbc_report_keys(struct tegra_kbc *kbc)
unsigned int num_down = 0;
unsigned long flags;
bool fn_keypress = false;
bool key_in_same_row = false;
bool key_in_same_col = false;

spin_lock_irqsave(&kbc->lock, flags);
for (i = 0; i < KBC_MAX_KPENT; i++) {
Expand All @@ -284,6 +287,34 @@ static void tegra_kbc_report_keys(struct tegra_kbc *kbc)
val >>= 8;
}

/*
* Matrix keyboard designs are prone to keyboard ghosting.
* Ghosting occurs if there are 3 keys such that -
* any 2 of the 3 keys share a row, and any 2 of them share a column.
* If so ignore the key presses for this iteration.
*/
if ((kbc->use_ghost_filter) && (num_down >= 3)) {
for (i = 0; i < num_down; i++) {
unsigned int j;
u8 curr_col = scancodes[i] & 0x07;
u8 curr_row = scancodes[i] >> KBC_ROW_SHIFT;

/*
* Find 2 keys such that one key is in the same row
* and the other is in the same column as the i-th key.
*/
for (j = i + 1; j < num_down; j++) {
u8 col = scancodes[j] & 0x07;
u8 row = scancodes[j] >> KBC_ROW_SHIFT;

if (col == curr_col)
key_in_same_col = true;
if (row == curr_row)
key_in_same_row = true;
}
}
}

/*
* If the platform uses Fn keymaps, translate keys on a Fn keypress.
* Function keycodes are KBC_MAX_KEY apart from the plain keycodes.
Expand All @@ -297,6 +328,10 @@ static void tegra_kbc_report_keys(struct tegra_kbc *kbc)

spin_unlock_irqrestore(&kbc->lock, flags);

/* Ignore the key presses for this iteration? */
if (key_in_same_col && key_in_same_row)
return;

tegra_kbc_report_released_keys(kbc->idev,
kbc->current_keys, kbc->num_pressed_keys,
keycodes, num_down);
Expand Down Expand Up @@ -652,6 +687,7 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)
input_dev->keycodemax *= 2;

kbc->use_fn_map = pdata->use_fn_map;
kbc->use_ghost_filter = pdata->use_ghost_filter;
keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data;
matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT,
input_dev->keycode, input_dev->keybit);
Expand Down

0 comments on commit 5639b64

Please sign in to comment.