drm/exynos: add plane enable/disable
authorJoonyoung Shim <jy0922.shim@samsung.com>
Wed, 27 Jun 2012 05:27:09 +0000 (14:27 +0900)
committerInki Dae <inki.dae@samsung.com>
Fri, 27 Jul 2012 02:13:54 +0000 (11:13 +0900)
The plane enable/disable can control only a power of plane, so they will
be helpful to handle planes with dpms.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
drivers/gpu/drm/exynos/exynos_drm_crtc.c
drivers/gpu/drm/exynos/exynos_drm_drv.h
drivers/gpu/drm/exynos/exynos_drm_encoder.c
drivers/gpu/drm/exynos/exynos_drm_encoder.h
drivers/gpu/drm/exynos/exynos_drm_plane.c
drivers/gpu/drm/exynos/exynos_drm_plane.h

index a5c594b3ee57702a94fc24a1618361b465267dce..39eb4f08e4eb3a3b00aa114cd87e33940714fad5 100644 (file)
@@ -71,23 +71,8 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
 
        mutex_lock(&dev->struct_mutex);
 
-       switch (mode) {
-       case DRM_MODE_DPMS_ON:
-               exynos_drm_fn_encoder(crtc, &mode,
-                               exynos_drm_encoder_crtc_dpms);
-               exynos_crtc->dpms = mode;
-               break;
-       case DRM_MODE_DPMS_STANDBY:
-       case DRM_MODE_DPMS_SUSPEND:
-       case DRM_MODE_DPMS_OFF:
-               exynos_drm_fn_encoder(crtc, &mode,
-                               exynos_drm_encoder_crtc_dpms);
-               exynos_crtc->dpms = mode;
-               break;
-       default:
-               DRM_ERROR("unspecified mode %d\n", mode);
-               break;
-       }
+       exynos_drm_fn_encoder(crtc, &mode, exynos_drm_encoder_crtc_dpms);
+       exynos_crtc->dpms = mode;
 
        mutex_unlock(&dev->struct_mutex);
 }
@@ -106,6 +91,7 @@ static void exynos_drm_crtc_commit(struct drm_crtc *crtc)
        DRM_DEBUG_KMS("%s\n", __FILE__);
 
        exynos_plane_commit(exynos_crtc->plane);
+       exynos_plane_dpms(exynos_crtc->plane, DRM_MODE_DPMS_ON);
 }
 
 static bool
index 1bd681c9642ff418528aa3f1262cfa909ae753ec..1c90a9a933c72c0743fd5d4c7df18b428c9e5cbe 100644 (file)
@@ -59,12 +59,14 @@ enum exynos_drm_output_type {
  *
  * @mode_set: copy drm overlay info to hw specific overlay info.
  * @commit: apply hardware specific overlay data to registers.
+ * @enable: enable hardware specific overlay.
  * @disable: disable hardware specific overlay.
  */
 struct exynos_drm_overlay_ops {
        void (*mode_set)(struct device *subdrv_dev,
                         struct exynos_drm_overlay *overlay);
        void (*commit)(struct device *subdrv_dev, int zpos);
+       void (*enable)(struct device *subdrv_dev, int zpos);
        void (*disable)(struct device *subdrv_dev, int zpos);
 };
 
index 5131d5975a4a06c3ccbb952cf4a3239120f7e5a2..2c037cd7d2d44aee526779636d5f8e999c4adf5d 100644 (file)
@@ -392,6 +392,22 @@ void exynos_drm_encoder_plane_commit(struct drm_encoder *encoder, void *data)
                overlay_ops->commit(manager->dev, zpos);
 }
 
+void exynos_drm_encoder_plane_enable(struct drm_encoder *encoder, void *data)
+{
+       struct exynos_drm_manager *manager =
+               to_exynos_encoder(encoder)->manager;
+       struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops;
+       int zpos = DEFAULT_ZPOS;
+
+       DRM_DEBUG_KMS("%s\n", __FILE__);
+
+       if (data)
+               zpos = *(int *)data;
+
+       if (overlay_ops && overlay_ops->enable)
+               overlay_ops->enable(manager->dev, zpos);
+}
+
 void exynos_drm_encoder_plane_disable(struct drm_encoder *encoder, void *data)
 {
        struct exynos_drm_manager *manager =
index 7692ee4a958a2ae996178b1b99fbcdf2fb74e68e..6470d9ddf5a15affa3291673422b72e06b456063 100644 (file)
@@ -44,6 +44,7 @@ void exynos_drm_encoder_crtc_dpms(struct drm_encoder *encoder, void *data);
 void exynos_drm_encoder_crtc_pipe(struct drm_encoder *encoder, void *data);
 void exynos_drm_encoder_plane_mode_set(struct drm_encoder *encoder, void *data);
 void exynos_drm_encoder_plane_commit(struct drm_encoder *encoder, void *data);
+void exynos_drm_encoder_plane_enable(struct drm_encoder *encoder, void *data);
 void exynos_drm_encoder_plane_disable(struct drm_encoder *encoder, void *data);
 
 #endif
index f018c9d32639a7a23b171459245536052a08db6f..b89829e5043a59a67152c5cafc241265f0183f12 100644 (file)
@@ -107,8 +107,32 @@ void exynos_plane_commit(struct drm_plane *plane)
 
        exynos_drm_fn_encoder(plane->crtc, &overlay->zpos,
                        exynos_drm_encoder_plane_commit);
+}
+
+void exynos_plane_dpms(struct drm_plane *plane, int mode)
+{
+       struct exynos_plane *exynos_plane = to_exynos_plane(plane);
+       struct exynos_drm_overlay *overlay = &exynos_plane->overlay;
 
-       exynos_plane->enabled = true;
+       DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
+
+       if (mode == DRM_MODE_DPMS_ON) {
+               if (exynos_plane->enabled)
+                       return;
+
+               exynos_drm_fn_encoder(plane->crtc, &overlay->zpos,
+                               exynos_drm_encoder_plane_enable);
+
+               exynos_plane->enabled = true;
+       } else {
+               if (!exynos_plane->enabled)
+                       return;
+
+               exynos_drm_fn_encoder(plane->crtc, &overlay->zpos,
+                               exynos_drm_encoder_plane_disable);
+
+               exynos_plane->enabled = false;
+       }
 }
 
 static int
@@ -132,24 +156,16 @@ exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
        plane->fb = crtc->fb;
 
        exynos_plane_commit(plane);
+       exynos_plane_dpms(plane, DRM_MODE_DPMS_ON);
 
        return 0;
 }
 
 static int exynos_disable_plane(struct drm_plane *plane)
 {
-       struct exynos_plane *exynos_plane = to_exynos_plane(plane);
-       struct exynos_drm_overlay *overlay = &exynos_plane->overlay;
-
        DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
 
-       if (!exynos_plane->enabled)
-               return 0;
-
-       exynos_drm_fn_encoder(plane->crtc, &overlay->zpos,
-                       exynos_drm_encoder_plane_disable);
-
-       exynos_plane->enabled = false;
+       exynos_plane_dpms(plane, DRM_MODE_DPMS_OFF);
 
        return 0;
 }
index c9dad86c915862a4f161ec38fd37b49f3ed76f19..88312458580d459946cd67a1f794a13929254374 100644 (file)
@@ -15,5 +15,6 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc,
                          uint32_t src_x, uint32_t src_y,
                          uint32_t src_w, uint32_t src_h);
 void exynos_plane_commit(struct drm_plane *plane);
+void exynos_plane_dpms(struct drm_plane *plane, int mode);
 struct drm_plane *exynos_plane_init(struct drm_device *dev,
                                    unsigned int possible_crtcs, bool priv);