Skip to contentSkip to conversation

HID: Add Wireless Radio Control feature for Chicony devices

PATCH Superseded Jian-Hong Pan 4 participants 10 messages Dec 22, 2020 – Jan 14, 2021 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: Add Wireless Radio Control feature for Chicony devices

Some Chicony's keyboards support airplane mode hotkey (Fn+F2) with "Wireless Radio Control" feature. For example, the wireless keyboard [04f2:1236] shipped with ASUS all-in-one desktop.

After consulting Chicony for this hotkey, learned the device will send with 0x11 as the report ID and 0x1 as the value when the key is pressed down.

This patch maps the event as KEY_RFKILL.

---
 drivers/hid/hid-chicony.c | 58 +++++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-ids.h     |  1 +
 2 files changed, 59 insertions(+)
drivers/hid/hid-chicony.c +58 -0
index 3f0ed6a95223..aca963aa0f1e 100644
@@ -21,6 +21,42 @@
 
 #include "hid-ids.h"
 
+#define KEY_PRESSED			0x01
+#define CH_WIRELESS_CTL_REPORT_ID	0x11
+
+static int ch_report_wireless(struct hid_report *report, u8 *data, int size)
+{
+	struct hid_device *hdev = report->device;
+	struct input_dev *input;
+
+	if (report->id != CH_WIRELESS_CTL_REPORT_ID ||
+	    report->maxfield != 1 ||
+	    *report->field[0]->value != KEY_PRESSED)
+		return 0;
+
+	input = report->field[0]->hidinput->input;
+	if (!input) {
+		hid_warn(hdev, "can't find wireless radio control's input");
+		return 0;
+	}
+
+	input_report_key(input, KEY_RFKILL, 1);
+	input_sync(input);
+	input_report_key(input, KEY_RFKILL, 0);
+	input_sync(input);
+
+	return 1;
+}
+
+static int ch_raw_event(struct hid_device *hdev,
+		struct hid_report *report, u8 *data, int size)
+{
+	if (report->application == HID_GD_WIRELESS_RADIO_CTLS)
+		return ch_report_wireless(report, data, size);
+
+	return 0;
+}
+
 #define ch_map_key_clear(c)	hid_map_usage_clear(hi, usage, bit, max, \
 					EV_KEY, (c))
 static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
@@ -77,10 +113,30 @@ static __u8 *ch_switch12_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 	return rdesc;
 }
 
+static int ch_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+	int ret;
+
+	hdev->quirks |= HID_QUIRK_INPUT_PER_APP;
+	ret = hid_parse(hdev);
+	if (ret) {
+		hid_err(hdev, "Chicony hid parse failed: %d\n", ret);
+		return ret;
+	}
+
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+	if (ret) {
+		hid_err(hdev, "Chicony hw start failed: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
 
 static const struct hid_device_id ch_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS3) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
 	{ }
 };
@@ -91,6 +147,8 @@ static struct hid_driver ch_driver = {
 	.id_table = ch_devices,
 	.report_fixup = ch_switch12_report_fixup,
 	.input_mapping = ch_input_mapping,
+	.probe = ch_probe,
+	.raw_event = ch_raw_event,
 };
 module_hid_driver(ch_driver);
 
drivers/hid/hid-ids.h +1 -0
index 4c5f23640f9c..06d90301a3dc 100644
@@ -270,6 +270,7 @@
 #define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE	0x1053
 #define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE2	0x0939
 #define USB_DEVICE_ID_CHICONY_WIRELESS2	0x1123
+#define USB_DEVICE_ID_CHICONY_WIRELESS3	0x1236
 #define USB_DEVICE_ID_ASUS_AK1D		0x1125
 #define USB_DEVICE_ID_CHICONY_TOSHIBA_WT10A	0x1408
 #define USB_DEVICE_ID_CHICONY_ACER_SWITCH12	0x1421
Signature · 1 line
2.29.2
#1 lore raw
Quoted 26 lines · Jian-Hong Pan

Some Chicony's keyboards support airplane mode hotkey (Fn+F2) with "Wireless Radio Control" feature. For example, the wireless keyboard [04f2:1236] shipped with ASUS all-in-one desktop.

After consulting Chicony for this hotkey, learned the device will send with 0x11 as the report ID and 0x1 as the value when the key is pressed down.

This patch maps the event as KEY_RFKILL.

---
 drivers/hid/hid-chicony.c | 58 +++++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-ids.h     |  1 +
 2 files changed, 59 insertions(+)
drivers/hid/hid-chicony.c +1 -0
index 3f0ed6a95223..aca963aa0f1e 100644
@@ -21,6 +21,42 @@
 
 #include "hid-ids.h"
 
+#define KEY_PRESSED                    0x01

drivers/hid/hid-chicony.c line 34

Quoted 10 lines
drivers/hid/hid-chicony.c +10 -0
+#define CH_WIRELESS_CTL_REPORT_ID      0x11
+
+static int ch_report_wireless(struct hid_report *report, u8 *data, int size)
+{
+       struct hid_device *hdev = report->device;
+       struct input_dev *input;
+
+       if (report->id != CH_WIRELESS_CTL_REPORT_ID ||
+           report->maxfield != 1 ||
+           *report->field[0]->value != KEY_PRESSED)

Maybe replace this line with hid_check_keys_pressed() and the KEY_PRESSED is not required.

Quoted 83 lines
drivers/hid/hid-chicony.c +47 -0
+               return 0;
+
+       input = report->field[0]->hidinput->input;
+       if (!input) {
+               hid_warn(hdev, "can't find wireless radio control's input");
+               return 0;
+       }
+
+       input_report_key(input, KEY_RFKILL, 1);
+       input_sync(input);
+       input_report_key(input, KEY_RFKILL, 0);
+       input_sync(input);
+
+       return 1;
+}
+
+static int ch_raw_event(struct hid_device *hdev,
+               struct hid_report *report, u8 *data, int size)
+{
+       if (report->application == HID_GD_WIRELESS_RADIO_CTLS)
+               return ch_report_wireless(report, data, size);
+
+       return 0;
+}
+
 #define ch_map_key_clear(c)    hid_map_usage_clear(hi, usage, bit, max, \
                                        EV_KEY, (c))
 static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
@@ -77,10 +113,30 @@ static __u8 *ch_switch12_report_fixup(struct hid_device *hdev, __u8 *rdesc,
        return rdesc;
 }
 
+static int ch_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+       int ret;
+
+       hdev->quirks |= HID_QUIRK_INPUT_PER_APP;
+       ret = hid_parse(hdev);
+       if (ret) {
+               hid_err(hdev, "Chicony hid parse failed: %d\n", ret);
+               return ret;
+       }
+
+       ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+       if (ret) {
+               hid_err(hdev, "Chicony hw start failed: %d\n", ret);
+               return ret;
+       }
+
+       return 0;
+}
 
 static const struct hid_device_id ch_devices[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS3) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
        { }
 };
@@ -91,6 +147,8 @@ static struct hid_driver ch_driver = {
        .id_table = ch_devices,
        .report_fixup = ch_switch12_report_fixup,
        .input_mapping = ch_input_mapping,
+       .probe = ch_probe,
+       .raw_event = ch_raw_event,
 };
 module_hid_driver(ch_driver);
 
drivers/hid/hid-ids.h +1 -1
index 4c5f23640f9c..06d90301a3dc 100644
@@ -270,6 +270,7 @@
 #define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE 0x1053
 #define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE2        0x0939
 #define USB_DEVICE_ID_CHICONY_WIRELESS2        0x1123
+#define USB_DEVICE_ID_CHICONY_WIRELESS3        0x1236
 #define USB_DEVICE_ID_ASUS_AK1D                0x1125
 #define USB_DEVICE_ID_CHICONY_TOSHIBA_WT10A    0x1408
 #define USB_DEVICE_ID_CHICONY_ACER_SWITCH12    0x1421
--

2.29.2

#2 lore raw

Chris Chiu <[email protected]> 於 2020年12月23日 週三 上午12:41寫道:

Quoted 27 lines · Jian-Hong Pan
Quoted 25 lines

Some Chicony's keyboards support airplane mode hotkey (Fn+F2) with "Wireless Radio Control" feature. For example, the wireless keyboard [04f2:1236] shipped with ASUS all-in-one desktop.

After consulting Chicony for this hotkey, learned the device will send with 0x11 as the report ID and 0x1 as the value when the key is pressed down.

This patch maps the event as KEY_RFKILL.

---
 drivers/hid/hid-chicony.c | 58 +++++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-ids.h     |  1 +
 2 files changed, 59 insertions(+)
drivers/hid/hid-chicony.c +0 -0
index 3f0ed6a95223..aca963aa0f1e 100644
@@ -21,6 +21,42 @@
 
 #include "hid-ids.h"
 
Quoted 14 lines

drivers/hid/hid-chicony.c line 34

Quoted 11 lines
drivers/hid/hid-chicony.c +11 -0
+#define KEY_PRESSED                    0x01
+#define CH_WIRELESS_CTL_REPORT_ID      0x11
+
+static int ch_report_wireless(struct hid_report *report, u8 *data, int size)
+{
+       struct hid_device *hdev = report->device;
+       struct input_dev *input;
+
+       if (report->id != CH_WIRELESS_CTL_REPORT_ID ||
+           report->maxfield != 1 ||
+           *report->field[0]->value != KEY_PRESSED)

Maybe replace this line with hid_check_keys_pressed() and the KEY_PRESSED is not required.

Thanks for your suggestion!

I tried hid_check_keys_pressed(). But, it always returns no key is pressed in this case.
However, if the idea is: Since there is already a report, there must be an event from the input. So, the key press checking is duplicated. This idea makes sense. I will have a modification for this.

Thanks!
Jian-Hong Pan

Quoted 83 lines
Quoted 83 lines
drivers/hid/hid-chicony.c +47 -0
+               return 0;
+
+       input = report->field[0]->hidinput->input;
+       if (!input) {
+               hid_warn(hdev, "can't find wireless radio control's input");
+               return 0;
+       }
+
+       input_report_key(input, KEY_RFKILL, 1);
+       input_sync(input);
+       input_report_key(input, KEY_RFKILL, 0);
+       input_sync(input);
+
+       return 1;
+}
+
+static int ch_raw_event(struct hid_device *hdev,
+               struct hid_report *report, u8 *data, int size)
+{
+       if (report->application == HID_GD_WIRELESS_RADIO_CTLS)
+               return ch_report_wireless(report, data, size);
+
+       return 0;
+}
+
 #define ch_map_key_clear(c)    hid_map_usage_clear(hi, usage, bit, max, \
                                        EV_KEY, (c))
 static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
@@ -77,10 +113,30 @@ static __u8 *ch_switch12_report_fixup(struct hid_device *hdev, __u8 *rdesc,
        return rdesc;
 }
 
+static int ch_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+       int ret;
+
+       hdev->quirks |= HID_QUIRK_INPUT_PER_APP;
+       ret = hid_parse(hdev);
+       if (ret) {
+               hid_err(hdev, "Chicony hid parse failed: %d\n", ret);
+               return ret;
+       }
+
+       ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+       if (ret) {
+               hid_err(hdev, "Chicony hw start failed: %d\n", ret);
+               return ret;
+       }
+
+       return 0;
+}
 
 static const struct hid_device_id ch_devices[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS3) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
        { }
 };
@@ -91,6 +147,8 @@ static struct hid_driver ch_driver = {
        .id_table = ch_devices,
        .report_fixup = ch_switch12_report_fixup,
        .input_mapping = ch_input_mapping,
+       .probe = ch_probe,
+       .raw_event = ch_raw_event,
 };
 module_hid_driver(ch_driver);
 
drivers/hid/hid-ids.h +1 -1
index 4c5f23640f9c..06d90301a3dc 100644
@@ -270,6 +270,7 @@
 #define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE 0x1053
 #define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE2        0x0939
 #define USB_DEVICE_ID_CHICONY_WIRELESS2        0x1123
+#define USB_DEVICE_ID_CHICONY_WIRELESS3        0x1236
 #define USB_DEVICE_ID_ASUS_AK1D                0x1125
 #define USB_DEVICE_ID_CHICONY_TOSHIBA_WT10A    0x1408
 #define USB_DEVICE_ID_CHICONY_ACER_SWITCH12    0x1421
--

2.29.2

#3 lore raw

PATCH v2 1/1 HID: Add Wireless Radio Control feature for Chicony devices

In reply to Chris Chiu

Some Chicony's keyboards support airplane mode hotkey (Fn+F2) with "Wireless Radio Control" feature. For example, the wireless keyboard [04f2:1236] shipped with ASUS all-in-one desktop.

After consulting Chicony for this hotkey, learned the device will send with 0x11 as the report ID and 0x1 as the value when the key is pressed down.

This patch maps the event as KEY_RFKILL.

---
v2: Remove the duplicated key pressed check.

 drivers/hid/hid-chicony.c | 55 +++++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-ids.h     |  1 +
 2 files changed, 56 insertions(+)
drivers/hid/hid-chicony.c +55 -0
index 3f0ed6a95223..ca556d39da2a 100644
@@ -21,6 +21,39 @@
 
 #include "hid-ids.h"
 
+#define CH_WIRELESS_CTL_REPORT_ID	0x11
+
+static int ch_report_wireless(struct hid_report *report, u8 *data, int size)
+{
+	struct hid_device *hdev = report->device;
+	struct input_dev *input;
+
+	if (report->id != CH_WIRELESS_CTL_REPORT_ID || report->maxfield != 1)
+		return 0;
+
+	input = report->field[0]->hidinput->input;
+	if (!input) {
+		hid_warn(hdev, "can't find wireless radio control's input");
+		return 0;
+	}
+
+	input_report_key(input, KEY_RFKILL, 1);
+	input_sync(input);
+	input_report_key(input, KEY_RFKILL, 0);
+	input_sync(input);
+
+	return 1;
+}
+
+static int ch_raw_event(struct hid_device *hdev,
+		struct hid_report *report, u8 *data, int size)
+{
+	if (report->application == HID_GD_WIRELESS_RADIO_CTLS)
+		return ch_report_wireless(report, data, size);
+
+	return 0;
+}
+
 #define ch_map_key_clear(c)	hid_map_usage_clear(hi, usage, bit, max, \
 					EV_KEY, (c))
 static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
@@ -77,10 +110,30 @@ static __u8 *ch_switch12_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 	return rdesc;
 }
 
+static int ch_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+	int ret;
+
+	hdev->quirks |= HID_QUIRK_INPUT_PER_APP;
+	ret = hid_parse(hdev);
+	if (ret) {
+		hid_err(hdev, "Chicony hid parse failed: %d\n", ret);
+		return ret;
+	}
+
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+	if (ret) {
+		hid_err(hdev, "Chicony hw start failed: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
 
 static const struct hid_device_id ch_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS3) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
 	{ }
 };
@@ -91,6 +144,8 @@ static struct hid_driver ch_driver = {
 	.id_table = ch_devices,
 	.report_fixup = ch_switch12_report_fixup,
 	.input_mapping = ch_input_mapping,
+	.probe = ch_probe,
+	.raw_event = ch_raw_event,
 };
 module_hid_driver(ch_driver);
 
drivers/hid/hid-ids.h +1 -0
index 4c5f23640f9c..06d90301a3dc 100644
@@ -270,6 +270,7 @@
 #define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE	0x1053
 #define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE2	0x0939
 #define USB_DEVICE_ID_CHICONY_WIRELESS2	0x1123
+#define USB_DEVICE_ID_CHICONY_WIRELESS3	0x1236
 #define USB_DEVICE_ID_ASUS_AK1D		0x1125
 #define USB_DEVICE_ID_CHICONY_TOSHIBA_WT10A	0x1408
 #define USB_DEVICE_ID_CHICONY_ACER_SWITCH12	0x1421
Signature · 1 line
2.29.2
Reviewed-by on v2 1/1
#4 lore raw
Quoted 5 lines · Jian-Hong Pan

Some Chicony's keyboards support airplane mode hotkey (Fn+F2) with "Wireless Radio Control" feature. For example, the wireless keyboard [04f2:1236] shipped with ASUS all-in-one desktop.

Quoted 7 lines

After consulting Chicony for this hotkey, learned the device will send with 0x11 as the report ID and 0x1 as the value when the key is pressed down.

This patch maps the event as KEY_RFKILL.

Quoted 106 lines

---
v2: Remove the duplicated key pressed check.

 drivers/hid/hid-chicony.c | 55 +++++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-ids.h     |  1 +
 2 files changed, 56 insertions(+)
drivers/hid/hid-chicony.c +55 -0
index 3f0ed6a95223..ca556d39da2a 100644
@@ -21,6 +21,39 @@
 
 #include "hid-ids.h"
 
+#define CH_WIRELESS_CTL_REPORT_ID      0x11
+
+static int ch_report_wireless(struct hid_report *report, u8 *data, int size)
+{
+       struct hid_device *hdev = report->device;
+       struct input_dev *input;
+
+       if (report->id != CH_WIRELESS_CTL_REPORT_ID || report->maxfield != 1)
+               return 0;
+
+       input = report->field[0]->hidinput->input;
+       if (!input) {
+               hid_warn(hdev, "can't find wireless radio control's input");
+               return 0;
+       }
+
+       input_report_key(input, KEY_RFKILL, 1);
+       input_sync(input);
+       input_report_key(input, KEY_RFKILL, 0);
+       input_sync(input);
+
+       return 1;
+}
+
+static int ch_raw_event(struct hid_device *hdev,
+               struct hid_report *report, u8 *data, int size)
+{
+       if (report->application == HID_GD_WIRELESS_RADIO_CTLS)
+               return ch_report_wireless(report, data, size);
+
+       return 0;
+}
+
 #define ch_map_key_clear(c)    hid_map_usage_clear(hi, usage, bit, max, \
                                        EV_KEY, (c))
 static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
@@ -77,10 +110,30 @@ static __u8 *ch_switch12_report_fixup(struct hid_device *hdev, __u8 *rdesc,
        return rdesc;
 }
 
+static int ch_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+       int ret;
+
+       hdev->quirks |= HID_QUIRK_INPUT_PER_APP;
+       ret = hid_parse(hdev);
+       if (ret) {
+               hid_err(hdev, "Chicony hid parse failed: %d\n", ret);
+               return ret;
+       }
+
+       ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+       if (ret) {
+               hid_err(hdev, "Chicony hw start failed: %d\n", ret);
+               return ret;
+       }
+
+       return 0;
+}
 
 static const struct hid_device_id ch_devices[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS3) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
        { }
 };
@@ -91,6 +144,8 @@ static struct hid_driver ch_driver = {
        .id_table = ch_devices,
        .report_fixup = ch_switch12_report_fixup,
        .input_mapping = ch_input_mapping,
+       .probe = ch_probe,
+       .raw_event = ch_raw_event,
 };
 module_hid_driver(ch_driver);
 
drivers/hid/hid-ids.h +1 -1
index 4c5f23640f9c..06d90301a3dc 100644
@@ -270,6 +270,7 @@
 #define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE 0x1053
 #define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE2        0x0939
 #define USB_DEVICE_ID_CHICONY_WIRELESS2        0x1123
+#define USB_DEVICE_ID_CHICONY_WIRELESS3        0x1236
 #define USB_DEVICE_ID_ASUS_AK1D                0x1125
 #define USB_DEVICE_ID_CHICONY_TOSHIBA_WT10A    0x1408
 #define USB_DEVICE_ID_CHICONY_ACER_SWITCH12    0x1421
--

2.29.2

maintainer
#5 lore raw
In reply to Jian-Hong Pan
Quoted 9 lines · Jian-Hong Pan

Some Chicony's keyboards support airplane mode hotkey (Fn+F2) with "Wireless Radio Control" feature. For example, the wireless keyboard [04f2:1236] shipped with ASUS all-in-one desktop.

After consulting Chicony for this hotkey, learned the device will send with 0x11 as the report ID and 0x1 as the value when the key is pressed down.

This patch maps the event as KEY_RFKILL.

I don't know how exactly does the report descriptor of that device look like, but is this not doable from userspace via setkeycode() (udev/systemd is shipping a lot of such mappings already -- see evdev/keyboard definitions in hwdb).

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
#6 lore raw

Jiri Kosina <[email protected]> 於 2021年1月7日 週四 下午5:23寫道:

Quoted 11 lines · Jian-Hong Pan
Quoted 9 lines

Some Chicony's keyboards support airplane mode hotkey (Fn+F2) with "Wireless Radio Control" feature. For example, the wireless keyboard [04f2:1236] shipped with ASUS all-in-one desktop.

After consulting Chicony for this hotkey, learned the device will send with 0x11 as the report ID and 0x1 as the value when the key is pressed down.

Quoted 6 lines
Quoted 1 line

This patch maps the event as KEY_RFKILL.

I don't know how exactly does the report descriptor of that device look like, but is this not doable from userspace via setkeycode() (udev/systemd is shipping a lot of such mappings already -- see evdev/keyboard definitions in hwdb).

Thanks for your suggestion!

I have tested the key with evtest. But it has no response from all inputs. Nor response from xev.

So, I tried usb monitor to see what does it send:

$ lsusb -d 04f2:1236
Bus 001 Device 002: ID 04f2:1236 Chicony Electronics Co., Ltd
$ sudo modprobe usbmon
$ sudo cat /sys/kernel/debug/usb/usbmon/1u
ffff9145e0dea6c0 348311963 C Ii:1:002:1 0:8 8 = 00000000 00000000
ffff9145e0dea6c0 348311996 S Ii:1:002:1 -115:8 8 <
ffff9145e0deaf00 352852533 C Ii:1:002:2 0:4 2 = 1101
ffff9145e0deaf00 352852547 S Ii:1:002:2 -115:4 3 <

It sends 0x1101 for the hotkey. The same response from hid events:

$ sudo cat /sys/kernel/debug/hid/0003\:04F2\:1236.0002/events
report (size 2) (numbered) =  11 01

Then, I notice there is the RFKILL event listed on the "Chicony USB Receiver Wireless Radio Control" device:

$ sudo evtest /dev/input/event8
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x4f2 product 0x1236 version 0x111
Input device name: "Chicony USB Receiver Wireless Radio Control"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 103 (KEY_UP)
    Event code 105 (KEY_LEFT)
    Event code 106 (KEY_RIGHT)
    Event code 108 (KEY_DOWN)
    Event code 116 (KEY_POWER)
    Event code 138 (KEY_HELP)
    Event code 139 (KEY_MENU)
    Event code 142 (KEY_SLEEP)
    Event code 143 (KEY_WAKEUP)
    Event code 148 (KEY_PROG1)
    Event code 174 (KEY_EXIT)
    Event code 227 (KEY_SWITCHVIDEOMODE)
    Event code 247 (KEY_RFKILL)
    Event code 314 (BTN_SELECT)
    Event code 315 (BTN_START)
    Event code 353 (KEY_SELECT)
    Event code 356 (KEY_POWER2)
    Event code 408 (KEY_RESTART)
    Event code 438 (KEY_CONTEXT_MENU)
  Event type 2 (EV_REL)
    Event code 9 (REL_MISC)
  Event type 3 (EV_ABS)
...

Also, after debugging, I found its HID application ID is HID_GD_WIRELESS_RADIO_CTLS 0x0001000c [1].
Then, I searched HID_GD_WIRELESS_RADIO_CTLS in the kernel. I found HID_GD_RFKILL_BTN [2] is mapped in hid-input.
However, this key press on the Chicony keyboard maps to nothing, nor HID_GD_RFKILL_BTN. Only have the HID report with raw data 0x11 0x00 as mentioned above.
It is more like ignored by the kernel and it even has no scancode. That's why I try to map it as KEY_RFKILL in the driver.

[1] https://elixir.bootlin.com/linux/v5.10/source/include/linux/hid.h#L181
[2] https://elixir.bootlin.com/linux/v5.10/source/drivers/hid/hid-input.c#L743

Regards,
Jian-Hong Pan

maintainer Applied
#7 lore raw
In reply to Jian-Hong Pan
Quoted 8 lines · Jian-Hong Pan

Some Chicony's keyboards support airplane mode hotkey (Fn+F2) with "Wireless Radio Control" feature. For example, the wireless keyboard [04f2:1236] shipped with ASUS all-in-one desktop.

After consulting Chicony for this hotkey, learned the device will send with 0x11 as the report ID and 0x1 as the value when the key is pressed down.

Quoted 5 lines

This patch maps the event as KEY_RFKILL.

---
v2: Remove the duplicated key pressed check.

Applied, thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs
#8 lore raw
In reply to Jian-Hong Pan
Quoted 7 lines · Jian-Hong Pan

Some Chicony's keyboards support airplane mode hotkey (Fn+F2) with "Wireless Radio Control" feature. For example, the wireless keyboard [04f2:1236] shipped with ASUS all-in-one desktop.

After consulting Chicony for this hotkey, learned the device will send with 0x11 as the report ID and 0x1 as the value when the key is pressed down.

Fun, how can airplane mode work on _wireless_ keyboard? :-).

Pavel

Signature · 1 line
http://www.livejournal.com/~pavelmachek
#9 lore raw

Pavel Machek <[email protected]> 於 2020年12月25日 週五 上午3:06寫道:

Quoted 11 lines · Jian-Hong Pan
Quoted 7 lines

Some Chicony's keyboards support airplane mode hotkey (Fn+F2) with "Wireless Radio Control" feature. For example, the wireless keyboard [04f2:1236] shipped with ASUS all-in-one desktop.

After consulting Chicony for this hotkey, learned the device will send with 0x11 as the report ID and 0x1 as the value when the key is pressed down.

Fun, how can airplane mode work on _wireless_ keyboard? :-).

Hmm! It is a funny point for this USB wireless keyboard! But I guess this kind of combination (with the "desktop") will not be used on an airplane :)

Jian-Hong Pan