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

media: rcar-vin: Make use of V4L2_CAP_IO_MC

Set the V4L2_CAP_IO_MC capability flag and remove the driver specific
vidioc_enum_input, vidioc_g_input and vidioc_s_input callbacks for the
media controller enabled part of the driver. Also add support mbus_code
filtering for format enumeration.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Niklas Söderlund and committed by
Mauro Carvalho Chehab
d5f74a1e e5b6b07a

+24 -16
+24 -16
drivers/media/platform/rcar-vin/rcar-v4l2.c
··· 343 343 unsigned int i; 344 344 int matched; 345 345 346 + /* 347 + * If mbus_code is set only enumerate supported pixel formats for that 348 + * bus code. Converting from YCbCr to RGB and RGB to YCbCr is possible 349 + * with VIN, so all supported YCbCr and RGB media bus codes can produce 350 + * all of the related pixel formats. If mbus_code is not set enumerate 351 + * all possible pixelformats. 352 + * 353 + * TODO: Once raw capture formats are added to the driver this needs 354 + * to be extended so raw media bus codes only result in raw pixel 355 + * formats. 356 + */ 357 + switch (f->mbus_code) { 358 + case 0: 359 + case MEDIA_BUS_FMT_YUYV8_1X16: 360 + case MEDIA_BUS_FMT_UYVY8_1X16: 361 + case MEDIA_BUS_FMT_UYVY8_2X8: 362 + case MEDIA_BUS_FMT_UYVY10_2X10: 363 + case MEDIA_BUS_FMT_RGB888_1X24: 364 + break; 365 + default: 366 + return -EINVAL; 367 + } 368 + 346 369 matched = -1; 347 370 for (i = 0; i < ARRAY_SIZE(rvin_formats); i++) { 348 371 if (rvin_format_from_pixel(vin, rvin_formats[i].fourcc)) ··· 790 767 return 0; 791 768 } 792 769 793 - static int rvin_mc_enum_input(struct file *file, void *priv, 794 - struct v4l2_input *i) 795 - { 796 - if (i->index != 0) 797 - return -EINVAL; 798 - 799 - i->type = V4L2_INPUT_TYPE_CAMERA; 800 - strscpy(i->name, "Camera", sizeof(i->name)); 801 - 802 - return 0; 803 - } 804 - 805 770 static const struct v4l2_ioctl_ops rvin_mc_ioctl_ops = { 806 771 .vidioc_querycap = rvin_querycap, 807 772 .vidioc_try_fmt_vid_cap = rvin_mc_try_fmt_vid_cap, 808 773 .vidioc_g_fmt_vid_cap = rvin_g_fmt_vid_cap, 809 774 .vidioc_s_fmt_vid_cap = rvin_mc_s_fmt_vid_cap, 810 775 .vidioc_enum_fmt_vid_cap = rvin_enum_fmt_vid_cap, 811 - 812 - .vidioc_enum_input = rvin_mc_enum_input, 813 - .vidioc_g_input = rvin_g_input, 814 - .vidioc_s_input = rvin_s_input, 815 776 816 777 .vidioc_reqbufs = vb2_ioctl_reqbufs, 817 778 .vidioc_create_bufs = vb2_ioctl_create_bufs, ··· 968 961 vin->format.colorspace = RVIN_DEFAULT_COLORSPACE; 969 962 970 963 if (vin->info->use_mc) { 964 + vdev->device_caps |= V4L2_CAP_IO_MC; 971 965 vdev->ioctl_ops = &rvin_mc_ioctl_ops; 972 966 } else { 973 967 vdev->ioctl_ops = &rvin_ioctl_ops;