diff options
Diffstat (limited to 'drivers/usb/gadget/function/uvc_video.c')
-rw-r--r-- | drivers/usb/gadget/function/uvc_video.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c index a5eb9a3fbb7a..c3e1f27dbbef 100644 --- a/drivers/usb/gadget/function/uvc_video.c +++ b/drivers/usb/gadget/function/uvc_video.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
16 | #include <linux/usb/ch9.h> | 16 | #include <linux/usb/ch9.h> |
17 | #include <linux/usb/gadget.h> | 17 | #include <linux/usb/gadget.h> |
18 | #include <linux/usb/video.h> | ||
18 | 19 | ||
19 | #include <media/v4l2-dev.h> | 20 | #include <media/v4l2-dev.h> |
20 | 21 | ||
@@ -85,7 +86,7 @@ uvc_video_encode_bulk(struct usb_request *req, struct uvc_video *video, | |||
85 | if (buf->bytesused == video->queue.buf_used) { | 86 | if (buf->bytesused == video->queue.buf_used) { |
86 | video->queue.buf_used = 0; | 87 | video->queue.buf_used = 0; |
87 | buf->state = UVC_BUF_STATE_DONE; | 88 | buf->state = UVC_BUF_STATE_DONE; |
88 | uvc_queue_next_buffer(&video->queue, buf); | 89 | uvcg_queue_next_buffer(&video->queue, buf); |
89 | video->fid ^= UVC_STREAM_FID; | 90 | video->fid ^= UVC_STREAM_FID; |
90 | 91 | ||
91 | video->payload_size = 0; | 92 | video->payload_size = 0; |
@@ -118,7 +119,7 @@ uvc_video_encode_isoc(struct usb_request *req, struct uvc_video *video, | |||
118 | if (buf->bytesused == video->queue.buf_used) { | 119 | if (buf->bytesused == video->queue.buf_used) { |
119 | video->queue.buf_used = 0; | 120 | video->queue.buf_used = 0; |
120 | buf->state = UVC_BUF_STATE_DONE; | 121 | buf->state = UVC_BUF_STATE_DONE; |
121 | uvc_queue_next_buffer(&video->queue, buf); | 122 | uvcg_queue_next_buffer(&video->queue, buf); |
122 | video->fid ^= UVC_STREAM_FID; | 123 | video->fid ^= UVC_STREAM_FID; |
123 | } | 124 | } |
124 | } | 125 | } |
@@ -171,19 +172,19 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req) | |||
171 | break; | 172 | break; |
172 | 173 | ||
173 | case -ESHUTDOWN: /* disconnect from host. */ | 174 | case -ESHUTDOWN: /* disconnect from host. */ |
174 | printk(KERN_INFO "VS request cancelled.\n"); | 175 | printk(KERN_DEBUG "VS request cancelled.\n"); |
175 | uvc_queue_cancel(queue, 1); | 176 | uvcg_queue_cancel(queue, 1); |
176 | goto requeue; | 177 | goto requeue; |
177 | 178 | ||
178 | default: | 179 | default: |
179 | printk(KERN_INFO "VS request completed with status %d.\n", | 180 | printk(KERN_INFO "VS request completed with status %d.\n", |
180 | req->status); | 181 | req->status); |
181 | uvc_queue_cancel(queue, 0); | 182 | uvcg_queue_cancel(queue, 0); |
182 | goto requeue; | 183 | goto requeue; |
183 | } | 184 | } |
184 | 185 | ||
185 | spin_lock_irqsave(&video->queue.irqlock, flags); | 186 | spin_lock_irqsave(&video->queue.irqlock, flags); |
186 | buf = uvc_queue_head(&video->queue); | 187 | buf = uvcg_queue_head(&video->queue); |
187 | if (buf == NULL) { | 188 | if (buf == NULL) { |
188 | spin_unlock_irqrestore(&video->queue.irqlock, flags); | 189 | spin_unlock_irqrestore(&video->queue.irqlock, flags); |
189 | goto requeue; | 190 | goto requeue; |
@@ -195,7 +196,7 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req) | |||
195 | printk(KERN_INFO "Failed to queue request (%d).\n", ret); | 196 | printk(KERN_INFO "Failed to queue request (%d).\n", ret); |
196 | usb_ep_set_halt(ep); | 197 | usb_ep_set_halt(ep); |
197 | spin_unlock_irqrestore(&video->queue.irqlock, flags); | 198 | spin_unlock_irqrestore(&video->queue.irqlock, flags); |
198 | uvc_queue_cancel(queue, 0); | 199 | uvcg_queue_cancel(queue, 0); |
199 | goto requeue; | 200 | goto requeue; |
200 | } | 201 | } |
201 | spin_unlock_irqrestore(&video->queue.irqlock, flags); | 202 | spin_unlock_irqrestore(&video->queue.irqlock, flags); |
@@ -274,13 +275,12 @@ error: | |||
274 | */ | 275 | */ |
275 | 276 | ||
276 | /* | 277 | /* |
277 | * uvc_video_pump - Pump video data into the USB requests | 278 | * uvcg_video_pump - Pump video data into the USB requests |
278 | * | 279 | * |
279 | * This function fills the available USB requests (listed in req_free) with | 280 | * This function fills the available USB requests (listed in req_free) with |
280 | * video data from the queued buffers. | 281 | * video data from the queued buffers. |
281 | */ | 282 | */ |
282 | static int | 283 | int uvcg_video_pump(struct uvc_video *video) |
283 | uvc_video_pump(struct uvc_video *video) | ||
284 | { | 284 | { |
285 | struct uvc_video_queue *queue = &video->queue; | 285 | struct uvc_video_queue *queue = &video->queue; |
286 | struct usb_request *req; | 286 | struct usb_request *req; |
@@ -288,7 +288,7 @@ uvc_video_pump(struct uvc_video *video) | |||
288 | unsigned long flags; | 288 | unsigned long flags; |
289 | int ret; | 289 | int ret; |
290 | 290 | ||
291 | /* FIXME TODO Race between uvc_video_pump and requests completion | 291 | /* FIXME TODO Race between uvcg_video_pump and requests completion |
292 | * handler ??? | 292 | * handler ??? |
293 | */ | 293 | */ |
294 | 294 | ||
@@ -309,10 +309,10 @@ uvc_video_pump(struct uvc_video *video) | |||
309 | /* Retrieve the first available video buffer and fill the | 309 | /* Retrieve the first available video buffer and fill the |
310 | * request, protected by the video queue irqlock. | 310 | * request, protected by the video queue irqlock. |
311 | */ | 311 | */ |
312 | spin_lock_irqsave(&video->queue.irqlock, flags); | 312 | spin_lock_irqsave(&queue->irqlock, flags); |
313 | buf = uvc_queue_head(&video->queue); | 313 | buf = uvcg_queue_head(queue); |
314 | if (buf == NULL) { | 314 | if (buf == NULL) { |
315 | spin_unlock_irqrestore(&video->queue.irqlock, flags); | 315 | spin_unlock_irqrestore(&queue->irqlock, flags); |
316 | break; | 316 | break; |
317 | } | 317 | } |
318 | 318 | ||
@@ -323,11 +323,11 @@ uvc_video_pump(struct uvc_video *video) | |||
323 | if (ret < 0) { | 323 | if (ret < 0) { |
324 | printk(KERN_INFO "Failed to queue request (%d)\n", ret); | 324 | printk(KERN_INFO "Failed to queue request (%d)\n", ret); |
325 | usb_ep_set_halt(video->ep); | 325 | usb_ep_set_halt(video->ep); |
326 | spin_unlock_irqrestore(&video->queue.irqlock, flags); | 326 | spin_unlock_irqrestore(&queue->irqlock, flags); |
327 | uvc_queue_cancel(queue, 0); | 327 | uvcg_queue_cancel(queue, 0); |
328 | break; | 328 | break; |
329 | } | 329 | } |
330 | spin_unlock_irqrestore(&video->queue.irqlock, flags); | 330 | spin_unlock_irqrestore(&queue->irqlock, flags); |
331 | } | 331 | } |
332 | 332 | ||
333 | spin_lock_irqsave(&video->req_lock, flags); | 333 | spin_lock_irqsave(&video->req_lock, flags); |
@@ -339,8 +339,7 @@ uvc_video_pump(struct uvc_video *video) | |||
339 | /* | 339 | /* |
340 | * Enable or disable the video stream. | 340 | * Enable or disable the video stream. |
341 | */ | 341 | */ |
342 | static int | 342 | int uvcg_video_enable(struct uvc_video *video, int enable) |
343 | uvc_video_enable(struct uvc_video *video, int enable) | ||
344 | { | 343 | { |
345 | unsigned int i; | 344 | unsigned int i; |
346 | int ret; | 345 | int ret; |
@@ -356,11 +355,11 @@ uvc_video_enable(struct uvc_video *video, int enable) | |||
356 | usb_ep_dequeue(video->ep, video->req[i]); | 355 | usb_ep_dequeue(video->ep, video->req[i]); |
357 | 356 | ||
358 | uvc_video_free_requests(video); | 357 | uvc_video_free_requests(video); |
359 | uvc_queue_enable(&video->queue, 0); | 358 | uvcg_queue_enable(&video->queue, 0); |
360 | return 0; | 359 | return 0; |
361 | } | 360 | } |
362 | 361 | ||
363 | if ((ret = uvc_queue_enable(&video->queue, 1)) < 0) | 362 | if ((ret = uvcg_queue_enable(&video->queue, 1)) < 0) |
364 | return ret; | 363 | return ret; |
365 | 364 | ||
366 | if ((ret = uvc_video_alloc_requests(video)) < 0) | 365 | if ((ret = uvc_video_alloc_requests(video)) < 0) |
@@ -372,14 +371,13 @@ uvc_video_enable(struct uvc_video *video, int enable) | |||
372 | } else | 371 | } else |
373 | video->encode = uvc_video_encode_isoc; | 372 | video->encode = uvc_video_encode_isoc; |
374 | 373 | ||
375 | return uvc_video_pump(video); | 374 | return uvcg_video_pump(video); |
376 | } | 375 | } |
377 | 376 | ||
378 | /* | 377 | /* |
379 | * Initialize the UVC video stream. | 378 | * Initialize the UVC video stream. |
380 | */ | 379 | */ |
381 | static int | 380 | int uvcg_video_init(struct uvc_video *video) |
382 | uvc_video_init(struct uvc_video *video) | ||
383 | { | 381 | { |
384 | INIT_LIST_HEAD(&video->req_free); | 382 | INIT_LIST_HEAD(&video->req_free); |
385 | spin_lock_init(&video->req_lock); | 383 | spin_lock_init(&video->req_lock); |
@@ -391,7 +389,7 @@ uvc_video_init(struct uvc_video *video) | |||
391 | video->imagesize = 320 * 240 * 2; | 389 | video->imagesize = 320 * 240 * 2; |
392 | 390 | ||
393 | /* Initialize the video buffers queue. */ | 391 | /* Initialize the video buffers queue. */ |
394 | uvc_queue_init(&video->queue, V4L2_BUF_TYPE_VIDEO_OUTPUT); | 392 | uvcg_queue_init(&video->queue, V4L2_BUF_TYPE_VIDEO_OUTPUT); |
395 | return 0; | 393 | return 0; |
396 | } | 394 | } |
397 | 395 | ||