Rev 3031 | Rev 5060 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3031 | Rev 4560 | ||
---|---|---|---|
Line 85... | Line 85... | ||
85 | * This is pretty much a hack, though it works. |
85 | * This is pretty much a hack, though it works. |
86 | * Without that, ns2501_readb and ns2501_writeb fail |
86 | * Without that, ns2501_readb and ns2501_writeb fail |
87 | * when switching the resolution. |
87 | * when switching the resolution. |
88 | */ |
88 | */ |
Line 89... | Line -... | ||
89 | - | ||
90 | static void enable_dvo(struct intel_dvo_device *dvo) |
- | |
91 | { |
- | |
92 | struct ns2501_priv *ns = (struct ns2501_priv *)(dvo->dev_priv); |
- | |
93 | struct i2c_adapter *adapter = dvo->i2c_bus; |
- | |
94 | struct intel_gmbus *bus = container_of(adapter, |
- | |
95 | struct intel_gmbus, |
- | |
96 | adapter); |
- | |
97 | struct drm_i915_private *dev_priv = bus->dev_priv; |
- | |
98 | - | ||
99 | DRM_DEBUG_KMS("%s: Trying to re-enable the DVO\n", __FUNCTION__); |
- | |
100 | - | ||
101 | ns->dvoc = I915_READ(DVO_C); |
- | |
102 | ns->pll_a = I915_READ(_DPLL_A); |
- | |
103 | ns->srcdim = I915_READ(DVOC_SRCDIM); |
- | |
104 | ns->fw_blc = I915_READ(FW_BLC); |
- | |
105 | - | ||
106 | I915_WRITE(DVOC, 0x10004084); |
- | |
107 | I915_WRITE(_DPLL_A, 0xd0820000); |
- | |
108 | I915_WRITE(DVOC_SRCDIM, 0x400300); // 1024x768 |
- | |
109 | I915_WRITE(FW_BLC, 0x1080304); |
- | |
110 | - | ||
111 | I915_WRITE(DVOC, 0x90004084); |
- | |
112 | } |
- | |
113 | - | ||
114 | /* |
- | |
115 | * Restore the I915 registers modified by the above |
- | |
116 | * trigger function. |
- | |
117 | */ |
- | |
118 | static void restore_dvo(struct intel_dvo_device *dvo) |
- | |
119 | { |
- | |
120 | struct i2c_adapter *adapter = dvo->i2c_bus; |
- | |
121 | struct intel_gmbus *bus = container_of(adapter, |
- | |
122 | struct intel_gmbus, |
- | |
123 | adapter); |
- | |
124 | struct drm_i915_private *dev_priv = bus->dev_priv; |
- | |
125 | struct ns2501_priv *ns = (struct ns2501_priv *)(dvo->dev_priv); |
- | |
126 | - | ||
127 | I915_WRITE(DVOC, ns->dvoc); |
- | |
128 | I915_WRITE(_DPLL_A, ns->pll_a); |
- | |
129 | I915_WRITE(DVOC_SRCDIM, ns->srcdim); |
- | |
130 | I915_WRITE(FW_BLC, ns->fw_blc); |
- | |
131 | } |
- | |
132 | 89 | ||
133 | /* |
90 | /* |
134 | ** Read a register from the ns2501. |
91 | ** Read a register from the ns2501. |
135 | ** Returns true if successful, false otherwise. |
92 | ** Returns true if successful, false otherwise. |
136 | ** If it returns false, it might be wise to enable the |
93 | ** If it returns false, it might be wise to enable the |
Line 298... | Line 255... | ||
298 | static void ns2501_mode_set(struct intel_dvo_device *dvo, |
255 | static void ns2501_mode_set(struct intel_dvo_device *dvo, |
299 | struct drm_display_mode *mode, |
256 | struct drm_display_mode *mode, |
300 | struct drm_display_mode *adjusted_mode) |
257 | struct drm_display_mode *adjusted_mode) |
301 | { |
258 | { |
302 | bool ok; |
259 | bool ok; |
303 | bool restore = false; |
260 | int retries = 10; |
304 | struct ns2501_priv *ns = (struct ns2501_priv *)(dvo->dev_priv); |
261 | struct ns2501_priv *ns = (struct ns2501_priv *)(dvo->dev_priv); |
Line 305... | Line 262... | ||
305 | 262 | ||
306 | DRM_DEBUG_KMS |
263 | DRM_DEBUG_KMS |
307 | ("%s: set mode (hdisplay=%d,htotal=%d,vdisplay=%d,vtotal=%d).\n", |
264 | ("%s: set mode (hdisplay=%d,htotal=%d,vdisplay=%d,vtotal=%d).\n", |
Line 474... | Line 431... | ||
474 | * as mode_OK delivered no other modes. |
431 | * as mode_OK delivered no other modes. |
475 | */ |
432 | */ |
476 | ns->reg_8_shadow |= NS2501_8_BPAS; |
433 | ns->reg_8_shadow |= NS2501_8_BPAS; |
477 | } |
434 | } |
478 | ok &= ns2501_writeb(dvo, NS2501_REG8, ns->reg_8_shadow); |
435 | ok &= ns2501_writeb(dvo, NS2501_REG8, ns->reg_8_shadow); |
479 | - | ||
480 | if (!ok) { |
- | |
481 | if (restore) |
- | |
482 | restore_dvo(dvo); |
- | |
483 | enable_dvo(dvo); |
- | |
484 | restore = true; |
- | |
485 | } |
- | |
486 | } while (!ok); |
436 | } while (!ok && retries--); |
487 | /* |
- | |
488 | * Restore the old i915 registers before |
- | |
489 | * forcing the ns2501 on. |
- | |
490 | */ |
- | |
491 | if (restore) |
- | |
492 | restore_dvo(dvo); |
- | |
493 | } |
437 | } |
Line 494... | Line 438... | ||
494 | 438 | ||
495 | /* set the NS2501 power state */ |
439 | /* set the NS2501 power state */ |
496 | static bool ns2501_get_hw_state(struct intel_dvo_device *dvo) |
440 | static bool ns2501_get_hw_state(struct intel_dvo_device *dvo) |
Line 508... | Line 452... | ||
508 | 452 | ||
509 | /* set the NS2501 power state */ |
453 | /* set the NS2501 power state */ |
510 | static void ns2501_dpms(struct intel_dvo_device *dvo, bool enable) |
454 | static void ns2501_dpms(struct intel_dvo_device *dvo, bool enable) |
511 | { |
455 | { |
512 | bool ok; |
456 | bool ok; |
513 | bool restore = false; |
457 | int retries = 10; |
514 | struct ns2501_priv *ns = (struct ns2501_priv *)(dvo->dev_priv); |
458 | struct ns2501_priv *ns = (struct ns2501_priv *)(dvo->dev_priv); |
Line 515... | Line 459... | ||
515 | unsigned char ch; |
459 | unsigned char ch; |
516 | 460 | ||
Line 535... | Line 479... | ||
535 | ns2501_writeb(dvo, 0x34, |
479 | ns2501_writeb(dvo, 0x34, |
536 | enable ? 0x03 : 0x00); |
480 | enable ? 0x03 : 0x00); |
537 | ok &= |
481 | ok &= |
538 | ns2501_writeb(dvo, 0x35, |
482 | ns2501_writeb(dvo, 0x35, |
539 | enable ? 0xff : 0x00); |
483 | enable ? 0xff : 0x00); |
540 | if (!ok) { |
- | |
541 | if (restore) |
- | |
542 | restore_dvo(dvo); |
- | |
543 | enable_dvo(dvo); |
- | |
544 | restore = true; |
- | |
545 | } |
- | |
546 | } while (!ok); |
484 | } while (!ok && retries--); |
547 | - | ||
548 | if (restore) |
- | |
549 | restore_dvo(dvo); |
- | |
550 | } |
485 | } |
551 | } |
486 | } |
Line 552... | Line 487... | ||
552 | 487 | ||
553 | static void ns2501_dump_regs(struct intel_dvo_device *dvo) |
488 | static void ns2501_dump_regs(struct intel_dvo_device *dvo) |