From: Philipp Zabel <p.zabel@pengutronix.de>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Grant Likely <grant.likely@linaro.org>,
Mauro Carvalho Chehab <m.chehab@samsung.com>,
Russell King - ARM Linux <linux@arm.linux.org.uk>,
Rob Herring <robh+dt@kernel.org>,
Sylwester Nawrocki <s.nawrocki@samsung.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
Kyungmin Park <kyungmin.park@samsung.com>,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v5 5/7] [media] of: move common endpoint parsing to drivers/of
Date: Tue, 04 Mar 2014 12:36:29 +0100 [thread overview]
Message-ID: <1393932989.3917.62.camel@paszta.hi.pengutronix.de> (raw)
In-Reply-To: <531595AB.4000001@ti.com>
Hi Tomi,
Am Dienstag, den 04.03.2014, 10:58 +0200 schrieb Tomi Valkeinen:
[...]
> > +int of_graph_parse_endpoint(const struct device_node *node,
> > + struct of_endpoint *endpoint)
> > +{
> > + struct device_node *port_node = of_get_parent(node);
>
> Can port_node be NULL? Probably only if something is quite wrong, but
> maybe it's safer to return error in that case.
both of_property_read_u32 and of_node_put can handle port_node == NULL.
I'll add a WARN_ONCE here as for of_graph_get_next_endpoint and continue
on.
> > + memset(endpoint, 0, sizeof(*endpoint));
> > +
> > + endpoint->local_node = node;
> > + /*
> > + * It doesn't matter whether the two calls below succeed.
> > + * If they don't then the default value 0 is used.
> > + */
> > + of_property_read_u32(port_node, "reg", &endpoint->port);
> > + of_property_read_u32(node, "reg", &endpoint->id);
>
> If the endpoint does not have 'port' as parent (i.e. the shortened
> format), the above will return the 'reg' of the device node (with
> 'device node' I mean the main node, with 'compatible' property).
Yes, a check for the port_node name is in order.
> And generally speaking, if struct of_endpoint is needed, maybe it would
> be better to return the struct of_endpoint when iterating the ports and
> endpoints. That way there's no need to do parsing "afterwards", trying
> to figure out if there's a parent port node, but the information is
> already at hand.
I'd like to keep the iteration separate from parsing so we can
eventually introduce a for_each_endpoint_of_node helper macro around
of_graph_get_next_endpoint.
[...]
> A few thoughts about the iteration, and the API in general.
>
> In the omapdss version I separated iterating ports and endpoints, for
> the two reasons:
>
> 1) I think there are cases where you may want to have properties in the
> port node, for things that are common for all the port's endpoints.
>
> 2) if there are multiple ports, I think the driver code is cleaner if
> you first take the port, decide what port that is and maybe call a
> sub-function, and then iterate the endpoints for that port only.
It depends a bit on whether you are actually iterating over individual
ports, or if you are just walking the whole endpoint graph to find
remote devices that have to be added to the component master's waiting
list, for example.
> Both of those are possible with the API in the series, but not very cleanly.
>
> Also, if you just want to iterate the endpoints, it's easy to implement
> a helper using the separate port and endpoint iterations.
I started out to move an existing (albeit lightly used) API to a common
place so others can use it and improve upon it, too. I'm happy to pile
on fixes directly in this series, but could we separate the improvement
step from the move, for the bigger modifications?
I had no immediate use for the port iteration, so I have taken no steps
to add a function for this. I see no problem to add this later when
somebody needs it, or even rewrite of_graph_get_next_endpoint to use it
if it is feasible. Iterating over endpoints on a given port needs no
helper, as you can just use for_each_child_of_node.
> Then, about the get_remote functions: I think there should be only one
> function for that purpose, one that returns the device node that
> contains the remote endpoint.
>
> My reasoning is that the ports and endpoints, and their contents, should
> be private to the device. So the only use to get the remote is to get
> the actual device, to see if it's been probed, or maybe get some video
> API for that device.
of_graph_get_remote_port currently is used in the exynos4-is/fimc-is.c
v4l2 driver to get the mipi-csi channel id from the remote port, and
I've started using it in imx-drm-core.c for two cases:
- given an endpoint on the encoder, find the remote port connected to
it, get the associated drm_crtc, to obtain its the drm_crtc_mask
for encoder->possible_crtcs.
- given an encoder and a connected drm_crtc, walk all endpoints to find
the remote port associated with the drm_crtc, and then use the local
endpoint parent port to determine multiplexer settings.
> If the driver model used has some kind of master-driver, which goes
> through all the display entities, I think the above is still valid. When
> the master-driver follows the remote-link, it still needs to first get
> the main device node, as the ports and endpoints make no sense without
> the context of the main device node.
I'm not sure about this. I might just need the remote port node
associated with a remote drm_crtc or drm_encoder structure to find out
which local endpoint I should look at to retrieve configuration.
regards
Philipp
next prev parent reply other threads:[~2014-03-04 11:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-27 17:35 [PATCH v5 0/7] Move device tree graph parsing helpers to drivers/of Philipp Zabel
2014-02-27 17:35 ` [PATCH v5 1/7] [media] of: move graph helpers from drivers/media/v4l2-core " Philipp Zabel
[not found] ` <1393522540-22887-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2014-02-27 17:35 ` [PATCH v5 2/7] Documentation: of: Document graph bindings Philipp Zabel
2014-02-28 21:08 ` Sylwester Nawrocki
2014-03-04 10:16 ` Philipp Zabel
2014-02-27 17:35 ` [PATCH v5 3/7] of: Warn if of_graph_get_next_endpoint is called with the root node Philipp Zabel
2014-02-28 21:09 ` Sylwester Nawrocki
2014-03-04 10:12 ` Philipp Zabel
2014-02-27 17:35 ` [PATCH v5 4/7] of: Reduce indentation in of_graph_get_next_endpoint Philipp Zabel
2014-02-27 17:35 ` [PATCH v5 5/7] [media] of: move common endpoint parsing to drivers/of Philipp Zabel
2014-02-28 21:09 ` Sylwester Nawrocki
2014-03-04 10:09 ` Philipp Zabel
[not found] ` <1393522540-22887-6-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2014-03-04 8:58 ` Tomi Valkeinen
2014-03-04 11:36 ` Philipp Zabel [this message]
2014-03-04 12:21 ` Tomi Valkeinen
2014-03-04 15:47 ` Philipp Zabel
[not found] ` <1393948056.3917.120.camel-+qGW7pzALmz7o/J7KWpOmN53zsg1cpMQ@public.gmane.org>
2014-03-05 10:05 ` Tomi Valkeinen
[not found] ` <5315C535.2070303-l0cyMroinI0@public.gmane.org>
2014-03-06 23:59 ` Laurent Pinchart
2014-03-07 0:06 ` Eric Boxer
2014-02-27 17:35 ` [PATCH v5 6/7] of: Implement simplified graph binding for single port devices Philipp Zabel
2014-03-04 9:06 ` Tomi Valkeinen
2014-03-04 10:04 ` Philipp Zabel
2014-02-27 17:35 ` [PATCH v5 7/7] of: Document " Philipp Zabel
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=1393932989.3917.62.camel@paszta.hi.pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=devicetree@vger.kernel.org \
--cc=g.liakhovetski@gmx.de \
--cc=grant.likely@linaro.org \
--cc=kyungmin.park@samsung.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=m.chehab@samsung.com \
--cc=robh+dt@kernel.org \
--cc=s.nawrocki@samsung.com \
--cc=tomi.valkeinen@ti.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).