Re: [PATCH 2/2] drm/i915: Make get_initial_plane_config also get the initial rotation config

2017-04-26 Thread Bastien Nocera
On Sun, 2017-04-23 at 18:11 +0200, Hans de Goede wrote:
> From: Ville Syrjala 

> diff --git a/drivers/gpu/drm/i915/intel_drv.h
> b/drivers/gpu/drm/i915/intel_drv.h
> index 344f238..63623dd 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -418,6 +418,7 @@ struct intel_initial_plane_config {
>   unsigned int tiling;
>   int size;
>   u32 base;
> + uint8_t rotation;

Mentioning what this is (DRM_ROTATE_* or something else) is even more
important here.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/2] drm/i915: Make get_initial_plane_config also get the initial rotation config

2017-04-23 Thread Hans de Goede
From: Ville Syrjala 

When retrieving the initial settings / mode from the hardware also
retrieve the initial rotation config.

Together with "drm/fb-helper: Make fbdev inherit the crtc's rotation"
this will make the fbdev inherit the initial rotation.

This is useful on e.g. some tablets which have their lcd panel mounted
upside down, which before this commit would result in the kernel boot
messages switching from being shown the right way up in efifb to being
shown upside down as soon as a native kms driver loads.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=94894
Cc: Ville Syrjala 
[hdego...@redhat.com: Split the intel_display bits out of Ville's
 "drm/fb-helper: Inherit rotation wip" patch]
Tested-by: Hans de Goede 
Signed-off-by: Hans de Goede 
---
 drivers/gpu/drm/i915/intel_display.c | 30 +-
 drivers/gpu/drm/i915/intel_drv.h |  1 +
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index ed1f4f2..5c9f504 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2821,6 +2821,8 @@ intel_find_initial_plane_obj(struct intel_crtc 
*intel_crtc,
plane_state->crtc_w = fb->width;
plane_state->crtc_h = fb->height;
 
+   plane_state->rotation = plane_config->rotation;
+
intel_state->base.src = drm_plane_state_src(plane_state);
intel_state->base.dst = drm_plane_state_dest(plane_state);
 
@@ -8733,6 +8735,9 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
plane_config->tiling = I915_TILING_X;
fb->modifier = I915_FORMAT_MOD_X_TILED;
}
+
+   if (val & DISPPLANE_ROTATE_180)
+   plane_config->rotation = DRM_ROTATE_180;
}
 
pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
@@ -9784,6 +9789,24 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
goto error;
}
 
+   /*
+* DRM_ROTATE_ is counter clockwise to stay compatible with Xrandr
+* while i915 HW rotation is clockwise, thats why this swapping.
+*/
+   switch (val & PLANE_CTL_ROTATE_MASK) {
+   case PLANE_CTL_ROTATE_0:
+   break;
+   case PLANE_CTL_ROTATE_90:
+   plane_config->rotation = DRM_ROTATE_270;
+   break;
+   case PLANE_CTL_ROTATE_180:
+   plane_config->rotation = DRM_ROTATE_180;
+   break;
+   case PLANE_CTL_ROTATE_270:
+   plane_config->rotation = DRM_ROTATE_90;
+   break;
+   }
+
base = I915_READ(PLANE_SURF(pipe, 0)) & 0xf000;
plane_config->base = base;
 
@@ -9872,6 +9895,9 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
plane_config->tiling = I915_TILING_X;
fb->modifier = I915_FORMAT_MOD_X_TILED;
}
+
+   if (val & DISPPLANE_ROTATE_180)
+   plane_config->rotation = DRM_ROTATE_180;
}
 
pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
@@ -16713,7 +16739,9 @@ int intel_modeset_init(struct drm_device *dev)
drm_modeset_unlock_all(dev);
 
for_each_intel_crtc(dev, crtc) {
-   struct intel_initial_plane_config plane_config = {};
+   struct intel_initial_plane_config plane_config = {
+   .rotation = DRM_ROTATE_0
+   };
 
if (!crtc->active)
continue;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 344f238..63623dd 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -418,6 +418,7 @@ struct intel_initial_plane_config {
unsigned int tiling;
int size;
u32 base;
+   uint8_t rotation;
 };
 
 #define SKL_MIN_SRC_W 8
-- 
2.9.3

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel