Rev 2330 | Rev 3480 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2330 | Rev 3031 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright 2006 Dave Airlie |
2 | * Copyright 2006 Dave Airlie |
3 | * Copyright © 2006-2007 Intel Corporation |
3 | * Copyright © 2006-2007 Intel Corporation |
4 | * |
4 | * |
5 | * Permission is hereby granted, free of charge, to any person obtaining a |
5 | * Permission is hereby granted, free of charge, to any person obtaining a |
6 | * copy of this software and associated documentation files (the "Software"), |
6 | * copy of this software and associated documentation files (the "Software"), |
7 | * to deal in the Software without restriction, including without limitation |
7 | * to deal in the Software without restriction, including without limitation |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
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 |
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: |
10 | * Software is furnished to do so, subject to the following conditions: |
11 | * |
11 | * |
12 | * The above copyright notice and this permission notice (including the next |
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 |
13 | * paragraph) shall be included in all copies or substantial portions of the |
14 | * Software. |
14 | * Software. |
15 | * |
15 | * |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
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, |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
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 |
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 |
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 |
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
22 | * DEALINGS IN THE SOFTWARE. |
22 | * DEALINGS IN THE SOFTWARE. |
23 | * |
23 | * |
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" |
36 | 35 | ||
37 | #define SIL164_ADDR 0x38 |
36 | #define SIL164_ADDR 0x38 |
38 | #define CH7xxx_ADDR 0x76 |
37 | #define CH7xxx_ADDR 0x76 |
39 | #define TFP410_ADDR 0x38 |
38 | #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 | { |
43 | .type = INTEL_DVO_CHIP_TMDS, |
43 | .type = INTEL_DVO_CHIP_TMDS, |
44 | .name = "sil164", |
44 | .name = "sil164", |
45 | .dvo_reg = DVOC, |
45 | .dvo_reg = DVOC, |
46 | .slave_addr = SIL164_ADDR, |
46 | .slave_addr = SIL164_ADDR, |
47 | .dev_ops = &sil164_ops, |
47 | .dev_ops = &sil164_ops, |
48 | }, |
48 | }, |
49 | { |
49 | { |
50 | .type = INTEL_DVO_CHIP_TMDS, |
50 | .type = INTEL_DVO_CHIP_TMDS, |
51 | .name = "ch7xxx", |
51 | .name = "ch7xxx", |
52 | .dvo_reg = DVOC, |
52 | .dvo_reg = DVOC, |
53 | .slave_addr = CH7xxx_ADDR, |
53 | .slave_addr = CH7xxx_ADDR, |
54 | .dev_ops = &ch7xxx_ops, |
54 | .dev_ops = &ch7xxx_ops, |
55 | }, |
55 | }, |
56 | { |
56 | { |
57 | .type = INTEL_DVO_CHIP_LVDS, |
57 | .type = INTEL_DVO_CHIP_LVDS, |
58 | .name = "ivch", |
58 | .name = "ivch", |
59 | .dvo_reg = DVOA, |
59 | .dvo_reg = DVOA, |
60 | .slave_addr = 0x02, /* Might also be 0x44, 0x84, 0xc4 */ |
60 | .slave_addr = 0x02, /* Might also be 0x44, 0x84, 0xc4 */ |
61 | .dev_ops = &ivch_ops, |
61 | .dev_ops = &ivch_ops, |
62 | }, |
62 | }, |
63 | { |
63 | { |
64 | .type = INTEL_DVO_CHIP_TMDS, |
64 | .type = INTEL_DVO_CHIP_TMDS, |
65 | .name = "tfp410", |
65 | .name = "tfp410", |
66 | .dvo_reg = DVOC, |
66 | .dvo_reg = DVOC, |
67 | .slave_addr = TFP410_ADDR, |
67 | .slave_addr = TFP410_ADDR, |
68 | .dev_ops = &tfp410_ops, |
68 | .dev_ops = &tfp410_ops, |
69 | }, |
69 | }, |
70 | { |
70 | { |
71 | .type = INTEL_DVO_CHIP_LVDS, |
71 | .type = INTEL_DVO_CHIP_LVDS, |
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 | }; |
79 | 86 | ||
80 | struct intel_dvo { |
87 | struct intel_dvo { |
81 | struct intel_encoder base; |
88 | struct intel_encoder base; |
82 | 89 | ||
83 | struct intel_dvo_device dev; |
90 | struct intel_dvo_device dev; |
84 | 91 | ||
85 | struct drm_display_mode *panel_fixed_mode; |
92 | struct drm_display_mode *panel_fixed_mode; |
86 | bool panel_wants_dither; |
93 | bool panel_wants_dither; |
87 | }; |
94 | }; |
88 | 95 | ||
89 | static struct intel_dvo *enc_to_intel_dvo(struct drm_encoder *encoder) |
96 | static struct intel_dvo *enc_to_intel_dvo(struct drm_encoder *encoder) |
90 | { |
97 | { |
91 | return container_of(encoder, struct intel_dvo, base.base); |
98 | return container_of(encoder, struct intel_dvo, base.base); |
92 | } |
99 | } |
93 | 100 | ||
94 | static struct intel_dvo *intel_attached_dvo(struct drm_connector *connector) |
101 | static struct intel_dvo *intel_attached_dvo(struct drm_connector *connector) |
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 | } |
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; |
105 | u32 temp = I915_READ(dvo_reg); |
149 | u32 temp = I915_READ(dvo_reg); |
106 | - | ||
107 | if (mode == DRM_MODE_DPMS_ON) { |
150 | |
108 | I915_WRITE(dvo_reg, temp | DVO_ENABLE); |
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 | ||
- | 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); |
111 | } else { |
183 | } else { |
- | 184 | intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, false); |
|
112 | intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, mode); |
185 | |
- | 186 | intel_dvo->base.connectors_active = false; |
|
113 | I915_WRITE(dvo_reg, temp & ~DVO_ENABLE); |
187 | |
114 | I915_READ(dvo_reg); |
188 | intel_crtc_update_dpms(crtc); |
- | 189 | } |
|
- | 190 | ||
115 | } |
191 | intel_modeset_check_state(connector->dev); |
116 | } |
192 | } |
117 | 193 | ||
118 | static int intel_dvo_mode_valid(struct drm_connector *connector, |
194 | static int intel_dvo_mode_valid(struct drm_connector *connector, |
119 | struct drm_display_mode *mode) |
195 | struct drm_display_mode *mode) |
120 | { |
196 | { |
121 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
197 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
122 | 198 | ||
123 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
199 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
124 | return MODE_NO_DBLESCAN; |
200 | return MODE_NO_DBLESCAN; |
125 | 201 | ||
126 | /* XXX: Validate clock range */ |
202 | /* XXX: Validate clock range */ |
127 | 203 | ||
128 | if (intel_dvo->panel_fixed_mode) { |
204 | if (intel_dvo->panel_fixed_mode) { |
129 | if (mode->hdisplay > intel_dvo->panel_fixed_mode->hdisplay) |
205 | if (mode->hdisplay > intel_dvo->panel_fixed_mode->hdisplay) |
130 | return MODE_PANEL; |
206 | return MODE_PANEL; |
131 | if (mode->vdisplay > intel_dvo->panel_fixed_mode->vdisplay) |
207 | if (mode->vdisplay > intel_dvo->panel_fixed_mode->vdisplay) |
132 | return MODE_PANEL; |
208 | return MODE_PANEL; |
133 | } |
209 | } |
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); |
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) |
141 | { |
217 | { |
142 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); |
218 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); |
143 | 219 | ||
144 | /* If we have timings from the BIOS for the panel, put them in |
220 | /* If we have timings from the BIOS for the panel, put them in |
145 | * to the adjusted mode. The CRTC will be set up for this mode, |
221 | * to the adjusted mode. The CRTC will be set up for this mode, |
146 | * with the panel scaling set up to source from the H/VDisplay |
222 | * with the panel scaling set up to source from the H/VDisplay |
147 | * of the original mode. |
223 | * of the original mode. |
148 | */ |
224 | */ |
149 | if (intel_dvo->panel_fixed_mode != NULL) { |
225 | if (intel_dvo->panel_fixed_mode != NULL) { |
150 | #define C(x) adjusted_mode->x = intel_dvo->panel_fixed_mode->x |
226 | #define C(x) adjusted_mode->x = intel_dvo->panel_fixed_mode->x |
151 | C(hdisplay); |
227 | C(hdisplay); |
152 | C(hsync_start); |
228 | C(hsync_start); |
153 | C(hsync_end); |
229 | C(hsync_end); |
154 | C(htotal); |
230 | C(htotal); |
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 | } |
163 | 238 | ||
164 | if (intel_dvo->dev.dev_ops->mode_fixup) |
239 | if (intel_dvo->dev.dev_ops->mode_fixup) |
165 | return intel_dvo->dev.dev_ops->mode_fixup(&intel_dvo->dev, mode, adjusted_mode); |
240 | return intel_dvo->dev.dev_ops->mode_fixup(&intel_dvo->dev, mode, adjusted_mode); |
166 | 241 | ||
167 | return true; |
242 | return true; |
168 | } |
243 | } |
169 | 244 | ||
170 | static void intel_dvo_mode_set(struct drm_encoder *encoder, |
245 | static void intel_dvo_mode_set(struct drm_encoder *encoder, |
171 | struct drm_display_mode *mode, |
246 | struct drm_display_mode *mode, |
172 | struct drm_display_mode *adjusted_mode) |
247 | struct drm_display_mode *adjusted_mode) |
173 | { |
248 | { |
174 | struct drm_device *dev = encoder->dev; |
249 | struct drm_device *dev = encoder->dev; |
175 | struct drm_i915_private *dev_priv = dev->dev_private; |
250 | struct drm_i915_private *dev_priv = dev->dev_private; |
176 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
251 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
177 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); |
252 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); |
178 | int pipe = intel_crtc->pipe; |
253 | int pipe = intel_crtc->pipe; |
179 | u32 dvo_val; |
254 | u32 dvo_val; |
180 | u32 dvo_reg = intel_dvo->dev.dvo_reg, dvo_srcdim_reg; |
255 | u32 dvo_reg = intel_dvo->dev.dvo_reg, dvo_srcdim_reg; |
181 | int dpll_reg = DPLL(pipe); |
256 | int dpll_reg = DPLL(pipe); |
182 | 257 | ||
183 | switch (dvo_reg) { |
258 | switch (dvo_reg) { |
184 | case DVOA: |
259 | case DVOA: |
185 | default: |
260 | default: |
186 | dvo_srcdim_reg = DVOA_SRCDIM; |
261 | dvo_srcdim_reg = DVOA_SRCDIM; |
187 | break; |
262 | break; |
188 | case DVOB: |
263 | case DVOB: |
189 | dvo_srcdim_reg = DVOB_SRCDIM; |
264 | dvo_srcdim_reg = DVOB_SRCDIM; |
190 | break; |
265 | break; |
191 | case DVOC: |
266 | case DVOC: |
192 | dvo_srcdim_reg = DVOC_SRCDIM; |
267 | dvo_srcdim_reg = DVOC_SRCDIM; |
193 | break; |
268 | break; |
194 | } |
269 | } |
195 | 270 | ||
196 | intel_dvo->dev.dev_ops->mode_set(&intel_dvo->dev, mode, adjusted_mode); |
271 | intel_dvo->dev.dev_ops->mode_set(&intel_dvo->dev, mode, adjusted_mode); |
197 | 272 | ||
198 | /* Save the data order, since I don't know what it should be set to. */ |
273 | /* Save the data order, since I don't know what it should be set to. */ |
199 | dvo_val = I915_READ(dvo_reg) & |
274 | dvo_val = I915_READ(dvo_reg) & |
200 | (DVO_PRESERVE_MASK | DVO_DATA_ORDER_GBRG); |
275 | (DVO_PRESERVE_MASK | DVO_DATA_ORDER_GBRG); |
201 | dvo_val |= DVO_DATA_ORDER_FP | DVO_BORDER_ENABLE | |
276 | dvo_val |= DVO_DATA_ORDER_FP | DVO_BORDER_ENABLE | |
202 | DVO_BLANK_ACTIVE_HIGH; |
277 | DVO_BLANK_ACTIVE_HIGH; |
203 | 278 | ||
204 | if (pipe == 1) |
279 | if (pipe == 1) |
205 | dvo_val |= DVO_PIPE_B_SELECT; |
280 | dvo_val |= DVO_PIPE_B_SELECT; |
206 | dvo_val |= DVO_PIPE_STALL; |
281 | dvo_val |= DVO_PIPE_STALL; |
207 | if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
282 | if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) |
208 | dvo_val |= DVO_HSYNC_ACTIVE_HIGH; |
283 | dvo_val |= DVO_HSYNC_ACTIVE_HIGH; |
209 | if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
284 | if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) |
210 | dvo_val |= DVO_VSYNC_ACTIVE_HIGH; |
285 | dvo_val |= DVO_VSYNC_ACTIVE_HIGH; |
211 | 286 | ||
212 | I915_WRITE(dpll_reg, I915_READ(dpll_reg) | DPLL_DVO_HIGH_SPEED); |
287 | I915_WRITE(dpll_reg, I915_READ(dpll_reg) | DPLL_DVO_HIGH_SPEED); |
213 | 288 | ||
214 | /*I915_WRITE(DVOB_SRCDIM, |
289 | /*I915_WRITE(DVOB_SRCDIM, |
215 | (adjusted_mode->hdisplay << DVO_SRCDIM_HORIZONTAL_SHIFT) | |
290 | (adjusted_mode->hdisplay << DVO_SRCDIM_HORIZONTAL_SHIFT) | |
216 | (adjusted_mode->VDisplay << DVO_SRCDIM_VERTICAL_SHIFT));*/ |
291 | (adjusted_mode->VDisplay << DVO_SRCDIM_VERTICAL_SHIFT));*/ |
217 | I915_WRITE(dvo_srcdim_reg, |
292 | I915_WRITE(dvo_srcdim_reg, |
218 | (adjusted_mode->hdisplay << DVO_SRCDIM_HORIZONTAL_SHIFT) | |
293 | (adjusted_mode->hdisplay << DVO_SRCDIM_HORIZONTAL_SHIFT) | |
219 | (adjusted_mode->vdisplay << DVO_SRCDIM_VERTICAL_SHIFT)); |
294 | (adjusted_mode->vdisplay << DVO_SRCDIM_VERTICAL_SHIFT)); |
220 | /*I915_WRITE(DVOB, dvo_val);*/ |
295 | /*I915_WRITE(DVOB, dvo_val);*/ |
221 | I915_WRITE(dvo_reg, dvo_val); |
296 | I915_WRITE(dvo_reg, dvo_val); |
222 | } |
297 | } |
223 | 298 | ||
224 | /** |
299 | /** |
225 | * Detect the output connection on our DVO device. |
300 | * Detect the output connection on our DVO device. |
226 | * |
301 | * |
227 | * Unimplemented. |
302 | * Unimplemented. |
228 | */ |
303 | */ |
229 | static enum drm_connector_status |
304 | static enum drm_connector_status |
230 | intel_dvo_detect(struct drm_connector *connector, bool force) |
305 | intel_dvo_detect(struct drm_connector *connector, bool force) |
231 | { |
306 | { |
232 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
307 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
233 | return intel_dvo->dev.dev_ops->detect(&intel_dvo->dev); |
308 | return intel_dvo->dev.dev_ops->detect(&intel_dvo->dev); |
234 | } |
309 | } |
235 | 310 | ||
236 | static int intel_dvo_get_modes(struct drm_connector *connector) |
311 | static int intel_dvo_get_modes(struct drm_connector *connector) |
237 | { |
312 | { |
238 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
313 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
239 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
314 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
240 | 315 | ||
241 | /* We should probably have an i2c driver get_modes function for those |
316 | /* We should probably have an i2c driver get_modes function for those |
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; |
250 | 325 | ||
251 | if (intel_dvo->panel_fixed_mode != NULL) { |
326 | if (intel_dvo->panel_fixed_mode != NULL) { |
252 | struct drm_display_mode *mode; |
327 | struct drm_display_mode *mode; |
253 | mode = drm_mode_duplicate(connector->dev, intel_dvo->panel_fixed_mode); |
328 | mode = drm_mode_duplicate(connector->dev, intel_dvo->panel_fixed_mode); |
254 | if (mode) { |
329 | if (mode) { |
255 | drm_mode_probed_add(connector, mode); |
330 | drm_mode_probed_add(connector, mode); |
256 | return 1; |
331 | return 1; |
257 | } |
332 | } |
258 | } |
333 | } |
259 | 334 | ||
260 | return 0; |
335 | return 0; |
261 | } |
336 | } |
262 | 337 | ||
263 | static void intel_dvo_destroy(struct drm_connector *connector) |
338 | static void intel_dvo_destroy(struct drm_connector *connector) |
264 | { |
339 | { |
265 | drm_sysfs_connector_remove(connector); |
340 | drm_sysfs_connector_remove(connector); |
266 | drm_connector_cleanup(connector); |
341 | drm_connector_cleanup(connector); |
267 | kfree(connector); |
342 | kfree(connector); |
268 | } |
343 | } |
269 | 344 | ||
270 | static const struct drm_encoder_helper_funcs intel_dvo_helper_funcs = { |
345 | static const struct drm_encoder_helper_funcs intel_dvo_helper_funcs = { |
271 | .dpms = intel_dvo_dpms, |
- | |
272 | .mode_fixup = intel_dvo_mode_fixup, |
346 | .mode_fixup = intel_dvo_mode_fixup, |
273 | .prepare = intel_encoder_prepare, |
- | |
274 | .mode_set = intel_dvo_mode_set, |
347 | .mode_set = intel_dvo_mode_set, |
275 | .commit = intel_encoder_commit, |
348 | .disable = intel_encoder_noop, |
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, |
282 | .fill_modes = drm_helper_probe_single_connector_modes, |
355 | .fill_modes = drm_helper_probe_single_connector_modes, |
283 | }; |
356 | }; |
284 | 357 | ||
285 | static const struct drm_connector_helper_funcs intel_dvo_connector_helper_funcs = { |
358 | static const struct drm_connector_helper_funcs intel_dvo_connector_helper_funcs = { |
286 | .mode_valid = intel_dvo_mode_valid, |
359 | .mode_valid = intel_dvo_mode_valid, |
287 | .get_modes = intel_dvo_get_modes, |
360 | .get_modes = intel_dvo_get_modes, |
288 | .best_encoder = intel_best_encoder, |
361 | .best_encoder = intel_best_encoder, |
289 | }; |
362 | }; |
290 | 363 | ||
291 | static void intel_dvo_enc_destroy(struct drm_encoder *encoder) |
364 | static void intel_dvo_enc_destroy(struct drm_encoder *encoder) |
292 | { |
365 | { |
293 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); |
366 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); |
294 | 367 | ||
295 | if (intel_dvo->dev.dev_ops->destroy) |
368 | if (intel_dvo->dev.dev_ops->destroy) |
296 | intel_dvo->dev.dev_ops->destroy(&intel_dvo->dev); |
369 | intel_dvo->dev.dev_ops->destroy(&intel_dvo->dev); |
297 | 370 | ||
298 | kfree(intel_dvo->panel_fixed_mode); |
371 | kfree(intel_dvo->panel_fixed_mode); |
299 | 372 | ||
300 | intel_encoder_destroy(encoder); |
373 | intel_encoder_destroy(encoder); |
301 | } |
374 | } |
302 | 375 | ||
303 | static const struct drm_encoder_funcs intel_dvo_enc_funcs = { |
376 | static const struct drm_encoder_funcs intel_dvo_enc_funcs = { |
304 | .destroy = intel_dvo_enc_destroy, |
377 | .destroy = intel_dvo_enc_destroy, |
305 | }; |
378 | }; |
306 | 379 | ||
307 | /** |
380 | /** |
308 | * Attempts to get a fixed panel timing for LVDS (currently only the i830). |
381 | * Attempts to get a fixed panel timing for LVDS (currently only the i830). |
309 | * |
382 | * |
310 | * Other chips with DVO LVDS will need to extend this to deal with the LVDS |
383 | * Other chips with DVO LVDS will need to extend this to deal with the LVDS |
311 | * chip being on DVOB/C and having multiple pipes. |
384 | * chip being on DVOB/C and having multiple pipes. |
312 | */ |
385 | */ |
313 | static struct drm_display_mode * |
386 | static struct drm_display_mode * |
314 | intel_dvo_get_current_mode(struct drm_connector *connector) |
387 | intel_dvo_get_current_mode(struct drm_connector *connector) |
315 | { |
388 | { |
316 | struct drm_device *dev = connector->dev; |
389 | struct drm_device *dev = connector->dev; |
317 | struct drm_i915_private *dev_priv = dev->dev_private; |
390 | struct drm_i915_private *dev_priv = dev->dev_private; |
318 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
391 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
319 | uint32_t dvo_val = I915_READ(intel_dvo->dev.dvo_reg); |
392 | uint32_t dvo_val = I915_READ(intel_dvo->dev.dvo_reg); |
320 | struct drm_display_mode *mode = NULL; |
393 | struct drm_display_mode *mode = NULL; |
321 | 394 | ||
322 | /* If the DVO port is active, that'll be the LVDS, so we can pull out |
395 | /* If the DVO port is active, that'll be the LVDS, so we can pull out |
323 | * its timings to get how the BIOS set up the panel. |
396 | * its timings to get how the BIOS set up the panel. |
324 | */ |
397 | */ |
325 | if (dvo_val & DVO_ENABLE) { |
398 | if (dvo_val & DVO_ENABLE) { |
326 | struct drm_crtc *crtc; |
399 | struct drm_crtc *crtc; |
327 | int pipe = (dvo_val & DVO_PIPE_B_SELECT) ? 1 : 0; |
400 | int pipe = (dvo_val & DVO_PIPE_B_SELECT) ? 1 : 0; |
328 | 401 | ||
329 | crtc = intel_get_crtc_for_pipe(dev, pipe); |
402 | crtc = intel_get_crtc_for_pipe(dev, pipe); |
330 | if (crtc) { |
403 | if (crtc) { |
331 | mode = intel_crtc_mode_get(dev, crtc); |
404 | mode = intel_crtc_mode_get(dev, crtc); |
332 | if (mode) { |
405 | if (mode) { |
333 | mode->type |= DRM_MODE_TYPE_PREFERRED; |
406 | mode->type |= DRM_MODE_TYPE_PREFERRED; |
334 | if (dvo_val & DVO_HSYNC_ACTIVE_HIGH) |
407 | if (dvo_val & DVO_HSYNC_ACTIVE_HIGH) |
335 | mode->flags |= DRM_MODE_FLAG_PHSYNC; |
408 | mode->flags |= DRM_MODE_FLAG_PHSYNC; |
336 | if (dvo_val & DVO_VSYNC_ACTIVE_HIGH) |
409 | if (dvo_val & DVO_VSYNC_ACTIVE_HIGH) |
337 | mode->flags |= DRM_MODE_FLAG_PVSYNC; |
410 | mode->flags |= DRM_MODE_FLAG_PVSYNC; |
338 | } |
411 | } |
339 | } |
412 | } |
340 | } |
413 | } |
341 | 414 | ||
342 | return mode; |
415 | return mode; |
343 | } |
416 | } |
344 | 417 | ||
345 | void intel_dvo_init(struct drm_device *dev) |
418 | void intel_dvo_init(struct drm_device *dev) |
346 | { |
419 | { |
347 | struct drm_i915_private *dev_priv = dev->dev_private; |
420 | struct drm_i915_private *dev_priv = dev->dev_private; |
348 | struct intel_encoder *intel_encoder; |
421 | struct intel_encoder *intel_encoder; |
349 | struct intel_dvo *intel_dvo; |
422 | struct intel_dvo *intel_dvo; |
350 | struct intel_connector *intel_connector; |
423 | struct intel_connector *intel_connector; |
351 | int i; |
424 | int i; |
352 | int encoder_type = DRM_MODE_ENCODER_NONE; |
425 | int encoder_type = DRM_MODE_ENCODER_NONE; |
353 | 426 | ||
354 | intel_dvo = kzalloc(sizeof(struct intel_dvo), GFP_KERNEL); |
427 | intel_dvo = kzalloc(sizeof(struct intel_dvo), GFP_KERNEL); |
355 | if (!intel_dvo) |
428 | if (!intel_dvo) |
356 | return; |
429 | return; |
357 | 430 | ||
358 | intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); |
431 | intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); |
359 | if (!intel_connector) { |
432 | if (!intel_connector) { |
360 | kfree(intel_dvo); |
433 | kfree(intel_dvo); |
361 | return; |
434 | return; |
362 | } |
435 | } |
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, |
366 | &intel_dvo_enc_funcs, encoder_type); |
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; |
|
- | 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; |
371 | const struct intel_dvo_device *dvo = &intel_dvo_devices[i]; |
449 | const struct intel_dvo_device *dvo = &intel_dvo_devices[i]; |
372 | struct i2c_adapter *i2c; |
450 | struct i2c_adapter *i2c; |
373 | int gpio; |
451 | int gpio; |
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 |
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). |
389 | */ |
467 | */ |
390 | i2c = &dev_priv->gmbus[gpio].adapter; |
468 | i2c = intel_gmbus_get_adapter(dev_priv, gpio); |
391 | 469 | ||
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); |
475 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1); |
398 | switch (dvo->type) { |
476 | switch (dvo->type) { |
399 | case INTEL_DVO_CHIP_TMDS: |
477 | case INTEL_DVO_CHIP_TMDS: |
400 | intel_encoder->clone_mask = |
478 | intel_encoder->cloneable = true; |
401 | (1 << INTEL_DVO_TMDS_CLONE_BIT) | |
- | |
402 | (1 << INTEL_ANALOG_CLONE_BIT); |
- | |
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; |
482 | encoder_type = DRM_MODE_ENCODER_TMDS; |
407 | break; |
483 | break; |
408 | case INTEL_DVO_CHIP_LVDS: |
484 | case INTEL_DVO_CHIP_LVDS: |
409 | intel_encoder->clone_mask = |
485 | intel_encoder->cloneable = false; |
410 | (1 << INTEL_DVO_LVDS_CLONE_BIT); |
- | |
411 | drm_connector_init(dev, connector, |
486 | drm_connector_init(dev, connector, |
412 | &intel_dvo_connector_funcs, |
487 | &intel_dvo_connector_funcs, |
413 | DRM_MODE_CONNECTOR_LVDS); |
488 | DRM_MODE_CONNECTOR_LVDS); |
414 | encoder_type = DRM_MODE_ENCODER_LVDS; |
489 | encoder_type = DRM_MODE_ENCODER_LVDS; |
415 | break; |
490 | break; |
416 | } |
491 | } |
417 | 492 | ||
418 | drm_connector_helper_add(connector, |
493 | drm_connector_helper_add(connector, |
419 | &intel_dvo_connector_helper_funcs); |
494 | &intel_dvo_connector_helper_funcs); |
420 | connector->display_info.subpixel_order = SubPixelHorizontalRGB; |
495 | connector->display_info.subpixel_order = SubPixelHorizontalRGB; |
421 | connector->interlace_allowed = false; |
496 | connector->interlace_allowed = false; |
422 | connector->doublescan_allowed = false; |
497 | connector->doublescan_allowed = false; |
423 | 498 | ||
424 | drm_encoder_helper_add(&intel_encoder->base, |
499 | drm_encoder_helper_add(&intel_encoder->base, |
425 | &intel_dvo_helper_funcs); |
500 | &intel_dvo_helper_funcs); |
426 | 501 | ||
427 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
502 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
428 | if (dvo->type == INTEL_DVO_CHIP_LVDS) { |
503 | if (dvo->type == INTEL_DVO_CHIP_LVDS) { |
429 | /* For our LVDS chipsets, we should hopefully be able |
504 | /* For our LVDS chipsets, we should hopefully be able |
430 | * to dig the fixed panel mode out of the BIOS data. |
505 | * to dig the fixed panel mode out of the BIOS data. |
431 | * However, it's in a different format from the BIOS |
506 | * However, it's in a different format from the BIOS |
432 | * data on chipsets with integrated LVDS (stored in AIM |
507 | * data on chipsets with integrated LVDS (stored in AIM |
433 | * headers, likely), so for now, just get the current |
508 | * headers, likely), so for now, just get the current |
434 | * mode being output through DVO. |
509 | * mode being output through DVO. |
435 | */ |
510 | */ |
436 | intel_dvo->panel_fixed_mode = |
511 | intel_dvo->panel_fixed_mode = |
437 | intel_dvo_get_current_mode(connector); |
512 | intel_dvo_get_current_mode(connector); |
438 | intel_dvo->panel_wants_dither = true; |
513 | intel_dvo->panel_wants_dither = true; |
439 | } |
514 | } |
440 | 515 | ||
441 | drm_sysfs_connector_add(connector); |
516 | drm_sysfs_connector_add(connector); |
442 | return; |
517 | return; |
443 | } |
518 | } |
444 | 519 | ||
445 | drm_encoder_cleanup(&intel_encoder->base); |
520 | drm_encoder_cleanup(&intel_encoder->base); |
446 | kfree(intel_dvo); |
521 | kfree(intel_dvo); |
447 | kfree(intel_connector); |
522 | kfree(intel_connector); |
448 | }><>><>><>><>><>>><>><>><>><> |
523 | }><>><>>><>><>><>><> |