intel_lvds.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149
  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 = to_i915(dev);
  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 = to_i915(dev);
  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 = to_i915(dev);
  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 (IS_GEN4(dev_priv)) {
  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 = to_i915(dev);
  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 (intel_wait_for_register(dev_priv, stat_reg, PP_ON, PP_ON, 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 = to_i915(dev);
  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 (intel_wait_for_register(dev_priv, 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 = to_i915(dev);
  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. };
  460. static const struct drm_connector_funcs intel_lvds_connector_funcs = {
  461. .dpms = drm_atomic_helper_connector_dpms,
  462. .detect = intel_lvds_detect,
  463. .fill_modes = drm_helper_probe_single_connector_modes,
  464. .set_property = intel_lvds_set_property,
  465. .atomic_get_property = intel_connector_atomic_get_property,
  466. .late_register = intel_connector_register,
  467. .early_unregister = intel_connector_unregister,
  468. .destroy = intel_lvds_destroy,
  469. .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
  470. .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
  471. };
  472. static const struct drm_encoder_funcs intel_lvds_enc_funcs = {
  473. .destroy = intel_encoder_destroy,
  474. };
  475. static int intel_no_lvds_dmi_callback(const struct dmi_system_id *id)
  476. {
  477. DRM_INFO("Skipping LVDS initialization for %s\n", id->ident);
  478. return 1;
  479. }
  480. /* These systems claim to have LVDS, but really don't */
  481. static const struct dmi_system_id intel_no_lvds[] = {
  482. {
  483. .callback = intel_no_lvds_dmi_callback,
  484. .ident = "Apple Mac Mini (Core series)",
  485. .matches = {
  486. DMI_MATCH(DMI_SYS_VENDOR, "Apple"),
  487. DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"),
  488. },
  489. },
  490. {
  491. .callback = intel_no_lvds_dmi_callback,
  492. .ident = "Apple Mac Mini (Core 2 series)",
  493. .matches = {
  494. DMI_MATCH(DMI_SYS_VENDOR, "Apple"),
  495. DMI_MATCH(DMI_PRODUCT_NAME, "Macmini2,1"),
  496. },
  497. },
  498. {
  499. .callback = intel_no_lvds_dmi_callback,
  500. .ident = "MSI IM-945GSE-A",
  501. .matches = {
  502. DMI_MATCH(DMI_SYS_VENDOR, "MSI"),
  503. DMI_MATCH(DMI_PRODUCT_NAME, "A9830IMS"),
  504. },
  505. },
  506. {
  507. .callback = intel_no_lvds_dmi_callback,
  508. .ident = "Dell Studio Hybrid",
  509. .matches = {
  510. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  511. DMI_MATCH(DMI_PRODUCT_NAME, "Studio Hybrid 140g"),
  512. },
  513. },
  514. {
  515. .callback = intel_no_lvds_dmi_callback,
  516. .ident = "Dell OptiPlex FX170",
  517. .matches = {
  518. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  519. DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex FX170"),
  520. },
  521. },
  522. {
  523. .callback = intel_no_lvds_dmi_callback,
  524. .ident = "AOpen Mini PC",
  525. .matches = {
  526. DMI_MATCH(DMI_SYS_VENDOR, "AOpen"),
  527. DMI_MATCH(DMI_PRODUCT_NAME, "i965GMx-IF"),
  528. },
  529. },
  530. {
  531. .callback = intel_no_lvds_dmi_callback,
  532. .ident = "AOpen Mini PC MP915",
  533. .matches = {
  534. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  535. DMI_MATCH(DMI_BOARD_NAME, "i915GMx-F"),
  536. },
  537. },
  538. {
  539. .callback = intel_no_lvds_dmi_callback,
  540. .ident = "AOpen i915GMm-HFS",
  541. .matches = {
  542. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  543. DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
  544. },
  545. },
  546. {
  547. .callback = intel_no_lvds_dmi_callback,
  548. .ident = "AOpen i45GMx-I",
  549. .matches = {
  550. DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
  551. DMI_MATCH(DMI_BOARD_NAME, "i45GMx-I"),
  552. },
  553. },
  554. {
  555. .callback = intel_no_lvds_dmi_callback,
  556. .ident = "Aopen i945GTt-VFA",
  557. .matches = {
  558. DMI_MATCH(DMI_PRODUCT_VERSION, "AO00001JW"),
  559. },
  560. },
  561. {
  562. .callback = intel_no_lvds_dmi_callback,
  563. .ident = "Clientron U800",
  564. .matches = {
  565. DMI_MATCH(DMI_SYS_VENDOR, "Clientron"),
  566. DMI_MATCH(DMI_PRODUCT_NAME, "U800"),
  567. },
  568. },
  569. {
  570. .callback = intel_no_lvds_dmi_callback,
  571. .ident = "Clientron E830",
  572. .matches = {
  573. DMI_MATCH(DMI_SYS_VENDOR, "Clientron"),
  574. DMI_MATCH(DMI_PRODUCT_NAME, "E830"),
  575. },
  576. },
  577. {
  578. .callback = intel_no_lvds_dmi_callback,
  579. .ident = "Asus EeeBox PC EB1007",
  580. .matches = {
  581. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
  582. DMI_MATCH(DMI_PRODUCT_NAME, "EB1007"),
  583. },
  584. },
  585. {
  586. .callback = intel_no_lvds_dmi_callback,
  587. .ident = "Asus AT5NM10T-I",
  588. .matches = {
  589. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  590. DMI_MATCH(DMI_BOARD_NAME, "AT5NM10T-I"),
  591. },
  592. },
  593. {
  594. .callback = intel_no_lvds_dmi_callback,
  595. .ident = "Hewlett-Packard HP t5740",
  596. .matches = {
  597. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  598. DMI_MATCH(DMI_PRODUCT_NAME, " t5740"),
  599. },
  600. },
  601. {
  602. .callback = intel_no_lvds_dmi_callback,
  603. .ident = "Hewlett-Packard t5745",
  604. .matches = {
  605. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  606. DMI_MATCH(DMI_PRODUCT_NAME, "hp t5745"),
  607. },
  608. },
  609. {
  610. .callback = intel_no_lvds_dmi_callback,
  611. .ident = "Hewlett-Packard st5747",
  612. .matches = {
  613. DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
  614. DMI_MATCH(DMI_PRODUCT_NAME, "hp st5747"),
  615. },
  616. },
  617. {
  618. .callback = intel_no_lvds_dmi_callback,
  619. .ident = "MSI Wind Box DC500",
  620. .matches = {
  621. DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
  622. DMI_MATCH(DMI_BOARD_NAME, "MS-7469"),
  623. },
  624. },
  625. {
  626. .callback = intel_no_lvds_dmi_callback,
  627. .ident = "Gigabyte GA-D525TUD",
  628. .matches = {
  629. DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."),
  630. DMI_MATCH(DMI_BOARD_NAME, "D525TUD"),
  631. },
  632. },
  633. {
  634. .callback = intel_no_lvds_dmi_callback,
  635. .ident = "Supermicro X7SPA-H",
  636. .matches = {
  637. DMI_MATCH(DMI_SYS_VENDOR, "Supermicro"),
  638. DMI_MATCH(DMI_PRODUCT_NAME, "X7SPA-H"),
  639. },
  640. },
  641. {
  642. .callback = intel_no_lvds_dmi_callback,
  643. .ident = "Fujitsu Esprimo Q900",
  644. .matches = {
  645. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  646. DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Q900"),
  647. },
  648. },
  649. {
  650. .callback = intel_no_lvds_dmi_callback,
  651. .ident = "Intel D410PT",
  652. .matches = {
  653. DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
  654. DMI_MATCH(DMI_BOARD_NAME, "D410PT"),
  655. },
  656. },
  657. {
  658. .callback = intel_no_lvds_dmi_callback,
  659. .ident = "Intel D425KT",
  660. .matches = {
  661. DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
  662. DMI_EXACT_MATCH(DMI_BOARD_NAME, "D425KT"),
  663. },
  664. },
  665. {
  666. .callback = intel_no_lvds_dmi_callback,
  667. .ident = "Intel D510MO",
  668. .matches = {
  669. DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
  670. DMI_EXACT_MATCH(DMI_BOARD_NAME, "D510MO"),
  671. },
  672. },
  673. {
  674. .callback = intel_no_lvds_dmi_callback,
  675. .ident = "Intel D525MW",
  676. .matches = {
  677. DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
  678. DMI_EXACT_MATCH(DMI_BOARD_NAME, "D525MW"),
  679. },
  680. },
  681. { } /* terminating entry */
  682. };
  683. static int intel_dual_link_lvds_callback(const struct dmi_system_id *id)
  684. {
  685. DRM_INFO("Forcing lvds to dual link mode on %s\n", id->ident);
  686. return 1;
  687. }
  688. static const struct dmi_system_id intel_dual_link_lvds[] = {
  689. {
  690. .callback = intel_dual_link_lvds_callback,
  691. .ident = "Apple MacBook Pro 15\" (2010)",
  692. .matches = {
  693. DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
  694. DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro6,2"),
  695. },
  696. },
  697. {
  698. .callback = intel_dual_link_lvds_callback,
  699. .ident = "Apple MacBook Pro 15\" (2011)",
  700. .matches = {
  701. DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
  702. DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro8,2"),
  703. },
  704. },
  705. {
  706. .callback = intel_dual_link_lvds_callback,
  707. .ident = "Apple MacBook Pro 15\" (2012)",
  708. .matches = {
  709. DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
  710. DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro9,1"),
  711. },
  712. },
  713. { } /* terminating entry */
  714. };
  715. struct intel_encoder *intel_get_lvds_encoder(struct drm_device *dev)
  716. {
  717. struct intel_encoder *intel_encoder;
  718. for_each_intel_encoder(dev, intel_encoder)
  719. if (intel_encoder->type == INTEL_OUTPUT_LVDS)
  720. return intel_encoder;
  721. return NULL;
  722. }
  723. bool intel_is_dual_link_lvds(struct drm_device *dev)
  724. {
  725. struct intel_encoder *encoder = intel_get_lvds_encoder(dev);
  726. return encoder && to_lvds_encoder(&encoder->base)->is_dual_link;
  727. }
  728. static bool compute_is_dual_link_lvds(struct intel_lvds_encoder *lvds_encoder)
  729. {
  730. struct drm_device *dev = lvds_encoder->base.base.dev;
  731. unsigned int val;
  732. struct drm_i915_private *dev_priv = to_i915(dev);
  733. /* use the module option value if specified */
  734. if (i915.lvds_channel_mode > 0)
  735. return i915.lvds_channel_mode == 2;
  736. /* single channel LVDS is limited to 112 MHz */
  737. if (lvds_encoder->attached_connector->base.panel.fixed_mode->clock
  738. > 112999)
  739. return true;
  740. if (dmi_check_system(intel_dual_link_lvds))
  741. return true;
  742. /* BIOS should set the proper LVDS register value at boot, but
  743. * in reality, it doesn't set the value when the lid is closed;
  744. * we need to check "the value to be set" in VBT when LVDS
  745. * register is uninitialized.
  746. */
  747. val = I915_READ(lvds_encoder->reg);
  748. if (!(val & ~(LVDS_PIPE_MASK | LVDS_DETECTED)))
  749. val = dev_priv->vbt.bios_lvds_val;
  750. return (val & LVDS_CLKB_POWER_MASK) == LVDS_CLKB_POWER_UP;
  751. }
  752. static bool intel_lvds_supported(struct drm_device *dev)
  753. {
  754. /* With the introduction of the PCH we gained a dedicated
  755. * LVDS presence pin, use it. */
  756. if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev))
  757. return true;
  758. /* Otherwise LVDS was only attached to mobile products,
  759. * except for the inglorious 830gm */
  760. if (INTEL_INFO(dev)->gen <= 4 && IS_MOBILE(dev) && !IS_I830(dev))
  761. return true;
  762. return false;
  763. }
  764. /**
  765. * intel_lvds_init - setup LVDS connectors on this device
  766. * @dev: drm device
  767. *
  768. * Create the connector, register the LVDS DDC bus, and try to figure out what
  769. * modes we can display on the LVDS panel (if present).
  770. */
  771. void intel_lvds_init(struct drm_device *dev)
  772. {
  773. struct drm_i915_private *dev_priv = to_i915(dev);
  774. struct intel_lvds_encoder *lvds_encoder;
  775. struct intel_encoder *intel_encoder;
  776. struct intel_lvds_connector *lvds_connector;
  777. struct intel_connector *intel_connector;
  778. struct drm_connector *connector;
  779. struct drm_encoder *encoder;
  780. struct drm_display_mode *scan; /* *modes, *bios_mode; */
  781. struct drm_display_mode *fixed_mode = NULL;
  782. struct drm_display_mode *downclock_mode = NULL;
  783. struct edid *edid;
  784. struct drm_crtc *crtc;
  785. i915_reg_t lvds_reg;
  786. u32 lvds;
  787. int pipe;
  788. u8 pin;
  789. /*
  790. * Unlock registers and just leave them unlocked. Do this before
  791. * checking quirk lists to avoid bogus WARNINGs.
  792. */
  793. if (HAS_PCH_SPLIT(dev)) {
  794. I915_WRITE(PCH_PP_CONTROL,
  795. I915_READ(PCH_PP_CONTROL) | PANEL_UNLOCK_REGS);
  796. } else if (INTEL_INFO(dev_priv)->gen < 5) {
  797. I915_WRITE(PP_CONTROL,
  798. I915_READ(PP_CONTROL) | PANEL_UNLOCK_REGS);
  799. }
  800. if (!intel_lvds_supported(dev))
  801. return;
  802. /* Skip init on machines we know falsely report LVDS */
  803. if (dmi_check_system(intel_no_lvds))
  804. return;
  805. if (HAS_PCH_SPLIT(dev))
  806. lvds_reg = PCH_LVDS;
  807. else
  808. lvds_reg = LVDS;
  809. lvds = I915_READ(lvds_reg);
  810. if (HAS_PCH_SPLIT(dev)) {
  811. if ((lvds & LVDS_DETECTED) == 0)
  812. return;
  813. if (dev_priv->vbt.edp.support) {
  814. DRM_DEBUG_KMS("disable LVDS for eDP support\n");
  815. return;
  816. }
  817. }
  818. pin = GMBUS_PIN_PANEL;
  819. if (!intel_bios_is_lvds_present(dev_priv, &pin)) {
  820. if ((lvds & LVDS_PORT_EN) == 0) {
  821. DRM_DEBUG_KMS("LVDS is not present in VBT\n");
  822. return;
  823. }
  824. DRM_DEBUG_KMS("LVDS is not present in VBT, but enabled anyway\n");
  825. }
  826. /* Set the Panel Power On/Off timings if uninitialized. */
  827. if (INTEL_INFO(dev_priv)->gen < 5 &&
  828. I915_READ(PP_ON_DELAYS) == 0 && I915_READ(PP_OFF_DELAYS) == 0) {
  829. /* Set T2 to 40ms and T5 to 200ms */
  830. I915_WRITE(PP_ON_DELAYS, 0x019007d0);
  831. /* Set T3 to 35ms and Tx to 200ms */
  832. I915_WRITE(PP_OFF_DELAYS, 0x015e07d0);
  833. DRM_DEBUG_KMS("Panel power timings uninitialized, setting defaults\n");
  834. }
  835. lvds_encoder = kzalloc(sizeof(*lvds_encoder), GFP_KERNEL);
  836. if (!lvds_encoder)
  837. return;
  838. lvds_connector = kzalloc(sizeof(*lvds_connector), GFP_KERNEL);
  839. if (!lvds_connector) {
  840. kfree(lvds_encoder);
  841. return;
  842. }
  843. if (intel_connector_init(&lvds_connector->base) < 0) {
  844. kfree(lvds_connector);
  845. kfree(lvds_encoder);
  846. return;
  847. }
  848. lvds_encoder->attached_connector = lvds_connector;
  849. intel_encoder = &lvds_encoder->base;
  850. encoder = &intel_encoder->base;
  851. intel_connector = &lvds_connector->base;
  852. connector = &intel_connector->base;
  853. drm_connector_init(dev, &intel_connector->base, &intel_lvds_connector_funcs,
  854. DRM_MODE_CONNECTOR_LVDS);
  855. drm_encoder_init(dev, &intel_encoder->base, &intel_lvds_enc_funcs,
  856. DRM_MODE_ENCODER_LVDS, "LVDS");
  857. intel_encoder->enable = intel_enable_lvds;
  858. intel_encoder->pre_enable = intel_pre_enable_lvds;
  859. intel_encoder->compute_config = intel_lvds_compute_config;
  860. if (HAS_PCH_SPLIT(dev_priv)) {
  861. intel_encoder->disable = pch_disable_lvds;
  862. intel_encoder->post_disable = pch_post_disable_lvds;
  863. } else {
  864. intel_encoder->disable = gmch_disable_lvds;
  865. }
  866. intel_encoder->get_hw_state = intel_lvds_get_hw_state;
  867. intel_encoder->get_config = intel_lvds_get_config;
  868. intel_connector->get_hw_state = intel_connector_get_hw_state;
  869. intel_connector_attach_encoder(intel_connector, intel_encoder);
  870. intel_encoder->type = INTEL_OUTPUT_LVDS;
  871. intel_encoder->cloneable = 0;
  872. if (HAS_PCH_SPLIT(dev))
  873. intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
  874. else if (IS_GEN4(dev))
  875. intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
  876. else
  877. intel_encoder->crtc_mask = (1 << 1);
  878. drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs);
  879. connector->display_info.subpixel_order = SubPixelHorizontalRGB;
  880. connector->interlace_allowed = false;
  881. connector->doublescan_allowed = false;
  882. lvds_encoder->reg = lvds_reg;
  883. /* create the scaling mode property */
  884. drm_mode_create_scaling_mode_property(dev);
  885. drm_object_attach_property(&connector->base,
  886. dev->mode_config.scaling_mode_property,
  887. DRM_MODE_SCALE_ASPECT);
  888. intel_connector->panel.fitting_mode = DRM_MODE_SCALE_ASPECT;
  889. /*
  890. * LVDS discovery:
  891. * 1) check for EDID on DDC
  892. * 2) check for VBT data
  893. * 3) check to see if LVDS is already on
  894. * if none of the above, no panel
  895. * 4) make sure lid is open
  896. * if closed, act like it's not there for now
  897. */
  898. /*
  899. * Attempt to get the fixed panel mode from DDC. Assume that the
  900. * preferred mode is the right one.
  901. */
  902. mutex_lock(&dev->mode_config.mutex);
  903. if (vga_switcheroo_handler_flags() & VGA_SWITCHEROO_CAN_SWITCH_DDC)
  904. edid = drm_get_edid_switcheroo(connector,
  905. intel_gmbus_get_adapter(dev_priv, pin));
  906. else
  907. edid = drm_get_edid(connector,
  908. intel_gmbus_get_adapter(dev_priv, pin));
  909. if (edid) {
  910. if (drm_add_edid_modes(connector, edid)) {
  911. drm_mode_connector_update_edid_property(connector,
  912. edid);
  913. } else {
  914. kfree(edid);
  915. edid = ERR_PTR(-EINVAL);
  916. }
  917. } else {
  918. edid = ERR_PTR(-ENOENT);
  919. }
  920. lvds_connector->base.edid = edid;
  921. if (IS_ERR_OR_NULL(edid)) {
  922. /* Didn't get an EDID, so
  923. * Set wide sync ranges so we get all modes
  924. * handed to valid_mode for checking
  925. */
  926. connector->display_info.min_vfreq = 0;
  927. connector->display_info.max_vfreq = 200;
  928. connector->display_info.min_hfreq = 0;
  929. connector->display_info.max_hfreq = 200;
  930. }
  931. list_for_each_entry(scan, &connector->probed_modes, head) {
  932. if (scan->type & DRM_MODE_TYPE_PREFERRED) {
  933. DRM_DEBUG_KMS("using preferred mode from EDID: ");
  934. drm_mode_debug_printmodeline(scan);
  935. fixed_mode = drm_mode_duplicate(dev, scan);
  936. if (fixed_mode)
  937. goto out;
  938. }
  939. }
  940. /* Failed to get EDID, what about VBT? */
  941. if (dev_priv->vbt.lfp_lvds_vbt_mode) {
  942. DRM_DEBUG_KMS("using mode from VBT: ");
  943. drm_mode_debug_printmodeline(dev_priv->vbt.lfp_lvds_vbt_mode);
  944. fixed_mode = drm_mode_duplicate(dev, dev_priv->vbt.lfp_lvds_vbt_mode);
  945. if (fixed_mode) {
  946. fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
  947. connector->display_info.width_mm = fixed_mode->width_mm;
  948. connector->display_info.height_mm = fixed_mode->height_mm;
  949. goto out;
  950. }
  951. }
  952. /*
  953. * If we didn't get EDID, try checking if the panel is already turned
  954. * on. If so, assume that whatever is currently programmed is the
  955. * correct mode.
  956. */
  957. /* Ironlake: FIXME if still fail, not try pipe mode now */
  958. if (HAS_PCH_SPLIT(dev))
  959. goto failed;
  960. pipe = (lvds & LVDS_PIPEB_SELECT) ? 1 : 0;
  961. crtc = intel_get_crtc_for_pipe(dev, pipe);
  962. if (crtc && (lvds & LVDS_PORT_EN)) {
  963. fixed_mode = intel_crtc_mode_get(dev, crtc);
  964. if (fixed_mode) {
  965. DRM_DEBUG_KMS("using current (BIOS) mode: ");
  966. drm_mode_debug_printmodeline(fixed_mode);
  967. fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
  968. goto out;
  969. }
  970. }
  971. /* If we still don't have a mode after all that, give up. */
  972. if (!fixed_mode)
  973. goto failed;
  974. out:
  975. mutex_unlock(&dev->mode_config.mutex);
  976. intel_panel_init(&intel_connector->panel, fixed_mode, downclock_mode);
  977. intel_panel_setup_backlight(connector, INVALID_PIPE);
  978. lvds_encoder->is_dual_link = compute_is_dual_link_lvds(lvds_encoder);
  979. DRM_DEBUG_KMS("detected %s-link lvds configuration\n",
  980. lvds_encoder->is_dual_link ? "dual" : "single");
  981. lvds_encoder->a3_power = lvds & LVDS_A3_POWER_MASK;
  982. lvds_connector->lid_notifier.notifier_call = intel_lid_notify;
  983. if (acpi_lid_notifier_register(&lvds_connector->lid_notifier)) {
  984. DRM_DEBUG_KMS("lid notifier registration failed\n");
  985. lvds_connector->lid_notifier.notifier_call = NULL;
  986. }
  987. return;
  988. failed:
  989. mutex_unlock(&dev->mode_config.mutex);
  990. DRM_DEBUG_KMS("No LVDS modes found, disabling.\n");
  991. drm_connector_cleanup(connector);
  992. drm_encoder_cleanup(encoder);
  993. kfree(lvds_encoder);
  994. kfree(lvds_connector);
  995. return;
  996. }