linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, Tsuchiya Yuto <kitakar@gmail.com>,
	bingbu.cao@intel.com, Yong Zhi <yong.zhi@intel.com>,
	Tianshu Qiu <tian.shu.qiu@intel.com>
Subject: Re: [PATCH 3/3] ipu3-cio2: Only allow setting valid mbus codes
Date: Fri, 9 Oct 2020 12:44:52 +0300	[thread overview]
Message-ID: <20201009094452.GR26842@paasikivi.fi.intel.com> (raw)
In-Reply-To: <20201009004949.GC12857@pendragon.ideasonboard.com>

Hi Laurent,

On Fri, Oct 09, 2020 at 03:49:49AM +0300, Laurent Pinchart wrote:
> Hi Sakari,
> 
> Thank you for the patch.
> 
> On Thu, Oct 08, 2020 at 11:47:47PM +0300, Sakari Ailus wrote:
> > Check the mbus code provided by the user is one of those the driver
> > supports. Ignore the code in set_fmt otherwise.
> 
> You're reading my mind :-)
> 
> The code shouldn't be ignored though, when an unsupported code is set,
> it's best to use a fixed default code instead to make the driver
> behaviour as stateless as possible.

I can change it to that, yes.

> 
> > Fixes: c2a6a07afe4a ("media: intel-ipu3: cio2: add new MIPI-CSI2 driver")
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> >  drivers/media/pci/intel/ipu3/ipu3-cio2.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> > index 9c7b527a8800..2ea6313e00b0 100644
> > --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> > +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> > @@ -1270,10 +1270,17 @@ static int cio2_subdev_set_fmt(struct v4l2_subdev *sd,
> >  	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
> >  		*v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format;
> >  	} else {
> > +		unsigned int i;
> > +
> >  		/* It's the sink, allow changing frame size */
> >  		q->subdev_fmt.width = fmt->format.width;
> >  		q->subdev_fmt.height = fmt->format.height;
> > -		q->subdev_fmt.code = fmt->format.code;
> > +		for (i = 0; i < ARRAY_SIZE(formats); i++) {
> > +			if (formats[i].mbus_code == fmt->format.code) {
> > +				q->subdev_fmt.code = fmt->format.code;
> > +				break;
> > +			}
> > +		}
> >  		fmt->format = q->subdev_fmt;
> 
> This should equally apply to the TRY format, we should accept an
> unsupported code. I'd rework the code as follows:
> 
> 	v4l2_mbus_framefmt *format;
> 
> 	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
> 		format = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
> 	else
> 		format = &q->subdev_fmt;
> 
> (this can be done outside of the mutex-protected section) and then
> operate on format unconditionally.

Agreed.

> Note that we should also allow changing the field and colorspace
> information.

Indeed.

-- 
Sakari Ailus

      reply	other threads:[~2020-10-09  9:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08 20:47 [PATCH 0/3] ipu3-cio2 format fixes Sakari Ailus
2020-10-08 20:47 ` [PATCH 1/3] ipu3-cio2: Return actual subdev format Sakari Ailus
2020-10-09  0:39   ` Laurent Pinchart
2020-10-08 20:47 ` [PATCH 2/3] ipu3-cio2: Serialise access to pad format Sakari Ailus
2020-10-09  0:44   ` Laurent Pinchart
2020-10-09  9:43     ` Sakari Ailus
2020-10-09 10:39       ` Laurent Pinchart
2020-10-09 16:17   ` Andy Shevchenko
2020-10-08 20:47 ` [PATCH 3/3] ipu3-cio2: Only allow setting valid mbus codes Sakari Ailus
2020-10-09  0:49   ` Laurent Pinchart
2020-10-09  9:44     ` Sakari Ailus [this message]

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=20201009094452.GR26842@paasikivi.fi.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=bingbu.cao@intel.com \
    --cc=kitakar@gmail.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=tian.shu.qiu@intel.com \
    --cc=yong.zhi@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).