Re: [PATCH v4 6/6] Input: Add ChromeOS EC keyboard driver
From: Simon Glass <sjg@chromium.org>
Date: 2013-02-19 16:58:06
Also in:
linux-devicetree, lkml
Hi, On Tue, Feb 19, 2013 at 12:36 AM, li guang [off-list ref] wrote:
在 2013-02-15五的 20:16 -0800,Simon Glass写道:quoted
Use the key-matrix layer to interpret key scan information from the EC and inject input based on the FDT-supplied key map. This driver registers itself with the ChromeOS EC driver to perform communications.[snip ...]quoted
+/* + * Returns true when there is at least one combination of pressed keys that + * results in ghosting. + */ +static bool cros_ec_keyb_has_ghosting(struct cros_ec_keyb *ckdev, uint8_t *buf) +{ + int row; + + /* + * Ghosting happens if for any pressed key X there are other keys + * pressed both in the same row and column of X as, for instance, + * in the following diagram: + * + * . . Y . g . + * . . . . . . + * . . . . . . + * . . X . Z . + * + * In this case only X, Y, and Z are pressed, but g appears to be + * pressed too (see Wikipedia). + * + * We can detect ghosting in a single pass (*) over the keyboard state + * by maintaining two arrays. pressed_in_row counts how many pressed + * keys we have found in a row. row_has_teeth is true if any of the + * pressed keys for this row has other pressed keys in its column. If + * at any point of the scan we find that a row has multiple pressed + * keys, and at least one of them is at the intersection with a column + * with multiple pressed keys, we're sure there is ghosting. + * Conversely, if there is ghosting, we will detect such situation for + * at least one key during the pass. + * + * (*) This looks linear in the number of keys, but it's not. We can + * cheat because the number of rows is small. + */ + for (row = 0; row < ckdev->rows; row++) { + if (cros_ec_keyb_row_has_ghosting(ckdev, buf, row)) + return true; + } + + return false; +}are you sure your EC's firmware did not do ghost-key detection? or, did you test ghost-key with/without your own ghost-key detection? as far as I know, ghost-key should be take care either by keyboard designer or firmware.
Yes, the matrix scans are sent from the EC in a raw form - in fact the EC on snow does not even know the keycode map. The EC does handle debouncing though. The idea is to reduce code/complexity in the EC where we are space-constrained. [snip] Regards, Simon