浏览代码

drm: omapdrm: Rework CRTC enable/disable for atomic updates

When using atomic updates the CRTC .enable() and .disable() helper
operations are preferred over the (then legacy) .prepare() and .commit()
operations. Implement .enable() and rework .disable() to not depend on
DPMS, easing DPMS removal later on.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Laurent Pinchart 10 年之前
父节点
当前提交
f1d57fb517
共有 1 个文件被更改,包括 59 次插入24 次删除
  1. 59 24
      drivers/gpu/drm/omapdrm/omap_crtc.c

+ 59 - 24
drivers/gpu/drm/omapdrm/omap_crtc.c

@@ -509,50 +509,70 @@ static void omap_crtc_destroy(struct drm_crtc *crtc)
 	kfree(omap_crtc);
 	kfree(omap_crtc);
 }
 }
 
 
-static void omap_crtc_dpms(struct drm_crtc *crtc, int mode)
+static bool omap_crtc_mode_fixup(struct drm_crtc *crtc,
+		const struct drm_display_mode *mode,
+		struct drm_display_mode *adjusted_mode)
+{
+	return true;
+}
+
+static void omap_crtc_enable(struct drm_crtc *crtc)
 {
 {
 	struct omap_drm_private *priv = crtc->dev->dev_private;
 	struct omap_drm_private *priv = crtc->dev->dev_private;
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
-	bool enable = (mode == DRM_MODE_DPMS_ON);
-	int i;
+	unsigned int i;
 
 
-	DBG("%s: %d", omap_crtc->name, mode);
+	DBG("%s", omap_crtc->name);
 
 
-	if (enable == omap_crtc->enabled)
+	if (omap_crtc->enabled)
 		return;
 		return;
 
 
-	if (!enable) {
-		omap_crtc_wait_page_flip(crtc);
-		dispc_runtime_get();
-		drm_crtc_vblank_off(crtc);
-		dispc_runtime_put();
-	}
-
-	/* Enable/disable all planes associated with the CRTC. */
+	/* Enable all planes associated with the CRTC. */
 	for (i = 0; i < priv->num_planes; i++) {
 	for (i = 0; i < priv->num_planes; i++) {
 		struct drm_plane *plane = priv->planes[i];
 		struct drm_plane *plane = priv->planes[i];
 
 
 		if (plane->crtc == crtc)
 		if (plane->crtc == crtc)
-			WARN_ON(omap_plane_set_enable(plane, enable));
+			WARN_ON(omap_plane_set_enable(plane, true));
 	}
 	}
 
 
-	omap_crtc->enabled = enable;
+	omap_crtc->enabled = true;
 
 
 	omap_crtc_setup(crtc);
 	omap_crtc_setup(crtc);
 	omap_crtc_flush(crtc);
 	omap_crtc_flush(crtc);
 
 
-	if (enable) {
-		dispc_runtime_get();
-		drm_crtc_vblank_on(crtc);
-		dispc_runtime_put();
-	}
+	dispc_runtime_get();
+	drm_crtc_vblank_on(crtc);
+	dispc_runtime_put();
 }
 }
 
 
-static bool omap_crtc_mode_fixup(struct drm_crtc *crtc,
-		const struct drm_display_mode *mode,
-		struct drm_display_mode *adjusted_mode)
+static void omap_crtc_disable(struct drm_crtc *crtc)
 {
 {
-	return true;
+	struct omap_drm_private *priv = crtc->dev->dev_private;
+	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+	unsigned int i;
+
+	DBG("%s", omap_crtc->name);
+
+	if (!omap_crtc->enabled)
+		return;
+
+	omap_crtc_wait_page_flip(crtc);
+	dispc_runtime_get();
+	drm_crtc_vblank_off(crtc);
+	dispc_runtime_put();
+
+	/* Disable all planes associated with the CRTC. */
+	for (i = 0; i < priv->num_planes; i++) {
+		struct drm_plane *plane = priv->planes[i];
+
+		if (plane->crtc == crtc)
+			WARN_ON(omap_plane_set_enable(plane, false));
+	}
+
+	omap_crtc->enabled = false;
+
+	omap_crtc_setup(crtc);
+	omap_crtc_flush(crtc);
 }
 }
 
 
 static int omap_crtc_mode_set(struct drm_crtc *crtc,
 static int omap_crtc_mode_set(struct drm_crtc *crtc,
@@ -587,6 +607,19 @@ static int omap_crtc_mode_set(struct drm_crtc *crtc,
 				   x, y, mode->hdisplay, mode->vdisplay);
 				   x, y, mode->hdisplay, mode->vdisplay);
 }
 }
 
 
+static void omap_crtc_dpms(struct drm_crtc *crtc, int mode)
+{
+	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+	bool enable = (mode == DRM_MODE_DPMS_ON);
+
+	DBG("%s: %d", omap_crtc->name, mode);
+
+	if (enable)
+		omap_crtc_enable(crtc);
+	else
+		omap_crtc_disable(crtc);
+}
+
 static void omap_crtc_prepare(struct drm_crtc *crtc)
 static void omap_crtc_prepare(struct drm_crtc *crtc)
 {
 {
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
@@ -751,6 +784,8 @@ static const struct drm_crtc_helper_funcs omap_crtc_helper_funcs = {
 	.prepare = omap_crtc_prepare,
 	.prepare = omap_crtc_prepare,
 	.commit = omap_crtc_commit,
 	.commit = omap_crtc_commit,
 	.mode_set_base = omap_crtc_mode_set_base,
 	.mode_set_base = omap_crtc_mode_set_base,
+	.disable = omap_crtc_disable,
+	.enable = omap_crtc_enable,
 };
 };
 
 
 /* -----------------------------------------------------------------------------
 /* -----------------------------------------------------------------------------