Commit d0669d00 authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Daniel Vetter

drm/i915: Clean up LVDS register handling

Keep single 'lvds_reg' and 'lvds' variable around in
intel_lvds_init(), and read it just once at the start.

Also intel_lvds_get_config() doesn't need to figure out which reg to use
since it can just consult lvds_encoder->reg.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 649636ef
...@@ -98,15 +98,11 @@ static void intel_lvds_get_config(struct intel_encoder *encoder, ...@@ -98,15 +98,11 @@ static void intel_lvds_get_config(struct intel_encoder *encoder,
{ {
struct drm_device *dev = encoder->base.dev; struct drm_device *dev = encoder->base.dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
u32 lvds_reg, tmp, flags = 0; struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
u32 tmp, flags = 0;
int dotclock; int dotclock;
if (HAS_PCH_SPLIT(dev)) tmp = I915_READ(lvds_encoder->reg);
lvds_reg = PCH_LVDS;
else
lvds_reg = LVDS;
tmp = I915_READ(lvds_reg);
if (tmp & LVDS_HSYNC_POLARITY) if (tmp & LVDS_HSYNC_POLARITY)
flags |= DRM_MODE_FLAG_NHSYNC; flags |= DRM_MODE_FLAG_NHSYNC;
else else
...@@ -943,6 +939,7 @@ void intel_lvds_init(struct drm_device *dev) ...@@ -943,6 +939,7 @@ void intel_lvds_init(struct drm_device *dev)
struct drm_display_mode *downclock_mode = NULL; struct drm_display_mode *downclock_mode = NULL;
struct edid *edid; struct edid *edid;
struct drm_crtc *crtc; struct drm_crtc *crtc;
u32 lvds_reg;
u32 lvds; u32 lvds;
int pipe; int pipe;
u8 pin; u8 pin;
...@@ -965,8 +962,15 @@ void intel_lvds_init(struct drm_device *dev) ...@@ -965,8 +962,15 @@ void intel_lvds_init(struct drm_device *dev)
if (dmi_check_system(intel_no_lvds)) if (dmi_check_system(intel_no_lvds))
return; return;
if (HAS_PCH_SPLIT(dev))
lvds_reg = PCH_LVDS;
else
lvds_reg = LVDS;
lvds = I915_READ(lvds_reg);
if (HAS_PCH_SPLIT(dev)) { if (HAS_PCH_SPLIT(dev)) {
if ((I915_READ(PCH_LVDS) & LVDS_DETECTED) == 0) if ((lvds & LVDS_DETECTED) == 0)
return; return;
if (dev_priv->vbt.edp_support) { if (dev_priv->vbt.edp_support) {
DRM_DEBUG_KMS("disable LVDS for eDP support\n"); DRM_DEBUG_KMS("disable LVDS for eDP support\n");
...@@ -976,8 +980,7 @@ void intel_lvds_init(struct drm_device *dev) ...@@ -976,8 +980,7 @@ void intel_lvds_init(struct drm_device *dev)
pin = GMBUS_PIN_PANEL; pin = GMBUS_PIN_PANEL;
if (!lvds_is_present_in_vbt(dev, &pin)) { if (!lvds_is_present_in_vbt(dev, &pin)) {
u32 reg = HAS_PCH_SPLIT(dev) ? PCH_LVDS : LVDS; if ((lvds & LVDS_PORT_EN) == 0) {
if ((I915_READ(reg) & LVDS_PORT_EN) == 0) {
DRM_DEBUG_KMS("LVDS is not present in VBT\n"); DRM_DEBUG_KMS("LVDS is not present in VBT\n");
return; return;
} }
...@@ -1054,11 +1057,7 @@ void intel_lvds_init(struct drm_device *dev) ...@@ -1054,11 +1057,7 @@ void intel_lvds_init(struct drm_device *dev)
connector->interlace_allowed = false; connector->interlace_allowed = false;
connector->doublescan_allowed = false; connector->doublescan_allowed = false;
if (HAS_PCH_SPLIT(dev)) { lvds_encoder->reg = lvds_reg;
lvds_encoder->reg = PCH_LVDS;
} else {
lvds_encoder->reg = LVDS;
}
/* create the scaling mode property */ /* create the scaling mode property */
drm_mode_create_scaling_mode_property(dev); drm_mode_create_scaling_mode_property(dev);
...@@ -1139,7 +1138,6 @@ void intel_lvds_init(struct drm_device *dev) ...@@ -1139,7 +1138,6 @@ void intel_lvds_init(struct drm_device *dev)
if (HAS_PCH_SPLIT(dev)) if (HAS_PCH_SPLIT(dev))
goto failed; goto failed;
lvds = I915_READ(LVDS);
pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0; pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0;
crtc = intel_get_crtc_for_pipe(dev, pipe); crtc = intel_get_crtc_for_pipe(dev, pipe);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment