[alsa-devel] [PATCH v2] ALSA: usb-audio: add front jack channel selector for EMU0204

Vasily Khoruzhick anarsoul at gmail.com
Wed Nov 13 10:54:27 CET 2013


On Wed, Nov 13, 2013 at 12:39 PM, Takashi Iwai <tiwai at suse.de> wrote:
>
> At Wed, 13 Nov 2013 12:32:20 +0300,
> Vasily Khoruzhick wrote:
> >
> > Add support for front jack channel selector which is present on EMU0204.
> > It allows to get 4 channels out of this soundcard.
> >
> > Tested-by: Yury Bushmelev <jay at jay-tech.ru>
> > Signed-off-by: Vasily Khoruzhick <anarsoul at gmail.com>
> > ---
> > v2: - pass constants for bRequest and bRequestType into snd_usb_ctl_msg()
> >     - implement control as an enum instead of a switch.
> >
> >  sound/usb/mixer_quirks.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 87 insertions(+)
> >
> > diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
> > index d42a584..83f8ab1 100644
> > --- a/sound/usb/mixer_quirks.c
> > +++ b/sound/usb/mixer_quirks.c
> > @@ -433,6 +433,86 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry,
> >       }
> >  }
> >
> > +/* EMU0204 */
> > +static int snd_emu0204_ch_switch_info(struct snd_kcontrol *kcontrol,
> > +                                   struct snd_ctl_elem_info *uinfo)
> > +{
> > +     static const char *texts[4] = {"1/2",
> > +                                    "3/4"
> > +     };
>
> The declared array size doesn't match.
>

Oh, sorry, my fault, will resend in few minutes.

>
>
> Takashi
>
> > +
> > +     uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
> > +     uinfo->count = 1;
> > +     uinfo->value.enumerated.items = 2;
> > +     if (uinfo->value.enumerated.item > 1)
> > +             uinfo->value.enumerated.item = 1;
> > +     strcpy(uinfo->value.enumerated.name,
> > +             texts[uinfo->value.enumerated.item]);
> > +
> > +     return 0;
> > +}
> > +
> > +static int snd_emu0204_ch_switch_get(struct snd_kcontrol *kcontrol,
> > +                                  struct snd_ctl_elem_value *ucontrol)
> > +{
> > +     ucontrol->value.enumerated.item[0] = kcontrol->private_value;
> > +     return 0;
> > +}
> > +
> > +static int snd_emu0204_ch_switch_put(struct snd_kcontrol *kcontrol,
> > +                                  struct snd_ctl_elem_value *ucontrol)
> > +{
> > +     struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
> > +     int value = ucontrol->value.enumerated.item[0];
> > +     int err, changed;
> > +     unsigned char buf[2];
>
> Better to have a sanity check of the value.  User-space can pass any
> value in theory.
>

And return -EINVAL on non-valid values? OK

>
>
> thanks,
>
> Takashi


Regards
Vasily


More information about the Alsa-devel mailing list