On Mon, 14 Aug 2006 [EMAIL PROTECTED] wrote:
> The driver I'm talking about is the snd-usb-audio. If the world would
> be perfect there would only be a single standard compliant driver for
> all usb audio devices. But as we all now it isn't. This is the reason
> why there are a lot of quirks and other special functions in this
> driver to support special hardware. The Fast Trak I'm talking about is
> not (yet) included but it has as similar behaviour like the Audiophile
> USB. This is configured by supplying option to the module through
> parameters.
>
>
> >
> > The decision of whether to use 16-bit or 24-bit audio should be made by
> > the user, not by the kernel. By changing the driver the way you want, you
> > would prevent people from using the device in 16-bit mode.
>
> This is not right because all altsets from the configuration 1 are
> also included in configuration 2. This is the reason why I think
> switching the configuration in the driver would do no harm.
I see. It sounds like a bad design. If all the altsettings from
config 1 are also present in config 2, why does config 1 exist at all?
> > Assuming you
> > really want to do that, it wouldn't be too hard to add support for
> > allowing a driver to change device configurations.
>
> How would I do that?
Try the patch below. (Note: I haven't tested it.)
Alan Stern
Index: usb-2.6/include/linux/usb.h
===================================================================
--- usb-2.6.orig/include/linux/usb.h
+++ usb-2.6/include/linux/usb.h
@@ -1112,6 +1112,9 @@ extern int usb_clear_halt(struct usb_dev
extern int usb_reset_configuration(struct usb_device *dev);
extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
+/* this request isn't really synchronous, but it belongs with the others */
+extern int usb_driver_set_configuration(struct usb_device *udev, int config);
+
/*
* timeouts, in milliseconds, used for sending/receiving control messages
* they typically complete within a few frames (msec) after they're issued
Index: usb-2.6/drivers/usb/core/message.c
===================================================================
--- usb-2.6.orig/drivers/usb/core/message.c
+++ usb-2.6/drivers/usb/core/message.c
@@ -1493,6 +1493,63 @@ free_interfaces:
return 0;
}
+struct set_config_request {
+ struct usb_device *udev;
+ int config;
+ struct work_struct work;
+};
+
+/* Worker routine for usb_driver_set_configuration() */
+static void driver_set_config_work(void *_req)
+{
+ struct set_config_request *req = _req;
+
+ usb_lock_device(req->udev);
+ usb_set_configuration(req->udev, req->config);
+ usb_unlock_device(req->udev);
+ usb_put_dev(req->udev);
+ kfree(req);
+}
+
+/**
+ * usb_driver_set_configuration - Provide a way for drivers to change device
configurations
+ * @dev: the device whose configuration is being updated
+ * @configuration: the configuration being chosen.
+ * Context: In process context, must be able to sleep
+ *
+ * Device interface drivers are not allowed to change device configurations.
+ * This because changing configurations will destroy the interface the driver
+ * is bound to and create new ones; it would be like a floppy-disk driver
+ * telling the computer to replace the floppy-disk drive with a tape drive!
+ *
+ * Still, in certain specialized circumstances the need may arise. This
+ * routine gets around the normal restriction by using a work thread to
+ * submit the change-config request.
+ *
+ * Returns 0 if the request was succesfully queued, error code otherwise.
+ */
+int usb_driver_set_configuration(struct usb_device *udev, int config)
+{
+ struct set_config_request *req;
+ int rc;
+
+ req = kmalloc(sizeof(*req), GFP_KERNEL);
+ if (!req)
+ return -ENOMEM;
+ req->udev = udev;
+ req->config = config;
+ INIT_WORK(&req->work, driver_set_config_work, req);
+
+ usb_get_dev(udev);
+ rc = schedule_work(&req->work);
+ if (rc) {
+ usb_put_dev(udev);
+ kfree(req);
+ }
+ return rc;
+}
+EXPORT_SYMBOL_GPL(usb_driver_set_configuration);
+
// synchronous request completion model
EXPORT_SYMBOL(usb_control_msg);
EXPORT_SYMBOL(usb_bulk_msg);
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel