Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2006-2007 Intel Corporation |
| 3 | * Copyright (c) 2006 Dave Airlie <airlied@linux.ie> |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice (including the next |
| 13 | * paragraph) shall be included in all copies or substantial portions of the |
| 14 | * Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: |
| 25 | * Eric Anholt <eric@anholt.net> |
| 26 | * Dave Airlie <airlied@linux.ie> |
| 27 | * Jesse Barnes <jesse.barnes@intel.com> |
| 28 | */ |
| 29 | |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 30 | #include <acpi/button.h> |
Paul Collins | 565dcd4 | 2009-02-04 23:05:41 +1300 | [diff] [blame] | 31 | #include <linux/dmi.h> |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 32 | #include <linux/i2c.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 33 | #include <linux/slab.h> |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 34 | #include "drmP.h" |
| 35 | #include "drm.h" |
| 36 | #include "drm_crtc.h" |
| 37 | #include "drm_edid.h" |
| 38 | #include "intel_drv.h" |
| 39 | #include "i915_drm.h" |
| 40 | #include "i915_drv.h" |
Zhao Yakui | e99da35 | 2009-06-26 09:46:18 +0800 | [diff] [blame] | 41 | #include <linux/acpi.h> |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 42 | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 43 | /* Private structure for the integrated LVDS support */ |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 44 | struct intel_lvds { |
| 45 | struct intel_encoder base; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 46 | int fitting_mode; |
| 47 | u32 pfit_control; |
| 48 | u32 pfit_pgm_ratios; |
| 49 | }; |
| 50 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 51 | static struct intel_lvds *enc_to_intel_lvds(struct drm_encoder *encoder) |
| 52 | { |
Chris Wilson | 4ef69c7 | 2010-09-09 15:14:28 +0100 | [diff] [blame] | 53 | return container_of(encoder, struct intel_lvds, base.base); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 54 | } |
| 55 | |
Matthew Garrett | 309b1e3 | 2010-05-18 13:53:16 -0400 | [diff] [blame] | 56 | static void intel_lvds_lock_panel(struct drm_device *dev, bool lock) |
| 57 | { |
| 58 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 59 | |
| 60 | if (lock) |
| 61 | I915_WRITE(PP_CONTROL, I915_READ(PP_CONTROL) & 0x3); |
| 62 | else |
| 63 | I915_WRITE(PP_CONTROL, I915_READ(PP_CONTROL) | PANEL_UNLOCK_REGS); |
| 64 | } |
| 65 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 66 | /** |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 67 | * Sets the power state for the panel. |
| 68 | */ |
| 69 | static void intel_lvds_set_power(struct drm_device *dev, bool on) |
| 70 | { |
| 71 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 913d8d1 | 2010-08-07 11:01:35 +0100 | [diff] [blame] | 72 | u32 ctl_reg, status_reg, lvds_reg; |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 73 | |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 74 | if (HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 75 | ctl_reg = PCH_PP_CONTROL; |
| 76 | status_reg = PCH_PP_STATUS; |
Jesse Barnes | 469d129 | 2010-02-11 12:41:05 -0800 | [diff] [blame] | 77 | lvds_reg = PCH_LVDS; |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 78 | } else { |
| 79 | ctl_reg = PP_CONTROL; |
| 80 | status_reg = PP_STATUS; |
Jesse Barnes | 469d129 | 2010-02-11 12:41:05 -0800 | [diff] [blame] | 81 | lvds_reg = LVDS; |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 82 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 83 | |
| 84 | if (on) { |
Jesse Barnes | 469d129 | 2010-02-11 12:41:05 -0800 | [diff] [blame] | 85 | I915_WRITE(lvds_reg, I915_READ(lvds_reg) | LVDS_PORT_EN); |
Chris Wilson | 77d07fd | 2010-09-12 12:42:35 +0100 | [diff] [blame] | 86 | I915_WRITE(ctl_reg, I915_READ(ctl_reg) | POWER_TARGET_ON); |
Chris Wilson | a957355 | 2010-08-22 13:18:16 +0100 | [diff] [blame] | 87 | intel_panel_set_backlight(dev, dev_priv->backlight_level); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 88 | } else { |
Chris Wilson | a957355 | 2010-08-22 13:18:16 +0100 | [diff] [blame] | 89 | intel_panel_set_backlight(dev, 0); |
Chris Wilson | 77d07fd | 2010-09-12 12:42:35 +0100 | [diff] [blame] | 90 | I915_WRITE(ctl_reg, I915_READ(ctl_reg) & ~POWER_TARGET_ON); |
Jesse Barnes | 469d129 | 2010-02-11 12:41:05 -0800 | [diff] [blame] | 91 | I915_WRITE(lvds_reg, I915_READ(lvds_reg) & ~LVDS_PORT_EN); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 92 | } |
Chris Wilson | c9f9ccc | 2010-09-12 13:07:25 +0100 | [diff] [blame] | 93 | POSTING_READ(lvds_reg); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | static void intel_lvds_dpms(struct drm_encoder *encoder, int mode) |
| 97 | { |
| 98 | struct drm_device *dev = encoder->dev; |
| 99 | |
| 100 | if (mode == DRM_MODE_DPMS_ON) |
| 101 | intel_lvds_set_power(dev, true); |
| 102 | else |
| 103 | intel_lvds_set_power(dev, false); |
| 104 | |
| 105 | /* XXX: We never power down the LVDS pairs. */ |
| 106 | } |
| 107 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 108 | static int intel_lvds_mode_valid(struct drm_connector *connector, |
| 109 | struct drm_display_mode *mode) |
| 110 | { |
| 111 | struct drm_device *dev = connector->dev; |
| 112 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 113 | struct drm_display_mode *fixed_mode = dev_priv->panel_fixed_mode; |
| 114 | |
| 115 | if (fixed_mode) { |
| 116 | if (mode->hdisplay > fixed_mode->hdisplay) |
| 117 | return MODE_PANEL; |
| 118 | if (mode->vdisplay > fixed_mode->vdisplay) |
| 119 | return MODE_PANEL; |
| 120 | } |
| 121 | |
| 122 | return MODE_OK; |
| 123 | } |
| 124 | |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 125 | static void |
| 126 | centre_horizontally(struct drm_display_mode *mode, |
| 127 | int width) |
| 128 | { |
| 129 | u32 border, sync_pos, blank_width, sync_width; |
| 130 | |
| 131 | /* keep the hsync and hblank widths constant */ |
| 132 | sync_width = mode->crtc_hsync_end - mode->crtc_hsync_start; |
| 133 | blank_width = mode->crtc_hblank_end - mode->crtc_hblank_start; |
| 134 | sync_pos = (blank_width - sync_width + 1) / 2; |
| 135 | |
| 136 | border = (mode->hdisplay - width + 1) / 2; |
| 137 | border += border & 1; /* make the border even */ |
| 138 | |
| 139 | mode->crtc_hdisplay = width; |
| 140 | mode->crtc_hblank_start = width + border; |
| 141 | mode->crtc_hblank_end = mode->crtc_hblank_start + blank_width; |
| 142 | |
| 143 | mode->crtc_hsync_start = mode->crtc_hblank_start + sync_pos; |
| 144 | mode->crtc_hsync_end = mode->crtc_hsync_start + sync_width; |
| 145 | } |
| 146 | |
| 147 | static void |
| 148 | centre_vertically(struct drm_display_mode *mode, |
| 149 | int height) |
| 150 | { |
| 151 | u32 border, sync_pos, blank_width, sync_width; |
| 152 | |
| 153 | /* keep the vsync and vblank widths constant */ |
| 154 | sync_width = mode->crtc_vsync_end - mode->crtc_vsync_start; |
| 155 | blank_width = mode->crtc_vblank_end - mode->crtc_vblank_start; |
| 156 | sync_pos = (blank_width - sync_width + 1) / 2; |
| 157 | |
| 158 | border = (mode->vdisplay - height + 1) / 2; |
| 159 | |
| 160 | mode->crtc_vdisplay = height; |
| 161 | mode->crtc_vblank_start = height + border; |
| 162 | mode->crtc_vblank_end = mode->crtc_vblank_start + blank_width; |
| 163 | |
| 164 | mode->crtc_vsync_start = mode->crtc_vblank_start + sync_pos; |
| 165 | mode->crtc_vsync_end = mode->crtc_vsync_start + sync_width; |
| 166 | } |
| 167 | |
| 168 | static inline u32 panel_fitter_scaling(u32 source, u32 target) |
| 169 | { |
| 170 | /* |
| 171 | * Floating point operation is not supported. So the FACTOR |
| 172 | * is defined, which can avoid the floating point computation |
| 173 | * when calculating the panel ratio. |
| 174 | */ |
| 175 | #define ACCURACY 12 |
| 176 | #define FACTOR (1 << ACCURACY) |
| 177 | u32 ratio = source * FACTOR / target; |
| 178 | return (FACTOR * ratio + FACTOR/2) / FACTOR; |
| 179 | } |
| 180 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 181 | static bool intel_lvds_mode_fixup(struct drm_encoder *encoder, |
| 182 | struct drm_display_mode *mode, |
| 183 | struct drm_display_mode *adjusted_mode) |
| 184 | { |
| 185 | struct drm_device *dev = encoder->dev; |
| 186 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 187 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 188 | struct intel_lvds *intel_lvds = enc_to_intel_lvds(encoder); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 189 | struct drm_encoder *tmp_encoder; |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 190 | u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 191 | |
| 192 | /* Should never happen!! */ |
| 193 | if (!IS_I965G(dev) && intel_crtc->pipe == 0) { |
Keith Packard | 1ae8c0a | 2009-06-28 15:42:17 -0700 | [diff] [blame] | 194 | DRM_ERROR("Can't support LVDS on pipe A\n"); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 195 | return false; |
| 196 | } |
| 197 | |
| 198 | /* Should never happen!! */ |
| 199 | list_for_each_entry(tmp_encoder, &dev->mode_config.encoder_list, head) { |
| 200 | if (tmp_encoder != encoder && tmp_encoder->crtc == encoder->crtc) { |
Keith Packard | 1ae8c0a | 2009-06-28 15:42:17 -0700 | [diff] [blame] | 201 | DRM_ERROR("Can't enable LVDS and another " |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 202 | "encoder on the same pipe\n"); |
| 203 | return false; |
| 204 | } |
| 205 | } |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 206 | /* If we don't have a panel mode, there is nothing we can do */ |
| 207 | if (dev_priv->panel_fixed_mode == NULL) |
| 208 | return true; |
Chris Wilson | 1d8e1c7 | 2010-08-07 11:01:28 +0100 | [diff] [blame] | 209 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 210 | /* |
Chris Wilson | 7167704 | 2010-07-17 13:38:43 +0100 | [diff] [blame] | 211 | * We have timings from the BIOS for the panel, put them in |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 212 | * to the adjusted mode. The CRTC will be set up for this mode, |
| 213 | * with the panel scaling set up to source from the H/VDisplay |
| 214 | * of the original mode. |
| 215 | */ |
Chris Wilson | 1d8e1c7 | 2010-08-07 11:01:28 +0100 | [diff] [blame] | 216 | intel_fixed_panel_mode(dev_priv->panel_fixed_mode, adjusted_mode); |
| 217 | |
| 218 | if (HAS_PCH_SPLIT(dev)) { |
| 219 | intel_pch_panel_fitting(dev, intel_lvds->fitting_mode, |
| 220 | mode, adjusted_mode); |
| 221 | return true; |
| 222 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 223 | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 224 | /* Make sure pre-965s set dither correctly */ |
| 225 | if (!IS_I965G(dev)) { |
| 226 | if (dev_priv->panel_wants_dither || dev_priv->lvds_dither) |
| 227 | pfit_control |= PANEL_8TO6_DITHER_ENABLE; |
| 228 | } |
| 229 | |
| 230 | /* Native modes don't need fitting */ |
| 231 | if (adjusted_mode->hdisplay == mode->hdisplay && |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 232 | adjusted_mode->vdisplay == mode->vdisplay) |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 233 | goto out; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 234 | |
| 235 | /* 965+ wants fuzzy fitting */ |
| 236 | if (IS_I965G(dev)) |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 237 | pfit_control |= ((intel_crtc->pipe << PFIT_PIPE_SHIFT) | |
| 238 | PFIT_FILTER_FUZZY); |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 239 | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 240 | /* |
| 241 | * Enable automatic panel scaling for non-native modes so that they fill |
| 242 | * the screen. Should be enabled before the pipe is enabled, according |
| 243 | * to register description and PRM. |
| 244 | * Change the value here to see the borders for debugging |
| 245 | */ |
Chris Wilson | 1d8e1c7 | 2010-08-07 11:01:28 +0100 | [diff] [blame] | 246 | I915_WRITE(BCLRPAT_A, 0); |
| 247 | I915_WRITE(BCLRPAT_B, 0); |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 248 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 249 | switch (intel_lvds->fitting_mode) { |
Jesse Barnes | 53bd838 | 2009-07-01 10:04:40 -0700 | [diff] [blame] | 250 | case DRM_MODE_SCALE_CENTER: |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 251 | /* |
| 252 | * For centered modes, we have to calculate border widths & |
| 253 | * heights and modify the values programmed into the CRTC. |
| 254 | */ |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 255 | centre_horizontally(adjusted_mode, mode->hdisplay); |
| 256 | centre_vertically(adjusted_mode, mode->vdisplay); |
| 257 | border = LVDS_BORDER_ENABLE; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 258 | break; |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 259 | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 260 | case DRM_MODE_SCALE_ASPECT: |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 261 | /* Scale but preserve the aspect ratio */ |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 262 | if (IS_I965G(dev)) { |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 263 | u32 scaled_width = adjusted_mode->hdisplay * mode->vdisplay; |
| 264 | u32 scaled_height = mode->hdisplay * adjusted_mode->vdisplay; |
| 265 | |
| 266 | pfit_control |= PFIT_ENABLE; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 267 | /* 965+ is easy, it does everything in hw */ |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 268 | if (scaled_width > scaled_height) |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 269 | pfit_control |= PFIT_SCALING_PILLAR; |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 270 | else if (scaled_width < scaled_height) |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 271 | pfit_control |= PFIT_SCALING_LETTER; |
| 272 | else |
| 273 | pfit_control |= PFIT_SCALING_AUTO; |
| 274 | } else { |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 275 | u32 scaled_width = adjusted_mode->hdisplay * mode->vdisplay; |
| 276 | u32 scaled_height = mode->hdisplay * adjusted_mode->vdisplay; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 277 | /* |
| 278 | * For earlier chips we have to calculate the scaling |
| 279 | * ratio by hand and program it into the |
| 280 | * PFIT_PGM_RATIO register |
| 281 | */ |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 282 | if (scaled_width > scaled_height) { /* pillar */ |
| 283 | centre_horizontally(adjusted_mode, scaled_height / mode->vdisplay); |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 284 | |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 285 | border = LVDS_BORDER_ENABLE; |
| 286 | if (mode->vdisplay != adjusted_mode->vdisplay) { |
| 287 | u32 bits = panel_fitter_scaling(mode->vdisplay, adjusted_mode->vdisplay); |
| 288 | pfit_pgm_ratios |= (bits << PFIT_HORIZ_SCALE_SHIFT | |
| 289 | bits << PFIT_VERT_SCALE_SHIFT); |
| 290 | pfit_control |= (PFIT_ENABLE | |
| 291 | VERT_INTERP_BILINEAR | |
| 292 | HORIZ_INTERP_BILINEAR); |
| 293 | } |
| 294 | } else if (scaled_width < scaled_height) { /* letter */ |
| 295 | centre_vertically(adjusted_mode, scaled_width / mode->hdisplay); |
| 296 | |
| 297 | border = LVDS_BORDER_ENABLE; |
| 298 | if (mode->hdisplay != adjusted_mode->hdisplay) { |
| 299 | u32 bits = panel_fitter_scaling(mode->hdisplay, adjusted_mode->hdisplay); |
| 300 | pfit_pgm_ratios |= (bits << PFIT_HORIZ_SCALE_SHIFT | |
| 301 | bits << PFIT_VERT_SCALE_SHIFT); |
| 302 | pfit_control |= (PFIT_ENABLE | |
| 303 | VERT_INTERP_BILINEAR | |
| 304 | HORIZ_INTERP_BILINEAR); |
| 305 | } |
| 306 | } else |
| 307 | /* Aspects match, Let hw scale both directions */ |
| 308 | pfit_control |= (PFIT_ENABLE | |
| 309 | VERT_AUTO_SCALE | HORIZ_AUTO_SCALE | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 310 | VERT_INTERP_BILINEAR | |
| 311 | HORIZ_INTERP_BILINEAR); |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 312 | } |
| 313 | break; |
| 314 | |
| 315 | case DRM_MODE_SCALE_FULLSCREEN: |
| 316 | /* |
| 317 | * Full scaling, even if it changes the aspect ratio. |
| 318 | * Fortunately this is all done for us in hw. |
| 319 | */ |
| 320 | pfit_control |= PFIT_ENABLE; |
| 321 | if (IS_I965G(dev)) |
| 322 | pfit_control |= PFIT_SCALING_AUTO; |
| 323 | else |
| 324 | pfit_control |= (VERT_AUTO_SCALE | HORIZ_AUTO_SCALE | |
| 325 | VERT_INTERP_BILINEAR | |
| 326 | HORIZ_INTERP_BILINEAR); |
| 327 | break; |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 328 | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 329 | default: |
| 330 | break; |
| 331 | } |
| 332 | |
| 333 | out: |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 334 | intel_lvds->pfit_control = pfit_control; |
| 335 | intel_lvds->pfit_pgm_ratios = pfit_pgm_ratios; |
Chris Wilson | 49be663 | 2010-07-18 12:05:54 +0100 | [diff] [blame] | 336 | dev_priv->lvds_border_bits = border; |
| 337 | |
Zhao Yakui | a3e17eb | 2009-10-10 10:42:37 +0800 | [diff] [blame] | 338 | /* |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 339 | * XXX: It would be nice to support lower refresh rates on the |
| 340 | * panels to reduce power consumption, and perhaps match the |
| 341 | * user's requested refresh rate. |
| 342 | */ |
| 343 | |
| 344 | return true; |
| 345 | } |
| 346 | |
| 347 | static void intel_lvds_prepare(struct drm_encoder *encoder) |
| 348 | { |
| 349 | struct drm_device *dev = encoder->dev; |
| 350 | struct drm_i915_private *dev_priv = dev->dev_private; |
Matthew Garrett | 309b1e3 | 2010-05-18 13:53:16 -0400 | [diff] [blame] | 351 | struct intel_lvds *intel_lvds = enc_to_intel_lvds(encoder); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 352 | |
Chris Wilson | a957355 | 2010-08-22 13:18:16 +0100 | [diff] [blame] | 353 | dev_priv->backlight_level = intel_panel_get_backlight(dev); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 354 | |
Matthew Garrett | 309b1e3 | 2010-05-18 13:53:16 -0400 | [diff] [blame] | 355 | if (intel_lvds->pfit_control == I915_READ(PFIT_CONTROL)) |
| 356 | intel_lvds_lock_panel(dev, false); |
| 357 | else |
| 358 | intel_lvds_set_power(dev, false); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | static void intel_lvds_commit( struct drm_encoder *encoder) |
| 362 | { |
| 363 | struct drm_device *dev = encoder->dev; |
| 364 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 365 | |
Chris Wilson | a957355 | 2010-08-22 13:18:16 +0100 | [diff] [blame] | 366 | if (dev_priv->backlight_level == 0) |
| 367 | dev_priv->backlight_level = intel_panel_get_max_backlight(dev); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 368 | |
Matthew Garrett | 309b1e3 | 2010-05-18 13:53:16 -0400 | [diff] [blame] | 369 | if ((I915_READ(PP_CONTROL) & PANEL_UNLOCK_REGS) == PANEL_UNLOCK_REGS) |
| 370 | intel_lvds_lock_panel(dev, true); |
| 371 | else |
| 372 | intel_lvds_set_power(dev, true); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | static void intel_lvds_mode_set(struct drm_encoder *encoder, |
| 376 | struct drm_display_mode *mode, |
| 377 | struct drm_display_mode *adjusted_mode) |
| 378 | { |
| 379 | struct drm_device *dev = encoder->dev; |
| 380 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 381 | struct intel_lvds *intel_lvds = enc_to_intel_lvds(encoder); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 382 | |
| 383 | /* |
| 384 | * The LVDS pin pair will already have been turned on in the |
| 385 | * intel_crtc_mode_set since it has a large impact on the DPLL |
| 386 | * settings. |
| 387 | */ |
| 388 | |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 389 | if (HAS_PCH_SPLIT(dev)) |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 390 | return; |
| 391 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 392 | /* |
| 393 | * Enable automatic panel scaling so that non-native modes fill the |
| 394 | * screen. Should be enabled before the pipe is enabled, according to |
| 395 | * register description and PRM. |
| 396 | */ |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 397 | I915_WRITE(PFIT_PGM_RATIOS, intel_lvds->pfit_pgm_ratios); |
| 398 | I915_WRITE(PFIT_CONTROL, intel_lvds->pfit_control); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | /** |
| 402 | * Detect the LVDS connection. |
| 403 | * |
Jesse Barnes | b42d4c5 | 2009-09-10 15:28:04 -0700 | [diff] [blame] | 404 | * Since LVDS doesn't have hotlug, we use the lid as a proxy. Open means |
| 405 | * connected and closed means disconnected. We also send hotplug events as |
| 406 | * needed, using lid status notification from the input layer. |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 407 | */ |
| 408 | static enum drm_connector_status intel_lvds_detect(struct drm_connector *connector) |
| 409 | { |
Jesse Barnes | 7b9c5ab | 2010-02-12 09:30:00 -0800 | [diff] [blame] | 410 | struct drm_device *dev = connector->dev; |
Jesse Barnes | b42d4c5 | 2009-09-10 15:28:04 -0700 | [diff] [blame] | 411 | enum drm_connector_status status = connector_status_connected; |
| 412 | |
Jesse Barnes | 7b9c5ab | 2010-02-12 09:30:00 -0800 | [diff] [blame] | 413 | /* ACPI lid methods were generally unreliable in this generation, so |
| 414 | * don't even bother. |
| 415 | */ |
Eric Anholt | 6e6c822 | 2010-03-17 13:48:06 -0700 | [diff] [blame] | 416 | if (IS_GEN2(dev) || IS_GEN3(dev)) |
Jesse Barnes | 7b9c5ab | 2010-02-12 09:30:00 -0800 | [diff] [blame] | 417 | return connector_status_connected; |
| 418 | |
Jesse Barnes | b42d4c5 | 2009-09-10 15:28:04 -0700 | [diff] [blame] | 419 | return status; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | /** |
| 423 | * Return the list of DDC modes if available, or the BIOS fixed mode otherwise. |
| 424 | */ |
| 425 | static int intel_lvds_get_modes(struct drm_connector *connector) |
| 426 | { |
| 427 | struct drm_device *dev = connector->dev; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 428 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 429 | |
Zhao Yakui | bfac4d6 | 2010-04-07 17:11:22 +0800 | [diff] [blame] | 430 | if (dev_priv->lvds_edid_good) { |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 431 | struct intel_encoder *encoder = intel_attached_encoder(connector); |
| 432 | int ret = intel_ddc_get_modes(connector, encoder->ddc_bus); |
Zhao Yakui | bfac4d6 | 2010-04-07 17:11:22 +0800 | [diff] [blame] | 433 | if (ret) |
| 434 | return ret; |
| 435 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 436 | |
| 437 | /* Didn't get an EDID, so |
| 438 | * Set wide sync ranges so we get all modes |
| 439 | * handed to valid_mode for checking |
| 440 | */ |
| 441 | connector->display_info.min_vfreq = 0; |
| 442 | connector->display_info.max_vfreq = 200; |
| 443 | connector->display_info.min_hfreq = 0; |
| 444 | connector->display_info.max_hfreq = 200; |
| 445 | |
| 446 | if (dev_priv->panel_fixed_mode != NULL) { |
| 447 | struct drm_display_mode *mode; |
| 448 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 449 | mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode); |
| 450 | drm_mode_probed_add(connector, mode); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 451 | |
| 452 | return 1; |
| 453 | } |
| 454 | |
| 455 | return 0; |
| 456 | } |
| 457 | |
Thomas Bächler | 0544edf | 2010-07-02 10:44:23 +0200 | [diff] [blame] | 458 | static int intel_no_modeset_on_lid_dmi_callback(const struct dmi_system_id *id) |
| 459 | { |
| 460 | DRM_DEBUG_KMS("Skipping forced modeset for %s\n", id->ident); |
| 461 | return 1; |
| 462 | } |
| 463 | |
| 464 | /* The GPU hangs up on these systems if modeset is performed on LID open */ |
| 465 | static const struct dmi_system_id intel_no_modeset_on_lid[] = { |
| 466 | { |
| 467 | .callback = intel_no_modeset_on_lid_dmi_callback, |
| 468 | .ident = "Toshiba Tecra A11", |
| 469 | .matches = { |
| 470 | DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), |
| 471 | DMI_MATCH(DMI_PRODUCT_NAME, "TECRA A11"), |
| 472 | }, |
| 473 | }, |
| 474 | |
| 475 | { } /* terminating entry */ |
| 476 | }; |
| 477 | |
Linus Torvalds | c9354c8 | 2009-11-02 09:29:55 -0800 | [diff] [blame] | 478 | /* |
| 479 | * Lid events. Note the use of 'modeset_on_lid': |
| 480 | * - we set it on lid close, and reset it on open |
| 481 | * - we use it as a "only once" bit (ie we ignore |
| 482 | * duplicate events where it was already properly |
| 483 | * set/reset) |
| 484 | * - the suspend/resume paths will also set it to |
| 485 | * zero, since they restore the mode ("lid open"). |
| 486 | */ |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 487 | static int intel_lid_notify(struct notifier_block *nb, unsigned long val, |
| 488 | void *unused) |
| 489 | { |
| 490 | struct drm_i915_private *dev_priv = |
| 491 | container_of(nb, struct drm_i915_private, lid_notifier); |
| 492 | struct drm_device *dev = dev_priv->dev; |
Zhao Yakui | a256537 | 2009-12-11 09:26:11 +0800 | [diff] [blame] | 493 | struct drm_connector *connector = dev_priv->int_lvds_connector; |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 494 | |
Zhao Yakui | a256537 | 2009-12-11 09:26:11 +0800 | [diff] [blame] | 495 | /* |
| 496 | * check and update the status of LVDS connector after receiving |
| 497 | * the LID nofication event. |
| 498 | */ |
| 499 | if (connector) |
| 500 | connector->status = connector->funcs->detect(connector); |
Thomas Bächler | 0544edf | 2010-07-02 10:44:23 +0200 | [diff] [blame] | 501 | /* Don't force modeset on machines where it causes a GPU lockup */ |
| 502 | if (dmi_check_system(intel_no_modeset_on_lid)) |
| 503 | return NOTIFY_OK; |
Linus Torvalds | c9354c8 | 2009-11-02 09:29:55 -0800 | [diff] [blame] | 504 | if (!acpi_lid_open()) { |
| 505 | dev_priv->modeset_on_lid = 1; |
| 506 | return NOTIFY_OK; |
Jesse Barnes | 06891e2 | 2009-09-14 10:58:48 -0700 | [diff] [blame] | 507 | } |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 508 | |
Linus Torvalds | c9354c8 | 2009-11-02 09:29:55 -0800 | [diff] [blame] | 509 | if (!dev_priv->modeset_on_lid) |
| 510 | return NOTIFY_OK; |
| 511 | |
| 512 | dev_priv->modeset_on_lid = 0; |
| 513 | |
| 514 | mutex_lock(&dev->mode_config.mutex); |
| 515 | drm_helper_resume_force_mode(dev); |
| 516 | mutex_unlock(&dev->mode_config.mutex); |
Jesse Barnes | 0632419 | 2009-09-10 15:28:05 -0700 | [diff] [blame] | 517 | |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 518 | return NOTIFY_OK; |
| 519 | } |
| 520 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 521 | /** |
| 522 | * intel_lvds_destroy - unregister and free LVDS structures |
| 523 | * @connector: connector to free |
| 524 | * |
| 525 | * Unregister the DDC bus for this connector then free the driver private |
| 526 | * structure. |
| 527 | */ |
| 528 | static void intel_lvds_destroy(struct drm_connector *connector) |
| 529 | { |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 530 | struct drm_device *dev = connector->dev; |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 531 | struct drm_i915_private *dev_priv = dev->dev_private; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 532 | |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 533 | if (dev_priv->lid_notifier.notifier_call) |
| 534 | acpi_lid_notifier_unregister(&dev_priv->lid_notifier); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 535 | drm_sysfs_connector_remove(connector); |
| 536 | drm_connector_cleanup(connector); |
| 537 | kfree(connector); |
| 538 | } |
| 539 | |
Jesse Barnes | 335041e | 2009-01-22 22:22:06 +1000 | [diff] [blame] | 540 | static int intel_lvds_set_property(struct drm_connector *connector, |
| 541 | struct drm_property *property, |
| 542 | uint64_t value) |
| 543 | { |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 544 | struct drm_device *dev = connector->dev; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 545 | |
| 546 | if (property == dev->mode_config.scaling_mode_property && |
| 547 | connector->encoder) { |
| 548 | struct drm_crtc *crtc = connector->encoder->crtc; |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 549 | struct drm_encoder *encoder = connector->encoder; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 550 | struct intel_lvds *intel_lvds = enc_to_intel_lvds(encoder); |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 551 | |
Jesse Barnes | 53bd838 | 2009-07-01 10:04:40 -0700 | [diff] [blame] | 552 | if (value == DRM_MODE_SCALE_NONE) { |
| 553 | DRM_DEBUG_KMS("no scaling not supported\n"); |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 554 | return 0; |
| 555 | } |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 556 | if (intel_lvds->fitting_mode == value) { |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 557 | /* the LVDS scaling property is not changed */ |
| 558 | return 0; |
| 559 | } |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 560 | intel_lvds->fitting_mode = value; |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 561 | if (crtc && crtc->enabled) { |
| 562 | /* |
| 563 | * If the CRTC is enabled, the display will be changed |
| 564 | * according to the new panel fitting mode. |
| 565 | */ |
| 566 | drm_crtc_helper_set_mode(crtc, &crtc->mode, |
| 567 | crtc->x, crtc->y, crtc->fb); |
| 568 | } |
| 569 | } |
| 570 | |
Jesse Barnes | 335041e | 2009-01-22 22:22:06 +1000 | [diff] [blame] | 571 | return 0; |
| 572 | } |
| 573 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 574 | static const struct drm_encoder_helper_funcs intel_lvds_helper_funcs = { |
| 575 | .dpms = intel_lvds_dpms, |
| 576 | .mode_fixup = intel_lvds_mode_fixup, |
| 577 | .prepare = intel_lvds_prepare, |
| 578 | .mode_set = intel_lvds_mode_set, |
| 579 | .commit = intel_lvds_commit, |
| 580 | }; |
| 581 | |
| 582 | static const struct drm_connector_helper_funcs intel_lvds_connector_helper_funcs = { |
| 583 | .get_modes = intel_lvds_get_modes, |
| 584 | .mode_valid = intel_lvds_mode_valid, |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 585 | .best_encoder = intel_best_encoder, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 586 | }; |
| 587 | |
| 588 | static const struct drm_connector_funcs intel_lvds_connector_funcs = { |
Keith Packard | c9fb15f | 2009-05-30 20:42:28 -0700 | [diff] [blame] | 589 | .dpms = drm_helper_connector_dpms, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 590 | .detect = intel_lvds_detect, |
| 591 | .fill_modes = drm_helper_probe_single_connector_modes, |
Jesse Barnes | 335041e | 2009-01-22 22:22:06 +1000 | [diff] [blame] | 592 | .set_property = intel_lvds_set_property, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 593 | .destroy = intel_lvds_destroy, |
| 594 | }; |
| 595 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 596 | static const struct drm_encoder_funcs intel_lvds_enc_funcs = { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 597 | .destroy = intel_encoder_destroy, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 598 | }; |
| 599 | |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 600 | static int __init intel_no_lvds_dmi_callback(const struct dmi_system_id *id) |
| 601 | { |
Zhao Yakui | 8a4c47f | 2009-07-20 13:48:04 +0800 | [diff] [blame] | 602 | DRM_DEBUG_KMS("Skipping LVDS initialization for %s\n", id->ident); |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 603 | return 1; |
| 604 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 605 | |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 606 | /* These systems claim to have LVDS, but really don't */ |
Jaswinder Singh Rajput | 93c05f2 | 2009-06-04 09:41:19 +1000 | [diff] [blame] | 607 | static const struct dmi_system_id intel_no_lvds[] = { |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 608 | { |
| 609 | .callback = intel_no_lvds_dmi_callback, |
| 610 | .ident = "Apple Mac Mini (Core series)", |
| 611 | .matches = { |
Keith Packard | 98acd46 | 2009-06-14 12:31:58 -0700 | [diff] [blame] | 612 | DMI_MATCH(DMI_SYS_VENDOR, "Apple"), |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 613 | DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"), |
| 614 | }, |
| 615 | }, |
| 616 | { |
| 617 | .callback = intel_no_lvds_dmi_callback, |
| 618 | .ident = "Apple Mac Mini (Core 2 series)", |
| 619 | .matches = { |
Keith Packard | 98acd46 | 2009-06-14 12:31:58 -0700 | [diff] [blame] | 620 | DMI_MATCH(DMI_SYS_VENDOR, "Apple"), |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 621 | DMI_MATCH(DMI_PRODUCT_NAME, "Macmini2,1"), |
| 622 | }, |
| 623 | }, |
| 624 | { |
| 625 | .callback = intel_no_lvds_dmi_callback, |
| 626 | .ident = "MSI IM-945GSE-A", |
| 627 | .matches = { |
| 628 | DMI_MATCH(DMI_SYS_VENDOR, "MSI"), |
| 629 | DMI_MATCH(DMI_PRODUCT_NAME, "A9830IMS"), |
| 630 | }, |
| 631 | }, |
| 632 | { |
| 633 | .callback = intel_no_lvds_dmi_callback, |
| 634 | .ident = "Dell Studio Hybrid", |
| 635 | .matches = { |
| 636 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 637 | DMI_MATCH(DMI_PRODUCT_NAME, "Studio Hybrid 140g"), |
| 638 | }, |
| 639 | }, |
Jarod Wilson | 70aa96c | 2009-05-27 17:20:39 -0400 | [diff] [blame] | 640 | { |
| 641 | .callback = intel_no_lvds_dmi_callback, |
| 642 | .ident = "AOpen Mini PC", |
| 643 | .matches = { |
| 644 | DMI_MATCH(DMI_SYS_VENDOR, "AOpen"), |
| 645 | DMI_MATCH(DMI_PRODUCT_NAME, "i965GMx-IF"), |
| 646 | }, |
| 647 | }, |
Michael Cousin | fa0864b | 2009-06-05 21:16:22 +0200 | [diff] [blame] | 648 | { |
| 649 | .callback = intel_no_lvds_dmi_callback, |
Tormod Volden | ed8c754 | 2009-07-13 22:26:48 +0200 | [diff] [blame] | 650 | .ident = "AOpen Mini PC MP915", |
| 651 | .matches = { |
| 652 | DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"), |
| 653 | DMI_MATCH(DMI_BOARD_NAME, "i915GMx-F"), |
| 654 | }, |
| 655 | }, |
| 656 | { |
| 657 | .callback = intel_no_lvds_dmi_callback, |
Michael Cousin | fa0864b | 2009-06-05 21:16:22 +0200 | [diff] [blame] | 658 | .ident = "Aopen i945GTt-VFA", |
| 659 | .matches = { |
| 660 | DMI_MATCH(DMI_PRODUCT_VERSION, "AO00001JW"), |
| 661 | }, |
| 662 | }, |
Stefan Bader | 9875557 | 2010-03-29 17:53:12 +0200 | [diff] [blame] | 663 | { |
| 664 | .callback = intel_no_lvds_dmi_callback, |
| 665 | .ident = "Clientron U800", |
| 666 | .matches = { |
| 667 | DMI_MATCH(DMI_SYS_VENDOR, "Clientron"), |
| 668 | DMI_MATCH(DMI_PRODUCT_NAME, "U800"), |
| 669 | }, |
| 670 | }, |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 671 | |
| 672 | { } /* terminating entry */ |
| 673 | }; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 674 | |
| 675 | /** |
Zhao Yakui | 18f9ed1 | 2009-11-20 03:24:16 +0000 | [diff] [blame] | 676 | * intel_find_lvds_downclock - find the reduced downclock for LVDS in EDID |
| 677 | * @dev: drm device |
| 678 | * @connector: LVDS connector |
| 679 | * |
| 680 | * Find the reduced downclock for LVDS in EDID. |
| 681 | */ |
| 682 | static void intel_find_lvds_downclock(struct drm_device *dev, |
| 683 | struct drm_connector *connector) |
| 684 | { |
| 685 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 686 | struct drm_display_mode *scan, *panel_fixed_mode; |
| 687 | int temp_downclock; |
| 688 | |
| 689 | panel_fixed_mode = dev_priv->panel_fixed_mode; |
| 690 | temp_downclock = panel_fixed_mode->clock; |
| 691 | |
| 692 | mutex_lock(&dev->mode_config.mutex); |
| 693 | list_for_each_entry(scan, &connector->probed_modes, head) { |
| 694 | /* |
| 695 | * If one mode has the same resolution with the fixed_panel |
| 696 | * mode while they have the different refresh rate, it means |
| 697 | * that the reduced downclock is found for the LVDS. In such |
| 698 | * case we can set the different FPx0/1 to dynamically select |
| 699 | * between low and high frequency. |
| 700 | */ |
| 701 | if (scan->hdisplay == panel_fixed_mode->hdisplay && |
| 702 | scan->hsync_start == panel_fixed_mode->hsync_start && |
| 703 | scan->hsync_end == panel_fixed_mode->hsync_end && |
| 704 | scan->htotal == panel_fixed_mode->htotal && |
| 705 | scan->vdisplay == panel_fixed_mode->vdisplay && |
| 706 | scan->vsync_start == panel_fixed_mode->vsync_start && |
| 707 | scan->vsync_end == panel_fixed_mode->vsync_end && |
| 708 | scan->vtotal == panel_fixed_mode->vtotal) { |
| 709 | if (scan->clock < temp_downclock) { |
| 710 | /* |
| 711 | * The downclock is already found. But we |
| 712 | * expect to find the lower downclock. |
| 713 | */ |
| 714 | temp_downclock = scan->clock; |
| 715 | } |
| 716 | } |
| 717 | } |
| 718 | mutex_unlock(&dev->mode_config.mutex); |
Jesse Barnes | 3381434 | 2010-01-14 20:48:02 +0000 | [diff] [blame] | 719 | if (temp_downclock < panel_fixed_mode->clock && |
| 720 | i915_lvds_downclock) { |
Zhao Yakui | 18f9ed1 | 2009-11-20 03:24:16 +0000 | [diff] [blame] | 721 | /* We found the downclock for LVDS. */ |
| 722 | dev_priv->lvds_downclock_avail = 1; |
| 723 | dev_priv->lvds_downclock = temp_downclock; |
| 724 | DRM_DEBUG_KMS("LVDS downclock is found in EDID. " |
| 725 | "Normal clock %dKhz, downclock %dKhz\n", |
| 726 | panel_fixed_mode->clock, temp_downclock); |
| 727 | } |
| 728 | return; |
| 729 | } |
| 730 | |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 731 | /* |
| 732 | * Enumerate the child dev array parsed from VBT to check whether |
| 733 | * the LVDS is present. |
| 734 | * If it is present, return 1. |
| 735 | * If it is not present, return false. |
| 736 | * If no child dev is parsed from VBT, it assumes that the LVDS is present. |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 737 | */ |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 738 | static bool lvds_is_present_in_vbt(struct drm_device *dev) |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 739 | { |
| 740 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 741 | int i; |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 742 | |
| 743 | if (!dev_priv->child_dev_num) |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 744 | return true; |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 745 | |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 746 | for (i = 0; i < dev_priv->child_dev_num; i++) { |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 747 | struct child_device_config *child = dev_priv->child_dev + i; |
| 748 | |
| 749 | /* If the device type is not LFP, continue. |
| 750 | * We have to check both the new identifiers as well as the |
| 751 | * old for compatibility with some BIOSes. |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 752 | */ |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 753 | if (child->device_type != DEVICE_TYPE_INT_LFP && |
| 754 | child->device_type != DEVICE_TYPE_LFP) |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 755 | continue; |
| 756 | |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 757 | /* However, we cannot trust the BIOS writers to populate |
| 758 | * the VBT correctly. Since LVDS requires additional |
| 759 | * information from AIM blocks, a non-zero addin offset is |
| 760 | * a good indicator that the LVDS is actually present. |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 761 | */ |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 762 | if (child->addin_offset) |
| 763 | return true; |
| 764 | |
| 765 | /* But even then some BIOS writers perform some black magic |
| 766 | * and instantiate the device without reference to any |
| 767 | * additional data. Trust that if the VBT was written into |
| 768 | * the OpRegion then they have validated the LVDS's existence. |
| 769 | */ |
| 770 | if (dev_priv->opregion.vbt) |
| 771 | return true; |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 772 | } |
Chris Wilson | 425904d | 2010-08-22 18:21:42 +0100 | [diff] [blame] | 773 | |
| 774 | return false; |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 775 | } |
| 776 | |
Zhao Yakui | 18f9ed1 | 2009-11-20 03:24:16 +0000 | [diff] [blame] | 777 | /** |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 778 | * intel_lvds_init - setup LVDS connectors on this device |
| 779 | * @dev: drm device |
| 780 | * |
| 781 | * Create the connector, register the LVDS DDC bus, and try to figure out what |
| 782 | * modes we can display on the LVDS panel (if present). |
| 783 | */ |
| 784 | void intel_lvds_init(struct drm_device *dev) |
| 785 | { |
| 786 | struct drm_i915_private *dev_priv = dev->dev_private; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 787 | struct intel_lvds *intel_lvds; |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 788 | struct intel_encoder *intel_encoder; |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 789 | struct intel_connector *intel_connector; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 790 | struct drm_connector *connector; |
| 791 | struct drm_encoder *encoder; |
| 792 | struct drm_display_mode *scan; /* *modes, *bios_mode; */ |
| 793 | struct drm_crtc *crtc; |
| 794 | u32 lvds; |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 795 | int pipe, gpio = GPIOC; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 796 | |
Jarod Wilson | 425d244 | 2009-05-05 10:00:25 -0400 | [diff] [blame] | 797 | /* Skip init on machines we know falsely report LVDS */ |
| 798 | if (dmi_check_system(intel_no_lvds)) |
Paul Collins | 565dcd4 | 2009-02-04 23:05:41 +1300 | [diff] [blame] | 799 | return; |
Paul Collins | 565dcd4 | 2009-02-04 23:05:41 +1300 | [diff] [blame] | 800 | |
Matthew Garrett | 11ba159 | 2009-12-15 13:55:24 -0500 | [diff] [blame] | 801 | if (!lvds_is_present_in_vbt(dev)) { |
| 802 | DRM_DEBUG_KMS("LVDS is not present in VBT\n"); |
Zhao Yakui | e99da35 | 2009-06-26 09:46:18 +0800 | [diff] [blame] | 803 | return; |
Zhao Yakui | 7cf4f69 | 2009-11-24 09:48:47 +0800 | [diff] [blame] | 804 | } |
Zhao Yakui | e99da35 | 2009-06-26 09:46:18 +0800 | [diff] [blame] | 805 | |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 806 | if (HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 807 | if ((I915_READ(PCH_LVDS) & LVDS_DETECTED) == 0) |
| 808 | return; |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 809 | if (dev_priv->edp_support) { |
Zhao Yakui | 28c9773 | 2009-10-09 11:39:41 +0800 | [diff] [blame] | 810 | DRM_DEBUG_KMS("disable LVDS for eDP support\n"); |
Zhenyu Wang | 32f9d65 | 2009-07-24 01:00:32 +0800 | [diff] [blame] | 811 | return; |
| 812 | } |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 813 | gpio = PCH_GPIOC; |
| 814 | } |
| 815 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 816 | intel_lvds = kzalloc(sizeof(struct intel_lvds), GFP_KERNEL); |
| 817 | if (!intel_lvds) { |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 818 | return; |
| 819 | } |
| 820 | |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 821 | intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); |
| 822 | if (!intel_connector) { |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 823 | kfree(intel_lvds); |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 824 | return; |
| 825 | } |
| 826 | |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 827 | intel_encoder = &intel_lvds->base; |
Chris Wilson | 4ef69c7 | 2010-09-09 15:14:28 +0100 | [diff] [blame] | 828 | encoder = &intel_encoder->base; |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 829 | connector = &intel_connector->base; |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 830 | drm_connector_init(dev, &intel_connector->base, &intel_lvds_connector_funcs, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 831 | DRM_MODE_CONNECTOR_LVDS); |
| 832 | |
Chris Wilson | 4ef69c7 | 2010-09-09 15:14:28 +0100 | [diff] [blame] | 833 | drm_encoder_init(dev, &intel_encoder->base, &intel_lvds_enc_funcs, |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 834 | DRM_MODE_ENCODER_LVDS); |
| 835 | |
Chris Wilson | df0e924 | 2010-09-09 16:20:55 +0100 | [diff] [blame] | 836 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 837 | intel_encoder->type = INTEL_OUTPUT_LVDS; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 838 | |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 839 | intel_encoder->clone_mask = (1 << INTEL_LVDS_CLONE_BIT); |
| 840 | intel_encoder->crtc_mask = (1 << 1); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 841 | drm_encoder_helper_add(encoder, &intel_lvds_helper_funcs); |
| 842 | drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs); |
| 843 | connector->display_info.subpixel_order = SubPixelHorizontalRGB; |
| 844 | connector->interlace_allowed = false; |
| 845 | connector->doublescan_allowed = false; |
| 846 | |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 847 | /* create the scaling mode property */ |
| 848 | drm_mode_create_scaling_mode_property(dev); |
| 849 | /* |
| 850 | * the initial panel fitting mode will be FULL_SCREEN. |
| 851 | */ |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 852 | |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 853 | drm_connector_attach_property(&intel_connector->base, |
Zhao Yakui | 3fbe18d | 2009-06-22 15:31:25 +0800 | [diff] [blame] | 854 | dev->mode_config.scaling_mode_property, |
Jesse Barnes | dd1ea37 | 2010-06-24 11:05:10 -0700 | [diff] [blame] | 855 | DRM_MODE_SCALE_ASPECT); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 856 | intel_lvds->fitting_mode = DRM_MODE_SCALE_ASPECT; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 857 | /* |
| 858 | * LVDS discovery: |
| 859 | * 1) check for EDID on DDC |
| 860 | * 2) check for VBT data |
| 861 | * 3) check to see if LVDS is already on |
| 862 | * if none of the above, no panel |
| 863 | * 4) make sure lid is open |
| 864 | * if closed, act like it's not there for now |
| 865 | */ |
| 866 | |
| 867 | /* Set up the DDC bus. */ |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 868 | intel_encoder->ddc_bus = intel_i2c_create(dev, gpio, "LVDSDDC_C"); |
| 869 | if (!intel_encoder->ddc_bus) { |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 870 | dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " |
| 871 | "failed.\n"); |
| 872 | goto failed; |
| 873 | } |
| 874 | |
| 875 | /* |
| 876 | * Attempt to get the fixed panel mode from DDC. Assume that the |
| 877 | * preferred mode is the right one. |
| 878 | */ |
Zhao Yakui | bfac4d6 | 2010-04-07 17:11:22 +0800 | [diff] [blame] | 879 | dev_priv->lvds_edid_good = true; |
| 880 | |
Zhenyu Wang | 335af9a | 2010-03-30 14:39:31 +0800 | [diff] [blame] | 881 | if (!intel_ddc_get_modes(connector, intel_encoder->ddc_bus)) |
Zhao Yakui | bfac4d6 | 2010-04-07 17:11:22 +0800 | [diff] [blame] | 882 | dev_priv->lvds_edid_good = false; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 883 | |
| 884 | list_for_each_entry(scan, &connector->probed_modes, head) { |
| 885 | mutex_lock(&dev->mode_config.mutex); |
| 886 | if (scan->type & DRM_MODE_TYPE_PREFERRED) { |
| 887 | dev_priv->panel_fixed_mode = |
| 888 | drm_mode_duplicate(dev, scan); |
| 889 | mutex_unlock(&dev->mode_config.mutex); |
Zhao Yakui | 18f9ed1 | 2009-11-20 03:24:16 +0000 | [diff] [blame] | 890 | intel_find_lvds_downclock(dev, connector); |
Paul Collins | 565dcd4 | 2009-02-04 23:05:41 +1300 | [diff] [blame] | 891 | goto out; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 892 | } |
| 893 | mutex_unlock(&dev->mode_config.mutex); |
| 894 | } |
| 895 | |
| 896 | /* Failed to get EDID, what about VBT? */ |
Ma Ling | 8863170 | 2009-05-13 11:19:55 +0800 | [diff] [blame] | 897 | if (dev_priv->lfp_lvds_vbt_mode) { |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 898 | mutex_lock(&dev->mode_config.mutex); |
| 899 | dev_priv->panel_fixed_mode = |
Ma Ling | 8863170 | 2009-05-13 11:19:55 +0800 | [diff] [blame] | 900 | drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 901 | mutex_unlock(&dev->mode_config.mutex); |
Jesse Barnes | e285f3c | 2009-01-14 10:53:36 -0800 | [diff] [blame] | 902 | if (dev_priv->panel_fixed_mode) { |
| 903 | dev_priv->panel_fixed_mode->type |= |
| 904 | DRM_MODE_TYPE_PREFERRED; |
Jesse Barnes | e285f3c | 2009-01-14 10:53:36 -0800 | [diff] [blame] | 905 | goto out; |
| 906 | } |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 907 | } |
| 908 | |
| 909 | /* |
| 910 | * If we didn't get EDID, try checking if the panel is already turned |
| 911 | * on. If so, assume that whatever is currently programmed is the |
| 912 | * correct mode. |
| 913 | */ |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 914 | |
Adam Jackson | f2b115e | 2009-12-03 17:14:42 -0500 | [diff] [blame] | 915 | /* Ironlake: FIXME if still fail, not try pipe mode now */ |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 916 | if (HAS_PCH_SPLIT(dev)) |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 917 | goto failed; |
| 918 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 919 | lvds = I915_READ(LVDS); |
| 920 | pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0; |
Chris Wilson | f875c15 | 2010-09-09 15:44:14 +0100 | [diff] [blame] | 921 | crtc = intel_get_crtc_for_pipe(dev, pipe); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 922 | |
| 923 | if (crtc && (lvds & LVDS_PORT_EN)) { |
| 924 | dev_priv->panel_fixed_mode = intel_crtc_mode_get(dev, crtc); |
| 925 | if (dev_priv->panel_fixed_mode) { |
| 926 | dev_priv->panel_fixed_mode->type |= |
| 927 | DRM_MODE_TYPE_PREFERRED; |
Paul Collins | 565dcd4 | 2009-02-04 23:05:41 +1300 | [diff] [blame] | 928 | goto out; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 929 | } |
| 930 | } |
| 931 | |
| 932 | /* If we still don't have a mode after all that, give up. */ |
| 933 | if (!dev_priv->panel_fixed_mode) |
| 934 | goto failed; |
| 935 | |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 936 | out: |
Eric Anholt | c619eed | 2010-01-28 16:45:52 -0800 | [diff] [blame] | 937 | if (HAS_PCH_SPLIT(dev)) { |
Zhenyu Wang | 541998a | 2009-06-05 15:38:44 +0800 | [diff] [blame] | 938 | u32 pwm; |
| 939 | /* make sure PWM is enabled */ |
| 940 | pwm = I915_READ(BLC_PWM_CPU_CTL2); |
| 941 | pwm |= (PWM_ENABLE | PWM_PIPE_B); |
| 942 | I915_WRITE(BLC_PWM_CPU_CTL2, pwm); |
| 943 | |
| 944 | pwm = I915_READ(BLC_PWM_PCH_CTL1); |
| 945 | pwm |= PWM_PCH_ENABLE; |
| 946 | I915_WRITE(BLC_PWM_PCH_CTL1, pwm); |
| 947 | } |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 948 | dev_priv->lid_notifier.notifier_call = intel_lid_notify; |
| 949 | if (acpi_lid_notifier_register(&dev_priv->lid_notifier)) { |
Zhao Yakui | 28c9773 | 2009-10-09 11:39:41 +0800 | [diff] [blame] | 950 | DRM_DEBUG_KMS("lid notifier registration failed\n"); |
Jesse Barnes | c1c7af6 | 2009-09-10 15:28:03 -0700 | [diff] [blame] | 951 | dev_priv->lid_notifier.notifier_call = NULL; |
| 952 | } |
Zhao Yakui | a256537 | 2009-12-11 09:26:11 +0800 | [diff] [blame] | 953 | /* keep the LVDS connector */ |
| 954 | dev_priv->int_lvds_connector = connector; |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 955 | drm_sysfs_connector_add(connector); |
| 956 | return; |
| 957 | |
| 958 | failed: |
Zhao Yakui | 8a4c47f | 2009-07-20 13:48:04 +0800 | [diff] [blame] | 959 | DRM_DEBUG_KMS("No LVDS modes found, disabling.\n"); |
Eric Anholt | 21d40d3 | 2010-03-25 11:11:14 -0700 | [diff] [blame] | 960 | if (intel_encoder->ddc_bus) |
| 961 | intel_i2c_destroy(intel_encoder->ddc_bus); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 962 | drm_connector_cleanup(connector); |
Shaohua Li | 1991bdf | 2009-11-17 17:19:23 +0800 | [diff] [blame] | 963 | drm_encoder_cleanup(encoder); |
Chris Wilson | ea5b213 | 2010-08-04 13:50:23 +0100 | [diff] [blame] | 964 | kfree(intel_lvds); |
Zhenyu Wang | bb8a356 | 2010-03-29 16:40:50 +0800 | [diff] [blame] | 965 | kfree(intel_connector); |
Jesse Barnes | 79e5394 | 2008-11-07 14:24:08 -0800 | [diff] [blame] | 966 | } |