Skip to content

Commit a24de38

Browse files
hkallweitlag-linaro
authored andcommitted
ALSA: control-led: Integrate mute led trigger
This driver is the only one calling ledtrig_audio_set(), therefore the LED audio trigger isn't usable standalone. So it makes sense to fully integrate LED audio triger handling here. The module aliases ensure that the driver is auto-loaded (if built as module) if a LED device has one of the two audio triggers as default trigger. In addition disable building the old audio mute LED trigger. Signed-off-by: Heiner Kallweit <[email protected]> Reviewed-by: Takashi Iwai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 822c91e commit a24de38

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

drivers/leds/trigger/Kconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ config LEDS_TRIGGER_PATTERN
136136
which is a series of tuples, of brightness and duration (ms).
137137
If unsure, say N
138138

139-
config LEDS_TRIGGER_AUDIO
140-
tristate "Audio Mute LED Trigger"
141-
help
142-
This allows LEDs to be controlled by audio drivers for following
143-
the audio mute and mic-mute changes.
144-
If unsure, say N
145-
146139
config LEDS_TRIGGER_TTY
147140
tristate "LED Trigger for TTY devices"
148141
depends on TTY

drivers/leds/trigger/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o
1414
obj-$(CONFIG_LEDS_TRIGGER_PANIC) += ledtrig-panic.o
1515
obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o
1616
obj-$(CONFIG_LEDS_TRIGGER_PATTERN) += ledtrig-pattern.o
17-
obj-$(CONFIG_LEDS_TRIGGER_AUDIO) += ledtrig-audio.o
1817
obj-$(CONFIG_LEDS_TRIGGER_TTY) += ledtrig-tty.o

sound/core/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,5 @@ config SND_CTL_LED
262262
tristate
263263
select NEW_LEDS if SND_CTL_LED
264264
select LEDS_TRIGGERS if SND_CTL_LED
265-
select LEDS_TRIGGER_AUDIO if SND_CTL_LED
266265

267266
source "sound/core/seq/Kconfig"

sound/core/control_led.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct snd_ctl_led_ctl {
5353

5454
static DEFINE_MUTEX(snd_ctl_led_mutex);
5555
static bool snd_ctl_led_card_valid[SNDRV_CARDS];
56+
static struct led_trigger *snd_ctl_ledtrig_audio[NUM_AUDIO_LEDS];
5657
static struct snd_ctl_led snd_ctl_leds[MAX_LED] = {
5758
{
5859
.name = "speaker",
@@ -174,8 +175,11 @@ static void snd_ctl_led_set_state(struct snd_card *card, unsigned int access,
174175
case MODE_FOLLOW_ROUTE: if (route >= 0) route ^= 1; break;
175176
case MODE_FOLLOW_MUTE: /* noop */ break;
176177
}
177-
if (route >= 0)
178-
ledtrig_audio_set(led->trigger_type, route ? LED_OFF : LED_ON);
178+
if (route >= 0) {
179+
struct led_trigger *trig = snd_ctl_ledtrig_audio[led->trigger_type];
180+
181+
led_trigger_event(trig, route ? LED_OFF : LED_ON);
182+
}
179183
}
180184

181185
static struct snd_ctl_led_ctl *snd_ctl_led_find(struct snd_kcontrol *kctl, unsigned int ioff)
@@ -425,8 +429,9 @@ static ssize_t brightness_show(struct device *dev,
425429
struct device_attribute *attr, char *buf)
426430
{
427431
struct snd_ctl_led *led = container_of(dev, struct snd_ctl_led, dev);
432+
struct led_trigger *trig = snd_ctl_ledtrig_audio[led->trigger_type];
428433

429-
return sysfs_emit(buf, "%u\n", ledtrig_audio_get(led->trigger_type));
434+
return sysfs_emit(buf, "%u\n", led_trigger_get_brightness(trig));
430435
}
431436

432437
static DEVICE_ATTR_RW(mode);
@@ -716,6 +721,9 @@ static int __init snd_ctl_led_init(void)
716721
struct snd_ctl_led *led;
717722
unsigned int group;
718723

724+
led_trigger_register_simple("audio-mute", &snd_ctl_ledtrig_audio[LED_AUDIO_MUTE]);
725+
led_trigger_register_simple("audio-micmute", &snd_ctl_ledtrig_audio[LED_AUDIO_MICMUTE]);
726+
719727
device_initialize(&snd_ctl_led_dev);
720728
snd_ctl_led_dev.class = &sound_class;
721729
snd_ctl_led_dev.release = snd_ctl_led_dev_release;
@@ -768,7 +776,13 @@ static void __exit snd_ctl_led_exit(void)
768776
}
769777
device_unregister(&snd_ctl_led_dev);
770778
snd_ctl_led_clean(NULL);
779+
780+
led_trigger_unregister_simple(snd_ctl_ledtrig_audio[LED_AUDIO_MUTE]);
781+
led_trigger_unregister_simple(snd_ctl_ledtrig_audio[LED_AUDIO_MICMUTE]);
771782
}
772783

773784
module_init(snd_ctl_led_init)
774785
module_exit(snd_ctl_led_exit)
786+
787+
MODULE_ALIAS("ledtrig:audio-mute");
788+
MODULE_ALIAS("ledtrig:audio-micmute");

0 commit comments

Comments
 (0)