[alsa-devel] [RFC] usb-audio: Use a table of mixer controls

Mark Hills mark at pogo.org.uk
Sat Jun 9 14:13:00 CEST 2012


On Sat, 12 May 2012, Takashi Iwai wrote:

> At Sat, 12 May 2012 00:21:14 +0100 (BST),
> Mark Hills wrote:
> > 
> > On Fri, 11 May 2012, Takashi Iwai wrote:
> > 
> > > > +/*
> > > > + * The mixer units for Ebox-44 are corrupt, and even where they
> > > > + * are valid they presents mono controls as L and R channels of
> > > > + * stereo. So we create provide a good mixer here.
> > > > + */
> > > > +struct std_mono_table ebox44_table[] = {
> > > > +	{ 4, 1, 0x0, USB_MIXER_INV_BOOLEAN, "Headphone Playback Switch", NULL },
> > > > +	{ 4, 2, 0x1, USB_MIXER_S16, "Headphone A Mix Playback Volume", NULL },
> > > > +	{ 4, 2, 0x2, USB_MIXER_S16, "Headphone B Mix Playback Volume", NULL },
> > > > +
> > > > +	{ 7, 1, 0x0, USB_MIXER_INV_BOOLEAN, "Output Playback Switch", NULL },
> > > > +	{ 7, 2, 0x1, USB_MIXER_S16, "Output A Playback Volume", NULL },
> > > > +	{ 7, 2, 0x2, USB_MIXER_S16, "Output B Playback Volume", NULL },
> > > > +
> > > > +	{ 10, 1, 0x0, USB_MIXER_INV_BOOLEAN, "Input Capture Switch", NULL },
> > > > +	{ 10, 2, 0x1, USB_MIXER_S16, "Input A Capture Volume", NULL },
> > > > +	{ 10, 2, 0x2, USB_MIXER_S16, "Input B Capture Volume", NULL },
> > > > +
> > > > +	{ }
> > > 
> > > C99 style struct initialization is preferred.  Then NULL settings can
> > > be omittted.
> > 
> > Do you mean like this?
> > 
> >   ebox44_table[] = {
> >       {
> >           .unitid = 4,
> >           .control =  1
> >           .cmask = 0x0
> >           /* etc. */
> >       }
> > 
> > Because then it becomes a lot less concise and a lot less readable?
> 
> I can't count fields more than two, so to me, C99 style is more
> readable :)

I know you can count more than two, because I see you do it with function 
calls all the time :-)

Nevertheless, I'll follow-up with revised (and tested) patches, ready for 
inclusion.
 
> > Of course, if there are more optional params in the future, then maybe.
> 
> Yep.

I see now in doing this that likely to happen is that the table becomes a 
full 'quirks' table with a mix of mono and stereo entries etc..

[...]
> Takashi

-- 
Mark


More information about the Alsa-devel mailing list