aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorAceLan Kao <acelan.kao@canonical.com>2013-03-08 02:44:30 -0500
committerMatthew Garrett <matthew.garrett@nebula.com>2013-05-08 19:59:43 -0400
commit5dd760b8131916dcf3680d1873d05df421c93a0c (patch)
tree0c7ed85ce5080713b5b1a6121d0b56cb29d20f06 /drivers/platform
parente0fd9affeb64088eff407dfc98bbd3a5c17ea479 (diff)
dell: add new dell WMI format for the AIO machines
There is a new DELL WMI spec. with new WMI event format. I'm working on the AIO machines, but I think the new format will apply to all the Dell's machines, not only for AIO, which will be released later this year. The new format of the WMI buffer is shown as below word 0 - the number of words following in the WMI buffer(not including this word. word 1 - the event type 0x0000 - A hot key is pressed or an event occurred 0x000F - A sequence of hot keys are pressed word 2 and on - the event data Signed-off-by: AceLan Kao <acelan.kao@canonical.com> Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/dell-wmi-aio.c53
1 files changed, 48 insertions, 5 deletions
diff --git a/drivers/platform/x86/dell-wmi-aio.c b/drivers/platform/x86/dell-wmi-aio.c
index 3f945457f71c..bcf8cc6b5537 100644
--- a/drivers/platform/x86/dell-wmi-aio.c
+++ b/drivers/platform/x86/dell-wmi-aio.c
@@ -34,6 +34,14 @@ MODULE_LICENSE("GPL");
34#define EVENT_GUID1 "284A0E6B-380E-472A-921F-E52786257FB4" 34#define EVENT_GUID1 "284A0E6B-380E-472A-921F-E52786257FB4"
35#define EVENT_GUID2 "02314822-307C-4F66-BF0E-48AEAEB26CC8" 35#define EVENT_GUID2 "02314822-307C-4F66-BF0E-48AEAEB26CC8"
36 36
37struct dell_wmi_event {
38 u16 length;
39 /* 0x000: A hot key pressed or an event occurred
40 * 0x00F: A sequence of hot keys are pressed */
41 u16 type;
42 u16 event[];
43};
44
37static const char *dell_wmi_aio_guids[] = { 45static const char *dell_wmi_aio_guids[] = {
38 EVENT_GUID1, 46 EVENT_GUID1,
39 EVENT_GUID2, 47 EVENT_GUID2,
@@ -46,15 +54,41 @@ MODULE_ALIAS("wmi:"EVENT_GUID2);
46static const struct key_entry dell_wmi_aio_keymap[] = { 54static const struct key_entry dell_wmi_aio_keymap[] = {
47 { KE_KEY, 0xc0, { KEY_VOLUMEUP } }, 55 { KE_KEY, 0xc0, { KEY_VOLUMEUP } },
48 { KE_KEY, 0xc1, { KEY_VOLUMEDOWN } }, 56 { KE_KEY, 0xc1, { KEY_VOLUMEDOWN } },
57 { KE_KEY, 0xe030, { KEY_VOLUMEUP } },
58 { KE_KEY, 0xe02e, { KEY_VOLUMEDOWN } },
59 { KE_KEY, 0xe020, { KEY_MUTE } },
60 { KE_KEY, 0xe027, { KEY_DISPLAYTOGGLE } },
61 { KE_KEY, 0xe006, { KEY_BRIGHTNESSUP } },
62 { KE_KEY, 0xe005, { KEY_BRIGHTNESSDOWN } },
63 { KE_KEY, 0xe00b, { KEY_SWITCHVIDEOMODE } },
49 { KE_END, 0 } 64 { KE_END, 0 }
50}; 65};
51 66
52static struct input_dev *dell_wmi_aio_input_dev; 67static struct input_dev *dell_wmi_aio_input_dev;
53 68
69/*
70 * The new WMI event data format will follow the dell_wmi_event structure
71 * So, we will check if the buffer matches the format
72 */
73static bool dell_wmi_aio_event_check(u8 *buffer, int length)
74{
75 struct dell_wmi_event *event = (struct dell_wmi_event *)buffer;
76
77 if (event == NULL || length < 6)
78 return false;
79
80 if ((event->type == 0 || event->type == 0xf) &&
81 event->length >= 2)
82 return true;
83
84 return false;
85}
86
54static void dell_wmi_aio_notify(u32 value, void *context) 87static void dell_wmi_aio_notify(u32 value, void *context)
55{ 88{
56 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; 89 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
57 union acpi_object *obj; 90 union acpi_object *obj;
91 struct dell_wmi_event *event;
58 acpi_status status; 92 acpi_status status;
59 93
60 status = wmi_get_event_data(value, &response); 94 status = wmi_get_event_data(value, &response);
@@ -65,7 +99,7 @@ static void dell_wmi_aio_notify(u32 value, void *context)
65 99
66 obj = (union acpi_object *)response.pointer; 100 obj = (union acpi_object *)response.pointer;
67 if (obj) { 101 if (obj) {
68 unsigned int scancode; 102 unsigned int scancode = 0;
69 103
70 switch (obj->type) { 104 switch (obj->type) {
71 case ACPI_TYPE_INTEGER: 105 case ACPI_TYPE_INTEGER:
@@ -75,13 +109,22 @@ static void dell_wmi_aio_notify(u32 value, void *context)
75 scancode, 1, true); 109 scancode, 1, true);
76 break; 110 break;
77 case ACPI_TYPE_BUFFER: 111 case ACPI_TYPE_BUFFER:
78 /* Broken machines return the scancode in a buffer */ 112 if (dell_wmi_aio_event_check(obj->buffer.pointer,
79 if (obj->buffer.pointer && obj->buffer.length > 0) { 113 obj->buffer.length)) {
80 scancode = obj->buffer.pointer[0]; 114 event = (struct dell_wmi_event *)
115 obj->buffer.pointer;
116 scancode = event->event[0];
117 } else {
118 /* Broken machines return the scancode in a
119 buffer */
120 if (obj->buffer.pointer &&
121 obj->buffer.length > 0)
122 scancode = obj->buffer.pointer[0];
123 }
124 if (scancode)
81 sparse_keymap_report_event( 125 sparse_keymap_report_event(
82 dell_wmi_aio_input_dev, 126 dell_wmi_aio_input_dev,
83 scancode, 1, true); 127 scancode, 1, true);
84 }
85 break; 128 break;
86 } 129 }
87 } 130 }