intel_lvds.c 34 KB

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