diff options
Diffstat (limited to 'drivers/usb/gadget/audio.c')
-rw-r--r-- | drivers/usb/gadget/audio.c | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c index a3a0f4a27ef0..58f220323847 100644 --- a/drivers/usb/gadget/audio.c +++ b/drivers/usb/gadget/audio.c | |||
@@ -89,120 +89,6 @@ static const struct usb_descriptor_header *otg_desc[] = { | |||
89 | 89 | ||
90 | /*-------------------------------------------------------------------------*/ | 90 | /*-------------------------------------------------------------------------*/ |
91 | 91 | ||
92 | /** | ||
93 | * Handle USB audio endpoint set/get command in setup class request | ||
94 | */ | ||
95 | |||
96 | static int audio_set_endpoint_req(struct usb_configuration *c, | ||
97 | const struct usb_ctrlrequest *ctrl) | ||
98 | { | ||
99 | struct usb_composite_dev *cdev = c->cdev; | ||
100 | int value = -EOPNOTSUPP; | ||
101 | u16 ep = le16_to_cpu(ctrl->wIndex); | ||
102 | u16 len = le16_to_cpu(ctrl->wLength); | ||
103 | u16 w_value = le16_to_cpu(ctrl->wValue); | ||
104 | |||
105 | DBG(cdev, "bRequest 0x%x, w_value 0x%04x, len %d, endpoint %d\n", | ||
106 | ctrl->bRequest, w_value, len, ep); | ||
107 | |||
108 | switch (ctrl->bRequest) { | ||
109 | case UAC_SET_CUR: | ||
110 | value = 0; | ||
111 | break; | ||
112 | |||
113 | case UAC_SET_MIN: | ||
114 | break; | ||
115 | |||
116 | case UAC_SET_MAX: | ||
117 | break; | ||
118 | |||
119 | case UAC_SET_RES: | ||
120 | break; | ||
121 | |||
122 | case UAC_SET_MEM: | ||
123 | break; | ||
124 | |||
125 | default: | ||
126 | break; | ||
127 | } | ||
128 | |||
129 | return value; | ||
130 | } | ||
131 | |||
132 | static int audio_get_endpoint_req(struct usb_configuration *c, | ||
133 | const struct usb_ctrlrequest *ctrl) | ||
134 | { | ||
135 | struct usb_composite_dev *cdev = c->cdev; | ||
136 | int value = -EOPNOTSUPP; | ||
137 | u8 ep = ((le16_to_cpu(ctrl->wIndex) >> 8) & 0xFF); | ||
138 | u16 len = le16_to_cpu(ctrl->wLength); | ||
139 | u16 w_value = le16_to_cpu(ctrl->wValue); | ||
140 | |||
141 | DBG(cdev, "bRequest 0x%x, w_value 0x%04x, len %d, endpoint %d\n", | ||
142 | ctrl->bRequest, w_value, len, ep); | ||
143 | |||
144 | switch (ctrl->bRequest) { | ||
145 | case UAC_GET_CUR: | ||
146 | case UAC_GET_MIN: | ||
147 | case UAC_GET_MAX: | ||
148 | case UAC_GET_RES: | ||
149 | value = 3; | ||
150 | break; | ||
151 | case UAC_GET_MEM: | ||
152 | break; | ||
153 | default: | ||
154 | break; | ||
155 | } | ||
156 | |||
157 | return value; | ||
158 | } | ||
159 | |||
160 | static int | ||
161 | audio_setup(struct usb_configuration *c, const struct usb_ctrlrequest *ctrl) | ||
162 | { | ||
163 | struct usb_composite_dev *cdev = c->cdev; | ||
164 | struct usb_request *req = cdev->req; | ||
165 | int value = -EOPNOTSUPP; | ||
166 | u16 w_index = le16_to_cpu(ctrl->wIndex); | ||
167 | u16 w_value = le16_to_cpu(ctrl->wValue); | ||
168 | u16 w_length = le16_to_cpu(ctrl->wLength); | ||
169 | |||
170 | /* composite driver infrastructure handles everything except | ||
171 | * Audio class messages; interface activation uses set_alt(). | ||
172 | */ | ||
173 | switch (ctrl->bRequestType) { | ||
174 | case USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_ENDPOINT: | ||
175 | value = audio_set_endpoint_req(c, ctrl); | ||
176 | break; | ||
177 | |||
178 | case USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT: | ||
179 | value = audio_get_endpoint_req(c, ctrl); | ||
180 | break; | ||
181 | |||
182 | default: | ||
183 | ERROR(cdev, "Invalid control req%02x.%02x v%04x i%04x l%d\n", | ||
184 | ctrl->bRequestType, ctrl->bRequest, | ||
185 | w_value, w_index, w_length); | ||
186 | } | ||
187 | |||
188 | /* respond with data transfer or status phase? */ | ||
189 | if (value >= 0) { | ||
190 | DBG(cdev, "Audio req%02x.%02x v%04x i%04x l%d\n", | ||
191 | ctrl->bRequestType, ctrl->bRequest, | ||
192 | w_value, w_index, w_length); | ||
193 | req->zero = 0; | ||
194 | req->length = value; | ||
195 | value = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC); | ||
196 | if (value < 0) | ||
197 | ERROR(cdev, "Audio response on err %d\n", value); | ||
198 | } | ||
199 | |||
200 | /* device either stalls (value < 0) or reports success */ | ||
201 | return value; | ||
202 | } | ||
203 | |||
204 | /*-------------------------------------------------------------------------*/ | ||
205 | |||
206 | static int __init audio_do_config(struct usb_configuration *c) | 92 | static int __init audio_do_config(struct usb_configuration *c) |
207 | { | 93 | { |
208 | /* FIXME alloc iConfiguration string, set it in c->strings */ | 94 | /* FIXME alloc iConfiguration string, set it in c->strings */ |
@@ -220,7 +106,6 @@ static int __init audio_do_config(struct usb_configuration *c) | |||
220 | static struct usb_configuration audio_config_driver = { | 106 | static struct usb_configuration audio_config_driver = { |
221 | .label = DRIVER_DESC, | 107 | .label = DRIVER_DESC, |
222 | .bind = audio_do_config, | 108 | .bind = audio_do_config, |
223 | .setup = audio_setup, | ||
224 | .bConfigurationValue = 1, | 109 | .bConfigurationValue = 1, |
225 | /* .iConfiguration = DYNAMIC */ | 110 | /* .iConfiguration = DYNAMIC */ |
226 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 111 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |