Re: Sound Blaster USB X-Fi configuration problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 20 Jul 2013, Mariusz Grecki wrote:

> Hi Alan,
> thanks for the fast response and useful infos. Unfortunately your patch
> does not work but triggered by it I made it working.
> The changes as as follows:
> 
> First we should diverse between Audigy and X-Fi in snd_usb_apply_boot_quirk:
> 
> 	case USB_ID(0x041e, 0x30df):
> 		/* X-Fi Surround 5.1 */
> 		return snd_usb_sb_x_fi_boot_quirk(dev);
> 
> and then additional function
> 
> static int snd_usb_sb_x_fi_boot_quirk(struct usb_device *dev)
> {
> 	u16 buf = 1;
> 
> 	snd_printk(KERN_ERR "X-Fi Surround 5.1 newer quirk\n");
> 
> 	snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x2a,
> 			USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
> 			0, 0, &buf, 2);
> 	snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x2a,
> 			USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
> 			0, 0, &buf, 2);
> 	if (buf == 0) {
> 		snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0x29,
> 				USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
> 				1, 2000, NULL, 0);
>   	usb_reset_device(dev);
> 		return -EAGAIN; //-ENODEV;
> 	}
> 	return 0;
> }

This is the same as the Audigy function, except for the printk string 
and the 2-byte buffer instead of the 1-byte buffer, right?  Therefore I 
suggest combining them into a single function.  You can pass the string 
and the buffer size as arguments.

> about this quirk function I am not sure. I tried to follow recorded
> initialization process from WinXP running on virtual machine. I made it
> finally running but without real understanding why it should be like
> that. I noticed that initialization process takes a while (~2 sec.). I
> do not care about that. If you think there is a smarter way to do it
> just suggest and I will test it.

Doing what Windows does is usually the best strategy.

> + static int snd_usb_sb_x_fi_boot_quirk(struct usb_device *dev)
> + {
> + 	u16 buf = 1;
> +
> + 	snd_printk(KERN_ERR "X-Fi Surround 5.1 newer quirk\n");
> +
> + 	snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x2a,
> + 			USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
> + 			0, 0, &buf, 2);

There's a serious problem here.  It's present in most or all of the 
quirk routines in this file, not just yours.

Namely, buffers used for USB transfers must not be allocated on the 
stack; they must be allocated using kmalloc or a related function.  The 
reason is because some architectures are not capable of performing DMA 
to addresses on the stack.

Do you feel like fixing up all those routines?  I suggest allocating
and deallocating a buffer in the function that calls the quirk 
routines, and have it pass the buffer as an extra argument.

> Many thanks for your help. That was exactly what I was looking for.

You're welcome.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux