intel_lvds.c 32 KB

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