Lines Matching +full:led +full:- +full:1
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * MSI GT683R led driver
14 #include "hid-ids.h"
33 GT683R_LED_SIDE = 1,
62 struct device *dev = led_cdev->dev->parent; in gt683r_brightness_set()
64 struct gt683r_led *led = hid_get_drvdata(hdev); in gt683r_brightness_set() local
67 if (led_cdev == &led->led_devs[i]) in gt683r_brightness_set()
72 led->brightnesses[i] = brightness; in gt683r_brightness_set()
73 schedule_work(&led->work); in gt683r_brightness_set()
82 struct hid_device *hdev = to_hid_device(dev->parent); in mode_show()
83 struct gt683r_led *led = hid_get_drvdata(hdev); in mode_show() local
85 if (led->mode == GT683R_LED_NORMAL) in mode_show()
87 else if (led->mode == GT683R_LED_AUDIO) in mode_show()
88 sysfs_mode = 1; in mode_show()
100 struct hid_device *hdev = to_hid_device(dev->parent); in mode_store()
101 struct gt683r_led *led = hid_get_drvdata(hdev); in mode_store() local
105 return -EINVAL; in mode_store()
107 mutex_lock(&led->lock); in mode_store()
110 led->mode = GT683R_LED_NORMAL; in mode_store()
111 else if (sysfs_mode == 1) in mode_store()
112 led->mode = GT683R_LED_AUDIO; in mode_store()
114 led->mode = GT683R_LED_BREATHING; in mode_store()
116 mutex_unlock(&led->lock); in mode_store()
117 schedule_work(&led->work); in mode_store()
122 static int gt683r_led_snd_msg(struct gt683r_led *led, u8 *msg) in gt683r_led_snd_msg() argument
126 ret = hid_hw_raw_request(led->hdev, msg[0], msg, GT683R_BUFFER_SIZE, in gt683r_led_snd_msg()
129 hid_err(led->hdev, in gt683r_led_snd_msg()
133 return -EIO; in gt683r_led_snd_msg()
139 static int gt683r_leds_set(struct gt683r_led *led, u8 leds) in gt683r_leds_set() argument
146 return -ENOMEM; in gt683r_leds_set()
149 buffer[1] = 0x02; in gt683r_leds_set()
152 ret = gt683r_led_snd_msg(led, buffer); in gt683r_leds_set()
158 static int gt683r_mode_set(struct gt683r_led *led, u8 mode) in gt683r_mode_set() argument
165 return -ENOMEM; in gt683r_mode_set()
168 buffer[1] = 0x02; in gt683r_mode_set()
172 ret = gt683r_led_snd_msg(led, buffer); in gt683r_mode_set()
183 struct gt683r_led *led = container_of(work, struct gt683r_led, work); in gt683r_led_work() local
185 mutex_lock(&led->lock); in gt683r_led_work()
188 if (led->brightnesses[i]) in gt683r_led_work()
192 if (gt683r_leds_set(led, leds)) in gt683r_led_work()
196 mode = led->mode; in gt683r_led_work()
200 gt683r_mode_set(led, mode); in gt683r_led_work()
202 mutex_unlock(&led->lock); in gt683r_led_work()
229 struct gt683r_led *led; in gt683r_led_probe() local
231 led = devm_kzalloc(&hdev->dev, sizeof(*led), GFP_KERNEL); in gt683r_led_probe()
232 if (!led) in gt683r_led_probe()
233 return -ENOMEM; in gt683r_led_probe()
235 mutex_init(&led->lock); in gt683r_led_probe()
236 INIT_WORK(&led->work, gt683r_led_work); in gt683r_led_probe()
238 led->mode = GT683R_LED_NORMAL; in gt683r_led_probe()
239 led->hdev = hdev; in gt683r_led_probe()
240 hid_set_drvdata(hdev, led); in gt683r_led_probe()
255 name_sz = strlen(dev_name(&hdev->dev)) + in gt683r_led_probe()
258 name = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL); in gt683r_led_probe()
260 ret = -ENOMEM; in gt683r_led_probe()
265 dev_name(&hdev->dev), gt683r_panel_names[i]); in gt683r_led_probe()
266 led->led_devs[i].name = name; in gt683r_led_probe()
267 led->led_devs[i].max_brightness = 1; in gt683r_led_probe()
268 led->led_devs[i].brightness_set = gt683r_brightness_set; in gt683r_led_probe()
269 led->led_devs[i].groups = gt683r_led_groups; in gt683r_led_probe()
271 ret = led_classdev_register(&hdev->dev, &led->led_devs[i]); in gt683r_led_probe()
273 hid_err(hdev, "could not register led device\n"); in gt683r_led_probe()
281 for (i = i - 1; i >= 0; i--) in gt683r_led_probe()
282 led_classdev_unregister(&led->led_devs[i]); in gt683r_led_probe()
290 struct gt683r_led *led = hid_get_drvdata(hdev); in gt683r_led_remove() local
293 led_classdev_unregister(&led->led_devs[i]); in gt683r_led_remove()
294 flush_work(&led->work); in gt683r_led_remove()
308 MODULE_DESCRIPTION("MSI GT683R led driver");