Lines Matching +full:led +full:- +full:s
1 // SPDX-License-Identifier: GPL-2.0-only
3 * LED support for the input layer
5 * Copyright 2010-2015 Samuel Thibault <samuel.thibault@ens-lyon.org>
31 [LED_NUML] = { "numlock", VT_TRIGGER("kbd-numlock") },
32 [LED_CAPSL] = { "capslock", VT_TRIGGER("kbd-capslock") },
33 [LED_SCROLLL] = { "scrolllock", VT_TRIGGER("kbd-scrolllock") },
35 [LED_KANA] = { "kana", VT_TRIGGER("kbd-kanalock") },
38 [LED_MUTE] = { "mute", AUDIO_TRIGGER("audio-mute") },
58 struct input_led *led = container_of(cdev, struct input_led, cdev); in input_leds_brightness_get() local
59 struct input_dev *input = led->handle->dev; in input_leds_brightness_get()
61 return test_bit(led->code, input->led) ? cdev->max_brightness : 0; in input_leds_brightness_get()
67 struct input_led *led = container_of(cdev, struct input_led, cdev); in input_leds_brightness_set() local
69 input_inject_event(led->handle, EV_LED, led->code, !!brightness); in input_leds_brightness_set()
82 for_each_set_bit(led_code, dev->ledbit, LED_CNT) in input_leds_get_count()
94 struct input_led *led; in input_leds_connect() local
102 return -ENXIO; in input_leds_connect()
106 return -ENOMEM; in input_leds_connect()
108 leds->num_leds = num_leds; in input_leds_connect()
110 leds->handle.dev = dev; in input_leds_connect()
111 leds->handle.handler = handler; in input_leds_connect()
112 leds->handle.name = "leds"; in input_leds_connect()
113 leds->handle.private = leds; in input_leds_connect()
115 error = input_register_handle(&leds->handle); in input_leds_connect()
119 error = input_open_device(&leds->handle); in input_leds_connect()
124 for_each_set_bit(led_code, dev->ledbit, LED_CNT) { in input_leds_connect()
128 led = &leds->leds[led_no]; in input_leds_connect()
129 led->handle = &leds->handle; in input_leds_connect()
130 led->code = led_code; in input_leds_connect()
132 led->cdev.name = kasprintf(GFP_KERNEL, "%s::%s", in input_leds_connect()
133 dev_name(&dev->dev), in input_leds_connect()
135 if (!led->cdev.name) { in input_leds_connect()
136 error = -ENOMEM; in input_leds_connect()
140 led->cdev.max_brightness = 1; in input_leds_connect()
141 led->cdev.brightness_get = input_leds_brightness_get; in input_leds_connect()
142 led->cdev.brightness_set = input_leds_brightness_set; in input_leds_connect()
143 led->cdev.default_trigger = input_led_info[led_code].trigger; in input_leds_connect()
145 error = led_classdev_register(&dev->dev, &led->cdev); in input_leds_connect()
147 dev_err(&dev->dev, "failed to register LED %s: %d\n", in input_leds_connect()
148 led->cdev.name, error); in input_leds_connect()
149 kfree(led->cdev.name); in input_leds_connect()
159 while (--led_no >= 0) { in input_leds_connect()
160 struct input_led *led = &leds->leds[led_no]; in input_leds_connect() local
162 led_classdev_unregister(&led->cdev); in input_leds_connect()
163 kfree(led->cdev.name); in input_leds_connect()
166 input_close_device(&leds->handle); in input_leds_connect()
169 input_unregister_handle(&leds->handle); in input_leds_connect()
178 struct input_leds *leds = handle->private; in input_leds_disconnect()
181 for (i = 0; i < leds->num_leds; i++) { in input_leds_disconnect()
182 struct input_led *led = &leds->leds[i]; in input_leds_disconnect() local
184 led_classdev_unregister(&led->cdev); in input_leds_disconnect()
185 kfree(led->cdev.name); in input_leds_disconnect()
223 MODULE_AUTHOR("Samuel Thibault <samuel.thibault@ens-lyon.org>");
225 MODULE_DESCRIPTION("Input -> LEDs Bridge");