From: Hans de Goede <hdegoede@redhat.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: "Marek Behún" <kabel@kernel.org>, "Takashi Iwai" <tiwai@suse.de>,
alsa-devel@alsa-project.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH v2] leds: trigger: audio: Add an activate callback to ensure the initial brightness is set
Date: Tue, 23 Feb 2021 10:52:34 +0100 [thread overview]
Message-ID: <6d5f521e-0484-cb22-fde5-8a6e133075a5@redhat.com> (raw)
In-Reply-To: <20210223091230.GI9750@amd>
Hi,
On 2/23/21 10:12 AM, Pavel Machek wrote:
> Hi!
>
>> Some 2-in-1s with a detachable (USB) keyboard(dock) have mute-LEDs in
>> the speaker- and/or mic-mute keys on the keyboard.
>>
>> Examples of this are the Lenovo Thinkpad10 tablet (with its USB kbd-dock)
>> and the HP x2 10 series.
>>
>> The detachable nature of these keyboards means that the keyboard and
>> thus the mute LEDs may show up after the user (or userspace restoring
>> old mixer settings) has muted the speaker and/or mic.
>>
>> Current LED-class devices with a default_trigger of "audio-mute" or
>> "audio-micmute" initialize the brightness member of led_classdev with
>> ledtrig_audio_get() before registering the LED.
>>
>> This makes the software state after attaching the keyboard match the
>> actual audio mute state, e.g. cat /sys/class/leds/foo/brightness will
>> show the right value.
>
> Makes sense.
>
>> +++ b/drivers/leds/trigger/ledtrig-audio.c
>> @@ -6,10 +6,33 @@
>> #include <linux/kernel.h>
>> #include <linux/leds.h>
>> #include <linux/module.h>
>> +#include "../leds.h"
>>
>> -static struct led_trigger *ledtrig_audio[NUM_AUDIO_LEDS];
>> static enum led_brightness audio_state[NUM_AUDIO_LEDS];
>>
>> +static int ledtrig_audio_mute_activate(struct led_classdev *led_cdev)
>> +{
>> + led_set_brightness_nosleep(led_cdev, audio_state[LED_AUDIO_MUTE]);
>> + return 0;
>> +}
>
> Is mute_activate called from atomic context?
All the other ledtrig-foo.c activate callbacks use led_set_brightness_nosleep(),
so yes I would assume so (I did not check, I assumed the others have good
reasons to do this).
Regards,
Hans
next prev parent reply other threads:[~2021-02-23 9:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-21 11:52 [PATCH v2] leds: trigger: audio: Add an activate callback to ensure the initial brightness is set Hans de Goede
2021-02-23 9:12 ` Pavel Machek
2021-02-23 9:52 ` Hans de Goede [this message]
2021-02-24 7:58 ` 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=6d5f521e-0484-cb22-fde5-8a6e133075a5@redhat.com \
--to=hdegoede@redhat.com \
--cc=alsa-devel@alsa-project.org \
--cc=kabel@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=tiwai@suse.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).