From: Sakari Ailus <sakari.ailus@iki.fi>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, hverkuil@xs4all.nl,
teturtia@gmail.com, dacohen@gmail.com, snjw23@gmail.com,
andriy.shevchenko@linux.intel.com, t.stanislaws@samsung.com,
tuukkat76@gmail.com, k.debski@gmail.com, riverful@gmail.com
Subject: Re: [PATCH 17/23] v4l: Implement v4l2_subdev_link_validate()
Date: Tue, 17 Jan 2012 22:21:39 +0200 [thread overview]
Message-ID: <20120117202139.GF13236@valkosipuli.localdomain> (raw)
In-Reply-To: <201201161544.08756.laurent.pinchart@ideasonboard.com>
Hi Laurent,
Thanks for the review!
On Mon, Jan 16, 2012 at 03:44:08PM +0100, Laurent Pinchart wrote:
> On Wednesday 11 January 2012 22:26:54 Sakari Ailus wrote:
> > v4l2_subdev_link_validate() is the default op for validating a link. In
> > V4L2 subdev context, it is used to call a pad op which performs the proper
> > link check without much extra work.
> >
> > Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
> > ---
> > drivers/media/video/v4l2-subdev.c | 62
> > +++++++++++++++++++++++++++++++++++++ include/media/v4l2-subdev.h |
> > 10 ++++++
> > 2 files changed, 72 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/media/video/v4l2-subdev.c
> > b/drivers/media/video/v4l2-subdev.c index 836270d..4b329a0 100644
> > --- a/drivers/media/video/v4l2-subdev.c
> > +++ b/drivers/media/video/v4l2-subdev.c
> > @@ -367,6 +367,68 @@ const struct v4l2_file_operations v4l2_subdev_fops = {
> > .poll = subdev_poll,
> > };
> >
> > +#ifdef CONFIG_MEDIA_CONTROLLER
> > +int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
> > + struct media_link *link,
> > + struct v4l2_subdev_format *source_fmt,
> > + struct v4l2_subdev_format *sink_fmt)
> > +{
> > + if (source_fmt->format.width != sink_fmt->format.width
> > + || source_fmt->format.height != sink_fmt->format.height
> > + || source_fmt->format.code != sink_fmt->format.code)
> > + return -EINVAL;
> > +
> > + return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate_default);
>
> What about calling this function directly from v4l2_subdev_link_validate() if
> the pad::link_validate operation is NULL ? That wouldn't require changing all
> subdev drivers to explicitly use the default implementation.
I can do that. I still want to keep the function available for those that
want to call it explicitly to perform the above check.
> > +
> > +static struct v4l2_subdev_format
> > +*v4l2_subdev_link_validate_get_format(struct media_pad *pad,
> > + struct v4l2_subdev_format *fmt)
> > +{
> > + int rval;
> > +
> > + switch (media_entity_type(pad->entity)) {
> > + case MEDIA_ENT_T_V4L2_SUBDEV:
> > + fmt->which = V4L2_SUBDEV_FORMAT_ACTIVE;
> > + fmt->pad = pad->index;
> > + rval = v4l2_subdev_call(media_entity_to_v4l2_subdev(
> > + pad->entity),
> > + pad, get_fmt, NULL, fmt);
> > + if (rval < 0)
> > + return NULL;
> > + return fmt;
> > + case MEDIA_ENT_T_DEVNODE_V4L:
> > + return NULL;
> > + default:
> > + BUG();
>
> Maybe WARN() and return NULL ?
It's a clear driver BUG() if this happens. If you think the correct response
to that is WARN() and return NULL, I can do that.
> > + }
> > +}
> > +
> > +int v4l2_subdev_link_validate(struct media_link *link)
> > +{
> > + struct v4l2_subdev *sink = NULL, *source = NULL;
> > + struct v4l2_subdev_format _sink_fmt, _source_fmt;
> > + struct v4l2_subdev_format *sink_fmt, *source_fmt;
> > +
> > + source_fmt = v4l2_subdev_link_validate_get_format(
> > + link->source, &_source_fmt);
> > + sink_fmt = v4l2_subdev_link_validate_get_format(
> > + link->sink, &_sink_fmt);
> > +
> > + if (source_fmt)
> > + source = media_entity_to_v4l2_subdev(link->source->entity);
> > + if (sink_fmt)
> > + sink = media_entity_to_v4l2_subdev(link->sink->entity);
> > +
> > + if (source_fmt && sink_fmt)
> > + return v4l2_subdev_call(sink, pad, link_validate, link,
> > + source_fmt, sink_fmt);
>
> This looks overly complex. Why don't you return 0 if one of the two entities
> is of a type different than MEDIA_ENT_T_V4L2_SUBDEV, then retrieve the formats
> for the two entities and return 0 if one of the two operation fails, and
> finally call pad::link_validate ?
Now that you mention that, I agree. :-) I'll fix it.
Regards,
--
Sakari Ailus
e-mail: sakari.ailus@iki.fi jabber/XMPP/Gmail: sailus@retiisi.org.uk
next prev parent reply other threads:[~2012-01-17 20:21 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-11 21:26 [PATCH 0/23] V4L2 subdev and sensor control changes, SMIA++ driver and N9 camera board code Sakari Ailus
2012-01-11 21:26 ` [PATCH 01/23] v4l: Introduce integer menu controls Sakari Ailus
2012-01-16 13:49 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 02/23] v4l: Document " Sakari Ailus
2012-01-16 13:50 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 03/23] vivi: Add an integer menu test control Sakari Ailus
2012-01-16 13:52 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 04/23] v4l: VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_G_SELECTION IOCTLs Sakari Ailus
2012-01-11 21:26 ` [PATCH 05/23] v4l: Support s_crop and g_crop through s/g_selection Sakari Ailus
2012-01-16 13:54 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 06/23] v4l: Add selections documentation Sakari Ailus
2012-01-11 21:26 ` [PATCH 07/23] v4l: Mark VIDIOC_SUBDEV_G_CROP and VIDIOC_SUBDEV_S_CROP obsolete Sakari Ailus
2012-01-11 21:26 ` [PATCH 08/23] v4l: Image source control class Sakari Ailus
2012-01-16 13:57 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 09/23] v4l: Add DPCM compressed formats Sakari Ailus
2012-01-16 14:01 ` Laurent Pinchart
2012-01-17 19:35 ` Sakari Ailus
2012-01-11 21:26 ` [PATCH 10/23] omap3isp: Support additional in-memory compressed bayer formats Sakari Ailus
2012-01-16 14:05 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 11/23] omap3isp: Move definitions required by board code under include/media Sakari Ailus
2012-01-16 14:05 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 12/23] omap3: add definition for CONTROL_CAMERA_PHY_CTRL Sakari Ailus
2012-01-16 14:06 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 13/23] omap3isp: Add lane configuration to platform data Sakari Ailus
2012-01-16 14:08 ` Laurent Pinchart
2012-01-17 19:27 ` Sakari Ailus
2012-01-11 21:26 ` [PATCH 14/23] omap3isp: Configure CSI-2 phy based on " Sakari Ailus
2012-01-16 14:22 ` Laurent Pinchart
2012-01-17 19:45 ` Sakari Ailus
2012-01-19 16:16 ` Laurent Pinchart
2012-01-19 19:11 ` Sakari Ailus
2012-01-11 21:26 ` [PATCH 15/23] omap3isp: Do not attempt to walk the pipeline outside the ISP Sakari Ailus
2012-01-11 21:26 ` [PATCH 16/23] media: Add link_validate op to check links to the sink pad Sakari Ailus
2012-01-16 14:35 ` Laurent Pinchart
2012-01-17 20:09 ` Sakari Ailus
2012-01-19 16:20 ` Laurent Pinchart
2012-01-19 19:13 ` Sakari Ailus
2012-01-11 21:26 ` [PATCH 17/23] v4l: Implement v4l2_subdev_link_validate() Sakari Ailus
2012-01-16 14:44 ` Laurent Pinchart
2012-01-17 20:21 ` Sakari Ailus [this message]
2012-01-19 16:21 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 18/23] omap3isp: Assume media_entity_pipeline_start may fail Sakari Ailus
2012-01-16 14:46 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 19/23] omap3isp: Default error handling for ccp2, csi2, preview and resizer Sakari Ailus
2012-01-16 14:50 ` Laurent Pinchart
2012-01-17 20:22 ` Sakari Ailus
2012-01-11 21:26 ` [PATCH 20/23] omap3isp: Move CCDC link validation to ispccdc.c Sakari Ailus
2012-01-11 21:26 ` [PATCH 21/23] omap3isp: Move resizer link validation to ispresizer.c Sakari Ailus
2012-01-11 21:26 ` [PATCH 22/23] smiapp: Add driver Sakari Ailus
2012-01-11 21:27 ` [PATCH 23/23] rm680: Add camera init Sakari Ailus
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=20120117202139.GF13236@valkosipuli.localdomain \
--to=sakari.ailus@iki.fi \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dacohen@gmail.com \
--cc=hverkuil@xs4all.nl \
--cc=k.debski@gmail.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=riverful@gmail.com \
--cc=snjw23@gmail.com \
--cc=t.stanislaws@samsung.com \
--cc=teturtia@gmail.com \
--cc=tuukkat76@gmail.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