Skip to content

Commit

Permalink
ALSA: usb-audio: more control quirks for M-Audio FastTrack devices
Browse files Browse the repository at this point in the history
Make use of the freshly introduced methods to re-use standard mixer
handling and add some controls that are hidden but implemented in a
standard conform way on M-Audio's FastTrack devices.

Signed-off-by: Daniel Mack <[email protected]>
Original-code-by: Felix Homann <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
zonque authored and tiwai committed May 25, 2011
1 parent 014950b commit d5a0bf6
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
70 changes: 70 additions & 0 deletions sound/usb/mixer_quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#include "mixer_quirks.h"
#include "helper.h"

extern struct snd_kcontrol_new *snd_usb_feature_unit_ctl;

/*
* Sound Blaster remote control configuration
*
Expand Down Expand Up @@ -492,6 +494,69 @@ static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface *mixer,
return err;
}

/* M-Audio FastTrack Ultra quirks */

/* private_free callback */
static void usb_mixer_elem_free(struct snd_kcontrol *kctl)
{
kfree(kctl->private_data);
kctl->private_data = NULL;
}

static int snd_maudio_ftu_create_ctl(struct usb_mixer_interface *mixer,
int in, int out, const char *name)
{
struct usb_mixer_elem_info *cval;
struct snd_kcontrol *kctl;

cval = kzalloc(sizeof(*cval), GFP_KERNEL);
if (!cval)
return -ENOMEM;

cval->id = 5;
cval->mixer = mixer;
cval->val_type = USB_MIXER_S16;
cval->channels = 1;
cval->control = out + 1;
cval->cmask = 1 << in;

kctl = snd_ctl_new1(snd_usb_feature_unit_ctl, cval);
if (!kctl) {
kfree(cval);
return -ENOMEM;
}

snprintf(kctl->id.name, sizeof(kctl->id.name), name);
kctl->private_free = usb_mixer_elem_free;
return snd_usb_mixer_add_control(mixer, kctl);
}

static int snd_maudio_ftu_create_mixer(struct usb_mixer_interface *mixer)
{
char name[64];
int in, out, err;

for (out = 0; out < 8; out++) {
for (in = 0; in < 8; in++) {
snprintf(name, sizeof(name),
"AIn%d - Out%d Capture Volume", in + 1, out + 1);
err = snd_maudio_ftu_create_ctl(mixer, in, out, name);
if (err < 0)
return err;
}

for (in = 8; in < 16; in++) {
snprintf(name, sizeof(name),
"DIn%d - Out%d Playback Volume", in - 7, out + 1);
err = snd_maudio_ftu_create_ctl(mixer, in, out, name);
if (err < 0)
return err;
}
}

return 0;
}

void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
unsigned char samplerate_id)
{
Expand Down Expand Up @@ -533,6 +598,11 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
snd_audigy2nx_proc_read);
break;

case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */
case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
err = snd_maudio_ftu_create_mixer(mixer);
break;

case USB_ID(0x0b05, 0x1739):
case USB_ID(0x0b05, 0x1743):
err = snd_xonar_u1_controls_create(mixer);
Expand Down
4 changes: 2 additions & 2 deletions sound/usb/quirks-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -1988,7 +1988,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
.data = & (const struct snd_usb_audio_quirk[]) {
{
.ifnum = 0,
.type = QUIRK_IGNORE_INTERFACE
.type = QUIRK_AUDIO_STANDARD_MIXER,
},
{
.ifnum = 1,
Expand Down Expand Up @@ -2055,7 +2055,7 @@ YAMAHA_DEVICE(0x7010, "UB99"),
.data = & (const struct snd_usb_audio_quirk[]) {
{
.ifnum = 0,
.type = QUIRK_IGNORE_INTERFACE
.type = QUIRK_AUDIO_STANDARD_MIXER,
},
{
.ifnum = 1,
Expand Down

0 comments on commit d5a0bf6

Please sign in to comment.