media: vivid: support multiplanar touch devices
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Sun, 15 Dec 2019 11:09:32 +0000 (12:09 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 16 Dec 2019 12:24:16 +0000 (13:24 +0100)
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>
drivers/media/platform/vivid/vivid-core.c
drivers/media/platform/vivid/vivid-touch-cap.c
drivers/media/platform/vivid/vivid-touch-cap.h
drivers/media/platform/vivid/vivid-vid-common.c

index 9eef606541a205a5064d1b5096863af8686be853..15091cbf6de704bc21a5a096a04b1073248a27a4 100644 (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 */
index 070df227e29b95e4f285dd79505833bfaef0b7f2..ebb00b128030c9d88c4f4296c014a0766ac369e4 100644 (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;
index 761050b652eb36afdc4115d7f51b53b7cc68de21..07e514046ae80f1347aec00f1da1cdaa7acc4721 100644 (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);
index 8665dfd25eb47556eff0b8692d364ad33d6c0184..76b0be670ebb34b2c02d5a09beedf4a5581dda19 100644 (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;