intel_lvds.c 33 KB

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