1 // SPDX-License-Identifier: GPL-2.0 2 // 3 // Audio Mute LED trigger 4 // 5 6 #include <linux/kernel.h> 7 #include <linux/leds.h> 8 #include <linux/module.h> 9 10 static struct led_trigger *ledtrig_audio[NUM_AUDIO_LEDS]; 11 static enum led_brightness audio_state[NUM_AUDIO_LEDS]; 12 13 enum led_brightness ledtrig_audio_get(enum led_audio type) 14 { 15 return audio_state[type]; 16 } 17 EXPORT_SYMBOL_GPL(ledtrig_audio_get); 18 19 void ledtrig_audio_set(enum led_audio type, enum led_brightness state) 20 { 21 audio_state[type] = state; 22 led_trigger_event(ledtrig_audio[type], state); 23 } 24 EXPORT_SYMBOL_GPL(ledtrig_audio_set); 25 26 static int __init ledtrig_audio_init(void) 27 { 28 led_trigger_register_simple("audio-mute", 29 &ledtrig_audio[LED_AUDIO_MUTE]); 30 led_trigger_register_simple("audio-micmute", 31 &ledtrig_audio[LED_AUDIO_MICMUTE]); 32 return 0; 33 } 34 module_init(ledtrig_audio_init); 35 36 static void __exit ledtrig_audio_exit(void) 37 { 38 led_trigger_unregister_simple(ledtrig_audio[LED_AUDIO_MUTE]); 39 led_trigger_unregister_simple(ledtrig_audio[LED_AUDIO_MICMUTE]); 40 } 41 module_exit(ledtrig_audio_exit); 42 43 MODULE_DESCRIPTION("LED trigger for audio mute control"); 44 MODULE_LICENSE("GPL v2"); 45