* [PATCH 1/2] HID: google: add magnemite/masterball USB ids
@ 2019-10-03 3:17 Nicolas Boichat
2019-10-03 3:17 ` Nicolas Boichat
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Nicolas Boichat @ 2019-10-03 3:17 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-input, linux-kernel, dtor, ikjn
Add 2 additional hammer-like devices.
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
---
drivers/hid/hid-google-hammer.c | 4 ++++
drivers/hid/hid-ids.h | 2 ++
2 files changed, 6 insertions(+)
diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c
index 31e4a39946f59ad..a52535ebc6fe92c 100644
--- a/drivers/hid/hid-google-hammer.c
+++ b/drivers/hid/hid-google-hammer.c
@@ -531,6 +531,10 @@ static void hammer_remove(struct hid_device *hdev)
static const struct hid_device_id hammer_devices[] = {
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_HAMMER) },
+ { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
+ USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MAGNEMITE) },
+ { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
+ USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MASTERBALL) },
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_STAFF) },
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 76969a22b0f2f79..447e8db21174ae7 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -476,6 +476,8 @@
#define USB_DEVICE_ID_GOOGLE_STAFF 0x502b
#define USB_DEVICE_ID_GOOGLE_WAND 0x502d
#define USB_DEVICE_ID_GOOGLE_WHISKERS 0x5030
+#define USB_DEVICE_ID_GOOGLE_MASTERBALL 0x503c
+#define USB_DEVICE_ID_GOOGLE_MAGNEMITE 0x503d
#define USB_VENDOR_ID_GOTOP 0x08f2
#define USB_DEVICE_ID_SUPER_Q2 0x007f
--
2.23.0.444.g18eeb5a265-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 1/2] HID: google: add magnemite/masterball USB ids 2019-10-03 3:17 [PATCH 1/2] HID: google: add magnemite/masterball USB ids Nicolas Boichat @ 2019-10-03 3:17 ` Nicolas Boichat 2019-10-03 3:18 ` [PATCH 2/2] HID: google: Detect base folded usage instead of hard-coding whiskers Nicolas Boichat 2019-10-10 19:08 ` [PATCH 1/2] HID: google: add magnemite/masterball USB ids Jiri Kosina 2 siblings, 0 replies; 8+ messages in thread From: Nicolas Boichat @ 2019-10-03 3:17 UTC (permalink / raw) To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-input, linux-kernel, dtor, ikjn Add 2 additional hammer-like devices. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> --- drivers/hid/hid-google-hammer.c | 4 ++++ drivers/hid/hid-ids.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c index 31e4a39946f59ad..a52535ebc6fe92c 100644 --- a/drivers/hid/hid-google-hammer.c +++ b/drivers/hid/hid-google-hammer.c @@ -531,6 +531,10 @@ static void hammer_remove(struct hid_device *hdev) static const struct hid_device_id hammer_devices[] = { { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_HAMMER) }, + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, + USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MAGNEMITE) }, + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, + USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_MASTERBALL) }, { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, USB_VENDOR_ID_GOOGLE, USB_DEVICE_ID_GOOGLE_STAFF) }, { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 76969a22b0f2f79..447e8db21174ae7 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -476,6 +476,8 @@ #define USB_DEVICE_ID_GOOGLE_STAFF 0x502b #define USB_DEVICE_ID_GOOGLE_WAND 0x502d #define USB_DEVICE_ID_GOOGLE_WHISKERS 0x5030 +#define USB_DEVICE_ID_GOOGLE_MASTERBALL 0x503c +#define USB_DEVICE_ID_GOOGLE_MAGNEMITE 0x503d #define USB_VENDOR_ID_GOTOP 0x08f2 #define USB_DEVICE_ID_SUPER_Q2 0x007f -- 2.23.0.444.g18eeb5a265-goog ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] HID: google: Detect base folded usage instead of hard-coding whiskers 2019-10-03 3:17 [PATCH 1/2] HID: google: add magnemite/masterball USB ids Nicolas Boichat 2019-10-03 3:17 ` Nicolas Boichat @ 2019-10-03 3:18 ` Nicolas Boichat 2019-10-03 3:18 ` Nicolas Boichat 2019-10-10 19:11 ` Jiri Kosina 2019-10-10 19:08 ` [PATCH 1/2] HID: google: add magnemite/masterball USB ids Jiri Kosina 2 siblings, 2 replies; 8+ messages in thread From: Nicolas Boichat @ 2019-10-03 3:18 UTC (permalink / raw) To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-input, linux-kernel, dtor, ikjn Some other hammer-like device will emit a similar code, let's look for the folded event in HID usage table, instead of hard-coding whiskers in many places. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> --- drivers/hid/hid-google-hammer.c | 53 ++++++++++++++++----------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c index a52535ebc6fe92c..2aa4ed157aec875 100644 --- a/drivers/hid/hid-google-hammer.c +++ b/drivers/hid/hid-google-hammer.c @@ -370,7 +370,7 @@ static void hammer_unregister_leds(struct hid_device *hdev) #define HID_UP_GOOGLEVENDOR 0xffd10000 #define HID_VD_KBD_FOLDED 0x00000019 -#define WHISKERS_KBD_FOLDED (HID_UP_GOOGLEVENDOR | HID_VD_KBD_FOLDED) +#define HID_USAGE_KBD_FOLDED (HID_UP_GOOGLEVENDOR | HID_VD_KBD_FOLDED) /* HID usage for keyboard backlight (Alphanumeric display brightness) */ #define HID_AD_BRIGHTNESS 0x00140046 @@ -380,8 +380,7 @@ static int hammer_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_usage *usage, unsigned long **bit, int *max) { - if (hdev->product == USB_DEVICE_ID_GOOGLE_WHISKERS && - usage->hid == WHISKERS_KBD_FOLDED) { + if (usage->hid == HID_USAGE_KBD_FOLDED) { /* * We do not want to have this usage mapped as it will get * mixed in with "base attached" signal and delivered over @@ -398,8 +397,7 @@ static int hammer_event(struct hid_device *hid, struct hid_field *field, { unsigned long flags; - if (hid->product == USB_DEVICE_ID_GOOGLE_WHISKERS && - usage->hid == WHISKERS_KBD_FOLDED) { + if (usage->hid == HID_USAGE_KBD_FOLDED) { spin_lock_irqsave(&cbas_ec_lock, flags); /* @@ -424,33 +422,22 @@ static int hammer_event(struct hid_device *hid, struct hid_field *field, return 0; } -static bool hammer_is_keyboard_interface(struct hid_device *hdev) +static bool hammer_has_usage(struct hid_device *hdev, unsigned int report_type, + unsigned application, unsigned usage) { - struct hid_report_enum *re = &hdev->report_enum[HID_INPUT_REPORT]; - struct hid_report *report; - - list_for_each_entry(report, &re->report_list, list) - if (report->application == HID_GD_KEYBOARD) - return true; - - return false; -} - -static bool hammer_has_backlight_control(struct hid_device *hdev) -{ - struct hid_report_enum *re = &hdev->report_enum[HID_OUTPUT_REPORT]; + struct hid_report_enum *re = &hdev->report_enum[report_type]; struct hid_report *report; int i, j; list_for_each_entry(report, &re->report_list, list) { - if (report->application != HID_GD_KEYBOARD) + if (report->application != application) continue; for (i = 0; i < report->maxfield; i++) { struct hid_field *field = report->field[i]; for (j = 0; j < field->maxusage; j++) - if (field->usage[j].hid == HID_AD_BRIGHTNESS) + if (field->usage[j].hid == usage) return true; } } @@ -458,6 +445,18 @@ static bool hammer_has_backlight_control(struct hid_device *hdev) return false; } +static bool hammer_has_folded_event(struct hid_device *hdev) +{ + return hammer_has_usage(hdev, HID_INPUT_REPORT, + HID_GD_KEYBOARD, HID_USAGE_KBD_FOLDED); +} + +static bool hammer_has_backlight_control(struct hid_device *hdev) +{ + return hammer_has_usage(hdev, HID_OUTPUT_REPORT, + HID_GD_KEYBOARD, HID_AD_BRIGHTNESS); +} + static int hammer_probe(struct hid_device *hdev, const struct hid_device_id *id) { @@ -473,12 +472,11 @@ static int hammer_probe(struct hid_device *hdev, /* * We always want to poll for, and handle tablet mode events from - * Whiskers, even when nobody has opened the input device. This also - * prevents the hid core from dropping early tablet mode events from - * the device. + * devices that have folded usage, even when nobody has opened the input + * device. This also prevents the hid core from dropping early tablet + * mode events from the device. */ - if (hdev->product == USB_DEVICE_ID_GOOGLE_WHISKERS && - hammer_is_keyboard_interface(hdev)) { + if (hammer_has_folded_event(hdev)) { hdev->quirks |= HID_QUIRK_ALWAYS_POLL; error = hid_hw_open(hdev); if (error) @@ -500,8 +498,7 @@ static void hammer_remove(struct hid_device *hdev) { unsigned long flags; - if (hdev->product == USB_DEVICE_ID_GOOGLE_WHISKERS && - hammer_is_keyboard_interface(hdev)) { + if (hammer_has_folded_event(hdev)) { hid_hw_close(hdev); /* -- 2.23.0.444.g18eeb5a265-goog ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] HID: google: Detect base folded usage instead of hard-coding whiskers 2019-10-03 3:18 ` [PATCH 2/2] HID: google: Detect base folded usage instead of hard-coding whiskers Nicolas Boichat @ 2019-10-03 3:18 ` Nicolas Boichat 2019-10-10 19:11 ` Jiri Kosina 1 sibling, 0 replies; 8+ messages in thread From: Nicolas Boichat @ 2019-10-03 3:18 UTC (permalink / raw) To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-input, linux-kernel, dtor, ikjn Some other hammer-like device will emit a similar code, let's look for the folded event in HID usage table, instead of hard-coding whiskers in many places. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> --- drivers/hid/hid-google-hammer.c | 53 ++++++++++++++++----------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c index a52535ebc6fe92c..2aa4ed157aec875 100644 --- a/drivers/hid/hid-google-hammer.c +++ b/drivers/hid/hid-google-hammer.c @@ -370,7 +370,7 @@ static void hammer_unregister_leds(struct hid_device *hdev) #define HID_UP_GOOGLEVENDOR 0xffd10000 #define HID_VD_KBD_FOLDED 0x00000019 -#define WHISKERS_KBD_FOLDED (HID_UP_GOOGLEVENDOR | HID_VD_KBD_FOLDED) +#define HID_USAGE_KBD_FOLDED (HID_UP_GOOGLEVENDOR | HID_VD_KBD_FOLDED) /* HID usage for keyboard backlight (Alphanumeric display brightness) */ #define HID_AD_BRIGHTNESS 0x00140046 @@ -380,8 +380,7 @@ static int hammer_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_usage *usage, unsigned long **bit, int *max) { - if (hdev->product == USB_DEVICE_ID_GOOGLE_WHISKERS && - usage->hid == WHISKERS_KBD_FOLDED) { + if (usage->hid == HID_USAGE_KBD_FOLDED) { /* * We do not want to have this usage mapped as it will get * mixed in with "base attached" signal and delivered over @@ -398,8 +397,7 @@ static int hammer_event(struct hid_device *hid, struct hid_field *field, { unsigned long flags; - if (hid->product == USB_DEVICE_ID_GOOGLE_WHISKERS && - usage->hid == WHISKERS_KBD_FOLDED) { + if (usage->hid == HID_USAGE_KBD_FOLDED) { spin_lock_irqsave(&cbas_ec_lock, flags); /* @@ -424,33 +422,22 @@ static int hammer_event(struct hid_device *hid, struct hid_field *field, return 0; } -static bool hammer_is_keyboard_interface(struct hid_device *hdev) +static bool hammer_has_usage(struct hid_device *hdev, unsigned int report_type, + unsigned application, unsigned usage) { - struct hid_report_enum *re = &hdev->report_enum[HID_INPUT_REPORT]; - struct hid_report *report; - - list_for_each_entry(report, &re->report_list, list) - if (report->application == HID_GD_KEYBOARD) - return true; - - return false; -} - -static bool hammer_has_backlight_control(struct hid_device *hdev) -{ - struct hid_report_enum *re = &hdev->report_enum[HID_OUTPUT_REPORT]; + struct hid_report_enum *re = &hdev->report_enum[report_type]; struct hid_report *report; int i, j; list_for_each_entry(report, &re->report_list, list) { - if (report->application != HID_GD_KEYBOARD) + if (report->application != application) continue; for (i = 0; i < report->maxfield; i++) { struct hid_field *field = report->field[i]; for (j = 0; j < field->maxusage; j++) - if (field->usage[j].hid == HID_AD_BRIGHTNESS) + if (field->usage[j].hid == usage) return true; } } @@ -458,6 +445,18 @@ static bool hammer_has_backlight_control(struct hid_device *hdev) return false; } +static bool hammer_has_folded_event(struct hid_device *hdev) +{ + return hammer_has_usage(hdev, HID_INPUT_REPORT, + HID_GD_KEYBOARD, HID_USAGE_KBD_FOLDED); +} + +static bool hammer_has_backlight_control(struct hid_device *hdev) +{ + return hammer_has_usage(hdev, HID_OUTPUT_REPORT, + HID_GD_KEYBOARD, HID_AD_BRIGHTNESS); +} + static int hammer_probe(struct hid_device *hdev, const struct hid_device_id *id) { @@ -473,12 +472,11 @@ static int hammer_probe(struct hid_device *hdev, /* * We always want to poll for, and handle tablet mode events from - * Whiskers, even when nobody has opened the input device. This also - * prevents the hid core from dropping early tablet mode events from - * the device. + * devices that have folded usage, even when nobody has opened the input + * device. This also prevents the hid core from dropping early tablet + * mode events from the device. */ - if (hdev->product == USB_DEVICE_ID_GOOGLE_WHISKERS && - hammer_is_keyboard_interface(hdev)) { + if (hammer_has_folded_event(hdev)) { hdev->quirks |= HID_QUIRK_ALWAYS_POLL; error = hid_hw_open(hdev); if (error) @@ -500,8 +498,7 @@ static void hammer_remove(struct hid_device *hdev) { unsigned long flags; - if (hdev->product == USB_DEVICE_ID_GOOGLE_WHISKERS && - hammer_is_keyboard_interface(hdev)) { + if (hammer_has_folded_event(hdev)) { hid_hw_close(hdev); /* -- 2.23.0.444.g18eeb5a265-goog ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] HID: google: Detect base folded usage instead of hard-coding whiskers 2019-10-03 3:18 ` [PATCH 2/2] HID: google: Detect base folded usage instead of hard-coding whiskers Nicolas Boichat 2019-10-03 3:18 ` Nicolas Boichat @ 2019-10-10 19:11 ` Jiri Kosina 2019-10-10 19:11 ` Jiri Kosina 1 sibling, 1 reply; 8+ messages in thread From: Jiri Kosina @ 2019-10-10 19:11 UTC (permalink / raw) To: Nicolas Boichat; +Cc: Benjamin Tissoires, linux-input, linux-kernel, dtor, ikjn On Thu, 3 Oct 2019, Nicolas Boichat wrote: > Some other hammer-like device will emit a similar code, let's look for > the folded event in HID usage table, instead of hard-coding whiskers > in many places. Applied to for-5.5/whiskers. Thanks, -- Jiri Kosina SUSE Labs ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] HID: google: Detect base folded usage instead of hard-coding whiskers 2019-10-10 19:11 ` Jiri Kosina @ 2019-10-10 19:11 ` Jiri Kosina 0 siblings, 0 replies; 8+ messages in thread From: Jiri Kosina @ 2019-10-10 19:11 UTC (permalink / raw) To: Nicolas Boichat; +Cc: Benjamin Tissoires, linux-input, linux-kernel, dtor, ikjn On Thu, 3 Oct 2019, Nicolas Boichat wrote: > Some other hammer-like device will emit a similar code, let's look for > the folded event in HID usage table, instead of hard-coding whiskers > in many places. Applied to for-5.5/whiskers. Thanks, -- Jiri Kosina SUSE Labs ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] HID: google: add magnemite/masterball USB ids 2019-10-03 3:17 [PATCH 1/2] HID: google: add magnemite/masterball USB ids Nicolas Boichat 2019-10-03 3:17 ` Nicolas Boichat 2019-10-03 3:18 ` [PATCH 2/2] HID: google: Detect base folded usage instead of hard-coding whiskers Nicolas Boichat @ 2019-10-10 19:08 ` Jiri Kosina 2019-10-10 19:08 ` Jiri Kosina 2 siblings, 1 reply; 8+ messages in thread From: Jiri Kosina @ 2019-10-10 19:08 UTC (permalink / raw) To: Nicolas Boichat; +Cc: Benjamin Tissoires, linux-input, linux-kernel, dtor, ikjn On Thu, 3 Oct 2019, Nicolas Boichat wrote: > Add 2 additional hammer-like devices. Applied to for-5.4/upstream-fixes. -- Jiri Kosina SUSE Labs ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] HID: google: add magnemite/masterball USB ids 2019-10-10 19:08 ` [PATCH 1/2] HID: google: add magnemite/masterball USB ids Jiri Kosina @ 2019-10-10 19:08 ` Jiri Kosina 0 siblings, 0 replies; 8+ messages in thread From: Jiri Kosina @ 2019-10-10 19:08 UTC (permalink / raw) To: Nicolas Boichat; +Cc: Benjamin Tissoires, linux-input, linux-kernel, dtor, ikjn On Thu, 3 Oct 2019, Nicolas Boichat wrote: > Add 2 additional hammer-like devices. Applied to for-5.4/upstream-fixes. -- Jiri Kosina SUSE Labs ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-10-10 19:12 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-10-03 3:17 [PATCH 1/2] HID: google: add magnemite/masterball USB ids Nicolas Boichat 2019-10-03 3:17 ` Nicolas Boichat 2019-10-03 3:18 ` [PATCH 2/2] HID: google: Detect base folded usage instead of hard-coding whiskers Nicolas Boichat 2019-10-03 3:18 ` Nicolas Boichat 2019-10-10 19:11 ` Jiri Kosina 2019-10-10 19:11 ` Jiri Kosina 2019-10-10 19:08 ` [PATCH 1/2] HID: google: add magnemite/masterball USB ids Jiri Kosina 2019-10-10 19:08 ` Jiri Kosina
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox