diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2014-07-22 13:58:39 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-08-20 15:04:58 -0400 |
commit | 0d992dec967d6edc97b3001598db7c4ac4e4b3c1 (patch) | |
tree | 3a0d5a0cfbcdd8b4c746462b589f0e2f8ad9db0d | |
parent | f3a3406b3f562f8d15b89979c0ca9e184b269084 (diff) |
usb: gadget: audio: convert to new interface of f_uac1
Use the new interface so that the old one can be removed.
Tested-by: Sebastian Reimers <sebastian.reimers@googlemail.com>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/gadget/legacy/Kconfig | 1 | ||||
-rw-r--r-- | drivers/usb/gadget/legacy/audio.c | 69 |
2 files changed, 64 insertions, 6 deletions
diff --git a/drivers/usb/gadget/legacy/Kconfig b/drivers/usb/gadget/legacy/Kconfig index 172a6a396fe2..bbd4b8545b9d 100644 --- a/drivers/usb/gadget/legacy/Kconfig +++ b/drivers/usb/gadget/legacy/Kconfig | |||
@@ -54,6 +54,7 @@ config USB_AUDIO | |||
54 | depends on SND | 54 | depends on SND |
55 | select USB_LIBCOMPOSITE | 55 | select USB_LIBCOMPOSITE |
56 | select SND_PCM | 56 | select SND_PCM |
57 | select USB_F_UAC1 if GADGET_UAC1 | ||
57 | select USB_F_UAC2 if !GADGET_UAC1 | 58 | select USB_F_UAC2 if !GADGET_UAC1 |
58 | help | 59 | help |
59 | This Gadget Audio driver is compatible with USB Audio Class | 60 | This Gadget Audio driver is compatible with USB Audio Class |
diff --git a/drivers/usb/gadget/legacy/audio.c b/drivers/usb/gadget/legacy/audio.c index cf1a5434feaf..bb40b61e2555 100644 --- a/drivers/usb/gadget/legacy/audio.c +++ b/drivers/usb/gadget/legacy/audio.c | |||
@@ -53,6 +53,35 @@ MODULE_PARM_DESC(c_srate, "Capture Sampling Rate"); | |||
53 | static int c_ssize = UAC2_DEF_CSSIZE; | 53 | static int c_ssize = UAC2_DEF_CSSIZE; |
54 | module_param(c_ssize, uint, S_IRUGO); | 54 | module_param(c_ssize, uint, S_IRUGO); |
55 | MODULE_PARM_DESC(c_ssize, "Capture Sample Size(bytes)"); | 55 | MODULE_PARM_DESC(c_ssize, "Capture Sample Size(bytes)"); |
56 | #else | ||
57 | #define FILE_PCM_PLAYBACK "/dev/snd/pcmC0D0p" | ||
58 | #define FILE_PCM_CAPTURE "/dev/snd/pcmC0D0c" | ||
59 | #define FILE_CONTROL "/dev/snd/controlC0" | ||
60 | |||
61 | static char *fn_play = FILE_PCM_PLAYBACK; | ||
62 | module_param(fn_play, charp, S_IRUGO); | ||
63 | MODULE_PARM_DESC(fn_play, "Playback PCM device file name"); | ||
64 | |||
65 | static char *fn_cap = FILE_PCM_CAPTURE; | ||
66 | module_param(fn_cap, charp, S_IRUGO); | ||
67 | MODULE_PARM_DESC(fn_cap, "Capture PCM device file name"); | ||
68 | |||
69 | static char *fn_cntl = FILE_CONTROL; | ||
70 | module_param(fn_cntl, charp, S_IRUGO); | ||
71 | MODULE_PARM_DESC(fn_cntl, "Control device file name"); | ||
72 | |||
73 | #define OUT_EP_MAX_PACKET_SIZE 200 | ||
74 | static int req_buf_size = OUT_EP_MAX_PACKET_SIZE; | ||
75 | module_param(req_buf_size, int, S_IRUGO); | ||
76 | MODULE_PARM_DESC(req_buf_size, "ISO OUT endpoint request buffer size"); | ||
77 | |||
78 | static int req_count = 256; | ||
79 | module_param(req_count, int, S_IRUGO); | ||
80 | MODULE_PARM_DESC(req_count, "ISO OUT endpoint request count"); | ||
81 | |||
82 | static int audio_buf_size = 48000; | ||
83 | module_param(audio_buf_size, int, S_IRUGO); | ||
84 | MODULE_PARM_DESC(audio_buf_size, "Audio buffer size"); | ||
56 | #endif | 85 | #endif |
57 | 86 | ||
58 | /* string IDs are assigned dynamically */ | 87 | /* string IDs are assigned dynamically */ |
@@ -77,12 +106,13 @@ static struct usb_gadget_strings *audio_strings[] = { | |||
77 | #ifndef CONFIG_GADGET_UAC1 | 106 | #ifndef CONFIG_GADGET_UAC1 |
78 | static struct usb_function_instance *fi_uac2; | 107 | static struct usb_function_instance *fi_uac2; |
79 | static struct usb_function *f_uac2; | 108 | static struct usb_function *f_uac2; |
109 | #else | ||
110 | static struct usb_function_instance *fi_uac1; | ||
111 | static struct usb_function *f_uac1; | ||
80 | #endif | 112 | #endif |
81 | 113 | ||
82 | #ifdef CONFIG_GADGET_UAC1 | 114 | #ifdef CONFIG_GADGET_UAC1 |
83 | #define USBF_UAC1_INCLUDED | ||
84 | #include "u_uac1.h" | 115 | #include "u_uac1.h" |
85 | #include "f_uac1.c" | ||
86 | #endif | 116 | #endif |
87 | 117 | ||
88 | /*-------------------------------------------------------------------------*/ | 118 | /*-------------------------------------------------------------------------*/ |
@@ -146,9 +176,7 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
146 | 176 | ||
147 | static int __init audio_do_config(struct usb_configuration *c) | 177 | static int __init audio_do_config(struct usb_configuration *c) |
148 | { | 178 | { |
149 | #ifndef CONFIG_GADGET_UAC1 | ||
150 | int status; | 179 | int status; |
151 | #endif | ||
152 | 180 | ||
153 | /* FIXME alloc iConfiguration string, set it in c->strings */ | 181 | /* FIXME alloc iConfiguration string, set it in c->strings */ |
154 | 182 | ||
@@ -158,7 +186,17 @@ static int __init audio_do_config(struct usb_configuration *c) | |||
158 | } | 186 | } |
159 | 187 | ||
160 | #ifdef CONFIG_GADGET_UAC1 | 188 | #ifdef CONFIG_GADGET_UAC1 |
161 | audio_bind_config(c); | 189 | f_uac1 = usb_get_function(fi_uac1); |
190 | if (IS_ERR(f_uac1)) { | ||
191 | status = PTR_ERR(f_uac1); | ||
192 | return status; | ||
193 | } | ||
194 | |||
195 | status = usb_add_function(c, f_uac1); | ||
196 | if (status < 0) { | ||
197 | usb_put_function(f_uac1); | ||
198 | return status; | ||
199 | } | ||
162 | #else | 200 | #else |
163 | f_uac2 = usb_get_function(fi_uac2); | 201 | f_uac2 = usb_get_function(fi_uac2); |
164 | if (IS_ERR(f_uac2)) { | 202 | if (IS_ERR(f_uac2)) { |
@@ -189,6 +227,8 @@ static int __init audio_bind(struct usb_composite_dev *cdev) | |||
189 | { | 227 | { |
190 | #ifndef CONFIG_GADGET_UAC1 | 228 | #ifndef CONFIG_GADGET_UAC1 |
191 | struct f_uac2_opts *uac2_opts; | 229 | struct f_uac2_opts *uac2_opts; |
230 | #else | ||
231 | struct f_uac1_opts *uac1_opts; | ||
192 | #endif | 232 | #endif |
193 | int status; | 233 | int status; |
194 | 234 | ||
@@ -196,6 +236,10 @@ static int __init audio_bind(struct usb_composite_dev *cdev) | |||
196 | fi_uac2 = usb_get_function_instance("uac2"); | 236 | fi_uac2 = usb_get_function_instance("uac2"); |
197 | if (IS_ERR(fi_uac2)) | 237 | if (IS_ERR(fi_uac2)) |
198 | return PTR_ERR(fi_uac2); | 238 | return PTR_ERR(fi_uac2); |
239 | #else | ||
240 | fi_uac1 = usb_get_function_instance("uac1"); | ||
241 | if (IS_ERR(fi_uac1)) | ||
242 | return PTR_ERR(fi_uac1); | ||
199 | #endif | 243 | #endif |
200 | 244 | ||
201 | #ifndef CONFIG_GADGET_UAC1 | 245 | #ifndef CONFIG_GADGET_UAC1 |
@@ -206,6 +250,14 @@ static int __init audio_bind(struct usb_composite_dev *cdev) | |||
206 | uac2_opts->c_chmask = c_chmask; | 250 | uac2_opts->c_chmask = c_chmask; |
207 | uac2_opts->c_srate = c_srate; | 251 | uac2_opts->c_srate = c_srate; |
208 | uac2_opts->c_ssize = c_ssize; | 252 | uac2_opts->c_ssize = c_ssize; |
253 | #else | ||
254 | uac1_opts = container_of(fi_uac1, struct f_uac1_opts, func_inst); | ||
255 | uac1_opts->fn_play = fn_play; | ||
256 | uac1_opts->fn_cap = fn_cap; | ||
257 | uac1_opts->fn_cntl = fn_cntl; | ||
258 | uac1_opts->req_buf_size = req_buf_size; | ||
259 | uac1_opts->req_count = req_count; | ||
260 | uac1_opts->audio_buf_size = audio_buf_size; | ||
209 | #endif | 261 | #endif |
210 | 262 | ||
211 | status = usb_string_ids_tab(cdev, strings_dev); | 263 | status = usb_string_ids_tab(cdev, strings_dev); |
@@ -225,6 +277,8 @@ static int __init audio_bind(struct usb_composite_dev *cdev) | |||
225 | fail: | 277 | fail: |
226 | #ifndef CONFIG_GADGET_UAC1 | 278 | #ifndef CONFIG_GADGET_UAC1 |
227 | usb_put_function_instance(fi_uac2); | 279 | usb_put_function_instance(fi_uac2); |
280 | #else | ||
281 | usb_put_function_instance(fi_uac1); | ||
228 | #endif | 282 | #endif |
229 | return status; | 283 | return status; |
230 | } | 284 | } |
@@ -232,7 +286,10 @@ fail: | |||
232 | static int __exit audio_unbind(struct usb_composite_dev *cdev) | 286 | static int __exit audio_unbind(struct usb_composite_dev *cdev) |
233 | { | 287 | { |
234 | #ifdef CONFIG_GADGET_UAC1 | 288 | #ifdef CONFIG_GADGET_UAC1 |
235 | gaudio_cleanup(); | 289 | if (!IS_ERR_OR_NULL(f_uac1)) |
290 | usb_put_function(f_uac1); | ||
291 | if (!IS_ERR_OR_NULL(fi_uac1)) | ||
292 | usb_put_function_instance(fi_uac1); | ||
236 | #else | 293 | #else |
237 | if (!IS_ERR_OR_NULL(f_uac2)) | 294 | if (!IS_ERR_OR_NULL(f_uac2)) |
238 | usb_put_function(f_uac2); | 295 | usb_put_function(f_uac2); |