omap3-pandora-kernel2: update
[openpandora.oe.git] / recipes / linux / omap3-pandora-kernel / keypad / 0004-Input-matrix-keypad-add-function-to-build-device-key.patch
1 From 81d264643825f8318c2e0ca39a8b5ce6a4ce3a5a Mon Sep 17 00:00:00 2001
2 From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
3 Date: Tue, 3 Nov 2009 15:49:37 +0200
4 Subject: [PATCH 4/7] Input: matrix-keypad - add function to build device keymap
5
6 Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
7 (cherry picked from commit 77a53fd21870c726b670c0d8179294ac1ea33468)
8
9 Conflicts:
10
11         drivers/input/keyboard/w90p910_keypad.c
12 ---
13  drivers/input/keyboard/matrix_keypad.c |   15 +++------------
14  include/linux/input/matrix_keypad.h    |   32 ++++++++++++++++++++++++++++++++
15  2 files changed, 35 insertions(+), 12 deletions(-)
16
17 diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
18 index 541b981..91cfe51 100644
19 --- a/drivers/input/keyboard/matrix_keypad.c
20 +++ b/drivers/input/keyboard/matrix_keypad.c
21 @@ -319,7 +319,6 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
22         struct input_dev *input_dev;
23         unsigned short *keycodes;
24         unsigned int row_shift;
25 -       int i;
26         int err;
27  
28         pdata = pdev->dev.platform_data;
29 @@ -363,18 +362,10 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
30  
31         input_dev->keycode      = keycodes;
32         input_dev->keycodesize  = sizeof(*keycodes);
33 -       input_dev->keycodemax   = pdata->num_row_gpios << keypad->row_shift;
34 -
35 -       for (i = 0; i < keymap_data->keymap_size; i++) {
36 -               unsigned int key = keymap_data->keymap[i];
37 -               unsigned int row = KEY_ROW(key);
38 -               unsigned int col = KEY_COL(key);
39 -               unsigned short code = KEY_VAL(key);
40 +       input_dev->keycodemax   = pdata->num_row_gpios << row_shift;
41  
42 -               keycodes[MATRIX_SCAN_CODE(row, col, row_shift)] = code;
43 -               __set_bit(code, input_dev->keybit);
44 -       }
45 -       __clear_bit(KEY_RESERVED, input_dev->keybit);
46 +       matrix_keypad_build_keymap(keymap_data, row_shift,
47 +                                  input_dev->keycode, input_dev->keybit);
48  
49         input_set_capability(input_dev, EV_MSC, MSC_SCAN);
50         input_set_drvdata(input_dev, keypad);
51 diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
52 index 15d5903..b3cd42d 100644
53 --- a/include/linux/input/matrix_keypad.h
54 +++ b/include/linux/input/matrix_keypad.h
55 @@ -63,4 +63,36 @@ struct matrix_keypad_platform_data {
56         bool            wakeup;
57  };
58  
59 +/**
60 + * matrix_keypad_build_keymap - convert platform keymap into matrix keymap
61 + * @keymap_data: keymap supplied by the platform code
62 + * @row_shift: number of bits to shift row value by to advance to the next
63 + * line in the keymap
64 + * @keymap: expanded version of keymap that is suitable for use by
65 + * matrix keyboad driver
66 + * @keybit: pointer to bitmap of keys supported by input device
67 + *
68 + * This function converts platform keymap (encoded with KEY() macro) into
69 + * an array of keycodes that is suitable for using in a standard matrix
70 + * keyboard driver that uses row and col as indices.
71 + */
72 +static inline void
73 +matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
74 +                          unsigned int row_shift,
75 +                          unsigned short *keymap, unsigned long *keybit)
76 +{
77 +       int i;
78 +
79 +       for (i = 0; i < keymap_data->keymap_size; i++) {
80 +               unsigned int key = keymap_data->keymap[i];
81 +               unsigned int row = KEY_ROW(key);
82 +               unsigned int col = KEY_COL(key);
83 +               unsigned short code = KEY_VAL(key);
84 +
85 +               keymap[MATRIX_SCAN_CODE(row, col, row_shift)] = code;
86 +               __set_bit(code, keybit);
87 +       }
88 +       __clear_bit(KEY_RESERVED, keybit);
89 +}
90 +
91  #endif /* _MATRIX_KEYPAD_H */
92 -- 
93 1.6.3.1
94