]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Input: pxa27x-keypad - use matrix_keymap for matrix keys
authorChao Xie <chao.xie@marvell.com>
Mon, 6 May 2013 03:24:58 +0000 (20:24 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 11 Jun 2013 05:29:03 +0000 (22:29 -0700)
pxa27x-keypad includes matrix keys. Make use of matrix_keymap
for the matrix keys.

Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
arch/arm/mach-mmp/aspenite.c
arch/arm/mach-mmp/teton_bga.c
drivers/input/keyboard/Kconfig
drivers/input/keyboard/pxa27x_keypad.c
include/linux/platform_data/keypad-pxa27x.h

index 9f64d5632e07af34ab02e2f67ed07937c98ac77b..1e233467fffa3b1f87411f8aa889bedc4386480e 100644 (file)
@@ -205,7 +205,7 @@ struct pxa168fb_mach_info aspenite_lcd_info = {
        .invert_pixclock        = 0,
 };
 
-static unsigned int aspenite_matrix_key_map[] = {
+static const unsigned int aspenite_matrix_key_map[] = {
        KEY(0, 6, KEY_UP),      /* SW 4 */
        KEY(0, 7, KEY_DOWN),    /* SW 5 */
        KEY(1, 6, KEY_LEFT),    /* SW 6 */
@@ -214,11 +214,15 @@ static unsigned int aspenite_matrix_key_map[] = {
        KEY(4, 7, KEY_ESC),     /* SW 9 */
 };
 
+static struct matrix_keymap_data aspenite_matrix_keymap_data = {
+       .keymap                 = aspenite_matrix_key_map,
+       .keymap_size            = ARRAY_SIZE(aspenite_matrix_key_map),
+};
+
 static struct pxa27x_keypad_platform_data aspenite_keypad_info __initdata = {
        .matrix_key_rows        = 5,
        .matrix_key_cols        = 8,
-       .matrix_key_map         = aspenite_matrix_key_map,
-       .matrix_key_map_size    = ARRAY_SIZE(aspenite_matrix_key_map),
+       .matrix_keymap_data     = &aspenite_matrix_keymap_data,
        .debounce_interval      = 30,
 };
 
index 8609967975ed9039e56b643ddd07ee52e0e3b12a..d8967fa483743bbfcc3aff542b67b176899195c5 100644 (file)
@@ -56,11 +56,15 @@ static unsigned int teton_bga_matrix_key_map[] = {
        KEY(1, 7, KEY_RIGHT),
 };
 
+static struct matrix_keymap_data teton_bga_matrix_keymap_data = {
+       .keymap                 = teton_bga_matrix_key_map,
+       .keymap_size            = ARRAY_SIZE(teton_bga_matrix_key_map),
+};
+
 static struct pxa27x_keypad_platform_data teton_bga_keypad_info __initdata = {
        .matrix_key_rows        = 2,
        .matrix_key_cols        = 8,
-       .matrix_key_map         = teton_bga_matrix_key_map,
-       .matrix_key_map_size    = ARRAY_SIZE(teton_bga_matrix_key_map),
+       .matrix_keymap_data     = &teton_bga_matrix_keymap_data,
        .debounce_interval      = 30,
 };
 
index 37c366623fc099f5cbc1109bbcbd23404245d0e9..706e11bb6a32f08503a5bc14225969a9b4921c13 100644 (file)
@@ -451,6 +451,7 @@ config KEYBOARD_OPENCORES
 config KEYBOARD_PXA27x
        tristate "PXA27x/PXA3xx keypad support"
        depends on PXA27x || PXA3xx || ARCH_MMP
+       select INPUT_MATRIXKMAP
        help
          Enable support for PXA27x/PXA3xx keypad controller.
 
index b674e7aca404016834f28eb9be4cfacc4f37bc99..5b2d8764dd37b712e49549cded3f195817c12b32 100644 (file)
@@ -118,25 +118,30 @@ struct pxa27x_keypad {
        unsigned int direct_key_mask;
 };
 
-static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
+static int pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
 {
        struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
        struct input_dev *input_dev = keypad->input_dev;
+       const struct matrix_keymap_data *keymap_data =
+                               pdata ? pdata->matrix_keymap_data : NULL;
        unsigned short keycode;
        int i;
+       int error;
 
-       for (i = 0; i < pdata->matrix_key_map_size; i++) {
-               unsigned int key = pdata->matrix_key_map[i];
-               unsigned int row = KEY_ROW(key);
-               unsigned int col = KEY_COL(key);
-               unsigned int scancode = MATRIX_SCAN_CODE(row, col,
-                                                        MATRIX_ROW_SHIFT);
+       error = matrix_keypad_build_keymap(keymap_data, NULL,
+                                          pdata->matrix_key_rows,
+                                          pdata->matrix_key_cols,
+                                          keypad->keycodes, input_dev);
+       if (error)
+               return error;
 
-               keycode = KEY_VAL(key);
-               keypad->keycodes[scancode] = keycode;
-               __set_bit(keycode, input_dev->keybit);
-       }
+       /*
+        * The keycodes may not only include matrix keys but also the direct
+        * or rotary keys.
+        */
+       input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
 
+       /* For direct keys. */
        for (i = 0; i < pdata->direct_key_num; i++) {
                keycode = pdata->direct_key_map[i];
                keypad->keycodes[MAX_MATRIX_KEY_NUM + i] = keycode;
@@ -178,6 +183,8 @@ static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
        }
 
        __clear_bit(KEY_RESERVED, input_dev->keybit);
+
+       return 0;
 }
 
 static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad)
@@ -555,7 +562,11 @@ static int pxa27x_keypad_probe(struct platform_device *pdev)
        input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
        input_set_capability(input_dev, EV_MSC, MSC_SCAN);
 
-       pxa27x_keypad_build_keycode(keypad);
+       error = pxa27x_keypad_build_keycode(keypad);
+       if (error) {
+               dev_err(&pdev->dev, "failed to build keycode\n");
+               goto failed_put_clk;
+       }
 
        if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) ||
            (pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) {
index 5ce8d5e6ea518e7f4d0303b4d4ac066dcd294224..24625569d16df600ed258a9c23c7c69be89fbaca 100644 (file)
 struct pxa27x_keypad_platform_data {
 
        /* code map for the matrix keys */
+       const struct matrix_keymap_data *matrix_keymap_data;
        unsigned int    matrix_key_rows;
        unsigned int    matrix_key_cols;
-       unsigned int    *matrix_key_map;
-       int             matrix_key_map_size;
 
        /* direct keys */
        int             direct_key_num;