aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel <pavel@ucw.cz>2018-11-24 00:29:25 +0100
committerPavel <pavel@ucw.cz>2018-11-24 00:29:25 +0100
commite7d6d170f2f45ea7a42c9ebb31869f440382e3ad (patch)
treebb8caf3ba1b2987bd5240dc5ad08864e077b4b7c
parent802852b3ef34f027a41194b7bb88632a76113811 (diff)
downloadlinux-n900-m-v4.20-rc2.9-7.tar.gz
leds: ledtrig-sound: provide indication of muted microphonem-v4.20-rc2.9-7
Ok, what about something like this? Tested, and it did not work. I guess I hooked it up at the wrong place in LED subsystem... or maybe thinkpad x60 is wrong machine to test on. Anyway, it looks less ugly than current code in alsa. We should not really be using mixer settings to turn LED on and off. Signed-off-by: Pavel Machek <pavel@ucw.cz> Cc: linux-leds@vger.kernel.org, jacek.anaszewski@gmail.com Cc: Takashi Iwai <tiwai@suse.de>, Andy Shevchenko <andy.shevchenko@gmail.com>, Platform Driver <platform-driver-x86@vger.kernel.org>
-rw-r--r--drivers/leds/trigger/Makefile1
-rw-r--r--drivers/leds/trigger/ledtrig-sound.c23
-rw-r--r--include/linux/leds.h8
-rw-r--r--sound/pci/hda/hda_generic.c2
-rw-r--r--sound/pci/hda/thinkpad_helper.c2
5 files changed, 36 insertions, 0 deletions
diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile
index 9bcb64ee81231b..c5ea19e8011e3f 100644
--- a/drivers/leds/trigger/Makefile
+++ b/drivers/leds/trigger/Makefile
@@ -14,3 +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-y += ledtrig-sound.o
diff --git a/drivers/leds/trigger/ledtrig-sound.c b/drivers/leds/trigger/ledtrig-sound.c
new file mode 100644
index 00000000000000..608df359d781ba
--- /dev/null
+++ b/drivers/leds/trigger/ledtrig-sound.c
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2018 Pavel Machek <pavel@ucw.cz>
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/leds.h>
+
+DEFINE_LED_TRIGGER(ledtrig_micmute);
+
+void ledtrig_mic_muted(bool muted)
+{
+ led_trigger_event(ledtrig_micmute, muted ? LED_FULL : LED_OFF);
+}
+EXPORT_SYMBOL(ledtrig_mic_muted);
+
+static int __init ledtrig_micmute_init(void)
+{
+ led_trigger_register_simple("mic-muted", &ledtrig_micmute);
+
+ return 0;
+}
+device_initcall(ledtrig_micmute_init);
diff --git a/include/linux/leds.h b/include/linux/leds.h
index e4a9a008dc6644..c30e1cb2c922aa 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -494,6 +494,14 @@ static inline void ledtrig_cpu(enum cpu_led_event evt)
}
#endif
+#ifdef CONFIG_LEDS_TRIGGERS
+extern void ledtrig_mic_muted(bool m);
+#else
+static inline void ledtrig_mic_muted(bool m) {}
+#endif
+
+
+
#ifdef CONFIG_LEDS_BRIGHTNESS_HW_CHANGED
extern void led_classdev_notify_brightness_hw_changed(
struct led_classdev *led_cdev, enum led_brightness brightness);
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 276150f29cda90..3ec1f61ebfe64e 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -29,6 +29,7 @@
#include <linux/string.h>
#include <linux/bitops.h>
#include <linux/module.h>
+#include <linux/leds.h>
#include <sound/core.h>
#include <sound/jack.h>
#include <sound/tlv.h>
@@ -3929,6 +3930,7 @@ static void call_micmute_led_update(struct hda_codec *codec)
val = !spec->micmute_led.capture;
break;
}
+ ledtrig_mic_muted(!spec->micmute_led.capture);
if (val == spec->micmute_led.led_value)
return;
diff --git a/sound/pci/hda/thinkpad_helper.c b/sound/pci/hda/thinkpad_helper.c
index 568575b72f2f72..f1b2265e83f9cb 100644
--- a/sound/pci/hda/thinkpad_helper.c
+++ b/sound/pci/hda/thinkpad_helper.c
@@ -23,6 +23,8 @@ static void update_tpacpi_mute_led(void *private_data, int enabled)
if (old_vmaster_hook)
old_vmaster_hook(private_data, enabled);
+ printk("mute led... %d\n", !enabled);
+
if (led_set_func)
led_set_func(TPACPI_LED_MUTE, !enabled);
}