diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-11 23:39:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-11 23:39:17 -0400 |
commit | 4f1cd91497774488ed16119ec3f54b3daf1561de (patch) | |
tree | 190ed2b2ecbbfe371740cf6e29d9aefd25ecc3e3 /drivers/media/v4l2-core | |
parent | 759e00b8a8883be28357426206d2f1752827e38a (diff) | |
parent | bf3b202b41999f88f091632f13842b7234bd58b7 (diff) |
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull second set of media updates from Mauro Carvalho Chehab:
"Despite its size, most of the stuff here is trivial. This series
contains:
- s5p-mfc: additions at the driver and at the core to support H.264
hardware codec;
- Some improvements at s5p and davinci embedded drivers;
- Some V4L2 compliance fixes applied on a few drivers;
- Several random trivial patches, including several fixes and a few
new board support additions;
Notes:
1) Some Exynos media patches were dependent on some -arm fixes that
got merged on changeset 782cd9e. That's why this pull request is
based that changeset.
2) As promised, I reviewed the pending VB2 DMABUF series.
While setting a test environment, it was noticed that the upstream
support for Samsung Exynos 4 boards (smdk310 and Origen) are
broken upstream, likely due to regressions: both defconfigs are
wrong and regulator settings for both boards are broken. That,
allied with some bug at the dummy regulator driver, causes OOPSes
during boot time.
Long story short: even fixing the above, the proposed patches
OOPSed when running the DMABUF test. Not sure yet if the OOPSes
are due to some other undetected regressions, or due to some bug
on the patches.
Due to the above, DMABUF patches for vb2 got NACKed for 3.7."
* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (109 commits)
[media] m5mols: Add missing #include <linux/sizes.h>
[media] stk1160: Add support for S-Video input
Revert "[media] omap3isp: Replace cpu_is_omap3630() with ISP revision check"
[media] dvb: LNA implementation changes
[media] v4l2-ioctl: fix W=1 warnings
[media] v4l2-ioctl: add blocks check for VIDIOC_SUBDEV_G/S_EDID
[media] omap3isp: Fix compilation error in ispreg.h
[media] rc-msi-digivox-ii: Add full scan keycodes
[media] cx25821: testing the wrong variable
[media] tda18271-common: hold the I2C adapter during write transfers
[media] ds3000: add module parameter to force firmware upload
[media] drivers/media: Remove unnecessary semicolon
[media] winbond: remove space from driver name
[media] iguanair: cannot send data from the stack
[media] omap3isp: Replace cpu_is_omap3630() with ISP revision check
[media] dvb-usb: print small buffers via %*ph
[media] uvc: Add return code check at vb2_queue_init()
[media] em28xx: Replace memcpy with struct assignment
[media] bt8xx: Add video4linux control V4L2_CID_COLOR_KILLER
[media] mem2mem_testdev: Use devm_kzalloc() in probe
...
Conflicts:
arch/arm/mach-davinci/include/mach/da8xx.h
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ctrls.c | 74 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ioctl.c | 8 | ||||
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-core.c | 79 |
3 files changed, 119 insertions, 42 deletions
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 631cdc0e0bda..f6ee201d9347 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c | |||
@@ -384,6 +384,25 @@ const char * const *v4l2_ctrl_get_menu(u32 id) | |||
384 | "Extended SAR", | 384 | "Extended SAR", |
385 | NULL, | 385 | NULL, |
386 | }; | 386 | }; |
387 | static const char * const h264_fp_arrangement_type[] = { | ||
388 | "Checkerboard", | ||
389 | "Column", | ||
390 | "Row", | ||
391 | "Side by Side", | ||
392 | "Top Bottom", | ||
393 | "Temporal", | ||
394 | NULL, | ||
395 | }; | ||
396 | static const char * const h264_fmo_map_type[] = { | ||
397 | "Interleaved Slices", | ||
398 | "Scattered Slices", | ||
399 | "Foreground with Leftover", | ||
400 | "Box Out", | ||
401 | "Raster Scan", | ||
402 | "Wipe Scan", | ||
403 | "Explicit", | ||
404 | NULL, | ||
405 | }; | ||
387 | static const char * const mpeg_mpeg4_level[] = { | 406 | static const char * const mpeg_mpeg4_level[] = { |
388 | "0", | 407 | "0", |
389 | "0b", | 408 | "0b", |
@@ -508,6 +527,10 @@ const char * const *v4l2_ctrl_get_menu(u32 id) | |||
508 | return h264_profile; | 527 | return h264_profile; |
509 | case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC: | 528 | case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC: |
510 | return vui_sar_idc; | 529 | return vui_sar_idc; |
530 | case V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE: | ||
531 | return h264_fp_arrangement_type; | ||
532 | case V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE: | ||
533 | return h264_fmo_map_type; | ||
511 | case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: | 534 | case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: |
512 | return mpeg_mpeg4_level; | 535 | return mpeg_mpeg4_level; |
513 | case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: | 536 | case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: |
@@ -643,6 +666,22 @@ const char *v4l2_ctrl_get_name(u32 id) | |||
643 | case V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_WIDTH: return "Horizontal Size of SAR"; | 666 | case V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_WIDTH: return "Horizontal Size of SAR"; |
644 | case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE: return "Aspect Ratio VUI Enable"; | 667 | case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE: return "Aspect Ratio VUI Enable"; |
645 | case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC: return "VUI Aspect Ratio IDC"; | 668 | case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC: return "VUI Aspect Ratio IDC"; |
669 | case V4L2_CID_MPEG_VIDEO_H264_SEI_FRAME_PACKING: return "H264 Enable Frame Packing SEI"; | ||
670 | case V4L2_CID_MPEG_VIDEO_H264_SEI_FP_CURRENT_FRAME_0: return "H264 Set Curr. Frame as Frame0"; | ||
671 | case V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE: return "H264 FP Arrangement Type"; | ||
672 | case V4L2_CID_MPEG_VIDEO_H264_FMO: return "H264 Flexible MB Ordering"; | ||
673 | case V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE: return "H264 Map Type for FMO"; | ||
674 | case V4L2_CID_MPEG_VIDEO_H264_FMO_SLICE_GROUP: return "H264 FMO Number of Slice Groups"; | ||
675 | case V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_DIRECTION: return "H264 FMO Direction of Change"; | ||
676 | case V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_RATE: return "H264 FMO Size of 1st Slice Grp"; | ||
677 | case V4L2_CID_MPEG_VIDEO_H264_FMO_RUN_LENGTH: return "H264 FMO No. of Consecutive MBs"; | ||
678 | case V4L2_CID_MPEG_VIDEO_H264_ASO: return "H264 Arbitrary Slice Ordering"; | ||
679 | case V4L2_CID_MPEG_VIDEO_H264_ASO_SLICE_ORDER: return "H264 ASO Slice Order"; | ||
680 | case V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING: return "Enable H264 Hierarchical Coding"; | ||
681 | case V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE: return "H264 Hierarchical Coding Type"; | ||
682 | case V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER:return "H264 Number of HC Layers"; | ||
683 | case V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP: | ||
684 | return "H264 Set QP Value for HC Layers"; | ||
646 | case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP: return "MPEG4 I-Frame QP Value"; | 685 | case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP: return "MPEG4 I-Frame QP Value"; |
647 | case V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP: return "MPEG4 P-Frame QP Value"; | 686 | case V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP: return "MPEG4 P-Frame QP Value"; |
648 | case V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP: return "MPEG4 B-Frame QP Value"; | 687 | case V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP: return "MPEG4 B-Frame QP Value"; |
@@ -657,6 +696,7 @@ const char *v4l2_ctrl_get_name(u32 id) | |||
657 | case V4L2_CID_MPEG_VIDEO_VBV_SIZE: return "VBV Buffer Size"; | 696 | case V4L2_CID_MPEG_VIDEO_VBV_SIZE: return "VBV Buffer Size"; |
658 | case V4L2_CID_MPEG_VIDEO_DEC_PTS: return "Video Decoder PTS"; | 697 | case V4L2_CID_MPEG_VIDEO_DEC_PTS: return "Video Decoder PTS"; |
659 | case V4L2_CID_MPEG_VIDEO_DEC_FRAME: return "Video Decoder Frame Count"; | 698 | case V4L2_CID_MPEG_VIDEO_DEC_FRAME: return "Video Decoder Frame Count"; |
699 | case V4L2_CID_MPEG_VIDEO_VBV_DELAY: return "Initial Delay for VBV Control"; | ||
660 | 700 | ||
661 | /* CAMERA controls */ | 701 | /* CAMERA controls */ |
662 | /* Keep the order of the 'case's the same as in videodev2.h! */ | 702 | /* Keep the order of the 'case's the same as in videodev2.h! */ |
@@ -749,6 +789,7 @@ const char *v4l2_ctrl_get_name(u32 id) | |||
749 | case V4L2_CID_IMAGE_PROC_CLASS: return "Image Processing Controls"; | 789 | case V4L2_CID_IMAGE_PROC_CLASS: return "Image Processing Controls"; |
750 | case V4L2_CID_LINK_FREQ: return "Link Frequency"; | 790 | case V4L2_CID_LINK_FREQ: return "Link Frequency"; |
751 | case V4L2_CID_PIXEL_RATE: return "Pixel Rate"; | 791 | case V4L2_CID_PIXEL_RATE: return "Pixel Rate"; |
792 | case V4L2_CID_TEST_PATTERN: return "Test Pattern"; | ||
752 | 793 | ||
753 | /* DV controls */ | 794 | /* DV controls */ |
754 | case V4L2_CID_DV_CLASS: return "Digital Video Controls"; | 795 | case V4L2_CID_DV_CLASS: return "Digital Video Controls"; |
@@ -853,6 +894,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, | |||
853 | case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE: | 894 | case V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE: |
854 | case V4L2_CID_MPEG_VIDEO_H264_PROFILE: | 895 | case V4L2_CID_MPEG_VIDEO_H264_PROFILE: |
855 | case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC: | 896 | case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC: |
897 | case V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE: | ||
898 | case V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE: | ||
856 | case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: | 899 | case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: |
857 | case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: | 900 | case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: |
858 | case V4L2_CID_JPEG_CHROMA_SUBSAMPLING: | 901 | case V4L2_CID_JPEG_CHROMA_SUBSAMPLING: |
@@ -862,6 +905,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, | |||
862 | case V4L2_CID_DV_TX_MODE: | 905 | case V4L2_CID_DV_TX_MODE: |
863 | case V4L2_CID_DV_TX_RGB_RANGE: | 906 | case V4L2_CID_DV_TX_RGB_RANGE: |
864 | case V4L2_CID_DV_RX_RGB_RANGE: | 907 | case V4L2_CID_DV_RX_RGB_RANGE: |
908 | case V4L2_CID_TEST_PATTERN: | ||
865 | *type = V4L2_CTRL_TYPE_MENU; | 909 | *type = V4L2_CTRL_TYPE_MENU; |
866 | break; | 910 | break; |
867 | case V4L2_CID_LINK_FREQ: | 911 | case V4L2_CID_LINK_FREQ: |
@@ -1648,6 +1692,36 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, | |||
1648 | } | 1692 | } |
1649 | EXPORT_SYMBOL(v4l2_ctrl_new_std_menu); | 1693 | EXPORT_SYMBOL(v4l2_ctrl_new_std_menu); |
1650 | 1694 | ||
1695 | /* Helper function for standard menu controls with driver defined menu */ | ||
1696 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, | ||
1697 | const struct v4l2_ctrl_ops *ops, u32 id, s32 max, | ||
1698 | s32 mask, s32 def, const char * const *qmenu) | ||
1699 | { | ||
1700 | enum v4l2_ctrl_type type; | ||
1701 | const char *name; | ||
1702 | u32 flags; | ||
1703 | s32 step; | ||
1704 | s32 min; | ||
1705 | |||
1706 | /* v4l2_ctrl_new_std_menu_items() should only be called for | ||
1707 | * standard controls without a standard menu. | ||
1708 | */ | ||
1709 | if (v4l2_ctrl_get_menu(id)) { | ||
1710 | handler_set_err(hdl, -EINVAL); | ||
1711 | return NULL; | ||
1712 | } | ||
1713 | |||
1714 | v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags); | ||
1715 | if (type != V4L2_CTRL_TYPE_MENU || qmenu == NULL) { | ||
1716 | handler_set_err(hdl, -EINVAL); | ||
1717 | return NULL; | ||
1718 | } | ||
1719 | return v4l2_ctrl_new(hdl, ops, id, name, type, 0, max, mask, def, | ||
1720 | flags, qmenu, NULL, NULL); | ||
1721 | |||
1722 | } | ||
1723 | EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items); | ||
1724 | |||
1651 | /* Helper function for standard integer menu controls */ | 1725 | /* Helper function for standard integer menu controls */ |
1652 | struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, | 1726 | struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, |
1653 | const struct v4l2_ctrl_ops *ops, | 1727 | const struct v4l2_ctrl_ops *ops, |
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 9d3e46c446ad..8f388ff31ebb 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c | |||
@@ -157,8 +157,7 @@ static const char *v4l2_memory_names[] = { | |||
157 | [V4L2_MEMORY_OVERLAY] = "overlay", | 157 | [V4L2_MEMORY_OVERLAY] = "overlay", |
158 | }; | 158 | }; |
159 | 159 | ||
160 | #define prt_names(a, arr) ((((a) >= 0) && ((a) < ARRAY_SIZE(arr))) ? \ | 160 | #define prt_names(a, arr) (((unsigned)(a)) < ARRAY_SIZE(arr) ? arr[a] : "unknown") |
161 | arr[a] : "unknown") | ||
162 | 161 | ||
163 | /* ------------------------------------------------------------------ */ | 162 | /* ------------------------------------------------------------------ */ |
164 | /* debug help functions */ | 163 | /* debug help functions */ |
@@ -2188,6 +2187,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size, | |||
2188 | int ret = 0; | 2187 | int ret = 0; |
2189 | 2188 | ||
2190 | switch (cmd) { | 2189 | switch (cmd) { |
2190 | case VIDIOC_PREPARE_BUF: | ||
2191 | case VIDIOC_QUERYBUF: | 2191 | case VIDIOC_QUERYBUF: |
2192 | case VIDIOC_QBUF: | 2192 | case VIDIOC_QBUF: |
2193 | case VIDIOC_DQBUF: { | 2193 | case VIDIOC_DQBUF: { |
@@ -2211,6 +2211,10 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size, | |||
2211 | struct v4l2_subdev_edid *edid = parg; | 2211 | struct v4l2_subdev_edid *edid = parg; |
2212 | 2212 | ||
2213 | if (edid->blocks) { | 2213 | if (edid->blocks) { |
2214 | if (edid->blocks > 256) { | ||
2215 | ret = -EINVAL; | ||
2216 | break; | ||
2217 | } | ||
2214 | *user_ptr = (void __user *)edid->edid; | 2218 | *user_ptr = (void __user *)edid->edid; |
2215 | *kernel_ptr = (void *)&edid->edid; | 2219 | *kernel_ptr = (void *)&edid->edid; |
2216 | *array_size = edid->blocks * 128; | 2220 | *array_size = edid->blocks * 128; |
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index e6a26b433e87..432df119af27 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c | |||
@@ -276,6 +276,9 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) | |||
276 | */ | 276 | */ |
277 | static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer *b) | 277 | static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer *b) |
278 | { | 278 | { |
279 | if (!V4L2_TYPE_IS_MULTIPLANAR(b->type)) | ||
280 | return 0; | ||
281 | |||
279 | /* Is memory for copying plane information present? */ | 282 | /* Is memory for copying plane information present? */ |
280 | if (NULL == b->m.planes) { | 283 | if (NULL == b->m.planes) { |
281 | dprintk(1, "Multi-planar buffer passed but " | 284 | dprintk(1, "Multi-planar buffer passed but " |
@@ -331,10 +334,9 @@ static bool __buffers_in_use(struct vb2_queue *q) | |||
331 | * __fill_v4l2_buffer() - fill in a struct v4l2_buffer with information to be | 334 | * __fill_v4l2_buffer() - fill in a struct v4l2_buffer with information to be |
332 | * returned to userspace | 335 | * returned to userspace |
333 | */ | 336 | */ |
334 | static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b) | 337 | static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b) |
335 | { | 338 | { |
336 | struct vb2_queue *q = vb->vb2_queue; | 339 | struct vb2_queue *q = vb->vb2_queue; |
337 | int ret; | ||
338 | 340 | ||
339 | /* Copy back data such as timestamp, flags, etc. */ | 341 | /* Copy back data such as timestamp, flags, etc. */ |
340 | memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); | 342 | memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); |
@@ -342,14 +344,11 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b) | |||
342 | b->reserved = vb->v4l2_buf.reserved; | 344 | b->reserved = vb->v4l2_buf.reserved; |
343 | 345 | ||
344 | if (V4L2_TYPE_IS_MULTIPLANAR(q->type)) { | 346 | if (V4L2_TYPE_IS_MULTIPLANAR(q->type)) { |
345 | ret = __verify_planes_array(vb, b); | ||
346 | if (ret) | ||
347 | return ret; | ||
348 | |||
349 | /* | 347 | /* |
350 | * Fill in plane-related data if userspace provided an array | 348 | * Fill in plane-related data if userspace provided an array |
351 | * for it. The memory and size is verified above. | 349 | * for it. The caller has already verified memory and size. |
352 | */ | 350 | */ |
351 | b->length = vb->num_planes; | ||
353 | memcpy(b->m.planes, vb->v4l2_planes, | 352 | memcpy(b->m.planes, vb->v4l2_planes, |
354 | b->length * sizeof(struct v4l2_plane)); | 353 | b->length * sizeof(struct v4l2_plane)); |
355 | } else { | 354 | } else { |
@@ -391,8 +390,6 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b) | |||
391 | 390 | ||
392 | if (__buffer_in_use(q, vb)) | 391 | if (__buffer_in_use(q, vb)) |
393 | b->flags |= V4L2_BUF_FLAG_MAPPED; | 392 | b->flags |= V4L2_BUF_FLAG_MAPPED; |
394 | |||
395 | return 0; | ||
396 | } | 393 | } |
397 | 394 | ||
398 | /** | 395 | /** |
@@ -411,6 +408,7 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b) | |||
411 | int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b) | 408 | int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b) |
412 | { | 409 | { |
413 | struct vb2_buffer *vb; | 410 | struct vb2_buffer *vb; |
411 | int ret; | ||
414 | 412 | ||
415 | if (b->type != q->type) { | 413 | if (b->type != q->type) { |
416 | dprintk(1, "querybuf: wrong buffer type\n"); | 414 | dprintk(1, "querybuf: wrong buffer type\n"); |
@@ -422,8 +420,10 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b) | |||
422 | return -EINVAL; | 420 | return -EINVAL; |
423 | } | 421 | } |
424 | vb = q->bufs[b->index]; | 422 | vb = q->bufs[b->index]; |
425 | 423 | ret = __verify_planes_array(vb, b); | |
426 | return __fill_v4l2_buffer(vb, b); | 424 | if (!ret) |
425 | __fill_v4l2_buffer(vb, b); | ||
426 | return ret; | ||
427 | } | 427 | } |
428 | EXPORT_SYMBOL(vb2_querybuf); | 428 | EXPORT_SYMBOL(vb2_querybuf); |
429 | 429 | ||
@@ -813,24 +813,16 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) | |||
813 | EXPORT_SYMBOL_GPL(vb2_buffer_done); | 813 | EXPORT_SYMBOL_GPL(vb2_buffer_done); |
814 | 814 | ||
815 | /** | 815 | /** |
816 | * __fill_vb2_buffer() - fill a vb2_buffer with information provided in | 816 | * __fill_vb2_buffer() - fill a vb2_buffer with information provided in a |
817 | * a v4l2_buffer by the userspace | 817 | * v4l2_buffer by the userspace. The caller has already verified that struct |
818 | * v4l2_buffer has a valid number of planes. | ||
818 | */ | 819 | */ |
819 | static int __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b, | 820 | static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b, |
820 | struct v4l2_plane *v4l2_planes) | 821 | struct v4l2_plane *v4l2_planes) |
821 | { | 822 | { |
822 | unsigned int plane; | 823 | unsigned int plane; |
823 | int ret; | ||
824 | 824 | ||
825 | if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { | 825 | if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { |
826 | /* | ||
827 | * Verify that the userspace gave us a valid array for | ||
828 | * plane information. | ||
829 | */ | ||
830 | ret = __verify_planes_array(vb, b); | ||
831 | if (ret) | ||
832 | return ret; | ||
833 | |||
834 | /* Fill in driver-provided information for OUTPUT types */ | 826 | /* Fill in driver-provided information for OUTPUT types */ |
835 | if (V4L2_TYPE_IS_OUTPUT(b->type)) { | 827 | if (V4L2_TYPE_IS_OUTPUT(b->type)) { |
836 | /* | 828 | /* |
@@ -872,8 +864,6 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b, | |||
872 | vb->v4l2_buf.field = b->field; | 864 | vb->v4l2_buf.field = b->field; |
873 | vb->v4l2_buf.timestamp = b->timestamp; | 865 | vb->v4l2_buf.timestamp = b->timestamp; |
874 | vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS; | 866 | vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS; |
875 | |||
876 | return 0; | ||
877 | } | 867 | } |
878 | 868 | ||
879 | /** | 869 | /** |
@@ -888,10 +878,8 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
888 | int ret; | 878 | int ret; |
889 | int write = !V4L2_TYPE_IS_OUTPUT(q->type); | 879 | int write = !V4L2_TYPE_IS_OUTPUT(q->type); |
890 | 880 | ||
891 | /* Verify and copy relevant information provided by the userspace */ | 881 | /* Copy relevant information provided by the userspace */ |
892 | ret = __fill_vb2_buffer(vb, b, planes); | 882 | __fill_vb2_buffer(vb, b, planes); |
893 | if (ret) | ||
894 | return ret; | ||
895 | 883 | ||
896 | for (plane = 0; plane < vb->num_planes; ++plane) { | 884 | for (plane = 0; plane < vb->num_planes; ++plane) { |
897 | /* Skip the plane if already verified */ | 885 | /* Skip the plane if already verified */ |
@@ -966,7 +954,8 @@ err: | |||
966 | */ | 954 | */ |
967 | static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b) | 955 | static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b) |
968 | { | 956 | { |
969 | return __fill_vb2_buffer(vb, b, vb->v4l2_planes); | 957 | __fill_vb2_buffer(vb, b, vb->v4l2_planes); |
958 | return 0; | ||
970 | } | 959 | } |
971 | 960 | ||
972 | /** | 961 | /** |
@@ -1059,7 +1048,9 @@ int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b) | |||
1059 | dprintk(1, "%s(): invalid buffer state %d\n", __func__, vb->state); | 1048 | dprintk(1, "%s(): invalid buffer state %d\n", __func__, vb->state); |
1060 | return -EINVAL; | 1049 | return -EINVAL; |
1061 | } | 1050 | } |
1062 | 1051 | ret = __verify_planes_array(vb, b); | |
1052 | if (ret < 0) | ||
1053 | return ret; | ||
1063 | ret = __buf_prepare(vb, b); | 1054 | ret = __buf_prepare(vb, b); |
1064 | if (ret < 0) | 1055 | if (ret < 0) |
1065 | return ret; | 1056 | return ret; |
@@ -1147,6 +1138,9 @@ int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) | |||
1147 | ret = -EINVAL; | 1138 | ret = -EINVAL; |
1148 | goto unlock; | 1139 | goto unlock; |
1149 | } | 1140 | } |
1141 | ret = __verify_planes_array(vb, b); | ||
1142 | if (ret) | ||
1143 | goto unlock; | ||
1150 | 1144 | ||
1151 | switch (vb->state) { | 1145 | switch (vb->state) { |
1152 | case VB2_BUF_STATE_DEQUEUED: | 1146 | case VB2_BUF_STATE_DEQUEUED: |
@@ -1243,8 +1237,10 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking) | |||
1243 | * the locks or return an error if one occurred. | 1237 | * the locks or return an error if one occurred. |
1244 | */ | 1238 | */ |
1245 | call_qop(q, wait_finish, q); | 1239 | call_qop(q, wait_finish, q); |
1246 | if (ret) | 1240 | if (ret) { |
1241 | dprintk(1, "Sleep was interrupted\n"); | ||
1247 | return ret; | 1242 | return ret; |
1243 | } | ||
1248 | } | 1244 | } |
1249 | return 0; | 1245 | return 0; |
1250 | } | 1246 | } |
@@ -1255,7 +1251,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking) | |||
1255 | * Will sleep if required for nonblocking == false. | 1251 | * Will sleep if required for nonblocking == false. |
1256 | */ | 1252 | */ |
1257 | static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb, | 1253 | static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb, |
1258 | int nonblocking) | 1254 | struct v4l2_buffer *b, int nonblocking) |
1259 | { | 1255 | { |
1260 | unsigned long flags; | 1256 | unsigned long flags; |
1261 | int ret; | 1257 | int ret; |
@@ -1273,10 +1269,16 @@ static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb, | |||
1273 | */ | 1269 | */ |
1274 | spin_lock_irqsave(&q->done_lock, flags); | 1270 | spin_lock_irqsave(&q->done_lock, flags); |
1275 | *vb = list_first_entry(&q->done_list, struct vb2_buffer, done_entry); | 1271 | *vb = list_first_entry(&q->done_list, struct vb2_buffer, done_entry); |
1276 | list_del(&(*vb)->done_entry); | 1272 | /* |
1273 | * Only remove the buffer from done_list if v4l2_buffer can handle all | ||
1274 | * the planes. | ||
1275 | */ | ||
1276 | ret = __verify_planes_array(*vb, b); | ||
1277 | if (!ret) | ||
1278 | list_del(&(*vb)->done_entry); | ||
1277 | spin_unlock_irqrestore(&q->done_lock, flags); | 1279 | spin_unlock_irqrestore(&q->done_lock, flags); |
1278 | 1280 | ||
1279 | return 0; | 1281 | return ret; |
1280 | } | 1282 | } |
1281 | 1283 | ||
1282 | /** | 1284 | /** |
@@ -1335,12 +1337,9 @@ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking) | |||
1335 | dprintk(1, "dqbuf: invalid buffer type\n"); | 1337 | dprintk(1, "dqbuf: invalid buffer type\n"); |
1336 | return -EINVAL; | 1338 | return -EINVAL; |
1337 | } | 1339 | } |
1338 | 1340 | ret = __vb2_get_done_vb(q, &vb, b, nonblocking); | |
1339 | ret = __vb2_get_done_vb(q, &vb, nonblocking); | 1341 | if (ret < 0) |
1340 | if (ret < 0) { | ||
1341 | dprintk(1, "dqbuf: error getting next done buffer\n"); | ||
1342 | return ret; | 1342 | return ret; |
1343 | } | ||
1344 | 1343 | ||
1345 | ret = call_qop(q, buf_finish, vb); | 1344 | ret = call_qop(q, buf_finish, vb); |
1346 | if (ret) { | 1345 | if (ret) { |