2 * Copyright © 2006-2007 Intel Corporation
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:
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
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.
24 * Eric Anholt <eric@anholt.net>
27 #include <linux/dmi.h>
28 #include <linux/i2c.h>
29 #include <linux/slab.h>
31 #include <drm/drm_crtc.h>
32 #include <drm/drm_crtc_helper.h>
33 #include <drm/drm_edid.h>
34 #include "intel_drv.h"
35 #include <drm/i915_drm.h>
38 /* Here's the desired hotplug mode */
39 #define ADPA_HOTPLUG_BITS (ADPA_CRT_HOTPLUG_PERIOD_128 | \
40 ADPA_CRT_HOTPLUG_WARMUP_10MS | \
41 ADPA_CRT_HOTPLUG_SAMPLE_4S | \
42 ADPA_CRT_HOTPLUG_VOLTAGE_50 | \
43 ADPA_CRT_HOTPLUG_VOLREF_325MV | \
44 ADPA_CRT_HOTPLUG_ENABLE)
47 struct intel_encoder base;
48 /* DPMS state is stored in the connector, which we need in the
49 * encoder's enable/disable callbacks */
50 struct intel_connector *connector;
51 bool force_hotplug_required;
55 static struct intel_crt *intel_attached_crt(struct drm_connector *connector)
57 return container_of(intel_attached_encoder(connector),
58 struct intel_crt, base);
61 static struct intel_crt *intel_encoder_to_crt(struct intel_encoder *encoder)
63 return container_of(encoder, struct intel_crt, base);
66 static bool intel_crt_get_hw_state(struct intel_encoder *encoder,
69 struct drm_device *dev = encoder->base.dev;
70 struct drm_i915_private *dev_priv = dev->dev_private;
71 struct intel_crt *crt = intel_encoder_to_crt(encoder);
74 tmp = I915_READ(crt->adpa_reg);
76 if (!(tmp & ADPA_DAC_ENABLE))
80 *pipe = PORT_TO_PIPE_CPT(tmp);
82 *pipe = PORT_TO_PIPE(tmp);
87 static void intel_crt_get_config(struct intel_encoder *encoder,
88 struct intel_crtc_config *pipe_config)
90 struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
91 struct intel_crt *crt = intel_encoder_to_crt(encoder);
94 tmp = I915_READ(crt->adpa_reg);
96 if (tmp & ADPA_HSYNC_ACTIVE_HIGH)
97 flags |= DRM_MODE_FLAG_PHSYNC;
99 flags |= DRM_MODE_FLAG_NHSYNC;
101 if (tmp & ADPA_VSYNC_ACTIVE_HIGH)
102 flags |= DRM_MODE_FLAG_PVSYNC;
104 flags |= DRM_MODE_FLAG_NVSYNC;
106 pipe_config->adjusted_mode.flags |= flags;
109 /* Note: The caller is required to filter out dpms modes not supported by the
111 static void intel_crt_set_dpms(struct intel_encoder *encoder, int mode)
113 struct drm_device *dev = encoder->base.dev;
114 struct drm_i915_private *dev_priv = dev->dev_private;
115 struct intel_crt *crt = intel_encoder_to_crt(encoder);
118 temp = I915_READ(crt->adpa_reg);
119 temp &= ~(ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE);
120 temp &= ~ADPA_DAC_ENABLE;
123 case DRM_MODE_DPMS_ON:
124 temp |= ADPA_DAC_ENABLE;
126 case DRM_MODE_DPMS_STANDBY:
127 temp |= ADPA_DAC_ENABLE | ADPA_HSYNC_CNTL_DISABLE;
129 case DRM_MODE_DPMS_SUSPEND:
130 temp |= ADPA_DAC_ENABLE | ADPA_VSYNC_CNTL_DISABLE;
132 case DRM_MODE_DPMS_OFF:
133 temp |= ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE;
137 I915_WRITE(crt->adpa_reg, temp);
140 static void intel_disable_crt(struct intel_encoder *encoder)
142 intel_crt_set_dpms(encoder, DRM_MODE_DPMS_OFF);
145 static void intel_enable_crt(struct intel_encoder *encoder)
147 struct intel_crt *crt = intel_encoder_to_crt(encoder);
149 intel_crt_set_dpms(encoder, crt->connector->base.dpms);
153 static void intel_crt_dpms(struct drm_connector *connector, int mode)
155 struct drm_device *dev = connector->dev;
156 struct intel_encoder *encoder = intel_attached_encoder(connector);
157 struct drm_crtc *crtc;
160 /* PCH platforms and VLV only support on/off. */
161 if (INTEL_INFO(dev)->gen >= 5 && mode != DRM_MODE_DPMS_ON)
162 mode = DRM_MODE_DPMS_OFF;
164 if (mode == connector->dpms)
167 old_dpms = connector->dpms;
168 connector->dpms = mode;
170 /* Only need to change hw state when actually enabled */
171 crtc = encoder->base.crtc;
173 encoder->connectors_active = false;
177 /* We need the pipe to run for anything but OFF. */
178 if (mode == DRM_MODE_DPMS_OFF)
179 encoder->connectors_active = false;
181 encoder->connectors_active = true;
183 if (mode < old_dpms) {
184 /* From off to on, enable the pipe first. */
185 intel_crtc_update_dpms(crtc);
187 intel_crt_set_dpms(encoder, mode);
189 intel_crt_set_dpms(encoder, mode);
191 intel_crtc_update_dpms(crtc);
194 intel_modeset_check_state(connector->dev);
197 static int intel_crt_mode_valid(struct drm_connector *connector,
198 struct drm_display_mode *mode)
200 struct drm_device *dev = connector->dev;
203 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
204 return MODE_NO_DBLESCAN;
206 if (mode->clock < 25000)
207 return MODE_CLOCK_LOW;
213 if (mode->clock > max_clock)
214 return MODE_CLOCK_HIGH;
216 /* The FDI receiver on LPT only supports 8bpc and only has 2 lanes. */
217 if (HAS_PCH_LPT(dev) &&
218 (ironlake_get_lanes_required(mode->clock, 270000, 24) > 2))
219 return MODE_CLOCK_HIGH;
224 static bool intel_crt_compute_config(struct intel_encoder *encoder,
225 struct intel_crtc_config *pipe_config)
227 struct drm_device *dev = encoder->base.dev;
229 if (HAS_PCH_SPLIT(dev))
230 pipe_config->has_pch_encoder = true;
232 /* LPT FDI RX only supports 8bpc. */
233 if (HAS_PCH_LPT(dev))
234 pipe_config->pipe_bpp = 24;
239 static void intel_crt_mode_set(struct drm_encoder *encoder,
240 struct drm_display_mode *mode,
241 struct drm_display_mode *adjusted_mode)
244 struct drm_device *dev = encoder->dev;
245 struct drm_crtc *crtc = encoder->crtc;
246 struct intel_crt *crt =
247 intel_encoder_to_crt(to_intel_encoder(encoder));
248 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
249 struct drm_i915_private *dev_priv = dev->dev_private;
252 if (HAS_PCH_SPLIT(dev))
253 adpa = ADPA_HOTPLUG_BITS;
257 if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
258 adpa |= ADPA_HSYNC_ACTIVE_HIGH;
259 if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
260 adpa |= ADPA_VSYNC_ACTIVE_HIGH;
262 /* For CPT allow 3 pipe config, for others just use A or B */
263 if (HAS_PCH_LPT(dev))
264 ; /* Those bits don't exist here */
265 else if (HAS_PCH_CPT(dev))
266 adpa |= PORT_TRANS_SEL_CPT(intel_crtc->pipe);
267 else if (intel_crtc->pipe == 0)
268 adpa |= ADPA_PIPE_A_SELECT;
270 adpa |= ADPA_PIPE_B_SELECT;
272 if (!HAS_PCH_SPLIT(dev))
273 I915_WRITE(BCLRPAT(intel_crtc->pipe), 0);
275 I915_WRITE(crt->adpa_reg, adpa);
278 static bool intel_ironlake_crt_detect_hotplug(struct drm_connector *connector)
280 struct drm_device *dev = connector->dev;
281 struct intel_crt *crt = intel_attached_crt(connector);
282 struct drm_i915_private *dev_priv = dev->dev_private;
286 /* The first time through, trigger an explicit detection cycle */
287 if (crt->force_hotplug_required) {
288 bool turn_off_dac = HAS_PCH_SPLIT(dev);
291 crt->force_hotplug_required = 0;
293 save_adpa = adpa = I915_READ(crt->adpa_reg);
294 DRM_DEBUG_KMS("trigger hotplug detect cycle: adpa=0x%x\n", adpa);
296 adpa |= ADPA_CRT_HOTPLUG_FORCE_TRIGGER;
298 adpa &= ~ADPA_DAC_ENABLE;
300 I915_WRITE(crt->adpa_reg, adpa);
302 if (wait_for((I915_READ(crt->adpa_reg) & ADPA_CRT_HOTPLUG_FORCE_TRIGGER) == 0,
304 DRM_DEBUG_KMS("timed out waiting for FORCE_TRIGGER");
307 I915_WRITE(crt->adpa_reg, save_adpa);
308 POSTING_READ(crt->adpa_reg);
312 /* Check the status to see if both blue and green are on now */
313 adpa = I915_READ(crt->adpa_reg);
314 if ((adpa & ADPA_CRT_HOTPLUG_MONITOR_MASK) != 0)
318 DRM_DEBUG_KMS("ironlake hotplug adpa=0x%x, result %d\n", adpa, ret);
323 static bool valleyview_crt_detect_hotplug(struct drm_connector *connector)
325 struct drm_device *dev = connector->dev;
326 struct intel_crt *crt = intel_attached_crt(connector);
327 struct drm_i915_private *dev_priv = dev->dev_private;
332 save_adpa = adpa = I915_READ(crt->adpa_reg);
333 DRM_DEBUG_KMS("trigger hotplug detect cycle: adpa=0x%x\n", adpa);
335 adpa |= ADPA_CRT_HOTPLUG_FORCE_TRIGGER;
337 I915_WRITE(crt->adpa_reg, adpa);
339 if (wait_for((I915_READ(crt->adpa_reg) & ADPA_CRT_HOTPLUG_FORCE_TRIGGER) == 0,
341 DRM_DEBUG_KMS("timed out waiting for FORCE_TRIGGER");
342 I915_WRITE(crt->adpa_reg, save_adpa);
345 /* Check the status to see if both blue and green are on now */
346 adpa = I915_READ(crt->adpa_reg);
347 if ((adpa & ADPA_CRT_HOTPLUG_MONITOR_MASK) != 0)
352 DRM_DEBUG_KMS("valleyview hotplug adpa=0x%x, result %d\n", adpa, ret);
354 /* FIXME: debug force function and remove */
361 * Uses CRT_HOTPLUG_EN and CRT_HOTPLUG_STAT to detect CRT presence.
363 * Not for i915G/i915GM
365 * \return true if CRT is connected.
366 * \return false if CRT is disconnected.
368 static bool intel_crt_detect_hotplug(struct drm_connector *connector)
370 struct drm_device *dev = connector->dev;
371 struct drm_i915_private *dev_priv = dev->dev_private;
372 u32 hotplug_en, orig, stat;
376 if (HAS_PCH_SPLIT(dev))
377 return intel_ironlake_crt_detect_hotplug(connector);
379 if (IS_VALLEYVIEW(dev))
380 return valleyview_crt_detect_hotplug(connector);
383 * On 4 series desktop, CRT detect sequence need to be done twice
384 * to get a reliable result.
387 if (IS_G4X(dev) && !IS_GM45(dev))
391 hotplug_en = orig = I915_READ(PORT_HOTPLUG_EN);
392 hotplug_en |= CRT_HOTPLUG_FORCE_DETECT;
394 for (i = 0; i < tries ; i++) {
395 /* turn on the FORCE_DETECT */
396 I915_WRITE(PORT_HOTPLUG_EN, hotplug_en);
397 /* wait for FORCE_DETECT to go off */
398 if (wait_for((I915_READ(PORT_HOTPLUG_EN) &
399 CRT_HOTPLUG_FORCE_DETECT) == 0,
401 DRM_DEBUG_KMS("timed out waiting for FORCE_DETECT to go off");
404 stat = I915_READ(PORT_HOTPLUG_STAT);
405 if ((stat & CRT_HOTPLUG_MONITOR_MASK) != CRT_HOTPLUG_MONITOR_NONE)
408 /* clear the interrupt we just generated, if any */
409 I915_WRITE(PORT_HOTPLUG_STAT, CRT_HOTPLUG_INT_STATUS);
411 /* and put the bits back */
412 I915_WRITE(PORT_HOTPLUG_EN, orig);
417 static struct edid *intel_crt_get_edid(struct drm_connector *connector,
418 struct i2c_adapter *i2c)
422 edid = drm_get_edid(connector, i2c);
424 if (!edid && !intel_gmbus_is_forced_bit(i2c)) {
425 DRM_DEBUG_KMS("CRT GMBUS EDID read failed, retry using GPIO bit-banging\n");
426 intel_gmbus_force_bit(i2c, true);
427 edid = drm_get_edid(connector, i2c);
428 intel_gmbus_force_bit(i2c, false);
434 /* local version of intel_ddc_get_modes() to use intel_crt_get_edid() */
435 static int intel_crt_ddc_get_modes(struct drm_connector *connector,
436 struct i2c_adapter *adapter)
441 edid = intel_crt_get_edid(connector, adapter);
445 ret = intel_connector_update_modes(connector, edid);
451 static bool intel_crt_detect_ddc(struct drm_connector *connector)
453 struct intel_crt *crt = intel_attached_crt(connector);
454 struct drm_i915_private *dev_priv = crt->base.base.dev->dev_private;
456 struct i2c_adapter *i2c;
458 BUG_ON(crt->base.type != INTEL_OUTPUT_ANALOG);
460 i2c = intel_gmbus_get_adapter(dev_priv, dev_priv->vbt.crt_ddc_pin);
461 edid = intel_crt_get_edid(connector, i2c);
464 bool is_digital = edid->input & DRM_EDID_INPUT_DIGITAL;
467 * This may be a DVI-I connector with a shared DDC
468 * link between analog and digital outputs, so we
469 * have to check the EDID input spec of the attached device.
472 DRM_DEBUG_KMS("CRT detected via DDC:0x50 [EDID]\n");
476 DRM_DEBUG_KMS("CRT not detected via DDC:0x50 [EDID reports a digital panel]\n");
478 DRM_DEBUG_KMS("CRT not detected via DDC:0x50 [no valid EDID found]\n");
486 static enum drm_connector_status
487 intel_crt_load_detect(struct intel_crt *crt)
489 struct drm_device *dev = crt->base.base.dev;
490 struct drm_i915_private *dev_priv = dev->dev_private;
491 uint32_t pipe = to_intel_crtc(crt->base.base.crtc)->pipe;
492 uint32_t save_bclrpat;
493 uint32_t save_vtotal;
494 uint32_t vtotal, vactive;
496 uint32_t vblank, vblank_start, vblank_end;
498 uint32_t bclrpat_reg;
502 uint32_t pipeconf_reg;
503 uint32_t pipe_dsl_reg;
505 enum drm_connector_status status;
507 DRM_DEBUG_KMS("starting load-detect on CRT\n");
509 bclrpat_reg = BCLRPAT(pipe);
510 vtotal_reg = VTOTAL(pipe);
511 vblank_reg = VBLANK(pipe);
512 vsync_reg = VSYNC(pipe);
513 pipeconf_reg = PIPECONF(pipe);
514 pipe_dsl_reg = PIPEDSL(pipe);
516 save_bclrpat = I915_READ(bclrpat_reg);
517 save_vtotal = I915_READ(vtotal_reg);
518 vblank = I915_READ(vblank_reg);
520 vtotal = ((save_vtotal >> 16) & 0xfff) + 1;
521 vactive = (save_vtotal & 0x7ff) + 1;
523 vblank_start = (vblank & 0xfff) + 1;
524 vblank_end = ((vblank >> 16) & 0xfff) + 1;
526 /* Set the border color to purple. */
527 I915_WRITE(bclrpat_reg, 0x500050);
530 uint32_t pipeconf = I915_READ(pipeconf_reg);
531 I915_WRITE(pipeconf_reg, pipeconf | PIPECONF_FORCE_BORDER);
532 POSTING_READ(pipeconf_reg);
533 /* Wait for next Vblank to substitue
534 * border color for Color info */
535 intel_wait_for_vblank(dev, pipe);
536 st00 = I915_READ8(VGA_MSR_WRITE);
537 status = ((st00 & (1 << 4)) != 0) ?
538 connector_status_connected :
539 connector_status_disconnected;
541 I915_WRITE(pipeconf_reg, pipeconf);
543 bool restore_vblank = false;
547 * If there isn't any border, add some.
548 * Yes, this will flicker
550 if (vblank_start <= vactive && vblank_end >= vtotal) {
551 uint32_t vsync = I915_READ(vsync_reg);
552 uint32_t vsync_start = (vsync & 0xffff) + 1;
554 vblank_start = vsync_start;
555 I915_WRITE(vblank_reg,
557 ((vblank_end - 1) << 16));
558 restore_vblank = true;
560 /* sample in the vertical border, selecting the larger one */
561 if (vblank_start - vactive >= vtotal - vblank_end)
562 vsample = (vblank_start + vactive) >> 1;
564 vsample = (vtotal + vblank_end) >> 1;
567 * Wait for the border to be displayed
569 while (I915_READ(pipe_dsl_reg) >= vactive)
571 while ((dsl = I915_READ(pipe_dsl_reg)) <= vsample)
574 * Watch ST00 for an entire scanline
580 /* Read the ST00 VGA status register */
581 st00 = I915_READ8(VGA_MSR_WRITE);
584 } while ((I915_READ(pipe_dsl_reg) == dsl));
586 /* restore vblank if necessary */
588 I915_WRITE(vblank_reg, vblank);
590 * If more than 3/4 of the scanline detected a monitor,
591 * then it is assumed to be present. This works even on i830,
592 * where there isn't any way to force the border color across
595 status = detect * 4 > count * 3 ?
596 connector_status_connected :
597 connector_status_disconnected;
600 /* Restore previous settings */
601 I915_WRITE(bclrpat_reg, save_bclrpat);
606 static enum drm_connector_status
607 intel_crt_detect(struct drm_connector *connector, bool force)
609 struct drm_device *dev = connector->dev;
610 struct intel_crt *crt = intel_attached_crt(connector);
611 enum drm_connector_status status;
612 struct intel_load_detect_pipe tmp;
614 if (I915_HAS_HOTPLUG(dev)) {
615 /* We can not rely on the HPD pin always being correctly wired
616 * up, for example many KVM do not pass it through, and so
617 * only trust an assertion that the monitor is connected.
619 if (intel_crt_detect_hotplug(connector)) {
620 DRM_DEBUG_KMS("CRT detected via hotplug\n");
621 return connector_status_connected;
623 DRM_DEBUG_KMS("CRT not detected via hotplug\n");
626 if (intel_crt_detect_ddc(connector))
627 return connector_status_connected;
629 /* Load detection is broken on HPD capable machines. Whoever wants a
630 * broken monitor (without edid) to work behind a broken kvm (that fails
631 * to have the right resistors for HP detection) needs to fix this up.
632 * For now just bail out. */
633 if (I915_HAS_HOTPLUG(dev))
634 return connector_status_disconnected;
637 return connector->status;
639 /* for pre-945g platforms use load detect */
640 if (intel_get_load_detect_pipe(connector, NULL, &tmp)) {
641 if (intel_crt_detect_ddc(connector))
642 status = connector_status_connected;
644 status = intel_crt_load_detect(crt);
645 intel_release_load_detect_pipe(connector, &tmp);
647 status = connector_status_unknown;
652 static void intel_crt_destroy(struct drm_connector *connector)
654 drm_sysfs_connector_remove(connector);
655 drm_connector_cleanup(connector);
659 static int intel_crt_get_modes(struct drm_connector *connector)
661 struct drm_device *dev = connector->dev;
662 struct drm_i915_private *dev_priv = dev->dev_private;
664 struct i2c_adapter *i2c;
666 i2c = intel_gmbus_get_adapter(dev_priv, dev_priv->vbt.crt_ddc_pin);
667 ret = intel_crt_ddc_get_modes(connector, i2c);
668 if (ret || !IS_G4X(dev))
671 /* Try to probe digital port for output in DVI-I -> VGA mode. */
672 i2c = intel_gmbus_get_adapter(dev_priv, GMBUS_PORT_DPB);
673 return intel_crt_ddc_get_modes(connector, i2c);
676 static int intel_crt_set_property(struct drm_connector *connector,
677 struct drm_property *property,
683 static void intel_crt_reset(struct drm_connector *connector)
685 struct drm_device *dev = connector->dev;
686 struct drm_i915_private *dev_priv = dev->dev_private;
687 struct intel_crt *crt = intel_attached_crt(connector);
689 if (HAS_PCH_SPLIT(dev)) {
692 adpa = I915_READ(crt->adpa_reg);
693 adpa &= ~ADPA_CRT_HOTPLUG_MASK;
694 adpa |= ADPA_HOTPLUG_BITS;
695 I915_WRITE(crt->adpa_reg, adpa);
696 POSTING_READ(crt->adpa_reg);
698 DRM_DEBUG_KMS("pch crt adpa set to 0x%x\n", adpa);
699 crt->force_hotplug_required = 1;
705 * Routines for controlling stuff on the analog port
708 static const struct drm_encoder_helper_funcs crt_encoder_funcs = {
709 .mode_set = intel_crt_mode_set,
712 static const struct drm_connector_funcs intel_crt_connector_funcs = {
713 .reset = intel_crt_reset,
714 .dpms = intel_crt_dpms,
715 .detect = intel_crt_detect,
716 .fill_modes = drm_helper_probe_single_connector_modes,
717 .destroy = intel_crt_destroy,
718 .set_property = intel_crt_set_property,
721 static const struct drm_connector_helper_funcs intel_crt_connector_helper_funcs = {
722 .mode_valid = intel_crt_mode_valid,
723 .get_modes = intel_crt_get_modes,
724 .best_encoder = intel_best_encoder,
727 static const struct drm_encoder_funcs intel_crt_enc_funcs = {
728 .destroy = intel_encoder_destroy,
731 static int __init intel_no_crt_dmi_callback(const struct dmi_system_id *id)
733 DRM_INFO("Skipping CRT initialization for %s\n", id->ident);
737 static const struct dmi_system_id intel_no_crt[] = {
739 .callback = intel_no_crt_dmi_callback,
742 DMI_MATCH(DMI_SYS_VENDOR, "ACER"),
743 DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"),
749 void intel_crt_init(struct drm_device *dev)
751 struct drm_connector *connector;
752 struct intel_crt *crt;
753 struct intel_connector *intel_connector;
754 struct drm_i915_private *dev_priv = dev->dev_private;
756 /* Skip machines without VGA that falsely report hotplug events */
757 if (dmi_check_system(intel_no_crt))
760 crt = kzalloc(sizeof(struct intel_crt), GFP_KERNEL);
764 intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
765 if (!intel_connector) {
770 connector = &intel_connector->base;
771 crt->connector = intel_connector;
772 drm_connector_init(dev, &intel_connector->base,
773 &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
775 drm_encoder_init(dev, &crt->base.base, &intel_crt_enc_funcs,
776 DRM_MODE_ENCODER_DAC);
778 intel_connector_attach_encoder(intel_connector, &crt->base);
780 crt->base.type = INTEL_OUTPUT_ANALOG;
781 crt->base.cloneable = true;
783 crt->base.crtc_mask = (1 << 0);
785 crt->base.crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
788 connector->interlace_allowed = 0;
790 connector->interlace_allowed = 1;
791 connector->doublescan_allowed = 0;
793 if (HAS_PCH_SPLIT(dev))
794 crt->adpa_reg = PCH_ADPA;
795 else if (IS_VALLEYVIEW(dev))
796 crt->adpa_reg = VLV_ADPA;
798 crt->adpa_reg = ADPA;
800 crt->base.compute_config = intel_crt_compute_config;
801 crt->base.disable = intel_disable_crt;
802 crt->base.enable = intel_enable_crt;
803 crt->base.get_config = intel_crt_get_config;
804 if (I915_HAS_HOTPLUG(dev))
805 crt->base.hpd_pin = HPD_CRT;
807 crt->base.get_hw_state = intel_ddi_get_hw_state;
809 crt->base.get_hw_state = intel_crt_get_hw_state;
810 intel_connector->get_hw_state = intel_connector_get_hw_state;
812 drm_encoder_helper_add(&crt->base.base, &crt_encoder_funcs);
813 drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
815 drm_sysfs_connector_add(connector);
817 if (!I915_HAS_HOTPLUG(dev))
818 intel_connector->polled = DRM_CONNECTOR_POLL_CONNECT;
821 * Configure the automatic hotplug detection stuff
823 crt->force_hotplug_required = 0;
826 * TODO: find a proper way to discover whether we need to set the the
827 * polarity and link reversal bits or not, instead of relying on the
830 if (HAS_PCH_LPT(dev)) {
831 u32 fdi_config = FDI_RX_POLARITY_REVERSED_LPT |
832 FDI_RX_LINK_REVERSAL_OVERRIDE;
834 dev_priv->fdi_rx_config = I915_READ(_FDI_RXA_CTL) & fdi_config;