Subject: [Patch] drm/i915: Set the LVDS_BORDER when using LVDS panel_fitting From: Zhao Yakui According to the spec the LVDS_BORDER_ENABLE bit decides whether the border data should be included in the active display and data sent to the panel. Border should be used when in VGA centered (un-scaled) mode or when scaling a 4:3 source image to a wide screen panel (typical 16:9). So when the LVDS scaling is used, decide whether the LVDS_BORDER should be enabled or not according to the current scaling mode. https://bugs.freedesktop.org/show_bug.cgi?id=23789 Signed-off-by: Zhao Yakui --- drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/i915_reg.h | 2 ++ drivers/gpu/drm/i915/intel_display.c | 2 ++ drivers/gpu/drm/i915/intel_lvds.c | 10 +++++++++- 4 files changed, 15 insertions(+), 1 deletion(-) Index: linux-2.6/drivers/gpu/drm/i915/i915_drv.h =================================================================== --- linux-2.6.orig/drivers/gpu/drm/i915/i915_drv.h 2009-10-09 11:26:07.000000000 +0800 +++ linux-2.6/drivers/gpu/drm/i915/i915_drv.h 2009-10-10 09:38:49.000000000 +0800 @@ -492,6 +492,8 @@ struct drm_i915_gem_phys_object *phys_objs[I915_MAX_PHYS_OBJECT]; } mm; struct sdvo_device_mapping sdvo_mappings[2]; + /* indicate whether the LVDS_BORDER should be enabled or not */ + unsigned int lvds_border_bits; /* Reclocking support */ bool render_reclock_avail; Index: linux-2.6/drivers/gpu/drm/i915/intel_lvds.c =================================================================== --- linux-2.6.orig/drivers/gpu/drm/i915/intel_lvds.c 2009-10-09 11:38:43.000000000 +0800 +++ linux-2.6/drivers/gpu/drm/i915/intel_lvds.c 2009-10-10 09:39:16.000000000 +0800 @@ -380,7 +380,7 @@ adjusted_mode->crtc_vblank_start + vsync_pos; /* keep the vsync width constant */ adjusted_mode->crtc_vsync_end = - adjusted_mode->crtc_vblank_start + vsync_width; + adjusted_mode->crtc_vsync_start + vsync_width; border = 1; break; case DRM_MODE_SCALE_ASPECT: @@ -526,6 +526,14 @@ lvds_priv->pfit_control = pfit_control; lvds_priv->pfit_pgm_ratios = pfit_pgm_ratios; /* + * When there exists the border, it means that the LVDS_BORDR + * should be enabled. + */ + if (border) + dev_priv->lvds_border_bits |= LVDS_BORDER_ENABLE; + else + dev_priv->lvds_border_bits &= ~(LVDS_BORDER_ENABLE); + /* * XXX: It would be nice to support lower refresh rates on the * panels to reduce power consumption, and perhaps match the * user's requested refresh rate. Index: linux-2.6/drivers/gpu/drm/i915/i915_reg.h =================================================================== --- linux-2.6.orig/drivers/gpu/drm/i915/i915_reg.h 2009-10-09 11:25:58.000000000 +0800 +++ linux-2.6/drivers/gpu/drm/i915/i915_reg.h 2009-10-10 09:32:20.000000000 +0800 @@ -968,6 +968,8 @@ #define LVDS_PORT_EN (1 << 31) /* Selects pipe B for LVDS data. Must be set on pre-965. */ #define LVDS_PIPEB_SELECT (1 << 30) +/* Enable border for unscaled (or aspect-scaled) display */ +#define LVDS_BORDER_ENABLE (1 << 15) /* * Enables the A0-A2 data pairs and CLKA, containing 18 bits of color data per * pixel. Index: linux-2.6/drivers/gpu/drm/i915/intel_display.c =================================================================== --- linux-2.6.orig/drivers/gpu/drm/i915/intel_display.c 2009-10-09 11:38:43.000000000 +0800 +++ linux-2.6/drivers/gpu/drm/i915/intel_display.c 2009-10-10 09:37:43.000000000 +0800 @@ -2936,6 +2936,8 @@ lvds = I915_READ(lvds_reg); lvds |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP | LVDS_PIPEB_SELECT; + /* set the corresponsding LVDS_BORDER bit */ + lvds |= dev_priv->lvds_border_bits; /* Set the B0-B3 data pairs corresponding to whether we're going to * set the DPLLs for dual-channel mode or not. */