diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2014-07-22 13:58:31 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-08-20 15:04:21 -0400 |
commit | ad94ac0cfdb6e28a2b0da740d2482a7306e947c3 (patch) | |
tree | e6816725beb15a2cdd604b8b8cfe1466f6f5454f | |
parent | f8f93d244afad804e09595fcb14320fe2896fef5 (diff) |
usb: gadget: audio: convert to new interface of f_uac2
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 | 85 |
2 files changed, 84 insertions, 2 deletions
diff --git a/drivers/usb/gadget/legacy/Kconfig b/drivers/usb/gadget/legacy/Kconfig index aa376f006333..172a6a396fe2 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_UAC2 if !GADGET_UAC1 | ||
57 | help | 58 | help |
58 | This Gadget Audio driver is compatible with USB Audio Class | 59 | This Gadget Audio driver is compatible with USB Audio Class |
59 | specification 2.0. It implements 1 AudioControl interface, | 60 | specification 2.0. It implements 1 AudioControl interface, |
diff --git a/drivers/usb/gadget/legacy/audio.c b/drivers/usb/gadget/legacy/audio.c index a41316bb436a..159af0345986 100644 --- a/drivers/usb/gadget/legacy/audio.c +++ b/drivers/usb/gadget/legacy/audio.c | |||
@@ -21,6 +21,38 @@ | |||
21 | 21 | ||
22 | USB_GADGET_COMPOSITE_OPTIONS(); | 22 | USB_GADGET_COMPOSITE_OPTIONS(); |
23 | 23 | ||
24 | #ifndef CONFIG_GADGET_UAC1 | ||
25 | /* Playback(USB-IN) Default Stereo - Fl/Fr */ | ||
26 | static int p_chmask = 0x3; | ||
27 | module_param(p_chmask, uint, S_IRUGO); | ||
28 | MODULE_PARM_DESC(p_chmask, "Playback Channel Mask"); | ||
29 | |||
30 | /* Playback Default 48 KHz */ | ||
31 | static int p_srate = 48000; | ||
32 | module_param(p_srate, uint, S_IRUGO); | ||
33 | MODULE_PARM_DESC(p_srate, "Playback Sampling Rate"); | ||
34 | |||
35 | /* Playback Default 16bits/sample */ | ||
36 | static int p_ssize = 2; | ||
37 | module_param(p_ssize, uint, S_IRUGO); | ||
38 | MODULE_PARM_DESC(p_ssize, "Playback Sample Size(bytes)"); | ||
39 | |||
40 | /* Capture(USB-OUT) Default Stereo - Fl/Fr */ | ||
41 | static int c_chmask = 0x3; | ||
42 | module_param(c_chmask, uint, S_IRUGO); | ||
43 | MODULE_PARM_DESC(c_chmask, "Capture Channel Mask"); | ||
44 | |||
45 | /* Capture Default 64 KHz */ | ||
46 | static int c_srate = 64000; | ||
47 | module_param(c_srate, uint, S_IRUGO); | ||
48 | MODULE_PARM_DESC(c_srate, "Capture Sampling Rate"); | ||
49 | |||
50 | /* Capture Default 16bits/sample */ | ||
51 | static int c_ssize = 2; | ||
52 | module_param(c_ssize, uint, S_IRUGO); | ||
53 | MODULE_PARM_DESC(c_ssize, "Capture Sample Size(bytes)"); | ||
54 | #endif | ||
55 | |||
24 | /* string IDs are assigned dynamically */ | 56 | /* string IDs are assigned dynamically */ |
25 | 57 | ||
26 | static struct usb_string strings_dev[] = { | 58 | static struct usb_string strings_dev[] = { |
@@ -40,13 +72,17 @@ static struct usb_gadget_strings *audio_strings[] = { | |||
40 | NULL, | 72 | NULL, |
41 | }; | 73 | }; |
42 | 74 | ||
75 | #ifndef CONFIG_GADGET_UAC1 | ||
76 | static struct usb_function_instance *fi_uac2; | ||
77 | static struct usb_function *f_uac2; | ||
78 | #endif | ||
79 | |||
43 | #ifdef CONFIG_GADGET_UAC1 | 80 | #ifdef CONFIG_GADGET_UAC1 |
44 | #include "u_uac1.h" | 81 | #include "u_uac1.h" |
45 | #include "u_uac1.c" | 82 | #include "u_uac1.c" |
46 | #include "f_uac1.c" | 83 | #include "f_uac1.c" |
47 | #else | 84 | #else |
48 | #define USB_FUAC2_INCLUDED | 85 | #include "u_uac2.h" |
49 | #include "f_uac2.c" | ||
50 | #endif | 86 | #endif |
51 | 87 | ||
52 | /*-------------------------------------------------------------------------*/ | 88 | /*-------------------------------------------------------------------------*/ |
@@ -110,6 +146,10 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
110 | 146 | ||
111 | static int __init audio_do_config(struct usb_configuration *c) | 147 | static int __init audio_do_config(struct usb_configuration *c) |
112 | { | 148 | { |
149 | #ifndef CONFIG_GADGET_UAC1 | ||
150 | int status; | ||
151 | #endif | ||
152 | |||
113 | /* FIXME alloc iConfiguration string, set it in c->strings */ | 153 | /* FIXME alloc iConfiguration string, set it in c->strings */ |
114 | 154 | ||
115 | if (gadget_is_otg(c->cdev->gadget)) { | 155 | if (gadget_is_otg(c->cdev->gadget)) { |
@@ -117,7 +157,21 @@ static int __init audio_do_config(struct usb_configuration *c) | |||
117 | c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 157 | c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
118 | } | 158 | } |
119 | 159 | ||
160 | #ifdef CONFIG_GADGET_UAC1 | ||
120 | audio_bind_config(c); | 161 | audio_bind_config(c); |
162 | #else | ||
163 | f_uac2 = usb_get_function(fi_uac2); | ||
164 | if (IS_ERR(f_uac2)) { | ||
165 | status = PTR_ERR(f_uac2); | ||
166 | return status; | ||
167 | } | ||
168 | |||
169 | status = usb_add_function(c, f_uac2); | ||
170 | if (status < 0) { | ||
171 | usb_put_function(f_uac2); | ||
172 | return status; | ||
173 | } | ||
174 | #endif | ||
121 | 175 | ||
122 | return 0; | 176 | return 0; |
123 | } | 177 | } |
@@ -133,8 +187,27 @@ static struct usb_configuration audio_config_driver = { | |||
133 | 187 | ||
134 | static int __init audio_bind(struct usb_composite_dev *cdev) | 188 | static int __init audio_bind(struct usb_composite_dev *cdev) |
135 | { | 189 | { |
190 | #ifndef CONFIG_GADGET_UAC1 | ||
191 | struct f_uac2_opts *uac2_opts; | ||
192 | #endif | ||
136 | int status; | 193 | int status; |
137 | 194 | ||
195 | #ifndef CONFIG_GADGET_UAC1 | ||
196 | fi_uac2 = usb_get_function_instance("uac2"); | ||
197 | if (IS_ERR(fi_uac2)) | ||
198 | return PTR_ERR(fi_uac2); | ||
199 | #endif | ||
200 | |||
201 | #ifndef CONFIG_GADGET_UAC1 | ||
202 | uac2_opts = container_of(fi_uac2, struct f_uac2_opts, func_inst); | ||
203 | uac2_opts->p_chmask = p_chmask; | ||
204 | uac2_opts->p_srate = p_srate; | ||
205 | uac2_opts->p_ssize = p_ssize; | ||
206 | uac2_opts->c_chmask = c_chmask; | ||
207 | uac2_opts->c_srate = c_srate; | ||
208 | uac2_opts->c_ssize = c_ssize; | ||
209 | #endif | ||
210 | |||
138 | status = usb_string_ids_tab(cdev, strings_dev); | 211 | status = usb_string_ids_tab(cdev, strings_dev); |
139 | if (status < 0) | 212 | if (status < 0) |
140 | goto fail; | 213 | goto fail; |
@@ -150,6 +223,9 @@ static int __init audio_bind(struct usb_composite_dev *cdev) | |||
150 | return 0; | 223 | return 0; |
151 | 224 | ||
152 | fail: | 225 | fail: |
226 | #ifndef CONFIG_GADGET_UAC1 | ||
227 | usb_put_function_instance(fi_uac2); | ||
228 | #endif | ||
153 | return status; | 229 | return status; |
154 | } | 230 | } |
155 | 231 | ||
@@ -157,6 +233,11 @@ static int __exit audio_unbind(struct usb_composite_dev *cdev) | |||
157 | { | 233 | { |
158 | #ifdef CONFIG_GADGET_UAC1 | 234 | #ifdef CONFIG_GADGET_UAC1 |
159 | gaudio_cleanup(); | 235 | gaudio_cleanup(); |
236 | #else | ||
237 | if (!IS_ERR_OR_NULL(f_uac2)) | ||
238 | usb_put_function(f_uac2); | ||
239 | if (!IS_ERR_OR_NULL(fi_uac2)) | ||
240 | usb_put_function_instance(fi_uac2); | ||
160 | #endif | 241 | #endif |
161 | return 0; | 242 | return 0; |
162 | } | 243 | } |