Re: [RFC 2/2] ASoC: rt5670: Add LED trigger support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 3/1/21 9:43 PM, Mark Brown wrote:
> On Mon, Mar 01, 2021 at 08:49:34PM +0100, Hans de Goede wrote:
>> On 3/1/21 8:15 PM, Mark Brown wrote:
> 
>>> Off the top of my head something like writing a control name into a
>>> sysfs file might work, it doesn't scale if you need to use multiple
>>> controls as rt5640 does though.
> 
>> Currently ALSA/UCM does not use sysfs files for anything, so this
>> feels very inconsistent with how all the rest of this currently works.
> 
> Yes, you'd really want to add string controls in ALSA.

Hmm, we already have SNDRV_CTL_ELEM_TYPE_BYTES controls. I think that will
work nicely actually, we can have the UCM conf file send a 0 terminated
string to the driver that way. It would be nice to have some syntactic
sugar on the UCM side to be able to actually specify a string instead
of an array of bytes, but I don't think we need any new userspace API
for this.

This can be combined with a SND_SOC_... macro + helper to add an
entry to the usual snd_kcontrol_new <codec-name>_snd_controls[] table for
this, which when the control gets set/put will walk over all the controls
and find one with a matching name and then add the access flag which
Jaroslav's code uses to control the led-trigger to the matching control.

I think that that should work nicely for the use-cases which I have
ATM and should be flexible enough for future cases. The same control
can even be written multiple times to set the flag on multiple controls
and we could have a write of an empty string clear the flag on all controls.

So in UCM (with the syntactic sugar) for the rt5640 we could then e.g.
use something like this:

# Clear Speaker Mute LED flags from all controls, then set it
# on the Speaker and HP Channel Switches
cset "name='Speaker Mute LED Control' ''"
cset "name='Speaker Mute LED Control' 'Speaker Channel Switch'"
cset "name='Speaker Mute LED Control' 'HP Channel Switch'"

Mark, does this sound like an acceptable solution to you ?

I know you will want to see the actual code before you can give me
a definitive yes on this, but I would like to know that this at least
looks like it would be acceptable to you before spending time on coding
this out and testing it.

Regards,

Hans




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux