[PATCH] HID: apple: Add quirk to disable fn key on some non-apple keyboards

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

 



---
 drivers/hid/hid-apple.c | 54 +++++++++++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 15 deletions(-)

diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 49812a76b..9d4cbe636 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -42,6 +42,7 @@
 #define APPLE_BACKLIGHT_CTL	BIT(10)
 #define APPLE_IS_NON_APPLE	BIT(11)
 #define APPLE_MAGIC_BACKLIGHT	BIT(12)
+#define APPLE_DISABLE_FN	BIT(13)
 
 #define APPLE_FLAG_FKEY		0x01
 
@@ -89,6 +90,19 @@ struct apple_sc_backlight {
 	struct hid_device *hdev;
 };
 
+struct apple_backlight_config_report {
+	u8 report_id;
+	u8 version;
+	u16 backlight_off, backlight_on_min, backlight_on_max;
+};
+
+struct apple_backlight_set_report {
+	u8 report_id;
+	u8 version;
+	u16 backlight;
+	u16 rate;
+};
+
 struct apple_magic_backlight {
 	struct led_classdev cdev;
 	struct hid_report *brightness;
@@ -152,20 +166,6 @@ static const struct apple_key_translation magic_keyboard_2015_fn_keys[] = {
 	{ }
 };
 
-struct apple_backlight_config_report {
-	u8 report_id;
-	u8 version;
-	u16 backlight_off, backlight_on_min, backlight_on_max;
-};
-
-struct apple_backlight_set_report {
-	u8 report_id;
-	u8 version;
-	u16 backlight;
-	u16 rate;
-};
-
-
 static const struct apple_key_translation apple2021_fn_keys[] = {
 	{ KEY_BACKSPACE, KEY_DELETE },
 	{ KEY_ENTER,	KEY_INSERT },
@@ -364,6 +364,10 @@ static const struct apple_non_apple_keyboard non_apple_keyboards[] = {
 	{ "WKB603" },
 };
 
+static const struct apple_non_apple_keyboard non_apple_keyboards_disable_fn[] = {
+	{ "Omoton" },
+};
+
 static bool apple_is_non_apple_keyboard(struct hid_device *hdev)
 {
 	int i;
@@ -378,6 +382,20 @@ static bool apple_is_non_apple_keyboard(struct hid_device *hdev)
 	return false;
 }
 
+static bool apple_disable_fn_key(struct hid_device *hdev)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(non_apple_keyboards_disable_fn); i++) {
+		char *non_apple = non_apple_keyboards_disable_fn[i].name;
+
+		if (strncmp(hdev->name, non_apple, strlen(non_apple)) == 0)
+			return true;
+	}
+
+	return false;
+}
+
 static inline void apple_setup_key_translation(struct input_dev *input,
 		const struct apple_key_translation *table)
 {
@@ -419,7 +437,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
 	unsigned int real_fnmode;
 
 	if (fnmode == 3) {
-		real_fnmode = (asc->quirks & APPLE_IS_NON_APPLE) ? 2 : 1;
+		real_fnmode = (asc->quirks & APPLE_DISABLE_FN) ? 0 :
+			      ((asc->quirks & APPLE_IS_NON_APPLE) ? 2 : 1);
 	} else {
 		real_fnmode = fnmode;
 	}
@@ -738,6 +757,11 @@ static int apple_input_configured(struct hid_device *hdev,
 		asc->quirks |= APPLE_IS_NON_APPLE;
 	}
 
+	if (apple_disable_fn_key(hdev)) {
+		hid_info(hdev, "Disable fn key quirk detected; fnmode=0 behaviour will be followed by default\n");
+		asc->quirks |= APPLE_DISABLE_FN;
+	}
+
 	return 0;
 }
 
-- 
2.39.5 (Apple Git-154)






[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