[alsa-devel] What is correct way to put conditional stuff in ASoC codec driver?

Mark Brown broonie at opensource.wolfsonmicro.com
Tue Jul 5 00:34:20 CEST 2011

On Mon, Jul 04, 2011 at 12:26:50PM +0530, Ashish Chavan wrote:
> On Fri, 2011-07-01 at 21:47 +0530, Mark Brown wrote:

> > This requirement is actually fairly unusual, but there's plenty of
> > drivers with open coded controls for various reasons.  Have you tried
> > looking at the existing drivers in mainline?

> Do you mean the requirement of having interdependent codec functionality
> is unusual? If yes, then it is something different that what I expected

Yes, or at least the need to actually worry about it is.

> and I need to do some homework before asking further questions. By
> "Homework" I roughly mean, 

> (1) Going through data sheets of some of Wolfsons' codecs to find out if
> they have similar inter dependent functional blocks.

There should be no need to look at one particular vendor.

> (2) If something is found, have a detailed look at that codec's driver
> in mainline. Find out how these functions are handled.

I really don't understand the difficulties you are having here.  There
are many examples of drivers implementing custom handling for controls
in the kernel, some of which do things that sound fairly similar to what
you're doing (though not exactly the same thing mostly).

> I haven't done this exercise yet, mainly because I assumed that my
> requirement is common and I could easily find a way to handle it from
> existing drivers or experts!

So when you looked at the drivers what did you see?  I already told you
what you need to do:

| You'd need to implement custom controls for the relevant enables which
| check to see what is currently enabled and prevents enables if there
| are conflicts.  You should do this dynamically and I'd expect that only

All you're doing is trying to restrict the values that can be set on a
control dynamically.

> In general, I have gone through some of the existing codec drivers in
> mainline to get a feel of them but couldn't find something that handles
> conditional part. May be I am missing something.

Please be more concrete about what you looked at and what you didn't
find which you were expecting.  Any custom control should at least
include some bounds checking so it's very surprising you weren't able to
find any examples of how you could prevent the user setting invalid

More information about the Alsa-devel mailing list