All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Patrick Shirkey <pshirkey@boosthardware.com>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: usbaudio won't do 24-bit or 32-bit i/o...
Date: Mon, 16 Dec 2002 18:19:25 +0100	[thread overview]
Message-ID: <s5hvg1tswyq.wl@alsa2.suse.de> (raw)
In-Reply-To: <3DFB0C79.7010000@boosthardware.com>

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

At Sat, 14 Dec 2002 19:48:25 +0900,
Patrick Shirkey wrote:
> 
> Takashi Iwai wrote:
> 
> > 
> > could you tell me the rcs version numbers of the files on
> > alsa-kernel/usb you are using (18 Nov.) ?  i've checked the files via
> > cvs but i couldn't see any differences around the date.
> > 
> 
> I have managed to test a more upto date version since then and it is the 
> same. I have no idea when this happened though as I wasn't actively 
> testing the 24 bit support until recently. I have a vague memory of 
> testing it much earlier in the year but I think that was only for playback.
> 
> I currently cannot record from input 1 and 2 either.
 
hmm, it's weird.  it would be nice if we can know at which point the
driver became broken...


> Working are:
> 
> output 1,2,3,4
> input 3,4
> 
> I also have to initialise both pcms with the small utility you made.

the attached patch will (hopefully) do the same thing as qinit in the
kernel at the initialization (applied to the latest cvs).  please let
me know whether it works.


ciao,

Takashi

[-- Attachment #2: usb-qinit.dif --]
[-- Type: application/octet-stream, Size: 5522 bytes --]

Index: alsa-kernel/usb/usbaudio.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/usb/usbaudio.c,v
retrieving revision 1.29
diff -u -r1.29 usbaudio.c
--- alsa-kernel/usb/usbaudio.c	16 Dec 2002 17:15:05 -0000	1.29
+++ alsa-kernel/usb/usbaudio.c	16 Dec 2002 17:14:16 -0000
@@ -928,6 +928,70 @@
 
 
 /*
+ * initialize the picth control and sample rate
+ */
+static int init_usb_pitch(struct usb_device *dev, int iface,
+			  struct usb_host_interface *alts,
+			  struct audioformat *fmt)
+{
+	unsigned int ep;
+	unsigned char data[1];
+	int err;
+
+	ep = get_endpoint(alts, 0)->bEndpointAddress;
+	/* if endpoint has pitch control, enable it */
+	if (fmt->attributes & EP_CS_ATTR_PITCH_CONTROL) {
+		data[0] = 1;
+		if ((err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR,
+					   USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 
+					   PITCH_CONTROL << 8, ep, data, 1, HZ)) < 0) {
+			snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH\n",
+				   dev->devnum, iface, ep);
+			return err;
+		}
+	}
+	return 0;
+}
+
+static int init_usb_sample_rate(struct usb_device *dev, int iface,
+				struct usb_host_interface *alts,
+				struct audioformat *fmt, int rate)
+{
+	unsigned int ep;
+	unsigned char data[3];
+	int err;
+
+	ep = get_endpoint(alts, 0)->bEndpointAddress;
+	/* if endpoint has sampling rate control, set it */
+	if (fmt->attributes & EP_CS_ATTR_SAMPLE_RATE) {
+		int crate;
+		data[0] = rate;
+		data[1] = rate >> 8;
+		data[2] = rate >> 16;
+		if ((err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR,
+					   USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 
+					   SAMPLING_FREQ_CONTROL << 8, ep, data, 3, HZ)) < 0) {
+			snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep 0x%x\n",
+				   dev->devnum, iface, fmt->altsetting, rate, ep);
+			return err;
+		}
+		if ((err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR,
+					   USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN,
+					   SAMPLING_FREQ_CONTROL << 8, ep, data, 3, HZ)) < 0) {
+			snd_printk(KERN_ERR "%d:%d:%d: cannot get freq at ep 0x%x\n",
+				   dev->devnum, iface, fmt->altsetting, ep);
+			return err;
+		}
+		crate = data[0] | (data[1] << 8) | (data[2] << 16);
+		if (crate != rate) {
+			snd_printd(KERN_WARNING "current rate %d is different from the runtime rate %d\n", crate, rate);
+			// runtime->rate = crate;
+		}
+	}
+	return 0;
+}
+
+/*
  * find a matching format and set up the interface
  */
 static int set_format(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime)
@@ -939,7 +1003,6 @@
 	struct usb_interface *iface;
 	struct audioformat *fmt;
 	unsigned int ep, attr;
-	unsigned char data[3];
 	int is_playback = subs->direction == SNDRV_PCM_STREAM_PLAYBACK;
 	int err;
 
@@ -1012,44 +1075,11 @@
 		subs->syncinterval = get_endpoint(alts, 1)->bRefresh;
 	}
 
-	ep = get_endpoint(alts, 0)->bEndpointAddress;
-	/* if endpoint has pitch control, enable it */
-	if (fmt->attributes & EP_CS_ATTR_PITCH_CONTROL) {
-		data[0] = 1;
-		if ((err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR,
-					   USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 
-					   PITCH_CONTROL << 8, ep, data, 1, HZ)) < 0) {
-			snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH\n",
-				   dev->devnum, subs->interface, ep);
-			return err;
-		}
-	}
-	/* if endpoint has sampling rate control, set it */
-	if (fmt->attributes & EP_CS_ATTR_SAMPLE_RATE) {
-		int crate;
-		data[0] = runtime->rate;
-		data[1] = runtime->rate >> 8;
-		data[2] = runtime->rate >> 16;
-		if ((err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR,
-					   USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 
-					   SAMPLING_FREQ_CONTROL << 8, ep, data, 3, HZ)) < 0) {
-			snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep 0x%x\n",
-				   dev->devnum, subs->interface, fmt->altsetting, runtime->rate, ep);
-			return err;
-		}
-		if ((err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR,
-					   USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN,
-					   SAMPLING_FREQ_CONTROL << 8, ep, data, 3, HZ)) < 0) {
-			snd_printk(KERN_ERR "%d:%d:%d: cannot get freq at ep 0x%x\n",
-				   dev->devnum, subs->interface, fmt->altsetting, ep);
-			return err;
-		}
-		crate = data[0] | (data[1] << 8) | (data[2] << 16);
-		if (crate != runtime->rate) {
-			snd_printd(KERN_WARNING "current rate %d is different from the runtime rate %d\n", crate, runtime->rate);
-			// runtime->rate = crate;
-		}
-	}
+	if ((err = init_usb_pitch(dev, subs->interface, alts, fmt)) < 0 ||
+	    (err = init_usb_sample_rate(dev, subs->interface, alts, fmt,
+					runtime->rate)) < 0)
+		return err;
+
 	/* always fill max packet size */
 	if (fmt->attributes & EP_CS_ATTR_FILL_MAX)
 		subs->fill_max = 1;
@@ -1829,6 +1859,10 @@
 			kfree(fp);
 			return err;
 		}
+		/* try to set the interface... */
+		usb_set_interface(chip->dev, iface_no, i);
+		init_usb_pitch(chip->dev, iface_no, alts, fp);
+		init_usb_sample_rate(chip->dev, iface_no, alts, fp, fp->rate_max);
 	}
 	return 0;
 }
@@ -1891,9 +1925,10 @@
 			/* skip non-supported classes */
 			continue;
 		}
-		parse_audio_endpoints(chip, buffer, buflen, j);
-		usb_set_interface(dev, j, 0); /* reset the current interface */
-		usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1);
+		if (! parse_audio_endpoints(chip, buffer, buflen, j)) {
+			usb_set_interface(dev, j, 0); /* reset the current interface */
+			usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1);
+		}
 	}
 
 	return 0;

  reply	other threads:[~2002-12-16 17:19 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-05 10:47 sb16 gets wedged when doing overlapped i/o (full duplex) John S. Denker
2002-12-05 11:31 ` usbaudio won't do 24-bit or 32-bit i/o, and won't do 96000 frames per second John S. Denker
2002-12-05 15:19   ` Clemens Ladisch
2002-12-05 19:10     ` John S. Denker
2002-12-06  9:16       ` Clemens Ladisch
2002-12-06 10:09         ` Jaroslav Kysela
2002-12-07 15:05           ` Patrick Shirkey
2002-12-06 13:13         ` John S. Denker
2002-12-06 14:22         ` many utils fail for extigy (usb) John S. Denker
2002-12-06  6:48     ` usbaudio won't do 24-bit or 32-bit i/o, and won't do 96000 frames per second Patrick Shirkey
2002-12-06  7:12       ` Patrick Shirkey
2002-12-13 18:19       ` Takashi Iwai
2002-12-14 10:48         ` usbaudio won't do 24-bit or 32-bit i/o Patrick Shirkey
2002-12-16 17:19           ` Takashi Iwai [this message]
2002-12-16 18:59             ` Patrick Shirkey
2002-12-16 20:11               ` Patrick Shirkey
2002-12-17 15:28               ` Takashi Iwai
2002-12-20 22:00                 ` Patrick Shirkey
2002-12-23 13:35                   ` Takashi Iwai
2002-12-23 18:58                     ` Patrick Shirkey
2002-12-05 11:39 ` sb16 gets wedged when doing overlapped i/o (full duplex) John S. Denker
2002-12-05 11:52 ` hard crash when snd-ice1712 loads John S. Denker
2002-12-05 17:42   ` Jaroslav Kysela
2002-12-05 23:10   ` Scott Bahling
2002-12-05 11:57 ` alsactl and alsamixer fail for extigy John S. Denker
2002-12-09 14:51   ` Takashi Iwai
2002-12-05 12:07 ` sb16 gets wedged when doing overlapped i/o (full duplex) Uros Bizjak
2002-12-05 13:45   ` John S. Denker
2002-12-05 14:55     ` Uros Bizjak
2002-12-05 17:47       ` Jaroslav Kysela
2002-12-05 18:33       ` John S. Denker
2002-12-06  7:14         ` Uros Bizjak
2002-12-06 14:08           ` John S. Denker
2002-12-06  0:41       ` cs4239 errs on full duplex (provoked by overruns?) John S. Denker
2002-12-05 15:23     ` sb16 gets wedged when doing overlapped i/o (full duplex) Paul Davis
2002-12-09 14:30       ` Takashi Iwai
2002-12-09 14:54     ` documentation or lack thereof John S. Denker
2002-12-09 15:05       ` Takashi Iwai
2002-12-09 15:23       ` ljp
2002-12-09 16:23       ` Paul Davis
2002-12-10 17:59         ` Patrick Shirkey
2002-12-10 22:28         ` soundcard matrix: broken links etc John S. Denker
2002-12-11  2:52           ` Patrick Shirkey
2002-12-11  4:05         ` John S. Denker
2002-12-11  5:27           ` Patrick Shirkey
2002-12-14 15:59         ` John S. Denker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hvg1tswyq.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=pshirkey@boosthardware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.