drm: simple_kms_helper: add support for bridges
authorAndrea Merello <andrea.merello@gmail.com>
Thu, 25 Aug 2016 09:04:34 +0000 (11:04 +0200)
committerArchit Taneja <architt@codeaurora.org>
Mon, 29 Aug 2016 03:45:37 +0000 (09:15 +0530)
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 <daniel@ffwll.ch>
Signed-off-by: Andrea Merello <andrea.merello@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Noralf Trønnes <noralf@tronnes.org>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1472115874-6219-3-git-send-email-andrea.merello@gmail.com
drivers/gpu/drm/drm_simple_kms_helper.c
include/drm/drm_simple_kms_helper.h

index 3301e4a9f7cda0daaba726c5d138a85b2e93bd83..7b6d26e64977b65473a2348f000a94707db20589 100644 (file)
@@ -139,6 +139,46 @@ static const struct drm_plane_funcs drm_simple_kms_plane_funcs = {
        .atomic_destroy_state   = drm_atomic_helper_plane_destroy_state,
 };
 
+/**
+ * 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 = &pipe->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
index 826946ca2b8265f6ff46465f5bd53e632c4517d9..5d112f75e04c0255e54b9c74ef8093ab46aa03d9 100644 (file)
@@ -91,6 +91,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,