eeepc-wmi: add touchpad sysfs file
[firefly-linux-kernel-4.4.55.git] / drivers / platform / x86 / eeepc-wmi.c
index bc7133345674360cb64f6e9992a802ccad4238a8..16c7f2d62515d850dd99a21b2310de14914bf3bd 100644 (file)
@@ -77,7 +77,8 @@ MODULE_ALIAS("wmi:"EEEPC_WMI_MGMT_GUID);
 #define EEEPC_WMI_DEVID_BRIGHTNESS     0x00050012
 #define EEEPC_WMI_DEVID_CAMERA         0x00060013
 #define EEEPC_WMI_DEVID_CARDREADER     0x00080013
-#define EEEPC_WMI_DEVID_TPDLED         0x00100011
+#define EEEPC_WMI_DEVID_TOUCHPAD       0x00100011
+#define EEEPC_WMI_DEVID_TOUCHPAD_LED   0x00100012
 
 #define EEEPC_WMI_DSTS_STATUS_BIT      0x00000001
 #define EEEPC_WMI_DSTS_PRESENCE_BIT    0x00010000
@@ -99,13 +100,13 @@ static const struct key_entry eeepc_wmi_keymap[] = {
        { KE_KEY, 0x30, { KEY_VOLUMEUP } },
        { KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
        { KE_KEY, 0x32, { KEY_MUTE } },
-       { KE_KEY, 0x5c, { KEY_F15 } },
+       { KE_KEY, 0x5c, { KEY_F15 } }, /* Power Gear key */
        { KE_KEY, 0x5d, { KEY_WLAN } },
        { KE_KEY, 0x6b, { KEY_F13 } }, /* Disable Touchpad */
        { KE_KEY, 0x88, { KEY_WLAN } },
        { KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } },
-       { KE_KEY, 0xe0, { KEY_PROG1 } },
-       { KE_KEY, 0xe1, { KEY_F14 } },
+       { KE_KEY, 0xe0, { KEY_PROG1 } }, /* Task Manager */
+       { KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */
        { KE_KEY, 0xe9, { KEY_BRIGHTNESS_ZERO } },
        { KE_END, 0},
 };
@@ -303,7 +304,7 @@ static void tpd_led_update(struct work_struct *work)
        eeepc = container_of(work, struct eeepc_wmi, tpd_led_work);
 
        ctrl_param = eeepc->tpd_led_wk;
-       eeepc_wmi_set_devstate(EEEPC_WMI_DEVID_TPDLED, ctrl_param, NULL);
+       eeepc_wmi_set_devstate(EEEPC_WMI_DEVID_TOUCHPAD_LED, ctrl_param, NULL);
 }
 
 static void tpd_led_set(struct led_classdev *led_cdev,
@@ -317,9 +318,9 @@ static void tpd_led_set(struct led_classdev *led_cdev,
        queue_work(eeepc->led_workqueue, &eeepc->tpd_led_work);
 }
 
-static int read_tpd_state(struct eeepc_wmi *eeepc)
+static int read_tpd_led_state(struct eeepc_wmi *eeepc)
 {
-       return eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_TPDLED);
+       return eeepc_wmi_get_devstate_simple(EEEPC_WMI_DEVID_TOUCHPAD_LED);
 }
 
 static enum led_brightness tpd_led_get(struct led_classdev *led_cdev)
@@ -328,14 +329,14 @@ static enum led_brightness tpd_led_get(struct led_classdev *led_cdev)
 
        eeepc = container_of(led_cdev, struct eeepc_wmi, tpd_led);
 
-       return read_tpd_state(eeepc);
+       return read_tpd_led_state(eeepc);
 }
 
 static int eeepc_wmi_led_init(struct eeepc_wmi *eeepc)
 {
        int rv;
 
-       if (read_tpd_state(eeepc) < 0)
+       if (read_tpd_led_state(eeepc) < 0)
                return 0;
 
        eeepc->led_workqueue = create_singlethread_workqueue("led_workqueue");
@@ -1006,6 +1007,7 @@ static ssize_t show_sys_wmi(int devid, char *buf)
                .store  = store_##_name,                                \
        }
 
+EEEPC_WMI_CREATE_DEVICE_ATTR(touchpad, 0644, EEEPC_WMI_DEVID_TOUCHPAD);
 EEEPC_WMI_CREATE_DEVICE_ATTR(camera, 0644, EEEPC_WMI_DEVID_CAMERA);
 EEEPC_WMI_CREATE_DEVICE_ATTR(cardr, 0644, EEEPC_WMI_DEVID_CARDREADER);
 
@@ -1036,6 +1038,7 @@ static struct attribute *platform_attributes[] = {
        &dev_attr_cpufv.attr,
        &dev_attr_camera.attr,
        &dev_attr_cardr.attr,
+       &dev_attr_touchpad.attr,
        NULL
 };
 
@@ -1050,6 +1053,8 @@ static mode_t eeepc_sysfs_is_visible(struct kobject *kobj,
                devid = EEEPC_WMI_DEVID_CAMERA;
        else if (attr == &dev_attr_cardr.attr)
                devid = EEEPC_WMI_DEVID_CARDREADER;
+       else if (attr == &dev_attr_touchpad.attr)
+               devid = EEEPC_WMI_DEVID_TOUCHPAD;
 
        if (devid != -1)
                supported = eeepc_wmi_get_devstate_simple(devid) != -ENODEV;