intel_lvds.c 33 KB

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