From: Heiner Kallweit <hkallweit1@gmail.com>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: "linux-leds@vger.kernel.org" <linux-leds@vger.kernel.org>,
linux-sound@vger.kernel.org, linux-mips@vger.kernel.org
Subject: [PATCH v2 2/3] ALSA: control-led: Integrate mute led trigger
Date: Mon, 4 Mar 2024 21:58:46 +0100 [thread overview]
Message-ID: <107634e6-d9ad-4a9f-881d-1eb72ea1a5a7@gmail.com> (raw)
In-Reply-To: <3918a80c-b885-40f6-a96e-bcd4c53ff448@gmail.com>
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 <hkallweit1@gmail.com>
---
v2:
- Ensure that audio mute trigger can't be built twice.
---
drivers/leds/trigger/Kconfig | 7 -------
drivers/leds/trigger/Makefile | 1 -
sound/core/Kconfig | 1 -
sound/core/control_led.c | 20 +++++++++++++++++---
4 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig
index d11d80176..31576952e 100644
--- a/drivers/leds/trigger/Kconfig
+++ b/drivers/leds/trigger/Kconfig
@@ -136,13 +136,6 @@ config LEDS_TRIGGER_PATTERN
which is a series of tuples, of brightness and duration (ms).
If unsure, say N
-config LEDS_TRIGGER_AUDIO
- tristate "Audio Mute LED Trigger"
- help
- This allows LEDs to be controlled by audio drivers for following
- the audio mute and mic-mute changes.
- If unsure, say N
-
config LEDS_TRIGGER_TTY
tristate "LED Trigger for TTY devices"
depends on TTY
diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile
index 25c4db97c..242f6c4e3 100644
--- a/drivers/leds/trigger/Makefile
+++ b/drivers/leds/trigger/Makefile
@@ -14,5 +14,4 @@ obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o
obj-$(CONFIG_LEDS_TRIGGER_PANIC) += ledtrig-panic.o
obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o
obj-$(CONFIG_LEDS_TRIGGER_PATTERN) += ledtrig-pattern.o
-obj-$(CONFIG_LEDS_TRIGGER_AUDIO) += ledtrig-audio.o
obj-$(CONFIG_LEDS_TRIGGER_TTY) += ledtrig-tty.o
diff --git a/sound/core/Kconfig b/sound/core/Kconfig
index 8077f481d..b970a1734 100644
--- a/sound/core/Kconfig
+++ b/sound/core/Kconfig
@@ -262,6 +262,5 @@ config SND_CTL_LED
tristate
select NEW_LEDS if SND_CTL_LED
select LEDS_TRIGGERS if SND_CTL_LED
- select LEDS_TRIGGER_AUDIO if SND_CTL_LED
source "sound/core/seq/Kconfig"
diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 3d37e9fa7..061a8ea23 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -53,6 +53,7 @@ struct snd_ctl_led_ctl {
static DEFINE_MUTEX(snd_ctl_led_mutex);
static bool snd_ctl_led_card_valid[SNDRV_CARDS];
+static struct led_trigger *snd_ctl_ledtrig_audio[NUM_AUDIO_LEDS];
static struct snd_ctl_led snd_ctl_leds[MAX_LED] = {
{
.name = "speaker",
@@ -174,8 +175,11 @@ static void snd_ctl_led_set_state(struct snd_card *card, unsigned int access,
case MODE_FOLLOW_ROUTE: if (route >= 0) route ^= 1; break;
case MODE_FOLLOW_MUTE: /* noop */ break;
}
- if (route >= 0)
- ledtrig_audio_set(led->trigger_type, route ? LED_OFF : LED_ON);
+ if (route >= 0) {
+ struct led_trigger *trig = snd_ctl_ledtrig_audio[led->trigger_type];
+
+ led_trigger_event(trig, route ? LED_OFF : LED_ON);
+ }
}
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,
struct device_attribute *attr, char *buf)
{
struct snd_ctl_led *led = container_of(dev, struct snd_ctl_led, dev);
+ struct led_trigger *trig = snd_ctl_ledtrig_audio[led->trigger_type];
- return sysfs_emit(buf, "%u\n", ledtrig_audio_get(led->trigger_type));
+ return sysfs_emit(buf, "%u\n", led_trigger_get_brightness(trig));
}
static DEVICE_ATTR_RW(mode);
@@ -716,6 +721,9 @@ static int __init snd_ctl_led_init(void)
struct snd_ctl_led *led;
unsigned int group;
+ led_trigger_register_simple("audio-mute", &snd_ctl_ledtrig_audio[LED_AUDIO_MUTE]);
+ led_trigger_register_simple("audio-micmute", &snd_ctl_ledtrig_audio[LED_AUDIO_MICMUTE]);
+
device_initialize(&snd_ctl_led_dev);
snd_ctl_led_dev.class = &sound_class;
snd_ctl_led_dev.release = snd_ctl_led_dev_release;
@@ -768,7 +776,13 @@ static void __exit snd_ctl_led_exit(void)
}
device_unregister(&snd_ctl_led_dev);
snd_ctl_led_clean(NULL);
+
+ led_trigger_unregister_simple(snd_ctl_ledtrig_audio[LED_AUDIO_MUTE]);
+ led_trigger_unregister_simple(snd_ctl_ledtrig_audio[LED_AUDIO_MICMUTE]);
}
module_init(snd_ctl_led_init)
module_exit(snd_ctl_led_exit)
+
+MODULE_ALIAS("ledtrig:audio-mute");
+MODULE_ALIAS("ledtrig:audio-micmute");
--
2.44.0
next prev parent reply other threads:[~2024-03-04 20:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 20:56 [PATCH v2 0/3] leds: trigger: Improve handling of led_trigger_event() and simplify mute audio trigger Heiner Kallweit
2024-03-04 20:57 ` [PATCH v2 1/3] leds: trigger: Store brightness set by led_trigger_event() Heiner Kallweit
2024-03-04 20:58 ` Heiner Kallweit [this message]
2024-03-04 20:59 ` [PATCH v2 3/3] leds: trigger: audio: Remove this trigger Heiner Kallweit
2024-03-05 9:08 ` [PATCH v2 0/3] leds: trigger: Improve handling of led_trigger_event() and simplify mute audio trigger Takashi Iwai
2024-03-05 12:08 ` Lee Jones
2024-03-05 12:09 ` Lee Jones
2024-03-05 14:54 ` Lee Jones
2024-03-05 15:56 ` Heiner Kallweit
2024-03-05 16:06 ` Lee Jones
2024-03-08 17:30 ` Heiner Kallweit
2024-03-27 12:08 ` Heiner Kallweit
2024-03-27 13:14 ` Lee Jones
2024-03-28 10:42 ` Lee Jones
2024-04-05 9:22 ` Heiner Kallweit
2024-04-11 9:22 ` Lee Jones
2024-04-11 15:44 ` [GIT PULL] Immutable branch between MFD, MIPS and Sound due for the v6.10 merge window Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=107634e6-d9ad-4a9f-881d-1eb72ea1a5a7@gmail.com \
--to=hkallweit1@gmail.com \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=tsbogend@alpha.franken.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).