intel_lvds.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  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. #include <acpi/button.h>
  30. #include <linux/dmi.h>
  31. #include <linux/i2c.h>
  32. #include <linux/slab.h>
  33. #include <linux/vga_switcheroo.h>
  34. #include <drm/drmP.h>
  35. #include <drm/drm_atomic_helper.h>
  36. #include <drm/drm_crtc.h>
  37. #include <drm/drm_edid.h>
  38. #include "intel_drv.h"
  39. #include <drm/i915_drm.h>
  40. #include "i915_drv.h"
  41. #include <linux/acpi.h>
  42. /* Private structure for the integrated LVDS support */
  43. struct intel_lvds_connector {
  44. struct intel_connector base;
  45. struct notifier_block lid_notifier;
  46. };
  47. struct intel_lvds_pps {
  48. /* 100us units */
  49. int t1_t2;
  50. int t3;
  51. int t4;
  52. int t5;
  53. int tx;
  54. int divider;
  55. int port;
  56. bool powerdown_on_reset;
  57. };
  58. struct intel_lvds_encoder {
  59. struct intel_encoder base;
  60. bool is_dual_link;
  61. i915_reg_t reg;
  62. u32 a3_power;
  63. struct intel_lvds_pps init_pps;
  64. u32 init_lvds_val;
  65. struct intel_lvds_connector *attached_connector;
  66. };
  67. static struct intel_lvds_encoder *to_lvds_encoder(struct drm_encoder *encoder)
  68. {
  69. return container_of(encoder, struct intel_lvds_encoder, base.base);
  70. }
  71. static struct intel_lvds_connector *to_lvds_connector(struct drm_connector *connector)
  72. {
  73. return container_of(connector, struct intel_lvds_connector, base.base);
  74. }
  75. static bool intel_lvds_get_hw_state(struct intel_encoder *encoder,
  76. enum pipe *pipe)
  77. {
  78. struct drm_device *dev = encoder->base.dev;
  79. struct drm_i915_private *dev_priv = to_i915(dev);
  80. struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
  81. u32 tmp;
  82. bool ret;
  83. if (!intel_display_power_get_if_enabled(dev_priv,
  84. encoder->power_domain))
  85. return false;
  86. ret = false;
  87. tmp = I915_READ(lvds_encoder->reg);
  88. if (!(tmp & LVDS_PORT_EN))
  89. goto out;
  90. if (HAS_PCH_CPT(dev_priv))
  91. *pipe = PORT_TO_PIPE_CPT(tmp);
  92. else
  93. *pipe = PORT_TO_PIPE(tmp);
  94. ret = true;
  95. out:
  96. intel_display_power_put(dev_priv, encoder->power_domain);
  97. return ret;
  98. }
  99. static void intel_lvds_get_config(struct intel_encoder *encoder,
  100. struct intel_crtc_state *pipe_config)
  101. {
  102. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  103. struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
  104. u32 tmp, flags = 0;
  105. tmp = I915_READ(lvds_encoder->reg);
  106. if (tmp & LVDS_HSYNC_POLARITY)
  107. flags |= DRM_MODE_FLAG_NHSYNC;
  108. else
  109. flags |= DRM_MODE_FLAG_PHSYNC;
  110. if (tmp & LVDS_VSYNC_POLARITY)
  111. flags |= DRM_MODE_FLAG_NVSYNC;
  112. else
  113. flags |= DRM_MODE_FLAG_PVSYNC;
  114. pipe_config->base.adjusted_mode.flags |= flags;
  115. if (INTEL_GEN(dev_priv) < 5)
  116. pipe_config->gmch_pfit.lvds_border_bits =
  117. tmp & LVDS_BORDER_ENABLE;
  118. /* gen2/3 store dither state in pfit control, needs to match */
  119. if (INTEL_GEN(dev_priv) < 4) {
  120. tmp = I915_READ(PFIT_CONTROL);
  121. pipe_config->gmch_pfit.control |= tmp & PANEL_8TO6_DITHER_ENABLE;
  122. }
  123. pipe_config->base.adjusted_mode.crtc_clock = pipe_config->port_clock;
  124. }
  125. static void intel_lvds_pps_get_hw_state(struct drm_i915_private *dev_priv,
  126. struct intel_lvds_pps *pps)
  127. {
  128. u32 val;
  129. pps->powerdown_on_reset = I915_READ(PP_CONTROL(0)) & PANEL_POWER_RESET;
  130. val = I915_READ(PP_ON_DELAYS(0));
  131. pps->port = (val & PANEL_PORT_SELECT_MASK) >>
  132. PANEL_PORT_SELECT_SHIFT;
  133. pps->t1_t2 = (val & PANEL_POWER_UP_DELAY_MASK) >>
  134. PANEL_POWER_UP_DELAY_SHIFT;
  135. pps->t5 = (val & PANEL_LIGHT_ON_DELAY_MASK) >>
  136. PANEL_LIGHT_ON_DELAY_SHIFT;
  137. val = I915_READ(PP_OFF_DELAYS(0));
  138. pps->t3 = (val & PANEL_POWER_DOWN_DELAY_MASK) >>
  139. PANEL_POWER_DOWN_DELAY_SHIFT;
  140. pps->tx = (val & PANEL_LIGHT_OFF_DELAY_MASK) >>
  141. PANEL_LIGHT_OFF_DELAY_SHIFT;
  142. val = I915_READ(PP_DIVISOR(0));
  143. pps->divider = (val & PP_REFERENCE_DIVIDER_MASK) >>
  144. PP_REFERENCE_DIVIDER_SHIFT;
  145. val = (val & PANEL_POWER_CYCLE_DELAY_MASK) >>
  146. PANEL_POWER_CYCLE_DELAY_SHIFT;
  147. /*
  148. * Remove the BSpec specified +1 (100ms) offset that accounts for a
  149. * too short power-cycle delay due to the asynchronous programming of
  150. * the register.
  151. */
  152. if (val)
  153. val--;
  154. /* Convert from 100ms to 100us units */
  155. pps->t4 = val * 1000;
  156. if (INTEL_INFO(dev_priv)->gen <= 4 &&
  157. pps->t1_t2 == 0 && pps->t5 == 0 && pps->t3 == 0 && pps->tx == 0) {
  158. DRM_DEBUG_KMS("Panel power timings uninitialized, "
  159. "setting defaults\n");
  160. /* Set T2 to 40ms and T5 to 200ms in 100 usec units */
  161. pps->t1_t2 = 40 * 10;
  162. pps->t5 = 200 * 10;
  163. /* Set T3 to 35ms and Tx to 200ms in 100 usec units */
  164. pps->t3 = 35 * 10;
  165. pps->tx = 200 * 10;
  166. }
  167. DRM_DEBUG_DRIVER("LVDS PPS:t1+t2 %d t3 %d t4 %d t5 %d tx %d "
  168. "divider %d port %d powerdown_on_reset %d\n",
  169. pps->t1_t2, pps->t3, pps->t4, pps->t5, pps->tx,
  170. pps->divider, pps->port, pps->powerdown_on_reset);
  171. }
  172. static void intel_lvds_pps_init_hw(struct drm_i915_private *dev_priv,
  173. struct intel_lvds_pps *pps)
  174. {
  175. u32 val;
  176. val = I915_READ(PP_CONTROL(0));
  177. WARN_ON((val & PANEL_UNLOCK_MASK) != PANEL_UNLOCK_REGS);
  178. if (pps->powerdown_on_reset)
  179. val |= PANEL_POWER_RESET;
  180. I915_WRITE(PP_CONTROL(0), val);
  181. I915_WRITE(PP_ON_DELAYS(0), (pps->port << PANEL_PORT_SELECT_SHIFT) |
  182. (pps->t1_t2 << PANEL_POWER_UP_DELAY_SHIFT) |
  183. (pps->t5 << PANEL_LIGHT_ON_DELAY_SHIFT));
  184. I915_WRITE(PP_OFF_DELAYS(0), (pps->t3 << PANEL_POWER_DOWN_DELAY_SHIFT) |
  185. (pps->tx << PANEL_LIGHT_OFF_DELAY_SHIFT));
  186. val = pps->divider << PP_REFERENCE_DIVIDER_SHIFT;
  187. val |= (DIV_ROUND_UP(pps->t4, 1000) + 1) <<
  188. PANEL_POWER_CYCLE_DELAY_SHIFT;
  189. I915_WRITE(PP_DIVISOR(0), val);
  190. }
  191. static void intel_pre_enable_lvds(struct intel_encoder *encoder,
  192. struct intel_crtc_state *pipe_config,
  193. struct drm_connector_state *conn_state)
  194. {
  195. struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
  196. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  197. struct intel_crtc *crtc = to_intel_crtc(pipe_config->base.crtc);
  198. const struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
  199. int pipe = crtc->pipe;
  200. u32 temp;
  201. if (HAS_PCH_SPLIT(dev_priv)) {
  202. assert_fdi_rx_pll_disabled(dev_priv, pipe);
  203. assert_shared_dpll_disabled(dev_priv,
  204. pipe_config->shared_dpll);
  205. } else {
  206. assert_pll_disabled(dev_priv, pipe);
  207. }
  208. intel_lvds_pps_init_hw(dev_priv, &lvds_encoder->init_pps);
  209. temp = lvds_encoder->init_lvds_val;
  210. temp |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP;
  211. if (HAS_PCH_CPT(dev_priv)) {
  212. temp &= ~PORT_TRANS_SEL_MASK;
  213. temp |= PORT_TRANS_SEL_CPT(pipe);
  214. } else {
  215. if (pipe == 1) {
  216. temp |= LVDS_PIPEB_SELECT;
  217. } else {
  218. temp &= ~LVDS_PIPEB_SELECT;
  219. }
  220. }
  221. /* set the corresponsding LVDS_BORDER bit */
  222. temp &= ~LVDS_BORDER_ENABLE;
  223. temp |= pipe_config->gmch_pfit.lvds_border_bits;
  224. /* Set the B0-B3 data pairs corresponding to whether we're going to
  225. * set the DPLLs for dual-channel mode or not.
  226. */
  227. if (lvds_encoder->is_dual_link)
  228. temp |= LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP;
  229. else
  230. temp &= ~(LVDS_B0B3_POWER_UP | LVDS_CLKB_POWER_UP);
  231. /* It would be nice to set 24 vs 18-bit mode (LVDS_A3_POWER_UP)
  232. * appropriately here, but we need to look more thoroughly into how
  233. * panels behave in the two modes. For now, let's just maintain the
  234. * value we got from the BIOS.
  235. */
  236. temp &= ~LVDS_A3_POWER_MASK;
  237. temp |= lvds_encoder->a3_power;
  238. /* Set the dithering flag on LVDS as needed, note that there is no
  239. * special lvds dither control bit on pch-split platforms, dithering is
  240. * only controlled through the PIPECONF reg. */
  241. if (IS_GEN4(dev_priv)) {
  242. /* Bspec wording suggests that LVDS port dithering only exists
  243. * for 18bpp panels. */
  244. if (pipe_config->dither && pipe_config->pipe_bpp == 18)
  245. temp |= LVDS_ENABLE_DITHER;
  246. else
  247. temp &= ~LVDS_ENABLE_DITHER;
  248. }
  249. temp &= ~(LVDS_HSYNC_POLARITY | LVDS_VSYNC_POLARITY);
  250. if (adjusted_mode->flags & DRM_MODE_FLAG_NHSYNC)
  251. temp |= LVDS_HSYNC_POLARITY;
  252. if (adjusted_mode->flags & DRM_MODE_FLAG_NVSYNC)
  253. temp |= LVDS_VSYNC_POLARITY;
  254. I915_WRITE(lvds_encoder->reg, temp);
  255. }
  256. /**
  257. * Sets the power state for the panel.
  258. */
  259. static void intel_enable_lvds(struct intel_encoder *encoder,
  260. struct intel_crtc_state *pipe_config,
  261. struct drm_connector_state *conn_state)
  262. {
  263. struct drm_device *dev = encoder->base.dev;
  264. struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
  265. struct drm_i915_private *dev_priv = to_i915(dev);
  266. I915_WRITE(lvds_encoder->reg, I915_READ(lvds_encoder->reg) | LVDS_PORT_EN);
  267. I915_WRITE(PP_CONTROL(0), I915_READ(PP_CONTROL(0)) | PANEL_POWER_ON);
  268. POSTING_READ(lvds_encoder->reg);
  269. if (intel_wait_for_register(dev_priv, PP_STATUS(0), PP_ON, PP_ON, 1000))
  270. DRM_ERROR("timed out waiting for panel to power on\n");
  271. intel_panel_enable_backlight(pipe_config, conn_state);
  272. }
  273. static void intel_disable_lvds(struct intel_encoder *encoder,
  274. struct intel_crtc_state *old_crtc_state,
  275. struct drm_connector_state *old_conn_state)
  276. {
  277. struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
  278. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  279. I915_WRITE(PP_CONTROL(0), I915_READ(PP_CONTROL(0)) & ~PANEL_POWER_ON);
  280. if (intel_wait_for_register(dev_priv, PP_STATUS(0), PP_ON, 0, 1000))
  281. DRM_ERROR("timed out waiting for panel to power off\n");
  282. I915_WRITE(lvds_encoder->reg, I915_READ(lvds_encoder->reg) & ~LVDS_PORT_EN);
  283. POSTING_READ(lvds_encoder->reg);
  284. }
  285. static void gmch_disable_lvds(struct intel_encoder *encoder,
  286. struct intel_crtc_state *old_crtc_state,
  287. struct drm_connector_state *old_conn_state)
  288. {
  289. intel_panel_disable_backlight(old_conn_state);
  290. intel_disable_lvds(encoder, old_crtc_state, old_conn_state);
  291. }
  292. static void pch_disable_lvds(struct intel_encoder *encoder,
  293. struct intel_crtc_state *old_crtc_state,
  294. struct drm_connector_state *old_conn_state)
  295. {
  296. intel_panel_disable_backlight(old_conn_state);
  297. }
  298. static void pch_post_disable_lvds(struct intel_encoder *encoder,
  299. struct intel_crtc_state *old_crtc_state,
  300. struct drm_connector_state *old_conn_state)
  301. {
  302. intel_disable_lvds(encoder, old_crtc_state, old_conn_state);
  303. }
  304. static enum drm_mode_status
  305. intel_lvds_mode_valid(struct drm_connector *connector,
  306. struct drm_display_mode *mode)
  307. {
  308. struct intel_connector *intel_connector = to_intel_connector(connector);
  309. struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
  310. int max_pixclk = to_i915(connector->dev)->max_dotclk_freq;
  311. if (mode->hdisplay > fixed_mode->hdisplay)
  312. return MODE_PANEL;
  313. if (mode->vdisplay > fixed_mode->vdisplay)
  314. return MODE_PANEL;
  315. if (fixed_mode->clock > max_pixclk)
  316. return MODE_CLOCK_HIGH;
  317. return MODE_OK;
  318. }
  319. static bool intel_lvds_compute_config(struct intel_encoder *intel_encoder,
  320. struct intel_crtc_state *pipe_config,
  321. struct drm_connector_state *conn_state)
  322. {
  323. struct drm_i915_private *dev_priv = to_i915(intel_encoder->base.dev);
  324. struct intel_lvds_encoder *lvds_encoder =
  325. to_lvds_encoder(&intel_encoder->base);
  326. struct intel_connector *intel_connector =
  327. &lvds_encoder->attached_connector->base;
  328. struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
  329. struct intel_crtc *intel_crtc = to_intel_crtc(pipe_config->base.crtc);
  330. unsigned int lvds_bpp;
  331. /* Should never happen!! */
  332. if (INTEL_GEN(dev_priv) < 4 && intel_crtc->pipe == 0) {
  333. DRM_ERROR("Can't support LVDS on pipe A\n");
  334. return false;
  335. }
  336. if (lvds_encoder->a3_power == LVDS_A3_POWER_UP)
  337. lvds_bpp = 8*3;
  338. else
  339. lvds_bpp = 6*3;
  340. if (lvds_bpp != pipe_config->pipe_bpp && !pipe_config->bw_constrained) {
  341. DRM_DEBUG_KMS("forcing display bpp (was %d) to LVDS (%d)\n",
  342. pipe_config->pipe_bpp, lvds_bpp);
  343. pipe_config->pipe_bpp = lvds_bpp;
  344. }
  345. /*
  346. * We have timings from the BIOS for the panel, put them in
  347. * to the adjusted mode. The CRTC will be set up for this mode,
  348. * with the panel scaling set up to source from the H/VDisplay
  349. * of the original mode.
  350. */
  351. intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
  352. adjusted_mode);
  353. if (HAS_PCH_SPLIT(dev_priv)) {
  354. pipe_config->has_pch_encoder = true;
  355. intel_pch_panel_fitting(intel_crtc, pipe_config,
  356. conn_state->scaling_mode);
  357. } else {
  358. intel_gmch_panel_fitting(intel_crtc, pipe_config,
  359. conn_state->scaling_mode);
  360. }
  361. /*
  362. * XXX: It would be nice to support lower refresh rates on the
  363. * panels to reduce power consumption, and perhaps match the
  364. * user's requested refresh rate.
  365. */
  366. return true;
  367. }
  368. /**
  369. * Detect the LVDS connection.
  370. *
  371. * Since LVDS doesn't have hotlug, we use the lid as a proxy. Open means
  372. * connected and closed means disconnected. We also send hotplug events as
  373. * needed, using lid status notification from the input layer.
  374. */
  375. static enum drm_connector_status
  376. intel_lvds_detect(struct drm_connector *connector, bool force)
  377. {
  378. struct drm_i915_private *dev_priv = to_i915(connector->dev);
  379. enum drm_connector_status status;
  380. DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
  381. connector->base.id, connector->name);
  382. status = intel_panel_detect(dev_priv);
  383. if (status != connector_status_unknown)
  384. return status;
  385. return connector_status_connected;
  386. }
  387. /**
  388. * Return the list of DDC modes if available, or the BIOS fixed mode otherwise.
  389. */
  390. static int intel_lvds_get_modes(struct drm_connector *connector)
  391. {
  392. struct intel_lvds_connector *lvds_connector = to_lvds_connector(connector);
  393. struct drm_device *dev = connector->dev;
  394. struct drm_display_mode *mode;
  395. /* use cached edid if we have one */
  396. if (!IS_ERR_OR_NULL(lvds_connector->base.edid))
  397. return drm_add_edid_modes(connector, lvds_connector->base.edid);
  398. mode = drm_mode_duplicate(dev, lvds_connector->base.panel.fixed_mode);
  399. if (mode == NULL)
  400. return 0;
  401. drm_mode_probed_add(connector, mode);
  402. return 1;
  403. }
  404. static int intel_no_modeset_on_lid_dmi_callback(const struct dmi_system_id *id)
  405. {
  406. DRM_INFO("Skipping forced modeset for %s\n", id->ident);
  407. return 1;
  408. }
  409. /* The GPU hangs up on these systems if modeset is performed on LID open */
  410. static const struct dmi_system_id intel_no_modeset_on_lid[] = {
  411. {
  412. .callback = intel_no_modeset_on_lid_dmi_callback,
  413. .ident = "Toshiba Tecra A11",
  414. .matches = {
  415. DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
  416. DMI_MATCH(DMI_PRODUCT_NAME, "TECRA A11"),
  417. },
  418. },
  419. { } /* terminating entry */
  420. };
  421. /*
  422. * Lid events. Note the use of 'modeset':
  423. * - we set it to MODESET_ON_LID_OPEN on lid close,
  424. * and set it to MODESET_DONE on open
  425. * - we use it as a "only once" bit (ie we ignore
  426. * duplicate events where it was already properly set)
  427. * - the suspend/resume paths will set it to
  428. * MODESET_SUSPENDED and ignore the lid open event,
  429. * because they restore the mode ("lid open").
  430. */
  431. static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
  432. void *unused)
  433. {
  434. struct intel_lvds_connector *lvds_connector =
  435. container_of(nb, struct intel_lvds_connector, lid_notifier);
  436. struct drm_connector *connector = &lvds_connector->base.base;
  437. struct drm_device *dev = connector->dev;
  438. struct drm_i915_private *dev_priv = to_i915(dev);
  439. if (dev->switch_power_state != DRM_SWITCH_POWER_ON)
  440. return NOTIFY_OK;
  441. mutex_lock(&dev_priv->modeset_restore_lock);
  442. if (dev_priv->modeset_restore == MODESET_SUSPENDED)
  443. goto exit;
  444. /*
  445. * check and update the status of LVDS connector after receiving
  446. * the LID nofication event.
  447. */
  448. connector->status = connector->funcs->detect(connector, false);
  449. /* Don't force modeset on machines where it causes a GPU lockup */
  450. if (dmi_check_system(intel_no_modeset_on_lid))
  451. goto exit;
  452. if (!acpi_lid_open()) {
  453. /* do modeset on next lid open event */
  454. dev_priv->modeset_restore = MODESET_ON_LID_OPEN;
  455. goto exit;
  456. }
  457. if (dev_priv->modeset_restore == MODESET_DONE)
  458. goto exit;
  459. /*
  460. * Some old platform's BIOS love to wreak havoc while the lid is closed.
  461. * We try to detect this here and undo any damage. The split for PCH
  462. * platforms is rather conservative and a bit arbitrary expect that on
  463. * those platforms VGA disabling requires actual legacy VGA I/O access,
  464. * and as part of the cleanup in the hw state restore we also redisable
  465. * the vga plane.
  466. */
  467. if (!HAS_PCH_SPLIT(dev_priv))
  468. intel_display_resume(dev);
  469. dev_priv->modeset_restore = MODESET_DONE;
  470. exit:
  471. mutex_unlock(&dev_priv->modeset_restore_lock);
  472. return NOTIFY_OK;
  473. }
  474. /**
  475. * intel_lvds_destroy - unregister and free LVDS structures
  476. * @connector: connector to free
  477. *
  478. * Unregister the DDC bus for this connector then free the driver private
  479. * structure.
  480. */
  481. static void intel_lvds_destroy(struct drm_connector *connector)
  482. {
  483. struct intel_lvds_connector *lvds_connector =
  484. to_lvds_connector(connector);
  485. if (lvds_connector->lid_notifier.notifier_call)
  486. acpi_lid_notifier_unregister(&lvds_connector->lid_notifier);
  487. if (!IS_ERR_OR_NULL(lvds_connector->base.edid))
  488. kfree(lvds_connector->base.edid);
  489. intel_panel_fini(&lvds_connector->base.panel);
  490. drm_connector_cleanup(connector);
  491. kfree(connector);
  492. }
  493. static const struct drm_connector_helper_funcs intel_lvds_connector_helper_funcs = {
  494. .get_modes = intel_lvds_get_modes,
  495. .mode_valid = intel_lvds_mode_valid,
  496. .atomic_check = intel_digital_connector_atomic_check,
  497. };
  498. static const struct drm_connector_funcs intel_lvds_connector_funcs = {
  499. .detect = intel_lvds_detect,
  500. .fill_modes = drm_helper_probe_single_connector_modes,
  501. .atomic_get_property = intel_digital_connector_atomic_get_property,
  502. .atomic_set_property = intel_digital_connector_atomic_set_property,
  503. .late_register = intel_connector_register,
  504. .early_unregister = intel_connector_unregister,
  505. .destroy = intel_lvds_destroy,
  506. .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
  507. .atomic_duplicate_state = intel_digital_connector_duplicate_state,
  508. };
  509. static const struct drm_encoder_funcs intel_lvds_enc_funcs = {
  510. .destroy = intel_encoder_destroy,
  511. };
  512. static int intel_no_lvds_dmi_callback(const struct dmi_system_id *id)
  513. {
  514. DRM_INFO("Skipping LVDS initialization for %s\n", id->ident);
  515. return 1;
  516. }
  517. /* These systems claim to have LVDS, but really don't */
  518. static const struct dmi_system_id intel_no_lvds[] = {
  519. {
  520. .callback = intel_no_lvds_dmi_callback,
  521. .ident = "Apple Mac Mini (Core series)",
  522. .matches = {
  523. DMI_MATCH(DMI_SYS_VENDOR, "Apple"),
  524. DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"),
  525. },
  526. },
  527. {
  528. .callback = intel_no_lvds_dmi_callback,
  529. .ident = "Apple Mac Mini (Core 2 series)",
  530. .matches = {
  531. DMI_MATCH(DMI_SYS_VENDOR, "Apple"),
  532. DMI_MATCH(DMI_PRODUCT_NAME, "Macmini2,1"),
  533. },
  534. },
  535. {
  536. .callback = intel_no_lvds_dmi_callback,
  537. .ident = "MSI IM-945GSE-A",
  538. .matches = {
  539. DMI_MATCH(DMI_SYS_VENDOR, "MSI"),
  540. DMI_MATCH(DMI_PRODUCT_NAME, "A9830IMS"),
  541. },
  542. },
  543. {
  544. .callback = intel_no_lvds_dmi_callback,
  545. .ident = "Dell Studio Hybrid",
  546. .matches = {
  547. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  548. DMI_MATCH(DMI_PRODUCT_NAME, "Studio Hybrid 140g"),
  549. },
  550. },
  551. {
  552. .callback = intel_no_lvds_dmi_callback,
  553. .ident = "Dell OptiPlex FX170",
  554. .matches = {
  555. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  556. DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex FX170"),
  557. },
  558. },
  559. {
  560. .callback = intel_no_lvds_dmi_callback,
  561. .ident = "AOpen Mini PC",
  562. .matches = {
  563. DMI_MATCH(DMI_SYS_VENDOR, "AOpen"),
  564. DMI_MATCH(DMI_PRODUCT_NAME, "i965GMx-IF"),
  565. },
  566. },
  567. {
  568. .callback = intel_no_lvds_dmi_callback,
  569. .ident = "AOpen Mini PC MP915",
  570. .matches = {
  571. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  572. DMI_MATCH(DMI_BOARD_NAME, "i915GMx-F"),
  573. },
  574. },
  575. {
  576. .callback = intel_no_lvds_dmi_callback,
  577. .ident = "AOpen i915GMm-HFS",
  578. .matches = {
  579. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  580. DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
  581. },
  582. },
  583. {
  584. .callback = intel_no_lvds_dmi_callback,
  585. .ident = "AOpen i45GMx-I",
  586. .matches = {
  587. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  588. DMI_MATCH(DMI_BOARD_NAME, "i45GMx-I"),
  589. },
  590. },
  591. {
  592. .callback = intel_no_lvds_dmi_callback,
  593. .ident = "Aopen i945GTt-VFA",
  594. .matches = {
  595. DMI_MATCH(DMI_PRODUCT_VERSION, "AO00001JW"),
  596. },
  597. },
  598. {
  599. .callback = intel_no_lvds_dmi_callback,
  600. .ident = "Clientron U800",
  601. .matches = {
  602. DMI_MATCH(DMI_SYS_VENDOR, "Clientron"),
  603. DMI_MATCH(DMI_PRODUCT_NAME, "U800"),
  604. },
  605. },
  606. {
  607. .callback = intel_no_lvds_dmi_callback,
  608. .ident = "Clientron E830",
  609. .matches = {
  610. DMI_MATCH(DMI_SYS_VENDOR, "Clientron"),
  611. DMI_MATCH(DMI_PRODUCT_NAME, "E830"),
  612. },
  613. },
  614. {
  615. .callback = intel_no_lvds_dmi_callback,
  616. .ident = "Asus EeeBox PC EB1007",
  617. .matches = {
  618. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
  619. DMI_MATCH(DMI_PRODUCT_NAME, "EB1007"),
  620. },
  621. },
  622. {
  623. .callback = intel_no_lvds_dmi_callback,
  624. .ident = "Asus AT5NM10T-I",
  625. .matches = {
  626. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  627. DMI_MATCH(DMI_BOARD_NAME, "AT5NM10T-I"),
  628. },
  629. },
  630. {
  631. .callback = intel_no_lvds_dmi_callback,
  632. .ident = "Hewlett-Packard HP t5740",
  633. .matches = {
  634. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  635. DMI_MATCH(DMI_PRODUCT_NAME, " t5740"),
  636. },
  637. },
  638. {
  639. .callback = intel_no_lvds_dmi_callback,
  640. .ident = "Hewlett-Packard t5745",
  641. .matches = {
  642. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  643. DMI_MATCH(DMI_PRODUCT_NAME, "hp t5745"),
  644. },
  645. },
  646. {
  647. .callback = intel_no_lvds_dmi_callback,
  648. .ident = "Hewlett-Packard st5747",
  649. .matches = {
  650. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  651. DMI_MATCH(DMI_PRODUCT_NAME, "hp st5747"),
  652. },
  653. },
  654. {
  655. .callback = intel_no_lvds_dmi_callback,
  656. .ident = "MSI Wind Box DC500",
  657. .matches = {
  658. DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
  659. DMI_MATCH(DMI_BOARD_NAME, "MS-7469"),
  660. },
  661. },
  662. {
  663. .callback = intel_no_lvds_dmi_callback,
  664. .ident = "Gigabyte GA-D525TUD",
  665. .matches = {
  666. DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."),
  667. DMI_MATCH(DMI_BOARD_NAME, "D525TUD"),
  668. },
  669. },
  670. {
  671. .callback = intel_no_lvds_dmi_callback,
  672. .ident = "Supermicro X7SPA-H",
  673. .matches = {
  674. DMI_MATCH(DMI_SYS_VENDOR, "Supermicro"),
  675. DMI_MATCH(DMI_PRODUCT_NAME, "X7SPA-H"),
  676. },
  677. },
  678. {
  679. .callback = intel_no_lvds_dmi_callback,
  680. .ident = "Fujitsu Esprimo Q900",
  681. .matches = {
  682. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  683. DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Q900"),
  684. },
  685. },
  686. {
  687. .callback = intel_no_lvds_dmi_callback,
  688. .ident = "Intel D410PT",
  689. .matches = {
  690. DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
  691. DMI_MATCH(DMI_BOARD_NAME, "D410PT"),
  692. },
  693. },
  694. {
  695. .callback = intel_no_lvds_dmi_callback,
  696. .ident = "Intel D425KT",
  697. .matches = {
  698. DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
  699. DMI_EXACT_MATCH(DMI_BOARD_NAME, "D425KT"),
  700. },
  701. },
  702. {
  703. .callback = intel_no_lvds_dmi_callback,
  704. .ident = "Intel D510MO",
  705. .matches = {
  706. DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
  707. DMI_EXACT_MATCH(DMI_BOARD_NAME, "D510MO"),
  708. },
  709. },
  710. {
  711. .callback = intel_no_lvds_dmi_callback,
  712. .ident = "Intel D525MW",
  713. .matches = {
  714. DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
  715. DMI_EXACT_MATCH(DMI_BOARD_NAME, "D525MW"),
  716. },
  717. },
  718. { } /* terminating entry */
  719. };
  720. static int intel_dual_link_lvds_callback(const struct dmi_system_id *id)
  721. {
  722. DRM_INFO("Forcing lvds to dual link mode on %s\n", id->ident);
  723. return 1;
  724. }
  725. static const struct dmi_system_id intel_dual_link_lvds[] = {
  726. {
  727. .callback = intel_dual_link_lvds_callback,
  728. .ident = "Apple MacBook Pro 15\" (2010)",
  729. .matches = {
  730. DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
  731. DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro6,2"),
  732. },
  733. },
  734. {
  735. .callback = intel_dual_link_lvds_callback,
  736. .ident = "Apple MacBook Pro 15\" (2011)",
  737. .matches = {
  738. DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
  739. DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro8,2"),
  740. },
  741. },
  742. {
  743. .callback = intel_dual_link_lvds_callback,
  744. .ident = "Apple MacBook Pro 15\" (2012)",
  745. .matches = {
  746. DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
  747. DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro9,1"),
  748. },
  749. },
  750. { } /* terminating entry */
  751. };
  752. struct intel_encoder *intel_get_lvds_encoder(struct drm_device *dev)
  753. {
  754. struct intel_encoder *intel_encoder;
  755. for_each_intel_encoder(dev, intel_encoder)
  756. if (intel_encoder->type == INTEL_OUTPUT_LVDS)
  757. return intel_encoder;
  758. return NULL;
  759. }
  760. bool intel_is_dual_link_lvds(struct drm_device *dev)
  761. {
  762. struct intel_encoder *encoder = intel_get_lvds_encoder(dev);
  763. return encoder && to_lvds_encoder(&encoder->base)->is_dual_link;
  764. }
  765. static bool compute_is_dual_link_lvds(struct intel_lvds_encoder *lvds_encoder)
  766. {
  767. struct drm_device *dev = lvds_encoder->base.base.dev;
  768. unsigned int val;
  769. struct drm_i915_private *dev_priv = to_i915(dev);
  770. /* use the module option value if specified */
  771. if (i915.lvds_channel_mode > 0)
  772. return i915.lvds_channel_mode == 2;
  773. /* single channel LVDS is limited to 112 MHz */
  774. if (lvds_encoder->attached_connector->base.panel.fixed_mode->clock
  775. > 112999)
  776. return true;
  777. if (dmi_check_system(intel_dual_link_lvds))
  778. return true;
  779. /* BIOS should set the proper LVDS register value at boot, but
  780. * in reality, it doesn't set the value when the lid is closed;
  781. * we need to check "the value to be set" in VBT when LVDS
  782. * register is uninitialized.
  783. */
  784. val = I915_READ(lvds_encoder->reg);
  785. if (!(val & ~(LVDS_PIPE_MASK | LVDS_DETECTED)))
  786. val = dev_priv->vbt.bios_lvds_val;
  787. return (val & LVDS_CLKB_POWER_MASK) == LVDS_CLKB_POWER_UP;
  788. }
  789. static bool intel_lvds_supported(struct drm_i915_private *dev_priv)
  790. {
  791. /* With the introduction of the PCH we gained a dedicated
  792. * LVDS presence pin, use it. */
  793. if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv))
  794. return true;
  795. /* Otherwise LVDS was only attached to mobile products,
  796. * except for the inglorious 830gm */
  797. if (INTEL_GEN(dev_priv) <= 4 &&
  798. IS_MOBILE(dev_priv) && !IS_I830(dev_priv))
  799. return true;
  800. return false;
  801. }
  802. /**
  803. * intel_lvds_init - setup LVDS connectors on this device
  804. * @dev: drm device
  805. *
  806. * Create the connector, register the LVDS DDC bus, and try to figure out what
  807. * modes we can display on the LVDS panel (if present).
  808. */
  809. void intel_lvds_init(struct drm_i915_private *dev_priv)
  810. {
  811. struct drm_device *dev = &dev_priv->drm;
  812. struct intel_lvds_encoder *lvds_encoder;
  813. struct intel_encoder *intel_encoder;
  814. struct intel_lvds_connector *lvds_connector;
  815. struct intel_connector *intel_connector;
  816. struct drm_connector *connector;
  817. struct drm_encoder *encoder;
  818. struct drm_display_mode *scan; /* *modes, *bios_mode; */
  819. struct drm_display_mode *fixed_mode = NULL;
  820. struct drm_display_mode *downclock_mode = NULL;
  821. struct edid *edid;
  822. struct intel_crtc *crtc;
  823. i915_reg_t lvds_reg;
  824. u32 lvds;
  825. int pipe;
  826. u8 pin;
  827. u32 allowed_scalers;
  828. if (!intel_lvds_supported(dev_priv))
  829. return;
  830. /* Skip init on machines we know falsely report LVDS */
  831. if (dmi_check_system(intel_no_lvds))
  832. return;
  833. if (HAS_PCH_SPLIT(dev_priv))
  834. lvds_reg = PCH_LVDS;
  835. else
  836. lvds_reg = LVDS;
  837. lvds = I915_READ(lvds_reg);
  838. if (HAS_PCH_SPLIT(dev_priv)) {
  839. if ((lvds & LVDS_DETECTED) == 0)
  840. return;
  841. if (dev_priv->vbt.edp.support) {
  842. DRM_DEBUG_KMS("disable LVDS for eDP support\n");
  843. return;
  844. }
  845. }
  846. pin = GMBUS_PIN_PANEL;
  847. if (!intel_bios_is_lvds_present(dev_priv, &pin)) {
  848. if ((lvds & LVDS_PORT_EN) == 0) {
  849. DRM_DEBUG_KMS("LVDS is not present in VBT\n");
  850. return;
  851. }
  852. DRM_DEBUG_KMS("LVDS is not present in VBT, but enabled anyway\n");
  853. }
  854. lvds_encoder = kzalloc(sizeof(*lvds_encoder), GFP_KERNEL);
  855. if (!lvds_encoder)
  856. return;
  857. lvds_connector = kzalloc(sizeof(*lvds_connector), GFP_KERNEL);
  858. if (!lvds_connector) {
  859. kfree(lvds_encoder);
  860. return;
  861. }
  862. if (intel_connector_init(&lvds_connector->base) < 0) {
  863. kfree(lvds_connector);
  864. kfree(lvds_encoder);
  865. return;
  866. }
  867. lvds_encoder->attached_connector = lvds_connector;
  868. intel_encoder = &lvds_encoder->base;
  869. encoder = &intel_encoder->base;
  870. intel_connector = &lvds_connector->base;
  871. connector = &intel_connector->base;
  872. drm_connector_init(dev, &intel_connector->base, &intel_lvds_connector_funcs,
  873. DRM_MODE_CONNECTOR_LVDS);
  874. drm_encoder_init(dev, &intel_encoder->base, &intel_lvds_enc_funcs,
  875. DRM_MODE_ENCODER_LVDS, "LVDS");
  876. intel_encoder->enable = intel_enable_lvds;
  877. intel_encoder->pre_enable = intel_pre_enable_lvds;
  878. intel_encoder->compute_config = intel_lvds_compute_config;
  879. if (HAS_PCH_SPLIT(dev_priv)) {
  880. intel_encoder->disable = pch_disable_lvds;
  881. intel_encoder->post_disable = pch_post_disable_lvds;
  882. } else {
  883. intel_encoder->disable = gmch_disable_lvds;
  884. }
  885. intel_encoder->get_hw_state = intel_lvds_get_hw_state;
  886. intel_encoder->get_config = intel_lvds_get_config;
  887. intel_connector->get_hw_state = intel_connector_get_hw_state;
  888. intel_connector_attach_encoder(intel_connector, intel_encoder);
  889. intel_encoder->type = INTEL_OUTPUT_LVDS;
  890. intel_encoder->power_domain = POWER_DOMAIN_PORT_OTHER;
  891. intel_encoder->port = PORT_NONE;
  892. intel_encoder->cloneable = 0;
  893. if (HAS_PCH_SPLIT(dev_priv))
  894. intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
  895. else if (IS_GEN4(dev_priv))
  896. intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
  897. else
  898. intel_encoder->crtc_mask = (1 << 1);
  899. drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs);
  900. connector->display_info.subpixel_order = SubPixelHorizontalRGB;
  901. connector->interlace_allowed = false;
  902. connector->doublescan_allowed = false;
  903. lvds_encoder->reg = lvds_reg;
  904. /* create the scaling mode property */
  905. allowed_scalers = BIT(DRM_MODE_SCALE_ASPECT);
  906. allowed_scalers |= BIT(DRM_MODE_SCALE_FULLSCREEN);
  907. allowed_scalers |= BIT(DRM_MODE_SCALE_CENTER);
  908. drm_connector_attach_scaling_mode_property(connector, allowed_scalers);
  909. connector->state->scaling_mode = DRM_MODE_SCALE_ASPECT;
  910. intel_lvds_pps_get_hw_state(dev_priv, &lvds_encoder->init_pps);
  911. lvds_encoder->init_lvds_val = lvds;
  912. /*
  913. * LVDS discovery:
  914. * 1) check for EDID on DDC
  915. * 2) check for VBT data
  916. * 3) check to see if LVDS is already on
  917. * if none of the above, no panel
  918. * 4) make sure lid is open
  919. * if closed, act like it's not there for now
  920. */
  921. /*
  922. * Attempt to get the fixed panel mode from DDC. Assume that the
  923. * preferred mode is the right one.
  924. */
  925. mutex_lock(&dev->mode_config.mutex);
  926. if (vga_switcheroo_handler_flags() & VGA_SWITCHEROO_CAN_SWITCH_DDC)
  927. edid = drm_get_edid_switcheroo(connector,
  928. intel_gmbus_get_adapter(dev_priv, pin));
  929. else
  930. edid = drm_get_edid(connector,
  931. intel_gmbus_get_adapter(dev_priv, pin));
  932. if (edid) {
  933. if (drm_add_edid_modes(connector, edid)) {
  934. drm_mode_connector_update_edid_property(connector,
  935. edid);
  936. } else {
  937. kfree(edid);
  938. edid = ERR_PTR(-EINVAL);
  939. }
  940. } else {
  941. edid = ERR_PTR(-ENOENT);
  942. }
  943. lvds_connector->base.edid = edid;
  944. list_for_each_entry(scan, &connector->probed_modes, head) {
  945. if (scan->type & DRM_MODE_TYPE_PREFERRED) {
  946. DRM_DEBUG_KMS("using preferred mode from EDID: ");
  947. drm_mode_debug_printmodeline(scan);
  948. fixed_mode = drm_mode_duplicate(dev, scan);
  949. if (fixed_mode)
  950. goto out;
  951. }
  952. }
  953. /* Failed to get EDID, what about VBT? */
  954. if (dev_priv->vbt.lfp_lvds_vbt_mode) {
  955. DRM_DEBUG_KMS("using mode from VBT: ");
  956. drm_mode_debug_printmodeline(dev_priv->vbt.lfp_lvds_vbt_mode);
  957. fixed_mode = drm_mode_duplicate(dev, dev_priv->vbt.lfp_lvds_vbt_mode);
  958. if (fixed_mode) {
  959. fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
  960. connector->display_info.width_mm = fixed_mode->width_mm;
  961. connector->display_info.height_mm = fixed_mode->height_mm;
  962. goto out;
  963. }
  964. }
  965. /*
  966. * If we didn't get EDID, try checking if the panel is already turned
  967. * on. If so, assume that whatever is currently programmed is the
  968. * correct mode.
  969. */
  970. /* Ironlake: FIXME if still fail, not try pipe mode now */
  971. if (HAS_PCH_SPLIT(dev_priv))
  972. goto failed;
  973. pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0;
  974. crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
  975. if (crtc && (lvds & LVDS_PORT_EN)) {
  976. fixed_mode = intel_crtc_mode_get(dev, &crtc->base);
  977. if (fixed_mode) {
  978. DRM_DEBUG_KMS("using current (BIOS) mode: ");
  979. drm_mode_debug_printmodeline(fixed_mode);
  980. fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
  981. goto out;
  982. }
  983. }
  984. /* If we still don't have a mode after all that, give up. */
  985. if (!fixed_mode)
  986. goto failed;
  987. out:
  988. mutex_unlock(&dev->mode_config.mutex);
  989. intel_panel_init(&intel_connector->panel, fixed_mode, NULL,
  990. downclock_mode);
  991. intel_panel_setup_backlight(connector, INVALID_PIPE);
  992. lvds_encoder->is_dual_link = compute_is_dual_link_lvds(lvds_encoder);
  993. DRM_DEBUG_KMS("detected %s-link lvds configuration\n",
  994. lvds_encoder->is_dual_link ? "dual" : "single");
  995. lvds_encoder->a3_power = lvds & LVDS_A3_POWER_MASK;
  996. lvds_connector->lid_notifier.notifier_call = intel_lid_notify;
  997. if (acpi_lid_notifier_register(&lvds_connector->lid_notifier)) {
  998. DRM_DEBUG_KMS("lid notifier registration failed\n");
  999. lvds_connector->lid_notifier.notifier_call = NULL;
  1000. }
  1001. return;
  1002. failed:
  1003. mutex_unlock(&dev->mode_config.mutex);
  1004. DRM_DEBUG_KMS("No LVDS modes found, disabling.\n");
  1005. drm_connector_cleanup(connector);
  1006. drm_encoder_cleanup(encoder);
  1007. kfree(lvds_encoder);
  1008. kfree(lvds_connector);
  1009. return;
  1010. }