Skip to content

Commit

Permalink
media: vivid: support multiplanar touch devices
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Dec 16, 2019
1 parent 095c21d commit 0885acd
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
45 changes: 39 additions & 6 deletions drivers/media/platform/vivid/vivid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 */
Expand Down
20 changes: 19 additions & 1 deletion drivers/media/platform/vivid/vivid-touch-cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions drivers/media/platform/vivid/vivid-touch-cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/vivid/vivid-vid-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0885acd

Please sign in to comment.