Linux Media Controller development
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Tomasz Figa <tfiga@chromium.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Sakari Ailus <sakari.ailus@iki.fi>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	kernel@collabora.com, Hirokazu Honda <hiroh@chromium.org>,
	Nicolas Dufresne <nicolas@ndufresne.ca>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	Maxime Jourdan <mjourdan@baylibre.com>
Subject: Re: [PATCH] media: v4l2: Fix the _MPLANE format check in v4l_enum_fmt()
Date: Thu, 6 Jun 2019 09:09:16 +0200	[thread overview]
Message-ID: <20190606090916.33c78976@collabora.com> (raw)
In-Reply-To: <20190606085159.3454aecb@collabora.com>

On Thu, 6 Jun 2019 08:51:59 +0200
Boris Brezillon <boris.brezillon@collabora.com> wrote:

> On Thu, 6 Jun 2019 12:53:57 +0900
> Tomasz Figa <tfiga@chromium.org> wrote:
> 
> > On Thu, Jun 6, 2019 at 1:46 AM Boris Brezillon
> > <boris.brezillon@collabora.com> wrote:  
> > >
> > > CAP_M2M_MPLANE means the device supports _MPLANE formats for both
> > > capture and output. Adjust the check to avoid EINVAL errors on
> > > such devices.
> > >
> > > Fixes: 366c719d6479 ("media: v4l2: Get rid of ->vidioc_enum_fmt_vid_{cap,out}_mplane")
> > > Reported-by: Maxime Jourdan <mjourdan@baylibre.com>
> > > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > > ---
> > >  drivers/media/v4l2-core/v4l2-ioctl.c | 9 +++++++--
> > >  1 file changed, 7 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> > > index b4c73e8f23c5..ace9b9761bed 100644
> > > --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> > > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> > > @@ -1385,6 +1385,7 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
> > >         struct video_device *vdev = video_devdata(file);
> > >         struct v4l2_fmtdesc *p = arg;
> > >         int ret = check_fmt(file, p->type);
> > > +       u32 cap_mask;
> > >
> > >         if (ret)
> > >                 return ret;
> > > @@ -1393,7 +1394,9 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
> > >         switch (p->type) {
> > >         case V4L2_BUF_TYPE_VIDEO_CAPTURE:
> > >         case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
> > > -               if (!!(vdev->device_caps & V4L2_CAP_VIDEO_CAPTURE_MPLANE) !=
> > > +               cap_mask = V4L2_CAP_VIDEO_CAPTURE_MPLANE |
> > > +                          V4L2_CAP_VIDEO_M2M_MPLANE;
> > > +               if (!!(vdev->device_caps & cap_mask) !=    
> > 
> > Shouldn't devices that report V4L2_CAP_VIDEO_M2M_MPLANE have also
> > V4L2_CAP_VIDEO_CAPTURE_MPLANE and V4L2_CAP_VIDEO_OUTPUT_MPLANE
> > reported anyway?  
> 
> That's the other option, force drivers that set
> V4L2_CAP_VIDEO_M2M_MPLANE to also set
> V4L2_CAP_VIDEO_{CAPTURE,OUTPUT}_MPLANE (or we can let the core do it).

That would basically look like this. Hans, let me know if you want me
to send a new version with the below diff.

--->8---
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 29946a2b2752..9cb782c62f69 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -933,6 +933,14 @@ int __video_register_device(struct video_device *vdev,
        }
 #endif
 
+       /*
+        * Adjust ->device_caps: CAP_M2M_MPLANE implies CAP_CAPTURE_MPLANES and
+        * CAP_OUTPUT_MLANES.
+        */
+       if (vdev->device_caps & V4L2_CAP_VIDEO_M2M_MPLANE)
+               vdev->device_caps |= V4L2_CAP_VIDEO_CAPTURE_MPLANE |
+                                    V4L2_CAP_VIDEO_OUTPUT_MPLANE;
+
        /* Pick a device node number */
        mutex_lock(&videodev_lock);
        nr = devnode_find(vdev, nr == -1 ? 0 : nr, minor_cnt);

  parent reply	other threads:[~2019-06-06  7:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-05 16:46 [PATCH] media: v4l2: Fix the _MPLANE format check in v4l_enum_fmt() Boris Brezillon
2019-06-06  3:53 ` Tomasz Figa
2019-06-06  6:51   ` Boris Brezillon
2019-06-06  7:09     ` Hans Verkuil
2019-06-06  8:01       ` Tomasz Figa
2019-06-06  7:09     ` Boris Brezillon [this message]
2019-06-06  7:10       ` Hans Verkuil
2019-06-06 13:58     ` Nicolas Dufresne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190606090916.33c78976@collabora.com \
    --to=boris.brezillon@collabora.com \
    --cc=hans.verkuil@cisco.com \
    --cc=hiroh@chromium.org \
    --cc=kernel@collabora.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mjourdan@baylibre.com \
    --cc=nicolas@ndufresne.ca \
    --cc=s.nawrocki@samsung.com \
    --cc=sakari.ailus@iki.fi \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox