Commit 0885acd7 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

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: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 095c21d3
...@@ -509,6 +509,36 @@ static int vivid_s_fmt_cap(struct file *file, void *priv, ...@@ -509,6 +509,36 @@ static int vivid_s_fmt_cap(struct file *file, void *priv,
return vidioc_s_fmt_vid_cap(file, priv, f); 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) static bool vivid_is_in_use(struct video_device *vdev)
{ {
unsigned long flags; unsigned long flags;
...@@ -605,9 +635,9 @@ static const struct v4l2_ioctl_ops vivid_ioctl_ops = { ...@@ -605,9 +635,9 @@ static const struct v4l2_ioctl_ops vivid_ioctl_ops = {
.vidioc_g_fmt_vid_cap = vivid_g_fmt_cap, .vidioc_g_fmt_vid_cap = vivid_g_fmt_cap,
.vidioc_try_fmt_vid_cap = vivid_try_fmt_cap, .vidioc_try_fmt_vid_cap = vivid_try_fmt_cap,
.vidioc_s_fmt_vid_cap = vivid_s_fmt_cap, .vidioc_s_fmt_vid_cap = vivid_s_fmt_cap,
.vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_vid_cap_mplane, .vidioc_g_fmt_vid_cap_mplane = vivid_g_fmt_cap_mplane,
.vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap_mplane, .vidioc_try_fmt_vid_cap_mplane = vivid_try_fmt_cap_mplane,
.vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt_vid_cap_mplane, .vidioc_s_fmt_vid_cap_mplane = vivid_s_fmt_cap_mplane,
.vidioc_enum_fmt_vid_out = vivid_enum_fmt_vid, .vidioc_enum_fmt_vid_out = vivid_enum_fmt_vid,
.vidioc_g_fmt_vid_out = vidioc_g_fmt_vid_out, .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) ...@@ -1077,9 +1107,12 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
dev->meta_out_caps |= V4L2_CAP_AUDIO; dev->meta_out_caps |= V4L2_CAP_AUDIO;
} }
/* set up the capabilities of the touch capture device */ /* set up the capabilities of the touch capture device */
if (dev->has_touch_cap) if (dev->has_touch_cap) {
dev->touch_cap_caps = V4L2_CAP_TOUCH | V4L2_CAP_VIDEO_CAPTURE | dev->touch_cap_caps = V4L2_CAP_TOUCH | V4L2_CAP_STREAMING |
V4L2_CAP_STREAMING | V4L2_CAP_READWRITE; V4L2_CAP_READWRITE;
dev->touch_cap_caps |= dev->multiplanar ?
V4L2_CAP_VIDEO_CAPTURE_MPLANE : V4L2_CAP_VIDEO_CAPTURE;
}
ret = -ENOMEM; ret = -ENOMEM;
/* initialize the test pattern generator */ /* initialize the test pattern generator */
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "vivid-core.h" #include "vivid-core.h"
#include "vivid-kthread-touch.h" #include "vivid-kthread-touch.h"
#include "vivid-vid-common.h"
#include "vivid-touch-cap.h" #include "vivid-touch-cap.h"
static int touch_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, 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) ...@@ -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); struct vivid_dev *dev = video_drvdata(file);
if (dev->multiplanar)
return -ENOTTY;
f->fmt.pix = dev->tch_format; f->fmt.pix = dev->tch_format;
return 0; 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, int vivid_g_parm_tch(struct file *file, void *priv,
struct v4l2_streamparm *parm) struct v4l2_streamparm *parm)
{ {
struct vivid_dev *dev = video_drvdata(file); 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; return -EINVAL;
parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
......
...@@ -28,6 +28,7 @@ extern const struct vb2_ops vivid_touch_cap_qops; ...@@ -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_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(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_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_g_input_tch(struct file *file, void *priv, unsigned int *i);
int vivid_s_input_tch(struct file *file, void *priv, unsigned int i); int vivid_s_input_tch(struct file *file, void *priv, unsigned int i);
......
...@@ -813,7 +813,7 @@ void fmt_sp2mp(const struct v4l2_format *sp_fmt, struct v4l2_format *mp_fmt) ...@@ -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)); memset(mp->reserved, 0, sizeof(mp->reserved));
mp_fmt->type = is_out ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : 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->width = pix->width;
mp->height = pix->height; mp->height = pix->height;
mp->pixelformat = pix->pixelformat; mp->pixelformat = pix->pixelformat;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment