drm/exynos: add property for crtc mode
authorJoonyoung Shim <jy0922.shim@samsung.com>
Wed, 27 Jun 2012 05:27:11 +0000 (14:27 +0900)
committerInki Dae <inki.dae@samsung.com>
Fri, 27 Jul 2012 02:13:54 +0000 (11:13 +0900)
This patch adds exynos specific property for crtc mode. The crtc mode
property has tow modes - normal and blank. The normal mode is default
mode and can use crtc normally. The blank mode turns off the private
plane of crtc, so we don't see crtc screen but can see other plane
screens.

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

index 047257bf9be0bd9b1b101e28e191122c5d536d5a..abb1e2f8227f3304a88b475bcc3190dec81be8c8 100644 (file)
 #define to_exynos_crtc(x)      container_of(x, struct exynos_drm_crtc,\
                                drm_crtc)
 
+enum exynos_crtc_mode {
+       CRTC_MODE_NORMAL,       /* normal mode */
+       CRTC_MODE_BLANK,        /* The private plane of crtc is blank */
+};
+
 /*
  * Exynos specific crtc structure.
  *
  *     we can refer to the crtc to current hardware interrupt occured through
  *     this pipe value.
  * @dpms: store the crtc dpms value
+ * @mode: store the crtc mode value
  */
 struct exynos_drm_crtc {
        struct drm_crtc                 drm_crtc;
        struct drm_plane                *plane;
        unsigned int                    pipe;
        unsigned int                    dpms;
+       enum exynos_crtc_mode           mode;
 };
 
 static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
@@ -255,12 +262,75 @@ static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
        kfree(exynos_crtc);
 }
 
+static int exynos_drm_crtc_set_property(struct drm_crtc *crtc,
+                                       struct drm_property *property,
+                                       uint64_t val)
+{
+       struct drm_device *dev = crtc->dev;
+       struct exynos_drm_private *dev_priv = dev->dev_private;
+       struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
+
+       DRM_DEBUG_KMS("%s\n", __func__);
+
+       if (property == dev_priv->crtc_mode_property) {
+               enum exynos_crtc_mode mode = val;
+
+               if (mode == exynos_crtc->mode)
+                       return 0;
+
+               exynos_crtc->mode = mode;
+
+               switch (mode) {
+               case CRTC_MODE_NORMAL:
+                       exynos_drm_crtc_commit(crtc);
+                       break;
+               case CRTC_MODE_BLANK:
+                       exynos_plane_dpms(exynos_crtc->plane,
+                                         DRM_MODE_DPMS_OFF);
+                       break;
+               default:
+                       break;
+               }
+
+               return 0;
+       }
+
+       return -EINVAL;
+}
+
 static struct drm_crtc_funcs exynos_crtc_funcs = {
        .set_config     = drm_crtc_helper_set_config,
        .page_flip      = exynos_drm_crtc_page_flip,
        .destroy        = exynos_drm_crtc_destroy,
+       .set_property   = exynos_drm_crtc_set_property,
+};
+
+static const struct drm_prop_enum_list mode_names[] = {
+       { CRTC_MODE_NORMAL, "normal" },
+       { CRTC_MODE_BLANK, "blank" },
 };
 
+static void exynos_drm_crtc_attach_mode_property(struct drm_crtc *crtc)
+{
+       struct drm_device *dev = crtc->dev;
+       struct exynos_drm_private *dev_priv = dev->dev_private;
+       struct drm_property *prop;
+
+       DRM_DEBUG_KMS("%s\n", __func__);
+
+       prop = dev_priv->crtc_mode_property;
+       if (!prop) {
+               prop = drm_property_create_enum(dev, 0, "mode", mode_names,
+                                               ARRAY_SIZE(mode_names));
+               if (!prop)
+                       return;
+
+               dev_priv->crtc_mode_property = prop;
+       }
+
+       drm_object_attach_property(&crtc->base, prop, 0);
+}
+
 int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr)
 {
        struct exynos_drm_crtc *exynos_crtc;
@@ -290,6 +360,8 @@ int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr)
        drm_crtc_init(dev, crtc, &exynos_crtc_funcs);
        drm_crtc_helper_add(crtc, &exynos_crtc_helper_funcs);
 
+       exynos_drm_crtc_attach_mode_property(crtc);
+
        return 0;
 }
 
index 1c90a9a933c72c0743fd5d4c7df18b428c9e5cbe..e22704b249d75782def8345dca75b5e51d60715d 100644 (file)
@@ -238,6 +238,7 @@ struct exynos_drm_private {
         */
        struct drm_crtc *crtc[MAX_CRTC];
        struct drm_property *plane_zpos_property;
+       struct drm_property *crtc_mode_property;
 };
 
 /*