media: v4l: Add support for V4L2_BUF_TYPE_META_OUTPUT
The V4L2_BUF_TYPE_META_OUTPUT mirrors the V4L2_BUF_TYPE_META_CAPTURE with the exception that it is an OUTPUT type. The use case for this is to pass buffers to the device that are not image data but metadata. The formats, just as the metadata capture formats, are typically device specific and highly structured. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Tested-by: Tian Shu Qiu <tian.shu.qiu@intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:

committed by
Mauro Carvalho Chehab

parent
fa09d06522
commit
72148d1a57
@@ -323,6 +323,7 @@ static int __get_v4l2_format32(struct v4l2_format __user *p64,
|
||||
return copy_in_user(&p64->fmt.sdr, &p32->fmt.sdr,
|
||||
sizeof(p64->fmt.sdr)) ? -EFAULT : 0;
|
||||
case V4L2_BUF_TYPE_META_CAPTURE:
|
||||
case V4L2_BUF_TYPE_META_OUTPUT:
|
||||
return copy_in_user(&p64->fmt.meta, &p32->fmt.meta,
|
||||
sizeof(p64->fmt.meta)) ? -EFAULT : 0;
|
||||
default:
|
||||
@@ -392,6 +393,7 @@ static int __put_v4l2_format32(struct v4l2_format __user *p64,
|
||||
return copy_in_user(&p32->fmt.sdr, &p64->fmt.sdr,
|
||||
sizeof(p64->fmt.sdr)) ? -EFAULT : 0;
|
||||
case V4L2_BUF_TYPE_META_CAPTURE:
|
||||
case V4L2_BUF_TYPE_META_OUTPUT:
|
||||
return copy_in_user(&p32->fmt.meta, &p64->fmt.meta,
|
||||
sizeof(p64->fmt.meta)) ? -EFAULT : 0;
|
||||
default:
|
||||
|
@@ -597,7 +597,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
|
||||
ops->vidioc_enum_fmt_vid_overlay ||
|
||||
ops->vidioc_enum_fmt_meta_cap)) ||
|
||||
(is_tx && (ops->vidioc_enum_fmt_vid_out ||
|
||||
ops->vidioc_enum_fmt_vid_out_mplane)))
|
||||
ops->vidioc_enum_fmt_vid_out_mplane ||
|
||||
ops->vidioc_enum_fmt_meta_out)))
|
||||
set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
|
||||
if ((is_rx && (ops->vidioc_g_fmt_vid_cap ||
|
||||
ops->vidioc_g_fmt_vid_cap_mplane ||
|
||||
@@ -605,7 +606,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
|
||||
ops->vidioc_g_fmt_meta_cap)) ||
|
||||
(is_tx && (ops->vidioc_g_fmt_vid_out ||
|
||||
ops->vidioc_g_fmt_vid_out_mplane ||
|
||||
ops->vidioc_g_fmt_vid_out_overlay)))
|
||||
ops->vidioc_g_fmt_vid_out_overlay ||
|
||||
ops->vidioc_g_fmt_meta_out)))
|
||||
set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
|
||||
if ((is_rx && (ops->vidioc_s_fmt_vid_cap ||
|
||||
ops->vidioc_s_fmt_vid_cap_mplane ||
|
||||
@@ -613,7 +615,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
|
||||
ops->vidioc_s_fmt_meta_cap)) ||
|
||||
(is_tx && (ops->vidioc_s_fmt_vid_out ||
|
||||
ops->vidioc_s_fmt_vid_out_mplane ||
|
||||
ops->vidioc_s_fmt_vid_out_overlay)))
|
||||
ops->vidioc_s_fmt_vid_out_overlay ||
|
||||
ops->vidioc_s_fmt_meta_out)))
|
||||
set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
|
||||
if ((is_rx && (ops->vidioc_try_fmt_vid_cap ||
|
||||
ops->vidioc_try_fmt_vid_cap_mplane ||
|
||||
@@ -621,7 +624,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
|
||||
ops->vidioc_try_fmt_meta_cap)) ||
|
||||
(is_tx && (ops->vidioc_try_fmt_vid_out ||
|
||||
ops->vidioc_try_fmt_vid_out_mplane ||
|
||||
ops->vidioc_try_fmt_vid_out_overlay)))
|
||||
ops->vidioc_try_fmt_vid_out_overlay ||
|
||||
ops->vidioc_try_fmt_meta_out)))
|
||||
set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
|
||||
SET_VALID_IOCTL(ops, VIDIOC_OVERLAY, vidioc_overlay);
|
||||
SET_VALID_IOCTL(ops, VIDIOC_G_FBUF, vidioc_g_fbuf);
|
||||
|
@@ -194,6 +194,7 @@ const char *v4l2_type_names[] = {
|
||||
[V4L2_BUF_TYPE_SDR_CAPTURE] = "sdr-cap",
|
||||
[V4L2_BUF_TYPE_SDR_OUTPUT] = "sdr-out",
|
||||
[V4L2_BUF_TYPE_META_CAPTURE] = "meta-cap",
|
||||
[V4L2_BUF_TYPE_META_OUTPUT] = "meta-out",
|
||||
};
|
||||
EXPORT_SYMBOL(v4l2_type_names);
|
||||
|
||||
@@ -366,6 +367,7 @@ static void v4l_print_format(const void *arg, bool write_only)
|
||||
(sdr->pixelformat >> 24) & 0xff);
|
||||
break;
|
||||
case V4L2_BUF_TYPE_META_CAPTURE:
|
||||
case V4L2_BUF_TYPE_META_OUTPUT:
|
||||
meta = &p->fmt.meta;
|
||||
pr_cont(", dataformat=%c%c%c%c, buffersize=%u\n",
|
||||
(meta->dataformat >> 0) & 0xff,
|
||||
@@ -999,6 +1001,10 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
|
||||
if (is_vid && is_rx && ops->vidioc_g_fmt_meta_cap)
|
||||
return 0;
|
||||
break;
|
||||
case V4L2_BUF_TYPE_META_OUTPUT:
|
||||
if (is_vid && is_tx && ops->vidioc_g_fmt_meta_out)
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1410,6 +1416,11 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
|
||||
break;
|
||||
ret = ops->vidioc_enum_fmt_meta_cap(file, fh, arg);
|
||||
break;
|
||||
case V4L2_BUF_TYPE_META_OUTPUT:
|
||||
if (unlikely(!ops->vidioc_enum_fmt_meta_out))
|
||||
break;
|
||||
ret = ops->vidioc_enum_fmt_meta_out(file, fh, arg);
|
||||
break;
|
||||
}
|
||||
if (ret == 0)
|
||||
v4l_fill_fmtdesc(p);
|
||||
@@ -1488,6 +1499,8 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
|
||||
return ops->vidioc_g_fmt_sdr_out(file, fh, arg);
|
||||
case V4L2_BUF_TYPE_META_CAPTURE:
|
||||
return ops->vidioc_g_fmt_meta_cap(file, fh, arg);
|
||||
case V4L2_BUF_TYPE_META_OUTPUT:
|
||||
return ops->vidioc_g_fmt_meta_out(file, fh, arg);
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1601,6 +1614,11 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
|
||||
break;
|
||||
CLEAR_AFTER_FIELD(p, fmt.meta);
|
||||
return ops->vidioc_s_fmt_meta_cap(file, fh, arg);
|
||||
case V4L2_BUF_TYPE_META_OUTPUT:
|
||||
if (unlikely(!ops->vidioc_s_fmt_meta_out))
|
||||
break;
|
||||
CLEAR_AFTER_FIELD(p, fmt.meta);
|
||||
return ops->vidioc_s_fmt_meta_out(file, fh, arg);
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1693,6 +1711,11 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
|
||||
break;
|
||||
CLEAR_AFTER_FIELD(p, fmt.meta);
|
||||
return ops->vidioc_try_fmt_meta_cap(file, fh, arg);
|
||||
case V4L2_BUF_TYPE_META_OUTPUT:
|
||||
if (unlikely(!ops->vidioc_try_fmt_meta_out))
|
||||
break;
|
||||
CLEAR_AFTER_FIELD(p, fmt.meta);
|
||||
return ops->vidioc_try_fmt_meta_out(file, fh, arg);
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user