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 16/23] media: Add link_validate op to check links to the sink pad
Date: Tue, 17 Jan 2012 22:09:58 +0200 [thread overview]
Message-ID: <20120117200958.GE13236@valkosipuli.localdomain> (raw)
In-Reply-To: <201201161535.08191.laurent.pinchart@ideasonboard.com>
Hi Laurent,
Thanks for the review.
On Mon, Jan 16, 2012 at 03:35:07PM +0100, Laurent Pinchart wrote:
> On Wednesday 11 January 2012 22:26:53 Sakari Ailus wrote:
> > Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
> > ---
> > drivers/media/media-entity.c | 73
> > ++++++++++++++++++++++++++++++++++++++++- include/media/media-entity.h |
> > 5 ++-
> > 2 files changed, 74 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
> > index 056138f..62ef4b8 100644
> > --- a/drivers/media/media-entity.c
> > +++ b/drivers/media/media-entity.c
> > @@ -196,6 +196,35 @@ media_entity_graph_walk_next(struct media_entity_graph
> > *graph) }
> > EXPORT_SYMBOL_GPL(media_entity_graph_walk_next);
> >
> > +struct media_link_enum {
> > + int i;
> > + struct media_entity *entity;
> > + unsigned long flags, mask;
> > +};
> > +
> > +static struct media_link
> > +*media_link_walk_next(struct media_link_enum *link_enum)
> > +{
> > + do {
> > + link_enum->i++;
> > + if (link_enum->i >= link_enum->entity->num_links)
> > + return NULL;
> > + } while ((link_enum->entity->links[link_enum->i].flags
> > + & link_enum->mask) != link_enum->flags);
> > +
> > + return &link_enum->entity->links[link_enum->i];
> > +}
> > +
> > +static void media_link_walk_start(struct media_link_enum *link_enum,
> > + struct media_entity *entity,
> > + unsigned long flags, unsigned long mask)
> > +{
> > + link_enum->i = -1;
> > + link_enum->entity = entity;
> > + link_enum->flags = flags;
> > + link_enum->mask = mask;
> > +}
>
> Do we really need a generic link walking code for a single user ? Merging this
> in the function below would result in much simpler code.
It's a single funcition but it's being used from two locations in it. I
would keep it as-is, since performing the same in the function itself would
much complicate it.
> > +
> > /*
> > --------------------------------------------------------------------------
> > --- * Pipeline management
> > */
> > @@ -214,23 +243,63 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next);
> > * pipeline pointer must be identical for all nested calls to
> > * media_entity_pipeline_start().
> > */
> > -void media_entity_pipeline_start(struct media_entity *entity,
> > - struct media_pipeline *pipe)
> > +__must_check int media_entity_pipeline_start(struct media_entity *entity,
> > + struct media_pipeline *pipe)
> > {
> > struct media_device *mdev = entity->parent;
> > struct media_entity_graph graph;
> > + struct media_entity *tmp = entity;
> > + int ret = 0;
> >
> > mutex_lock(&mdev->graph_mutex);
> >
> > media_entity_graph_walk_start(&graph, entity);
> >
> > while ((entity = media_entity_graph_walk_next(&graph))) {
> > + struct media_entity_graph tmp_graph;
> > + struct media_link_enum link_enum;
> > + struct media_link *link;
> > +
> > entity->stream_count++;
> > WARN_ON(entity->pipe && entity->pipe != pipe);
> > entity->pipe = pipe;
> > +
> > + if (!entity->ops || !entity->ops->link_validate)
> > + continue;
> > +
> > + media_link_walk_start(&link_enum, entity,
> > + MEDIA_LNK_FL_ENABLED,
> > + MEDIA_LNK_FL_ENABLED);
> > +
> > + while ((link = media_link_walk_next(&link_enum))) {
> > + if (link->sink->entity != entity)
> > + continue;
> > +
> > + ret = entity->ops->link_validate(link);
> > + if (ret < 0 && ret != -ENOIOCTLCMD)
> > + break;
> > + }
> > + if (!ret || ret == -ENOIOCTLCMD)
> > + continue;
>
> What about a goto error instead ? That would keep the error code out of the
> loop.
Fixed.
> > +
> > + /*
> > + * Link validation on graph failed. We revert what we
> > + * did and return the error.
> > + */
> > + media_entity_graph_walk_start(&tmp_graph, tmp);
>
> I've never liked tmp as a variable name. As the graph variable isn't used
> anymore from this point on, you can reuse it. tmp can then be renamed to
> something more descriptive.
I re-use graph, and tmp is called entity_err now.
> > + do {
> > + tmp = media_entity_graph_walk_next(&tmp_graph);
> > + tmp->stream_count--;
> > + if (entity->stream_count == 0)
> > + entity->pipe = NULL;
> > + } while (tmp != entity);
> > +
> > + break;
> > }
> >
> > mutex_unlock(&mdev->graph_mutex);
> > +
> > + return ret == 0 || ret == -ENOIOCTLCMD ? 0 : ret;
> > }
> > EXPORT_SYMBOL_GPL(media_entity_pipeline_start);
> >
> > diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> > index cd8bca6..f7ba80a 100644
> > --- a/include/media/media-entity.h
> > +++ b/include/media/media-entity.h
> > @@ -46,6 +46,7 @@ struct media_entity_operations {
> > int (*link_setup)(struct media_entity *entity,
> > const struct media_pad *local,
> > const struct media_pad *remote, u32 flags);
> > + int (*link_validate)(struct media_link *link);
>
> What about documenting the operation in Documentation/media-framework.txt ?
Yup.
---
Link validation
---------------
Link validation is performed from media_entity_pipeline_start() for any
entity which has sink pads in the pipeline. The
media_entity::link_validate() callback is used for that purpose. In
link_validate() callback, the entity driver should check that the properties
of the source pad of the connected entity and its own sink pad match.
---
> > };
> >
> > struct media_entity {
> > @@ -140,8 +141,8 @@ void media_entity_graph_walk_start(struct
> > media_entity_graph *graph, struct media_entity *entity);
> > struct media_entity *
> > media_entity_graph_walk_next(struct media_entity_graph *graph);
> > -void media_entity_pipeline_start(struct media_entity *entity,
> > - struct media_pipeline *pipe);
> > +__must_check int media_entity_pipeline_start(struct media_entity *entity,
> > + struct media_pipeline *pipe);
>
> As well as keeping the media_entity_pipeline_start() documentation up-to-date
> in the same file :-)
Added a note it may return an error.
Cheers,
--
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:10 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 [this message]
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
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=20120117200958.GE13236@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