blob: 23126023aeba04e6819d9ad1fdd64f2b8d69b646 [file] [log] [blame]
Jesse Barnes79e53942008-11-07 14:24:08 -08001/*
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 Barnesc1c7af62009-09-10 15:28:03 -070030#include <acpi/button.h>
Paul Collins565dcd42009-02-04 23:05:41 +130031#include <linux/dmi.h>
Jesse Barnes79e53942008-11-07 14:24:08 -080032#include <linux/i2c.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090033#include <linux/slab.h>
David Howells760285e2012-10-02 18:01:07 +010034#include <drm/drmP.h>
35#include <drm/drm_crtc.h>
36#include <drm/drm_edid.h>
Jesse Barnes79e53942008-11-07 14:24:08 -080037#include "intel_drv.h"
David Howells760285e2012-10-02 18:01:07 +010038#include <drm/i915_drm.h>
Jesse Barnes79e53942008-11-07 14:24:08 -080039#include "i915_drv.h"
Zhao Yakuie99da352009-06-26 09:46:18 +080040#include <linux/acpi.h>
Jesse Barnes79e53942008-11-07 14:24:08 -080041
Zhao Yakui3fbe18d2009-06-22 15:31:25 +080042/* Private structure for the integrated LVDS support */
Jani Nikulac7362c42012-10-19 14:51:44 +030043struct intel_lvds_connector {
44 struct intel_connector base;
Jani Nikuladb1740a2012-10-19 14:51:45 +030045
46 struct notifier_block lid_notifier;
Jani Nikulac7362c42012-10-19 14:51:44 +030047};
48
Jani Nikula29b99b42012-10-19 14:51:43 +030049struct intel_lvds_encoder {
Chris Wilsonea5b2132010-08-04 13:50:23 +010050 struct intel_encoder base;
Chris Wilson788319d2010-09-12 17:34:41 +010051
Daniel Vetter13c7d872012-11-26 17:22:10 +010052 bool is_dual_link;
Daniel Vetter7dec0602012-09-11 14:12:25 +020053 u32 reg;
Chris Wilson788319d2010-09-12 17:34:41 +010054
Jani Nikula62165e02012-10-19 14:51:47 +030055 struct intel_lvds_connector *attached_connector;
Zhao Yakui3fbe18d2009-06-22 15:31:25 +080056};
57
Jani Nikula29b99b42012-10-19 14:51:43 +030058static struct intel_lvds_encoder *to_lvds_encoder(struct drm_encoder *encoder)
Chris Wilsonea5b2132010-08-04 13:50:23 +010059{
Jani Nikula29b99b42012-10-19 14:51:43 +030060 return container_of(encoder, struct intel_lvds_encoder, base.base);
Chris Wilsonea5b2132010-08-04 13:50:23 +010061}
62
Jani Nikulac7362c42012-10-19 14:51:44 +030063static struct intel_lvds_connector *to_lvds_connector(struct drm_connector *connector)
Chris Wilson788319d2010-09-12 17:34:41 +010064{
Jani Nikulac7362c42012-10-19 14:51:44 +030065 return container_of(connector, struct intel_lvds_connector, base.base);
Chris Wilson788319d2010-09-12 17:34:41 +010066}
67
Daniel Vetterb1dc3322012-07-02 21:09:00 +020068static bool intel_lvds_get_hw_state(struct intel_encoder *encoder,
69 enum pipe *pipe)
70{
71 struct drm_device *dev = encoder->base.dev;
72 struct drm_i915_private *dev_priv = dev->dev_private;
Daniel Vetter7dec0602012-09-11 14:12:25 +020073 struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
74 u32 tmp;
Daniel Vetterb1dc3322012-07-02 21:09:00 +020075
Daniel Vetter7dec0602012-09-11 14:12:25 +020076 tmp = I915_READ(lvds_encoder->reg);
Daniel Vetterb1dc3322012-07-02 21:09:00 +020077
78 if (!(tmp & LVDS_PORT_EN))
79 return false;
80
81 if (HAS_PCH_CPT(dev))
82 *pipe = PORT_TO_PIPE_CPT(tmp);
83 else
84 *pipe = PORT_TO_PIPE(tmp);
85
86 return true;
87}
88
Jesse Barnes045ac3b2013-05-14 17:08:26 -070089static void intel_lvds_get_config(struct intel_encoder *encoder,
90 struct intel_crtc_config *pipe_config)
91{
92 struct drm_device *dev = encoder->base.dev;
93 struct drm_i915_private *dev_priv = dev->dev_private;
94 u32 lvds_reg, tmp, flags = 0;
Ville Syrjälä18442d02013-09-13 16:00:08 +030095 int dotclock;
Jesse Barnes045ac3b2013-05-14 17:08:26 -070096
97 if (HAS_PCH_SPLIT(dev))
98 lvds_reg = PCH_LVDS;
99 else
100 lvds_reg = LVDS;
101
102 tmp = I915_READ(lvds_reg);
103 if (tmp & LVDS_HSYNC_POLARITY)
104 flags |= DRM_MODE_FLAG_NHSYNC;
105 else
106 flags |= DRM_MODE_FLAG_PHSYNC;
107 if (tmp & LVDS_VSYNC_POLARITY)
108 flags |= DRM_MODE_FLAG_NVSYNC;
109 else
110 flags |= DRM_MODE_FLAG_PVSYNC;
111
112 pipe_config->adjusted_mode.flags |= flags;
Daniel Vetter06922822013-07-11 13:35:40 +0200113
Ville Syrjälä18442d02013-09-13 16:00:08 +0300114 dotclock = pipe_config->port_clock;
115
116 if (HAS_PCH_SPLIT(dev_priv->dev))
117 ironlake_check_encoder_dotclock(pipe_config, dotclock);
118
Damien Lespiau241bfc32013-09-25 16:45:37 +0100119 pipe_config->adjusted_mode.crtc_clock = dotclock;
Jesse Barnes045ac3b2013-05-14 17:08:26 -0700120}
121
Daniel Vetterf6736a12013-06-05 13:34:30 +0200122static void intel_pre_enable_lvds(struct intel_encoder *encoder)
Daniel Vetterfc683092012-11-26 17:22:12 +0100123{
124 struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
125 struct drm_device *dev = encoder->base.dev;
126 struct drm_i915_private *dev_priv = dev->dev_private;
Daniel Vetter55607e82013-06-16 21:42:39 +0200127 struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
Ville Syrjälä4c6df4b2013-09-02 21:13:39 +0300128 const struct drm_display_mode *adjusted_mode =
129 &crtc->config.adjusted_mode;
Daniel Vetter55607e82013-06-16 21:42:39 +0200130 int pipe = crtc->pipe;
Daniel Vetterfc683092012-11-26 17:22:12 +0100131 u32 temp;
132
Daniel Vetter55607e82013-06-16 21:42:39 +0200133 if (HAS_PCH_SPLIT(dev)) {
134 assert_fdi_rx_pll_disabled(dev_priv, pipe);
135 assert_shared_dpll_disabled(dev_priv,
136 intel_crtc_to_shared_dpll(crtc));
137 } else {
138 assert_pll_disabled(dev_priv, pipe);
139 }
140
Daniel Vetterfc683092012-11-26 17:22:12 +0100141 temp = I915_READ(lvds_encoder->reg);
142 temp |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP;
Daniel Vetter62810e52012-11-26 17:22:13 +0100143
144 if (HAS_PCH_CPT(dev)) {
145 temp &= ~PORT_TRANS_SEL_MASK;
146 temp |= PORT_TRANS_SEL_CPT(pipe);
Daniel Vetterfc683092012-11-26 17:22:12 +0100147 } else {
Daniel Vetter62810e52012-11-26 17:22:13 +0100148 if (pipe == 1) {
149 temp |= LVDS_PIPEB_SELECT;
150 } else {
151 temp &= ~LVDS_PIPEB_SELECT;
152 }
Daniel Vetterfc683092012-11-26 17:22:12 +0100153 }
Daniel Vetter62810e52012-11-26 17:22:13 +0100154
Daniel Vetterfc683092012-11-26 17:22:12 +0100155 /* set the corresponsding LVDS_BORDER bit */
Daniel Vetter2fa2fe92013-05-07 23:34:16 +0200156 temp &= ~LVDS_BORDER_ENABLE;
Daniel Vetter55607e82013-06-16 21:42:39 +0200157 temp |= crtc->config.gmch_pfit.lvds_border_bits;
Daniel Vetterfc683092012-11-26 17:22:12 +0100158 /* Set the B0-B3 data pairs corresponding to whether we're going to
159 * set the DPLLs for dual-channel mode or not.
160 */
161 if (lvds_encoder->is_dual_link)
162 temp |= LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP;
163 else
164 temp &= ~(LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP);
165
166 /* It would be nice to set 24 vs 18-bit mode (LVDS_A3_POWER_UP)
167 * appropriately here, but we need to look more thoroughly into how
168 * panels behave in the two modes.
169 */
Daniel Vetter62810e52012-11-26 17:22:13 +0100170
171 /* Set the dithering flag on LVDS as needed, note that there is no
172 * special lvds dither control bit on pch-split platforms, dithering is
173 * only controlled through the PIPECONF reg. */
174 if (INTEL_INFO(dev)->gen == 4) {
Daniel Vetterd8b32242013-04-25 17:54:44 +0200175 /* Bspec wording suggests that LVDS port dithering only exists
176 * for 18bpp panels. */
Daniel Vetter55607e82013-06-16 21:42:39 +0200177 if (crtc->config.dither && crtc->config.pipe_bpp == 18)
Daniel Vetterfc683092012-11-26 17:22:12 +0100178 temp |= LVDS_ENABLE_DITHER;
179 else
180 temp &= ~LVDS_ENABLE_DITHER;
181 }
182 temp &= ~(LVDS_HSYNC_POLARITY | LVDS_VSYNC_POLARITY);
Ville Syrjälä4c6df4b2013-09-02 21:13:39 +0300183 if (adjusted_mode->flags & DRM_MODE_FLAG_NHSYNC)
Daniel Vetterfc683092012-11-26 17:22:12 +0100184 temp |= LVDS_HSYNC_POLARITY;
Ville Syrjälä4c6df4b2013-09-02 21:13:39 +0300185 if (adjusted_mode->flags & DRM_MODE_FLAG_NVSYNC)
Daniel Vetterfc683092012-11-26 17:22:12 +0100186 temp |= LVDS_VSYNC_POLARITY;
187
188 I915_WRITE(lvds_encoder->reg, temp);
189}
190
Jesse Barnes79e53942008-11-07 14:24:08 -0800191/**
Jesse Barnes79e53942008-11-07 14:24:08 -0800192 * Sets the power state for the panel.
193 */
Daniel Vetterc22834e2012-06-30 15:31:28 +0200194static void intel_enable_lvds(struct intel_encoder *encoder)
Jesse Barnes79e53942008-11-07 14:24:08 -0800195{
Daniel Vetterc22834e2012-06-30 15:31:28 +0200196 struct drm_device *dev = encoder->base.dev;
Jani Nikula29b99b42012-10-19 14:51:43 +0300197 struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
Jesse Barnes752aa882013-10-31 18:55:49 +0200198 struct intel_connector *intel_connector =
199 &lvds_encoder->attached_connector->base;
Jesse Barnes79e53942008-11-07 14:24:08 -0800200 struct drm_i915_private *dev_priv = dev->dev_private;
Daniel Vetter7dec0602012-09-11 14:12:25 +0200201 u32 ctl_reg, stat_reg;
Zhenyu Wang541998a2009-06-05 15:38:44 +0800202
Eric Anholtc619eed2010-01-28 16:45:52 -0800203 if (HAS_PCH_SPLIT(dev)) {
Zhenyu Wang541998a2009-06-05 15:38:44 +0800204 ctl_reg = PCH_PP_CONTROL;
Keith Packardde842ef2011-08-06 10:30:45 -0700205 stat_reg = PCH_PP_STATUS;
Zhenyu Wang541998a2009-06-05 15:38:44 +0800206 } else {
207 ctl_reg = PP_CONTROL;
Keith Packardde842ef2011-08-06 10:30:45 -0700208 stat_reg = PP_STATUS;
Zhenyu Wang541998a2009-06-05 15:38:44 +0800209 }
Jesse Barnes79e53942008-11-07 14:24:08 -0800210
Daniel Vetter7dec0602012-09-11 14:12:25 +0200211 I915_WRITE(lvds_encoder->reg, I915_READ(lvds_encoder->reg) | LVDS_PORT_EN);
Chris Wilsone9e331a2010-09-13 01:16:10 +0100212
Chris Wilson2a1292f2010-12-05 19:21:18 +0000213 I915_WRITE(ctl_reg, I915_READ(ctl_reg) | POWER_TARGET_ON);
Daniel Vetter7dec0602012-09-11 14:12:25 +0200214 POSTING_READ(lvds_encoder->reg);
Keith Packardde842ef2011-08-06 10:30:45 -0700215 if (wait_for((I915_READ(stat_reg) & PP_ON) != 0, 1000))
216 DRM_ERROR("timed out waiting for panel to power on\n");
Chris Wilson2a1292f2010-12-05 19:21:18 +0000217
Jesse Barnes752aa882013-10-31 18:55:49 +0200218 intel_panel_enable_backlight(intel_connector);
Chris Wilson2a1292f2010-12-05 19:21:18 +0000219}
220
Daniel Vetterc22834e2012-06-30 15:31:28 +0200221static void intel_disable_lvds(struct intel_encoder *encoder)
Chris Wilson2a1292f2010-12-05 19:21:18 +0000222{
Daniel Vetterc22834e2012-06-30 15:31:28 +0200223 struct drm_device *dev = encoder->base.dev;
Jani Nikula29b99b42012-10-19 14:51:43 +0300224 struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
Jesse Barnes752aa882013-10-31 18:55:49 +0200225 struct intel_connector *intel_connector =
226 &lvds_encoder->attached_connector->base;
Chris Wilson2a1292f2010-12-05 19:21:18 +0000227 struct drm_i915_private *dev_priv = dev->dev_private;
Daniel Vetter7dec0602012-09-11 14:12:25 +0200228 u32 ctl_reg, stat_reg;
Chris Wilson2a1292f2010-12-05 19:21:18 +0000229
230 if (HAS_PCH_SPLIT(dev)) {
231 ctl_reg = PCH_PP_CONTROL;
Keith Packardde842ef2011-08-06 10:30:45 -0700232 stat_reg = PCH_PP_STATUS;
Chris Wilson2a1292f2010-12-05 19:21:18 +0000233 } else {
234 ctl_reg = PP_CONTROL;
Keith Packardde842ef2011-08-06 10:30:45 -0700235 stat_reg = PP_STATUS;
Chris Wilson2a1292f2010-12-05 19:21:18 +0000236 }
237
Jesse Barnes752aa882013-10-31 18:55:49 +0200238 intel_panel_disable_backlight(intel_connector);
Chris Wilson2a1292f2010-12-05 19:21:18 +0000239
240 I915_WRITE(ctl_reg, I915_READ(ctl_reg) & ~POWER_TARGET_ON);
Keith Packardde842ef2011-08-06 10:30:45 -0700241 if (wait_for((I915_READ(stat_reg) & PP_ON) == 0, 1000))
242 DRM_ERROR("timed out waiting for panel to power off\n");
Chris Wilson2a1292f2010-12-05 19:21:18 +0000243
Daniel Vetter7dec0602012-09-11 14:12:25 +0200244 I915_WRITE(lvds_encoder->reg, I915_READ(lvds_encoder->reg) & ~LVDS_PORT_EN);
245 POSTING_READ(lvds_encoder->reg);
Jesse Barnes79e53942008-11-07 14:24:08 -0800246}
247
Damien Lespiauc19de8e2013-11-28 15:29:18 +0000248static enum drm_mode_status
249intel_lvds_mode_valid(struct drm_connector *connector,
250 struct drm_display_mode *mode)
Jesse Barnes79e53942008-11-07 14:24:08 -0800251{
Jani Nikuladd06f902012-10-19 14:51:50 +0300252 struct intel_connector *intel_connector = to_intel_connector(connector);
253 struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
Jesse Barnes79e53942008-11-07 14:24:08 -0800254
Chris Wilson788319d2010-09-12 17:34:41 +0100255 if (mode->hdisplay > fixed_mode->hdisplay)
256 return MODE_PANEL;
257 if (mode->vdisplay > fixed_mode->vdisplay)
258 return MODE_PANEL;
Jesse Barnes79e53942008-11-07 14:24:08 -0800259
260 return MODE_OK;
261}
262
Daniel Vetter7ae89232013-03-27 00:44:52 +0100263static bool intel_lvds_compute_config(struct intel_encoder *intel_encoder,
264 struct intel_crtc_config *pipe_config)
Jesse Barnes79e53942008-11-07 14:24:08 -0800265{
Daniel Vetter7ae89232013-03-27 00:44:52 +0100266 struct drm_device *dev = intel_encoder->base.dev;
Jesse Barnes79e53942008-11-07 14:24:08 -0800267 struct drm_i915_private *dev_priv = dev->dev_private;
Daniel Vetter7ae89232013-03-27 00:44:52 +0100268 struct intel_lvds_encoder *lvds_encoder =
269 to_lvds_encoder(&intel_encoder->base);
Jani Nikula4d891522012-10-26 12:03:59 +0300270 struct intel_connector *intel_connector =
271 &lvds_encoder->attached_connector->base;
Daniel Vetter7ae89232013-03-27 00:44:52 +0100272 struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode;
Jani Nikula29b99b42012-10-19 14:51:43 +0300273 struct intel_crtc *intel_crtc = lvds_encoder->base.new_crtc;
Daniel Vetter4e53c2e2013-03-27 00:44:58 +0100274 unsigned int lvds_bpp;
Jesse Barnes79e53942008-11-07 14:24:08 -0800275
276 /* Should never happen!! */
Chris Wilsona6c45cf2010-09-17 00:32:17 +0100277 if (INTEL_INFO(dev)->gen < 4 && intel_crtc->pipe == 0) {
Keith Packard1ae8c0a2009-06-28 15:42:17 -0700278 DRM_ERROR("Can't support LVDS on pipe A\n");
Jesse Barnes79e53942008-11-07 14:24:08 -0800279 return false;
280 }
281
Daniel Vetter4e53c2e2013-03-27 00:44:58 +0100282 if ((I915_READ(lvds_encoder->reg) & LVDS_A3_POWER_MASK) ==
283 LVDS_A3_POWER_UP)
284 lvds_bpp = 8*3;
285 else
286 lvds_bpp = 6*3;
287
Daniel Vettere29c22c2013-02-21 00:00:16 +0100288 if (lvds_bpp != pipe_config->pipe_bpp && !pipe_config->bw_constrained) {
Daniel Vetter4e53c2e2013-03-27 00:44:58 +0100289 DRM_DEBUG_KMS("forcing display bpp (was %d) to LVDS (%d)\n",
290 pipe_config->pipe_bpp, lvds_bpp);
291 pipe_config->pipe_bpp = lvds_bpp;
292 }
Daniel Vetterd8b32242013-04-25 17:54:44 +0200293
Jesse Barnes79e53942008-11-07 14:24:08 -0800294 /*
Chris Wilson71677042010-07-17 13:38:43 +0100295 * We have timings from the BIOS for the panel, put them in
Jesse Barnes79e53942008-11-07 14:24:08 -0800296 * to the adjusted mode. The CRTC will be set up for this mode,
297 * with the panel scaling set up to source from the H/VDisplay
298 * of the original mode.
299 */
Jani Nikula4d891522012-10-26 12:03:59 +0300300 intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
Jani Nikuladd06f902012-10-19 14:51:50 +0300301 adjusted_mode);
Chris Wilson1d8e1c72010-08-07 11:01:28 +0100302
303 if (HAS_PCH_SPLIT(dev)) {
Daniel Vetter5bfe2ac2013-03-27 00:44:55 +0100304 pipe_config->has_pch_encoder = true;
305
Jesse Barnesb074cec2013-04-25 12:55:02 -0700306 intel_pch_panel_fitting(intel_crtc, pipe_config,
307 intel_connector->panel.fitting_mode);
Jesse Barnes2dd24552013-04-25 12:55:01 -0700308 } else {
309 intel_gmch_panel_fitting(intel_crtc, pipe_config,
310 intel_connector->panel.fitting_mode);
Jesse Barnes79e53942008-11-07 14:24:08 -0800311
Daniel Vetter21d8a472013-07-12 08:07:30 +0200312 }
Daniel Vetterf9bef082012-04-15 19:53:19 +0200313
Zhao Yakuia3e17eb2009-10-10 10:42:37 +0800314 /*
Jesse Barnes79e53942008-11-07 14:24:08 -0800315 * XXX: It would be nice to support lower refresh rates on the
316 * panels to reduce power consumption, and perhaps match the
317 * user's requested refresh rate.
318 */
319
320 return true;
321}
322
Jesse Barnes79e53942008-11-07 14:24:08 -0800323/**
324 * Detect the LVDS connection.
325 *
Jesse Barnesb42d4c52009-09-10 15:28:04 -0700326 * Since LVDS doesn't have hotlug, we use the lid as a proxy. Open means
327 * connected and closed means disconnected. We also send hotplug events as
328 * needed, using lid status notification from the input layer.
Jesse Barnes79e53942008-11-07 14:24:08 -0800329 */
Chris Wilson7b334fc2010-09-09 23:51:02 +0100330static enum drm_connector_status
Chris Wilson930a9e22010-09-14 11:07:23 +0100331intel_lvds_detect(struct drm_connector *connector, bool force)
Jesse Barnes79e53942008-11-07 14:24:08 -0800332{
Jesse Barnes7b9c5ab2010-02-12 09:30:00 -0800333 struct drm_device *dev = connector->dev;
Chris Wilson6ee3b5a2011-03-24 13:26:43 +0000334 enum drm_connector_status status;
Jesse Barnesb42d4c52009-09-10 15:28:04 -0700335
Chris Wilson164c8592013-07-20 20:27:08 +0100336 DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
Jani Nikulac23cc412014-06-03 14:56:17 +0300337 connector->base.id, connector->name);
Chris Wilson164c8592013-07-20 20:27:08 +0100338
Chris Wilsonfe16d942011-02-12 10:29:38 +0000339 status = intel_panel_detect(dev);
340 if (status != connector_status_unknown)
341 return status;
Chris Wilson01fe9db2011-01-16 19:37:30 +0000342
Chris Wilson6ee3b5a2011-03-24 13:26:43 +0000343 return connector_status_connected;
Jesse Barnes79e53942008-11-07 14:24:08 -0800344}
345
346/**
347 * Return the list of DDC modes if available, or the BIOS fixed mode otherwise.
348 */
349static int intel_lvds_get_modes(struct drm_connector *connector)
350{
Jani Nikula62165e02012-10-19 14:51:47 +0300351 struct intel_lvds_connector *lvds_connector = to_lvds_connector(connector);
Jesse Barnes79e53942008-11-07 14:24:08 -0800352 struct drm_device *dev = connector->dev;
Chris Wilson788319d2010-09-12 17:34:41 +0100353 struct drm_display_mode *mode;
Jesse Barnes79e53942008-11-07 14:24:08 -0800354
Jani Nikula9cd300e2012-10-19 14:51:52 +0300355 /* use cached edid if we have one */
Chris Wilson2aa4f092012-11-21 16:14:04 +0000356 if (!IS_ERR_OR_NULL(lvds_connector->base.edid))
Jani Nikula9cd300e2012-10-19 14:51:52 +0300357 return drm_add_edid_modes(connector, lvds_connector->base.edid);
Jesse Barnes79e53942008-11-07 14:24:08 -0800358
Jani Nikuladd06f902012-10-19 14:51:50 +0300359 mode = drm_mode_duplicate(dev, lvds_connector->base.panel.fixed_mode);
Chris Wilson311bd682011-01-13 19:06:50 +0000360 if (mode == NULL)
Chris Wilson788319d2010-09-12 17:34:41 +0100361 return 0;
Jesse Barnes79e53942008-11-07 14:24:08 -0800362
Chris Wilson788319d2010-09-12 17:34:41 +0100363 drm_mode_probed_add(connector, mode);
364 return 1;
Jesse Barnes79e53942008-11-07 14:24:08 -0800365}
366
Thomas Bächler0544edf2010-07-02 10:44:23 +0200367static int intel_no_modeset_on_lid_dmi_callback(const struct dmi_system_id *id)
368{
Daniel Vetterbc0daf42012-04-01 13:16:49 +0200369 DRM_INFO("Skipping forced modeset for %s\n", id->ident);
Thomas Bächler0544edf2010-07-02 10:44:23 +0200370 return 1;
371}
372
373/* The GPU hangs up on these systems if modeset is performed on LID open */
374static const struct dmi_system_id intel_no_modeset_on_lid[] = {
375 {
376 .callback = intel_no_modeset_on_lid_dmi_callback,
377 .ident = "Toshiba Tecra A11",
378 .matches = {
379 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
380 DMI_MATCH(DMI_PRODUCT_NAME, "TECRA A11"),
381 },
382 },
383
384 { } /* terminating entry */
385};
386
Linus Torvaldsc9354c82009-11-02 09:29:55 -0800387/*
Zhang Ruib8efb172013-02-05 15:41:53 +0800388 * Lid events. Note the use of 'modeset':
389 * - we set it to MODESET_ON_LID_OPEN on lid close,
390 * and set it to MODESET_DONE on open
Linus Torvaldsc9354c82009-11-02 09:29:55 -0800391 * - we use it as a "only once" bit (ie we ignore
Zhang Ruib8efb172013-02-05 15:41:53 +0800392 * duplicate events where it was already properly set)
393 * - the suspend/resume paths will set it to
394 * MODESET_SUSPENDED and ignore the lid open event,
395 * because they restore the mode ("lid open").
Linus Torvaldsc9354c82009-11-02 09:29:55 -0800396 */
Jesse Barnesc1c7af62009-09-10 15:28:03 -0700397static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
398 void *unused)
399{
Jani Nikuladb1740a2012-10-19 14:51:45 +0300400 struct intel_lvds_connector *lvds_connector =
401 container_of(nb, struct intel_lvds_connector, lid_notifier);
402 struct drm_connector *connector = &lvds_connector->base.base;
403 struct drm_device *dev = connector->dev;
404 struct drm_i915_private *dev_priv = dev->dev_private;
Jesse Barnesc1c7af62009-09-10 15:28:03 -0700405
Alex Williamson2fb4e612011-04-21 16:08:14 -0600406 if (dev->switch_power_state != DRM_SWITCH_POWER_ON)
407 return NOTIFY_OK;
408
Zhang Ruib8efb172013-02-05 15:41:53 +0800409 mutex_lock(&dev_priv->modeset_restore_lock);
410 if (dev_priv->modeset_restore == MODESET_SUSPENDED)
411 goto exit;
Zhao Yakuia2565372009-12-11 09:26:11 +0800412 /*
413 * check and update the status of LVDS connector after receiving
414 * the LID nofication event.
415 */
Jani Nikuladb1740a2012-10-19 14:51:45 +0300416 connector->status = connector->funcs->detect(connector, false);
Chris Wilson7b334fc2010-09-09 23:51:02 +0100417
Thomas Bächler0544edf2010-07-02 10:44:23 +0200418 /* Don't force modeset on machines where it causes a GPU lockup */
419 if (dmi_check_system(intel_no_modeset_on_lid))
Zhang Ruib8efb172013-02-05 15:41:53 +0800420 goto exit;
Linus Torvaldsc9354c82009-11-02 09:29:55 -0800421 if (!acpi_lid_open()) {
Zhang Ruib8efb172013-02-05 15:41:53 +0800422 /* do modeset on next lid open event */
423 dev_priv->modeset_restore = MODESET_ON_LID_OPEN;
424 goto exit;
Jesse Barnes06891e22009-09-14 10:58:48 -0700425 }
Jesse Barnesc1c7af62009-09-10 15:28:03 -0700426
Zhang Ruib8efb172013-02-05 15:41:53 +0800427 if (dev_priv->modeset_restore == MODESET_DONE)
428 goto exit;
Linus Torvaldsc9354c82009-11-02 09:29:55 -0800429
Daniel Vetter5be19d92013-10-09 10:47:12 +0200430 /*
431 * Some old platform's BIOS love to wreak havoc while the lid is closed.
432 * We try to detect this here and undo any damage. The split for PCH
433 * platforms is rather conservative and a bit arbitrary expect that on
434 * those platforms VGA disabling requires actual legacy VGA I/O access,
435 * and as part of the cleanup in the hw state restore we also redisable
436 * the vga plane.
437 */
438 if (!HAS_PCH_SPLIT(dev)) {
439 drm_modeset_lock_all(dev);
440 intel_modeset_setup_hw_state(dev, true);
441 drm_modeset_unlock_all(dev);
442 }
Jesse Barnes06324192009-09-10 15:28:05 -0700443
Zhang Ruib8efb172013-02-05 15:41:53 +0800444 dev_priv->modeset_restore = MODESET_DONE;
445
446exit:
447 mutex_unlock(&dev_priv->modeset_restore_lock);
Jesse Barnesc1c7af62009-09-10 15:28:03 -0700448 return NOTIFY_OK;
449}
450
Jesse Barnes79e53942008-11-07 14:24:08 -0800451/**
452 * intel_lvds_destroy - unregister and free LVDS structures
453 * @connector: connector to free
454 *
455 * Unregister the DDC bus for this connector then free the driver private
456 * structure.
457 */
458static void intel_lvds_destroy(struct drm_connector *connector)
459{
Jani Nikuladb1740a2012-10-19 14:51:45 +0300460 struct intel_lvds_connector *lvds_connector =
461 to_lvds_connector(connector);
Jesse Barnes79e53942008-11-07 14:24:08 -0800462
Jani Nikuladb1740a2012-10-19 14:51:45 +0300463 if (lvds_connector->lid_notifier.notifier_call)
464 acpi_lid_notifier_unregister(&lvds_connector->lid_notifier);
Matthew Garrettaaa6fd22011-08-12 12:11:33 +0200465
Jani Nikula9cd300e2012-10-19 14:51:52 +0300466 if (!IS_ERR_OR_NULL(lvds_connector->base.edid))
467 kfree(lvds_connector->base.edid);
468
Jani Nikula1d508702012-10-19 14:51:49 +0300469 intel_panel_fini(&lvds_connector->base.panel);
Jani Nikuladb1740a2012-10-19 14:51:45 +0300470
Jesse Barnes79e53942008-11-07 14:24:08 -0800471 drm_connector_cleanup(connector);
472 kfree(connector);
473}
474
Jesse Barnes335041e2009-01-22 22:22:06 +1000475static int intel_lvds_set_property(struct drm_connector *connector,
476 struct drm_property *property,
477 uint64_t value)
478{
Jani Nikula4d891522012-10-26 12:03:59 +0300479 struct intel_connector *intel_connector = to_intel_connector(connector);
Zhao Yakui3fbe18d2009-06-22 15:31:25 +0800480 struct drm_device *dev = connector->dev;
Zhao Yakui3fbe18d2009-06-22 15:31:25 +0800481
Chris Wilson788319d2010-09-12 17:34:41 +0100482 if (property == dev->mode_config.scaling_mode_property) {
Jani Nikula62165e02012-10-19 14:51:47 +0300483 struct drm_crtc *crtc;
Zhenyu Wangbb8a3562010-03-29 16:40:50 +0800484
Jesse Barnes53bd8382009-07-01 10:04:40 -0700485 if (value == DRM_MODE_SCALE_NONE) {
486 DRM_DEBUG_KMS("no scaling not supported\n");
Chris Wilson788319d2010-09-12 17:34:41 +0100487 return -EINVAL;
Zhao Yakui3fbe18d2009-06-22 15:31:25 +0800488 }
Chris Wilson788319d2010-09-12 17:34:41 +0100489
Jani Nikula4d891522012-10-26 12:03:59 +0300490 if (intel_connector->panel.fitting_mode == value) {
Zhao Yakui3fbe18d2009-06-22 15:31:25 +0800491 /* the LVDS scaling property is not changed */
492 return 0;
493 }
Jani Nikula4d891522012-10-26 12:03:59 +0300494 intel_connector->panel.fitting_mode = value;
Jani Nikula62165e02012-10-19 14:51:47 +0300495
496 crtc = intel_attached_encoder(connector)->base.crtc;
Zhao Yakui3fbe18d2009-06-22 15:31:25 +0800497 if (crtc && crtc->enabled) {
498 /*
499 * If the CRTC is enabled, the display will be changed
500 * according to the new panel fitting mode.
501 */
Chris Wilsonc0c36b942012-12-19 16:08:43 +0000502 intel_crtc_restore_mode(crtc);
Zhao Yakui3fbe18d2009-06-22 15:31:25 +0800503 }
504 }
505
Jesse Barnes335041e2009-01-22 22:22:06 +1000506 return 0;
507}
508
Jesse Barnes79e53942008-11-07 14:24:08 -0800509static const struct drm_connector_helper_funcs intel_lvds_connector_helper_funcs = {
510 .get_modes = intel_lvds_get_modes,
511 .mode_valid = intel_lvds_mode_valid,
Chris Wilsondf0e9242010-09-09 16:20:55 +0100512 .best_encoder = intel_best_encoder,
Jesse Barnes79e53942008-11-07 14:24:08 -0800513};
514
515static const struct drm_connector_funcs intel_lvds_connector_funcs = {
Daniel Vetterc22834e2012-06-30 15:31:28 +0200516 .dpms = intel_connector_dpms,
Jesse Barnes79e53942008-11-07 14:24:08 -0800517 .detect = intel_lvds_detect,
518 .fill_modes = drm_helper_probe_single_connector_modes,
Jesse Barnes335041e2009-01-22 22:22:06 +1000519 .set_property = intel_lvds_set_property,
Jesse Barnes79e53942008-11-07 14:24:08 -0800520 .destroy = intel_lvds_destroy,
521};
522
Jesse Barnes79e53942008-11-07 14:24:08 -0800523static const struct drm_encoder_funcs intel_lvds_enc_funcs = {
Chris Wilsonea5b2132010-08-04 13:50:23 +0100524 .destroy = intel_encoder_destroy,
Jesse Barnes79e53942008-11-07 14:24:08 -0800525};
526
Jarod Wilson425d2442009-05-05 10:00:25 -0400527static int __init intel_no_lvds_dmi_callback(const struct dmi_system_id *id)
528{
Daniel Vetterbc0daf42012-04-01 13:16:49 +0200529 DRM_INFO("Skipping LVDS initialization for %s\n", id->ident);
Jarod Wilson425d2442009-05-05 10:00:25 -0400530 return 1;
531}
Jesse Barnes79e53942008-11-07 14:24:08 -0800532
Jarod Wilson425d2442009-05-05 10:00:25 -0400533/* These systems claim to have LVDS, but really don't */
Jaswinder Singh Rajput93c05f22009-06-04 09:41:19 +1000534static const struct dmi_system_id intel_no_lvds[] = {
Jarod Wilson425d2442009-05-05 10:00:25 -0400535 {
536 .callback = intel_no_lvds_dmi_callback,
537 .ident = "Apple Mac Mini (Core series)",
538 .matches = {
Keith Packard98acd462009-06-14 12:31:58 -0700539 DMI_MATCH(DMI_SYS_VENDOR, "Apple"),
Jarod Wilson425d2442009-05-05 10:00:25 -0400540 DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"),
541 },
542 },
543 {
544 .callback = intel_no_lvds_dmi_callback,
545 .ident = "Apple Mac Mini (Core 2 series)",
546 .matches = {
Keith Packard98acd462009-06-14 12:31:58 -0700547 DMI_MATCH(DMI_SYS_VENDOR, "Apple"),
Jarod Wilson425d2442009-05-05 10:00:25 -0400548 DMI_MATCH(DMI_PRODUCT_NAME, "Macmini2,1"),
549 },
550 },
551 {
552 .callback = intel_no_lvds_dmi_callback,
553 .ident = "MSI IM-945GSE-A",
554 .matches = {
555 DMI_MATCH(DMI_SYS_VENDOR, "MSI"),
556 DMI_MATCH(DMI_PRODUCT_NAME, "A9830IMS"),
557 },
558 },
559 {
560 .callback = intel_no_lvds_dmi_callback,
561 .ident = "Dell Studio Hybrid",
562 .matches = {
563 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
564 DMI_MATCH(DMI_PRODUCT_NAME, "Studio Hybrid 140g"),
565 },
566 },
Jarod Wilson70aa96c2009-05-27 17:20:39 -0400567 {
568 .callback = intel_no_lvds_dmi_callback,
Pieterjan Camerlynckb0662542011-07-26 16:23:54 +0200569 .ident = "Dell OptiPlex FX170",
570 .matches = {
571 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
572 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex FX170"),
573 },
574 },
575 {
576 .callback = intel_no_lvds_dmi_callback,
Jarod Wilson70aa96c2009-05-27 17:20:39 -0400577 .ident = "AOpen Mini PC",
578 .matches = {
579 DMI_MATCH(DMI_SYS_VENDOR, "AOpen"),
580 DMI_MATCH(DMI_PRODUCT_NAME, "i965GMx-IF"),
581 },
582 },
Michael Cousinfa0864b2009-06-05 21:16:22 +0200583 {
584 .callback = intel_no_lvds_dmi_callback,
Tormod Voldened8c7542009-07-13 22:26:48 +0200585 .ident = "AOpen Mini PC MP915",
586 .matches = {
587 DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
588 DMI_MATCH(DMI_BOARD_NAME, "i915GMx-F"),
589 },
590 },
591 {
592 .callback = intel_no_lvds_dmi_callback,
Knut Petersen22ab70d2011-01-14 15:38:10 +0000593 .ident = "AOpen i915GMm-HFS",
594 .matches = {
595 DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
596 DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
597 },
598 },
599 {
600 .callback = intel_no_lvds_dmi_callback,
Daniel Vettere57b6882012-02-08 16:42:52 +0100601 .ident = "AOpen i45GMx-I",
602 .matches = {
603 DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
604 DMI_MATCH(DMI_BOARD_NAME, "i45GMx-I"),
605 },
606 },
607 {
608 .callback = intel_no_lvds_dmi_callback,
Michael Cousinfa0864b2009-06-05 21:16:22 +0200609 .ident = "Aopen i945GTt-VFA",
610 .matches = {
611 DMI_MATCH(DMI_PRODUCT_VERSION, "AO00001JW"),
612 },
613 },
Stefan Bader9875557ee82010-03-29 17:53:12 +0200614 {
615 .callback = intel_no_lvds_dmi_callback,
616 .ident = "Clientron U800",
617 .matches = {
618 DMI_MATCH(DMI_SYS_VENDOR, "Clientron"),
619 DMI_MATCH(DMI_PRODUCT_NAME, "U800"),
620 },
621 },
Hans de Goede6a574b52011-06-04 15:39:21 +0200622 {
Joel Sass44306ab2012-01-10 13:03:55 -0500623 .callback = intel_no_lvds_dmi_callback,
624 .ident = "Clientron E830",
625 .matches = {
626 DMI_MATCH(DMI_SYS_VENDOR, "Clientron"),
627 DMI_MATCH(DMI_PRODUCT_NAME, "E830"),
628 },
629 },
630 {
Hans de Goede6a574b52011-06-04 15:39:21 +0200631 .callback = intel_no_lvds_dmi_callback,
632 .ident = "Asus EeeBox PC EB1007",
633 .matches = {
634 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
635 DMI_MATCH(DMI_PRODUCT_NAME, "EB1007"),
636 },
637 },
Adam Jackson0999bbe2011-11-28 12:22:56 -0500638 {
639 .callback = intel_no_lvds_dmi_callback,
640 .ident = "Asus AT5NM10T-I",
641 .matches = {
642 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
643 DMI_MATCH(DMI_BOARD_NAME, "AT5NM10T-I"),
644 },
645 },
Marc Gariepyf5b8a7e2012-02-09 09:35:21 -0500646 {
647 .callback = intel_no_lvds_dmi_callback,
Ben Mesman45a211d2013-04-16 20:00:28 +0200648 .ident = "Hewlett-Packard HP t5740",
Jan-Benedict Glaw33471112012-05-22 15:21:53 +0200649 .matches = {
650 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
Ben Mesman45a211d2013-04-16 20:00:28 +0200651 DMI_MATCH(DMI_PRODUCT_NAME, " t5740"),
Jan-Benedict Glaw33471112012-05-22 15:21:53 +0200652 },
653 },
654 {
655 .callback = intel_no_lvds_dmi_callback,
Marc Gariepyf5b8a7e2012-02-09 09:35:21 -0500656 .ident = "Hewlett-Packard t5745",
657 .matches = {
658 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
Marc Gariepy62004972012-05-01 13:37:57 -0400659 DMI_MATCH(DMI_PRODUCT_NAME, "hp t5745"),
Marc Gariepyf5b8a7e2012-02-09 09:35:21 -0500660 },
661 },
662 {
663 .callback = intel_no_lvds_dmi_callback,
664 .ident = "Hewlett-Packard st5747",
665 .matches = {
666 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
Marc Gariepy62004972012-05-01 13:37:57 -0400667 DMI_MATCH(DMI_PRODUCT_NAME, "hp st5747"),
Marc Gariepyf5b8a7e2012-02-09 09:35:21 -0500668 },
669 },
Anisse Astier97effad2012-03-07 18:36:35 +0100670 {
671 .callback = intel_no_lvds_dmi_callback,
672 .ident = "MSI Wind Box DC500",
673 .matches = {
674 DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
675 DMI_MATCH(DMI_BOARD_NAME, "MS-7469"),
676 },
677 },
Sjoerd Simons9756fe32012-06-22 09:43:07 +0200678 {
679 .callback = intel_no_lvds_dmi_callback,
Calvin Waltona51d4ed2012-08-24 07:56:31 -0400680 .ident = "Gigabyte GA-D525TUD",
681 .matches = {
682 DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."),
683 DMI_MATCH(DMI_BOARD_NAME, "D525TUD"),
684 },
685 },
Chris Wilsonc31407a2012-10-18 21:07:01 +0100686 {
687 .callback = intel_no_lvds_dmi_callback,
688 .ident = "Supermicro X7SPA-H",
689 .matches = {
690 DMI_MATCH(DMI_SYS_VENDOR, "Supermicro"),
691 DMI_MATCH(DMI_PRODUCT_NAME, "X7SPA-H"),
692 },
693 },
Christian Lamparter9e9dd0e2013-04-03 14:34:11 +0200694 {
695 .callback = intel_no_lvds_dmi_callback,
696 .ident = "Fujitsu Esprimo Q900",
697 .matches = {
698 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
699 DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Q900"),
700 },
701 },
Chris Wilsone5614f02013-07-03 15:05:03 -0700702 {
703 .callback = intel_no_lvds_dmi_callback,
Rob Pearce645378d2013-10-27 16:13:42 +0000704 .ident = "Intel D410PT",
705 .matches = {
706 DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
707 DMI_MATCH(DMI_BOARD_NAME, "D410PT"),
708 },
709 },
710 {
711 .callback = intel_no_lvds_dmi_callback,
712 .ident = "Intel D425KT",
713 .matches = {
714 DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
715 DMI_EXACT_MATCH(DMI_BOARD_NAME, "D425KT"),
716 },
717 },
718 {
719 .callback = intel_no_lvds_dmi_callback,
Chris Wilsone5614f02013-07-03 15:05:03 -0700720 .ident = "Intel D510MO",
721 .matches = {
722 DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
723 DMI_EXACT_MATCH(DMI_BOARD_NAME, "D510MO"),
724 },
725 },
Jani Nikuladcf6d292013-07-03 15:05:05 -0700726 {
727 .callback = intel_no_lvds_dmi_callback,
728 .ident = "Intel D525MW",
729 .matches = {
730 DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
731 DMI_EXACT_MATCH(DMI_BOARD_NAME, "D525MW"),
732 },
733 },
Jarod Wilson425d2442009-05-05 10:00:25 -0400734
735 { } /* terminating entry */
736};
Jesse Barnes79e53942008-11-07 14:24:08 -0800737
Zhao Yakui7cf4f692009-11-24 09:48:47 +0800738/*
739 * Enumerate the child dev array parsed from VBT to check whether
740 * the LVDS is present.
741 * If it is present, return 1.
742 * If it is not present, return false.
743 * If no child dev is parsed from VBT, it assumes that the LVDS is present.
Zhao Yakui7cf4f692009-11-24 09:48:47 +0800744 */
Chris Wilson270eea02010-09-24 01:15:02 +0100745static bool lvds_is_present_in_vbt(struct drm_device *dev,
746 u8 *i2c_pin)
Zhao Yakui7cf4f692009-11-24 09:48:47 +0800747{
748 struct drm_i915_private *dev_priv = dev->dev_private;
Chris Wilson425904d2010-08-22 18:21:42 +0100749 int i;
Zhao Yakui7cf4f692009-11-24 09:48:47 +0800750
Rodrigo Vivi41aa3442013-05-09 20:03:18 -0300751 if (!dev_priv->vbt.child_dev_num)
Chris Wilson425904d2010-08-22 18:21:42 +0100752 return true;
Zhao Yakui7cf4f692009-11-24 09:48:47 +0800753
Rodrigo Vivi41aa3442013-05-09 20:03:18 -0300754 for (i = 0; i < dev_priv->vbt.child_dev_num; i++) {
Paulo Zanoni768f69c2013-09-11 18:02:47 -0300755 union child_device_config *uchild = dev_priv->vbt.child_dev + i;
756 struct old_child_dev_config *child = &uchild->old;
Chris Wilson425904d2010-08-22 18:21:42 +0100757
758 /* If the device type is not LFP, continue.
759 * We have to check both the new identifiers as well as the
760 * old for compatibility with some BIOSes.
Zhao Yakui7cf4f692009-11-24 09:48:47 +0800761 */
Chris Wilson425904d2010-08-22 18:21:42 +0100762 if (child->device_type != DEVICE_TYPE_INT_LFP &&
763 child->device_type != DEVICE_TYPE_LFP)
Zhao Yakui7cf4f692009-11-24 09:48:47 +0800764 continue;
765
Daniel Kurtz3bd7d902012-03-28 02:36:14 +0800766 if (intel_gmbus_is_port_valid(child->i2c_pin))
767 *i2c_pin = child->i2c_pin;
Chris Wilson270eea02010-09-24 01:15:02 +0100768
Chris Wilson425904d2010-08-22 18:21:42 +0100769 /* However, we cannot trust the BIOS writers to populate
770 * the VBT correctly. Since LVDS requires additional
771 * information from AIM blocks, a non-zero addin offset is
772 * a good indicator that the LVDS is actually present.
Zhao Yakui7cf4f692009-11-24 09:48:47 +0800773 */
Chris Wilson425904d2010-08-22 18:21:42 +0100774 if (child->addin_offset)
775 return true;
776
777 /* But even then some BIOS writers perform some black magic
778 * and instantiate the device without reference to any
779 * additional data. Trust that if the VBT was written into
780 * the OpRegion then they have validated the LVDS's existence.
781 */
782 if (dev_priv->opregion.vbt)
783 return true;
Zhao Yakui7cf4f692009-11-24 09:48:47 +0800784 }
Chris Wilson425904d2010-08-22 18:21:42 +0100785
786 return false;
Zhao Yakui7cf4f692009-11-24 09:48:47 +0800787}
788
Daniel Vetter1974cad2012-11-26 17:22:09 +0100789static int intel_dual_link_lvds_callback(const struct dmi_system_id *id)
790{
791 DRM_INFO("Forcing lvds to dual link mode on %s\n", id->ident);
792 return 1;
793}
794
795static const struct dmi_system_id intel_dual_link_lvds[] = {
796 {
797 .callback = intel_dual_link_lvds_callback,
798 .ident = "Apple MacBook Pro (Core i5/i7 Series)",
799 .matches = {
800 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
801 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro8,2"),
802 },
803 },
804 { } /* terminating entry */
805};
806
807bool intel_is_dual_link_lvds(struct drm_device *dev)
808{
Daniel Vetter13c7d872012-11-26 17:22:10 +0100809 struct intel_encoder *encoder;
810 struct intel_lvds_encoder *lvds_encoder;
811
812 list_for_each_entry(encoder, &dev->mode_config.encoder_list,
813 base.head) {
814 if (encoder->type == INTEL_OUTPUT_LVDS) {
815 lvds_encoder = to_lvds_encoder(&encoder->base);
816
817 return lvds_encoder->is_dual_link;
818 }
819 }
820
821 return false;
822}
823
Daniel Vetter7dec0602012-09-11 14:12:25 +0200824static bool compute_is_dual_link_lvds(struct intel_lvds_encoder *lvds_encoder)
Daniel Vetter13c7d872012-11-26 17:22:10 +0100825{
Daniel Vetter7dec0602012-09-11 14:12:25 +0200826 struct drm_device *dev = lvds_encoder->base.base.dev;
Daniel Vetter1974cad2012-11-26 17:22:09 +0100827 unsigned int val;
828 struct drm_i915_private *dev_priv = dev->dev_private;
Daniel Vetter1974cad2012-11-26 17:22:09 +0100829
830 /* use the module option value if specified */
Jani Nikulad330a952014-01-21 11:24:25 +0200831 if (i915.lvds_channel_mode > 0)
832 return i915.lvds_channel_mode == 2;
Daniel Vetter1974cad2012-11-26 17:22:09 +0100833
834 if (dmi_check_system(intel_dual_link_lvds))
835 return true;
836
Daniel Vetter13c7d872012-11-26 17:22:10 +0100837 /* BIOS should set the proper LVDS register value at boot, but
838 * in reality, it doesn't set the value when the lid is closed;
839 * we need to check "the value to be set" in VBT when LVDS
840 * register is uninitialized.
841 */
Daniel Vetter7dec0602012-09-11 14:12:25 +0200842 val = I915_READ(lvds_encoder->reg);
Daniel Vetter13c7d872012-11-26 17:22:10 +0100843 if (!(val & ~(LVDS_PIPE_MASK | LVDS_DETECTED)))
Rodrigo Vivi41aa3442013-05-09 20:03:18 -0300844 val = dev_priv->vbt.bios_lvds_val;
Daniel Vetter13c7d872012-11-26 17:22:10 +0100845
Daniel Vetter1974cad2012-11-26 17:22:09 +0100846 return (val & LVDS_CLKB_POWER_MASK) == LVDS_CLKB_POWER_UP;
847}
848
Chris Wilsonf3cfcba2012-02-09 09:35:53 +0000849static bool intel_lvds_supported(struct drm_device *dev)
850{
851 /* With the introduction of the PCH we gained a dedicated
852 * LVDS presence pin, use it. */
Paulo Zanoni311e3592013-03-06 20:03:19 -0300853 if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev))
Chris Wilsonf3cfcba2012-02-09 09:35:53 +0000854 return true;
855
856 /* Otherwise LVDS was only attached to mobile products,
857 * except for the inglorious 830gm */
Paulo Zanoni311e3592013-03-06 20:03:19 -0300858 if (INTEL_INFO(dev)->gen <= 4 && IS_MOBILE(dev) && !IS_I830(dev))
859 return true;
860
861 return false;
Chris Wilsonf3cfcba2012-02-09 09:35:53 +0000862}
863
Zhao Yakui18f9ed12009-11-20 03:24:16 +0000864/**
Jesse Barnes79e53942008-11-07 14:24:08 -0800865 * intel_lvds_init - setup LVDS connectors on this device
866 * @dev: drm device
867 *
868 * Create the connector, register the LVDS DDC bus, and try to figure out what
869 * modes we can display on the LVDS panel (if present).
870 */
Daniel Vetterc9093352013-06-06 22:22:47 +0200871void intel_lvds_init(struct drm_device *dev)
Jesse Barnes79e53942008-11-07 14:24:08 -0800872{
873 struct drm_i915_private *dev_priv = dev->dev_private;
Jani Nikula29b99b42012-10-19 14:51:43 +0300874 struct intel_lvds_encoder *lvds_encoder;
Eric Anholt21d40d32010-03-25 11:11:14 -0700875 struct intel_encoder *intel_encoder;
Jani Nikulac7362c42012-10-19 14:51:44 +0300876 struct intel_lvds_connector *lvds_connector;
Zhenyu Wangbb8a3562010-03-29 16:40:50 +0800877 struct intel_connector *intel_connector;
Jesse Barnes79e53942008-11-07 14:24:08 -0800878 struct drm_connector *connector;
879 struct drm_encoder *encoder;
880 struct drm_display_mode *scan; /* *modes, *bios_mode; */
Jani Nikuladd06f902012-10-19 14:51:50 +0300881 struct drm_display_mode *fixed_mode = NULL;
Vandana Kannan4b6ed682014-02-11 14:26:36 +0530882 struct drm_display_mode *downclock_mode = NULL;
Jani Nikula9cd300e2012-10-19 14:51:52 +0300883 struct edid *edid;
Jesse Barnes79e53942008-11-07 14:24:08 -0800884 struct drm_crtc *crtc;
885 u32 lvds;
Chris Wilson270eea02010-09-24 01:15:02 +0100886 int pipe;
887 u8 pin;
Jesse Barnes79e53942008-11-07 14:24:08 -0800888
Chris Wilsonf3cfcba2012-02-09 09:35:53 +0000889 if (!intel_lvds_supported(dev))
Daniel Vetterc9093352013-06-06 22:22:47 +0200890 return;
Chris Wilsonf3cfcba2012-02-09 09:35:53 +0000891
Jarod Wilson425d2442009-05-05 10:00:25 -0400892 /* Skip init on machines we know falsely report LVDS */
893 if (dmi_check_system(intel_no_lvds))
Daniel Vetterc9093352013-06-06 22:22:47 +0200894 return;
Paul Collins565dcd42009-02-04 23:05:41 +1300895
Chris Wilson270eea02010-09-24 01:15:02 +0100896 pin = GMBUS_PORT_PANEL;
897 if (!lvds_is_present_in_vbt(dev, &pin)) {
Matthew Garrett11ba1592009-12-15 13:55:24 -0500898 DRM_DEBUG_KMS("LVDS is not present in VBT\n");
Daniel Vetterc9093352013-06-06 22:22:47 +0200899 return;
Zhao Yakui7cf4f692009-11-24 09:48:47 +0800900 }
Zhao Yakuie99da352009-06-26 09:46:18 +0800901
Eric Anholtc619eed2010-01-28 16:45:52 -0800902 if (HAS_PCH_SPLIT(dev)) {
Zhenyu Wang541998a2009-06-05 15:38:44 +0800903 if ((I915_READ(PCH_LVDS) & LVDS_DETECTED) == 0)
Daniel Vetterc9093352013-06-06 22:22:47 +0200904 return;
Rodrigo Vivi41aa3442013-05-09 20:03:18 -0300905 if (dev_priv->vbt.edp_support) {
Zhao Yakui28c97732009-10-09 11:39:41 +0800906 DRM_DEBUG_KMS("disable LVDS for eDP support\n");
Daniel Vetterc9093352013-06-06 22:22:47 +0200907 return;
Zhenyu Wang32f9d652009-07-24 01:00:32 +0800908 }
Zhenyu Wang541998a2009-06-05 15:38:44 +0800909 }
910
Daniel Vetterb14c5672013-09-19 12:18:32 +0200911 lvds_encoder = kzalloc(sizeof(*lvds_encoder), GFP_KERNEL);
Jani Nikula29b99b42012-10-19 14:51:43 +0300912 if (!lvds_encoder)
Daniel Vetterc9093352013-06-06 22:22:47 +0200913 return;
Jesse Barnes79e53942008-11-07 14:24:08 -0800914
Daniel Vetterb14c5672013-09-19 12:18:32 +0200915 lvds_connector = kzalloc(sizeof(*lvds_connector), GFP_KERNEL);
Jani Nikulac7362c42012-10-19 14:51:44 +0300916 if (!lvds_connector) {
Jani Nikula29b99b42012-10-19 14:51:43 +0300917 kfree(lvds_encoder);
Daniel Vetterc9093352013-06-06 22:22:47 +0200918 return;
Jesse Barnes79e53942008-11-07 14:24:08 -0800919 }
920
Jani Nikula62165e02012-10-19 14:51:47 +0300921 lvds_encoder->attached_connector = lvds_connector;
Zhenyu Wangbb8a3562010-03-29 16:40:50 +0800922
Jani Nikula29b99b42012-10-19 14:51:43 +0300923 intel_encoder = &lvds_encoder->base;
Chris Wilson4ef69c72010-09-09 15:14:28 +0100924 encoder = &intel_encoder->base;
Jani Nikulac7362c42012-10-19 14:51:44 +0300925 intel_connector = &lvds_connector->base;
Chris Wilsonea5b2132010-08-04 13:50:23 +0100926 connector = &intel_connector->base;
Zhenyu Wangbb8a3562010-03-29 16:40:50 +0800927 drm_connector_init(dev, &intel_connector->base, &intel_lvds_connector_funcs,
Jesse Barnes79e53942008-11-07 14:24:08 -0800928 DRM_MODE_CONNECTOR_LVDS);
929
Chris Wilson4ef69c72010-09-09 15:14:28 +0100930 drm_encoder_init(dev, &intel_encoder->base, &intel_lvds_enc_funcs,
Jesse Barnes79e53942008-11-07 14:24:08 -0800931 DRM_MODE_ENCODER_LVDS);
932
Daniel Vetterc22834e2012-06-30 15:31:28 +0200933 intel_encoder->enable = intel_enable_lvds;
Daniel Vetterf6736a12013-06-05 13:34:30 +0200934 intel_encoder->pre_enable = intel_pre_enable_lvds;
Daniel Vetter7ae89232013-03-27 00:44:52 +0100935 intel_encoder->compute_config = intel_lvds_compute_config;
Daniel Vetterc22834e2012-06-30 15:31:28 +0200936 intel_encoder->disable = intel_disable_lvds;
Daniel Vetterb1dc3322012-07-02 21:09:00 +0200937 intel_encoder->get_hw_state = intel_lvds_get_hw_state;
Jesse Barnes045ac3b2013-05-14 17:08:26 -0700938 intel_encoder->get_config = intel_lvds_get_config;
Daniel Vetterb1dc3322012-07-02 21:09:00 +0200939 intel_connector->get_hw_state = intel_connector_get_hw_state;
Imre Deak4932e2c2014-02-11 17:12:48 +0200940 intel_connector->unregister = intel_connector_unregister;
Daniel Vetterc22834e2012-06-30 15:31:28 +0200941
Chris Wilsondf0e9242010-09-09 16:20:55 +0100942 intel_connector_attach_encoder(intel_connector, intel_encoder);
Eric Anholt21d40d32010-03-25 11:11:14 -0700943 intel_encoder->type = INTEL_OUTPUT_LVDS;
Jesse Barnes79e53942008-11-07 14:24:08 -0800944
Ville Syrjäläbc079e82014-03-03 16:15:28 +0200945 intel_encoder->cloneable = 0;
Jesse Barnes27f82272011-09-02 12:54:37 -0700946 if (HAS_PCH_SPLIT(dev))
947 intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
Daniel Vetter0b9f43a2012-06-05 10:07:11 +0200948 else if (IS_GEN4(dev))
949 intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
Jesse Barnes27f82272011-09-02 12:54:37 -0700950 else
951 intel_encoder->crtc_mask = (1 << 1);
952
Jesse Barnes79e53942008-11-07 14:24:08 -0800953 drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs);
954 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
955 connector->interlace_allowed = false;
956 connector->doublescan_allowed = false;
957
Daniel Vetter7dec0602012-09-11 14:12:25 +0200958 if (HAS_PCH_SPLIT(dev)) {
959 lvds_encoder->reg = PCH_LVDS;
960 } else {
961 lvds_encoder->reg = LVDS;
962 }
963
Zhao Yakui3fbe18d2009-06-22 15:31:25 +0800964 /* create the scaling mode property */
965 drm_mode_create_scaling_mode_property(dev);
Rob Clark662595d2012-10-11 20:36:04 -0500966 drm_object_attach_property(&connector->base,
Zhao Yakui3fbe18d2009-06-22 15:31:25 +0800967 dev->mode_config.scaling_mode_property,
Jesse Barnesdd1ea372010-06-24 11:05:10 -0700968 DRM_MODE_SCALE_ASPECT);
Jani Nikula4d891522012-10-26 12:03:59 +0300969 intel_connector->panel.fitting_mode = DRM_MODE_SCALE_ASPECT;
Jesse Barnes79e53942008-11-07 14:24:08 -0800970 /*
971 * LVDS discovery:
972 * 1) check for EDID on DDC
973 * 2) check for VBT data
974 * 3) check to see if LVDS is already on
975 * if none of the above, no panel
976 * 4) make sure lid is open
977 * if closed, act like it's not there for now
978 */
979
Jesse Barnes79e53942008-11-07 14:24:08 -0800980 /*
981 * Attempt to get the fixed panel mode from DDC. Assume that the
982 * preferred mode is the right one.
983 */
Daniel Vetter4da98542014-03-21 23:22:35 +0100984 mutex_lock(&dev->mode_config.mutex);
Jani Nikula9cd300e2012-10-19 14:51:52 +0300985 edid = drm_get_edid(connector, intel_gmbus_get_adapter(dev_priv, pin));
986 if (edid) {
987 if (drm_add_edid_modes(connector, edid)) {
Chris Wilson3f8ff0e2010-11-08 23:20:52 +0000988 drm_mode_connector_update_edid_property(connector,
Jani Nikula9cd300e2012-10-19 14:51:52 +0300989 edid);
Chris Wilson3f8ff0e2010-11-08 23:20:52 +0000990 } else {
Jani Nikula9cd300e2012-10-19 14:51:52 +0300991 kfree(edid);
992 edid = ERR_PTR(-EINVAL);
Chris Wilson3f8ff0e2010-11-08 23:20:52 +0000993 }
Jani Nikula9cd300e2012-10-19 14:51:52 +0300994 } else {
995 edid = ERR_PTR(-ENOENT);
Chris Wilson3f8ff0e2010-11-08 23:20:52 +0000996 }
Jani Nikula9cd300e2012-10-19 14:51:52 +0300997 lvds_connector->base.edid = edid;
998
999 if (IS_ERR_OR_NULL(edid)) {
Chris Wilson788319d2010-09-12 17:34:41 +01001000 /* Didn't get an EDID, so
1001 * Set wide sync ranges so we get all modes
1002 * handed to valid_mode for checking
1003 */
1004 connector->display_info.min_vfreq = 0;
1005 connector->display_info.max_vfreq = 200;
1006 connector->display_info.min_hfreq = 0;
1007 connector->display_info.max_hfreq = 200;
1008 }
Jesse Barnes79e53942008-11-07 14:24:08 -08001009
1010 list_for_each_entry(scan, &connector->probed_modes, head) {
Jesse Barnes79e53942008-11-07 14:24:08 -08001011 if (scan->type & DRM_MODE_TYPE_PREFERRED) {
Chris Wilson6a9d51b2012-11-21 16:14:03 +00001012 DRM_DEBUG_KMS("using preferred mode from EDID: ");
1013 drm_mode_debug_printmodeline(scan);
1014
Jani Nikuladd06f902012-10-19 14:51:50 +03001015 fixed_mode = drm_mode_duplicate(dev, scan);
Chris Wilson6a9d51b2012-11-21 16:14:03 +00001016 if (fixed_mode) {
Vandana Kannan4b6ed682014-02-11 14:26:36 +05301017 downclock_mode =
Vandana Kannanec9ed192013-12-10 13:37:36 +05301018 intel_find_panel_downclock(dev,
1019 fixed_mode, connector);
Vandana Kannan4b6ed682014-02-11 14:26:36 +05301020 if (downclock_mode != NULL &&
1021 i915.lvds_downclock) {
Vandana Kannanec9ed192013-12-10 13:37:36 +05301022 /* We found the downclock for LVDS. */
1023 dev_priv->lvds_downclock_avail = true;
1024 dev_priv->lvds_downclock =
Vandana Kannanec9ed192013-12-10 13:37:36 +05301025 downclock_mode->clock;
1026 DRM_DEBUG_KMS("LVDS downclock is found"
1027 " in EDID. Normal clock %dKhz, "
1028 "downclock %dKhz\n",
1029 fixed_mode->clock,
1030 dev_priv->lvds_downclock);
1031 }
Chris Wilson6a9d51b2012-11-21 16:14:03 +00001032 goto out;
1033 }
Jesse Barnes79e53942008-11-07 14:24:08 -08001034 }
Jesse Barnes79e53942008-11-07 14:24:08 -08001035 }
1036
1037 /* Failed to get EDID, what about VBT? */
Rodrigo Vivi41aa3442013-05-09 20:03:18 -03001038 if (dev_priv->vbt.lfp_lvds_vbt_mode) {
Chris Wilson6a9d51b2012-11-21 16:14:03 +00001039 DRM_DEBUG_KMS("using mode from VBT: ");
Rodrigo Vivi41aa3442013-05-09 20:03:18 -03001040 drm_mode_debug_printmodeline(dev_priv->vbt.lfp_lvds_vbt_mode);
Chris Wilson6a9d51b2012-11-21 16:14:03 +00001041
Rodrigo Vivi41aa3442013-05-09 20:03:18 -03001042 fixed_mode = drm_mode_duplicate(dev, dev_priv->vbt.lfp_lvds_vbt_mode);
Jani Nikuladd06f902012-10-19 14:51:50 +03001043 if (fixed_mode) {
1044 fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
Jesse Barnese285f3cd2009-01-14 10:53:36 -08001045 goto out;
1046 }
Jesse Barnes79e53942008-11-07 14:24:08 -08001047 }
1048
1049 /*
1050 * If we didn't get EDID, try checking if the panel is already turned
1051 * on. If so, assume that whatever is currently programmed is the
1052 * correct mode.
1053 */
Zhenyu Wang541998a2009-06-05 15:38:44 +08001054
Adam Jacksonf2b115e2009-12-03 17:14:42 -05001055 /* Ironlake: FIXME if still fail, not try pipe mode now */
Eric Anholtc619eed2010-01-28 16:45:52 -08001056 if (HAS_PCH_SPLIT(dev))
Zhenyu Wang541998a2009-06-05 15:38:44 +08001057 goto failed;
1058
Jesse Barnes79e53942008-11-07 14:24:08 -08001059 lvds = I915_READ(LVDS);
1060 pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0;
Chris Wilsonf875c152010-09-09 15:44:14 +01001061 crtc = intel_get_crtc_for_pipe(dev, pipe);
Jesse Barnes79e53942008-11-07 14:24:08 -08001062
1063 if (crtc && (lvds & LVDS_PORT_EN)) {
Jani Nikuladd06f902012-10-19 14:51:50 +03001064 fixed_mode = intel_crtc_mode_get(dev, crtc);
1065 if (fixed_mode) {
Chris Wilson6a9d51b2012-11-21 16:14:03 +00001066 DRM_DEBUG_KMS("using current (BIOS) mode: ");
1067 drm_mode_debug_printmodeline(fixed_mode);
Jani Nikuladd06f902012-10-19 14:51:50 +03001068 fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
Paul Collins565dcd42009-02-04 23:05:41 +13001069 goto out;
Jesse Barnes79e53942008-11-07 14:24:08 -08001070 }
1071 }
1072
1073 /* If we still don't have a mode after all that, give up. */
Jani Nikuladd06f902012-10-19 14:51:50 +03001074 if (!fixed_mode)
Jesse Barnes79e53942008-11-07 14:24:08 -08001075 goto failed;
1076
Jesse Barnes79e53942008-11-07 14:24:08 -08001077out:
Daniel Vetter4da98542014-03-21 23:22:35 +01001078 mutex_unlock(&dev->mode_config.mutex);
1079
Daniel Vetter7dec0602012-09-11 14:12:25 +02001080 lvds_encoder->is_dual_link = compute_is_dual_link_lvds(lvds_encoder);
Daniel Vetter13c7d872012-11-26 17:22:10 +01001081 DRM_DEBUG_KMS("detected %s-link lvds configuration\n",
1082 lvds_encoder->is_dual_link ? "dual" : "single");
1083
Daniel Vetter24ded202012-06-05 12:14:54 +02001084 /*
1085 * Unlock registers and just
1086 * leave them unlocked
1087 */
Eric Anholtc619eed2010-01-28 16:45:52 -08001088 if (HAS_PCH_SPLIT(dev)) {
Keith Packarded10fca2011-08-06 10:33:12 -07001089 I915_WRITE(PCH_PP_CONTROL,
1090 I915_READ(PCH_PP_CONTROL) | PANEL_UNLOCK_REGS);
1091 } else {
Keith Packarded10fca2011-08-06 10:33:12 -07001092 I915_WRITE(PP_CONTROL,
1093 I915_READ(PP_CONTROL) | PANEL_UNLOCK_REGS);
Zhenyu Wang541998a2009-06-05 15:38:44 +08001094 }
Jani Nikuladb1740a2012-10-19 14:51:45 +03001095 lvds_connector->lid_notifier.notifier_call = intel_lid_notify;
1096 if (acpi_lid_notifier_register(&lvds_connector->lid_notifier)) {
Zhao Yakui28c97732009-10-09 11:39:41 +08001097 DRM_DEBUG_KMS("lid notifier registration failed\n");
Jani Nikuladb1740a2012-10-19 14:51:45 +03001098 lvds_connector->lid_notifier.notifier_call = NULL;
Jesse Barnesc1c7af62009-09-10 15:28:03 -07001099 }
Jesse Barnes79e53942008-11-07 14:24:08 -08001100 drm_sysfs_connector_add(connector);
Matthew Garrettaaa6fd22011-08-12 12:11:33 +02001101
Vandana Kannan4b6ed682014-02-11 14:26:36 +05301102 intel_panel_init(&intel_connector->panel, fixed_mode, downclock_mode);
Jani Nikula0657b6b2012-10-19 14:51:46 +03001103 intel_panel_setup_backlight(connector);
Matthew Garrettaaa6fd22011-08-12 12:11:33 +02001104
Daniel Vetterc9093352013-06-06 22:22:47 +02001105 return;
Jesse Barnes79e53942008-11-07 14:24:08 -08001106
1107failed:
Daniel Vetter4da98542014-03-21 23:22:35 +01001108 mutex_unlock(&dev->mode_config.mutex);
1109
Zhao Yakui8a4c47f2009-07-20 13:48:04 +08001110 DRM_DEBUG_KMS("No LVDS modes found, disabling.\n");
Jesse Barnes79e53942008-11-07 14:24:08 -08001111 drm_connector_cleanup(connector);
Shaohua Li1991bdf2009-11-17 17:19:23 +08001112 drm_encoder_cleanup(encoder);
Jani Nikula29b99b42012-10-19 14:51:43 +03001113 kfree(lvds_encoder);
Jani Nikulac7362c42012-10-19 14:51:44 +03001114 kfree(lvds_connector);
Daniel Vetterc9093352013-06-06 22:22:47 +02001115 return;
Jesse Barnes79e53942008-11-07 14:24:08 -08001116}