sony-laptop: Make the driver use MSC_SCAN and a setkeycode and getkeycode key table.
The following is the only way I could think of to hide some events as per Dmitry suggestions while still using the default {set,get}keycode implementation. Make the driver use MSC_SCAN and a setkeycode and getkeycode key table. Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Richard Hughes <richard@hughsie.com> Signed-off-by: Mattia Dongili <malattia@linux.it> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
b25b732a16
commit
bc57f865fa
1 changed files with 140 additions and 50 deletions
|
@ -142,45 +142,124 @@ struct sony_laptop_keypress {
|
||||||
int key;
|
int key;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Correspondance table between sonypi events and input layer events */
|
/* Correspondance table between sonypi events
|
||||||
static struct {
|
* and input layer indexes in the keymap
|
||||||
int sonypiev;
|
*/
|
||||||
int inputev;
|
static int sony_laptop_input_index[] = {
|
||||||
} sony_laptop_inputkeys[] = {
|
-1, /* no event */
|
||||||
{ SONYPI_EVENT_CAPTURE_PRESSED, KEY_CAMERA },
|
-1, /* SONYPI_EVENT_JOGDIAL_DOWN */
|
||||||
{ SONYPI_EVENT_FNKEY_ONLY, KEY_FN },
|
-1, /* SONYPI_EVENT_JOGDIAL_UP */
|
||||||
{ SONYPI_EVENT_FNKEY_ESC, KEY_FN_ESC },
|
-1, /* SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */
|
||||||
{ SONYPI_EVENT_FNKEY_F1, KEY_FN_F1 },
|
-1, /* SONYPI_EVENT_JOGDIAL_UP_PRESSED */
|
||||||
{ SONYPI_EVENT_FNKEY_F2, KEY_FN_F2 },
|
-1, /* SONYPI_EVENT_JOGDIAL_PRESSED */
|
||||||
{ SONYPI_EVENT_FNKEY_F3, KEY_FN_F3 },
|
-1, /* SONYPI_EVENT_JOGDIAL_RELEASED */
|
||||||
{ SONYPI_EVENT_FNKEY_F4, KEY_FN_F4 },
|
0, /* SONYPI_EVENT_CAPTURE_PRESSED */
|
||||||
{ SONYPI_EVENT_FNKEY_F5, KEY_FN_F5 },
|
1, /* SONYPI_EVENT_CAPTURE_RELEASED */
|
||||||
{ SONYPI_EVENT_FNKEY_F6, KEY_FN_F6 },
|
2, /* SONYPI_EVENT_CAPTURE_PARTIALPRESSED */
|
||||||
{ SONYPI_EVENT_FNKEY_F7, KEY_FN_F7 },
|
3, /* SONYPI_EVENT_CAPTURE_PARTIALRELEASED */
|
||||||
{ SONYPI_EVENT_FNKEY_F8, KEY_FN_F8 },
|
4, /* SONYPI_EVENT_FNKEY_ESC */
|
||||||
{ SONYPI_EVENT_FNKEY_F9, KEY_FN_F9 },
|
5, /* SONYPI_EVENT_FNKEY_F1 */
|
||||||
{ SONYPI_EVENT_FNKEY_F10, KEY_FN_F10 },
|
6, /* SONYPI_EVENT_FNKEY_F2 */
|
||||||
{ SONYPI_EVENT_FNKEY_F11, KEY_FN_F11 },
|
7, /* SONYPI_EVENT_FNKEY_F3 */
|
||||||
{ SONYPI_EVENT_FNKEY_F12, KEY_FN_F12 },
|
8, /* SONYPI_EVENT_FNKEY_F4 */
|
||||||
{ SONYPI_EVENT_FNKEY_1, KEY_FN_1 },
|
9, /* SONYPI_EVENT_FNKEY_F5 */
|
||||||
{ SONYPI_EVENT_FNKEY_2, KEY_FN_2 },
|
10, /* SONYPI_EVENT_FNKEY_F6 */
|
||||||
{ SONYPI_EVENT_FNKEY_D, KEY_FN_D },
|
11, /* SONYPI_EVENT_FNKEY_F7 */
|
||||||
{ SONYPI_EVENT_FNKEY_E, KEY_FN_E },
|
12, /* SONYPI_EVENT_FNKEY_F8 */
|
||||||
{ SONYPI_EVENT_FNKEY_F, KEY_FN_F },
|
13, /* SONYPI_EVENT_FNKEY_F9 */
|
||||||
{ SONYPI_EVENT_FNKEY_S, KEY_FN_S },
|
14, /* SONYPI_EVENT_FNKEY_F10 */
|
||||||
{ SONYPI_EVENT_FNKEY_B, KEY_FN_B },
|
15, /* SONYPI_EVENT_FNKEY_F11 */
|
||||||
{ SONYPI_EVENT_BLUETOOTH_PRESSED, KEY_BLUE },
|
16, /* SONYPI_EVENT_FNKEY_F12 */
|
||||||
{ SONYPI_EVENT_BLUETOOTH_ON, KEY_BLUE },
|
17, /* SONYPI_EVENT_FNKEY_1 */
|
||||||
{ SONYPI_EVENT_PKEY_P1, KEY_PROG1 },
|
18, /* SONYPI_EVENT_FNKEY_2 */
|
||||||
{ SONYPI_EVENT_PKEY_P2, KEY_PROG2 },
|
19, /* SONYPI_EVENT_FNKEY_D */
|
||||||
{ SONYPI_EVENT_PKEY_P3, KEY_PROG3 },
|
20, /* SONYPI_EVENT_FNKEY_E */
|
||||||
{ SONYPI_EVENT_BACK_PRESSED, KEY_BACK },
|
21, /* SONYPI_EVENT_FNKEY_F */
|
||||||
{ SONYPI_EVENT_HELP_PRESSED, KEY_HELP },
|
22, /* SONYPI_EVENT_FNKEY_S */
|
||||||
{ SONYPI_EVENT_ZOOM_PRESSED, KEY_ZOOM },
|
23, /* SONYPI_EVENT_FNKEY_B */
|
||||||
{ SONYPI_EVENT_WIRELESS_ON, KEY_WLAN },
|
24, /* SONYPI_EVENT_BLUETOOTH_PRESSED */
|
||||||
{ SONYPI_EVENT_WIRELESS_OFF, KEY_WLAN },
|
25, /* SONYPI_EVENT_PKEY_P1 */
|
||||||
{ SONYPI_EVENT_THUMBPHRASE_PRESSED, BTN_THUMB },
|
26, /* SONYPI_EVENT_PKEY_P2 */
|
||||||
{ 0, 0 },
|
27, /* SONYPI_EVENT_PKEY_P3 */
|
||||||
|
28, /* SONYPI_EVENT_BACK_PRESSED */
|
||||||
|
-1, /* SONYPI_EVENT_LID_CLOSED */
|
||||||
|
-1, /* SONYPI_EVENT_LID_OPENED */
|
||||||
|
29, /* SONYPI_EVENT_BLUETOOTH_ON */
|
||||||
|
30, /* SONYPI_EVENT_BLUETOOTH_OFF */
|
||||||
|
31, /* SONYPI_EVENT_HELP_PRESSED */
|
||||||
|
32, /* SONYPI_EVENT_FNKEY_ONLY */
|
||||||
|
33, /* SONYPI_EVENT_JOGDIAL_FAST_DOWN */
|
||||||
|
34, /* SONYPI_EVENT_JOGDIAL_FAST_UP */
|
||||||
|
35, /* SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */
|
||||||
|
36, /* SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */
|
||||||
|
37, /* SONYPI_EVENT_JOGDIAL_VFAST_DOWN */
|
||||||
|
38, /* SONYPI_EVENT_JOGDIAL_VFAST_UP */
|
||||||
|
39, /* SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */
|
||||||
|
40, /* SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */
|
||||||
|
41, /* SONYPI_EVENT_ZOOM_PRESSED */
|
||||||
|
42, /* SONYPI_EVENT_THUMBPHRASE_PRESSED */
|
||||||
|
43, /* SONYPI_EVENT_MEYE_FACE */
|
||||||
|
44, /* SONYPI_EVENT_MEYE_OPPOSITE */
|
||||||
|
45, /* SONYPI_EVENT_MEMORYSTICK_INSERT */
|
||||||
|
46, /* SONYPI_EVENT_MEMORYSTICK_EJECT */
|
||||||
|
-1, /* SONYPI_EVENT_ANYBUTTON_RELEASED */
|
||||||
|
-1, /* SONYPI_EVENT_BATTERY_INSERT */
|
||||||
|
-1, /* SONYPI_EVENT_BATTERY_REMOVE */
|
||||||
|
-1, /* SONYPI_EVENT_FNKEY_RELEASED */
|
||||||
|
47, /* SONYPI_EVENT_WIRELESS_ON */
|
||||||
|
48, /* SONYPI_EVENT_WIRELESS_OFF */
|
||||||
|
};
|
||||||
|
|
||||||
|
static int sony_laptop_input_keycode_map[] = {
|
||||||
|
KEY_CAMERA, /* 0 SONYPI_EVENT_CAPTURE_PRESSED */
|
||||||
|
KEY_RESERVED, /* 1 SONYPI_EVENT_CAPTURE_RELEASED */
|
||||||
|
KEY_RESERVED, /* 2 SONYPI_EVENT_CAPTURE_PARTIALPRESSED */
|
||||||
|
KEY_RESERVED, /* 3 SONYPI_EVENT_CAPTURE_PARTIALRELEASED */
|
||||||
|
KEY_FN_ESC, /* 4 SONYPI_EVENT_FNKEY_ESC */
|
||||||
|
KEY_FN_F1, /* 5 SONYPI_EVENT_FNKEY_F1 */
|
||||||
|
KEY_FN_F2, /* 6 SONYPI_EVENT_FNKEY_F2 */
|
||||||
|
KEY_FN_F3, /* 7 SONYPI_EVENT_FNKEY_F3 */
|
||||||
|
KEY_FN_F4, /* 8 SONYPI_EVENT_FNKEY_F4 */
|
||||||
|
KEY_FN_F5, /* 9 SONYPI_EVENT_FNKEY_F5 */
|
||||||
|
KEY_FN_F6, /* 10 SONYPI_EVENT_FNKEY_F6 */
|
||||||
|
KEY_FN_F7, /* 11 SONYPI_EVENT_FNKEY_F7 */
|
||||||
|
KEY_FN_F8, /* 12 SONYPI_EVENT_FNKEY_F8 */
|
||||||
|
KEY_FN_F9, /* 13 SONYPI_EVENT_FNKEY_F9 */
|
||||||
|
KEY_FN_F10, /* 14 SONYPI_EVENT_FNKEY_F10 */
|
||||||
|
KEY_FN_F11, /* 15 SONYPI_EVENT_FNKEY_F11 */
|
||||||
|
KEY_FN_F12, /* 16 SONYPI_EVENT_FNKEY_F12 */
|
||||||
|
KEY_FN_F1, /* 17 SONYPI_EVENT_FNKEY_1 */
|
||||||
|
KEY_FN_F2, /* 18 SONYPI_EVENT_FNKEY_2 */
|
||||||
|
KEY_FN_D, /* 19 SONYPI_EVENT_FNKEY_D */
|
||||||
|
KEY_FN_E, /* 20 SONYPI_EVENT_FNKEY_E */
|
||||||
|
KEY_FN_F, /* 21 SONYPI_EVENT_FNKEY_F */
|
||||||
|
KEY_FN_S, /* 22 SONYPI_EVENT_FNKEY_S */
|
||||||
|
KEY_FN_B, /* 23 SONYPI_EVENT_FNKEY_B */
|
||||||
|
KEY_BLUETOOTH, /* 24 SONYPI_EVENT_BLUETOOTH_PRESSED */
|
||||||
|
KEY_PROG1, /* 25 SONYPI_EVENT_PKEY_P1 */
|
||||||
|
KEY_PROG2, /* 26 SONYPI_EVENT_PKEY_P2 */
|
||||||
|
KEY_PROG3, /* 27 SONYPI_EVENT_PKEY_P3 */
|
||||||
|
KEY_BACK, /* 28 SONYPI_EVENT_BACK_PRESSED */
|
||||||
|
KEY_BLUETOOTH, /* 29 SONYPI_EVENT_BLUETOOTH_ON */
|
||||||
|
KEY_BLUETOOTH, /* 30 SONYPI_EVENT_BLUETOOTH_OFF */
|
||||||
|
KEY_HELP, /* 31 SONYPI_EVENT_HELP_PRESSED */
|
||||||
|
KEY_FN, /* 32 SONYPI_EVENT_FNKEY_ONLY */
|
||||||
|
KEY_RESERVED, /* 33 SONYPI_EVENT_JOGDIAL_FAST_DOWN */
|
||||||
|
KEY_RESERVED, /* 34 SONYPI_EVENT_JOGDIAL_FAST_UP */
|
||||||
|
KEY_RESERVED, /* 35 SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */
|
||||||
|
KEY_RESERVED, /* 36 SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */
|
||||||
|
KEY_RESERVED, /* 37 SONYPI_EVENT_JOGDIAL_VFAST_DOWN */
|
||||||
|
KEY_RESERVED, /* 38 SONYPI_EVENT_JOGDIAL_VFAST_UP */
|
||||||
|
KEY_RESERVED, /* 39 SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */
|
||||||
|
KEY_RESERVED, /* 40 SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */
|
||||||
|
KEY_ZOOM, /* 41 SONYPI_EVENT_ZOOM_PRESSED */
|
||||||
|
BTN_THUMB, /* 42 SONYPI_EVENT_THUMBPHRASE_PRESSED */
|
||||||
|
KEY_RESERVED, /* 43 SONYPI_EVENT_MEYE_FACE */
|
||||||
|
KEY_RESERVED, /* 44 SONYPI_EVENT_MEYE_OPPOSITE */
|
||||||
|
KEY_RESERVED, /* 45 SONYPI_EVENT_MEMORYSTICK_INSERT */
|
||||||
|
KEY_RESERVED, /* 46 SONYPI_EVENT_MEMORYSTICK_EJECT */
|
||||||
|
KEY_WLAN, /* 47 SONYPI_EVENT_WIRELESS_ON */
|
||||||
|
KEY_WLAN, /* 48 SONYPI_EVENT_WIRELESS_OFF */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* release buttons after a short delay if pressed */
|
/* release buttons after a short delay if pressed */
|
||||||
|
@ -204,7 +283,6 @@ static void sony_laptop_report_input_event(u8 event)
|
||||||
struct input_dev *jog_dev = sony_laptop_input.jog_dev;
|
struct input_dev *jog_dev = sony_laptop_input.jog_dev;
|
||||||
struct input_dev *key_dev = sony_laptop_input.key_dev;
|
struct input_dev *key_dev = sony_laptop_input.key_dev;
|
||||||
struct sony_laptop_keypress kp = { NULL };
|
struct sony_laptop_keypress kp = { NULL };
|
||||||
int i;
|
|
||||||
|
|
||||||
if (event == SONYPI_EVENT_FNKEY_RELEASED) {
|
if (event == SONYPI_EVENT_FNKEY_RELEASED) {
|
||||||
/* Nothing, not all VAIOs generate this event */
|
/* Nothing, not all VAIOs generate this event */
|
||||||
|
@ -233,17 +311,22 @@ static void sony_laptop_report_input_event(u8 event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
for (i = 0; sony_laptop_inputkeys[i].sonypiev; i++)
|
if (event > ARRAY_SIZE (sony_laptop_input_keycode_map)) {
|
||||||
if (event == sony_laptop_inputkeys[i].sonypiev) {
|
dprintk("sony_laptop_report_input_event, event not known: %d\n", event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (sony_laptop_input_index[event] != -1) {
|
||||||
|
kp.key = sony_laptop_input_keycode_map[sony_laptop_input_index[event]];
|
||||||
|
if (kp.key != KEY_UNKNOWN)
|
||||||
kp.dev = key_dev;
|
kp.dev = key_dev;
|
||||||
kp.key = sony_laptop_inputkeys[i].inputev;
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kp.dev) {
|
if (kp.dev) {
|
||||||
input_report_key(kp.dev, kp.key, 1);
|
input_report_key(kp.dev, kp.key, 1);
|
||||||
|
/* we emit the scancode so we can always remap the key */
|
||||||
|
input_event(kp.dev, EV_MSC, MSC_SCAN, event);
|
||||||
input_sync(kp.dev);
|
input_sync(kp.dev);
|
||||||
kfifo_put(sony_laptop_input.fifo,
|
kfifo_put(sony_laptop_input.fifo,
|
||||||
(unsigned char *)&kp, sizeof(kp));
|
(unsigned char *)&kp, sizeof(kp));
|
||||||
|
@ -298,11 +381,18 @@ static int sony_laptop_setup_input(void)
|
||||||
key_dev->id.vendor = PCI_VENDOR_ID_SONY;
|
key_dev->id.vendor = PCI_VENDOR_ID_SONY;
|
||||||
|
|
||||||
/* Initialize the Input Drivers: special keys */
|
/* Initialize the Input Drivers: special keys */
|
||||||
key_dev->evbit[0] = BIT(EV_KEY);
|
set_bit(EV_KEY, key_dev->evbit);
|
||||||
for (i = 0; sony_laptop_inputkeys[i].sonypiev; i++)
|
set_bit(EV_MSC, key_dev->evbit);
|
||||||
if (sony_laptop_inputkeys[i].inputev)
|
set_bit(MSC_SCAN, key_dev->mscbit);
|
||||||
set_bit(sony_laptop_inputkeys[i].inputev,
|
key_dev->keycodesize = sizeof(sony_laptop_input_keycode_map[0]);
|
||||||
key_dev->keybit);
|
key_dev->keycodemax = ARRAY_SIZE(sony_laptop_input_keycode_map);
|
||||||
|
key_dev->keycode = &sony_laptop_input_keycode_map;
|
||||||
|
for (i = 0; i < ARRAY_SIZE(sony_laptop_input_keycode_map); i++) {
|
||||||
|
if (sony_laptop_input_keycode_map[i] != KEY_RESERVED) {
|
||||||
|
set_bit(sony_laptop_input_keycode_map[i],
|
||||||
|
key_dev->keybit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
error = input_register_device(key_dev);
|
error = input_register_device(key_dev);
|
||||||
if (error)
|
if (error)
|
||||||
|
|
Loading…
Reference in a new issue