From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: usbaudio won't do 24-bit or 32-bit i/o... Date: Mon, 16 Dec 2002 18:19:25 +0100 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <3DF0482E.8010109@boosthardware.com> <3DFB0C79.7010000@boosthardware.com> Mime-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi") Content-Type: multipart/mixed; boundary="Multipart_Mon_Dec_16_18:19:25_2002-1" Return-path: In-Reply-To: <3DFB0C79.7010000@boosthardware.com> Errors-To: alsa-devel-admin@lists.sourceforge.net List-Help: List-Post: List-Subscribe: , List-Unsubscribe: , List-Archive: To: Patrick Shirkey Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org --Multipart_Mon_Dec_16_18:19:25_2002-1 Content-Type: text/plain; charset=US-ASCII 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 --Multipart_Mon_Dec_16_18:19:25_2002-1 Content-Type: application/octet-stream Content-Disposition: attachment; filename="usb-qinit.dif" Content-Transfer-Encoding: 7bit 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; --Multipart_Mon_Dec_16_18:19:25_2002-1-- ------------------------------------------------------- This sf.net email is sponsored by: With Great Power, Comes Great Responsibility Learn to use your power at OSDN's High Performance Computing Channel http://hpc.devchannel.org/