All of lore.kernel.org
 help / color / mirror / Atom feed
* A plea for help on mixer support for Fast Track Ultra (8R)
@ 2011-05-18 15:19 Felix Homann
  2011-05-18 15:29 ` Felix Homann
  2011-05-18 17:51 ` Daniel Mack
  0 siblings, 2 replies; 34+ messages in thread
From: Felix Homann @ 2011-05-18 15:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: Grant Diffey, Daniel Mack

[-- Attachment #1: Type: text/plain, Size: 1059 bytes --]

Hi,

I need some help again by someone who's more familiar with Alsa's inner 
working than I am. This might be you, Daniel ;-)

I've attached a patch series that would add support for the mixer in 
M-Audio's Fast Track Ultra (8R) devices.

BUT, it will break others!

It will break others in that mixer controls will show up multiple times. 
The reason for this seems to be my ambitiuos calling of 
snd_usb_create_mixer() for quirked devices in card.c. To circumvent the 
problem of a control showing up multiple times, I check for duplicates 
in add_unique_control_to_empty_mixer() and skip controls already present.

This doesn't work for devices which are not using 
add_unique_control_to_empty_mixer(), in other words *all* devices not 
using my messy patch...

So, probably the best thing would be to have some kind of entry in 
quirks-table.h to tell which device would need to be "mixerquirked" to 
prevent other devices to be disturbed. How can this be done?

I would highly appreciate anybody coming up with a proper solution.

Kind regards,

Felix


[-- Attachment #2: 0001-Raise-MAX_CHANNELS-to-16-as-needed-by-Fast-TRack-Ult.patch --]
[-- Type: text/x-patch, Size: 714 bytes --]

>From d698eefa94673ab9869de2614338cd2e0998ab3a Mon Sep 17 00:00:00 2001
From: Felix Homann <fex@yerbouti>
Date: Wed, 18 May 2011 09:09:24 +0200
Subject: [PATCH - Basic mixer support for Fast Track Ultra 1/6]Raise MAX_CHANNELS to 16 as needed by Fast TRack Ultra (8R)


Signed-off-by: Felix Homann <linuxaudio@showlabor.de>

diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index b4a2c81..06d035f 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -24,7 +24,7 @@ struct usb_mixer_interface {
 	u8 xonar_u1_status;
 };
 
-#define MAX_CHANNELS	10	/* max logical channels */
+#define MAX_CHANNELS	16	/* max logical channels */
 
 struct usb_mixer_elem_info {
 	struct usb_mixer_interface *mixer;
-- 
1.7.4.1


[-- Attachment #3: 0002-Move-USB_MIXER_-enum-to-mixer.h.patch --]
[-- Type: text/x-patch, Size: 1213 bytes --]

>From 1319e39fc58114f7d277966a845b09b47dbb3730 Mon Sep 17 00:00:00 2001
From: Felix Homann <linuxaudio@showlabor.de>
Date: Wed, 18 May 2011 09:17:44 +0200
Subject: [PATCH - Basic mixer support for Fast Track Ultra 2/6]Move USB_MIXER_ enum to mixer.h
 This facilitates using it in mixer_quirks.c


Signed-off-by: Felix Homann <linuxaudio@showlabor.de>

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 5e47757..ea95ce2 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -86,16 +86,6 @@ struct mixer_build {
 	const struct usbmix_selector_map *selector_map;
 };
 
-enum {
-	USB_MIXER_BOOLEAN,
-	USB_MIXER_INV_BOOLEAN,
-	USB_MIXER_S8,
-	USB_MIXER_U8,
-	USB_MIXER_S16,
-	USB_MIXER_U16,
-};
-
-
 /*E-mu 0202/0404/0204 eXtension Unit(XU) control*/
 enum {
 	USB_XU_CLOCK_RATE 		= 0xe301,
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index 06d035f..86af922 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -1,6 +1,15 @@
 #ifndef __USBMIXER_H
 #define __USBMIXER_H
 
+enum {
+	USB_MIXER_BOOLEAN,
+	USB_MIXER_INV_BOOLEAN,
+	USB_MIXER_S8,
+	USB_MIXER_U8,
+	USB_MIXER_S16,
+	USB_MIXER_U16,
+};
+
 struct usb_mixer_interface {
 	struct snd_usb_audio *chip;
 	struct list_head list;
-- 
1.7.4.1


[-- Attachment #4: 0003-Add-mixer-quirk-for-Fast-Track-Ultra-devices.patch --]
[-- Type: text/x-patch, Size: 5041 bytes --]

>From 84a7175d0c05e5f9cf2a6d7c682ba6904686df64 Mon Sep 17 00:00:00 2001
From: Felix Homann <linuxaudio@showlabor.de>
Date: Wed, 18 May 2011 10:05:34 +0200
Subject: [PATCH - Basic mixer support for Fast Track Ultra 3/6]Add mixer quirk for Fast Track Ultra devices


Signed-off-by: Felix Homann <linuxaudio@showlabor.de>

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index ea95ce2..1c37792 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -542,6 +542,31 @@ static int add_control_to_empty(struct mixer_build *state, struct snd_kcontrol *
 	return 0;
 }
 
+/* 
+ * This is almost the same as 'add_control_to_empty' but using a mixer instead of a mixer_build
+ * it simplifies building a mixer for devices without proper descriptors,
+ * e.g. the Fast Track Ultra devices
+ */ 
+int add_unique_control_to_empty_mixer(struct usb_mixer_interface *mixer, struct snd_kcontrol *kctl)
+{
+	struct usb_mixer_elem_info *cval = kctl->private_data;
+	int err;
+	
+	/* No duplicates! */
+	if (snd_ctl_find_id(mixer->chip->card, &kctl->id))
+		return 0;
+
+	if ((err = snd_ctl_add(mixer->chip->card, kctl)) < 0) {
+		snd_printd(KERN_ERR "cannot add control (err = %d)\n", err);
+		return err;
+	}
+	
+	cval->elem_id = &kctl->id;
+	cval->next_id_elem = mixer->id_elems[cval->id];
+	mixer->id_elems[cval->id] = cval;
+	
+	return 0;
+}
 
 /*
  * get a terminal name string
@@ -1331,6 +1356,57 @@ static void build_mixer_unit_ctl(struct mixer_build *state,
 	add_control_to_empty(state, kctl);
 }
 
+/*
+ * build a mixer unit control and give it a name
+ *
+ * this is essentially identical to build_mixer_unit_ctl but doesn't
+ * rely on proper descriptors to get a name for a control.
+ * At least, useful for Fast Track Ultra devices.
+ */
+
+int build_named_mixer_unit_ctl(struct usb_mixer_interface *mixer,
+	int in_pin, int in_ch, int unitid, int val_type, unsigned int cmask, char* ctrl_name, int channels)
+{
+	struct usb_mixer_elem_info *cval;
+	struct snd_kcontrol *kctl;
+	int err;
+	
+	cval = kzalloc(sizeof(*cval), GFP_KERNEL);
+	if (! cval)
+		return -1;
+	
+	cval->mixer = mixer;
+	cval->id = unitid;
+	cval->control = in_ch + 1; /* based on 1 */
+	cval->val_type = val_type; /* like USB_MIXER_S16 etc. */
+	if (!((0 < channels) && (channels <= MAX_CHANNELS)))
+		return -1;
+	cval->channels = 1;
+	cval->cmask = cmask;
+	/* get min/max values */
+	get_min_max(cval, 0);
+	
+	kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval);
+	if (! kctl) {
+		snd_printk(KERN_ERR "cannot malloc kcontrol\n");
+		kfree(cval);
+		return -1;
+	}
+	
+	kctl->tlv.c = mixer_vol_tlv;
+	kctl->vd[0].access |= 
+		SNDRV_CTL_ELEM_ACCESS_TLV_READ |
+		SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK;
+	kctl->private_free = usb_mixer_elem_free;
+	
+	sprintf(kctl->id.name, ctrl_name);
+	
+	if (err = add_unique_control_to_empty_mixer(mixer, kctl))
+		return err;
+	
+	return 0;
+}
+
 
 /*
  * parse a mixer unit
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index 86af922..6fe7bea 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -61,6 +61,9 @@ void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid);
 
 int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
 				int request, int validx, int value_set);
+int build_named_mixer_unit_ctl(struct usb_mixer_interface *mixer,
+		int in_pin, int in_ch, int unitid, int val_type, 
+		unsigned int cmask, char* ctrl_name, int channels);
 void snd_usb_mixer_inactivate(struct usb_mixer_interface *mixer);
 int snd_usb_mixer_activate(struct usb_mixer_interface *mixer);
 
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 73dcc82..e87f359 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -500,6 +500,36 @@ void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
 	}
 }
 
+/*
+ * Create mixer controls for Fast Track Ultra (8R)
+ */
+int snd_ftu_controls_create(struct usb_mixer_interface *mixer)
+{
+	char name[44];
+	int out, in_ch, unitid, err;
+	unsigned int cmask;
+	int val_type =  USB_MIXER_S16;
+	int channels = 1; /* mono channels */
+	
+	unitid = 5; // FTU's unit id
+	for (out = 0; out < 8; ++out) {
+		for (in_ch = 0; in_ch < 16; ++in_ch) {
+				cmask = (1 << in_ch);
+			if (in_ch < 8)
+				sprintf(name, "AIn%d - Out%d Capture Volume", in_ch + 1, out + 1);
+			else if (in_ch >= 8)
+				sprintf(name, "DIn%d - Out%d Playback Volume", in_ch - 7, out + 1);     
+			if ((err = build_named_mixer_unit_ctl(mixer, in_ch, out, unitid, 
+				val_type, cmask, name, channels))) {
+				return err;
+			}
+		}
+	}
+	
+	return 0;
+}
+
+
 int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
 {
 	int err = 0;
@@ -537,6 +567,10 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
 				snd_nativeinstruments_ta10_mixers,
 				ARRAY_SIZE(snd_nativeinstruments_ta10_mixers));
 		break;
+	case USB_ID(0x0763, 0x2080):/* M-Audio Fast Track Ultra */
+	case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
+		err = snd_ftu_controls_create(mixer);
+		break;
 	}
 
 	return err;
-- 
1.7.4.1


[-- Attachment #5: 0004-Try-to-create-a-mixer-for-quirked-devices-too.patch --]
[-- Type: text/x-patch, Size: 802 bytes --]

>From 67da1908c4dd0e10a24f65d321875fae3dae7a42 Mon Sep 17 00:00:00 2001
From: Felix Homann <linuxaudio@showlabor.de>
Date: Wed, 18 May 2011 10:40:22 +0200
Subject: [PATCH - Basic mixer support for Fast Track Ultra 5/6]Try to create a mixer for quirked devices, too


Signed-off-by: Felix Homann <linuxaudio@showlabor.de>

diff --git a/sound/usb/card.c b/sound/usb/card.c
index 40722f8..52ad7b0 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -493,6 +493,11 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
 	 */
 	if (!chip->ctrl_intf)
 		chip->ctrl_intf = alts;
+	
+	/* try to create a mixer for quirked devices, too */
+	if (snd_usb_create_mixer(chip, ifnum, ignore_ctl_error) < 0) {
+		goto __error;
+	}
 
 	if (err > 0) {
 		/* create normal USB audio interfaces */
-- 
1.7.4.1


[-- Attachment #6: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2011-05-24 23:55 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-18 15:19 A plea for help on mixer support for Fast Track Ultra (8R) Felix Homann
2011-05-18 15:29 ` Felix Homann
2011-05-18 17:51 ` Daniel Mack
2011-05-18 18:46   ` Felix Homann
2011-05-18 21:30     ` Daniel Mack
2011-05-19  0:51       ` Grant Diffey
2011-05-19  5:42       ` Takashi Iwai
2011-05-19  6:45         ` Felix Homann
2011-05-19  7:15           ` Clemens Ladisch
2011-05-19  7:24           ` Takashi Iwai
2011-05-19  8:14             ` Felix Homann
2011-05-19  8:52               ` Daniel Mack
2011-05-19 10:56                 ` Felix Homann
2011-05-19 11:05                 ` Daniel Mack
2011-05-19 12:23                   ` Felix Homann
2011-05-19 13:36                   ` Felix Homann
2011-05-19 13:42                   ` Felix Homann
2011-05-19 14:12                     ` Daniel Mack
2011-05-20 10:12                       ` Felix Homann
2011-05-20 11:12                         ` Daniel Mack
2011-05-20 11:14                         ` Felix Homann
2011-05-20 11:37                           ` Daniel Mack
2011-05-20 15:08                             ` Grant Diffey
2011-05-20 15:43                               ` Grant Diffey
2011-05-20 15:52                                 ` Felix Homann
2011-05-20 15:54                                 ` Daniel Mack
2011-05-20 16:25                                   ` Grant Diffey
2011-05-20 16:38                                     ` Daniel Mack
2011-05-20 16:44                                       ` Felix Homann
2011-05-20 16:52                                         ` Felix Homann
2011-05-24 10:11                               ` Felix Homann
2011-05-24 10:47                                 ` Daniel Mack
2011-05-24 11:54                                   ` Takashi Iwai
2011-05-24 23:55                                 ` Grant Diffey

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.