[alsa-devel] [PATCH 1/5] Unify M-Audio Fast Track Ultra and Ebox-44 mixer quirks.

Takashi Iwai tiwai at suse.de
Tue Apr 24 08:20:37 CEST 2012


At Mon, 23 Apr 2012 19:36:06 +0100 (BST),
Mark Hills wrote:
> 
> On Mon, 23 Apr 2012, Felix Homann wrote:
> 
> > +/* This function allows for the creation of standard UAC controls.
> > + * See the quirks for M-Audio FTUs or Ebox-44.
> > + * If you don't want to set a TLV callback pass NULL.
> > + * 
> > + * Since there doesn't seem to be a devices that needs a multichannel
> > + * version, we keep it mono for simplicity.
> > + */
> > +static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer,
> > +				unsigned int unitid,
> > +				unsigned int control,
> > +				unsigned int cmask,
> > +				int val_type,
> > +				const char *name,
> > +				snd_kcontrol_tlv_rw_t *tlv_callback)
> > +{
> > +	int err;
> > +	struct usb_mixer_elem_info *cval;
> > +	struct snd_kcontrol *kctl;
> > +
> > +	cval = kzalloc(sizeof(*cval), GFP_KERNEL);
> > +	if (!cval)
> > +		return -ENOMEM;
> > +
> > +	cval->id = unitid;
> > +	cval->mixer = mixer;
> > +	cval->val_type = val_type;
> > +	cval->channels = 1;
> > +	cval->control = control;
> > +	cval->cmask = cmask;
> > +
> > +	/* FIXME: Do we need this?
> > +	 * The following values are for compatibility with
> > +	 * Ebox-44 mixer.
> > +	 * But the corresponding ebox-44 function says:
> > +	 *    "Volume controls will override these values"
> > +	 * 
> > +	 * These values don't have any effect at all for
> > +	 * M-Audio FTUs.
> > +	 * So I think, we can safely omit the range settings here.
> > +	 */
> > +	cval->min = 0;
> > +	cval->max = 1;
> > +	cval->res = 0;
> > +	cval->dBmin = 0;
> > +	cval->dBmax = 0;
> 
> When implementing the Ebox44 quirk, I found I needed this. The min and max 
> would be automatically completed for the S16 values, but not for the mute 
> buttons, so I defaulted to the range required for the BOOLEAN.
> 
> I was really hoping some one would explain this when I RFC'd the patch. 
> But at that time the code was not part of some general-purpose function so 
> it wasn't really an issue.

The reason is because get_min_max*() isn't called in the place you
created these controls, and get_min_max() would be called only for
integer volumes later even if uninitialized.  A short cut for booleans.


Takashi


More information about the Alsa-devel mailing list