media: vivid: support multiplanar touch devices

The v4l2-compliance tests failed with the touch device when multiplanar was
enabled in vivid. Since it is perfectly fine to support the multiplanar API
for touch, add support for this in vivid.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Hans Verkuil 2019-12-15 12:09:32 +01:00 committed by Mauro Carvalho Chehab
parent 095c21d31b
commit 0885acd77e
4 changed files with 60 additions and 8 deletions

View File

@ -509,6 +509,36 @@ static int vivid_s_fmt_cap(struct file *file, void *priv,
return vidioc_s_fmt_vid_cap(file, priv, f);
}
static int vivid_g_fmt_cap_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
struct video_device *vdev = video_devdata(file);
if (vdev->vfl_type == VFL_TYPE_TOUCH)
return vivid_g_fmt_tch_mplane(file, priv, f);
return vidioc_g_fmt_vid_cap_mplane(file, priv, f);
}
static int vivid_try_fmt_cap_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
struct video_device *vdev = video_devdata(file);
if (vdev->vfl_type == VFL_TYPE_TOUCH)
return vivid_g_fmt_tch_mplane(file, priv, f);
return vidioc_try_fmt_vid_cap_mplane(file, priv, f);
}
static int vivid_s_fmt_cap_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
struct video_device *vdev = video_devdata(file);
if (vdev->vfl_type == VFL_TYPE_TOUCH)
return vivid_g_fmt_tch_mplane(file, priv, f);
return vidioc_s_fmt_vid_cap_mplane(file, priv, f);
}
static bool vivid_is_in_use(struct video_device *vdev)
{
unsigned long flags;
@ -605,9 +635,9 @@ static const struct v4l2_ioctl_ops vivid_ioctl_ops = {
.vidioc_g_fmt_vid_cap = vivid_g_fmt_cap,
.vidioc_try_fmt_vid_cap = vivid_try_fmt_cap,
.vidioc_s_fmt_vid_cap = vivid_s_fmt_cap,
.vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_vid_cap_mplane,
.vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap_mplane,
.vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt_vid_cap_mplane,
.vidioc_g_fmt_vid_cap_mplane = vivid_g_fmt_cap_mplane,
.vidioc_try_fmt_vid_cap_mplane = vivid_try_fmt_cap_mplane,
.vidioc_s_fmt_vid_cap_mplane = vivid_s_fmt_cap_mplane,
.vidioc_enum_fmt_vid_out = vivid_enum_fmt_vid,
.vidioc_g_fmt_vid_out = vidioc_g_fmt_vid_out,
@ -1077,9 +1107,12 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
dev->meta_out_caps |= V4L2_CAP_AUDIO;
}
/* set up the capabilities of the touch capture device */
if (dev->has_touch_cap)
dev->touch_cap_caps = V4L2_CAP_TOUCH | V4L2_CAP_VIDEO_CAPTURE |
V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
if (dev->has_touch_cap) {
dev->touch_cap_caps = V4L2_CAP_TOUCH | V4L2_CAP_STREAMING |
V4L2_CAP_READWRITE;
dev->touch_cap_caps |= dev->multiplanar ?
V4L2_CAP_VIDEO_CAPTURE_MPLANE : V4L2_CAP_VIDEO_CAPTURE;
}
ret = -ENOMEM;
/* initialize the test pattern generator */

View File

@ -5,6 +5,7 @@
#include "vivid-core.h"
#include "vivid-kthread-touch.h"
#include "vivid-vid-common.h"
#include "vivid-touch-cap.h"
static int touch_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
@ -129,16 +130,33 @@ int vivid_g_fmt_tch(struct file *file, void *priv, struct v4l2_format *f)
{
struct vivid_dev *dev = video_drvdata(file);
if (dev->multiplanar)
return -ENOTTY;
f->fmt.pix = dev->tch_format;
return 0;
}
int vivid_g_fmt_tch_mplane(struct file *file, void *priv, struct v4l2_format *f)
{
struct vivid_dev *dev = video_drvdata(file);
struct v4l2_format sp_fmt;
if (!dev->multiplanar)
return -ENOTTY;
sp_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
sp_fmt.fmt.pix = dev->tch_format;
fmt_sp2mp(&sp_fmt, f);
return 0;
}
int vivid_g_parm_tch(struct file *file, void *priv,
struct v4l2_streamparm *parm)
{
struct vivid_dev *dev = video_drvdata(file);
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
if (parm->type != (dev->multiplanar ?
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE :
V4L2_BUF_TYPE_VIDEO_CAPTURE))
return -EINVAL;
parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;

View File

@ -28,6 +28,7 @@ extern const struct vb2_ops vivid_touch_cap_qops;
int vivid_enum_fmt_tch(struct file *file, void *priv, struct v4l2_fmtdesc *f);
int vivid_g_fmt_tch(struct file *file, void *priv, struct v4l2_format *f);
int vivid_g_fmt_tch_mplane(struct file *file, void *priv, struct v4l2_format *f);
int vivid_enum_input_tch(struct file *file, void *priv, struct v4l2_input *inp);
int vivid_g_input_tch(struct file *file, void *priv, unsigned int *i);
int vivid_s_input_tch(struct file *file, void *priv, unsigned int i);

View File

@ -813,7 +813,7 @@ void fmt_sp2mp(const struct v4l2_format *sp_fmt, struct v4l2_format *mp_fmt)
memset(mp->reserved, 0, sizeof(mp->reserved));
mp_fmt->type = is_out ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE :
V4L2_CAP_VIDEO_CAPTURE_MPLANE;
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
mp->width = pix->width;
mp->height = pix->height;
mp->pixelformat = pix->pixelformat;