summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Yung-Chieh Lo <yjlou@chromium.org>2011-10-31 23:44:22 +0800
committerLouis Yung-Chieh Lo <yjlou@chromium.org>2011-10-31 23:44:22 +0800
commit27e5806614f206c81211af1b6275ad0e3d895967 (patch)
tree2bcb9dab3bd8df705add5d0cca34f373ca627547
parentafa146d0396fc5b77c411d103384da63a3e456d2 (diff)
downloadchrome-ec-release-R17-1412.B.tar.gz
Add Chrome OS standard keyboard matrix table.release-R17-1412.B
BUG=None TEST=make && make runtests Change-Id: Ib9ae5ee445e473c27de703fc4dbc8cafa0eac468
-rw-r--r--board/board.c50
-rw-r--r--cros_ec/test/ec_keyboard_test.c24
2 files changed, 31 insertions, 43 deletions
diff --git a/board/board.c b/board/board.c
index 2e5e9cc49c..d466ec348b 100644
--- a/board/board.c
+++ b/board/board.c
@@ -13,34 +13,30 @@
#define CROS_COL_NUM 13
/* The standard Chrome OS keyboard matrix table. */
-static uint8_t maxtri_table[CROS_ROW_NUM][CROS_COL_NUM] = {
- /* FIXME: waiting for approval to open-source this table. */
-};
-static uint16_t scancode_set2[128] = {
- /* 0 */ 0x0000, 0x000E, 0x0016, 0x001E, 0x0026, 0x0025, 0x002E, 0x0036,
- /* 8 */ 0x003d, 0x003e, 0x0046, 0x0045, 0x004E, 0x0055, 0x0000, 0x0066,
- /* 16 */ 0x000d, 0x0015, 0x001d, 0x0024, 0x002d, 0x002c, 0x0035, 0x003c,
- /* 24 */ 0x0043, 0x0044, 0x004D, 0x0054, 0x005b, 0x005d, 0xE01F, 0x001c,
- /* 32 */ 0x001b, 0x0023, 0x002b, 0x0034, 0x0033, 0x003B, 0x0042, 0x004B,
- /* 40 */ 0x004C, 0x0052, 0x0000, 0x005A, 0x0012, 0x0000, 0x001A, 0x0022,
- /* 48 */ 0x0021, 0x002A, 0x0032, 0x0031, 0x003A, 0x0041, 0x0049, 0x004A,
- /* 56 */ 0x0000, 0x0059, 0x0014, 0xE037, 0x0011, 0x0029, 0xE011, 0x0000,
- /* 64 */ 0xE014, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 72 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xe06B,
- /* 80 */ 0x0000, 0x0000, 0x0000, 0xE075, 0xE072, 0x0000, 0x0000, 0x0000,
- /* 88 */ 0x0000, 0xE074, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 96 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 104 */ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0076, 0x0000,
- /* 112 */ 0x0005, 0x0006, 0x0004, 0x000c, 0x0003, 0x000b, 0x0083, 0x0009,
- /* 120 */ 0x0000, 0x000a, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+static uint16_t scancode_set2[CROS_ROW_NUM][CROS_COL_NUM] = {
+ {0x0000, 0xe01f, 0x0005, 0x0032, 0x0009, 0x0000, 0x0031, 0x0000, 0x0055,
+ 0x0000, 0xe011, 0x0000, 0x0000},
+ {0x0000, 0x0076, 0x000c, 0x0034, 0x0083, 0x0000, 0x0033, 0x0000, 0x0052,
+ 0x0001, 0x0000, 0x0066, 0x0000},
+ {0x0014, 0x000d, 0x0004, 0x002c, 0x000b, 0x005b, 0x0035, 0x0000, 0x0054,
+ 0x000a, 0x0000, 0x0000, 0x0000},
+ {0x0000, 0x000e, 0x0006, 0x002e, 0x0003, 0x0000, 0x0036, 0x0000, 0x004e,
+ 0x0000, 0x0000, 0x005d, 0x0000},
+ {0xe014, 0x001c, 0x0023, 0x002b, 0x001b, 0x0042, 0x003b, 0x0000, 0x004c,
+ 0x004b, 0x0000, 0x005a, 0x0000},
+ {0x0000, 0x001a, 0x0021, 0x002a, 0x0022, 0x0041, 0x003a, 0x0012, 0x004a,
+ 0x0049, 0x0000, 0x0029, 0x0000},
+ {0x0000, 0x0016, 0x0026, 0x0025, 0x001e, 0x003e, 0x003d, 0x0000, 0x0045,
+ 0x0046, 0x0011, 0xe072, 0xe074},
+ {0x0000, 0x0015, 0x0024, 0x002d, 0x001d, 0x0043, 0x003c, 0x0059, 0x004d,
+ 0x0044, 0x0000, 0xe075, 0xe06b},
};
static EcError MatrixCallback(
int8_t row, int8_t col, int8_t pressed,
enum EcScancodeSet code_set, uint8_t *scan_code, int32_t* len) {
- int key_index; /* the index og scancode_set */
uint16_t make_code;
EC_ASSERT(code_set == EC_SCANCODE_SET_2); /* TODO: support other sets? */
@@ -54,18 +50,10 @@ static EcError MatrixCallback(
*len = 0;
-#if 1 /* FIXME: remove #if after we can opensource the matrix table. */
- /* fake */
- maxtri_table[0][0] = scancode_set2[0]; // FIXME: to make compiler happy
- make_code = scancode_set2[key_index = row * 8 + col];
-#else
- key_index = maxtri_table[row][col];
- EC_ASSERT(key_index < (sizeof(scancode_set2) / sizeof(scancode_set2[0])));
- make_code = scancode_set2[key_index];
-#endif
+ make_code = scancode_set2[row][col];
+ EC_ASSERT(make_code); /* there must be a make code mapping to a key */
/* Output the make code (from table) */
- EC_ASSERT(make_code); /* there must be a make code mapping to a key */
if (make_code >= 0x0100) {
*len += 2;
scan_code[0] = make_code >> 8;
diff --git a/cros_ec/test/ec_keyboard_test.c b/cros_ec/test/ec_keyboard_test.c
index b84e179ece..bf9c2c595c 100644
--- a/cros_ec/test/ec_keyboard_test.c
+++ b/cros_ec/test/ec_keyboard_test.c
@@ -28,7 +28,7 @@ EcError TestKeyMade() {
/* Fake a key press */
SimulateKeyStateChange(2, 3, 1);
EC_ASSERT(EC_SUCCESS == PullI8042ScanCode(&buf));
- EC_ASSERT(buf == 0x24);
+ EC_ASSERT(buf == 0x2c);
EC_ASSERT(EC_ERROR_BUFFER_EMPTY == PullI8042ScanCode(&buf));
/* The duplicate press event will be ignored. */
@@ -36,11 +36,11 @@ EcError TestKeyMade() {
EC_ASSERT(EC_ERROR_BUFFER_EMPTY == PullI8042ScanCode(&buf));
/* Test 2-byte scan code */
- SimulateKeyStateChange(3, 6, 1);
+ SimulateKeyStateChange(7, 12, 1);
EC_ASSERT(EC_SUCCESS == PullI8042ScanCode(&buf));
EC_ASSERT(buf == 0xE0);
EC_ASSERT(EC_SUCCESS == PullI8042ScanCode(&buf));
- EC_ASSERT(buf == 0x1f);
+ EC_ASSERT(buf == 0x6b);
EC_ASSERT(EC_ERROR_BUFFER_EMPTY == PullI8042ScanCode(&buf));
return EC_SUCCESS;
@@ -50,35 +50,35 @@ EcError TestKeyReleased() {
uint8_t buf;
/* The key is not pressed yet. A release event doesn't send out a code. */
- SimulateKeyStateChange(0, 1, 0);
+ SimulateKeyStateChange(0, 2, 0);
EC_ASSERT(EC_ERROR_BUFFER_EMPTY == PullI8042ScanCode(&buf));
/* Press and release it. Expect a release code. */
- SimulateKeyStateChange(0, 1, 1);
+ SimulateKeyStateChange(0, 2, 1);
EC_ASSERT(EC_SUCCESS == PullI8042ScanCode(&buf));
- EC_ASSERT(buf == 0x0E);
+ EC_ASSERT(buf == 0x05);
EC_ASSERT(EC_ERROR_BUFFER_EMPTY == PullI8042ScanCode(&buf));
- SimulateKeyStateChange(0, 1, 0); /* release */
+ SimulateKeyStateChange(0, 2, 0); /* release */
EC_ASSERT(EC_SUCCESS == PullI8042ScanCode(&buf));
EC_ASSERT(buf == 0xF0);
EC_ASSERT(EC_SUCCESS == PullI8042ScanCode(&buf));
- EC_ASSERT(buf == 0x0E);
+ EC_ASSERT(buf == 0x05);
EC_ASSERT(EC_ERROR_BUFFER_EMPTY == PullI8042ScanCode(&buf));
/* Test 3-byte break code */
- SimulateKeyStateChange(7, 3, 1);
+ SimulateKeyStateChange(6, 11, 1);
EC_ASSERT(EC_SUCCESS == PullI8042ScanCode(&buf));
EC_ASSERT(buf == 0xE0);
EC_ASSERT(EC_SUCCESS == PullI8042ScanCode(&buf));
- EC_ASSERT(buf == 0x37);
+ EC_ASSERT(buf == 0x72);
EC_ASSERT(EC_ERROR_BUFFER_EMPTY == PullI8042ScanCode(&buf));
- SimulateKeyStateChange(7, 3, 0); /* release */
+ SimulateKeyStateChange(6, 11, 0); /* release */
EC_ASSERT(EC_SUCCESS == PullI8042ScanCode(&buf));
EC_ASSERT(buf == 0xE0);
EC_ASSERT(EC_SUCCESS == PullI8042ScanCode(&buf));
EC_ASSERT(buf == 0xF0);
EC_ASSERT(EC_SUCCESS == PullI8042ScanCode(&buf));
- EC_ASSERT(buf == 0x37);
+ EC_ASSERT(buf == 0x72);
EC_ASSERT(EC_ERROR_BUFFER_EMPTY == PullI8042ScanCode(&buf));
return EC_SUCCESS;