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

media: omap3isp: implement enum_fmt_vid_cap/out

Add missing ioctls. This makes v4l2-compliance happier:

fail: v4l2-test-formats.cpp(516): pixelformat 59565955 (UYVY) for buftype 1 not reported by ENUM_FMT
test VIDIOC_G_FMT: FAIL
fail: v4l2-test-formats.cpp(516): pixelformat 59565955 (UYVY) for buftype 1 not reported by ENUM_FMT
test VIDIOC_TRY_FMT: FAIL
fail: v4l2-test-formats.cpp(516): pixelformat 56595559 (YUYV) for buftype 1 not reported by ENUM_FMT
test VIDIOC_S_FMT: FAIL

Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

+36 -3
+36 -3
drivers/media/platform/ti/omap3isp/ispvideo.c
··· 35 35 /* 36 36 * NOTE: When adding new media bus codes, always remember to add 37 37 * corresponding in-memory formats to the table below!!! 38 + * 39 + * If there are multiple entries with the same pixelformat but 40 + * different media bus codes, then keep those together. Otherwise 41 + * isp_video_enum_format() cannot detect duplicate pixelformats. 38 42 */ 39 43 static struct isp_format_info formats[] = { 40 44 { MEDIA_BUS_FMT_Y8_1X8, MEDIA_BUS_FMT_Y8_1X8, ··· 101 97 { MEDIA_BUS_FMT_UYVY8_1X16, MEDIA_BUS_FMT_UYVY8_1X16, 102 98 MEDIA_BUS_FMT_UYVY8_1X16, 0, 103 99 V4L2_PIX_FMT_UYVY, 16, 2, }, 104 - { MEDIA_BUS_FMT_YUYV8_1X16, MEDIA_BUS_FMT_YUYV8_1X16, 105 - MEDIA_BUS_FMT_YUYV8_1X16, 0, 106 - V4L2_PIX_FMT_YUYV, 16, 2, }, 107 100 { MEDIA_BUS_FMT_UYVY8_2X8, MEDIA_BUS_FMT_UYVY8_2X8, 108 101 MEDIA_BUS_FMT_UYVY8_2X8, 0, 109 102 V4L2_PIX_FMT_UYVY, 8, 2, }, 103 + { MEDIA_BUS_FMT_YUYV8_1X16, MEDIA_BUS_FMT_YUYV8_1X16, 104 + MEDIA_BUS_FMT_YUYV8_1X16, 0, 105 + V4L2_PIX_FMT_YUYV, 16, 2, }, 110 106 { MEDIA_BUS_FMT_YUYV8_2X8, MEDIA_BUS_FMT_YUYV8_2X8, 111 107 MEDIA_BUS_FMT_YUYV8_2X8, 0, 112 108 V4L2_PIX_FMT_YUYV, 8, 2, }, ··· 654 650 | V4L2_CAP_STREAMING | V4L2_CAP_DEVICE_CAPS | V4L2_CAP_IO_MC; 655 651 656 652 return 0; 653 + } 654 + 655 + static int 656 + isp_video_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f) 657 + { 658 + struct isp_video *video = video_drvdata(file); 659 + unsigned int i, j; 660 + 661 + if (f->type != video->type) 662 + return -EINVAL; 663 + 664 + for (i = 0, j = 0; i < ARRAY_SIZE(formats); i++) { 665 + /* Weed out duplicate pixelformats with different mbus codes */ 666 + if (!f->mbus_code && i && 667 + formats[i - 1].pixelformat == formats[i].pixelformat) 668 + continue; 669 + if (f->mbus_code && formats[i].code != f->mbus_code) 670 + continue; 671 + 672 + if (j == f->index) { 673 + f->pixelformat = formats[i].pixelformat; 674 + return 0; 675 + } 676 + j++; 677 + } 678 + 679 + return -EINVAL; 657 680 } 658 681 659 682 static int ··· 1289 1258 1290 1259 static const struct v4l2_ioctl_ops isp_video_ioctl_ops = { 1291 1260 .vidioc_querycap = isp_video_querycap, 1261 + .vidioc_enum_fmt_vid_cap = isp_video_enum_format, 1292 1262 .vidioc_g_fmt_vid_cap = isp_video_get_format, 1293 1263 .vidioc_s_fmt_vid_cap = isp_video_set_format, 1294 1264 .vidioc_try_fmt_vid_cap = isp_video_try_format, 1265 + .vidioc_enum_fmt_vid_out = isp_video_enum_format, 1295 1266 .vidioc_g_fmt_vid_out = isp_video_get_format, 1296 1267 .vidioc_s_fmt_vid_out = isp_video_set_format, 1297 1268 .vidioc_try_fmt_vid_out = isp_video_try_format,