Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: uvc: separately compile some components of f_uvc

Compile uvc_queue, uvc_v4l2, uvc_video separately so that later they can
be all combined in a separately compiled f_uvc.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
[Make uvc_v4l2_ioctl_ops non-static]
[Rename __UVC__V4L2__H__ and __UVC__VIDEO__H__]
[Update MAINTAINERS]
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Andrzej Pietrasiewicz and committed by
Felipe Balbi
3a83c16e 7ea95b11

+118 -37
+1 -1
MAINTAINERS
··· 9669 9669 M: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 9670 9670 L: linux-usb@vger.kernel.org 9671 9671 S: Maintained 9672 - F: drivers/usb/gadget/function/*uvc*.c 9672 + F: drivers/usb/gadget/function/*uvc* 9673 9673 F: drivers/usb/gadget/legacy/webcam.c 9674 9674 9675 9675 USB WIRELESS RNDIS DRIVER (rndis_wlan)
+2
drivers/usb/gadget/function/f_uvc.c
··· 27 27 #include <media/v4l2-event.h> 28 28 29 29 #include "uvc.h" 30 + #include "uvc_v4l2.h" 31 + #include "uvc_video.h" 30 32 31 33 unsigned int uvc_gadget_trace_param; 32 34 static unsigned int streaming_interval;
+8
drivers/usb/gadget/function/f_uvc.h
··· 16 16 #include <linux/usb/composite.h> 17 17 #include <linux/usb/video.h> 18 18 19 + #include "uvc.h" 20 + 21 + void uvc_function_setup_continue(struct uvc_device *uvc); 22 + 23 + void uvc_function_connect(struct uvc_device *uvc); 24 + 25 + void uvc_function_disconnect(struct uvc_device *uvc); 26 + 19 27 int uvc_bind_config(struct usb_configuration *c, 20 28 const struct uvc_descriptor_header * const *fs_control, 21 29 const struct uvc_descriptor_header * const *hs_control,
+1
drivers/usb/gadget/function/uvc.h
··· 53 53 #ifdef __KERNEL__ 54 54 55 55 #include <linux/usb.h> /* For usb_endpoint_* */ 56 + #include <linux/usb/composite.h> 56 57 #include <linux/usb/gadget.h> 57 58 #include <linux/videodev2.h> 58 59 #include <linux/version.h>
+17 -22
drivers/usb/gadget/function/uvc_queue.c
··· 126 126 .wait_finish = uvc_wait_finish, 127 127 }; 128 128 129 - static int uvcg_queue_init(struct uvc_video_queue *queue, 130 - enum v4l2_buf_type type) 129 + int uvcg_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type) 131 130 { 132 131 int ret; 133 132 ··· 153 154 /* 154 155 * Free the video buffers. 155 156 */ 156 - static void uvcg_free_buffers(struct uvc_video_queue *queue) 157 + void uvcg_free_buffers(struct uvc_video_queue *queue) 157 158 { 158 159 mutex_lock(&queue->mutex); 159 160 vb2_queue_release(&queue->queue); ··· 163 164 /* 164 165 * Allocate the video buffers. 165 166 */ 166 - static int uvcg_alloc_buffers(struct uvc_video_queue *queue, 167 + int uvcg_alloc_buffers(struct uvc_video_queue *queue, 167 168 struct v4l2_requestbuffers *rb) 168 169 { 169 170 int ret; ··· 175 176 return ret ? ret : rb->count; 176 177 } 177 178 178 - static int uvcg_query_buffer(struct uvc_video_queue *queue, 179 - struct v4l2_buffer *buf) 179 + int uvcg_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf) 180 180 { 181 181 int ret; 182 182 ··· 186 188 return ret; 187 189 } 188 190 189 - static int uvcg_queue_buffer(struct uvc_video_queue *queue, 190 - struct v4l2_buffer *buf) 191 + int uvcg_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf) 191 192 { 192 193 unsigned long flags; 193 194 int ret; ··· 210 213 * Dequeue a video buffer. If nonblocking is false, block until a buffer is 211 214 * available. 212 215 */ 213 - static int uvcg_dequeue_buffer(struct uvc_video_queue *queue, 214 - struct v4l2_buffer *buf, int nonblocking) 216 + int uvcg_dequeue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf, 217 + int nonblocking) 215 218 { 216 219 int ret; 217 220 ··· 228 231 * This function implements video queue polling and is intended to be used by 229 232 * the device poll handler. 230 233 */ 231 - static unsigned int uvcg_queue_poll(struct uvc_video_queue *queue, 232 - struct file *file, poll_table *wait) 234 + unsigned int uvcg_queue_poll(struct uvc_video_queue *queue, struct file *file, 235 + poll_table *wait) 233 236 { 234 237 unsigned int ret; 235 238 ··· 240 243 return ret; 241 244 } 242 245 243 - static int uvcg_queue_mmap(struct uvc_video_queue *queue, 244 - struct vm_area_struct *vma) 246 + int uvcg_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma) 245 247 { 246 248 int ret; 247 249 ··· 257 261 * 258 262 * NO-MMU arch need this function to make mmap() work correctly. 259 263 */ 260 - static unsigned long uvcg_queue_get_unmapped_area( 261 - struct uvc_video_queue *queue, 262 - unsigned long pgoff) 264 + unsigned long uvcg_queue_get_unmapped_area(struct uvc_video_queue *queue, 265 + unsigned long pgoff) 263 266 { 264 267 unsigned long ret; 265 268 ··· 281 286 * This function acquires the irq spinlock and can be called from interrupt 282 287 * context. 283 288 */ 284 - static void uvcg_queue_cancel(struct uvc_video_queue *queue, int disconnect) 289 + void uvcg_queue_cancel(struct uvc_video_queue *queue, int disconnect) 285 290 { 286 291 struct uvc_buffer *buf; 287 292 unsigned long flags; ··· 322 327 * This function can't be called from interrupt context. Use 323 328 * uvcg_queue_cancel() instead. 324 329 */ 325 - static int uvcg_queue_enable(struct uvc_video_queue *queue, int enable) 330 + int uvcg_queue_enable(struct uvc_video_queue *queue, int enable) 326 331 { 327 332 unsigned long flags; 328 333 int ret = 0; ··· 359 364 } 360 365 361 366 /* called with &queue_irqlock held.. */ 362 - static struct uvc_buffer *uvcg_queue_next_buffer(struct uvc_video_queue *queue, 363 - struct uvc_buffer *buf) 367 + struct uvc_buffer *uvcg_queue_next_buffer(struct uvc_video_queue *queue, 368 + struct uvc_buffer *buf) 364 369 { 365 370 struct uvc_buffer *nextbuf; 366 371 ··· 388 393 return nextbuf; 389 394 } 390 395 391 - static struct uvc_buffer *uvcg_queue_head(struct uvc_video_queue *queue) 396 + struct uvc_buffer *uvcg_queue_head(struct uvc_video_queue *queue) 392 397 { 393 398 struct uvc_buffer *buf = NULL; 394 399
+33
drivers/usb/gadget/function/uvc_queue.h
··· 57 57 return vb2_is_streaming(&queue->queue); 58 58 } 59 59 60 + int uvcg_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type); 61 + 62 + void uvcg_free_buffers(struct uvc_video_queue *queue); 63 + 64 + int uvcg_alloc_buffers(struct uvc_video_queue *queue, 65 + struct v4l2_requestbuffers *rb); 66 + 67 + int uvcg_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf); 68 + 69 + int uvcg_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf); 70 + 71 + int uvcg_dequeue_buffer(struct uvc_video_queue *queue, 72 + struct v4l2_buffer *buf, int nonblocking); 73 + 74 + unsigned int uvcg_queue_poll(struct uvc_video_queue *queue, 75 + struct file *file, poll_table *wait); 76 + 77 + int uvcg_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma); 78 + 79 + #ifndef CONFIG_MMU 80 + unsigned long uvcg_queue_get_unmapped_area(struct uvc_video_queue *queue, 81 + unsigned long pgoff); 82 + #endif /* CONFIG_MMU */ 83 + 84 + void uvcg_queue_cancel(struct uvc_video_queue *queue, int disconnect); 85 + 86 + int uvcg_queue_enable(struct uvc_video_queue *queue, int enable); 87 + 88 + struct uvc_buffer *uvcg_queue_next_buffer(struct uvc_video_queue *queue, 89 + struct uvc_buffer *buf); 90 + 91 + struct uvc_buffer *uvcg_queue_head(struct uvc_video_queue *queue); 92 + 60 93 #endif /* __KERNEL__ */ 61 94 62 95 #endif /* _UVC_QUEUE_H_ */
+4 -2
drivers/usb/gadget/function/uvc_v4l2.c
··· 23 23 #include <media/v4l2-event.h> 24 24 #include <media/v4l2-ioctl.h> 25 25 26 + #include "f_uvc.h" 26 27 #include "uvc.h" 27 28 #include "uvc_queue.h" 29 + #include "uvc_video.h" 28 30 29 31 /* -------------------------------------------------------------------------- 30 32 * Requests handling ··· 261 259 } 262 260 } 263 261 264 - static const struct v4l2_ioctl_ops uvc_v4l2_ioctl_ops = { 262 + const struct v4l2_ioctl_ops uvc_v4l2_ioctl_ops = { 265 263 .vidioc_querycap = uvc_v4l2_querycap, 266 264 .vidioc_g_fmt_vid_out = uvc_v4l2_get_format, 267 265 .vidioc_s_fmt_vid_out = uvc_v4l2_set_format, ··· 352 350 } 353 351 #endif 354 352 355 - static struct v4l2_file_operations uvc_v4l2_fops = { 353 + struct v4l2_file_operations uvc_v4l2_fops = { 356 354 .owner = THIS_MODULE, 357 355 .open = uvc_v4l2_open, 358 356 .release = uvc_v4l2_release,
+22
drivers/usb/gadget/function/uvc_v4l2.h
··· 1 + /* 2 + * uvc_v4l2.h -- USB Video Class Gadget driver 3 + * 4 + * Copyright (C) 2009-2010 5 + * Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 + * 7 + * Copyright (c) 2013 Samsung Electronics Co., Ltd. 8 + * http://www.samsung.com 9 + * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 + * 11 + * This program is free software; you can redistribute it and/or modify 12 + * it under the terms of the GNU General Public License version 2 as 13 + * published by the Free Software Foundation. 14 + */ 15 + 16 + #ifndef __UVC_V4L2_H__ 17 + #define __UVC_V4L2_H__ 18 + 19 + extern const struct v4l2_ioctl_ops uvc_v4l2_ioctl_ops; 20 + extern struct v4l2_file_operations uvc_v4l2_fops; 21 + 22 + #endif /* __UVC_V4L2_H__ */
+4 -6
drivers/usb/gadget/function/uvc_video.c
··· 15 15 #include <linux/errno.h> 16 16 #include <linux/usb/ch9.h> 17 17 #include <linux/usb/gadget.h> 18 + #include <linux/usb/video.h> 18 19 19 20 #include <media/v4l2-dev.h> 20 21 ··· 280 279 * This function fills the available USB requests (listed in req_free) with 281 280 * video data from the queued buffers. 282 281 */ 283 - static int 284 - uvcg_video_pump(struct uvc_video *video) 282 + int uvcg_video_pump(struct uvc_video *video) 285 283 { 286 284 struct uvc_video_queue *queue = &video->queue; 287 285 struct usb_request *req; ··· 339 339 /* 340 340 * Enable or disable the video stream. 341 341 */ 342 - static int 343 - uvcg_video_enable(struct uvc_video *video, int enable) 342 + int uvcg_video_enable(struct uvc_video *video, int enable) 344 343 { 345 344 unsigned int i; 346 345 int ret; ··· 377 378 /* 378 379 * Initialize the UVC video stream. 379 380 */ 380 - static int 381 - uvcg_video_init(struct uvc_video *video) 381 + int uvcg_video_init(struct uvc_video *video) 382 382 { 383 383 INIT_LIST_HEAD(&video->req_free); 384 384 spin_lock_init(&video->req_lock);
+24
drivers/usb/gadget/function/uvc_video.h
··· 1 + /* 2 + * uvc_video.h -- USB Video Class Gadget driver 3 + * 4 + * Copyright (C) 2009-2010 5 + * Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 + * 7 + * Copyright (c) 2013 Samsung Electronics Co., Ltd. 8 + * http://www.samsung.com 9 + * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 10 + * 11 + * This program is free software; you can redistribute it and/or modify 12 + * it under the terms of the GNU General Public License version 2 as 13 + * published by the Free Software Foundation. 14 + */ 15 + #ifndef __UVC_VIDEO_H__ 16 + #define __UVC_VIDEO_H__ 17 + 18 + int uvcg_video_pump(struct uvc_video *video); 19 + 20 + int uvcg_video_enable(struct uvc_video *video, int enable); 21 + 22 + int uvcg_video_init(struct uvc_video *video); 23 + 24 + #endif /* __UVC_VIDEO_H__ */
+1 -1
drivers/usb/gadget/legacy/Makefile
··· 19 19 g_hid-y := hid.o 20 20 g_dbgp-y := dbgp.o 21 21 g_nokia-y := nokia.o 22 - g_webcam-y := webcam.o 22 + g_webcam-y := webcam.o ../function/uvc_queue.o ../function/uvc_v4l2.o ../function/uvc_video.o 23 23 g_ncm-y := ncm.o 24 24 g_acm_ms-y := acm_ms.o 25 25 g_tcm_usb_gadget-y := tcm_usb_gadget.o
+1 -5
drivers/usb/gadget/legacy/webcam.c
··· 12 12 13 13 #include <linux/kernel.h> 14 14 #include <linux/device.h> 15 + #include <linux/module.h> 15 16 #include <linux/usb/video.h> 16 - 17 - #include "f_uvc.h" 18 17 19 18 /* 20 19 * Kbuild is not very cooperative with respect to linking separately ··· 22 23 * the runtime footprint, and giving us at least some parts of what 23 24 * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 24 25 */ 25 - #include "uvc_queue.c" 26 - #include "uvc_video.c" 27 - #include "uvc_v4l2.c" 28 26 #include "f_uvc.c" 29 27 30 28 USB_GADGET_COMPOSITE_OPTIONS();