[PATCH v3 3/3] drm: simple_kms_helper: add support for bridges

2016-08-29 Thread Archit Taneja


On 08/25/2016 02:34 PM, Andrea Merello wrote:
> Introduce drm_simple_display_pipe_attach_bridge() and
> drm_simple_display_pipe_detach_bridge() in order to make it possible to use
> drm encoders with the simple display pipes managed by simple_kms_helpers
>
> Suggested-by: Daniel Vetter 
> Signed-off-by: Andrea Merello 
> Reviewed-by: Daniel Vetter 


Pushed to drm-misc.

Thanks,
Archit

> Cc: Noralf Trønnes 
> Cc: Daniel Vetter 
> Cc: David Airlie 
> ---
>   drivers/gpu/drm/drm_simple_kms_helper.c | 40 
> +
>   include/drm/drm_simple_kms_helper.h |  5 +
>   2 files changed, 45 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c 
> b/drivers/gpu/drm/drm_simple_kms_helper.c
> index 3301e4a..8e9858b 100644
> --- a/drivers/gpu/drm/drm_simple_kms_helper.c
> +++ b/drivers/gpu/drm/drm_simple_kms_helper.c
> @@ -140,6 +140,46 @@ static const struct drm_plane_funcs 
> drm_simple_kms_plane_funcs = {
>   };
>
>   /**
> + * drm_simple_display_pipe_attach_bridge - Attach a bridge to the display 
> pipe
> + * @pipe: simple display pipe object
> + * @bridge: bridge to attach
> + *
> + * Makes it possible to still use the drm_simple_display_pipe helpers when
> + * a DRM bridge has to be used.
> + *
> + * Note that you probably want to initialize the pipe by passing a NULL
> + * connector to drm_simple_display_pipe_init().
> + *
> + * Returns:
> + * Zero on success, negative error code on failure.
> + */
> +int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe 
> *pipe,
> + struct drm_bridge *bridge)
> +{
> + bridge->encoder = >encoder;
> + pipe->encoder.bridge = bridge;
> + return drm_bridge_attach(pipe->encoder.dev, bridge);
> +}
> +EXPORT_SYMBOL(drm_simple_display_pipe_attach_bridge);
> +
> +/**
> + * drm_simple_display_pipe_detach_bridge - Detach the bridge from the 
> display pipe
> + * @pipe: simple display pipe object
> + *
> + * Detaches the drm bridge previously attached with
> + * drm_simple_display_pipe_attach_bridge()
> + */
> +void drm_simple_display_pipe_detach_bridge(struct drm_simple_display_pipe 
> *pipe)
> +{
> + if (WARN_ON(!pipe->encoder.bridge))
> + return;
> +
> + drm_bridge_detach(pipe->encoder.bridge);
> + pipe->encoder.bridge = NULL;
> +}
> +EXPORT_SYMBOL(drm_simple_display_pipe_detach_bridge);
> +
> +/**
>* drm_simple_display_pipe_init - Initialize a simple display pipeline
>* @dev: DRM device
>* @pipe: simple display pipe object to initialize
> diff --git a/include/drm/drm_simple_kms_helper.h 
> b/include/drm/drm_simple_kms_helper.h
> index 2690397..5245d1f 100644
> --- a/include/drm/drm_simple_kms_helper.h
> +++ b/include/drm/drm_simple_kms_helper.h
> @@ -85,6 +85,11 @@ struct drm_simple_display_pipe {
>   const struct drm_simple_display_pipe_funcs *funcs;
>   };
>
> +int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe 
> *pipe,
> + struct drm_bridge *bridge);
> +
> +void drm_simple_display_pipe_detach_bridge(struct drm_simple_display_pipe 
> *pipe);
> +
>   int drm_simple_display_pipe_init(struct drm_device *dev,
>   struct drm_simple_display_pipe *pipe,
>   const struct drm_simple_display_pipe_funcs *funcs,
>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


[PATCH v3 3/3] drm: simple_kms_helper: add support for bridges

2016-08-25 Thread Andrea Merello
Introduce drm_simple_display_pipe_attach_bridge() and
drm_simple_display_pipe_detach_bridge() in order to make it possible to use
drm encoders with the simple display pipes managed by simple_kms_helpers

Suggested-by: Daniel Vetter 
Signed-off-by: Andrea Merello 
Reviewed-by: Daniel Vetter 
Cc: Noralf Trønnes 
Cc: Daniel Vetter 
Cc: David Airlie 
---
 drivers/gpu/drm/drm_simple_kms_helper.c | 40 +
 include/drm/drm_simple_kms_helper.h |  5 +
 2 files changed, 45 insertions(+)

diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c 
b/drivers/gpu/drm/drm_simple_kms_helper.c
index 3301e4a..8e9858b 100644
--- a/drivers/gpu/drm/drm_simple_kms_helper.c
+++ b/drivers/gpu/drm/drm_simple_kms_helper.c
@@ -140,6 +140,46 @@ static const struct drm_plane_funcs 
drm_simple_kms_plane_funcs = {
 };

 /**
+ * drm_simple_display_pipe_attach_bridge - Attach a bridge to the display pipe
+ * @pipe: simple display pipe object
+ * @bridge: bridge to attach
+ *
+ * Makes it possible to still use the drm_simple_display_pipe helpers when
+ * a DRM bridge has to be used.
+ *
+ * Note that you probably want to initialize the pipe by passing a NULL
+ * connector to drm_simple_display_pipe_init().
+ *
+ * Returns:
+ * Zero on success, negative error code on failure.
+ */
+int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe,
+   struct drm_bridge *bridge)
+{
+   bridge->encoder = >encoder;
+   pipe->encoder.bridge = bridge;
+   return drm_bridge_attach(pipe->encoder.dev, bridge);
+}
+EXPORT_SYMBOL(drm_simple_display_pipe_attach_bridge);
+
+/**
+ * drm_simple_display_pipe_detach_bridge - Detach the bridge from the display 
pipe
+ * @pipe: simple display pipe object
+ *
+ * Detaches the drm bridge previously attached with
+ * drm_simple_display_pipe_attach_bridge()
+ */
+void drm_simple_display_pipe_detach_bridge(struct drm_simple_display_pipe 
*pipe)
+{
+   if (WARN_ON(!pipe->encoder.bridge))
+   return;
+
+   drm_bridge_detach(pipe->encoder.bridge);
+   pipe->encoder.bridge = NULL;
+}
+EXPORT_SYMBOL(drm_simple_display_pipe_detach_bridge);
+
+/**
  * drm_simple_display_pipe_init - Initialize a simple display pipeline
  * @dev: DRM device
  * @pipe: simple display pipe object to initialize
diff --git a/include/drm/drm_simple_kms_helper.h 
b/include/drm/drm_simple_kms_helper.h
index 2690397..5245d1f 100644
--- a/include/drm/drm_simple_kms_helper.h
+++ b/include/drm/drm_simple_kms_helper.h
@@ -85,6 +85,11 @@ struct drm_simple_display_pipe {
const struct drm_simple_display_pipe_funcs *funcs;
 };

+int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe,
+   struct drm_bridge *bridge);
+
+void drm_simple_display_pipe_detach_bridge(struct drm_simple_display_pipe 
*pipe);
+
 int drm_simple_display_pipe_init(struct drm_device *dev,
struct drm_simple_display_pipe *pipe,
const struct drm_simple_display_pipe_funcs *funcs,
-- 
2.7.4