diff options
Diffstat (limited to 'drivers/usb/gadget/audio.c')
-rw-r--r-- | drivers/usb/gadget/audio.c | 62 |
1 files changed, 14 insertions, 48 deletions
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c index 98899244860e..231b0efe8fdc 100644 --- a/drivers/usb/gadget/audio.c +++ b/drivers/usb/gadget/audio.c | |||
@@ -12,35 +12,21 @@ | |||
12 | /* #define VERBOSE_DEBUG */ | 12 | /* #define VERBOSE_DEBUG */ |
13 | 13 | ||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/utsname.h> | 15 | #include <linux/module.h> |
16 | #include <linux/usb/composite.h> | ||
16 | 17 | ||
18 | #include "gadget_chips.h" | ||
17 | #define DRIVER_DESC "Linux USB Audio Gadget" | 19 | #define DRIVER_DESC "Linux USB Audio Gadget" |
18 | #define DRIVER_VERSION "Feb 2, 2012" | 20 | #define DRIVER_VERSION "Feb 2, 2012" |
19 | 21 | ||
20 | /*-------------------------------------------------------------------------*/ | 22 | USB_GADGET_COMPOSITE_OPTIONS(); |
21 | |||
22 | /* | ||
23 | * Kbuild is not very cooperative with respect to linking separately | ||
24 | * compiled library objects into one module. So for now we won't use | ||
25 | * separate compilation ... ensuring init/exit sections work to shrink | ||
26 | * the runtime footprint, and giving us at least some parts of what | ||
27 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
28 | */ | ||
29 | #include "composite.c" | ||
30 | #include "usbstring.c" | ||
31 | #include "config.c" | ||
32 | #include "epautoconf.c" | ||
33 | 23 | ||
34 | /* string IDs are assigned dynamically */ | 24 | /* string IDs are assigned dynamically */ |
35 | 25 | ||
36 | #define STRING_MANUFACTURER_IDX 0 | ||
37 | #define STRING_PRODUCT_IDX 1 | ||
38 | |||
39 | static char manufacturer[50]; | ||
40 | |||
41 | static struct usb_string strings_dev[] = { | 26 | static struct usb_string strings_dev[] = { |
42 | [STRING_MANUFACTURER_IDX].s = manufacturer, | 27 | [USB_GADGET_MANUFACTURER_IDX].s = "", |
43 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | 28 | [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC, |
29 | [USB_GADGET_SERIAL_IDX].s = "", | ||
44 | { } /* end of list */ | 30 | { } /* end of list */ |
45 | }; | 31 | }; |
46 | 32 | ||
@@ -149,39 +135,18 @@ static struct usb_configuration audio_config_driver = { | |||
149 | 135 | ||
150 | static int __init audio_bind(struct usb_composite_dev *cdev) | 136 | static int __init audio_bind(struct usb_composite_dev *cdev) |
151 | { | 137 | { |
152 | int gcnum; | ||
153 | int status; | 138 | int status; |
154 | 139 | ||
155 | gcnum = usb_gadget_controller_number(cdev->gadget); | 140 | status = usb_string_ids_tab(cdev, strings_dev); |
156 | if (gcnum >= 0) | ||
157 | device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum); | ||
158 | else { | ||
159 | ERROR(cdev, "controller '%s' not recognized; trying %s\n", | ||
160 | cdev->gadget->name, | ||
161 | audio_config_driver.label); | ||
162 | device_desc.bcdDevice = | ||
163 | __constant_cpu_to_le16(0x0300 | 0x0099); | ||
164 | } | ||
165 | |||
166 | /* device descriptor strings: manufacturer, product */ | ||
167 | snprintf(manufacturer, sizeof manufacturer, "%s %s with %s", | ||
168 | init_utsname()->sysname, init_utsname()->release, | ||
169 | cdev->gadget->name); | ||
170 | status = usb_string_id(cdev); | ||
171 | if (status < 0) | ||
172 | goto fail; | ||
173 | strings_dev[STRING_MANUFACTURER_IDX].id = status; | ||
174 | device_desc.iManufacturer = status; | ||
175 | |||
176 | status = usb_string_id(cdev); | ||
177 | if (status < 0) | 141 | if (status < 0) |
178 | goto fail; | 142 | goto fail; |
179 | strings_dev[STRING_PRODUCT_IDX].id = status; | 143 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
180 | device_desc.iProduct = status; | 144 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
181 | 145 | ||
182 | status = usb_add_config(cdev, &audio_config_driver, audio_do_config); | 146 | status = usb_add_config(cdev, &audio_config_driver, audio_do_config); |
183 | if (status < 0) | 147 | if (status < 0) |
184 | goto fail; | 148 | goto fail; |
149 | usb_composite_overwrite_options(cdev, &coverwrite); | ||
185 | 150 | ||
186 | INFO(cdev, "%s, version: %s\n", DRIVER_DESC, DRIVER_VERSION); | 151 | INFO(cdev, "%s, version: %s\n", DRIVER_DESC, DRIVER_VERSION); |
187 | return 0; | 152 | return 0; |
@@ -198,17 +163,18 @@ static int __exit audio_unbind(struct usb_composite_dev *cdev) | |||
198 | return 0; | 163 | return 0; |
199 | } | 164 | } |
200 | 165 | ||
201 | static struct usb_composite_driver audio_driver = { | 166 | static __refdata struct usb_composite_driver audio_driver = { |
202 | .name = "g_audio", | 167 | .name = "g_audio", |
203 | .dev = &device_desc, | 168 | .dev = &device_desc, |
204 | .strings = audio_strings, | 169 | .strings = audio_strings, |
205 | .max_speed = USB_SPEED_HIGH, | 170 | .max_speed = USB_SPEED_HIGH, |
171 | .bind = audio_bind, | ||
206 | .unbind = __exit_p(audio_unbind), | 172 | .unbind = __exit_p(audio_unbind), |
207 | }; | 173 | }; |
208 | 174 | ||
209 | static int __init init(void) | 175 | static int __init init(void) |
210 | { | 176 | { |
211 | return usb_composite_probe(&audio_driver, audio_bind); | 177 | return usb_composite_probe(&audio_driver); |
212 | } | 178 | } |
213 | module_init(init); | 179 | module_init(init); |
214 | 180 | ||