linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-omap@vger.kernel.org, linux-fbdev@vger.kernel.org,
	devicetree@vger.kernel.org, Archit Taneja <archit@ti.com>,
	Darren Etheridge <detheridge@ti.com>,
	Tony Lindgren <tony@atomide.com>
Subject: Re: [PATCH 10/26] OMAPDSS: add of helpers
Date: Wed, 11 Dec 2013 23:19:56 +0000	[thread overview]
Message-ID: <4533892.HJaRcDt4Q8@avalon> (raw)
In-Reply-To: <1386160133-24026-11-git-send-email-tomi.valkeinen@ti.com>

Hi Tomi,

On Wednesday 04 December 2013 14:28:37 Tomi Valkeinen wrote:
> Add helpers to get ports and endpoints from DT data.
> 
> While all the functions in dss-of.c might be useful for panel drivers if
> they need to parse full port/endpoint data, at the moment we only need a
> few of them outside dss-of.c, so only those functions are exported.

I totally understand that it was easier to add this code to the OMAP DSS 
driver, but I believe we should refactor the existing drivers/media/v4l2-
core/v4l2-of.c and move it to a non V4L2-specific location (what about 
drivers/media ?) sooner rather than later. That's on my to-do list for 
Saturday.

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/video/omap2/dss/Makefile |   2 +-
>  drivers/video/omap2/dss/dss-of.c | 160 ++++++++++++++++++++++++++++++++++++
>  include/video/omapdss.h          |   6 ++
>  3 files changed, 167 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/video/omap2/dss/dss-of.c
> 
> diff --git a/drivers/video/omap2/dss/Makefile
> b/drivers/video/omap2/dss/Makefile index d3aa91bdd6a8..8aec8bda27cc 100644
> --- a/drivers/video/omap2/dss/Makefile
> +++ b/drivers/video/omap2/dss/Makefile
> @@ -1,7 +1,7 @@
>  obj-$(CONFIG_OMAP2_DSS) += omapdss.o
>  # Core DSS files
>  omapdss-y := core.o dss.o dss_features.o dispc.o dispc_coefs.o display.o \
> -	output.o
> +	output.o dss-of.o
>  # DSS compat layer files
>  omapdss-y += manager.o manager-sysfs.o overlay.o overlay-sysfs.o apply.o \
>  	dispc-compat.o display-sysfs.o
> diff --git a/drivers/video/omap2/dss/dss-of.c
> b/drivers/video/omap2/dss/dss-of.c new file mode 100644
> index 000000000000..9aa61d4bdb3d
> --- /dev/null
> +++ b/drivers/video/omap2/dss/dss-of.c
> @@ -0,0 +1,160 @@
> +/*
> + * Copyright (C) 2013 Texas Instruments
> + * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published
> by + * the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful, but
> WITHOUT + * ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> General Public License for + * more details.
> + */
> +
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/seq_file.h>
> +
> +#include <video/omapdss.h>
> +
> +#include "dss.h"
> +#include "dss_features.h"
> +
> +static struct device_node *
> +omapdss_of_get_next_port(const struct device_node *parent,
> +			 struct device_node *prev)
> +{
> +	struct device_node *port = NULL;
> +
> +	if (!parent)
> +		return NULL;
> +
> +	if (!prev) {
> +		struct device_node *ports;
> +		/*
> +		 * It's the first call, we have to find a port subnode
> +		 * within this node or within an optional 'ports' node.
> +		 */
> +		ports = of_get_child_by_name(parent, "ports");
> +		if (ports)
> +			parent = ports;
> +
> +		port = of_get_child_by_name(parent, "port");
> +
> +		/* release the 'ports' node */
> +		of_node_put(ports);
> +	} else {
> +		struct device_node *ports;
> +
> +		ports = of_get_parent(prev);
> +		if (!ports)
> +			return NULL;
> +
> +		do {
> +			port = of_get_next_child(ports, prev);
> +			if (!port) {
> +				of_node_put(ports);
> +				return NULL;
> +			}
> +			prev = port;
> +		} while (of_node_cmp(port->name, "port") != 0);
> +	}
> +
> +	return port;
> +}
> +
> +static struct device_node *
> +omapdss_of_get_next_endpoint(const struct device_node *parent,
> +			     struct device_node *prev)
> +{
> +	struct device_node *ep = NULL;
> +
> +	if (!parent)
> +		return NULL;
> +
> +	do {
> +		ep = of_get_next_child(parent, prev);
> +		if (!ep)
> +			return NULL;
> +		prev = ep;
> +	} while (of_node_cmp(ep->name, "endpoint") != 0);
> +
> +	return ep;
> +}
> +
> +static struct device_node *
> +omapdss_of_get_remote_device_node(const struct device_node *node)
> +{
> +	struct device_node *np;
> +	int i;
> +
> +	np = of_parse_phandle(node, "remote-endpoint", 0);
> +
> +	if (!np)
> +		return NULL;
> +
> +	np = of_get_next_parent(np);
> +
> +	for (i = 0; i < 3 && np; ++i) {
> +		struct property *prop;
> +
> +		prop = of_find_property(np, "compatible", NULL);
> +
> +		if (prop)
> +			return np;
> +
> +		np = of_get_next_parent(np);
> +	}
> +
> +	return NULL;
> +}
> +
> +struct device_node *
> +omapdss_of_get_first_endpoint(const struct device_node *parent)
> +{
> +	struct device_node *port;
> +	struct device_node *ep;
> +
> +	port = omapdss_of_get_next_port(parent, NULL);
> +	if (port) {
> +		ep = omapdss_of_get_next_endpoint(port, NULL);
> +		of_node_put(port);
> +	} else {
> +		ep = omapdss_of_get_next_endpoint(parent, NULL);
> +	}
> +
> +	return ep;
> +}
> +EXPORT_SYMBOL_GPL(omapdss_of_get_first_endpoint);
> +
> +struct omap_dss_device *
> +omapdss_of_find_source_for_first_ep(struct device_node *node)
> +{
> +	struct device_node *ep;
> +	struct device_node *src_node;
> +	struct omap_dss_device *src;
> +
> +	ep = omapdss_of_get_first_endpoint(node);
> +	if (!ep)
> +		return ERR_PTR(-EINVAL);
> +
> +	src_node = omapdss_of_get_remote_device_node(ep);
> +
> +	of_node_put(ep);
> +
> +	if (!src_node)
> +		return ERR_PTR(-EINVAL);
> +
> +	src = omap_dss_find_output_by_node(src_node);
> +
> +	of_node_put(src_node);
> +
> +	if (!src)
> +		return ERR_PTR(-EPROBE_DEFER);
> +
> +	return src;
> +}
> +EXPORT_SYMBOL_GPL(omapdss_of_find_source_for_first_ep);
> diff --git a/include/video/omapdss.h b/include/video/omapdss.h
> index 3d7c51a6f9ff..c510591df1b8 100644
> --- a/include/video/omapdss.h
> +++ b/include/video/omapdss.h
> @@ -1019,4 +1019,10 @@ static inline bool omapdss_device_is_enabled(struct
> omap_dss_device *dssdev) return dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
>  }
> 
> +struct device_node *
> +omapdss_of_get_first_endpoint(const struct device_node *parent);
> +
> +struct omap_dss_device *
> +omapdss_of_find_source_for_first_ep(struct device_node *node);
> +
>  #endif
-- 
Regards,

Laurent Pinchart


  reply	other threads:[~2013-12-11 23:19 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-04 12:28 [PATCH 00/26] OMAPDSS: DT support (Christmas edition) Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 01/26] OMAPDSS: rename display-sysfs 'name' entry Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 02/26] OMAPDSS: DSI: fix fifosize Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 03/26] ARM: OMAP: remove DSS DT hack Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 04/26] OMAPDSS: remove DT hacks for regulators Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 05/26] ARM: OMAP2+: add omapdss_init_of() Tomi Valkeinen
2013-12-11 23:10   ` Laurent Pinchart
2013-12-12  7:30     ` Tomi Valkeinen
2013-12-13  8:44       ` Archit Taneja
2013-12-13  8:40         ` Tomi Valkeinen
2013-12-13 17:07         ` Tony Lindgren
2013-12-04 12:28 ` [PATCH 06/26] OMAPDSS: if dssdev->name==NULL, use alias Tomi Valkeinen
2013-12-11 23:13   ` Laurent Pinchart
2013-12-11 23:56     ` Laurent Pinchart
2013-12-12  7:41       ` Tomi Valkeinen
     [not found]         ` <52A968BD.20304-l0cyMroinI0@public.gmane.org>
2013-12-12 10:05           ` Sebastian Reichel
2013-12-12 13:22             ` Laurent Pinchart
2013-12-12 14:13             ` Tomi Valkeinen
2013-12-12 14:15               ` Laurent Pinchart
2013-12-12 14:19                 ` Tomi Valkeinen
2013-12-12 17:31                   ` Sebastian Reichel
2013-12-13 12:01               ` Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 07/26] OMAPDSS: get dssdev->alias from DT alias Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 08/26] OMAPFB: clean up default display search Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 09/26] OMAPFB: search for default display with DT alias Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 10/26] OMAPDSS: add of helpers Tomi Valkeinen
2013-12-11 23:19   ` Laurent Pinchart [this message]
2013-12-12  7:48     ` Tomi Valkeinen
2013-12-13  2:37       ` Laurent Pinchart
2013-12-04 12:28 ` [PATCH 11/26] OMAPDSS: Add DT support to DSS, DISPC, DPI, HDMI, VENC Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 12/26] OMAPDSS: Add DT support to DSI Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 13/26] ARM: omap3.dtsi: add omapdss information Tomi Valkeinen
2013-12-05 17:05   ` Tony Lindgren
2013-12-09 12:45     ` Tomi Valkeinen
2013-12-09 18:04       ` Tony Lindgren
2013-12-11 23:44       ` Laurent Pinchart
2013-12-12  8:38         ` Tomi Valkeinen
2013-12-12 21:59           ` Tony Lindgren
2013-12-13  3:27             ` Laurent Pinchart
2013-12-13 10:18               ` Tomi Valkeinen
     [not found]                 ` <52AADEF3.9040808-l0cyMroinI0@public.gmane.org>
2013-12-13 17:10                   ` Tony Lindgren
2013-12-13  3:24           ` Laurent Pinchart
2013-12-13  9:29             ` Tomi Valkeinen
2013-12-16 10:49             ` Tomi Valkeinen
     [not found]               ` <52AEDA9F.2020609-l0cyMroinI0@public.gmane.org>
2013-12-16 13:55                 ` Laurent Pinchart
2013-12-04 12:28 ` [PATCH 14/26] ARM: omap4.dtsi: " Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 15/26] ARM: omap4-panda.dts: add display information Tomi Valkeinen
2013-12-06  8:57   ` Javier Martinez Canillas
2013-12-09 12:56     ` Tomi Valkeinen
2013-12-09 15:09       ` Javier Martinez Canillas
2013-12-09 15:30         ` Tomi Valkeinen
2013-12-09 16:53           ` Javier Martinez Canillas
2013-12-10 10:56             ` Enric Balletbo Serra
2013-12-10 12:10               ` Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 16/26] ARM: omap4-sdp.dts: " Tomi Valkeinen
2013-12-13  9:39   ` Archit Taneja
2013-12-13  9:39     ` Tomi Valkeinen
2013-12-13  9:58       ` Archit Taneja
2013-12-13 10:15         ` Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 17/26] ARM: omap3-tobi.dts: add lcd (TEST) Tomi Valkeinen
2013-12-06 10:18   ` Florian Vaussard
2013-12-10 12:18     ` Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 18/26] ARM: omap3-beagle.dts: add display information Tomi Valkeinen
2013-12-06  8:41   ` Javier Martinez Canillas
2013-12-09 12:06     ` Tomi Valkeinen
2013-12-09 12:16       ` Javier Martinez Canillas
2013-12-04 12:28 ` [PATCH 19/26] ARM: omap3-beagle-xm.dts: " Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 20/26] OMAPDSS: panel-dsi-cm: Add DT support Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 21/26] OMAPDSS: encoder-tfp410: " Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 22/26] OMAPDSS: connector-dvi: " Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 23/26] OMAPDSS: encoder-tpd12s015: " Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 24/26] OMAPDSS: hdmi-connector: " Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 25/26] OMAPDSS: panel-dpi: " Tomi Valkeinen
2013-12-04 12:28 ` [PATCH 26/26] OMAPDSS: connector-analog-tv: " Tomi Valkeinen
     [not found] ` <1386160133-24026-1-git-send-email-tomi.valkeinen-l0cyMroinI0@public.gmane.org>
2013-12-04 16:01   ` [PATCH 00/26] OMAPDSS: DT support (Christmas edition) Sebastian Reichel
2013-12-05  9:41     ` Tomi Valkeinen
2013-12-07  3:48 ` Javier Martinez Canillas
2013-12-07  4:28   ` Javier Martinez Canillas
2013-12-09 12:01     ` Tomi Valkeinen
2013-12-09 12:23       ` Javier Martinez Canillas
2013-12-12  0:39 ` Laurent Pinchart
2013-12-12  8:54   ` Tomi Valkeinen
2013-12-13  3:45     ` Laurent Pinchart
2013-12-13  8:16       ` Geert Uytterhoeven
2013-12-13 10:05       ` Tomi Valkeinen
2013-12-13 14:37         ` Laurent Pinchart
2013-12-13 15:47           ` Tomi Valkeinen
2013-12-13 17:22             ` Tony Lindgren
2013-12-14  7:34               ` Tomi Valkeinen
2013-12-14 14:09                 ` Tony Lindgren
2013-12-16  7:24                   ` Tomi Valkeinen
2013-12-18  0:30                     ` Tony Lindgren

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=4533892.HJaRcDt4Q8@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=archit@ti.com \
    --cc=detheridge@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=tomi.valkeinen@ti.com \
    --cc=tony@atomide.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).