[PATCH 3/4] hid-lenovo: Handle X1 Tablet cover FNLock function appropriately

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The FNLock state is not handled by the X1 tablet cover itself.
There is the need to set the FNLock LED which actually enables
the FNLock state of the cover. This means activating the FNLock LED
will enable FNLock state and FNLock LED.
---
 drivers/hid/hid-lenovo.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 2efd5b0..3ace8c3 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -526,6 +526,29 @@ static void lenovo_led_brightness_set_tpx1cover(struct led_classdev *led_cdev,
 	}
 }
 
+static int lenovo_event_tpx1cover(struct hid_device *hdev,
+		struct hid_field *field, struct hid_usage *usage, __s32 value)
+{
+	int ret = 0;
+
+	if (usage->hid == HID_CP_CONSUMERCONTROL) {
+		if (usage->usage_index == 8 && value == 1) {
+			struct lenovo_drvdata_tpx1cover *drv_data = hid_get_drvdata(hdev);
+
+			if (drv_data && drv_data->led_present) {
+				drv_data->fnlock_state = lenovo_led_brightness_get_tpx1cover(
+						&drv_data->led_fnlock) == LED_OFF ? 1 : 0;
+				lenovo_led_brightness_set_tpx1cover(
+					&drv_data->led_fnlock,
+					drv_data->fnlock_state ? LED_FULL : LED_OFF);
+			}
+		}
+
+	}
+
+	return ret;
+}
+
 static int lenovo_event(struct hid_device *hdev, struct hid_field *field,
 		struct hid_usage *usage, __s32 value)
 {
@@ -533,6 +556,8 @@ static int lenovo_event(struct hid_device *hdev, struct hid_field *field,
 	case USB_DEVICE_ID_LENOVO_CUSBKBD:
 	case USB_DEVICE_ID_LENOVO_CBTKBD:
 		return lenovo_event_cptkbd(hdev, field, usage, value);
+	case USB_DEVICE_ID_LENOVO_X1_COVER:
+		return lenovo_event_tpx1cover(hdev, field, usage, value);
 	default:
 		return 0;
 	}
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux