Lines Matching +full:led +full:- +full:backlight

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * - Vengeance K70 Keyboard
7 * - K70 RAPIDFIRE Keyboard
8 * - Vengeance K90 Keyboard
9 * - Scimitar PRO RGB Gaming Mouse
24 #include "hid-ids.h"
43 struct k90_led *backlight; member
52 return usage - 0xd0 + 1; in corsair_usage_to_gkey()
55 return usage - 0xe8 + 17; in corsair_usage_to_gkey()
81 MODULE_PARM_DESC(gkey_codes, "Key codes for the G-keys");
139 * LED class devices
142 #define K90_BACKLIGHT_LED_SUFFIX "::backlight"
148 struct k90_led *led = container_of(led_cdev, struct k90_led, cdev); in k90_backlight_get() local
149 struct device *dev = led->cdev.dev->parent; in k90_backlight_get()
150 struct usb_interface *usbif = to_usb_interface(dev->parent); in k90_backlight_get()
157 return -ENOMEM; in k90_backlight_get()
167 ret = -EIO; in k90_backlight_get()
173 "Read invalid backlight brightness: %02hhx.\n", in k90_backlight_get()
175 ret = -EIO; in k90_backlight_get()
187 struct k90_led *led = container_of(led_cdev, struct k90_led, cdev); in k90_record_led_get() local
189 return led->brightness; in k90_record_led_get()
195 struct k90_led *led = container_of(led_cdev, struct k90_led, cdev); in k90_brightness_set() local
197 led->brightness = brightness; in k90_brightness_set()
198 schedule_work(&led->work); in k90_brightness_set()
204 struct k90_led *led = container_of(work, struct k90_led, work); in k90_backlight_work() local
209 if (led->removed) in k90_backlight_work()
212 dev = led->cdev.dev->parent; in k90_backlight_work()
213 usbif = to_usb_interface(dev->parent); in k90_backlight_work()
219 USB_RECIP_DEVICE, led->brightness, 0, in k90_backlight_work()
222 dev_warn(dev, "Failed to set backlight brightness (error: %d).\n", in k90_backlight_work()
229 struct k90_led *led = container_of(work, struct k90_led, work); in k90_record_led_work() local
235 if (led->removed) in k90_record_led_work()
238 dev = led->cdev.dev->parent; in k90_record_led_work()
239 usbif = to_usb_interface(dev->parent); in k90_record_led_work()
242 if (led->brightness > 0) in k90_record_led_work()
253 dev_warn(dev, "Failed to set record LED state (error: %d).\n", in k90_record_led_work()
265 struct usb_interface *usbif = to_usb_interface(dev->parent); in k90_show_macro_mode()
272 return -ENOMEM; in k90_show_macro_mode()
282 ret = -EIO; in k90_show_macro_mode()
297 ret = -EIO; in k90_show_macro_mode()
313 struct usb_interface *usbif = to_usb_interface(dev->parent); in k90_store_macro_mode()
322 return -EINVAL; in k90_store_macro_mode()
342 struct usb_interface *usbif = to_usb_interface(dev->parent); in k90_show_current_profile()
349 return -ENOMEM; in k90_show_current_profile()
359 ret = -EIO; in k90_show_current_profile()
366 ret = -EIO; in k90_show_current_profile()
382 struct usb_interface *usbif = to_usb_interface(dev->parent); in k90_store_current_profile()
387 return -EINVAL; in k90_store_current_profile()
389 return -EINVAL; in k90_store_current_profile()
430 drvdata->backlight = kzalloc(sizeof(struct k90_led), GFP_KERNEL); in k90_init_backlight()
431 if (!drvdata->backlight) { in k90_init_backlight()
432 ret = -ENOMEM; in k90_init_backlight()
437 strlen(dev_name(&dev->dev)) + sizeof(K90_BACKLIGHT_LED_SUFFIX); in k90_init_backlight()
440 ret = -ENOMEM; in k90_init_backlight()
444 dev_name(&dev->dev)); in k90_init_backlight()
445 drvdata->backlight->removed = false; in k90_init_backlight()
446 drvdata->backlight->cdev.name = name; in k90_init_backlight()
447 drvdata->backlight->cdev.max_brightness = 3; in k90_init_backlight()
448 drvdata->backlight->cdev.brightness_set = k90_brightness_set; in k90_init_backlight()
449 drvdata->backlight->cdev.brightness_get = k90_backlight_get; in k90_init_backlight()
450 INIT_WORK(&drvdata->backlight->work, k90_backlight_work); in k90_init_backlight()
451 ret = led_classdev_register(&dev->dev, &drvdata->backlight->cdev); in k90_init_backlight()
458 kfree(drvdata->backlight->cdev.name); in k90_init_backlight()
460 kfree(drvdata->backlight); in k90_init_backlight()
461 drvdata->backlight = NULL; in k90_init_backlight()
476 ret = -ENOMEM; in k90_init_macro_functions()
479 drvdata->k90 = k90; in k90_init_macro_functions()
481 /* Init LED device for record LED */ in k90_init_macro_functions()
482 name_sz = strlen(dev_name(&dev->dev)) + sizeof(K90_RECORD_LED_SUFFIX); in k90_init_macro_functions()
485 ret = -ENOMEM; in k90_init_macro_functions()
489 dev_name(&dev->dev)); in k90_init_macro_functions()
490 k90->record_led.removed = false; in k90_init_macro_functions()
491 k90->record_led.cdev.name = name; in k90_init_macro_functions()
492 k90->record_led.cdev.max_brightness = 1; in k90_init_macro_functions()
493 k90->record_led.cdev.brightness_set = k90_brightness_set; in k90_init_macro_functions()
494 k90->record_led.cdev.brightness_get = k90_record_led_get; in k90_init_macro_functions()
495 INIT_WORK(&k90->record_led.work, k90_record_led_work); in k90_init_macro_functions()
496 k90->record_led.brightness = 0; in k90_init_macro_functions()
497 ret = led_classdev_register(&dev->dev, &k90->record_led.cdev); in k90_init_macro_functions()
502 ret = sysfs_create_group(&dev->dev.kobj, &k90_attr_group); in k90_init_macro_functions()
509 k90->record_led.removed = true; in k90_init_macro_functions()
510 led_classdev_unregister(&k90->record_led.cdev); in k90_init_macro_functions()
511 cancel_work_sync(&k90->record_led.work); in k90_init_macro_functions()
513 kfree(k90->record_led.cdev.name); in k90_init_macro_functions()
517 drvdata->k90 = NULL; in k90_init_macro_functions()
525 if (drvdata->backlight) { in k90_cleanup_backlight()
526 drvdata->backlight->removed = true; in k90_cleanup_backlight()
527 led_classdev_unregister(&drvdata->backlight->cdev); in k90_cleanup_backlight()
528 cancel_work_sync(&drvdata->backlight->work); in k90_cleanup_backlight()
529 kfree(drvdata->backlight->cdev.name); in k90_cleanup_backlight()
530 kfree(drvdata->backlight); in k90_cleanup_backlight()
537 struct k90_drvdata *k90 = drvdata->k90; in k90_cleanup_macro_functions()
540 sysfs_remove_group(&dev->dev.kobj, &k90_attr_group); in k90_cleanup_macro_functions()
542 k90->record_led.removed = true; in k90_cleanup_macro_functions()
543 led_classdev_unregister(&k90->record_led.cdev); in k90_cleanup_macro_functions()
544 cancel_work_sync(&k90->record_led.work); in k90_cleanup_macro_functions()
545 kfree(k90->record_led.cdev.name); in k90_cleanup_macro_functions()
554 unsigned long quirks = id->driver_data; in corsair_probe()
559 return -EINVAL; in corsair_probe()
561 usbif = to_usb_interface(dev->dev.parent); in corsair_probe()
563 drvdata = devm_kzalloc(&dev->dev, sizeof(struct corsair_drvdata), in corsair_probe()
566 return -ENOMEM; in corsair_probe()
567 drvdata->quirks = quirks; in corsair_probe()
581 if (usbif->cur_altsetting->desc.bInterfaceNumber == 0) { in corsair_probe()
590 hid_warn(dev, "Failed to initialize K90 backlight.\n"); in corsair_probe()
610 if (!drvdata->k90) in corsair_event()
613 switch (usage->hid & HID_USAGE) { in corsair_event()
615 drvdata->k90->record_led.brightness = 1; in corsair_event()
618 drvdata->k90->record_led.brightness = 0; in corsair_event()
635 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_KEYBOARD) in corsair_input_mapping()
638 gkey = corsair_usage_to_gkey(usage->hid & HID_USAGE); in corsair_input_mapping()
641 corsair_gkey_map[gkey - 1]); in corsair_input_mapping()
644 if ((usage->hid & HID_USAGE) >= CORSAIR_USAGE_SPECIAL_MIN && in corsair_input_mapping()
645 (usage->hid & HID_USAGE) <= CORSAIR_USAGE_SPECIAL_MAX) { in corsair_input_mapping()
646 switch (usage->hid & HID_USAGE) { in corsair_input_mapping()
673 return -1; in corsair_input_mapping()
689 * - USB ID 1b1c:1b34, sold as GLAIVE RGB Gaming mouse
690 * - USB ID 1b1c:1b3e, sold as Scimitar RGB Pro Gaming mouse
696 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); in corsair_mouse_report_fixup()
698 if (intf->cur_altsetting->desc.bInterfaceNumber == 1) { in corsair_mouse_report_fixup()
706 switch (hdev->product) { in corsair_mouse_report_fixup()