All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: dri-devel@lists.freedesktop.org,
	Russell King <rmk+kernel@arm.linux.org.uk>,
	Grant Likely <grant.likely@linaro.org>,
	Andy Yan <andy.yan@rock-chips.com>,
	kernel@pengutronix.de
Subject: Re: [PATCH v3 1/3] drm: add drm_of_encoder_active_endpoint helpers
Date: Thu, 27 Aug 2015 16:22:46 +0200	[thread overview]
Message-ID: <20150827142246.GC1367@phenom.ffwll.local> (raw)
In-Reply-To: <1440672968-29422-2-git-send-email-p.zabel@pengutronix.de>

On Thu, Aug 27, 2015 at 12:56:05PM +0200, Philipp Zabel wrote:
> This patch adds a helper to parse the encoder endpoint connected to the
> encoder's crtc and two helpers to return its id and port id.
> 
> This can be used to determine input mux setting from endpoint or port ids.
> 
> Suggested-by: Daniel Kurtz <djkurtz@chromium.org>
> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/gpu/drm/drm_of.c | 34 ++++++++++++++++++++++++++++++++++
>  include/drm/drm_of.h     | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 67 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index be38840..0c9714cd 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -61,3 +61,37 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  	return possible_crtcs;
>  }
>  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
> +
> +/*
> + * drm_of_encoder_active_endpoint - return the active encoder endpoint
> + * @node: device tree node containing encoder input ports
> + * @encoder: drm_encoder
> + *
> + * Given an encoder device node and a drm_encoder with a connected crtc,
> + * parse the encoder endpoint connecting to the crtc port.
> + */

Can you please write proper kerneldoc for this plus pull drm_of.c into the
docbook template? Some overview comments in a DOC: section (maybe even
with code snippets/examples, we can do those now in 4.3) would be even
better.
-Daniel

> +int drm_of_encoder_active_endpoint(struct device_node *node,
> +				   struct drm_encoder *encoder,
> +				   struct of_endpoint *endpoint)
> +{
> +	struct device_node *ep;
> +	struct drm_crtc *crtc = encoder->crtc;
> +	struct device_node *port;
> +	int ret;
> +
> +	if (!node || !crtc)
> +		return -EINVAL;
> +
> +	for_each_endpoint_of_node(node, ep) {
> +		port = of_graph_get_remote_port(ep);
> +		of_node_put(port);
> +		if (port == crtc->port) {
> +			ret = of_graph_parse_endpoint(ep, endpoint);
> +			of_node_put(ep);
> +			return ret;
> +		}
> +	}
> +
> +	return -EINVAL;
> +}
> +EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint);
> diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
> index 2441f71..efd3b44 100644
> --- a/include/drm/drm_of.h
> +++ b/include/drm/drm_of.h
> @@ -1,18 +1,51 @@
>  #ifndef __DRM_OF_H__
>  #define __DRM_OF_H__
>  
> +#include <linux/of_graph.h>
> +
>  struct drm_device;
> +struct drm_encoder;
>  struct device_node;
>  
>  #ifdef CONFIG_OF
>  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  					   struct device_node *port);
> +extern int drm_of_encoder_active_endpoint(struct device_node *node,
> +					  struct drm_encoder *encoder,
> +					  struct of_endpoint *endpoint);
>  #else
>  static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  						  struct device_node *port)
>  {
>  	return 0;
>  }
> +
> +static inline int drm_of_encoder_active_endpoint(struct device_node *node,
> +						 struct drm_encoder *encoder,
> +						 struct of_endpoint *endpoint)
> +{
> +	return -EINVAL;
> +}
>  #endif
>  
> +static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
> +						    struct drm_encoder *encoder)
> +{
> +	struct of_endpoint endpoint;
> +	int ret = drm_of_encoder_active_endpoint(node, encoder,
> +						 &endpoint);
> +
> +	return ret ?: endpoint.id;
> +}
> +
> +static inline int drm_of_encoder_active_port_id(struct device_node *node,
> +						struct drm_encoder *encoder)
> +{
> +	struct of_endpoint endpoint;
> +	int ret = drm_of_encoder_active_endpoint(node, encoder,
> +						 &endpoint);
> +
> +	return ret ?: endpoint.port;
> +}
> +
>  #endif /* __DRM_OF_H__ */
> -- 
> 2.5.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-08-27 14:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-27 10:56 [PATCH v3 0/3] drm_of_encoder_active_endpoint helpers Philipp Zabel
2015-08-27 10:56 ` [PATCH v3 1/3] drm: add " Philipp Zabel
2015-08-27 14:22   ` Daniel Vetter [this message]
2015-08-28 13:31     ` Philipp Zabel
2015-08-27 10:56 ` [PATCH v3 2/3] drm/imx: remove imx_drm_encoder_get_mux_id Philipp Zabel
2015-08-27 10:56 ` [PATCH v3 3/3] drm/rockchip: remove rockchip_drm_encoder_get_mux_id Philipp Zabel
2015-08-27 11:26   ` Heiko Stuebner
2015-08-28  1:17     ` Yakir Yang
2015-08-28  3:18       ` Yakir Yang
2015-08-28 13:27         ` Philipp Zabel
2015-08-28  1:56   ` Mark yao

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=20150827142246.GC1367@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=andy.yan@rock-chips.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=grant.likely@linaro.org \
    --cc=kernel@pengutronix.de \
    --cc=p.zabel@pengutronix.de \
    --cc=rmk+kernel@arm.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.