Re: [Intel-gfx] [PATCH v2 03/15] drm: Add support for optional per-plane rotation property

2016-07-25 Thread Joonas Lahtinen
On pe, 2016-07-22 at 16:43 +0300, ville.syrj...@linux.intel.com wrote:
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 986de180e6c2..9e20a52ece7c 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -5801,6 +5801,39 @@ struct drm_property 
> *drm_mode_create_rotation_property(struct drm_device *dev,
>  }
>  EXPORT_SYMBOL(drm_mode_create_rotation_property);
>  
> +int drm_plane_create_rotation_property(struct drm_plane *plane,
> +    unsigned int rotation,
> +    unsigned int supported_rotations)
> +{
> + static const struct drm_prop_enum_list props[] = {
> + { DRM_ROTATE_0,   "rotate-0" },
> + { DRM_ROTATE_90,  "rotate-90" },
> + { DRM_ROTATE_180, "rotate-180" },
> + { DRM_ROTATE_270, "rotate-270" },
> + { DRM_REFLECT_X,  "reflect-x" },
> + { DRM_REFLECT_Y,  "reflect-y" },

I sent a series for converting the DRM_ROTATE_? defines into BIT()
variants, so __builtin_ffs(DRM_ROTATE_0) - 1 etc. would end up used
here depending on which gets merged first.

Also,

Reviewed-by: Joonas Lahtinen 

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v2 03/15] drm: Add support for optional per-plane rotation property

2016-07-22 Thread ville . syrjala
From: Ville Syrjälä 

Not all planes on the ssytem may support the same rotations/reflections,
so make it possible to create a separate property for each plane.
This way userspace gets told exactly which rotations/reflections are
possible for each plane.

v2: Add drm_plane_create_rotation_property() helper

Signed-off-by: Ville Syrjälä 
Reviewed-by: Chris Wilson  (v1)
---
 drivers/gpu/drm/drm_atomic.c|  6 --
 drivers/gpu/drm/drm_crtc.c  | 33 +
 drivers/gpu/drm/drm_fb_helper.c |  6 +-
 include/drm/drm_crtc.h  | 10 +-
 4 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index c425bd39a210..116f940a9267 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -709,7 +709,8 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
state->src_w = val;
} else if (property == config->prop_src_h) {
state->src_h = val;
-   } else if (property == config->rotation_property) {
+   } else if (property == config->rotation_property ||
+  property == plane->rotation_property) {
if (!is_power_of_2(val & DRM_ROTATE_MASK))
return -EINVAL;
state->rotation = val;
@@ -767,7 +768,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
*val = state->src_w;
} else if (property == config->prop_src_h) {
*val = state->src_h;
-   } else if (property == config->rotation_property) {
+   } else if (property == config->rotation_property ||
+  property == plane->rotation_property) {
*val = state->rotation;
} else if (plane->funcs->atomic_get_property) {
return plane->funcs->atomic_get_property(plane, state, 
property, val);
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 986de180e6c2..9e20a52ece7c 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -5801,6 +5801,39 @@ struct drm_property 
*drm_mode_create_rotation_property(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_mode_create_rotation_property);
 
+int drm_plane_create_rotation_property(struct drm_plane *plane,
+  unsigned int rotation,
+  unsigned int supported_rotations)
+{
+   static const struct drm_prop_enum_list props[] = {
+   { DRM_ROTATE_0,   "rotate-0" },
+   { DRM_ROTATE_90,  "rotate-90" },
+   { DRM_ROTATE_180, "rotate-180" },
+   { DRM_ROTATE_270, "rotate-270" },
+   { DRM_REFLECT_X,  "reflect-x" },
+   { DRM_REFLECT_Y,  "reflect-y" },
+   };
+   struct drm_property *prop;
+
+   WARN_ON((supported_rotations & rotation) == 0);
+
+   prop = drm_property_create_bitmask(plane->dev, 0, "rotation",
+  props, ARRAY_SIZE(props),
+  supported_rotations);
+   if (!prop)
+   return -ENOMEM;
+
+   drm_object_attach_property(>base, prop, rotation);
+
+   if (plane->state)
+   plane->state->rotation = rotation;
+
+   plane->rotation_property = prop;
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_plane_create_rotation_property);
+
 /**
  * DOC: Tile group
  *
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index ce54e985d91b..ce536c0553e5 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -392,7 +392,11 @@ static int restore_fbdev_mode(struct drm_fb_helper 
*fb_helper)
if (plane->type != DRM_PLANE_TYPE_PRIMARY)
drm_plane_force_disable(plane);
 
-   if (dev->mode_config.rotation_property) {
+   if (plane->rotation_property) {
+   drm_mode_plane_set_obj_prop(plane,
+   plane->rotation_property,
+   BIT(DRM_ROTATE_0));
+   } else if (dev->mode_config.rotation_property) {
drm_mode_plane_set_obj_prop(plane,

dev->mode_config.rotation_property,
BIT(DRM_ROTATE_0));
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index b7ac7dcf52db..01cf0673f6c8 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1737,6 +1737,11 @@ struct drm_plane {
const struct drm_plane_helper_funcs *helper_private;
 
struct drm_plane_state *state;
+
+   /**
+* @rotation_property: Optional property for planes to specify rotation.
+*/
+   struct drm_property *rotation_property;
 };