Rev 2330 | Rev 3480 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2330 | Rev 3031 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | * Authors: |
24 | * Authors: |
25 | * Eric Anholt |
25 | * Eric Anholt |
26 | */ |
26 | */ |
27 | #include |
27 | #include |
28 | #include |
28 | #include |
29 | #include "drmP.h" |
29 | #include |
30 | #include "drm.h" |
- | |
31 | #include "drm_crtc.h" |
30 | #include |
32 | #include "intel_drv.h" |
31 | #include "intel_drv.h" |
33 | #include "i915_drm.h" |
32 | #include |
34 | #include "i915_drv.h" |
33 | #include "i915_drv.h" |
35 | #include "dvo.h" |
34 | #include "dvo.h" |
Line 36... | Line 35... | ||
36 | 35 | ||
37 | #define SIL164_ADDR 0x38 |
36 | #define SIL164_ADDR 0x38 |
38 | #define CH7xxx_ADDR 0x76 |
37 | #define CH7xxx_ADDR 0x76 |
- | 38 | #define TFP410_ADDR 0x38 |
|
Line 39... | Line 39... | ||
39 | #define TFP410_ADDR 0x38 |
39 | #define NS2501_ADDR 0x38 |
40 | 40 | ||
41 | static const struct intel_dvo_device intel_dvo_devices[] = { |
41 | static const struct intel_dvo_device intel_dvo_devices[] = { |
42 | { |
42 | { |
Line 72... | Line 72... | ||
72 | .name = "ch7017", |
72 | .name = "ch7017", |
73 | .dvo_reg = DVOC, |
73 | .dvo_reg = DVOC, |
74 | .slave_addr = 0x75, |
74 | .slave_addr = 0x75, |
75 | .gpio = GMBUS_PORT_DPB, |
75 | .gpio = GMBUS_PORT_DPB, |
76 | .dev_ops = &ch7017_ops, |
76 | .dev_ops = &ch7017_ops, |
- | 77 | }, |
|
- | 78 | { |
|
- | 79 | .type = INTEL_DVO_CHIP_TMDS, |
|
- | 80 | .name = "ns2501", |
|
- | 81 | .dvo_reg = DVOC, |
|
- | 82 | .slave_addr = NS2501_ADDR, |
|
- | 83 | .dev_ops = &ns2501_ops, |
|
77 | } |
84 | } |
78 | }; |
85 | }; |
Line 79... | Line 86... | ||
79 | 86 | ||
80 | struct intel_dvo { |
87 | struct intel_dvo { |
Line 95... | Line 102... | ||
95 | { |
102 | { |
96 | return container_of(intel_attached_encoder(connector), |
103 | return container_of(intel_attached_encoder(connector), |
97 | struct intel_dvo, base); |
104 | struct intel_dvo, base); |
98 | } |
105 | } |
Line 99... | Line 106... | ||
99 | 106 | ||
100 | static void intel_dvo_dpms(struct drm_encoder *encoder, int mode) |
107 | static bool intel_dvo_connector_get_hw_state(struct intel_connector *connector) |
- | 108 | { |
|
- | 109 | struct intel_dvo *intel_dvo = intel_attached_dvo(&connector->base); |
|
- | 110 | ||
- | 111 | return intel_dvo->dev.dev_ops->get_hw_state(&intel_dvo->dev); |
|
- | 112 | } |
|
- | 113 | ||
- | 114 | static bool intel_dvo_get_hw_state(struct intel_encoder *encoder, |
|
- | 115 | enum pipe *pipe) |
|
- | 116 | { |
|
- | 117 | struct drm_device *dev = encoder->base.dev; |
|
- | 118 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 119 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(&encoder->base); |
|
- | 120 | u32 tmp; |
|
- | 121 | ||
- | 122 | tmp = I915_READ(intel_dvo->dev.dvo_reg); |
|
- | 123 | ||
- | 124 | if (!(tmp & DVO_ENABLE)) |
|
- | 125 | return false; |
|
- | 126 | ||
- | 127 | *pipe = PORT_TO_PIPE(tmp); |
|
- | 128 | ||
- | 129 | return true; |
|
- | 130 | } |
|
- | 131 | ||
- | 132 | static void intel_disable_dvo(struct intel_encoder *encoder) |
|
- | 133 | { |
|
- | 134 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
|
- | 135 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(&encoder->base); |
|
- | 136 | u32 dvo_reg = intel_dvo->dev.dvo_reg; |
|
- | 137 | u32 temp = I915_READ(dvo_reg); |
|
- | 138 | ||
- | 139 | intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, false); |
|
- | 140 | I915_WRITE(dvo_reg, temp & ~DVO_ENABLE); |
|
- | 141 | I915_READ(dvo_reg); |
|
- | 142 | } |
|
- | 143 | ||
- | 144 | static void intel_enable_dvo(struct intel_encoder *encoder) |
|
101 | { |
145 | { |
102 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
146 | struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; |
103 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); |
147 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(&encoder->base); |
104 | u32 dvo_reg = intel_dvo->dev.dvo_reg; |
148 | u32 dvo_reg = intel_dvo->dev.dvo_reg; |
Line 105... | Line -... | ||
105 | u32 temp = I915_READ(dvo_reg); |
- | |
106 | 149 | u32 temp = I915_READ(dvo_reg); |
|
107 | if (mode == DRM_MODE_DPMS_ON) { |
150 | |
- | 151 | I915_WRITE(dvo_reg, temp | DVO_ENABLE); |
|
- | 152 | I915_READ(dvo_reg); |
|
- | 153 | intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, true); |
|
- | 154 | } |
|
- | 155 | ||
- | 156 | static void intel_dvo_dpms(struct drm_connector *connector, int mode) |
|
- | 157 | { |
|
- | 158 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
|
- | 159 | struct drm_crtc *crtc; |
|
- | 160 | ||
- | 161 | /* dvo supports only 2 dpms states. */ |
|
- | 162 | if (mode != DRM_MODE_DPMS_ON) |
|
- | 163 | mode = DRM_MODE_DPMS_OFF; |
|
- | 164 | ||
- | 165 | if (mode == connector->dpms) |
|
- | 166 | return; |
|
- | 167 | ||
- | 168 | connector->dpms = mode; |
|
- | 169 | ||
- | 170 | /* Only need to change hw state when actually enabled */ |
|
- | 171 | crtc = intel_dvo->base.base.crtc; |
|
- | 172 | if (!crtc) { |
|
- | 173 | intel_dvo->base.connectors_active = false; |
|
- | 174 | return; |
|
- | 175 | } |
|
- | 176 | ||
- | 177 | if (mode == DRM_MODE_DPMS_ON) { |
|
- | 178 | intel_dvo->base.connectors_active = true; |
|
- | 179 | ||
108 | I915_WRITE(dvo_reg, temp | DVO_ENABLE); |
180 | intel_crtc_update_dpms(crtc); |
109 | I915_READ(dvo_reg); |
181 | |
110 | intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, mode); |
182 | intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, true); |
- | 183 | } else { |
|
111 | } else { |
184 | intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, false); |
- | 185 | ||
112 | intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, mode); |
186 | intel_dvo->base.connectors_active = false; |
113 | I915_WRITE(dvo_reg, temp & ~DVO_ENABLE); |
187 | |
- | 188 | intel_crtc_update_dpms(crtc); |
|
- | 189 | } |
|
114 | I915_READ(dvo_reg); |
190 | |
Line 115... | Line 191... | ||
115 | } |
191 | intel_modeset_check_state(connector->dev); |
116 | } |
192 | } |
117 | 193 | ||
Line 134... | Line 210... | ||
134 | 210 | ||
135 | return intel_dvo->dev.dev_ops->mode_valid(&intel_dvo->dev, mode); |
211 | return intel_dvo->dev.dev_ops->mode_valid(&intel_dvo->dev, mode); |
Line 136... | Line 212... | ||
136 | } |
212 | } |
137 | 213 | ||
138 | static bool intel_dvo_mode_fixup(struct drm_encoder *encoder, |
214 | static bool intel_dvo_mode_fixup(struct drm_encoder *encoder, |
139 | struct drm_display_mode *mode, |
215 | const struct drm_display_mode *mode, |
140 | struct drm_display_mode *adjusted_mode) |
216 | struct drm_display_mode *adjusted_mode) |
Line 141... | Line 217... | ||
141 | { |
217 | { |
Line 155... | Line 231... | ||
155 | C(vdisplay); |
231 | C(vdisplay); |
156 | C(vsync_start); |
232 | C(vsync_start); |
157 | C(vsync_end); |
233 | C(vsync_end); |
158 | C(vtotal); |
234 | C(vtotal); |
159 | C(clock); |
235 | C(clock); |
160 | drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V); |
- | |
161 | #undef C |
236 | #undef C |
162 | } |
237 | } |
Line 163... | Line 238... | ||
163 | 238 | ||
164 | if (intel_dvo->dev.dev_ops->mode_fixup) |
239 | if (intel_dvo->dev.dev_ops->mode_fixup) |
Line 242... | Line 317... | ||
242 | * devices which will have a fixed set of modes determined by the chip |
317 | * devices which will have a fixed set of modes determined by the chip |
243 | * (TV-out, for example), but for now with just TMDS and LVDS, |
318 | * (TV-out, for example), but for now with just TMDS and LVDS, |
244 | * that's not the case. |
319 | * that's not the case. |
245 | */ |
320 | */ |
246 | intel_ddc_get_modes(connector, |
321 | intel_ddc_get_modes(connector, |
247 | &dev_priv->gmbus[GMBUS_PORT_DPC].adapter); |
322 | intel_gmbus_get_adapter(dev_priv, GMBUS_PORT_DPC)); |
248 | if (!list_empty(&connector->probed_modes)) |
323 | if (!list_empty(&connector->probed_modes)) |
249 | return 1; |
324 | return 1; |
Line 250... | Line 325... | ||
250 | 325 | ||
251 | if (intel_dvo->panel_fixed_mode != NULL) { |
326 | if (intel_dvo->panel_fixed_mode != NULL) { |
Line 266... | Line 341... | ||
266 | drm_connector_cleanup(connector); |
341 | drm_connector_cleanup(connector); |
267 | kfree(connector); |
342 | kfree(connector); |
268 | } |
343 | } |
Line 269... | Line 344... | ||
269 | 344 | ||
270 | static const struct drm_encoder_helper_funcs intel_dvo_helper_funcs = { |
- | |
271 | .dpms = intel_dvo_dpms, |
345 | static const struct drm_encoder_helper_funcs intel_dvo_helper_funcs = { |
272 | .mode_fixup = intel_dvo_mode_fixup, |
- | |
273 | .prepare = intel_encoder_prepare, |
346 | .mode_fixup = intel_dvo_mode_fixup, |
274 | .mode_set = intel_dvo_mode_set, |
347 | .mode_set = intel_dvo_mode_set, |
275 | .commit = intel_encoder_commit, |
348 | .disable = intel_encoder_noop, |
Line 276... | Line 349... | ||
276 | }; |
349 | }; |
277 | 350 | ||
278 | static const struct drm_connector_funcs intel_dvo_connector_funcs = { |
351 | static const struct drm_connector_funcs intel_dvo_connector_funcs = { |
279 | .dpms = drm_helper_connector_dpms, |
352 | .dpms = intel_dvo_dpms, |
280 | .detect = intel_dvo_detect, |
353 | .detect = intel_dvo_detect, |
281 | .destroy = intel_dvo_destroy, |
354 | .destroy = intel_dvo_destroy, |
Line 363... | Line 436... | ||
363 | 436 | ||
364 | intel_encoder = &intel_dvo->base; |
437 | intel_encoder = &intel_dvo->base; |
365 | drm_encoder_init(dev, &intel_encoder->base, |
438 | drm_encoder_init(dev, &intel_encoder->base, |
Line -... | Line 439... | ||
- | 439 | &intel_dvo_enc_funcs, encoder_type); |
|
- | 440 | ||
- | 441 | intel_encoder->disable = intel_disable_dvo; |
|
- | 442 | intel_encoder->enable = intel_enable_dvo; |
|
- | 443 | intel_encoder->get_hw_state = intel_dvo_get_hw_state; |
|
366 | &intel_dvo_enc_funcs, encoder_type); |
444 | intel_connector->get_hw_state = intel_dvo_connector_get_hw_state; |
367 | 445 | ||
368 | /* Now, try to find a controller */ |
446 | /* Now, try to find a controller */ |
369 | for (i = 0; i < ARRAY_SIZE(intel_dvo_devices); i++) { |
447 | for (i = 0; i < ARRAY_SIZE(intel_dvo_devices); i++) { |
370 | struct drm_connector *connector = &intel_connector->base; |
448 | struct drm_connector *connector = &intel_connector->base; |
Line 374... | Line 452... | ||
374 | 452 | ||
375 | /* Allow the I2C driver info to specify the GPIO to be used in |
453 | /* Allow the I2C driver info to specify the GPIO to be used in |
376 | * special cases, but otherwise default to what's defined |
454 | * special cases, but otherwise default to what's defined |
377 | * in the spec. |
455 | * in the spec. |
378 | */ |
456 | */ |
379 | if (dvo->gpio != 0) |
457 | if (intel_gmbus_is_port_valid(dvo->gpio)) |
380 | gpio = dvo->gpio; |
458 | gpio = dvo->gpio; |
381 | else if (dvo->type == INTEL_DVO_CHIP_LVDS) |
459 | else if (dvo->type == INTEL_DVO_CHIP_LVDS) |
382 | gpio = GMBUS_PORT_SSC; |
460 | gpio = GMBUS_PORT_SSC; |
383 | else |
461 | else |
Line 384... | Line 462... | ||
384 | gpio = GMBUS_PORT_DPB; |
462 | gpio = GMBUS_PORT_DPB; |
385 | 463 | ||
386 | /* Set up the I2C bus necessary for the chip we're probing. |
464 | /* Set up the I2C bus necessary for the chip we're probing. |
387 | * It appears that everything is on GPIOE except for panels |
465 | * It appears that everything is on GPIOE except for panels |
388 | * on i830 laptops, which are on GPIOB (DVOA). |
466 | * on i830 laptops, which are on GPIOB (DVOA). |
Line 389... | Line 467... | ||
389 | */ |
467 | */ |
390 | i2c = &dev_priv->gmbus[gpio].adapter; |
468 | i2c = intel_gmbus_get_adapter(dev_priv, gpio); |
391 | 469 | ||
Line 392... | Line 470... | ||
392 | intel_dvo->dev = *dvo; |
470 | intel_dvo->dev = *dvo; |
393 | if (!dvo->dev_ops->init(&intel_dvo->dev, i2c)) |
471 | if (!dvo->dev_ops->init(&intel_dvo->dev, i2c)) |
394 | continue; |
472 | continue; |
395 | 473 | ||
396 | intel_encoder->type = INTEL_OUTPUT_DVO; |
474 | intel_encoder->type = INTEL_OUTPUT_DVO; |
397 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1); |
- | |
398 | switch (dvo->type) { |
- | |
399 | case INTEL_DVO_CHIP_TMDS: |
475 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1); |
400 | intel_encoder->clone_mask = |
476 | switch (dvo->type) { |
401 | (1 << INTEL_DVO_TMDS_CLONE_BIT) | |
477 | case INTEL_DVO_CHIP_TMDS: |
402 | (1 << INTEL_ANALOG_CLONE_BIT); |
478 | intel_encoder->cloneable = true; |
403 | drm_connector_init(dev, connector, |
479 | drm_connector_init(dev, connector, |
404 | &intel_dvo_connector_funcs, |
480 | &intel_dvo_connector_funcs, |
405 | DRM_MODE_CONNECTOR_DVII); |
481 | DRM_MODE_CONNECTOR_DVII); |
406 | encoder_type = DRM_MODE_ENCODER_TMDS; |
- | |
407 | break; |
482 | encoder_type = DRM_MODE_ENCODER_TMDS; |
408 | case INTEL_DVO_CHIP_LVDS: |
483 | break; |
409 | intel_encoder->clone_mask = |
484 | case INTEL_DVO_CHIP_LVDS: |
410 | (1 << INTEL_DVO_LVDS_CLONE_BIT); |
485 | intel_encoder->cloneable = false; |
411 | drm_connector_init(dev, connector, |
486 | drm_connector_init(dev, connector, |