intel_hdmi.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. /*
  2. * Copyright 2006 Dave Airlie <airlied@linux.ie>
  3. * Copyright © 2006-2009 Intel Corporation
  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. * Jesse Barnes <jesse.barnes@intel.com>
  27. */
  28. #include <linux/i2c.h>
  29. #include <linux/slab.h>
  30. #include <linux/delay.h>
  31. #include "drmP.h"
  32. #include "drm.h"
  33. #include "drm_crtc.h"
  34. #include "drm_edid.h"
  35. #include "intel_drv.h"
  36. #include "i915_drm.h"
  37. #include "i915_drv.h"
  38. struct intel_hdmi {
  39. struct intel_encoder base;
  40. u32 sdvox_reg;
  41. int ddc_bus;
  42. uint32_t color_range;
  43. bool has_hdmi_sink;
  44. bool has_audio;
  45. enum hdmi_force_audio force_audio;
  46. void (*write_infoframe)(struct drm_encoder *encoder,
  47. struct dip_infoframe *frame);
  48. };
  49. static struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder)
  50. {
  51. return container_of(encoder, struct intel_hdmi, base.base);
  52. }
  53. static struct intel_hdmi *intel_attached_hdmi(struct drm_connector *connector)
  54. {
  55. return container_of(intel_attached_encoder(connector),
  56. struct intel_hdmi, base);
  57. }
  58. void intel_dip_infoframe_csum(struct dip_infoframe *frame)
  59. {
  60. uint8_t *data = (uint8_t *)frame;
  61. uint8_t sum = 0;
  62. unsigned i;
  63. frame->checksum = 0;
  64. frame->ecc = 0;
  65. for (i = 0; i < frame->len + DIP_HEADER_SIZE; i++)
  66. sum += data[i];
  67. frame->checksum = 0x100 - sum;
  68. }
  69. static u32 intel_infoframe_index(struct dip_infoframe *frame)
  70. {
  71. u32 flags = 0;
  72. switch (frame->type) {
  73. case DIP_TYPE_AVI:
  74. flags |= VIDEO_DIP_SELECT_AVI;
  75. break;
  76. case DIP_TYPE_SPD:
  77. flags |= VIDEO_DIP_SELECT_SPD;
  78. break;
  79. default:
  80. DRM_DEBUG_DRIVER("unknown info frame type %d\n", frame->type);
  81. break;
  82. }
  83. return flags;
  84. }
  85. static u32 intel_infoframe_flags(struct dip_infoframe *frame)
  86. {
  87. u32 flags = 0;
  88. switch (frame->type) {
  89. case DIP_TYPE_AVI:
  90. flags |= VIDEO_DIP_ENABLE_AVI | VIDEO_DIP_FREQ_VSYNC;
  91. break;
  92. case DIP_TYPE_SPD:
  93. flags |= VIDEO_DIP_ENABLE_SPD | VIDEO_DIP_FREQ_VSYNC;
  94. break;
  95. default:
  96. DRM_DEBUG_DRIVER("unknown info frame type %d\n", frame->type);
  97. break;
  98. }
  99. return flags;
  100. }
  101. static void i9xx_write_infoframe(struct drm_encoder *encoder,
  102. struct dip_infoframe *frame)
  103. {
  104. uint32_t *data = (uint32_t *)frame;
  105. struct drm_device *dev = encoder->dev;
  106. struct drm_i915_private *dev_priv = dev->dev_private;
  107. struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
  108. u32 port, flags, val = I915_READ(VIDEO_DIP_CTL);
  109. unsigned i, len = DIP_HEADER_SIZE + frame->len;
  110. /* XXX first guess at handling video port, is this corrent? */
  111. if (intel_hdmi->sdvox_reg == SDVOB)
  112. port = VIDEO_DIP_PORT_B;
  113. else if (intel_hdmi->sdvox_reg == SDVOC)
  114. port = VIDEO_DIP_PORT_C;
  115. else
  116. return;
  117. flags = intel_infoframe_index(frame);
  118. val &= ~VIDEO_DIP_SELECT_MASK;
  119. I915_WRITE(VIDEO_DIP_CTL, VIDEO_DIP_ENABLE | val | port | flags);
  120. mmiowb();
  121. for (i = 0; i < len; i += 4) {
  122. I915_WRITE(VIDEO_DIP_DATA, *data);
  123. data++;
  124. }
  125. mmiowb();
  126. flags |= intel_infoframe_flags(frame);
  127. I915_WRITE(VIDEO_DIP_CTL, VIDEO_DIP_ENABLE | val | port | flags);
  128. POSTING_READ(VIDEO_DIP_CTL);
  129. }
  130. static void ironlake_write_infoframe(struct drm_encoder *encoder,
  131. struct dip_infoframe *frame)
  132. {
  133. uint32_t *data = (uint32_t *)frame;
  134. struct drm_device *dev = encoder->dev;
  135. struct drm_i915_private *dev_priv = dev->dev_private;
  136. struct drm_crtc *crtc = encoder->crtc;
  137. struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
  138. int reg = TVIDEO_DIP_CTL(intel_crtc->pipe);
  139. unsigned i, len = DIP_HEADER_SIZE + frame->len;
  140. u32 flags, val = I915_READ(reg);
  141. intel_wait_for_vblank(dev, intel_crtc->pipe);
  142. flags = intel_infoframe_index(frame);
  143. val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */
  144. I915_WRITE(reg, VIDEO_DIP_ENABLE | val | flags);
  145. mmiowb();
  146. for (i = 0; i < len; i += 4) {
  147. I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data);
  148. data++;
  149. }
  150. mmiowb();
  151. flags |= intel_infoframe_flags(frame);
  152. I915_WRITE(reg, VIDEO_DIP_ENABLE | val | flags);
  153. POSTING_READ(reg);
  154. }
  155. static void intel_set_infoframe(struct drm_encoder *encoder,
  156. struct dip_infoframe *frame)
  157. {
  158. struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
  159. if (!intel_hdmi->has_hdmi_sink)
  160. return;
  161. intel_dip_infoframe_csum(frame);
  162. intel_hdmi->write_infoframe(encoder, frame);
  163. }
  164. static void intel_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
  165. {
  166. struct dip_infoframe avi_if = {
  167. .type = DIP_TYPE_AVI,
  168. .ver = DIP_VERSION_AVI,
  169. .len = DIP_LEN_AVI,
  170. };
  171. intel_set_infoframe(encoder, &avi_if);
  172. }
  173. static void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder)
  174. {
  175. struct dip_infoframe spd_if;
  176. memset(&spd_if, 0, sizeof(spd_if));
  177. spd_if.type = DIP_TYPE_SPD;
  178. spd_if.ver = DIP_VERSION_SPD;
  179. spd_if.len = DIP_LEN_SPD;
  180. strcpy(spd_if.body.spd.vn, "Intel");
  181. strcpy(spd_if.body.spd.pd, "Integrated gfx");
  182. spd_if.body.spd.sdi = DIP_SPD_PC;
  183. intel_set_infoframe(encoder, &spd_if);
  184. }
  185. static void intel_hdmi_mode_set(struct drm_encoder *encoder,
  186. struct drm_display_mode *mode,
  187. struct drm_display_mode *adjusted_mode)
  188. {
  189. struct drm_device *dev = encoder->dev;
  190. struct drm_i915_private *dev_priv = dev->dev_private;
  191. struct drm_crtc *crtc = encoder->crtc;
  192. struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
  193. struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
  194. u32 sdvox;
  195. sdvox = SDVO_ENCODING_HDMI | SDVO_BORDER_ENABLE;
  196. if (!HAS_PCH_SPLIT(dev))
  197. sdvox |= intel_hdmi->color_range;
  198. if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
  199. sdvox |= SDVO_VSYNC_ACTIVE_HIGH;
  200. if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
  201. sdvox |= SDVO_HSYNC_ACTIVE_HIGH;
  202. if (intel_crtc->bpp > 24)
  203. sdvox |= COLOR_FORMAT_12bpc;
  204. else
  205. sdvox |= COLOR_FORMAT_8bpc;
  206. /* Required on CPT */
  207. if (intel_hdmi->has_hdmi_sink && HAS_PCH_CPT(dev))
  208. sdvox |= HDMI_MODE_SELECT;
  209. if (intel_hdmi->has_audio) {
  210. DRM_DEBUG_DRIVER("Enabling HDMI audio on pipe %c\n",
  211. pipe_name(intel_crtc->pipe));
  212. sdvox |= SDVO_AUDIO_ENABLE;
  213. sdvox |= SDVO_NULL_PACKETS_DURING_VSYNC;
  214. intel_write_eld(encoder, adjusted_mode);
  215. }
  216. if (HAS_PCH_CPT(dev))
  217. sdvox |= PORT_TRANS_SEL_CPT(intel_crtc->pipe);
  218. else if (intel_crtc->pipe == 1)
  219. sdvox |= SDVO_PIPE_B_SELECT;
  220. I915_WRITE(intel_hdmi->sdvox_reg, sdvox);
  221. POSTING_READ(intel_hdmi->sdvox_reg);
  222. intel_hdmi_set_avi_infoframe(encoder);
  223. intel_hdmi_set_spd_infoframe(encoder);
  224. }
  225. static void intel_hdmi_dpms(struct drm_encoder *encoder, int mode)
  226. {
  227. struct drm_device *dev = encoder->dev;
  228. struct drm_i915_private *dev_priv = dev->dev_private;
  229. struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
  230. u32 temp;
  231. u32 enable_bits = SDVO_ENABLE;
  232. if (intel_hdmi->has_audio || mode != DRM_MODE_DPMS_ON)
  233. enable_bits |= SDVO_AUDIO_ENABLE;
  234. temp = I915_READ(intel_hdmi->sdvox_reg);
  235. /* HW workaround, need to toggle enable bit off and on for 12bpc, but
  236. * we do this anyway which shows more stable in testing.
  237. */
  238. if (HAS_PCH_SPLIT(dev)) {
  239. I915_WRITE(intel_hdmi->sdvox_reg, temp & ~SDVO_ENABLE);
  240. POSTING_READ(intel_hdmi->sdvox_reg);
  241. }
  242. if (mode != DRM_MODE_DPMS_ON) {
  243. temp &= ~enable_bits;
  244. } else {
  245. temp |= enable_bits;
  246. }
  247. I915_WRITE(intel_hdmi->sdvox_reg, temp);
  248. POSTING_READ(intel_hdmi->sdvox_reg);
  249. /* HW workaround, need to write this twice for issue that may result
  250. * in first write getting masked.
  251. */
  252. if (HAS_PCH_SPLIT(dev)) {
  253. I915_WRITE(intel_hdmi->sdvox_reg, temp);
  254. POSTING_READ(intel_hdmi->sdvox_reg);
  255. }
  256. }
  257. static int intel_hdmi_mode_valid(struct drm_connector *connector,
  258. struct drm_display_mode *mode)
  259. {
  260. if (mode->clock > 165000)
  261. return MODE_CLOCK_HIGH;
  262. if (mode->clock < 20000)
  263. return MODE_CLOCK_LOW;
  264. if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
  265. return MODE_NO_DBLESCAN;
  266. return MODE_OK;
  267. }
  268. static bool intel_hdmi_mode_fixup(struct drm_encoder *encoder,
  269. struct drm_display_mode *mode,
  270. struct drm_display_mode *adjusted_mode)
  271. {
  272. return true;
  273. }
  274. static enum drm_connector_status
  275. intel_hdmi_detect(struct drm_connector *connector, bool force)
  276. {
  277. struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
  278. struct drm_i915_private *dev_priv = connector->dev->dev_private;
  279. struct edid *edid;
  280. enum drm_connector_status status = connector_status_disconnected;
  281. intel_hdmi->has_hdmi_sink = false;
  282. intel_hdmi->has_audio = false;
  283. edid = drm_get_edid(connector,
  284. &dev_priv->gmbus[intel_hdmi->ddc_bus].adapter);
  285. if (edid) {
  286. if (edid->input & DRM_EDID_INPUT_DIGITAL) {
  287. status = connector_status_connected;
  288. if (intel_hdmi->force_audio != HDMI_AUDIO_OFF_DVI)
  289. intel_hdmi->has_hdmi_sink =
  290. drm_detect_hdmi_monitor(edid);
  291. intel_hdmi->has_audio = drm_detect_monitor_audio(edid);
  292. }
  293. connector->display_info.raw_edid = NULL;
  294. kfree(edid);
  295. }
  296. if (status == connector_status_connected) {
  297. if (intel_hdmi->force_audio != HDMI_AUDIO_AUTO)
  298. intel_hdmi->has_audio =
  299. (intel_hdmi->force_audio == HDMI_AUDIO_ON);
  300. }
  301. return status;
  302. }
  303. static int intel_hdmi_get_modes(struct drm_connector *connector)
  304. {
  305. struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
  306. struct drm_i915_private *dev_priv = connector->dev->dev_private;
  307. /* We should parse the EDID data and find out if it's an HDMI sink so
  308. * we can send audio to it.
  309. */
  310. return intel_ddc_get_modes(connector,
  311. &dev_priv->gmbus[intel_hdmi->ddc_bus].adapter);
  312. }
  313. static bool
  314. intel_hdmi_detect_audio(struct drm_connector *connector)
  315. {
  316. struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
  317. struct drm_i915_private *dev_priv = connector->dev->dev_private;
  318. struct edid *edid;
  319. bool has_audio = false;
  320. edid = drm_get_edid(connector,
  321. &dev_priv->gmbus[intel_hdmi->ddc_bus].adapter);
  322. if (edid) {
  323. if (edid->input & DRM_EDID_INPUT_DIGITAL)
  324. has_audio = drm_detect_monitor_audio(edid);
  325. connector->display_info.raw_edid = NULL;
  326. kfree(edid);
  327. }
  328. return has_audio;
  329. }
  330. static int
  331. intel_hdmi_set_property(struct drm_connector *connector,
  332. struct drm_property *property,
  333. uint64_t val)
  334. {
  335. struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
  336. struct drm_i915_private *dev_priv = connector->dev->dev_private;
  337. int ret;
  338. ret = drm_connector_property_set_value(connector, property, val);
  339. if (ret)
  340. return ret;
  341. if (property == dev_priv->force_audio_property) {
  342. enum hdmi_force_audio i = val;
  343. bool has_audio;
  344. if (i == intel_hdmi->force_audio)
  345. return 0;
  346. intel_hdmi->force_audio = i;
  347. if (i == HDMI_AUDIO_AUTO)
  348. has_audio = intel_hdmi_detect_audio(connector);
  349. else
  350. has_audio = (i == HDMI_AUDIO_ON);
  351. if (i == HDMI_AUDIO_OFF_DVI)
  352. intel_hdmi->has_hdmi_sink = 0;
  353. intel_hdmi->has_audio = has_audio;
  354. goto done;
  355. }
  356. if (property == dev_priv->broadcast_rgb_property) {
  357. if (val == !!intel_hdmi->color_range)
  358. return 0;
  359. intel_hdmi->color_range = val ? SDVO_COLOR_RANGE_16_235 : 0;
  360. goto done;
  361. }
  362. return -EINVAL;
  363. done:
  364. if (intel_hdmi->base.base.crtc) {
  365. struct drm_crtc *crtc = intel_hdmi->base.base.crtc;
  366. drm_crtc_helper_set_mode(crtc, &crtc->mode,
  367. crtc->x, crtc->y,
  368. crtc->fb);
  369. }
  370. return 0;
  371. }
  372. static void intel_hdmi_destroy(struct drm_connector *connector)
  373. {
  374. drm_sysfs_connector_remove(connector);
  375. drm_connector_cleanup(connector);
  376. kfree(connector);
  377. }
  378. static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs = {
  379. .dpms = intel_hdmi_dpms,
  380. .mode_fixup = intel_hdmi_mode_fixup,
  381. .prepare = intel_encoder_prepare,
  382. .mode_set = intel_hdmi_mode_set,
  383. .commit = intel_encoder_commit,
  384. };
  385. static const struct drm_connector_funcs intel_hdmi_connector_funcs = {
  386. .dpms = drm_helper_connector_dpms,
  387. .detect = intel_hdmi_detect,
  388. .fill_modes = drm_helper_probe_single_connector_modes,
  389. .set_property = intel_hdmi_set_property,
  390. .destroy = intel_hdmi_destroy,
  391. };
  392. static const struct drm_connector_helper_funcs intel_hdmi_connector_helper_funcs = {
  393. .get_modes = intel_hdmi_get_modes,
  394. .mode_valid = intel_hdmi_mode_valid,
  395. .best_encoder = intel_best_encoder,
  396. };
  397. static const struct drm_encoder_funcs intel_hdmi_enc_funcs = {
  398. .destroy = intel_encoder_destroy,
  399. };
  400. static void
  401. intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector)
  402. {
  403. intel_attach_force_audio_property(connector);
  404. intel_attach_broadcast_rgb_property(connector);
  405. }
  406. void intel_hdmi_init(struct drm_device *dev, int sdvox_reg)
  407. {
  408. struct drm_i915_private *dev_priv = dev->dev_private;
  409. struct drm_connector *connector;
  410. struct intel_encoder *intel_encoder;
  411. struct intel_connector *intel_connector;
  412. struct intel_hdmi *intel_hdmi;
  413. int i;
  414. intel_hdmi = kzalloc(sizeof(struct intel_hdmi), GFP_KERNEL);
  415. if (!intel_hdmi)
  416. return;
  417. intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
  418. if (!intel_connector) {
  419. kfree(intel_hdmi);
  420. return;
  421. }
  422. intel_encoder = &intel_hdmi->base;
  423. drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs,
  424. DRM_MODE_ENCODER_TMDS);
  425. connector = &intel_connector->base;
  426. drm_connector_init(dev, connector, &intel_hdmi_connector_funcs,
  427. DRM_MODE_CONNECTOR_HDMIA);
  428. drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs);
  429. intel_encoder->type = INTEL_OUTPUT_HDMI;
  430. connector->polled = DRM_CONNECTOR_POLL_HPD;
  431. connector->interlace_allowed = 1;
  432. connector->doublescan_allowed = 0;
  433. intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
  434. /* Set up the DDC bus. */
  435. if (sdvox_reg == SDVOB) {
  436. intel_encoder->clone_mask = (1 << INTEL_HDMIB_CLONE_BIT);
  437. intel_hdmi->ddc_bus = GMBUS_PORT_DPB;
  438. dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS;
  439. } else if (sdvox_reg == SDVOC) {
  440. intel_encoder->clone_mask = (1 << INTEL_HDMIC_CLONE_BIT);
  441. intel_hdmi->ddc_bus = GMBUS_PORT_DPC;
  442. dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS;
  443. } else if (sdvox_reg == HDMIB) {
  444. intel_encoder->clone_mask = (1 << INTEL_HDMID_CLONE_BIT);
  445. intel_hdmi->ddc_bus = GMBUS_PORT_DPB;
  446. dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS;
  447. } else if (sdvox_reg == HDMIC) {
  448. intel_encoder->clone_mask = (1 << INTEL_HDMIE_CLONE_BIT);
  449. intel_hdmi->ddc_bus = GMBUS_PORT_DPC;
  450. dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS;
  451. } else if (sdvox_reg == HDMID) {
  452. intel_encoder->clone_mask = (1 << INTEL_HDMIF_CLONE_BIT);
  453. intel_hdmi->ddc_bus = GMBUS_PORT_DPD;
  454. dev_priv->hotplug_supported_mask |= HDMID_HOTPLUG_INT_STATUS;
  455. }
  456. intel_hdmi->sdvox_reg = sdvox_reg;
  457. if (!HAS_PCH_SPLIT(dev)) {
  458. intel_hdmi->write_infoframe = i9xx_write_infoframe;
  459. I915_WRITE(VIDEO_DIP_CTL, 0);
  460. POSTING_READ(VIDEO_DIP_CTL);
  461. } else {
  462. intel_hdmi->write_infoframe = ironlake_write_infoframe;
  463. for_each_pipe(i) {
  464. I915_WRITE(TVIDEO_DIP_CTL(i), 0);
  465. POSTING_READ(TVIDEO_DIP_CTL(i));
  466. }
  467. }
  468. drm_encoder_helper_add(&intel_encoder->base, &intel_hdmi_helper_funcs);
  469. intel_hdmi_add_properties(intel_hdmi, connector);
  470. intel_connector_attach_encoder(intel_connector, intel_encoder);
  471. drm_sysfs_connector_add(connector);
  472. /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written
  473. * 0xd. Failure to do so will result in spurious interrupts being
  474. * generated on the port when a cable is not attached.
  475. */
  476. if (IS_G4X(dev) && !IS_GM45(dev)) {
  477. u32 temp = I915_READ(PEG_BAND_GAP_DATA);
  478. I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd);
  479. }
  480. }