From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Cc: "Ayman Bagabas" <ayman.bagabas@gmail.com>,
platform-driver-x86@vger.kernel.org,
"Hui Wang" <hui.wang@canonical.com>,
ibm-acpi-devel@lists.sourceforge.net,
"Jacek Anaszewski" <jacek.anaszewski@gmail.com>,
"Pavel Machek" <pavel@ucw.cz>,
"Pali Rohár" <pali.rohar@gmail.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
linux-leds@vger.kernel.org
Subject: [PATCH 2/6] platform/x86: dell-laptop: Add micmute LED trigger support
Date: Mon, 26 Nov 2018 18:11:22 +0100 [thread overview]
Message-ID: <20181126171126.20280-3-tiwai@suse.de> (raw)
In-Reply-To: <20181126171126.20280-1-tiwai@suse.de>
This patch adds the LED trigger support for audio mic-mute control.
As of this patch, the LED device isn't tied with the audio driver, and
can be changed via user-space at "dell::micmute" sysfs entry. The
binding with HD-audio is still done via the existing exported
dell_micmute_led_set(). It will be replaced with the LED trigger
binding in later patches.
Also this selects CONFIG_LEDS_TRIGGERS and CONFIG_LEDS_TRIGGERS_AUDIO
unconditionally. Strictly speaking, these aren't 100% mandatory, but
leaving these manual selections would lead to a functional regression
easily once after converting from the dynamic symbol binding to the
LEDs trigger in a later patch.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
drivers/platform/x86/Kconfig | 2 ++
drivers/platform/x86/dell-laptop.c | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 54f6a40c75c6..9b9cc3cc33e9 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -177,6 +177,8 @@ config DELL_LAPTOP
select POWER_SUPPLY
select LEDS_CLASS
select NEW_LEDS
+ select LEDS_TRIGGERS
+ select LEDS_TRIGGER_AUDIO
---help---
This driver adds support for rfkill and backlight control to Dell
laptops (except for some models covered by the Compal driver).
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 06978c14c83b..6a647e2d09ee 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -2131,6 +2131,23 @@ int dell_micmute_led_set(int state)
}
EXPORT_SYMBOL_GPL(dell_micmute_led_set);
+static int micmute_led_set(struct led_classdev *led_cdev,
+ enum led_brightness brightness)
+{
+ int state = brightness != LED_OFF;
+ int err;
+
+ err = dell_micmute_led_set(state);
+ return err < 0 ? err : 0;
+}
+
+static struct led_classdev micmute_led_cdev = {
+ .name = "dell::micmute",
+ .max_brightness = 1,
+ .brightness_set_blocking = micmute_led_set,
+ .default_trigger = "audio-micmute",
+};
+
static int __init dell_init(void)
{
struct calling_interface_token *token;
@@ -2175,6 +2192,11 @@ static int __init dell_init(void)
dell_laptop_register_notifier(&dell_laptop_notifier);
+ micmute_led_cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
+ ret = led_classdev_register(&platform_device->dev, &micmute_led_cdev);
+ if (ret < 0)
+ goto fail_led;
+
if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
return 0;
@@ -2220,6 +2242,8 @@ static int __init dell_init(void)
fail_get_brightness:
backlight_device_unregister(dell_backlight_device);
fail_backlight:
+ led_classdev_unregister(&micmute_led_cdev);
+fail_led:
dell_cleanup_rfkill();
fail_rfkill:
platform_device_del(platform_device);
@@ -2239,6 +2263,7 @@ static void __exit dell_exit(void)
touchpad_led_exit();
kbd_led_exit();
backlight_device_unregister(dell_backlight_device);
+ led_classdev_unregister(&micmute_led_cdev);
dell_cleanup_rfkill();
if (platform_device) {
platform_device_unregister(platform_device);
--
2.19.1
next prev parent reply other threads:[~2018-11-26 17:11 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-26 17:11 [PATCH 0/6] Introduce audio-mute LED trigger (and conversions to it) Takashi Iwai
2018-11-26 17:11 ` Takashi Iwai [this message]
2018-11-26 17:11 ` [PATCH 3/6] platform/x86: thinkpad_acpi: Add audio mute LED classdev support Takashi Iwai
2018-11-26 23:04 ` Andy Shevchenko
2018-11-27 11:04 ` Takashi Iwai
[not found] ` <20181126171126.20280-1-tiwai-l3A5Bk7waGM@public.gmane.org>
2018-11-26 17:11 ` [PATCH 1/6] leds: trigger: Introduce audio mute LED trigger Takashi Iwai
[not found] ` <20181126171126.20280-2-tiwai-l3A5Bk7waGM@public.gmane.org>
2018-11-26 20:59 ` Jacek Anaszewski
2018-11-27 11:04 ` Takashi Iwai
2018-11-26 22:58 ` Andy Shevchenko
2018-11-27 11:04 ` Takashi Iwai
2018-11-26 17:11 ` [PATCH 4/6] ALSA: hda - Support led audio trigger Takashi Iwai
2018-11-26 17:11 ` [PATCH 6/6] platform/x86: thinkpad_acpi: Drop superfluous exported function Takashi Iwai
2018-11-26 17:11 ` [PATCH 5/6] platform/x86: dell-laptop: " Takashi Iwai
2018-11-26 23:09 ` [PATCH 0/6] Introduce audio-mute LED trigger (and conversions to it) Andy Shevchenko
2018-11-27 11:05 ` Takashi Iwai
2018-11-27 8:44 ` Pavel Machek
2018-11-27 11:06 ` Takashi Iwai
2018-11-28 11:18 ` Pali Rohár
2018-11-28 11:38 ` Takashi Iwai
2018-11-28 12:25 ` Pavel Machek
2018-11-28 12:58 ` Takashi Iwai
2018-11-28 13:40 ` Andy Shevchenko
2018-11-28 19:58 ` Jacek Anaszewski
2018-11-28 20:34 ` Pavel Machek
2018-11-28 20:46 ` Pali Rohár
2018-11-28 21:00 ` Jacek Anaszewski
2018-11-28 21:22 ` Pavel Machek
2018-11-29 21:23 ` Jacek Anaszewski
2018-11-29 21:56 ` Takashi Iwai
2018-11-30 10:42 ` Andy Shevchenko
2018-12-01 14:41 ` Well-known LED names was " Pavel Machek
2018-12-08 21:59 ` Jacek Anaszewski
2018-11-28 21:01 ` Pavel Machek
2018-11-27 10:26 ` [ibm-acpi-devel] " Henrique de Moraes Holschuh
2018-11-27 11:11 ` Takashi Iwai
2018-11-28 11:14 ` Pali Rohár
2018-11-28 11:30 ` Takashi Iwai
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=20181126171126.20280-3-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ayman.bagabas@gmail.com \
--cc=hui.wang@canonical.com \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-leds@vger.kernel.org \
--cc=pali.rohar@gmail.com \
--cc=pavel@ucw.cz \
--cc=platform-driver-x86@vger.kernel.org \
/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