aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorEldad Zack <eldad@fogrefinery.com>2012-11-28 17:55:37 -0500
committerTakashi Iwai <tiwai@suse.de>2012-11-29 02:43:55 -0500
commitd847ce0e9a9031a3a62bbbe3ad8f37769a1a6f59 (patch)
treebbfcb247321d138a6ac8451154fbbfd3bfd7389f /sound/usb
parent5dae5fd24071319bb67d3375217d5b0b6d16cb0b (diff)
ALSA: usb-audio: parameterize FTU effect unit control
Adds the unit ID and the control as parameters to the creation of the effect unit control for the M-Audio Fast Track Ultra. This allows the code to be shared with other devices that use different unit ID and control, such as the M-Audio Fast Track C400. Signed-off-by: Eldad Zack <eldad@fogrefinery.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/mixer_quirks.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 4199b97e76a1..a614dabe82c7 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -635,11 +635,13 @@ static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface *mixer,
635} 635}
636 636
637/* M-Audio FastTrack Ultra quirks */ 637/* M-Audio FastTrack Ultra quirks */
638/* FTU Effect switch */ 638/* FTU Effect switch (also used by C400) */
639struct snd_ftu_eff_switch_priv_val { 639struct snd_ftu_eff_switch_priv_val {
640 struct usb_mixer_interface *mixer; 640 struct usb_mixer_interface *mixer;
641 int cached_value; 641 int cached_value;
642 int is_cached; 642 int is_cached;
643 int bUnitID;
644 int validx;
643}; 645};
644 646
645static int snd_ftu_eff_switch_info(struct snd_kcontrol *kcontrol, 647static int snd_ftu_eff_switch_info(struct snd_kcontrol *kcontrol,
@@ -674,9 +676,8 @@ static int snd_ftu_eff_switch_get(struct snd_kcontrol *kctl,
674 struct snd_ftu_eff_switch_priv_val *pval; 676 struct snd_ftu_eff_switch_priv_val *pval;
675 int err; 677 int err;
676 unsigned char value[2]; 678 unsigned char value[2];
679 int id, validx;
677 680
678 const int id = 6;
679 const int validx = 1;
680 const int val_len = 2; 681 const int val_len = 2;
681 682
682 value[0] = 0x00; 683 value[0] = 0x00;
@@ -698,6 +699,8 @@ static int snd_ftu_eff_switch_get(struct snd_kcontrol *kctl,
698 if (snd_BUG_ON(!chip)) 699 if (snd_BUG_ON(!chip))
699 return -EINVAL; 700 return -EINVAL;
700 701
702 id = pval->bUnitID;
703 validx = pval->validx;
701 704
702 down_read(&mixer->chip->shutdown_rwsem); 705 down_read(&mixer->chip->shutdown_rwsem);
703 if (mixer->chip->shutdown) 706 if (mixer->chip->shutdown)
@@ -728,10 +731,8 @@ static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
728 struct usb_mixer_interface *mixer; 731 struct usb_mixer_interface *mixer;
729 int changed, cur_val, err, new_val; 732 int changed, cur_val, err, new_val;
730 unsigned char value[2]; 733 unsigned char value[2];
734 int id, validx;
731 735
732
733 const int id = 6;
734 const int validx = 1;
735 const int val_len = 2; 736 const int val_len = 2;
736 737
737 changed = 0; 738 changed = 0;
@@ -749,6 +750,9 @@ static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
749 if (snd_BUG_ON(!chip)) 750 if (snd_BUG_ON(!chip))
750 return -EINVAL; 751 return -EINVAL;
751 752
753 id = pval->bUnitID;
754 validx = pval->validx;
755
752 if (!pval->is_cached) { 756 if (!pval->is_cached) {
753 /* Read current value */ 757 /* Read current value */
754 down_read(&mixer->chip->shutdown_rwsem); 758 down_read(&mixer->chip->shutdown_rwsem);
@@ -793,7 +797,8 @@ static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
793 return changed; 797 return changed;
794} 798}
795 799
796static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer) 800static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer,
801 int validx, int bUnitID)
797{ 802{
798 static struct snd_kcontrol_new template = { 803 static struct snd_kcontrol_new template = {
799 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 804 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -816,6 +821,8 @@ static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer)
816 pval->cached_value = 0; 821 pval->cached_value = 0;
817 pval->is_cached = 0; 822 pval->is_cached = 0;
818 pval->mixer = mixer; 823 pval->mixer = mixer;
824 pval->bUnitID = bUnitID;
825 pval->validx = validx;
819 826
820 template.private_value = (unsigned long) pval; 827 template.private_value = (unsigned long) pval;
821 kctl = snd_ctl_new1(&template, mixer->chip); 828 kctl = snd_ctl_new1(&template, mixer->chip);
@@ -974,9 +981,10 @@ static int snd_ftu_create_mixer(struct usb_mixer_interface *mixer)
974 if (err < 0) 981 if (err < 0)
975 return err; 982 return err;
976 983
977 err = snd_ftu_create_effect_switch(mixer); 984 err = snd_ftu_create_effect_switch(mixer, 1, 6);
978 if (err < 0) 985 if (err < 0)
979 return err; 986 return err;
987
980 err = snd_ftu_create_effect_volume_ctl(mixer); 988 err = snd_ftu_create_effect_volume_ctl(mixer);
981 if (err < 0) 989 if (err < 0)
982 return err; 990 return err;