intel_crt.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /*
  2. * Copyright © 2006-2007 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. *
  23. * Authors:
  24. * Eric Anholt <eric@anholt.net>
  25. */
  26. #include <linux/i2c.h>
  27. #include <linux/slab.h>
  28. #include "drmP.h"
  29. #include "drm.h"
  30. #include "drm_crtc.h"
  31. #include "drm_crtc_helper.h"
  32. #include "drm_edid.h"
  33. #include "intel_drv.h"
  34. #include "i915_drm.h"
  35. #include "i915_drv.h"
  36. /* Here's the desired hotplug mode */
  37. #define ADPA_HOTPLUG_BITS (ADPA_CRT_HOTPLUG_PERIOD_128 | \
  38. ADPA_CRT_HOTPLUG_WARMUP_10MS | \
  39. ADPA_CRT_HOTPLUG_SAMPLE_4S | \
  40. ADPA_CRT_HOTPLUG_VOLTAGE_50 | \
  41. ADPA_CRT_HOTPLUG_VOLREF_325MV | \
  42. ADPA_CRT_HOTPLUG_ENABLE)
  43. struct intel_crt {
  44. struct intel_encoder base;
  45. bool force_hotplug_required;
  46. };
  47. static struct intel_crt *intel_attached_crt(struct drm_connector *connector)
  48. {
  49. return container_of(intel_attached_encoder(connector),
  50. struct intel_crt, base);
  51. }
  52. static void intel_crt_dpms(struct drm_encoder *encoder, int mode)
  53. {
  54. struct drm_device *dev = encoder->dev;
  55. struct drm_i915_private *dev_priv = dev->dev_private;
  56. u32 temp, reg;
  57. if (HAS_PCH_SPLIT(dev))
  58. reg = PCH_ADPA;
  59. else
  60. reg = ADPA;
  61. temp = I915_READ(reg);
  62. temp &= ~(ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE);
  63. temp &= ~ADPA_DAC_ENABLE;
  64. switch(mode) {
  65. case DRM_MODE_DPMS_ON:
  66. temp |= ADPA_DAC_ENABLE;
  67. break;
  68. case DRM_MODE_DPMS_STANDBY:
  69. temp |= ADPA_DAC_ENABLE | ADPA_HSYNC_CNTL_DISABLE;
  70. break;
  71. case DRM_MODE_DPMS_SUSPEND:
  72. temp |= ADPA_DAC_ENABLE | ADPA_VSYNC_CNTL_DISABLE;
  73. break;
  74. case DRM_MODE_DPMS_OFF:
  75. temp |= ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE;
  76. break;
  77. }
  78. I915_WRITE(reg, temp);
  79. }
  80. static int intel_crt_mode_valid(struct drm_connector *connector,
  81. struct drm_display_mode *mode)
  82. {
  83. struct drm_device *dev = connector->dev;
  84. int max_clock = 0;
  85. if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
  86. return MODE_NO_DBLESCAN;
  87. if (mode->clock < 25000)
  88. return MODE_CLOCK_LOW;
  89. if (IS_GEN2(dev))
  90. max_clock = 350000;
  91. else
  92. max_clock = 400000;
  93. if (mode->clock > max_clock)
  94. return MODE_CLOCK_HIGH;
  95. return MODE_OK;
  96. }
  97. static bool intel_crt_mode_fixup(struct drm_encoder *encoder,
  98. struct drm_display_mode *mode,
  99. struct drm_display_mode *adjusted_mode)
  100. {
  101. return true;
  102. }
  103. static void intel_crt_mode_set(struct drm_encoder *encoder,
  104. struct drm_display_mode *mode,
  105. struct drm_display_mode *adjusted_mode)
  106. {
  107. struct drm_device *dev = encoder->dev;
  108. struct drm_crtc *crtc = encoder->crtc;
  109. struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
  110. struct drm_i915_private *dev_priv = dev->dev_private;
  111. int dpll_md_reg;
  112. u32 adpa, dpll_md;
  113. u32 adpa_reg;
  114. if (intel_crtc->pipe == 0)
  115. dpll_md_reg = DPLL_A_MD;
  116. else
  117. dpll_md_reg = DPLL_B_MD;
  118. if (HAS_PCH_SPLIT(dev))
  119. adpa_reg = PCH_ADPA;
  120. else
  121. adpa_reg = ADPA;
  122. /*
  123. * Disable separate mode multiplier used when cloning SDVO to CRT
  124. * XXX this needs to be adjusted when we really are cloning
  125. */
  126. if (INTEL_INFO(dev)->gen >= 4 && !HAS_PCH_SPLIT(dev)) {
  127. dpll_md = I915_READ(dpll_md_reg);
  128. I915_WRITE(dpll_md_reg,
  129. dpll_md & ~DPLL_MD_UDI_MULTIPLIER_MASK);
  130. }
  131. adpa = ADPA_HOTPLUG_BITS;
  132. if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
  133. adpa |= ADPA_HSYNC_ACTIVE_HIGH;
  134. if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
  135. adpa |= ADPA_VSYNC_ACTIVE_HIGH;
  136. if (intel_crtc->pipe == 0) {
  137. if (HAS_PCH_CPT(dev))
  138. adpa |= PORT_TRANS_A_SEL_CPT;
  139. else
  140. adpa |= ADPA_PIPE_A_SELECT;
  141. if (!HAS_PCH_SPLIT(dev))
  142. I915_WRITE(BCLRPAT_A, 0);
  143. } else {
  144. if (HAS_PCH_CPT(dev))
  145. adpa |= PORT_TRANS_B_SEL_CPT;
  146. else
  147. adpa |= ADPA_PIPE_B_SELECT;
  148. if (!HAS_PCH_SPLIT(dev))
  149. I915_WRITE(BCLRPAT_B, 0);
  150. }
  151. I915_WRITE(adpa_reg, adpa);
  152. }
  153. static bool intel_ironlake_crt_detect_hotplug(struct drm_connector *connector)
  154. {
  155. struct drm_device *dev = connector->dev;
  156. struct intel_crt *crt = intel_attached_crt(connector);
  157. struct drm_i915_private *dev_priv = dev->dev_private;
  158. u32 adpa;
  159. bool ret;
  160. /* The first time through, trigger an explicit detection cycle */
  161. if (crt->force_hotplug_required) {
  162. bool turn_off_dac = HAS_PCH_SPLIT(dev);
  163. u32 save_adpa;
  164. crt->force_hotplug_required = 0;
  165. save_adpa = adpa = I915_READ(PCH_ADPA);
  166. DRM_DEBUG_KMS("trigger hotplug detect cycle: adpa=0x%x\n", adpa);
  167. adpa |= ADPA_CRT_HOTPLUG_FORCE_TRIGGER;
  168. if (turn_off_dac)
  169. adpa &= ~ADPA_DAC_ENABLE;
  170. I915_WRITE(PCH_ADPA, adpa);
  171. if (wait_for((I915_READ(PCH_ADPA) & ADPA_CRT_HOTPLUG_FORCE_TRIGGER) == 0,
  172. 1000))
  173. DRM_DEBUG_KMS("timed out waiting for FORCE_TRIGGER");
  174. if (turn_off_dac) {
  175. I915_WRITE(PCH_ADPA, save_adpa);
  176. POSTING_READ(PCH_ADPA);
  177. }
  178. }
  179. /* Check the status to see if both blue and green are on now */
  180. adpa = I915_READ(PCH_ADPA);
  181. if ((adpa & ADPA_CRT_HOTPLUG_MONITOR_MASK) != 0)
  182. ret = true;
  183. else
  184. ret = false;
  185. DRM_DEBUG_KMS("ironlake hotplug adpa=0x%x, result %d\n", adpa, ret);
  186. return ret;
  187. }
  188. /**
  189. * Uses CRT_HOTPLUG_EN and CRT_HOTPLUG_STAT to detect CRT presence.
  190. *
  191. * Not for i915G/i915GM
  192. *
  193. * \return true if CRT is connected.
  194. * \return false if CRT is disconnected.
  195. */
  196. static bool intel_crt_detect_hotplug(struct drm_connector *connector)
  197. {
  198. struct drm_device *dev = connector->dev;
  199. struct drm_i915_private *dev_priv = dev->dev_private;
  200. u32 hotplug_en, orig, stat;
  201. bool ret = false;
  202. int i, tries = 0;
  203. if (HAS_PCH_SPLIT(dev))
  204. return intel_ironlake_crt_detect_hotplug(connector);
  205. /*
  206. * On 4 series desktop, CRT detect sequence need to be done twice
  207. * to get a reliable result.
  208. */
  209. if (IS_G4X(dev) && !IS_GM45(dev))
  210. tries = 2;
  211. else
  212. tries = 1;
  213. hotplug_en = orig = I915_READ(PORT_HOTPLUG_EN);
  214. hotplug_en |= CRT_HOTPLUG_FORCE_DETECT;
  215. for (i = 0; i < tries ; i++) {
  216. /* turn on the FORCE_DETECT */
  217. I915_WRITE(PORT_HOTPLUG_EN, hotplug_en);
  218. /* wait for FORCE_DETECT to go off */
  219. if (wait_for((I915_READ(PORT_HOTPLUG_EN) &
  220. CRT_HOTPLUG_FORCE_DETECT) == 0,
  221. 1000))
  222. DRM_DEBUG_KMS("timed out waiting for FORCE_DETECT to go off");
  223. }
  224. stat = I915_READ(PORT_HOTPLUG_STAT);
  225. if ((stat & CRT_HOTPLUG_MONITOR_MASK) != CRT_HOTPLUG_MONITOR_NONE)
  226. ret = true;
  227. /* clear the interrupt we just generated, if any */
  228. I915_WRITE(PORT_HOTPLUG_STAT, CRT_HOTPLUG_INT_STATUS);
  229. /* and put the bits back */
  230. I915_WRITE(PORT_HOTPLUG_EN, orig);
  231. return ret;
  232. }
  233. static bool intel_crt_ddc_probe(struct drm_i915_private *dev_priv, int ddc_bus)
  234. {
  235. u8 buf;
  236. struct i2c_msg msgs[] = {
  237. {
  238. .addr = 0xA0,
  239. .flags = 0,
  240. .len = 1,
  241. .buf = &buf,
  242. },
  243. };
  244. /* DDC monitor detect: Does it ACK a write to 0xA0? */
  245. return i2c_transfer(&dev_priv->gmbus[ddc_bus].adapter, msgs, 1) == 1;
  246. }
  247. static bool intel_crt_detect_ddc(struct drm_connector *connector)
  248. {
  249. struct intel_crt *crt = intel_attached_crt(connector);
  250. struct drm_i915_private *dev_priv = crt->base.base.dev->dev_private;
  251. /* CRT should always be at 0, but check anyway */
  252. if (crt->base.type != INTEL_OUTPUT_ANALOG)
  253. return false;
  254. if (intel_crt_ddc_probe(dev_priv, dev_priv->crt_ddc_pin)) {
  255. DRM_DEBUG_KMS("CRT detected via DDC:0xa0\n");
  256. return true;
  257. }
  258. if (intel_ddc_probe(&crt->base, dev_priv->crt_ddc_pin)) {
  259. struct edid *edid;
  260. bool is_digital = false;
  261. edid = drm_get_edid(connector,
  262. &dev_priv->gmbus[dev_priv->crt_ddc_pin].adapter);
  263. /*
  264. * This may be a DVI-I connector with a shared DDC
  265. * link between analog and digital outputs, so we
  266. * have to check the EDID input spec of the attached device.
  267. */
  268. if (edid != NULL) {
  269. is_digital = edid->input & DRM_EDID_INPUT_DIGITAL;
  270. connector->display_info.raw_edid = NULL;
  271. kfree(edid);
  272. }
  273. if (!is_digital) {
  274. DRM_DEBUG_KMS("CRT detected via DDC:0x50 [EDID]\n");
  275. return true;
  276. }
  277. }
  278. return false;
  279. }
  280. static enum drm_connector_status
  281. intel_crt_load_detect(struct drm_crtc *crtc, struct intel_crt *crt)
  282. {
  283. struct drm_encoder *encoder = &crt->base.base;
  284. struct drm_device *dev = encoder->dev;
  285. struct drm_i915_private *dev_priv = dev->dev_private;
  286. struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
  287. uint32_t pipe = intel_crtc->pipe;
  288. uint32_t save_bclrpat;
  289. uint32_t save_vtotal;
  290. uint32_t vtotal, vactive;
  291. uint32_t vsample;
  292. uint32_t vblank, vblank_start, vblank_end;
  293. uint32_t dsl;
  294. uint32_t bclrpat_reg;
  295. uint32_t vtotal_reg;
  296. uint32_t vblank_reg;
  297. uint32_t vsync_reg;
  298. uint32_t pipeconf_reg;
  299. uint32_t pipe_dsl_reg;
  300. uint8_t st00;
  301. enum drm_connector_status status;
  302. DRM_DEBUG_KMS("starting load-detect on CRT\n");
  303. if (pipe == 0) {
  304. bclrpat_reg = BCLRPAT_A;
  305. vtotal_reg = VTOTAL_A;
  306. vblank_reg = VBLANK_A;
  307. vsync_reg = VSYNC_A;
  308. pipeconf_reg = PIPEACONF;
  309. pipe_dsl_reg = PIPEADSL;
  310. } else {
  311. bclrpat_reg = BCLRPAT_B;
  312. vtotal_reg = VTOTAL_B;
  313. vblank_reg = VBLANK_B;
  314. vsync_reg = VSYNC_B;
  315. pipeconf_reg = PIPEBCONF;
  316. pipe_dsl_reg = PIPEBDSL;
  317. }
  318. save_bclrpat = I915_READ(bclrpat_reg);
  319. save_vtotal = I915_READ(vtotal_reg);
  320. vblank = I915_READ(vblank_reg);
  321. vtotal = ((save_vtotal >> 16) & 0xfff) + 1;
  322. vactive = (save_vtotal & 0x7ff) + 1;
  323. vblank_start = (vblank & 0xfff) + 1;
  324. vblank_end = ((vblank >> 16) & 0xfff) + 1;
  325. /* Set the border color to purple. */
  326. I915_WRITE(bclrpat_reg, 0x500050);
  327. if (!IS_GEN2(dev)) {
  328. uint32_t pipeconf = I915_READ(pipeconf_reg);
  329. I915_WRITE(pipeconf_reg, pipeconf | PIPECONF_FORCE_BORDER);
  330. POSTING_READ(pipeconf_reg);
  331. /* Wait for next Vblank to substitue
  332. * border color for Color info */
  333. intel_wait_for_vblank(dev, pipe);
  334. st00 = I915_READ8(VGA_MSR_WRITE);
  335. status = ((st00 & (1 << 4)) != 0) ?
  336. connector_status_connected :
  337. connector_status_disconnected;
  338. I915_WRITE(pipeconf_reg, pipeconf);
  339. } else {
  340. bool restore_vblank = false;
  341. int count, detect;
  342. /*
  343. * If there isn't any border, add some.
  344. * Yes, this will flicker
  345. */
  346. if (vblank_start <= vactive && vblank_end >= vtotal) {
  347. uint32_t vsync = I915_READ(vsync_reg);
  348. uint32_t vsync_start = (vsync & 0xffff) + 1;
  349. vblank_start = vsync_start;
  350. I915_WRITE(vblank_reg,
  351. (vblank_start - 1) |
  352. ((vblank_end - 1) << 16));
  353. restore_vblank = true;
  354. }
  355. /* sample in the vertical border, selecting the larger one */
  356. if (vblank_start - vactive >= vtotal - vblank_end)
  357. vsample = (vblank_start + vactive) >> 1;
  358. else
  359. vsample = (vtotal + vblank_end) >> 1;
  360. /*
  361. * Wait for the border to be displayed
  362. */
  363. while (I915_READ(pipe_dsl_reg) >= vactive)
  364. ;
  365. while ((dsl = I915_READ(pipe_dsl_reg)) <= vsample)
  366. ;
  367. /*
  368. * Watch ST00 for an entire scanline
  369. */
  370. detect = 0;
  371. count = 0;
  372. do {
  373. count++;
  374. /* Read the ST00 VGA status register */
  375. st00 = I915_READ8(VGA_MSR_WRITE);
  376. if (st00 & (1 << 4))
  377. detect++;
  378. } while ((I915_READ(pipe_dsl_reg) == dsl));
  379. /* restore vblank if necessary */
  380. if (restore_vblank)
  381. I915_WRITE(vblank_reg, vblank);
  382. /*
  383. * If more than 3/4 of the scanline detected a monitor,
  384. * then it is assumed to be present. This works even on i830,
  385. * where there isn't any way to force the border color across
  386. * the screen
  387. */
  388. status = detect * 4 > count * 3 ?
  389. connector_status_connected :
  390. connector_status_disconnected;
  391. }
  392. /* Restore previous settings */
  393. I915_WRITE(bclrpat_reg, save_bclrpat);
  394. return status;
  395. }
  396. static enum drm_connector_status
  397. intel_crt_detect(struct drm_connector *connector, bool force)
  398. {
  399. struct drm_device *dev = connector->dev;
  400. struct intel_crt *crt = intel_attached_crt(connector);
  401. struct drm_crtc *crtc;
  402. int dpms_mode;
  403. enum drm_connector_status status;
  404. if (I915_HAS_HOTPLUG(dev)) {
  405. if (intel_crt_detect_hotplug(connector)) {
  406. DRM_DEBUG_KMS("CRT detected via hotplug\n");
  407. return connector_status_connected;
  408. } else {
  409. DRM_DEBUG_KMS("CRT not detected via hotplug\n");
  410. return connector_status_disconnected;
  411. }
  412. }
  413. if (intel_crt_detect_ddc(connector))
  414. return connector_status_connected;
  415. if (!force)
  416. return connector->status;
  417. /* for pre-945g platforms use load detect */
  418. crtc = crt->base.base.crtc;
  419. if (crtc && crtc->enabled) {
  420. status = intel_crt_load_detect(crtc, crt);
  421. } else {
  422. crtc = intel_get_load_detect_pipe(&crt->base, connector,
  423. NULL, &dpms_mode);
  424. if (crtc) {
  425. if (intel_crt_detect_ddc(connector))
  426. status = connector_status_connected;
  427. else
  428. status = intel_crt_load_detect(crtc, crt);
  429. intel_release_load_detect_pipe(&crt->base,
  430. connector, dpms_mode);
  431. } else
  432. status = connector_status_unknown;
  433. }
  434. return status;
  435. }
  436. static void intel_crt_destroy(struct drm_connector *connector)
  437. {
  438. drm_sysfs_connector_remove(connector);
  439. drm_connector_cleanup(connector);
  440. kfree(connector);
  441. }
  442. static int intel_crt_get_modes(struct drm_connector *connector)
  443. {
  444. struct drm_device *dev = connector->dev;
  445. struct drm_i915_private *dev_priv = dev->dev_private;
  446. int ret;
  447. ret = intel_ddc_get_modes(connector,
  448. &dev_priv->gmbus[dev_priv->crt_ddc_pin].adapter);
  449. if (ret || !IS_G4X(dev))
  450. return ret;
  451. /* Try to probe digital port for output in DVI-I -> VGA mode. */
  452. return intel_ddc_get_modes(connector,
  453. &dev_priv->gmbus[GMBUS_PORT_DPB].adapter);
  454. }
  455. static int intel_crt_set_property(struct drm_connector *connector,
  456. struct drm_property *property,
  457. uint64_t value)
  458. {
  459. return 0;
  460. }
  461. /*
  462. * Routines for controlling stuff on the analog port
  463. */
  464. static const struct drm_encoder_helper_funcs intel_crt_helper_funcs = {
  465. .dpms = intel_crt_dpms,
  466. .mode_fixup = intel_crt_mode_fixup,
  467. .prepare = intel_encoder_prepare,
  468. .commit = intel_encoder_commit,
  469. .mode_set = intel_crt_mode_set,
  470. };
  471. static const struct drm_connector_funcs intel_crt_connector_funcs = {
  472. .dpms = drm_helper_connector_dpms,
  473. .detect = intel_crt_detect,
  474. .fill_modes = drm_helper_probe_single_connector_modes,
  475. .destroy = intel_crt_destroy,
  476. .set_property = intel_crt_set_property,
  477. };
  478. static const struct drm_connector_helper_funcs intel_crt_connector_helper_funcs = {
  479. .mode_valid = intel_crt_mode_valid,
  480. .get_modes = intel_crt_get_modes,
  481. .best_encoder = intel_best_encoder,
  482. };
  483. static const struct drm_encoder_funcs intel_crt_enc_funcs = {
  484. .destroy = intel_encoder_destroy,
  485. };
  486. void intel_crt_init(struct drm_device *dev)
  487. {
  488. struct drm_connector *connector;
  489. struct intel_crt *crt;
  490. struct intel_connector *intel_connector;
  491. struct drm_i915_private *dev_priv = dev->dev_private;
  492. crt = kzalloc(sizeof(struct intel_crt), GFP_KERNEL);
  493. if (!crt)
  494. return;
  495. intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
  496. if (!intel_connector) {
  497. kfree(crt);
  498. return;
  499. }
  500. connector = &intel_connector->base;
  501. drm_connector_init(dev, &intel_connector->base,
  502. &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
  503. drm_encoder_init(dev, &crt->base.base, &intel_crt_enc_funcs,
  504. DRM_MODE_ENCODER_DAC);
  505. intel_connector_attach_encoder(intel_connector, &crt->base);
  506. crt->base.type = INTEL_OUTPUT_ANALOG;
  507. crt->base.clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT |
  508. 1 << INTEL_ANALOG_CLONE_BIT |
  509. 1 << INTEL_SDVO_LVDS_CLONE_BIT);
  510. crt->base.crtc_mask = (1 << 0) | (1 << 1);
  511. connector->interlace_allowed = 1;
  512. connector->doublescan_allowed = 0;
  513. drm_encoder_helper_add(&crt->base.base, &intel_crt_helper_funcs);
  514. drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
  515. drm_sysfs_connector_add(connector);
  516. if (I915_HAS_HOTPLUG(dev))
  517. connector->polled = DRM_CONNECTOR_POLL_HPD;
  518. else
  519. connector->polled = DRM_CONNECTOR_POLL_CONNECT;
  520. /*
  521. * Configure the automatic hotplug detection stuff
  522. */
  523. crt->force_hotplug_required = 0;
  524. if (HAS_PCH_SPLIT(dev)) {
  525. u32 adpa;
  526. adpa = I915_READ(PCH_ADPA);
  527. adpa &= ~ADPA_CRT_HOTPLUG_MASK;
  528. adpa |= ADPA_HOTPLUG_BITS;
  529. I915_WRITE(PCH_ADPA, adpa);
  530. POSTING_READ(PCH_ADPA);
  531. DRM_DEBUG_KMS("pch crt adpa set to 0x%x\n", adpa);
  532. crt->force_hotplug_required = 1;
  533. }
  534. dev_priv->hotplug_supported_mask |= CRT_HOTPLUG_INT_STATUS;
  535. }