From: Phil Sutter <phil@nwl.cc>
To: Pavel Machek <pavel@ucw.cz>
Cc: linux-leds@vger.kernel.org
Subject: Re: [PATCH] leds: trigger: Add invert attribute to ledtrig-audio
Date: Tue, 10 Aug 2021 11:22:46 +0200 [thread overview]
Message-ID: <20210810092246.GB3673@orbyte.nwl.cc> (raw)
In-Reply-To: <20210809181118.GA16184@duo.ucw.cz>
Hi Pavel,
On Mon, Aug 09, 2021 at 08:11:18PM +0200, Pavel Machek wrote:
> > Inverting micmute LED used to be possible via a mixer setting, but
> > conversion to LEDs class (probably) killed it. Re-establish the old
> > functionality via sysfs attribute in audio LED triggers.
>
> So we have both invert and inverted attributes. Fun :-).
Hmm! :)
Are you talking about LED_BLINK_INVERT flag? I see a few triggers allow
inversion but didn't find LED drivers exporting such a property.
> See sysfs-class-led and sysfs-class-led-trigger-oneshot.
I think I "copied" from oneshot trigger when writing this patch.
> We definitely want this documented. We probably want this for most
> triggers, maybe it should get one implementation in library somewhere?
Should this be an implicit attribute of simple triggers only or all? In
the latter case (which could simplify some triggers) I guess the value
inversion has to take place in led_set_brightness_nopm(), the lowest
level function triggers may use.
How does inversion work, actually? LED_OFF <-> LED_ON is trivial, but
what about LED_HALF and LED_FULL? Leaving LED_HALF as-is seems logical,
but the opposite of LED_OFF might be LED_ON or LED_FULL. Does
max_brightness determine that?
>
> Otherwise it makes sense.
>
> > +static ssize_t do_invert_store(enum led_audio type,
> > + const char *buf, size_t size)
> > +{
> > + unsigned long state;
> > + int ret;
> > +
> > + ret = kstrtoul(buf, 0, &state);
> > + if (ret)
> > + return ret;
> > +
> > + led_invert[type] = !!state;
> > + ledtrig_audio_set(type, audio_state[type]);
>
> Accepting 42 as valid value sounds wrong. Anyway, this should do what
> oneshot trigger does.
Similarities to oneshot are not a coincidence. :)
Cheers, Phil
next prev parent reply other threads:[~2021-08-10 9:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-09 12:29 [PATCH] leds: trigger: Add invert attribute to ledtrig-audio Phil Sutter
2021-08-09 18:11 ` Pavel Machek
2021-08-10 9:22 ` Phil Sutter [this message]
2021-08-10 13:52 ` Pavel Machek
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=20210810092246.GB3673@orbyte.nwl.cc \
--to=phil@nwl.cc \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/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).