drm: omapdrm: Store the rotation property in dev->mode_config
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Fri, 6 Mar 2015 15:16:43 +0000 (17:16 +0200)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Fri, 12 Jun 2015 19:52:44 +0000 (22:52 +0300)
Rotation is a standard property, store it in
dev->mode_config.rotation_property. While at it, extract the properties
initialization code to a separate function instead of running it for
every plane.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/gpu/drm/omapdrm/omap_crtc.c
drivers/gpu/drm/omapdrm/omap_drv.c
drivers/gpu/drm/omapdrm/omap_drv.h
drivers/gpu/drm/omapdrm/omap_plane.c

index f456544bf300ba89fdea11242afd4656436888dd..7a64765d053731b5628c130a2e004f9229c4d03d 100644 (file)
@@ -646,9 +646,7 @@ static int omap_crtc_page_flip_locked(struct drm_crtc *crtc,
 static int omap_crtc_set_property(struct drm_crtc *crtc,
                struct drm_property *property, uint64_t val)
 {
-       struct omap_drm_private *priv = crtc->dev->dev_private;
-
-       if (property == priv->rotation_prop) {
+       if (property == crtc->dev->mode_config.rotation_property) {
                crtc->invert_dimensions =
                                !!(val & ((1LL << DRM_ROTATE_90) | (1LL << DRM_ROTATE_270)));
        }
index 94920d47e3b63f0dcd37bb6ee73f127f9049d7eb..ce6a255d277ace8429d45b99320ab36edc60ca05 100644 (file)
@@ -151,6 +151,27 @@ static int omap_modeset_create_crtc(struct drm_device *dev, int id,
        return 0;
 }
 
+static int omap_modeset_init_properties(struct drm_device *dev)
+{
+       struct omap_drm_private *priv = dev->dev_private;
+
+       if (priv->has_dmm) {
+               dev->mode_config.rotation_property =
+                       drm_mode_create_rotation_property(dev,
+                               BIT(DRM_ROTATE_0) | BIT(DRM_ROTATE_90) |
+                               BIT(DRM_ROTATE_180) | BIT(DRM_ROTATE_270) |
+                               BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y));
+               if (!dev->mode_config.rotation_property)
+                       return -ENOMEM;
+       }
+
+       priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0, 3);
+       if (!priv->zorder_prop)
+               return -ENOMEM;
+
+       return 0;
+}
+
 static int omap_modeset_init(struct drm_device *dev)
 {
        struct omap_drm_private *priv = dev->dev_private;
@@ -165,6 +186,10 @@ static int omap_modeset_init(struct drm_device *dev)
 
        omap_drm_irq_install(dev);
 
+       ret = omap_modeset_init_properties(dev);
+       if (ret < 0)
+               return ret;
+
        /*
         * We usually don't want to create a CRTC for each manager, at least
         * not until we have a way to expose private planes to userspace.
@@ -583,7 +608,7 @@ static void dev_lastclose(struct drm_device *dev)
 
        DBG("lastclose: dev=%p", dev);
 
-       if (priv->rotation_prop) {
+       if (dev->mode_config.rotation_property) {
                /* need to restore default rotation state.. not sure
                 * if there is a cleaner way to restore properties to
                 * default state?  Maybe a flag that properties should
@@ -592,12 +617,12 @@ static void dev_lastclose(struct drm_device *dev)
                 */
                for (i = 0; i < priv->num_crtcs; i++) {
                        drm_object_property_set_value(&priv->crtcs[i]->base,
-                                       priv->rotation_prop, 0);
+                                       dev->mode_config.rotation_property, 0);
                }
 
                for (i = 0; i < priv->num_planes; i++) {
                        drm_object_property_set_value(&priv->planes[i]->base,
-                                       priv->rotation_prop, 0);
+                                       dev->mode_config.rotation_property, 0);
                }
        }
 
index b31c79f15aede8481af46d62e8342b59aaa62f4c..a42a11c621069b3b8f4588f880ea87576085130f 100644 (file)
@@ -114,7 +114,6 @@ struct omap_drm_private {
        bool has_dmm;
 
        /* properties: */
-       struct drm_property *rotation_prop;
        struct drm_property *zorder_prop;
 
        /* irq handling: */
index 1c6b63f394741595f110adce51c56188f03787ba..a1c9c08db34551b1895b297e6a4a4f77591c8844 100644 (file)
@@ -297,33 +297,14 @@ void omap_plane_install_properties(struct drm_plane *plane,
 {
        struct drm_device *dev = plane->dev;
        struct omap_drm_private *priv = dev->dev_private;
-       struct drm_property *prop;
 
        if (priv->has_dmm) {
-               prop = priv->rotation_prop;
-               if (!prop) {
-                       prop = drm_mode_create_rotation_property(dev,
-                                                                BIT(DRM_ROTATE_0) |
-                                                                BIT(DRM_ROTATE_90) |
-                                                                BIT(DRM_ROTATE_180) |
-                                                                BIT(DRM_ROTATE_270) |
-                                                                BIT(DRM_REFLECT_X) |
-                                                                BIT(DRM_REFLECT_Y));
-                       if (prop == NULL)
-                               return;
-                       priv->rotation_prop = prop;
-               }
+               struct drm_property *prop = dev->mode_config.rotation_property;
+
                drm_object_attach_property(obj, prop, 0);
        }
 
-       prop = priv->zorder_prop;
-       if (!prop) {
-               prop = drm_property_create_range(dev, 0, "zorder", 0, 3);
-               if (prop == NULL)
-                       return;
-               priv->zorder_prop = prop;
-       }
-       drm_object_attach_property(obj, prop, 0);
+       drm_object_attach_property(obj, priv->zorder_prop, 0);
 }
 
 int omap_plane_set_property(struct drm_plane *plane,
@@ -333,7 +314,7 @@ int omap_plane_set_property(struct drm_plane *plane,
        struct omap_drm_private *priv = plane->dev->dev_private;
        int ret = -EINVAL;
 
-       if (property == priv->rotation_prop) {
+       if (property == plane->dev->mode_config.rotation_property) {
                DBG("%s: rotation: %02x", omap_plane->name, (uint32_t)val);
                omap_plane->win.rotation = val;
                ret = omap_plane_apply(plane);