Commit Graph

17 Commits

Author SHA1 Message Date
Jason Wang 12ffcd7578 HID: lg-g15: Fix comment typo
The double `with' is duplicated in line 769, remove one.

Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-07-21 13:47:12 +02:00
Hans de Goede b413c59ead HID: lg-g15 + ite: Add MODULE_AUTHOR
I noticed that the 2 HID drivers which I've written and maintain were
missing a MODULE_AUTHOR tag, add this so that people can easily figure
out who to email with questions.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-05-05 14:39:24 +02:00
Hans de Goede cbe5b6b6a7 HID: lg-g15: Add support for the Logitech Z-10 speakers
Add support to hid-lg-g15 for the Logitech Z-10 speakers. This adds
support for the LCD menu keys found on these speakers, as well as
support for controlling the LCD's brightness through a LED classdev.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-05-05 14:39:24 +02:00
Hans de Goede 1e5c22983f HID: lg-g15: Make the LED-name used by lg_g15_register_led() a parameter
Make the LED-name used by lg_g15_register_led() a parameter.

This is a preparation patch for adding support for the LCD menu
keys + LCD brightness control on the Logitech Z-10 speakers (with LCD)
which use the same protocol as the G15 keyboards.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-05-05 14:39:24 +02:00
Hans de Goede 614d34f8b3 HID: lg-g15: Add a lg_g15_init_input_dev() helper function
Factor the input-device setup + KEY_KBD_LCD_MENU capability setting out
of lg_g15_probe() into a new lg_g15_init_input_dev() helper function.

This is a preparation patch for adding support for the LCD menu
keys + LCD brightness control on the Logitech Z-10 speakers (with LCD)
which use the same protocol as the G15 keyboards.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-05-05 14:39:24 +02:00
Hans de Goede ba3e054e7a HID: lg-g15: Add a lg_g15_handle_lcd_menu_keys() helper function
Factor out the handling of the G15 LCD menu keys out of
lg_g15_event() into a new lg_g15_handle_lcd_menu_keys() helper function.

This is a preparation patch for adding support for the LCD menu
keys on the Logitech Z-10 speakers (with LCD) which use the same
funky HID report format.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-05-05 14:39:24 +02:00
Hans de Goede 042d05b2e3 HID: lg-g15: Remove unused size argument from lg_*_event() functions
The report-size is already checked in lg_g15_raw_event() before calling
the lg_*_event() functions and these functions don't use the passed
in size at all, drop the unused parameter.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-05-05 14:39:24 +02:00
Colin Ian King 4d30083301 HID: lg-g15: make a const array static, makes object smaller
Don't populate the const array led_names on the stack but instead make
it static. Makes the object code smaller by 79 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  19686	   7952	    256	  27894	   6cf6	drivers/hid/hid-lg-g15.o

After:
   text	   data	    bss	    dec	    hex	filename
  19543	   8016	    256	  27815	   6ca7	drivers/hid/hid-lg-g15.o

(gcc version 10.2.0)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-02-05 10:13:28 +01:00
Gustavo A. R. Silva df561f6688 treewide: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2020-08-23 17:36:59 -05:00
Fabian Schindlatz b1bd0f7528 HID: logitech: Add support for Logitech G11 extra keys
The Logitech G11 keyboard is a cheap variant of the G15 without the LCD
screen. It uses the same layout for its extra and macro keys (G1 - G18,
M1-M3, MR) and - from the input subsystem's perspective - behaves just
like the G15, so we can treat it as such.

Tested it with my own keyboard.

Signed-off-by: Fabian Schindlatz <fabian.schindlatz@fau.de>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2020-04-14 11:15:36 +02:00
Hans de Goede b8a75eadda HID: lg-g15: Do not fail the probe when we fail to disable F# emulation
By default the G1-G12 keys on the Logitech gaming keyboards send
F1 - F12 when in "generic HID" mode.

The first thing the hid-lg-g15 driver does is disable this behavior.

We have received a bugreport that this does not work when the keyboard
is connected through an Aten KVM switch. Using a gaming keyboard with
a KVM is a bit weird setup, but still we can try to fail a bit more
gracefully here.

On the G510 keyboards the same USB-interface which is used for the gaming
keys is also used for the media-keys. Before this commit we would call
hid_hw_stop() on failure to disable the F# emulation and then exit the
probe method with an error code.

This not only causes us to not handle the gaming-keys, but this also
breaks the media keys which is a regression compared to the situation
when these keyboards where handled by the generic hidinput driver.

This commit changes the error handling to clear the hiddev drvdata
(to disable our .raw_event handler) and then returning from the probe
method with success.

The net result of this is that, when connected through a KVM, things
work as well as they did before the hid-lg-g15 driver was introduced.

Fixes: ad4203f5a2 ("HID: lg-g15: Add support for the G510 keyboards' gaming keys")
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1806321
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2020-03-17 21:48:48 +01:00
Hans de Goede 4682bb8e05 HID: lg-g15: Add support for the G510's M1-M3 and MR LEDs
Add support for controlling the LEDs below the M1-M3 and MR keys
on the G510.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2019-10-03 20:48:28 +02:00
Hans de Goede 1f8cde2a53 HID: lg-g15: Add support for controlling the G510's RGB backlight
Note that the keyboard has a backlight on/off toggle button. If the
backlight is turned off through that button, then any changes we make
will be ignored and we cannot turn it back on again from the host.

To workaround this we write the last set RGB values when we receive an
event indicating that the backlight has been turned on again.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2019-10-03 20:48:27 +02:00
Hans de Goede ad4203f5a2 HID: lg-g15: Add support for the G510 keyboards' gaming keys
Add support for the gaming and LCD menu keys on the G510 keyboard.

Note this commit does not add support for the keyboard and LCD backlight
and the status LEDs, this is done in a follow up commit.

Note the G510 generates 4 different input reports on its second
(Consumer Keys) interface:

-input report 1 is standard bootclass keyboard input report, mirroring
 normal keyboard interface
-input report 2 is consumer page keys
-input report 3 is gkeys, etc.
-input report 4 is LED status, single byte, bits:
 bit 2: kbd and LCD backlight is *off* when set, toggled by the light key
 bit 3: headphone mute LED
 bit 4: mic mute LED

Input-report 1 we ignore since this is a duplicate report from the first
interface, report 2 is handled by the regular hid-input code. In this
commit we add handling for input report 3.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2019-10-03 20:48:27 +02:00
Hans de Goede d5b5fc8c89 HID: lg-g15: Add support for the M1-M3 and MR LEDs
Add support for controlling the LEDs below the M1-M3 and MR keys.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2019-10-03 20:48:27 +02:00
Hans de Goede 97b741aba9 HID: lg-g15: Add keyboard and LCD backlight control
Register a led_classdev for the keyboard backlight and another one for
the LCD backlight.

This commit also includes LED_BRIGHT_HW_CHANGED support, which together
with a desktop-environment which supports this, such as GNOME3 leads to
the kbd-backlight OSD being show with the new level when changing the
backlight setting through the hotkey on the keyboard.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2019-10-03 20:48:27 +02:00
Hans de Goede 3a0275384c HID: Add driver for Logitech gaming keyboards (G15, G15 v2)
Add a driver to stop the extra "G" keys from sending F1 - F12 instead
making them send KEY_GKEY# and also make the non-functional M1 - M3 and MR
keys and the non-functional buttons below the LCD panel properly generated
key events.

Note the connect_mask and gkeys_settings_output_report variables may seem
unnecessary since they are always set to the same value, these are there in
preparation of adding support for the G, M and LCD keys on the G510 kbd.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2019-10-03 20:48:27 +02:00