Skip to contentSkip to conversation

drm/crtc_helper: Add drm_crtc_helper_disable_planes()

RFC PATCH In review Jyri Sarha 2 participants 2 messages Nov 20, 2015

Subsystems (2)
lore
Share & tools
lore

Jyri Sarha

author
#0 lore raw

RFC PATCH 1/1 drm/crtc_helper: Add drm_crtc_helper_disable_planes()

Add drm_crtc_helper_disable_planes() for disabling all planes associated with the given CRTC and having disable callback. This can be used for instance in CRTC helper disable callback.

---
So it appears that this is the only missing piece for disabling and enabling planes with their associated CRTCs for the times when the CRTCs are blanked or otherwise unused.

 drivers/gpu/drm/drm_crtc_helper.c | 26 ++++++++++++++++++++++++++
 include/drm/drm_crtc_helper.h     |  1 +
 2 files changed, 27 insertions(+)
drivers/gpu/drm/drm_crtc_helper.c +26 -0
index ef53475..33dddd5 100644
@@ -410,6 +410,32 @@ done:
 }
 EXPORT_SYMBOL(drm_crtc_helper_set_mode);
 
+/**
+ * drm_crtc_helper_disable_planes - helper to disable CRTC's planes
+ * @crtc: CRTC
+ *
+ * Disables all planes associated with the given CRTC and having
+ * disable callback. This can be used for instance in CRTC helper
+ * disable callback.
+ */
+void drm_crtc_helper_disable_planes(struct drm_crtc *crtc)
+{
+	struct drm_plane *plane;
+	int i;
+
+	drm_for_each_plane(plane, crtc->dev) {
+		const struct drm_plane_helper_funcs *plane_funcs =
+			plane->helper_private;
+
+		if (plane->state->crtc != crtc || !plane_funcs)
+			continue;
+
+		if (plane_funcs->atomic_disable)
+			plane_funcs->atomic_disable(plane, NULL);
+	}
+}
+EXPORT_SYMBOL(drm_crtc_helper_disable_planes);
+
 static void
 drm_crtc_helper_disable(struct drm_crtc *crtc)
 {
include/drm/drm_crtc_helper.h +1 -0
index 3febb4b..d47051f 100644
@@ -189,6 +189,7 @@ extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 				     struct drm_display_mode *mode,
 				     int x, int y,
 				     struct drm_framebuffer *old_fb);
+extern void drm_crtc_helper_disable_planes(struct drm_crtc *crtc);
 extern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
 extern bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
 
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 19 lines · Jyri Sarha

Add drm_crtc_helper_disable_planes() for disabling all planes associated with the given CRTC and having disable callback. This can be used for instance in CRTC helper disable callback.

---
So it appears that this is the only missing piece for disabling and enabling planes with their associated CRTCs for the times when the CRTCs are blanked or otherwise unused.

 drivers/gpu/drm/drm_crtc_helper.c | 26 ++++++++++++++++++++++++++
 include/drm/drm_crtc_helper.h     |  1 +
 2 files changed, 27 insertions(+)
drivers/gpu/drm/drm_crtc_helper.c +0 -0
index ef53475..33dddd5 100644

drivers/gpu/drm/drm_crtc_helper.c done: · line 418

Quoted 9 lines
drivers/gpu/drm/drm_crtc_helper.c +6 -0
@@ -410,6 +410,32 @@ done:
 }
 EXPORT_SYMBOL(drm_crtc_helper_set_mode);
 
+/**
+ * drm_crtc_helper_disable_planes - helper to disable CRTC's planes
+ * @crtc: CRTC
+ *
+ * Disables all planes associated with the given CRTC and having
+ * disable callback. This can be used for instance in CRTC helper

s/in CRTC/in the CRTC/

drivers/gpu/drm/drm_crtc_helper.c done: · line 419

Quoted 1 line
drivers/gpu/drm/drm_crtc_helper.c +1 -0
+ * disable callback.

"... to disable all planes before shutting down the display pipeline." just to clarify usage.

One open is whether we should call the crtc-level atomic_begin/flush functions. I think adding that would be good, to avoid tearing while disabling planes. If drivers need different behaviour we can always add a knob to select the right one (i.e. with or without atomic_begin/flush).

drivers/gpu/drm/drm_crtc_helper.c done: · line 421

Quoted 2 lines
drivers/gpu/drm/drm_crtc_helper.c +2 -0
+ */
+void drm_crtc_helper_disable_planes(struct drm_crtc *crtc)

This function only makes sense for atomic drivers, so should be in drm_atomic_helper.c. drm_crtc_helper.c is the legacy helper library for non-atomic drivers.

Also needs a different name then, for example drm_atomic_helper_disable_planes_on_crtc, for consistency with drm_atomic_helper_commit_planes_on_crtc

drivers/gpu/drm/drm_crtc_helper.c done: · line 434

Quoted 13 lines
drivers/gpu/drm/drm_crtc_helper.c +13 -0
+{
+	struct drm_plane *plane;
+	int i;
+
+	drm_for_each_plane(plane, crtc->dev) {
+		const struct drm_plane_helper_funcs *plane_funcs =
+			plane->helper_private;
+
+		if (plane->state->crtc != crtc || !plane_funcs)
+			continue;
+
+		if (plane_funcs->atomic_disable)
+			plane_funcs->atomic_disable(plane, NULL);

Imo WARN_ON(!plane_funcs->atomic_disable); since calling this function without having disable hooks really doesn't make sense. Please also update the kerneldoc with something like "It is a bug to call this function without having implemented the ->atomic_disable() plane hook."

Cheers, Daniel

Quoted 22 lines
drivers/gpu/drm/drm_crtc_helper.c +4 -0
+	}
+}
+EXPORT_SYMBOL(drm_crtc_helper_disable_planes);
+
 static void
 drm_crtc_helper_disable(struct drm_crtc *crtc)
 {
include/drm/drm_crtc_helper.h +1 -0
index 3febb4b..d47051f 100644
@@ -189,6 +189,7 @@ extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 				     struct drm_display_mode *mode,
 				     int x, int y,
 				     struct drm_framebuffer *old_fb);
+extern void drm_crtc_helper_disable_planes(struct drm_crtc *crtc);
 extern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
 extern bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
 
Signature · 1 line
1.9.1
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel