Lines Matching +full:led +full:-
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * MSI GT683R led driver
14 #include "hid-ids.h"
63 struct device *dev = led_cdev->dev->parent; in gt683r_brightness_set()
65 struct gt683r_led *led = hid_get_drvdata(hdev); in gt683r_brightness_set() local
68 if (led_cdev == &led->led_devs[i]) in gt683r_brightness_set()
73 led->brightnesses[i] = brightness; in gt683r_brightness_set()
74 schedule_work(&led->work); in gt683r_brightness_set()
83 struct hid_device *hdev = to_hid_device(dev->parent); in mode_show()
84 struct gt683r_led *led = hid_get_drvdata(hdev); in mode_show() local
86 if (led->mode == GT683R_LED_NORMAL) in mode_show()
88 else if (led->mode == GT683R_LED_AUDIO) in mode_show()
101 struct hid_device *hdev = to_hid_device(dev->parent); in mode_store()
102 struct gt683r_led *led = hid_get_drvdata(hdev); in mode_store() local
106 return -EINVAL; in mode_store()
108 mutex_lock(&led->lock); in mode_store()
111 led->mode = GT683R_LED_NORMAL; in mode_store()
113 led->mode = GT683R_LED_AUDIO; in mode_store()
115 led->mode = GT683R_LED_BREATHING; in mode_store()
117 mutex_unlock(&led->lock); in mode_store()
118 schedule_work(&led->work); in mode_store()
123 static int gt683r_led_snd_msg(struct gt683r_led *led, u8 *msg) in gt683r_led_snd_msg() argument
127 ret = hid_hw_raw_request(led->hdev, msg[0], msg, GT683R_BUFFER_SIZE, in gt683r_led_snd_msg()
130 hid_err(led->hdev, in gt683r_led_snd_msg()
134 return -EIO; in gt683r_led_snd_msg()
140 static int gt683r_leds_set(struct gt683r_led *led, u8 leds) in gt683r_leds_set() argument
147 return -ENOMEM; in gt683r_leds_set()
153 ret = gt683r_led_snd_msg(led, buffer); in gt683r_leds_set()
159 static int gt683r_mode_set(struct gt683r_led *led, u8 mode) in gt683r_mode_set() argument
166 return -ENOMEM; in gt683r_mode_set()
173 ret = gt683r_led_snd_msg(led, buffer); in gt683r_mode_set()
184 struct gt683r_led *led = container_of(work, struct gt683r_led, work); in gt683r_led_work() local
186 mutex_lock(&led->lock); in gt683r_led_work()
189 if (led->brightnesses[i]) in gt683r_led_work()
193 if (gt683r_leds_set(led, leds)) in gt683r_led_work()
197 mode = led->mode; in gt683r_led_work()
201 gt683r_mode_set(led, mode); in gt683r_led_work()
203 mutex_unlock(&led->lock); in gt683r_led_work()
230 struct gt683r_led *led; in gt683r_led_probe() local
232 led = devm_kzalloc(&hdev->dev, sizeof(*led), GFP_KERNEL); in gt683r_led_probe()
233 if (!led) in gt683r_led_probe()
234 return -ENOMEM; in gt683r_led_probe()
236 mutex_init(&led->lock); in gt683r_led_probe()
237 INIT_WORK(&led->work, gt683r_led_work); in gt683r_led_probe()
239 led->mode = GT683R_LED_NORMAL; in gt683r_led_probe()
240 led->hdev = hdev; in gt683r_led_probe()
241 hid_set_drvdata(hdev, led); in gt683r_led_probe()
256 name_sz = strlen(dev_name(&hdev->dev)) + in gt683r_led_probe()
259 name = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL); in gt683r_led_probe()
261 ret = -ENOMEM; in gt683r_led_probe()
266 dev_name(&hdev->dev), gt683r_panel_names[i]); in gt683r_led_probe()
267 led->led_devs[i].name = name; in gt683r_led_probe()
268 led->led_devs[i].max_brightness = 1; in gt683r_led_probe()
269 led->led_devs[i].brightness_set = gt683r_brightness_set; in gt683r_led_probe()
270 led->led_devs[i].groups = gt683r_led_groups; in gt683r_led_probe()
272 ret = led_classdev_register(&hdev->dev, &led->led_devs[i]); in gt683r_led_probe()
274 hid_err(hdev, "could not register led device\n"); in gt683r_led_probe()
282 for (i = i - 1; i >= 0; i--) in gt683r_led_probe()
283 led_classdev_unregister(&led->led_devs[i]); in gt683r_led_probe()
291 struct gt683r_led *led = hid_get_drvdata(hdev); in gt683r_led_remove() local
294 led_classdev_unregister(&led->led_devs[i]); in gt683r_led_remove()
295 flush_work(&led->work); in gt683r_led_remove()
309 MODULE_DESCRIPTION("MSI GT683R led driver");