i915: Modify for pineview lvds sync polarity
Subsystems (2)
PATCH 1/1 i915: Modify for pineview lvds sync polarity
The i915 driver normally assumes the video bios has configured several of the LVDS panel registers, and it just inherits the values. If the vbios has not run, several of these will need to be setup.
intel_display.c: ensures the sync polarity to the panel is correct and issues a message if the driver changes it.
If these are not correct then although the panel looks ok, output from an HDMI encoder (eg, Chrontel CH7036) will be incorrect.
Index: drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/i915_reg.h +4 -0
@@ -1056,6 +1056,10 @@#define LVDS_PIPEB_SELECT (1 << 30)/* LVDS dithering flag on 965/g4x platform */ #define LVDS_ENABLE_DITHER (1 << 25) +/* LVDS sync polarity flags. Set to invert (i.e. negative) */ +#define LVDS_VSYNC_POLARITY (1 << 21) +#define LVDS_HSYNC_POLARITY (1 << 20) +/* Enable border for unscaled (or aspect-scaled) display */ #define LVDS_BORDER_ENABLE (1 << 15)/*
Index: drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_display.c +23 -0
@@ -3334,6 +3334,29 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, lvds &= ~LVDS_ENABLE_DITHER ; } } +/* Only tested on pineview, should work on IS_9XX */ +if (IS_PINEVIEW (dev)) { +/* Set sync polarity for case when vbios did not */ +char curhs, curvs, newhs, newvs; + curhs = (lvds &LVDS_HSYNC_POLARITY ) ?'-' :'+' ; + curvs = (lvds &LVDS_VSYNC_POLARITY ) ?'-' :'+' ; + newhs = (adjusted_mode->flags &DRM_MODE_FLAG_NHSYNC ) ? +'-' :'+' ; + newvs = (adjusted_mode->flags &DRM_MODE_FLAG_NVSYNC ) ? +'-' :'+' ; +if ((newhs != curhs) || (newvs != curvs)) { +DRM_INFO ("Change lvds panel from %chsync " +"%cvsync to %chsync %cvsync\n" , + curhs, curvs, newhs, newvs); +/* Clear to both + polarity */ + lvds &= ~(LVDS_HSYNC_POLARITY | +LVDS_VSYNC_POLARITY ); +if (newhs =='-' ) + lvds |=LVDS_HSYNC_POLARITY ; +if (newvs =='-' ) + lvds |=LVDS_VSYNC_POLARITY ; + } + }I915_WRITE (lvds_reg, lvds);I915_READ (lvds_reg); }
I was going to apply this and fix it up, but got stuck at git-am ;-)
drivers/gpu/drm/i915/intel_display.c static int intel_crtc_mode_set(struct drm_crtc *crtc, · line 3337
Quoted 1 line · On Tue, 14 Dec 2010 11:38:34 -0800, [email protected] wrote:
drivers/gpu/drm/i915/intel_display.c +1
-0+/* Only tested on pineview, should work on IS_9XX */
Yes, according to the docs I've checked so far, this is true for all chipsets (and sharing the same bits).
drivers/gpu/drm/i915/intel_display.c static int intel_crtc_mode_set(struct drm_crtc *crtc, · line 3346
Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +9
-0+if (IS_PINEVIEW (dev)) { +/* Set sync polarity for case when vbios did not */ +char curhs, curvs, newhs, newvs; + curhs = (lvds &LVDS_HSYNC_POLARITY ) ?'-' :'+' ; + curvs = (lvds &LVDS_VSYNC_POLARITY ) ?'-' :'+' ; + newhs = (adjusted_mode->flags &DRM_MODE_FLAG_NHSYNC ) ? +'-' :'+' ; + newvs = (adjusted_mode->flags &DRM_MODE_FLAG_NVSYNC ) ? +'-' :'+' ;
This unusual block of code sticks out like a sore thumb. (Admittedly, the whole of intel_display.c is ugly, but we want to try and improve it over time ;-)
int lvds_sync = 0;
if (adjusted_mode->flags & DRM_MODE_FLAG_NHSYNC)
lvds_sync |= LVDS_HSYNC_POLARITY;
if (adjusted_mode->flags & DRM_MODE_FLAG_NVSYNC)
lvds_sync |= LVDS_VSYNC_POLARITY;
if (lvds & (LVDS_HSYNC_POLARITY | LVDS_VSYNC_POLARITY) != lvds_sync) {
char flags[2] = "-+";
DRM_INFO("Changing LVDS panel from (%chsync, %cvsync) to "
"(%chsync, %cvsync)\n",
flags[!(lvds & LVDS_HSYNC_POLARITY)],
flags[!(lvds & LVDS_VSYNC_POLARITY)],
flags[!(lvds_sync & LVDS_HSYNC_POLARITY)],
flags[!(lvds_sync & LVDS_VSYNC_POLARITY)]);
lvds &= ~(LVDS_HSYNC_POLARITY | LVDS_VSYNC_POLARITY);
lvds |= lvds_sync;
}-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre