aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/uvc/uvc_queue.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-04 12:50:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-04 12:50:07 -0400
commit3c83e61e67256e0bb08c46cc2db43b58fd617251 (patch)
tree0233e1e04e6449c60b01ff5dea8bea85bcf22f08 /drivers/media/usb/uvc/uvc_queue.c
parent4a4389abdd9822fdf3cc2ac6ed87eb811fd43acc (diff)
parenta83b93a7480441a47856dc9104bea970e84cda87 (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: "The main set of series of patches for media subsystem, including: - document RC sysfs class - added an API to setup scancode to allow waking up systems using the Remote Controller - add API for SDR devices. Drivers are still on staging - some API improvements for getting EDID data from media inputs/outputs - new DVB frontend driver for drx-j (ATSC) - one driver (it913x/it9137) got removed, in favor of an improvement on another driver (af9035) - added a skeleton V4L2 PCI driver at documentation - added a dual flash driver (lm3646) - added a new IR driver (img-ir) - added an IR scancode decoder for the Sharp protocol - some improvements at the usbtv driver, to allow its core to be reused. - added a new SDR driver (rtl2832u_sdr) - added a new tuner driver (msi001) - several improvements at em28xx driver to fix PM support, device removal and to split the V4L2 specific bits into a separate sub-driver - one driver got converted to videobuf2 (s2255drv) - the e4000 tuner driver now follows an improved binding model - some fixes at V4L2 compat32 code - several fixes and enhancements at videobuf2 code - some cleanups at V4L2 API documentation - usual driver enhancements, new board additions and misc fixups" [ NOTE! This merge effective drops commit 4329b93b283c ("of: Reduce indentation in of_graph_get_next_endpoint"). The of_graph_get_next_endpoint() function was moved and renamed by commit fd9fdb78a9bf ("[media] of: move graph helpers from drivers/media/v4l2-core to drivers/of"). It was originally called v4l2_of_get_next_endpoint() and lived in the file drivers/media/v4l2-core/v4l2-of.c. In that original location, it was then fixed to support empty port nodes by commit b9db140c1e46 ("[media] v4l: of: Support empty port nodes"), and that commit clashes badly with the dropped "Reduce intendation" commit. I had to choose one or the other, and decided that the "Support empty port nodes" commit was more important ] * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (426 commits) [media] em28xx-dvb: fix PCTV 461e tuner I2C binding Revert "[media] em28xx-dvb: fix PCTV 461e tuner I2C binding" [media] em28xx: fix PCTV 290e LNA oops [media] em28xx-dvb: fix PCTV 461e tuner I2C binding [media] m88ds3103: fix bug on .set_tone() [media] saa7134: fix WARN_ON during resume [media] v4l2-dv-timings: add module name, description, license [media] videodev2.h: add parenthesis around macro arguments [media] saa6752hs: depends on CRC32 [media] si4713: fix Kconfig dependencies [media] Sensoray 2255 uses videobuf2 [media] adv7180: free an interrupt on failure paths in init_device() [media] e4000: make VIDEO_V4L2 dependency optional [media] af9033: Don't export functions for the hardware filter [media] af9035: use af9033 PID filters [media] af9033: implement PID filter [media] rtl2832_sdr: do not use dynamic stack allocation [media] e4000: fix 32-bit build error [media] em28xx-audio: make sure audio is unmuted on open() [media] DocBook media: v4l2_format_sdr was renamed to v4l2_sdr_format ...
Diffstat (limited to 'drivers/media/usb/uvc/uvc_queue.c')
-rw-r--r--drivers/media/usb/uvc/uvc_queue.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index cd962be860ca..6e92d2080255 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -48,12 +48,14 @@ static int uvc_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
48 struct uvc_streaming *stream = 48 struct uvc_streaming *stream =
49 container_of(queue, struct uvc_streaming, queue); 49 container_of(queue, struct uvc_streaming, queue);
50 50
51 if (*nbuffers > UVC_MAX_VIDEO_BUFFERS) 51 /* Make sure the image size is large enough. */
52 *nbuffers = UVC_MAX_VIDEO_BUFFERS; 52 if (fmt && fmt->fmt.pix.sizeimage < stream->ctrl.dwMaxVideoFrameSize)
53 return -EINVAL;
53 54
54 *nplanes = 1; 55 *nplanes = 1;
55 56
56 sizes[0] = stream->ctrl.dwMaxVideoFrameSize; 57 sizes[0] = fmt ? fmt->fmt.pix.sizeimage
58 : stream->ctrl.dwMaxVideoFrameSize;
57 59
58 return 0; 60 return 0;
59} 61}
@@ -104,15 +106,15 @@ static void uvc_buffer_queue(struct vb2_buffer *vb)
104 spin_unlock_irqrestore(&queue->irqlock, flags); 106 spin_unlock_irqrestore(&queue->irqlock, flags);
105} 107}
106 108
107static int uvc_buffer_finish(struct vb2_buffer *vb) 109static void uvc_buffer_finish(struct vb2_buffer *vb)
108{ 110{
109 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); 111 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
110 struct uvc_streaming *stream = 112 struct uvc_streaming *stream =
111 container_of(queue, struct uvc_streaming, queue); 113 container_of(queue, struct uvc_streaming, queue);
112 struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf); 114 struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf);
113 115
114 uvc_video_clock_update(stream, &vb->v4l2_buf, buf); 116 if (vb->state == VB2_BUF_STATE_DONE)
115 return 0; 117 uvc_video_clock_update(stream, &vb->v4l2_buf, buf);
116} 118}
117 119
118static void uvc_wait_prepare(struct vb2_queue *vq) 120static void uvc_wait_prepare(struct vb2_queue *vq)
@@ -149,7 +151,8 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
149 queue->queue.buf_struct_size = sizeof(struct uvc_buffer); 151 queue->queue.buf_struct_size = sizeof(struct uvc_buffer);
150 queue->queue.ops = &uvc_queue_qops; 152 queue->queue.ops = &uvc_queue_qops;
151 queue->queue.mem_ops = &vb2_vmalloc_memops; 153 queue->queue.mem_ops = &vb2_vmalloc_memops;
152 queue->queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 154 queue->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
155 | V4L2_BUF_FLAG_TSTAMP_SRC_SOE;
153 ret = vb2_queue_init(&queue->queue); 156 ret = vb2_queue_init(&queue->queue);
154 if (ret) 157 if (ret)
155 return ret; 158 return ret;
@@ -196,6 +199,18 @@ int uvc_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf)
196 return ret; 199 return ret;
197} 200}
198 201
202int uvc_create_buffers(struct uvc_video_queue *queue,
203 struct v4l2_create_buffers *cb)
204{
205 int ret;
206
207 mutex_lock(&queue->mutex);
208 ret = vb2_create_bufs(&queue->queue, cb);
209 mutex_unlock(&queue->mutex);
210
211 return ret;
212}
213
199int uvc_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf) 214int uvc_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf)
200{ 215{
201 int ret; 216 int ret;