drm/i915: Deal with upside-down mounted LCD panels
Subsystems (2)
v4 cover drm/i915: Deal with upside-down mounted LCD panels
Hi All,
When I last send this patch not everyone was enthusiastic about this patch. As already mentioned in the v2 discussion, solving this in userspace is not really feasible since there is no single place to fix it there, it will need fixing in at least 6 different places from the top of my head (basically any app/server/"driver" talking directly to kms needs fixing) Also fixing it in userspace will be quite complicated even in a single consumer of the kms API.
It has been 3 months since my last version and no other solution has materialized, so I would like to move forward with this patch.
The only technical objection against my previous version was that it did not fix the subpixel order reported to userspace, that has been fixed in this version and it has been rebased on top of the latest drm-intel-next-queued.
New in v4: Fix compiler warning introduced in v3.
Regards,
Hans
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 1/1 drm/i915: Deal with upside-down mounted LCD panels
On some (Bay Trail) devices the LCD panel is mounted upside-down.
This commit uses the code to read back the initial rotation of the primary plane in get_initial_plane_config from Ville Syrjala's "drm/fb-helper: Inherit rotation wip" patch and when re-using the initial fb it stores that in intel_crtc.initial_rotation.
It adds an intel_plane_get_rotation helper which combines this initial_rotation with any rotation requested by userspace and uses this in all places which look at a planes rotation, thus transparently dealing with upside-down LCD panels without requiring any user-space or fbcon changes.
This fixes 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, as well as any graphics displayed by userspace being upside-down.
Note this only deals with upside-down LCD panels / 180 degrees rotation as the hardware in question only supports 180 degrees rotation in hardware. The one model known which has a panel mounted with 90/270 degrees rotation will need to be fully dealt with in userspace, even the firmware boot screen / menus are rotated 90 degrees on this one and there simply is nothing the kernel can do about this.
---
Changes in v2:
-Fix brown paperbag bug s/val & mask/val & ~mask/ to clear old rotation bits
Changes in v3:
-Rebase on current (2017 aug. 22) drm-intel-next-queued
Changes in v4:
-Fix compiler warning from unhandled case in intel_fixup_initial_subpixel_order
--- drivers/gpu/drm/i915/intel_atomic_plane.c | 7 ++- drivers/gpu/drm/i915/intel_display.c | 93 +++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_drv.h | 32 +++++++++++ drivers/gpu/drm/i915/intel_fbc.c | 2 +- drivers/gpu/drm/i915/intel_pm.c | 6 +- drivers/gpu/drm/i915/intel_sprite.c | 14 ++--- 6 files changed, 123 insertions(+), 31 deletions(-)
drivers/gpu/drm/i915/intel_atomic_plane.c +4 -3
@@ -116,6 +116,7 @@ int intel_plane_atomic_check_with_state(struct intel_crtc_state *crtc_state,struct intel_plane *intel_plane =to_intel_plane (plane);const struct drm_display_mode *adjusted_mode = &crtc_state->base.adjusted_mode; +unsigned int rotation =intel_plane_get_rotation (state);int ret;/*
@@ -135,7 +136,7 @@ int intel_plane_atomic_check_with_state(struct intel_crtc_state *crtc_state, intel_state->clip.y2 = crtc_state->base.enable ? crtc_state->pipe_src_h :0 ; -if (state->fb &&drm_rotation_90_or_270 (state->rotation)) { +if (state->fb &&drm_rotation_90_or_270 (rotation)) {struct drm_format_name_buf format_name; if (state->fb->modifier != I915_FORMAT_MOD_Y_TILED &&
@@ -164,8 +165,8 @@ int intel_plane_atomic_check_with_state(struct intel_crtc_state *crtc_state,/* CHV ignores the mirror bit when the rotate bit is set :( */ if (IS_CHERRYVIEW (dev_priv) && - state->rotation &DRM_MODE_ROTATE_180 && - state->rotation &DRM_MODE_REFLECT_X ) { + rotation &DRM_MODE_ROTATE_180 && + rotation &DRM_MODE_REFLECT_X ) {DRM_DEBUG_KMS ("Cannot rotate and reflect at the same time\n" );return -EINVAL ; }
drivers/gpu/drm/i915/intel_display.c +75 -18
233 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +32 -0
@@ -447,6 +447,7 @@ struct intel_initial_plane_config {unsigned int tiling;int size;u32 base; +uint8_t rotation;/* DRM_MODE_ROTATE_* */ };#define SKL_MIN_SRC_W 8
@@ -802,6 +803,12 @@ struct intel_crtc {unsigned long long enabled_power_domains;struct intel_overlay *overlay; +/* +* Initial DRM_MODE_ROTATE_* as read back from the hardware at init, +* this is used to compensate for e.g. upside-down mounted lcd-panels. +*/ +uint8_t initial_rotation; +/* Display surface base address adjustement for pageflips. Note that on * gen4+ this only adjusts up to a tile, offsets within a tile are * handled in the hw itself (with the TILEOFF register). */
@@ -1464,6 +1471,31 @@ static inline u32 intel_plane_ggtt_offset(const struct intel_plane_state *state)return i915_ggtt_offset (state->vma); } +static inline unsigned int +intel_plane_get_rotation (const struct drm_plane_state *plane_state) +{ +unsigned int rotation = plane_state->rotation; +unsigned int new_rotation =DRM_MODE_ROTATE_0 ; +struct intel_crtc *intel_crtc; + +if (!plane_state->crtc) +return rotation; + +/* We only support an initial rotation of DRM_MODE_ROTATE_180 for now */ + intel_crtc =to_intel_crtc (plane_state->crtc); +if (intel_crtc->initial_rotation !=DRM_MODE_ROTATE_180 ) +return rotation; + +switch (rotation &DRM_MODE_ROTATE_MASK ) { +case DRM_MODE_ROTATE_0 : new_rotation =DRM_MODE_ROTATE_180 ;break ; +case DRM_MODE_ROTATE_90 : new_rotation =DRM_MODE_ROTATE_270 ;break ; +case DRM_MODE_ROTATE_180 : new_rotation =DRM_MODE_ROTATE_0 ;break ; +case DRM_MODE_ROTATE_270 : new_rotation =DRM_MODE_ROTATE_90 ;break ; + } + +return (rotation & ~DRM_MODE_ROTATE_MASK ) | new_rotation; +} +u32 skl_plane_ctl (const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state); u32 skl_plane_stride(const struct drm_framebuffer *fb, int plane,
drivers/gpu/drm/i915/intel_fbc.c +1 -1
@@ -737,7 +737,7 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc,if (IS_HASWELL (dev_priv) ||IS_BROADWELL (dev_priv)) cache->crtc.hsw_bdw_pixel_rate = crtc_state->pixel_rate; - cache->plane.rotation = plane_state->base.rotation; + cache->plane.rotation =intel_plane_get_rotation (&plane_state->base);/* * Src coordinates are already rotated by 270 degrees for * the 90/270 degree plane rotation cases (to match the
drivers/gpu/drm/i915/intel_pm.c +4 -2
@@ -4080,6 +4080,7 @@ skl_ddb_min_alloc(const struct drm_plane_state *pstate, {struct drm_framebuffer *fb = pstate->fb;struct intel_plane_state *intel_pstate =to_intel_plane_state (pstate); +unsigned int rotation =intel_plane_get_rotation (pstate);uint32_t src_w, src_h;uint32_t min_scanlines =8 ;uint8_t plane_bpp;
@@ -4117,7 +4118,7 @@ skl_ddb_min_alloc(const struct drm_plane_state *pstate,else plane_bpp = fb->format->cpp[0 ]; -if (drm_rotation_90_or_270 (pstate->rotation)) { +if (drm_rotation_90_or_270 (rotation)) {switch (plane_bpp) {case 1 : min_scanlines =32 ;
@@ -4382,6 +4383,7 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,struct intel_plane *plane =to_intel_plane (intel_pstate->base.plane);const struct drm_plane_state *pstate = &intel_pstate->base;const struct drm_framebuffer *fb = pstate->fb; +unsigned int rotation =intel_plane_get_rotation (pstate);uint32_t latency = dev_priv->wm.skl_latency[level];uint_fixed_16_16_t method1, method2;uint_fixed_16_16_t plane_blocks_per_line;
@@ -4434,7 +4436,7 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv, fb->format->cpp[0 ]; plane_pixel_rate =skl_adjusted_plane_pixel_rate (cstate, intel_pstate); -if (drm_rotation_90_or_270 (pstate->rotation)) { +if (drm_rotation_90_or_270 (rotation)) {switch (cpp) {case 1 :
drivers/gpu/drm/i915/intel_sprite.c +7 -7
@@ -237,7 +237,7 @@ skl_update_plane(struct intel_plane *plane,u32 plane_ctl = plane_state->ctl;const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;u32 surf_addr = plane_state->main.offset; -unsigned int rotation = plane_state->base.rotation; +unsigned int rotation =intel_plane_get_rotation (&plane_state->base);u32 stride =skl_plane_stride (fb,0 , rotation);u32 aux_stride =skl_plane_stride (fb,1 , rotation);int crtc_x = plane_state->base.dst.x1;
@@ -367,7 +367,7 @@ static u32 vlv_sprite_ctl(const struct intel_crtc_state *crtc_state, const struct intel_plane_state *plane_state) {const struct drm_framebuffer *fb = plane_state->base.fb; -unsigned int rotation = plane_state->base.rotation; +unsigned int rotation =intel_plane_get_rotation (&plane_state->base);const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;u32 sprctl;
@@ -507,7 +507,7 @@ static u32 ivb_sprite_ctl(const struct intel_crtc_state *crtc_state,struct drm_i915_private *dev_priv =to_i915 (plane_state->base.plane->dev);const struct drm_framebuffer *fb = plane_state->base.fb; -unsigned int rotation = plane_state->base.rotation; +unsigned int rotation =intel_plane_get_rotation (&plane_state->base);const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;u32 sprctl;
@@ -647,7 +647,7 @@ static u32 g4x_sprite_ctl(const struct intel_crtc_state *crtc_state,struct drm_i915_private *dev_priv =to_i915 (plane_state->base.plane->dev);const struct drm_framebuffer *fb = plane_state->base.fb; -unsigned int rotation = plane_state->base.rotation; +unsigned int rotation =intel_plane_get_rotation (&plane_state->base);const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;u32 dvscntr;
@@ -780,6 +780,7 @@ intel_check_sprite_plane(struct intel_plane *plane,struct drm_i915_private *dev_priv =to_i915 (plane->base.dev);struct intel_crtc *crtc =to_intel_crtc (crtc_state->base.crtc);struct drm_framebuffer *fb = state->base.fb; +unsigned int rotation =intel_plane_get_rotation (&state->base);int crtc_x, crtc_y;unsigned int crtc_w, crtc_h;uint32_t src_x, src_y, src_w, src_h;
@@ -834,8 +835,7 @@ intel_check_sprite_plane(struct intel_plane *plane,* coordinates and sizes. We probably need some way to decide whether * more strict checking should be done instead. */ -drm_rect_rotate (src, fb->width <<16 , fb->height <<16 , - state->base.rotation); +drm_rect_rotate (src, fb->width <<16 , fb->height <<16 , rotation); hscale =drm_rect_calc_hscale_relaxed (src, dst, min_scale, max_scale);BUG_ON (hscale <0 );
@@ -876,7 +876,7 @@ intel_check_sprite_plane(struct intel_plane *plane, drm_rect_height(dst) * vscale - drm_rect_height(src));drm_rect_rotate_inv (src, fb->width <<16 , fb->height <<16 , - state->base.rotation); + rotation);/* sanity check to make sure the src viewport wasn't enlarged */ WARN_ON(src->x1 < (int) state->base.src_x ||
Signature · 6 lines
2.13.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915: Deal with upside-down mounted LCD panels (rev2)
In reply to Hans de Goede== Series Details ==
== Series Details ==
Series: drm/i915: Deal with upside-down mounted LCD panels (rev2)
URL : https://patchwork.freedesktop.org/series/29161/
State : success
== Summary ==
Series 29161v2 drm/i915: Deal with upside-down mounted LCD panels
https://patchwork.freedesktop.org/api/1.0/series/29161/revisions/2/mbox/
Test kms_cursor_legacy:
Subgroup basic-busy-flip-before-cursor-legacy:
fail -> PASS (fi-snb-2600) fdo#100215fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215
fi-bdw-5557u total:279 pass:268 dwarn:0 dfail:0 fail:0 skip:11 time:454s fi-blb-e6850 total:279 pass:224 dwarn:1 dfail:0 fail:0 skip:54 time:364s fi-bsw-n3050 total:279 pass:243 dwarn:0 dfail:0 fail:0 skip:36 time:543s fi-bwr-2160 total:279 pass:184 dwarn:0 dfail:0 fail:0 skip:95 time:258s fi-bxt-j4205 total:279 pass:260 dwarn:0 dfail:0 fail:0 skip:19 time:521s fi-byt-j1900 total:279 pass:254 dwarn:1 dfail:0 fail:0 skip:24 time:520s fi-byt-n2820 total:279 pass:250 dwarn:1 dfail:0 fail:0 skip:28 time:512s fi-elk-e7500 total:279 pass:230 dwarn:0 dfail:0 fail:0 skip:49 time:430s fi-glk-2a total:279 pass:260 dwarn:0 dfail:0 fail:0 skip:19 time:609s fi-hsw-4770 total:279 pass:263 dwarn:0 dfail:0 fail:0 skip:16 time:441s fi-hsw-4770r total:279 pass:263 dwarn:0 dfail:0 fail:0 skip:16 time:422s fi-ilk-650 total:279 pass:229 dwarn:0 dfail:0 fail:0 skip:50 time:423s fi-ivb-3520m total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:509s fi-ivb-3770 total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:483s fi-kbl-7500u total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:476s fi-kbl-7560u total:279 pass:269 dwarn:0 dfail:0 fail:0 skip:10 time:595s fi-kbl-r total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:602s fi-pnv-d510 total:279 pass:223 dwarn:1 dfail:0 fail:0 skip:55 time:521s fi-skl-6260u total:279 pass:269 dwarn:0 dfail:0 fail:0 skip:10 time:465s fi-skl-6700k total:279 pass:261 dwarn:0 dfail:0 fail:0 skip:18 time:483s fi-skl-6770hq total:279 pass:269 dwarn:0 dfail:0 fail:0 skip:10 time:486s fi-skl-gvtdvm total:279 pass:266 dwarn:0 dfail:0 fail:0 skip:13 time:444s fi-skl-x1585l total:279 pass:268 dwarn:0 dfail:0 fail:0 skip:11 time:481s fi-snb-2520m total:279 pass:251 dwarn:0 dfail:0 fail:0 skip:28 time:546s fi-snb-2600 total:279 pass:250 dwarn:0 dfail:0 fail:0 skip:29 time:407s
fi-bdw-gvtdvm failed to connect after reboot
84896d875643281c82beba90c3ce632b5b328c52 drm-tip: 2017y-08m-25d-14h-00m-21s UTC integration manifest c5fe897477a7 drm/i915: Deal with upside-down mounted LCD panels
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5495/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for drm/i915: Deal with upside-down mounted LCD panels (rev2)
In reply to Hans de Goede== Series Details ==
== Series Details ==
Series: drm/i915: Deal with upside-down mounted LCD panels (rev2)
URL : https://patchwork.freedesktop.org/series/29161/
State : success
== Summary ==
Test kms_setmode:
Subgroup basic:
pass -> FAIL (shard-hsw) fdo#99912
Test perf:
Subgroup blocking:
fail -> PASS (shard-hsw) fdo#102252fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
shard-hsw total:2230 pass:1230 dwarn:0 dfail:0 fail:18 skip:982 time:9586s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5495/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx