[PATCH 1/3] drm: add drm_of_encoder_active_endpoint helpers

Philipp Zabel p.zabel at pengutronix.de
Tue Feb 24 03:13:02 PST 2015


Am Dienstag, den 24.02.2015, 12:02 +0100 schrieb Philipp Zabel:
> 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 at chromium.org>
> Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>
> ---
>  drivers/gpu/drm/drm_of.c | 34 ++++++++++++++++++++++++++++++++++
>  include/drm/drm_of.h     | 32 ++++++++++++++++++++++++++++++++
>  2 files changed, 66 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index aaa1307..a526301 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.
> + */
> +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..8a95126 100644
> --- a/include/drm/drm_of.h
> +++ b/include/drm/drm_of.h

TODO: test before posting, not after.

@@ -4,6 +4,7 @@
 #include <linux/of_graph.h>
 
 struct drm_device;
+struct drm_encoder;
 struct device_node;
 
 #ifdef CONFIG_OF

> @@ -1,18 +1,50 @@
>  #ifndef __DRM_OF_H__
>  #define __DRM_OF_H__
>  
> +#include <linux/of_graph.h>
> +
>  struct drm_device;
>  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__ */

regards
Philipp



More information about the dri-devel mailing list