Commit | Line | Data |
---|---|---|
771fe6b9 JG |
1 | /* |
2 | * Copyright 2007-8 Advanced Micro Devices, Inc. | |
3 | * Copyright 2008 Red Hat Inc. | |
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 shall be included in | |
13 | * all copies or substantial portions of the Software. | |
14 | * | |
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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
19 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
21 | * OTHER DEALINGS IN THE SOFTWARE. | |
22 | * | |
23 | * Authors: Dave Airlie | |
24 | * Alex Deucher | |
25 | */ | |
26 | #include "drmP.h" | |
27 | #include "drm_edid.h" | |
28 | #include "drm_crtc_helper.h" | |
d50ba256 | 29 | #include "drm_fb_helper.h" |
771fe6b9 JG |
30 | #include "radeon_drm.h" |
31 | #include "radeon.h" | |
923f6848 | 32 | #include "atom.h" |
771fe6b9 JG |
33 | |
34 | extern void | |
35 | radeon_combios_connected_scratch_regs(struct drm_connector *connector, | |
36 | struct drm_encoder *encoder, | |
37 | bool connected); | |
38 | extern void | |
39 | radeon_atombios_connected_scratch_regs(struct drm_connector *connector, | |
40 | struct drm_encoder *encoder, | |
41 | bool connected); | |
42 | ||
63ec0119 MD |
43 | extern void |
44 | radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder, | |
45 | struct drm_connector *drm_connector); | |
46 | ||
591a10e1 AD |
47 | bool radeon_connector_encoder_is_dp_bridge(struct drm_connector *connector); |
48 | ||
d4877cf2 AD |
49 | void radeon_connector_hotplug(struct drm_connector *connector) |
50 | { | |
51 | struct drm_device *dev = connector->dev; | |
52 | struct radeon_device *rdev = dev->dev_private; | |
53 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
54 | ||
cbac9543 AD |
55 | /* bail if the connector does not have hpd pin, e.g., |
56 | * VGA, TV, etc. | |
57 | */ | |
58 | if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) | |
59 | return; | |
60 | ||
1e85e1d0 | 61 | radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd); |
d4877cf2 | 62 | |
73104b5c AD |
63 | /* if the connector is already off, don't turn it back on */ |
64 | if (connector->dpms != DRM_MODE_DPMS_ON) | |
65 | return; | |
66 | ||
d5811e87 AD |
67 | /* just deal with DP (not eDP) here. */ |
68 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) { | |
69 | int saved_dpms = connector->dpms; | |
7c3ed0fd | 70 | |
5ba7ddf8 AD |
71 | /* Only turn off the display it it's physically disconnected */ |
72 | if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) | |
1e85e1d0 | 73 | drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); |
5ba7ddf8 AD |
74 | else if (radeon_dp_needs_link_train(radeon_connector)) |
75 | drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); | |
d5811e87 | 76 | connector->dpms = saved_dpms; |
d4877cf2 | 77 | } |
d4877cf2 AD |
78 | } |
79 | ||
445282db DA |
80 | static void radeon_property_change_mode(struct drm_encoder *encoder) |
81 | { | |
82 | struct drm_crtc *crtc = encoder->crtc; | |
83 | ||
84 | if (crtc && crtc->enabled) { | |
85 | drm_crtc_helper_set_mode(crtc, &crtc->mode, | |
86 | crtc->x, crtc->y, crtc->fb); | |
87 | } | |
88 | } | |
771fe6b9 JG |
89 | static void |
90 | radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_connector_status status) | |
91 | { | |
92 | struct drm_device *dev = connector->dev; | |
93 | struct radeon_device *rdev = dev->dev_private; | |
94 | struct drm_encoder *best_encoder = NULL; | |
95 | struct drm_encoder *encoder = NULL; | |
96 | struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; | |
97 | struct drm_mode_object *obj; | |
98 | bool connected; | |
99 | int i; | |
100 | ||
101 | best_encoder = connector_funcs->best_encoder(connector); | |
102 | ||
103 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | |
104 | if (connector->encoder_ids[i] == 0) | |
105 | break; | |
106 | ||
107 | obj = drm_mode_object_find(connector->dev, | |
108 | connector->encoder_ids[i], | |
109 | DRM_MODE_OBJECT_ENCODER); | |
110 | if (!obj) | |
111 | continue; | |
112 | ||
113 | encoder = obj_to_encoder(obj); | |
114 | ||
115 | if ((encoder == best_encoder) && (status == connector_status_connected)) | |
116 | connected = true; | |
117 | else | |
118 | connected = false; | |
119 | ||
120 | if (rdev->is_atom_bios) | |
121 | radeon_atombios_connected_scratch_regs(connector, encoder, connected); | |
122 | else | |
123 | radeon_combios_connected_scratch_regs(connector, encoder, connected); | |
124 | ||
125 | } | |
126 | } | |
127 | ||
445282db DA |
128 | struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type) |
129 | { | |
130 | struct drm_mode_object *obj; | |
131 | struct drm_encoder *encoder; | |
132 | int i; | |
133 | ||
134 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | |
135 | if (connector->encoder_ids[i] == 0) | |
136 | break; | |
137 | ||
138 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); | |
139 | if (!obj) | |
140 | continue; | |
141 | ||
142 | encoder = obj_to_encoder(obj); | |
143 | if (encoder->encoder_type == encoder_type) | |
144 | return encoder; | |
145 | } | |
146 | return NULL; | |
147 | } | |
148 | ||
771fe6b9 JG |
149 | struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector) |
150 | { | |
151 | int enc_id = connector->encoder_ids[0]; | |
152 | struct drm_mode_object *obj; | |
153 | struct drm_encoder *encoder; | |
154 | ||
155 | /* pick the encoder ids */ | |
156 | if (enc_id) { | |
157 | obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); | |
158 | if (!obj) | |
159 | return NULL; | |
160 | encoder = obj_to_encoder(obj); | |
161 | return encoder; | |
162 | } | |
163 | return NULL; | |
164 | } | |
165 | ||
4ce001ab DA |
166 | /* |
167 | * radeon_connector_analog_encoder_conflict_solve | |
168 | * - search for other connectors sharing this encoder | |
169 | * if priority is true, then set them disconnected if this is connected | |
170 | * if priority is false, set us disconnected if they are connected | |
171 | */ | |
172 | static enum drm_connector_status | |
173 | radeon_connector_analog_encoder_conflict_solve(struct drm_connector *connector, | |
174 | struct drm_encoder *encoder, | |
175 | enum drm_connector_status current_status, | |
176 | bool priority) | |
177 | { | |
178 | struct drm_device *dev = connector->dev; | |
179 | struct drm_connector *conflict; | |
08d07511 | 180 | struct radeon_connector *radeon_conflict; |
4ce001ab DA |
181 | int i; |
182 | ||
183 | list_for_each_entry(conflict, &dev->mode_config.connector_list, head) { | |
184 | if (conflict == connector) | |
185 | continue; | |
186 | ||
08d07511 | 187 | radeon_conflict = to_radeon_connector(conflict); |
4ce001ab DA |
188 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
189 | if (conflict->encoder_ids[i] == 0) | |
190 | break; | |
191 | ||
192 | /* if the IDs match */ | |
193 | if (conflict->encoder_ids[i] == encoder->base.id) { | |
194 | if (conflict->status != connector_status_connected) | |
195 | continue; | |
08d07511 AD |
196 | |
197 | if (radeon_conflict->use_digital) | |
198 | continue; | |
4ce001ab DA |
199 | |
200 | if (priority == true) { | |
c5d46b4e AD |
201 | DRM_DEBUG_KMS("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict)); |
202 | DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(connector)); | |
4ce001ab DA |
203 | conflict->status = connector_status_disconnected; |
204 | radeon_connector_update_scratch_regs(conflict, connector_status_disconnected); | |
205 | } else { | |
c5d46b4e AD |
206 | DRM_DEBUG_KMS("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector)); |
207 | DRM_DEBUG_KMS("in favor of %s\n", drm_get_connector_name(conflict)); | |
4ce001ab DA |
208 | current_status = connector_status_disconnected; |
209 | } | |
210 | break; | |
211 | } | |
212 | } | |
213 | } | |
214 | return current_status; | |
215 | ||
216 | } | |
217 | ||
771fe6b9 JG |
218 | static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encoder) |
219 | { | |
220 | struct drm_device *dev = encoder->dev; | |
221 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | |
222 | struct drm_display_mode *mode = NULL; | |
de2103e4 | 223 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
771fe6b9 | 224 | |
de2103e4 AD |
225 | if (native_mode->hdisplay != 0 && |
226 | native_mode->vdisplay != 0 && | |
227 | native_mode->clock != 0) { | |
fb06ca8f | 228 | mode = drm_mode_duplicate(dev, native_mode); |
771fe6b9 JG |
229 | mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; |
230 | drm_mode_set_name(mode); | |
231 | ||
d9fdaafb | 232 | DRM_DEBUG_KMS("Adding native panel mode %s\n", mode->name); |
d2efdf6d AD |
233 | } else if (native_mode->hdisplay != 0 && |
234 | native_mode->vdisplay != 0) { | |
235 | /* mac laptops without an edid */ | |
236 | /* Note that this is not necessarily the exact panel mode, | |
237 | * but an approximation based on the cvt formula. For these | |
238 | * systems we should ideally read the mode info out of the | |
239 | * registers or add a mode table, but this works and is much | |
240 | * simpler. | |
241 | */ | |
242 | mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false); | |
243 | mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; | |
d9fdaafb | 244 | DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode->name); |
771fe6b9 JG |
245 | } |
246 | return mode; | |
247 | } | |
248 | ||
923f6848 AD |
249 | static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_connector *connector) |
250 | { | |
251 | struct drm_device *dev = encoder->dev; | |
252 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | |
253 | struct drm_display_mode *mode = NULL; | |
de2103e4 | 254 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
923f6848 AD |
255 | int i; |
256 | struct mode_size { | |
257 | int w; | |
258 | int h; | |
259 | } common_modes[17] = { | |
260 | { 640, 480}, | |
261 | { 720, 480}, | |
262 | { 800, 600}, | |
263 | { 848, 480}, | |
264 | {1024, 768}, | |
265 | {1152, 768}, | |
266 | {1280, 720}, | |
267 | {1280, 800}, | |
268 | {1280, 854}, | |
269 | {1280, 960}, | |
270 | {1280, 1024}, | |
271 | {1440, 900}, | |
272 | {1400, 1050}, | |
273 | {1680, 1050}, | |
274 | {1600, 1200}, | |
275 | {1920, 1080}, | |
276 | {1920, 1200} | |
277 | }; | |
278 | ||
279 | for (i = 0; i < 17; i++) { | |
dfdd6467 AD |
280 | if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { |
281 | if (common_modes[i].w > 1024 || | |
282 | common_modes[i].h > 768) | |
283 | continue; | |
284 | } | |
923f6848 | 285 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
de2103e4 AD |
286 | if (common_modes[i].w > native_mode->hdisplay || |
287 | common_modes[i].h > native_mode->vdisplay || | |
288 | (common_modes[i].w == native_mode->hdisplay && | |
289 | common_modes[i].h == native_mode->vdisplay)) | |
923f6848 AD |
290 | continue; |
291 | } | |
292 | if (common_modes[i].w < 320 || common_modes[i].h < 200) | |
293 | continue; | |
294 | ||
d50ba256 | 295 | mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false); |
923f6848 AD |
296 | drm_mode_probed_add(connector, mode); |
297 | } | |
298 | } | |
299 | ||
771fe6b9 JG |
300 | int radeon_connector_set_property(struct drm_connector *connector, struct drm_property *property, |
301 | uint64_t val) | |
302 | { | |
445282db DA |
303 | struct drm_device *dev = connector->dev; |
304 | struct radeon_device *rdev = dev->dev_private; | |
305 | struct drm_encoder *encoder; | |
306 | struct radeon_encoder *radeon_encoder; | |
307 | ||
308 | if (property == rdev->mode_info.coherent_mode_property) { | |
309 | struct radeon_encoder_atom_dig *dig; | |
ce227c41 | 310 | bool new_coherent_mode; |
445282db DA |
311 | |
312 | /* need to find digital encoder on connector */ | |
313 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); | |
314 | if (!encoder) | |
315 | return 0; | |
316 | ||
317 | radeon_encoder = to_radeon_encoder(encoder); | |
318 | ||
319 | if (!radeon_encoder->enc_priv) | |
320 | return 0; | |
321 | ||
322 | dig = radeon_encoder->enc_priv; | |
ce227c41 DA |
323 | new_coherent_mode = val ? true : false; |
324 | if (dig->coherent_mode != new_coherent_mode) { | |
325 | dig->coherent_mode = new_coherent_mode; | |
326 | radeon_property_change_mode(&radeon_encoder->base); | |
327 | } | |
445282db DA |
328 | } |
329 | ||
5b1714d3 AD |
330 | if (property == rdev->mode_info.underscan_property) { |
331 | /* need to find digital encoder on connector */ | |
332 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); | |
333 | if (!encoder) | |
334 | return 0; | |
335 | ||
336 | radeon_encoder = to_radeon_encoder(encoder); | |
337 | ||
338 | if (radeon_encoder->underscan_type != val) { | |
339 | radeon_encoder->underscan_type = val; | |
340 | radeon_property_change_mode(&radeon_encoder->base); | |
341 | } | |
342 | } | |
343 | ||
5bccf5e3 MG |
344 | if (property == rdev->mode_info.underscan_hborder_property) { |
345 | /* need to find digital encoder on connector */ | |
346 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); | |
347 | if (!encoder) | |
348 | return 0; | |
349 | ||
350 | radeon_encoder = to_radeon_encoder(encoder); | |
351 | ||
352 | if (radeon_encoder->underscan_hborder != val) { | |
353 | radeon_encoder->underscan_hborder = val; | |
354 | radeon_property_change_mode(&radeon_encoder->base); | |
355 | } | |
356 | } | |
357 | ||
358 | if (property == rdev->mode_info.underscan_vborder_property) { | |
359 | /* need to find digital encoder on connector */ | |
360 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); | |
361 | if (!encoder) | |
362 | return 0; | |
363 | ||
364 | radeon_encoder = to_radeon_encoder(encoder); | |
365 | ||
366 | if (radeon_encoder->underscan_vborder != val) { | |
367 | radeon_encoder->underscan_vborder = val; | |
368 | radeon_property_change_mode(&radeon_encoder->base); | |
369 | } | |
370 | } | |
371 | ||
445282db DA |
372 | if (property == rdev->mode_info.tv_std_property) { |
373 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TVDAC); | |
374 | if (!encoder) { | |
375 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_DAC); | |
376 | } | |
377 | ||
378 | if (!encoder) | |
379 | return 0; | |
380 | ||
381 | radeon_encoder = to_radeon_encoder(encoder); | |
382 | if (!radeon_encoder->enc_priv) | |
383 | return 0; | |
643acacf | 384 | if (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom) { |
445282db DA |
385 | struct radeon_encoder_atom_dac *dac_int; |
386 | dac_int = radeon_encoder->enc_priv; | |
387 | dac_int->tv_std = val; | |
388 | } else { | |
389 | struct radeon_encoder_tv_dac *dac_int; | |
390 | dac_int = radeon_encoder->enc_priv; | |
391 | dac_int->tv_std = val; | |
392 | } | |
393 | radeon_property_change_mode(&radeon_encoder->base); | |
394 | } | |
395 | ||
396 | if (property == rdev->mode_info.load_detect_property) { | |
397 | struct radeon_connector *radeon_connector = | |
398 | to_radeon_connector(connector); | |
399 | ||
400 | if (val == 0) | |
401 | radeon_connector->dac_load_detect = false; | |
402 | else | |
403 | radeon_connector->dac_load_detect = true; | |
404 | } | |
405 | ||
406 | if (property == rdev->mode_info.tmds_pll_property) { | |
407 | struct radeon_encoder_int_tmds *tmds = NULL; | |
408 | bool ret = false; | |
409 | /* need to find digital encoder on connector */ | |
410 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); | |
411 | if (!encoder) | |
412 | return 0; | |
413 | ||
414 | radeon_encoder = to_radeon_encoder(encoder); | |
415 | ||
416 | tmds = radeon_encoder->enc_priv; | |
417 | if (!tmds) | |
418 | return 0; | |
419 | ||
420 | if (val == 0) { | |
421 | if (rdev->is_atom_bios) | |
422 | ret = radeon_atombios_get_tmds_info(radeon_encoder, tmds); | |
423 | else | |
424 | ret = radeon_legacy_get_tmds_info_from_combios(radeon_encoder, tmds); | |
425 | } | |
426 | if (val == 1 || ret == false) { | |
427 | radeon_legacy_get_tmds_info_from_table(radeon_encoder, tmds); | |
428 | } | |
429 | radeon_property_change_mode(&radeon_encoder->base); | |
430 | } | |
431 | ||
771fe6b9 JG |
432 | return 0; |
433 | } | |
434 | ||
e384fab8 TR |
435 | /* |
436 | * Some integrated ATI Radeon chipset implementations (e. g. | |
437 | * Asus M2A-VM HDMI) may indicate the availability of a DDC, | |
438 | * even when there's no monitor connected. For these connectors | |
439 | * following DDC probe extension will be applied: check also for the | |
440 | * availability of EDID with at least a correct EDID header. Only then, | |
441 | * DDC is assumed to be available. This prevents drm_get_edid() and | |
442 | * drm_edid_block_valid() from periodically dumping data and kernel | |
443 | * errors into the logs and onto the terminal. | |
444 | */ | |
445 | static bool radeon_connector_needs_extended_probe(struct radeon_device *dev, | |
446 | uint32_t supported_device, | |
447 | int connector_type) | |
448 | { | |
449 | /* Asus M2A-VM HDMI board sends data to i2c bus even, | |
450 | * if HDMI add-on card is not plugged in or HDMI is disabled in | |
451 | * BIOS. Valid DDC can only be assumed, if also a valid EDID header | |
452 | * can be retrieved via i2c bus during DDC probe */ | |
453 | if ((dev->pdev->device == 0x791e) && | |
454 | (dev->pdev->subsystem_vendor == 0x1043) && | |
455 | (dev->pdev->subsystem_device == 0x826d)) { | |
456 | if ((connector_type == DRM_MODE_CONNECTOR_HDMIA) && | |
457 | (supported_device == ATOM_DEVICE_DFP2_SUPPORT)) | |
458 | return true; | |
459 | } | |
a81b31e9 TR |
460 | /* ECS A740GM-M with ATI RADEON 2100 sends data to i2c bus |
461 | * for a DVI connector that is not implemented */ | |
462 | if ((dev->pdev->device == 0x796e) && | |
463 | (dev->pdev->subsystem_vendor == 0x1019) && | |
464 | (dev->pdev->subsystem_device == 0x2615)) { | |
465 | if ((connector_type == DRM_MODE_CONNECTOR_DVID) && | |
466 | (supported_device == ATOM_DEVICE_DFP2_SUPPORT)) | |
467 | return true; | |
468 | } | |
f2b60717 TR |
469 | /* TOSHIBA Satellite L300D with ATI Mobility Radeon x1100 |
470 | * (RS690M) sends data to i2c bus for a HDMI connector that | |
471 | * is not implemented */ | |
472 | if ((dev->pdev->device == 0x791f) && | |
473 | (dev->pdev->subsystem_vendor == 0x1179) && | |
474 | (dev->pdev->subsystem_device == 0xff68)) { | |
475 | if ((connector_type == DRM_MODE_CONNECTOR_HDMIA) && | |
476 | (supported_device == ATOM_DEVICE_DFP2_SUPPORT)) | |
477 | return true; | |
478 | } | |
e384fab8 TR |
479 | |
480 | /* Default: no EDID header probe required for DDC probing */ | |
481 | return false; | |
482 | } | |
483 | ||
8dfaa8a7 MD |
484 | static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder, |
485 | struct drm_connector *connector) | |
486 | { | |
487 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | |
de2103e4 | 488 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
13bb9430 MG |
489 | struct drm_display_mode *t, *mode; |
490 | ||
491 | /* If the EDID preferred mode doesn't match the native mode, use it */ | |
492 | list_for_each_entry_safe(mode, t, &connector->probed_modes, head) { | |
493 | if (mode->type & DRM_MODE_TYPE_PREFERRED) { | |
494 | if (mode->hdisplay != native_mode->hdisplay || | |
495 | mode->vdisplay != native_mode->vdisplay) | |
496 | memcpy(native_mode, mode, sizeof(*mode)); | |
497 | } | |
498 | } | |
8dfaa8a7 MD |
499 | |
500 | /* Try to get native mode details from EDID if necessary */ | |
de2103e4 | 501 | if (!native_mode->clock) { |
8dfaa8a7 | 502 | list_for_each_entry_safe(mode, t, &connector->probed_modes, head) { |
de2103e4 AD |
503 | if (mode->hdisplay == native_mode->hdisplay && |
504 | mode->vdisplay == native_mode->vdisplay) { | |
505 | *native_mode = *mode; | |
506 | drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V); | |
c5d46b4e | 507 | DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n"); |
8dfaa8a7 MD |
508 | break; |
509 | } | |
510 | } | |
511 | } | |
13bb9430 | 512 | |
de2103e4 | 513 | if (!native_mode->clock) { |
c5d46b4e | 514 | DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n"); |
8dfaa8a7 MD |
515 | radeon_encoder->rmx_type = RMX_OFF; |
516 | } | |
517 | } | |
771fe6b9 JG |
518 | |
519 | static int radeon_lvds_get_modes(struct drm_connector *connector) | |
520 | { | |
521 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
522 | struct drm_encoder *encoder; | |
523 | int ret = 0; | |
524 | struct drm_display_mode *mode; | |
525 | ||
526 | if (radeon_connector->ddc_bus) { | |
527 | ret = radeon_ddc_get_modes(radeon_connector); | |
528 | if (ret > 0) { | |
7747b713 | 529 | encoder = radeon_best_single_encoder(connector); |
8dfaa8a7 MD |
530 | if (encoder) { |
531 | radeon_fixup_lvds_native_mode(encoder, connector); | |
7747b713 AD |
532 | /* add scaled modes */ |
533 | radeon_add_common_modes(encoder, connector); | |
8dfaa8a7 | 534 | } |
771fe6b9 JG |
535 | return ret; |
536 | } | |
537 | } | |
538 | ||
539 | encoder = radeon_best_single_encoder(connector); | |
540 | if (!encoder) | |
541 | return 0; | |
542 | ||
543 | /* we have no EDID modes */ | |
544 | mode = radeon_fp_native_mode(encoder); | |
545 | if (mode) { | |
546 | ret = 1; | |
547 | drm_mode_probed_add(connector, mode); | |
7a868e18 AD |
548 | /* add the width/height from vbios tables if available */ |
549 | connector->display_info.width_mm = mode->width_mm; | |
550 | connector->display_info.height_mm = mode->height_mm; | |
7747b713 AD |
551 | /* add scaled modes */ |
552 | radeon_add_common_modes(encoder, connector); | |
771fe6b9 | 553 | } |
923f6848 | 554 | |
771fe6b9 JG |
555 | return ret; |
556 | } | |
557 | ||
558 | static int radeon_lvds_mode_valid(struct drm_connector *connector, | |
559 | struct drm_display_mode *mode) | |
560 | { | |
a3fa6320 AD |
561 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
562 | ||
563 | if ((mode->hdisplay < 320) || (mode->vdisplay < 240)) | |
564 | return MODE_PANEL; | |
565 | ||
566 | if (encoder) { | |
567 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | |
568 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; | |
569 | ||
570 | /* AVIVO hardware supports downscaling modes larger than the panel | |
571 | * to the panel size, but I'm not sure this is desirable. | |
572 | */ | |
573 | if ((mode->hdisplay > native_mode->hdisplay) || | |
574 | (mode->vdisplay > native_mode->vdisplay)) | |
575 | return MODE_PANEL; | |
576 | ||
577 | /* if scaling is disabled, block non-native modes */ | |
578 | if (radeon_encoder->rmx_type == RMX_OFF) { | |
579 | if ((mode->hdisplay != native_mode->hdisplay) || | |
580 | (mode->vdisplay != native_mode->vdisplay)) | |
581 | return MODE_PANEL; | |
582 | } | |
583 | } | |
584 | ||
771fe6b9 JG |
585 | return MODE_OK; |
586 | } | |
587 | ||
7b334fcb | 588 | static enum drm_connector_status |
930a9e28 | 589 | radeon_lvds_detect(struct drm_connector *connector, bool force) |
771fe6b9 | 590 | { |
0549a061 | 591 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
2ffb8429 | 592 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
0549a061 | 593 | enum drm_connector_status ret = connector_status_disconnected; |
2ffb8429 AD |
594 | |
595 | if (encoder) { | |
596 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | |
de2103e4 | 597 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
2ffb8429 AD |
598 | |
599 | /* check if panel is valid */ | |
de2103e4 | 600 | if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240) |
2ffb8429 AD |
601 | ret = connector_status_connected; |
602 | ||
603 | } | |
0549a061 AD |
604 | |
605 | /* check for edid as well */ | |
0294cf4f AD |
606 | if (radeon_connector->edid) |
607 | ret = connector_status_connected; | |
608 | else { | |
609 | if (radeon_connector->ddc_bus) { | |
0294cf4f AD |
610 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, |
611 | &radeon_connector->ddc_bus->adapter); | |
0294cf4f AD |
612 | if (radeon_connector->edid) |
613 | ret = connector_status_connected; | |
614 | } | |
0549a061 | 615 | } |
771fe6b9 | 616 | /* check acpi lid status ??? */ |
2ffb8429 | 617 | |
771fe6b9 JG |
618 | radeon_connector_update_scratch_regs(connector, ret); |
619 | return ret; | |
620 | } | |
621 | ||
622 | static void radeon_connector_destroy(struct drm_connector *connector) | |
623 | { | |
624 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
625 | ||
0294cf4f AD |
626 | if (radeon_connector->edid) |
627 | kfree(radeon_connector->edid); | |
771fe6b9 JG |
628 | kfree(radeon_connector->con_priv); |
629 | drm_sysfs_connector_remove(connector); | |
630 | drm_connector_cleanup(connector); | |
631 | kfree(connector); | |
632 | } | |
633 | ||
445282db DA |
634 | static int radeon_lvds_set_property(struct drm_connector *connector, |
635 | struct drm_property *property, | |
636 | uint64_t value) | |
637 | { | |
638 | struct drm_device *dev = connector->dev; | |
639 | struct radeon_encoder *radeon_encoder; | |
640 | enum radeon_rmx_type rmx_type; | |
641 | ||
d9fdaafb | 642 | DRM_DEBUG_KMS("\n"); |
445282db DA |
643 | if (property != dev->mode_config.scaling_mode_property) |
644 | return 0; | |
645 | ||
646 | if (connector->encoder) | |
647 | radeon_encoder = to_radeon_encoder(connector->encoder); | |
648 | else { | |
649 | struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; | |
650 | radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector)); | |
651 | } | |
652 | ||
653 | switch (value) { | |
654 | case DRM_MODE_SCALE_NONE: rmx_type = RMX_OFF; break; | |
655 | case DRM_MODE_SCALE_CENTER: rmx_type = RMX_CENTER; break; | |
656 | case DRM_MODE_SCALE_ASPECT: rmx_type = RMX_ASPECT; break; | |
657 | default: | |
658 | case DRM_MODE_SCALE_FULLSCREEN: rmx_type = RMX_FULL; break; | |
659 | } | |
660 | if (radeon_encoder->rmx_type == rmx_type) | |
661 | return 0; | |
662 | ||
663 | radeon_encoder->rmx_type = rmx_type; | |
664 | ||
665 | radeon_property_change_mode(&radeon_encoder->base); | |
666 | return 0; | |
667 | } | |
668 | ||
669 | ||
771fe6b9 JG |
670 | struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs = { |
671 | .get_modes = radeon_lvds_get_modes, | |
672 | .mode_valid = radeon_lvds_mode_valid, | |
673 | .best_encoder = radeon_best_single_encoder, | |
674 | }; | |
675 | ||
676 | struct drm_connector_funcs radeon_lvds_connector_funcs = { | |
677 | .dpms = drm_helper_connector_dpms, | |
678 | .detect = radeon_lvds_detect, | |
679 | .fill_modes = drm_helper_probe_single_connector_modes, | |
680 | .destroy = radeon_connector_destroy, | |
445282db | 681 | .set_property = radeon_lvds_set_property, |
771fe6b9 JG |
682 | }; |
683 | ||
684 | static int radeon_vga_get_modes(struct drm_connector *connector) | |
685 | { | |
686 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
687 | int ret; | |
688 | ||
689 | ret = radeon_ddc_get_modes(radeon_connector); | |
690 | ||
691 | return ret; | |
692 | } | |
693 | ||
694 | static int radeon_vga_mode_valid(struct drm_connector *connector, | |
695 | struct drm_display_mode *mode) | |
696 | { | |
b20f9bef AD |
697 | struct drm_device *dev = connector->dev; |
698 | struct radeon_device *rdev = dev->dev_private; | |
699 | ||
a3fa6320 | 700 | /* XXX check mode bandwidth */ |
b20f9bef AD |
701 | |
702 | if ((mode->clock / 10) > rdev->clock.max_pixel_clock) | |
703 | return MODE_CLOCK_HIGH; | |
704 | ||
771fe6b9 JG |
705 | return MODE_OK; |
706 | } | |
707 | ||
7b334fcb | 708 | static enum drm_connector_status |
930a9e28 | 709 | radeon_vga_detect(struct drm_connector *connector, bool force) |
771fe6b9 | 710 | { |
fafcf94e AD |
711 | struct drm_device *dev = connector->dev; |
712 | struct radeon_device *rdev = dev->dev_private; | |
771fe6b9 JG |
713 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
714 | struct drm_encoder *encoder; | |
715 | struct drm_encoder_helper_funcs *encoder_funcs; | |
4b9d2a21 | 716 | bool dret = false; |
771fe6b9 JG |
717 | enum drm_connector_status ret = connector_status_disconnected; |
718 | ||
4ce001ab DA |
719 | encoder = radeon_best_single_encoder(connector); |
720 | if (!encoder) | |
721 | ret = connector_status_disconnected; | |
722 | ||
eb6b6d7c | 723 | if (radeon_connector->ddc_bus) |
e384fab8 TR |
724 | dret = radeon_ddc_probe(radeon_connector, |
725 | radeon_connector->requires_extended_probe); | |
0294cf4f AD |
726 | if (dret) { |
727 | if (radeon_connector->edid) { | |
728 | kfree(radeon_connector->edid); | |
729 | radeon_connector->edid = NULL; | |
730 | } | |
0294cf4f | 731 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter); |
0294cf4f AD |
732 | |
733 | if (!radeon_connector->edid) { | |
f82f5f3a JG |
734 | DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", |
735 | drm_get_connector_name(connector)); | |
736 | ret = connector_status_connected; | |
0294cf4f AD |
737 | } else { |
738 | radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); | |
739 | ||
740 | /* some oems have boards with separate digital and analog connectors | |
741 | * with a shared ddc line (often vga + hdmi) | |
742 | */ | |
743 | if (radeon_connector->use_digital && radeon_connector->shared_ddc) { | |
744 | kfree(radeon_connector->edid); | |
745 | radeon_connector->edid = NULL; | |
746 | ret = connector_status_disconnected; | |
747 | } else | |
748 | ret = connector_status_connected; | |
749 | } | |
750 | } else { | |
c3cceedd DA |
751 | |
752 | /* if we aren't forcing don't do destructive polling */ | |
753 | if (!force) | |
754 | return connector->status; | |
755 | ||
d8a7f792 | 756 | if (radeon_connector->dac_load_detect && encoder) { |
445282db DA |
757 | encoder_funcs = encoder->helper_private; |
758 | ret = encoder_funcs->detect(encoder, connector); | |
759 | } | |
771fe6b9 JG |
760 | } |
761 | ||
4ce001ab DA |
762 | if (ret == connector_status_connected) |
763 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); | |
fafcf94e AD |
764 | |
765 | /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the | |
766 | * vbios to deal with KVMs. If we have one and are not able to detect a monitor | |
767 | * by other means, assume the CRT is connected and use that EDID. | |
768 | */ | |
769 | if ((!rdev->is_atom_bios) && | |
770 | (ret == connector_status_disconnected) && | |
771 | rdev->mode_info.bios_hardcoded_edid_size) { | |
772 | ret = connector_status_connected; | |
773 | } | |
774 | ||
771fe6b9 JG |
775 | radeon_connector_update_scratch_regs(connector, ret); |
776 | return ret; | |
777 | } | |
778 | ||
779 | struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs = { | |
780 | .get_modes = radeon_vga_get_modes, | |
781 | .mode_valid = radeon_vga_mode_valid, | |
782 | .best_encoder = radeon_best_single_encoder, | |
783 | }; | |
784 | ||
785 | struct drm_connector_funcs radeon_vga_connector_funcs = { | |
786 | .dpms = drm_helper_connector_dpms, | |
787 | .detect = radeon_vga_detect, | |
788 | .fill_modes = drm_helper_probe_single_connector_modes, | |
789 | .destroy = radeon_connector_destroy, | |
790 | .set_property = radeon_connector_set_property, | |
791 | }; | |
792 | ||
4ce001ab DA |
793 | static int radeon_tv_get_modes(struct drm_connector *connector) |
794 | { | |
795 | struct drm_device *dev = connector->dev; | |
923f6848 | 796 | struct radeon_device *rdev = dev->dev_private; |
4ce001ab | 797 | struct drm_display_mode *tv_mode; |
923f6848 | 798 | struct drm_encoder *encoder; |
4ce001ab | 799 | |
923f6848 AD |
800 | encoder = radeon_best_single_encoder(connector); |
801 | if (!encoder) | |
802 | return 0; | |
4ce001ab | 803 | |
923f6848 AD |
804 | /* avivo chips can scale any mode */ |
805 | if (rdev->family >= CHIP_RS600) | |
806 | /* add scaled modes */ | |
807 | radeon_add_common_modes(encoder, connector); | |
808 | else { | |
809 | /* only 800x600 is supported right now on pre-avivo chips */ | |
d50ba256 | 810 | tv_mode = drm_cvt_mode(dev, 800, 600, 60, false, false, false); |
923f6848 AD |
811 | tv_mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; |
812 | drm_mode_probed_add(connector, tv_mode); | |
813 | } | |
4ce001ab DA |
814 | return 1; |
815 | } | |
816 | ||
817 | static int radeon_tv_mode_valid(struct drm_connector *connector, | |
818 | struct drm_display_mode *mode) | |
819 | { | |
a3fa6320 AD |
820 | if ((mode->hdisplay > 1024) || (mode->vdisplay > 768)) |
821 | return MODE_CLOCK_RANGE; | |
4ce001ab DA |
822 | return MODE_OK; |
823 | } | |
824 | ||
7b334fcb | 825 | static enum drm_connector_status |
930a9e28 | 826 | radeon_tv_detect(struct drm_connector *connector, bool force) |
4ce001ab DA |
827 | { |
828 | struct drm_encoder *encoder; | |
829 | struct drm_encoder_helper_funcs *encoder_funcs; | |
445282db DA |
830 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
831 | enum drm_connector_status ret = connector_status_disconnected; | |
832 | ||
833 | if (!radeon_connector->dac_load_detect) | |
834 | return ret; | |
4ce001ab DA |
835 | |
836 | encoder = radeon_best_single_encoder(connector); | |
837 | if (!encoder) | |
838 | ret = connector_status_disconnected; | |
839 | else { | |
840 | encoder_funcs = encoder->helper_private; | |
841 | ret = encoder_funcs->detect(encoder, connector); | |
842 | } | |
843 | if (ret == connector_status_connected) | |
844 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false); | |
845 | radeon_connector_update_scratch_regs(connector, ret); | |
846 | return ret; | |
847 | } | |
848 | ||
849 | struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs = { | |
850 | .get_modes = radeon_tv_get_modes, | |
851 | .mode_valid = radeon_tv_mode_valid, | |
852 | .best_encoder = radeon_best_single_encoder, | |
853 | }; | |
854 | ||
855 | struct drm_connector_funcs radeon_tv_connector_funcs = { | |
856 | .dpms = drm_helper_connector_dpms, | |
857 | .detect = radeon_tv_detect, | |
858 | .fill_modes = drm_helper_probe_single_connector_modes, | |
859 | .destroy = radeon_connector_destroy, | |
860 | .set_property = radeon_connector_set_property, | |
861 | }; | |
862 | ||
771fe6b9 JG |
863 | static int radeon_dvi_get_modes(struct drm_connector *connector) |
864 | { | |
865 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
866 | int ret; | |
867 | ||
868 | ret = radeon_ddc_get_modes(radeon_connector); | |
771fe6b9 JG |
869 | return ret; |
870 | } | |
871 | ||
4ce001ab DA |
872 | /* |
873 | * DVI is complicated | |
874 | * Do a DDC probe, if DDC probe passes, get the full EDID so | |
875 | * we can do analog/digital monitor detection at this point. | |
876 | * If the monitor is an analog monitor or we got no DDC, | |
877 | * we need to find the DAC encoder object for this connector. | |
878 | * If we got no DDC, we do load detection on the DAC encoder object. | |
879 | * If we got analog DDC or load detection passes on the DAC encoder | |
880 | * we have to check if this analog encoder is shared with anyone else (TV) | |
881 | * if its shared we have to set the other connector to disconnected. | |
882 | */ | |
7b334fcb | 883 | static enum drm_connector_status |
930a9e28 | 884 | radeon_dvi_detect(struct drm_connector *connector, bool force) |
771fe6b9 | 885 | { |
fafcf94e AD |
886 | struct drm_device *dev = connector->dev; |
887 | struct radeon_device *rdev = dev->dev_private; | |
771fe6b9 | 888 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
4ce001ab | 889 | struct drm_encoder *encoder = NULL; |
771fe6b9 JG |
890 | struct drm_encoder_helper_funcs *encoder_funcs; |
891 | struct drm_mode_object *obj; | |
892 | int i; | |
893 | enum drm_connector_status ret = connector_status_disconnected; | |
4b9d2a21 | 894 | bool dret = false; |
771fe6b9 | 895 | |
eb6b6d7c | 896 | if (radeon_connector->ddc_bus) |
e384fab8 TR |
897 | dret = radeon_ddc_probe(radeon_connector, |
898 | radeon_connector->requires_extended_probe); | |
4ce001ab | 899 | if (dret) { |
0294cf4f AD |
900 | if (radeon_connector->edid) { |
901 | kfree(radeon_connector->edid); | |
902 | radeon_connector->edid = NULL; | |
903 | } | |
4ce001ab | 904 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter); |
4ce001ab DA |
905 | |
906 | if (!radeon_connector->edid) { | |
f82f5f3a JG |
907 | DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", |
908 | drm_get_connector_name(connector)); | |
4a9a8b71 DA |
909 | /* rs690 seems to have a problem with connectors not existing and always |
910 | * return a block of 0's. If we see this just stop polling on this output */ | |
911 | if ((rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) && radeon_connector->base.null_edid_counter) { | |
912 | ret = connector_status_disconnected; | |
913 | DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n", drm_get_connector_name(connector)); | |
914 | radeon_connector->ddc_bus = NULL; | |
915 | } | |
4ce001ab DA |
916 | } else { |
917 | radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); | |
918 | ||
0294cf4f AD |
919 | /* some oems have boards with separate digital and analog connectors |
920 | * with a shared ddc line (often vga + hdmi) | |
921 | */ | |
922 | if ((!radeon_connector->use_digital) && radeon_connector->shared_ddc) { | |
923 | kfree(radeon_connector->edid); | |
924 | radeon_connector->edid = NULL; | |
925 | ret = connector_status_disconnected; | |
926 | } else | |
927 | ret = connector_status_connected; | |
71407c46 | 928 | |
42f14c4b AD |
929 | /* This gets complicated. We have boards with VGA + HDMI with a |
930 | * shared DDC line and we have boards with DVI-D + HDMI with a shared | |
931 | * DDC line. The latter is more complex because with DVI<->HDMI adapters | |
932 | * you don't really know what's connected to which port as both are digital. | |
71407c46 | 933 | */ |
d3932d6c | 934 | if (radeon_connector->shared_ddc && (ret == connector_status_connected)) { |
71407c46 AD |
935 | struct drm_connector *list_connector; |
936 | struct radeon_connector *list_radeon_connector; | |
937 | list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) { | |
938 | if (connector == list_connector) | |
939 | continue; | |
940 | list_radeon_connector = to_radeon_connector(list_connector); | |
b2ea4aa6 AD |
941 | if (list_radeon_connector->shared_ddc && |
942 | (list_radeon_connector->ddc_bus->rec.i2c_id == | |
943 | radeon_connector->ddc_bus->rec.i2c_id)) { | |
42f14c4b AD |
944 | /* cases where both connectors are digital */ |
945 | if (list_connector->connector_type != DRM_MODE_CONNECTOR_VGA) { | |
946 | /* hpd is our only option in this case */ | |
947 | if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { | |
71407c46 AD |
948 | kfree(radeon_connector->edid); |
949 | radeon_connector->edid = NULL; | |
950 | ret = connector_status_disconnected; | |
951 | } | |
952 | } | |
953 | } | |
954 | } | |
955 | } | |
4ce001ab DA |
956 | } |
957 | } | |
958 | ||
959 | if ((ret == connector_status_connected) && (radeon_connector->use_digital == true)) | |
960 | goto out; | |
961 | ||
c3cceedd DA |
962 | if (!force) { |
963 | ret = connector->status; | |
964 | goto out; | |
965 | } | |
966 | ||
4ce001ab | 967 | /* find analog encoder */ |
445282db DA |
968 | if (radeon_connector->dac_load_detect) { |
969 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | |
970 | if (connector->encoder_ids[i] == 0) | |
971 | break; | |
771fe6b9 | 972 | |
445282db DA |
973 | obj = drm_mode_object_find(connector->dev, |
974 | connector->encoder_ids[i], | |
975 | DRM_MODE_OBJECT_ENCODER); | |
976 | if (!obj) | |
977 | continue; | |
771fe6b9 | 978 | |
445282db | 979 | encoder = obj_to_encoder(obj); |
771fe6b9 | 980 | |
445282db DA |
981 | encoder_funcs = encoder->helper_private; |
982 | if (encoder_funcs->detect) { | |
983 | if (ret != connector_status_connected) { | |
984 | ret = encoder_funcs->detect(encoder, connector); | |
985 | if (ret == connector_status_connected) { | |
986 | radeon_connector->use_digital = false; | |
987 | } | |
771fe6b9 | 988 | } |
445282db | 989 | break; |
771fe6b9 JG |
990 | } |
991 | } | |
992 | } | |
993 | ||
4ce001ab DA |
994 | if ((ret == connector_status_connected) && (radeon_connector->use_digital == false) && |
995 | encoder) { | |
996 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); | |
997 | } | |
998 | ||
fafcf94e AD |
999 | /* RN50 and some RV100 asics in servers often have a hardcoded EDID in the |
1000 | * vbios to deal with KVMs. If we have one and are not able to detect a monitor | |
1001 | * by other means, assume the DFP is connected and use that EDID. In most | |
1002 | * cases the DVI port is actually a virtual KVM port connected to the service | |
1003 | * processor. | |
1004 | */ | |
1005 | if ((!rdev->is_atom_bios) && | |
1006 | (ret == connector_status_disconnected) && | |
1007 | rdev->mode_info.bios_hardcoded_edid_size) { | |
1008 | radeon_connector->use_digital = true; | |
1009 | ret = connector_status_connected; | |
1010 | } | |
1011 | ||
4ce001ab | 1012 | out: |
771fe6b9 JG |
1013 | /* updated in get modes as well since we need to know if it's analog or digital */ |
1014 | radeon_connector_update_scratch_regs(connector, ret); | |
1015 | return ret; | |
1016 | } | |
1017 | ||
1018 | /* okay need to be smart in here about which encoder to pick */ | |
1019 | struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector) | |
1020 | { | |
1021 | int enc_id = connector->encoder_ids[0]; | |
1022 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
1023 | struct drm_mode_object *obj; | |
1024 | struct drm_encoder *encoder; | |
1025 | int i; | |
1026 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | |
1027 | if (connector->encoder_ids[i] == 0) | |
1028 | break; | |
1029 | ||
1030 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); | |
1031 | if (!obj) | |
1032 | continue; | |
1033 | ||
1034 | encoder = obj_to_encoder(obj); | |
1035 | ||
4ce001ab | 1036 | if (radeon_connector->use_digital == true) { |
771fe6b9 JG |
1037 | if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) |
1038 | return encoder; | |
1039 | } else { | |
1040 | if (encoder->encoder_type == DRM_MODE_ENCODER_DAC || | |
1041 | encoder->encoder_type == DRM_MODE_ENCODER_TVDAC) | |
1042 | return encoder; | |
1043 | } | |
1044 | } | |
1045 | ||
1046 | /* see if we have a default encoder TODO */ | |
1047 | ||
1048 | /* then check use digitial */ | |
1049 | /* pick the first one */ | |
1050 | if (enc_id) { | |
1051 | obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); | |
1052 | if (!obj) | |
1053 | return NULL; | |
1054 | encoder = obj_to_encoder(obj); | |
1055 | return encoder; | |
1056 | } | |
1057 | return NULL; | |
1058 | } | |
1059 | ||
d50ba256 DA |
1060 | static void radeon_dvi_force(struct drm_connector *connector) |
1061 | { | |
1062 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
1063 | if (connector->force == DRM_FORCE_ON) | |
1064 | radeon_connector->use_digital = false; | |
1065 | if (connector->force == DRM_FORCE_ON_DIGITAL) | |
1066 | radeon_connector->use_digital = true; | |
1067 | } | |
1068 | ||
a3fa6320 AD |
1069 | static int radeon_dvi_mode_valid(struct drm_connector *connector, |
1070 | struct drm_display_mode *mode) | |
1071 | { | |
1b24203e AD |
1072 | struct drm_device *dev = connector->dev; |
1073 | struct radeon_device *rdev = dev->dev_private; | |
a3fa6320 AD |
1074 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
1075 | ||
1076 | /* XXX check mode bandwidth */ | |
1077 | ||
1b24203e AD |
1078 | /* clocks over 135 MHz have heat issues with DVI on RV100 */ |
1079 | if (radeon_connector->use_digital && | |
1080 | (rdev->family == CHIP_RV100) && | |
1081 | (mode->clock > 135000)) | |
1082 | return MODE_CLOCK_HIGH; | |
1083 | ||
a3fa6320 AD |
1084 | if (radeon_connector->use_digital && (mode->clock > 165000)) { |
1085 | if ((radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I) || | |
1086 | (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) || | |
1087 | (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B)) | |
1088 | return MODE_OK; | |
e1e84017 AD |
1089 | else if (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_A) { |
1090 | if (ASIC_IS_DCE3(rdev)) { | |
1091 | /* HDMI 1.3+ supports max clock of 340 Mhz */ | |
1092 | if (mode->clock > 340000) | |
1093 | return MODE_CLOCK_HIGH; | |
1094 | else | |
1095 | return MODE_OK; | |
1096 | } else | |
1097 | return MODE_CLOCK_HIGH; | |
1098 | } else | |
a3fa6320 AD |
1099 | return MODE_CLOCK_HIGH; |
1100 | } | |
b20f9bef AD |
1101 | |
1102 | /* check against the max pixel clock */ | |
1103 | if ((mode->clock / 10) > rdev->clock.max_pixel_clock) | |
1104 | return MODE_CLOCK_HIGH; | |
1105 | ||
a3fa6320 AD |
1106 | return MODE_OK; |
1107 | } | |
1108 | ||
771fe6b9 JG |
1109 | struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs = { |
1110 | .get_modes = radeon_dvi_get_modes, | |
a3fa6320 | 1111 | .mode_valid = radeon_dvi_mode_valid, |
771fe6b9 JG |
1112 | .best_encoder = radeon_dvi_encoder, |
1113 | }; | |
1114 | ||
1115 | struct drm_connector_funcs radeon_dvi_connector_funcs = { | |
1116 | .dpms = drm_helper_connector_dpms, | |
1117 | .detect = radeon_dvi_detect, | |
1118 | .fill_modes = drm_helper_probe_single_connector_modes, | |
1119 | .set_property = radeon_connector_set_property, | |
1120 | .destroy = radeon_connector_destroy, | |
d50ba256 | 1121 | .force = radeon_dvi_force, |
771fe6b9 JG |
1122 | }; |
1123 | ||
ffd09c64 AD |
1124 | static void radeon_dp_connector_destroy(struct drm_connector *connector) |
1125 | { | |
1126 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
1127 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; | |
1128 | ||
ffd09c64 AD |
1129 | if (radeon_connector->edid) |
1130 | kfree(radeon_connector->edid); | |
1131 | if (radeon_dig_connector->dp_i2c_bus) | |
ac1aade6 | 1132 | radeon_i2c_destroy(radeon_dig_connector->dp_i2c_bus); |
ffd09c64 AD |
1133 | kfree(radeon_connector->con_priv); |
1134 | drm_sysfs_connector_remove(connector); | |
1135 | drm_connector_cleanup(connector); | |
1136 | kfree(connector); | |
1137 | } | |
1138 | ||
746c1aa4 DA |
1139 | static int radeon_dp_get_modes(struct drm_connector *connector) |
1140 | { | |
1141 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
8b834852 | 1142 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; |
591a10e1 | 1143 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
746c1aa4 DA |
1144 | int ret; |
1145 | ||
f89931f3 AD |
1146 | if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) || |
1147 | (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) { | |
d291767b AD |
1148 | struct drm_display_mode *mode; |
1149 | ||
8b834852 AD |
1150 | if (!radeon_dig_connector->edp_on) |
1151 | atombios_set_edp_panel_power(connector, | |
1152 | ATOM_TRANSMITTER_ACTION_POWER_ON); | |
d291767b | 1153 | ret = radeon_ddc_get_modes(radeon_connector); |
8b834852 AD |
1154 | if (!radeon_dig_connector->edp_on) |
1155 | atombios_set_edp_panel_power(connector, | |
1156 | ATOM_TRANSMITTER_ACTION_POWER_OFF); | |
d291767b AD |
1157 | |
1158 | if (ret > 0) { | |
d291767b AD |
1159 | if (encoder) { |
1160 | radeon_fixup_lvds_native_mode(encoder, connector); | |
1161 | /* add scaled modes */ | |
1162 | radeon_add_common_modes(encoder, connector); | |
1163 | } | |
1164 | return ret; | |
1165 | } | |
1166 | ||
1167 | encoder = radeon_best_single_encoder(connector); | |
1168 | if (!encoder) | |
1169 | return 0; | |
1170 | ||
1171 | /* we have no EDID modes */ | |
1172 | mode = radeon_fp_native_mode(encoder); | |
1173 | if (mode) { | |
1174 | ret = 1; | |
1175 | drm_mode_probed_add(connector, mode); | |
1176 | /* add the width/height from vbios tables if available */ | |
1177 | connector->display_info.width_mm = mode->width_mm; | |
1178 | connector->display_info.height_mm = mode->height_mm; | |
1179 | /* add scaled modes */ | |
1180 | radeon_add_common_modes(encoder, connector); | |
1181 | } | |
591a10e1 AD |
1182 | } else { |
1183 | /* need to setup ddc on the bridge */ | |
1184 | if (radeon_connector_encoder_is_dp_bridge(connector)) { | |
1185 | if (encoder) | |
1186 | radeon_atom_ext_encoder_setup_ddc(encoder); | |
1187 | } | |
d291767b | 1188 | ret = radeon_ddc_get_modes(radeon_connector); |
591a10e1 | 1189 | } |
8b834852 | 1190 | |
746c1aa4 DA |
1191 | return ret; |
1192 | } | |
1193 | ||
d7fa8bb3 AD |
1194 | bool radeon_connector_encoder_is_dp_bridge(struct drm_connector *connector) |
1195 | { | |
1196 | struct drm_mode_object *obj; | |
1197 | struct drm_encoder *encoder; | |
1198 | struct radeon_encoder *radeon_encoder; | |
1199 | int i; | |
1200 | bool found = false; | |
1201 | ||
1202 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | |
1203 | if (connector->encoder_ids[i] == 0) | |
1204 | break; | |
1205 | ||
1206 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); | |
1207 | if (!obj) | |
1208 | continue; | |
1209 | ||
1210 | encoder = obj_to_encoder(obj); | |
1211 | radeon_encoder = to_radeon_encoder(encoder); | |
1212 | ||
1213 | switch (radeon_encoder->encoder_id) { | |
1214 | case ENCODER_OBJECT_ID_TRAVIS: | |
1215 | case ENCODER_OBJECT_ID_NUTMEG: | |
1216 | found = true; | |
1217 | break; | |
1218 | default: | |
1219 | break; | |
1220 | } | |
1221 | } | |
1222 | ||
1223 | return found; | |
1224 | } | |
1225 | ||
1226 | bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector) | |
1227 | { | |
1228 | struct drm_mode_object *obj; | |
1229 | struct drm_encoder *encoder; | |
1230 | struct radeon_encoder *radeon_encoder; | |
1231 | int i; | |
1232 | bool found = false; | |
1233 | ||
1234 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | |
1235 | if (connector->encoder_ids[i] == 0) | |
1236 | break; | |
1237 | ||
1238 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); | |
1239 | if (!obj) | |
1240 | continue; | |
1241 | ||
1242 | encoder = obj_to_encoder(obj); | |
1243 | radeon_encoder = to_radeon_encoder(encoder); | |
1244 | if (radeon_encoder->caps & ATOM_ENCODER_CAP_RECORD_HBR2) | |
1245 | found = true; | |
1246 | } | |
1247 | ||
1248 | return found; | |
1249 | } | |
1250 | ||
1251 | bool radeon_connector_is_dp12_capable(struct drm_connector *connector) | |
1252 | { | |
1253 | struct drm_device *dev = connector->dev; | |
1254 | struct radeon_device *rdev = dev->dev_private; | |
1255 | ||
1256 | if (ASIC_IS_DCE5(rdev) && | |
1257 | (rdev->clock.dp_extclk >= 53900) && | |
1258 | radeon_connector_encoder_is_hbr2(connector)) { | |
1259 | return true; | |
1260 | } | |
1261 | ||
1262 | return false; | |
1263 | } | |
1264 | ||
7b334fcb | 1265 | static enum drm_connector_status |
930a9e28 | 1266 | radeon_dp_detect(struct drm_connector *connector, bool force) |
746c1aa4 | 1267 | { |
f8d0edde AD |
1268 | struct drm_device *dev = connector->dev; |
1269 | struct radeon_device *rdev = dev->dev_private; | |
746c1aa4 | 1270 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
746c1aa4 | 1271 | enum drm_connector_status ret = connector_status_disconnected; |
4143e919 | 1272 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; |
591a10e1 | 1273 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
746c1aa4 DA |
1274 | |
1275 | if (radeon_connector->edid) { | |
1276 | kfree(radeon_connector->edid); | |
1277 | radeon_connector->edid = NULL; | |
1278 | } | |
1279 | ||
f89931f3 AD |
1280 | if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) || |
1281 | (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) { | |
d291767b AD |
1282 | if (encoder) { |
1283 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | |
1284 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; | |
1285 | ||
1286 | /* check if panel is valid */ | |
1287 | if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240) | |
1288 | ret = connector_status_connected; | |
1289 | } | |
6f50eae7 AD |
1290 | /* eDP is always DP */ |
1291 | radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT; | |
8b834852 AD |
1292 | if (!radeon_dig_connector->edp_on) |
1293 | atombios_set_edp_panel_power(connector, | |
1294 | ATOM_TRANSMITTER_ACTION_POWER_ON); | |
6f50eae7 | 1295 | if (radeon_dp_getdpcd(radeon_connector)) |
9fa05c98 | 1296 | ret = connector_status_connected; |
8b834852 AD |
1297 | if (!radeon_dig_connector->edp_on) |
1298 | atombios_set_edp_panel_power(connector, | |
1299 | ATOM_TRANSMITTER_ACTION_POWER_OFF); | |
b06947b5 AD |
1300 | } else if (radeon_connector_encoder_is_dp_bridge(connector)) { |
1301 | /* DP bridges are always DP */ | |
1302 | radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT; | |
1303 | /* get the DPCD from the bridge */ | |
1304 | radeon_dp_getdpcd(radeon_connector); | |
1305 | ||
1306 | if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) | |
1307 | ret = connector_status_connected; | |
1308 | else { | |
1309 | /* need to setup ddc on the bridge */ | |
591a10e1 AD |
1310 | if (encoder) |
1311 | radeon_atom_ext_encoder_setup_ddc(encoder); | |
b06947b5 AD |
1312 | if (radeon_ddc_probe(radeon_connector, |
1313 | radeon_connector->requires_extended_probe)) | |
1314 | ret = connector_status_connected; | |
1315 | } | |
1316 | ||
1317 | if ((ret == connector_status_disconnected) && | |
1318 | radeon_connector->dac_load_detect) { | |
1319 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); | |
1320 | struct drm_encoder_helper_funcs *encoder_funcs; | |
1321 | if (encoder) { | |
1322 | encoder_funcs = encoder->helper_private; | |
1323 | ret = encoder_funcs->detect(encoder, connector); | |
1324 | } | |
591a10e1 | 1325 | } |
b06947b5 | 1326 | } else { |
6f50eae7 | 1327 | radeon_dig_connector->dp_sink_type = radeon_dp_getsinktype(radeon_connector); |
f8d0edde AD |
1328 | if (radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { |
1329 | ret = connector_status_connected; | |
1330 | if (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) | |
1331 | radeon_dp_getdpcd(radeon_connector); | |
6f50eae7 | 1332 | } else { |
f8d0edde AD |
1333 | if (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) { |
1334 | if (radeon_dp_getdpcd(radeon_connector)) | |
1335 | ret = connector_status_connected; | |
1336 | } else { | |
e384fab8 TR |
1337 | if (radeon_ddc_probe(radeon_connector, |
1338 | radeon_connector->requires_extended_probe)) | |
f8d0edde AD |
1339 | ret = connector_status_connected; |
1340 | } | |
4143e919 | 1341 | } |
746c1aa4 | 1342 | } |
4143e919 | 1343 | |
30f44372 | 1344 | radeon_connector_update_scratch_regs(connector, ret); |
746c1aa4 DA |
1345 | return ret; |
1346 | } | |
1347 | ||
5801ead6 AD |
1348 | static int radeon_dp_mode_valid(struct drm_connector *connector, |
1349 | struct drm_display_mode *mode) | |
1350 | { | |
1351 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
1352 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; | |
1353 | ||
1354 | /* XXX check mode bandwidth */ | |
1355 | ||
f89931f3 AD |
1356 | if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) || |
1357 | (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)) { | |
d291767b AD |
1358 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
1359 | ||
1360 | if ((mode->hdisplay < 320) || (mode->vdisplay < 240)) | |
1361 | return MODE_PANEL; | |
1362 | ||
1363 | if (encoder) { | |
1364 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | |
1365 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; | |
1366 | ||
f89931f3 | 1367 | /* AVIVO hardware supports downscaling modes larger than the panel |
d291767b AD |
1368 | * to the panel size, but I'm not sure this is desirable. |
1369 | */ | |
1370 | if ((mode->hdisplay > native_mode->hdisplay) || | |
1371 | (mode->vdisplay > native_mode->vdisplay)) | |
1372 | return MODE_PANEL; | |
1373 | ||
1374 | /* if scaling is disabled, block non-native modes */ | |
1375 | if (radeon_encoder->rmx_type == RMX_OFF) { | |
1376 | if ((mode->hdisplay != native_mode->hdisplay) || | |
1377 | (mode->vdisplay != native_mode->vdisplay)) | |
1378 | return MODE_PANEL; | |
1379 | } | |
1380 | } | |
5801ead6 | 1381 | return MODE_OK; |
d291767b AD |
1382 | } else { |
1383 | if ((radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || | |
1384 | (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) | |
1385 | return radeon_dp_mode_valid_helper(connector, mode); | |
1386 | else | |
1387 | return MODE_OK; | |
1388 | } | |
5801ead6 AD |
1389 | } |
1390 | ||
746c1aa4 DA |
1391 | struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = { |
1392 | .get_modes = radeon_dp_get_modes, | |
5801ead6 | 1393 | .mode_valid = radeon_dp_mode_valid, |
746c1aa4 DA |
1394 | .best_encoder = radeon_dvi_encoder, |
1395 | }; | |
1396 | ||
1397 | struct drm_connector_funcs radeon_dp_connector_funcs = { | |
1398 | .dpms = drm_helper_connector_dpms, | |
1399 | .detect = radeon_dp_detect, | |
1400 | .fill_modes = drm_helper_probe_single_connector_modes, | |
1401 | .set_property = radeon_connector_set_property, | |
ffd09c64 | 1402 | .destroy = radeon_dp_connector_destroy, |
746c1aa4 DA |
1403 | .force = radeon_dvi_force, |
1404 | }; | |
1405 | ||
771fe6b9 JG |
1406 | void |
1407 | radeon_add_atom_connector(struct drm_device *dev, | |
1408 | uint32_t connector_id, | |
1409 | uint32_t supported_device, | |
1410 | int connector_type, | |
1411 | struct radeon_i2c_bus_rec *i2c_bus, | |
b75fad06 | 1412 | uint32_t igp_lane_info, |
eed45b30 | 1413 | uint16_t connector_object_id, |
26b5bc98 AD |
1414 | struct radeon_hpd *hpd, |
1415 | struct radeon_router *router) | |
771fe6b9 | 1416 | { |
445282db | 1417 | struct radeon_device *rdev = dev->dev_private; |
771fe6b9 JG |
1418 | struct drm_connector *connector; |
1419 | struct radeon_connector *radeon_connector; | |
1420 | struct radeon_connector_atom_dig *radeon_dig_connector; | |
eac4dff6 AD |
1421 | struct drm_encoder *encoder; |
1422 | struct radeon_encoder *radeon_encoder; | |
771fe6b9 | 1423 | uint32_t subpixel_order = SubPixelNone; |
0294cf4f | 1424 | bool shared_ddc = false; |
eac4dff6 | 1425 | bool is_dp_bridge = false; |
771fe6b9 | 1426 | |
4ce001ab | 1427 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
771fe6b9 JG |
1428 | return; |
1429 | ||
cf4c12f9 AD |
1430 | /* if the user selected tv=0 don't try and add the connector */ |
1431 | if (((connector_type == DRM_MODE_CONNECTOR_SVIDEO) || | |
1432 | (connector_type == DRM_MODE_CONNECTOR_Composite) || | |
1433 | (connector_type == DRM_MODE_CONNECTOR_9PinDIN)) && | |
1434 | (radeon_tv == 0)) | |
1435 | return; | |
1436 | ||
771fe6b9 JG |
1437 | /* see if we already added it */ |
1438 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | |
1439 | radeon_connector = to_radeon_connector(connector); | |
1440 | if (radeon_connector->connector_id == connector_id) { | |
1441 | radeon_connector->devices |= supported_device; | |
1442 | return; | |
1443 | } | |
0294cf4f | 1444 | if (radeon_connector->ddc_bus && i2c_bus->valid) { |
d3932d6c | 1445 | if (radeon_connector->ddc_bus->rec.i2c_id == i2c_bus->i2c_id) { |
0294cf4f AD |
1446 | radeon_connector->shared_ddc = true; |
1447 | shared_ddc = true; | |
1448 | } | |
fb939dfc | 1449 | if (radeon_connector->router_bus && router->ddc_valid && |
26b5bc98 AD |
1450 | (radeon_connector->router.router_id == router->router_id)) { |
1451 | radeon_connector->shared_ddc = false; | |
1452 | shared_ddc = false; | |
1453 | } | |
0294cf4f | 1454 | } |
771fe6b9 JG |
1455 | } |
1456 | ||
eac4dff6 AD |
1457 | /* check if it's a dp bridge */ |
1458 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { | |
1459 | radeon_encoder = to_radeon_encoder(encoder); | |
1460 | if (radeon_encoder->devices & supported_device) { | |
1461 | switch (radeon_encoder->encoder_id) { | |
1462 | case ENCODER_OBJECT_ID_TRAVIS: | |
1463 | case ENCODER_OBJECT_ID_NUTMEG: | |
1464 | is_dp_bridge = true; | |
1465 | break; | |
1466 | default: | |
1467 | break; | |
1468 | } | |
1469 | } | |
1470 | } | |
1471 | ||
771fe6b9 JG |
1472 | radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); |
1473 | if (!radeon_connector) | |
1474 | return; | |
1475 | ||
1476 | connector = &radeon_connector->base; | |
1477 | ||
1478 | radeon_connector->connector_id = connector_id; | |
1479 | radeon_connector->devices = supported_device; | |
0294cf4f | 1480 | radeon_connector->shared_ddc = shared_ddc; |
b75fad06 | 1481 | radeon_connector->connector_object_id = connector_object_id; |
eed45b30 | 1482 | radeon_connector->hpd = *hpd; |
e384fab8 TR |
1483 | radeon_connector->requires_extended_probe = |
1484 | radeon_connector_needs_extended_probe(rdev, supported_device, | |
1485 | connector_type); | |
26b5bc98 | 1486 | radeon_connector->router = *router; |
fb939dfc | 1487 | if (router->ddc_valid || router->cd_valid) { |
26b5bc98 AD |
1488 | radeon_connector->router_bus = radeon_i2c_lookup(rdev, &router->i2c_info); |
1489 | if (!radeon_connector->router_bus) | |
a70882aa | 1490 | DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n"); |
26b5bc98 | 1491 | } |
eac4dff6 AD |
1492 | |
1493 | if (is_dp_bridge) { | |
771fe6b9 JG |
1494 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
1495 | if (!radeon_dig_connector) | |
1496 | goto failed; | |
771fe6b9 JG |
1497 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
1498 | radeon_connector->con_priv = radeon_dig_connector; | |
eac4dff6 AD |
1499 | drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); |
1500 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); | |
771fe6b9 | 1501 | if (i2c_bus->valid) { |
eac4dff6 AD |
1502 | /* add DP i2c bus */ |
1503 | if (connector_type == DRM_MODE_CONNECTOR_eDP) | |
1504 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch"); | |
1505 | else | |
1506 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch"); | |
1507 | if (!radeon_dig_connector->dp_i2c_bus) | |
1508 | DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n"); | |
f376b94f | 1509 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
771fe6b9 | 1510 | if (!radeon_connector->ddc_bus) |
eac4dff6 | 1511 | DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
771fe6b9 | 1512 | } |
eac4dff6 AD |
1513 | switch (connector_type) { |
1514 | case DRM_MODE_CONNECTOR_VGA: | |
1515 | case DRM_MODE_CONNECTOR_DVIA: | |
1516 | default: | |
1517 | connector->interlace_allowed = true; | |
1518 | connector->doublescan_allowed = true; | |
d629a3ce AD |
1519 | radeon_connector->dac_load_detect = true; |
1520 | drm_connector_attach_property(&radeon_connector->base, | |
1521 | rdev->mode_info.load_detect_property, | |
1522 | 1); | |
eac4dff6 AD |
1523 | break; |
1524 | case DRM_MODE_CONNECTOR_DVII: | |
1525 | case DRM_MODE_CONNECTOR_DVID: | |
1526 | case DRM_MODE_CONNECTOR_HDMIA: | |
1527 | case DRM_MODE_CONNECTOR_HDMIB: | |
1528 | case DRM_MODE_CONNECTOR_DisplayPort: | |
430f70d5 AD |
1529 | drm_connector_attach_property(&radeon_connector->base, |
1530 | rdev->mode_info.underscan_property, | |
56bec7c0 | 1531 | UNDERSCAN_OFF); |
5bccf5e3 MG |
1532 | drm_connector_attach_property(&radeon_connector->base, |
1533 | rdev->mode_info.underscan_hborder_property, | |
1534 | 0); | |
1535 | drm_connector_attach_property(&radeon_connector->base, | |
1536 | rdev->mode_info.underscan_vborder_property, | |
1537 | 0); | |
eac4dff6 AD |
1538 | subpixel_order = SubPixelHorizontalRGB; |
1539 | connector->interlace_allowed = true; | |
1540 | if (connector_type == DRM_MODE_CONNECTOR_HDMIB) | |
1541 | connector->doublescan_allowed = true; | |
1542 | else | |
1543 | connector->doublescan_allowed = false; | |
d629a3ce AD |
1544 | if (connector_type == DRM_MODE_CONNECTOR_DVII) { |
1545 | radeon_connector->dac_load_detect = true; | |
1546 | drm_connector_attach_property(&radeon_connector->base, | |
1547 | rdev->mode_info.load_detect_property, | |
1548 | 1); | |
1549 | } | |
eac4dff6 AD |
1550 | break; |
1551 | case DRM_MODE_CONNECTOR_LVDS: | |
1552 | case DRM_MODE_CONNECTOR_eDP: | |
1553 | drm_connector_attach_property(&radeon_connector->base, | |
1554 | dev->mode_config.scaling_mode_property, | |
1555 | DRM_MODE_SCALE_FULLSCREEN); | |
1556 | subpixel_order = SubPixelHorizontalRGB; | |
1557 | connector->interlace_allowed = false; | |
1558 | connector->doublescan_allowed = false; | |
1559 | break; | |
5bccf5e3 | 1560 | } |
eac4dff6 AD |
1561 | } else { |
1562 | switch (connector_type) { | |
1563 | case DRM_MODE_CONNECTOR_VGA: | |
1564 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); | |
1565 | drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); | |
1566 | if (i2c_bus->valid) { | |
1567 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); | |
1568 | if (!radeon_connector->ddc_bus) | |
1569 | DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); | |
1570 | } | |
390d0bbe AD |
1571 | radeon_connector->dac_load_detect = true; |
1572 | drm_connector_attach_property(&radeon_connector->base, | |
1573 | rdev->mode_info.load_detect_property, | |
1574 | 1); | |
eac4dff6 AD |
1575 | /* no HPD on analog connectors */ |
1576 | radeon_connector->hpd.hpd = RADEON_HPD_NONE; | |
1577 | connector->polled = DRM_CONNECTOR_POLL_CONNECT; | |
1578 | connector->interlace_allowed = true; | |
c49948f4 | 1579 | connector->doublescan_allowed = true; |
eac4dff6 AD |
1580 | break; |
1581 | case DRM_MODE_CONNECTOR_DVIA: | |
1582 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); | |
1583 | drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); | |
1584 | if (i2c_bus->valid) { | |
1585 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); | |
1586 | if (!radeon_connector->ddc_bus) | |
1587 | DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); | |
1588 | } | |
1589 | radeon_connector->dac_load_detect = true; | |
430f70d5 | 1590 | drm_connector_attach_property(&radeon_connector->base, |
eac4dff6 AD |
1591 | rdev->mode_info.load_detect_property, |
1592 | 1); | |
1593 | /* no HPD on analog connectors */ | |
1594 | radeon_connector->hpd.hpd = RADEON_HPD_NONE; | |
1595 | connector->interlace_allowed = true; | |
1596 | connector->doublescan_allowed = true; | |
1597 | break; | |
1598 | case DRM_MODE_CONNECTOR_DVII: | |
1599 | case DRM_MODE_CONNECTOR_DVID: | |
1600 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); | |
1601 | if (!radeon_dig_connector) | |
1602 | goto failed; | |
1603 | radeon_dig_connector->igp_lane_info = igp_lane_info; | |
1604 | radeon_connector->con_priv = radeon_dig_connector; | |
1605 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); | |
1606 | drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); | |
1607 | if (i2c_bus->valid) { | |
1608 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); | |
1609 | if (!radeon_connector->ddc_bus) | |
1610 | DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); | |
1611 | } | |
1612 | subpixel_order = SubPixelHorizontalRGB; | |
5bccf5e3 | 1613 | drm_connector_attach_property(&radeon_connector->base, |
eac4dff6 AD |
1614 | rdev->mode_info.coherent_mode_property, |
1615 | 1); | |
1616 | if (ASIC_IS_AVIVO(rdev)) { | |
1617 | drm_connector_attach_property(&radeon_connector->base, | |
1618 | rdev->mode_info.underscan_property, | |
1619 | UNDERSCAN_OFF); | |
1620 | drm_connector_attach_property(&radeon_connector->base, | |
1621 | rdev->mode_info.underscan_hborder_property, | |
1622 | 0); | |
1623 | drm_connector_attach_property(&radeon_connector->base, | |
1624 | rdev->mode_info.underscan_vborder_property, | |
1625 | 0); | |
1626 | } | |
1627 | if (connector_type == DRM_MODE_CONNECTOR_DVII) { | |
1628 | radeon_connector->dac_load_detect = true; | |
1629 | drm_connector_attach_property(&radeon_connector->base, | |
1630 | rdev->mode_info.load_detect_property, | |
1631 | 1); | |
1632 | } | |
1633 | connector->interlace_allowed = true; | |
1634 | if (connector_type == DRM_MODE_CONNECTOR_DVII) | |
1635 | connector->doublescan_allowed = true; | |
1636 | else | |
1637 | connector->doublescan_allowed = false; | |
1638 | break; | |
1639 | case DRM_MODE_CONNECTOR_HDMIA: | |
1640 | case DRM_MODE_CONNECTOR_HDMIB: | |
1641 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); | |
1642 | if (!radeon_dig_connector) | |
1643 | goto failed; | |
1644 | radeon_dig_connector->igp_lane_info = igp_lane_info; | |
1645 | radeon_connector->con_priv = radeon_dig_connector; | |
1646 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); | |
1647 | drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); | |
1648 | if (i2c_bus->valid) { | |
1649 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); | |
1650 | if (!radeon_connector->ddc_bus) | |
1651 | DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); | |
1652 | } | |
5bccf5e3 | 1653 | drm_connector_attach_property(&radeon_connector->base, |
eac4dff6 AD |
1654 | rdev->mode_info.coherent_mode_property, |
1655 | 1); | |
1656 | if (ASIC_IS_AVIVO(rdev)) { | |
1657 | drm_connector_attach_property(&radeon_connector->base, | |
1658 | rdev->mode_info.underscan_property, | |
1659 | UNDERSCAN_OFF); | |
1660 | drm_connector_attach_property(&radeon_connector->base, | |
1661 | rdev->mode_info.underscan_hborder_property, | |
1662 | 0); | |
1663 | drm_connector_attach_property(&radeon_connector->base, | |
1664 | rdev->mode_info.underscan_vborder_property, | |
1665 | 0); | |
1666 | } | |
1667 | subpixel_order = SubPixelHorizontalRGB; | |
1668 | connector->interlace_allowed = true; | |
1669 | if (connector_type == DRM_MODE_CONNECTOR_HDMIB) | |
1670 | connector->doublescan_allowed = true; | |
1671 | else | |
1672 | connector->doublescan_allowed = false; | |
1673 | break; | |
1674 | case DRM_MODE_CONNECTOR_DisplayPort: | |
1675 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); | |
1676 | if (!radeon_dig_connector) | |
1677 | goto failed; | |
1678 | radeon_dig_connector->igp_lane_info = igp_lane_info; | |
1679 | radeon_connector->con_priv = radeon_dig_connector; | |
1680 | drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); | |
1681 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); | |
1682 | if (i2c_bus->valid) { | |
1683 | /* add DP i2c bus */ | |
1684 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch"); | |
1685 | if (!radeon_dig_connector->dp_i2c_bus) | |
1686 | DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n"); | |
1687 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); | |
1688 | if (!radeon_connector->ddc_bus) | |
1689 | DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); | |
1690 | } | |
1691 | subpixel_order = SubPixelHorizontalRGB; | |
1692 | drm_connector_attach_property(&radeon_connector->base, | |
1693 | rdev->mode_info.coherent_mode_property, | |
1694 | 1); | |
1695 | if (ASIC_IS_AVIVO(rdev)) { | |
1696 | drm_connector_attach_property(&radeon_connector->base, | |
1697 | rdev->mode_info.underscan_property, | |
1698 | UNDERSCAN_OFF); | |
1699 | drm_connector_attach_property(&radeon_connector->base, | |
1700 | rdev->mode_info.underscan_hborder_property, | |
1701 | 0); | |
1702 | drm_connector_attach_property(&radeon_connector->base, | |
1703 | rdev->mode_info.underscan_vborder_property, | |
1704 | 0); | |
1705 | } | |
1706 | connector->interlace_allowed = true; | |
1707 | /* in theory with a DP to VGA converter... */ | |
c49948f4 | 1708 | connector->doublescan_allowed = false; |
eac4dff6 AD |
1709 | break; |
1710 | case DRM_MODE_CONNECTOR_eDP: | |
1711 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); | |
1712 | if (!radeon_dig_connector) | |
1713 | goto failed; | |
1714 | radeon_dig_connector->igp_lane_info = igp_lane_info; | |
1715 | radeon_connector->con_priv = radeon_dig_connector; | |
1716 | drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); | |
1717 | drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); | |
1718 | if (i2c_bus->valid) { | |
1719 | /* add DP i2c bus */ | |
1720 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch"); | |
1721 | if (!radeon_dig_connector->dp_i2c_bus) | |
1722 | DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n"); | |
1723 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); | |
1724 | if (!radeon_connector->ddc_bus) | |
1725 | DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); | |
1726 | } | |
430f70d5 | 1727 | drm_connector_attach_property(&radeon_connector->base, |
eac4dff6 AD |
1728 | dev->mode_config.scaling_mode_property, |
1729 | DRM_MODE_SCALE_FULLSCREEN); | |
1730 | subpixel_order = SubPixelHorizontalRGB; | |
1731 | connector->interlace_allowed = false; | |
1732 | connector->doublescan_allowed = false; | |
1733 | break; | |
1734 | case DRM_MODE_CONNECTOR_SVIDEO: | |
1735 | case DRM_MODE_CONNECTOR_Composite: | |
1736 | case DRM_MODE_CONNECTOR_9PinDIN: | |
1737 | drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); | |
1738 | drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); | |
1739 | radeon_connector->dac_load_detect = true; | |
5bccf5e3 | 1740 | drm_connector_attach_property(&radeon_connector->base, |
eac4dff6 AD |
1741 | rdev->mode_info.load_detect_property, |
1742 | 1); | |
5bccf5e3 | 1743 | drm_connector_attach_property(&radeon_connector->base, |
eac4dff6 AD |
1744 | rdev->mode_info.tv_std_property, |
1745 | radeon_atombios_get_tv_info(rdev)); | |
1746 | /* no HPD on analog connectors */ | |
1747 | radeon_connector->hpd.hpd = RADEON_HPD_NONE; | |
1748 | connector->interlace_allowed = false; | |
1749 | connector->doublescan_allowed = false; | |
1750 | break; | |
1751 | case DRM_MODE_CONNECTOR_LVDS: | |
1752 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); | |
1753 | if (!radeon_dig_connector) | |
1754 | goto failed; | |
1755 | radeon_dig_connector->igp_lane_info = igp_lane_info; | |
1756 | radeon_connector->con_priv = radeon_dig_connector; | |
1757 | drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); | |
1758 | drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); | |
1759 | if (i2c_bus->valid) { | |
1760 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); | |
1761 | if (!radeon_connector->ddc_bus) | |
1762 | DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); | |
1763 | } | |
1764 | drm_connector_attach_property(&radeon_connector->base, | |
1765 | dev->mode_config.scaling_mode_property, | |
1766 | DRM_MODE_SCALE_FULLSCREEN); | |
1767 | subpixel_order = SubPixelHorizontalRGB; | |
1768 | connector->interlace_allowed = false; | |
1769 | connector->doublescan_allowed = false; | |
1770 | break; | |
771fe6b9 | 1771 | } |
771fe6b9 JG |
1772 | } |
1773 | ||
2581afcc | 1774 | if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) { |
eb1f8e4f DA |
1775 | if (i2c_bus->valid) |
1776 | connector->polled = DRM_CONNECTOR_POLL_CONNECT; | |
1777 | } else | |
1778 | connector->polled = DRM_CONNECTOR_POLL_HPD; | |
1779 | ||
771fe6b9 JG |
1780 | connector->display_info.subpixel_order = subpixel_order; |
1781 | drm_sysfs_connector_add(connector); | |
1782 | return; | |
1783 | ||
1784 | failed: | |
771fe6b9 JG |
1785 | drm_connector_cleanup(connector); |
1786 | kfree(connector); | |
1787 | } | |
1788 | ||
1789 | void | |
1790 | radeon_add_legacy_connector(struct drm_device *dev, | |
1791 | uint32_t connector_id, | |
1792 | uint32_t supported_device, | |
1793 | int connector_type, | |
b75fad06 | 1794 | struct radeon_i2c_bus_rec *i2c_bus, |
eed45b30 AD |
1795 | uint16_t connector_object_id, |
1796 | struct radeon_hpd *hpd) | |
771fe6b9 | 1797 | { |
445282db | 1798 | struct radeon_device *rdev = dev->dev_private; |
771fe6b9 JG |
1799 | struct drm_connector *connector; |
1800 | struct radeon_connector *radeon_connector; | |
1801 | uint32_t subpixel_order = SubPixelNone; | |
1802 | ||
4ce001ab | 1803 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
771fe6b9 JG |
1804 | return; |
1805 | ||
cf4c12f9 AD |
1806 | /* if the user selected tv=0 don't try and add the connector */ |
1807 | if (((connector_type == DRM_MODE_CONNECTOR_SVIDEO) || | |
1808 | (connector_type == DRM_MODE_CONNECTOR_Composite) || | |
1809 | (connector_type == DRM_MODE_CONNECTOR_9PinDIN)) && | |
1810 | (radeon_tv == 0)) | |
1811 | return; | |
1812 | ||
771fe6b9 JG |
1813 | /* see if we already added it */ |
1814 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | |
1815 | radeon_connector = to_radeon_connector(connector); | |
1816 | if (radeon_connector->connector_id == connector_id) { | |
1817 | radeon_connector->devices |= supported_device; | |
1818 | return; | |
1819 | } | |
1820 | } | |
1821 | ||
1822 | radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); | |
1823 | if (!radeon_connector) | |
1824 | return; | |
1825 | ||
1826 | connector = &radeon_connector->base; | |
1827 | ||
1828 | radeon_connector->connector_id = connector_id; | |
1829 | radeon_connector->devices = supported_device; | |
b75fad06 | 1830 | radeon_connector->connector_object_id = connector_object_id; |
eed45b30 | 1831 | radeon_connector->hpd = *hpd; |
e384fab8 TR |
1832 | radeon_connector->requires_extended_probe = |
1833 | radeon_connector_needs_extended_probe(rdev, supported_device, | |
1834 | connector_type); | |
771fe6b9 JG |
1835 | switch (connector_type) { |
1836 | case DRM_MODE_CONNECTOR_VGA: | |
1837 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); | |
0b4c0f3f | 1838 | drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
771fe6b9 | 1839 | if (i2c_bus->valid) { |
f376b94f | 1840 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
771fe6b9 | 1841 | if (!radeon_connector->ddc_bus) |
a70882aa | 1842 | DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
771fe6b9 | 1843 | } |
35e4b7af | 1844 | radeon_connector->dac_load_detect = true; |
445282db DA |
1845 | drm_connector_attach_property(&radeon_connector->base, |
1846 | rdev->mode_info.load_detect_property, | |
1847 | 1); | |
2581afcc AD |
1848 | /* no HPD on analog connectors */ |
1849 | radeon_connector->hpd.hpd = RADEON_HPD_NONE; | |
eb1f8e4f | 1850 | connector->polled = DRM_CONNECTOR_POLL_CONNECT; |
c49948f4 AD |
1851 | connector->interlace_allowed = true; |
1852 | connector->doublescan_allowed = true; | |
771fe6b9 JG |
1853 | break; |
1854 | case DRM_MODE_CONNECTOR_DVIA: | |
1855 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); | |
0b4c0f3f | 1856 | drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
771fe6b9 | 1857 | if (i2c_bus->valid) { |
f376b94f | 1858 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
771fe6b9 | 1859 | if (!radeon_connector->ddc_bus) |
a70882aa | 1860 | DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
771fe6b9 | 1861 | } |
35e4b7af | 1862 | radeon_connector->dac_load_detect = true; |
445282db DA |
1863 | drm_connector_attach_property(&radeon_connector->base, |
1864 | rdev->mode_info.load_detect_property, | |
1865 | 1); | |
2581afcc AD |
1866 | /* no HPD on analog connectors */ |
1867 | radeon_connector->hpd.hpd = RADEON_HPD_NONE; | |
c49948f4 AD |
1868 | connector->interlace_allowed = true; |
1869 | connector->doublescan_allowed = true; | |
771fe6b9 JG |
1870 | break; |
1871 | case DRM_MODE_CONNECTOR_DVII: | |
1872 | case DRM_MODE_CONNECTOR_DVID: | |
1873 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); | |
0b4c0f3f | 1874 | drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); |
771fe6b9 | 1875 | if (i2c_bus->valid) { |
f376b94f | 1876 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
771fe6b9 | 1877 | if (!radeon_connector->ddc_bus) |
a70882aa | 1878 | DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
68b3adb4 AD |
1879 | } |
1880 | if (connector_type == DRM_MODE_CONNECTOR_DVII) { | |
35e4b7af | 1881 | radeon_connector->dac_load_detect = true; |
445282db DA |
1882 | drm_connector_attach_property(&radeon_connector->base, |
1883 | rdev->mode_info.load_detect_property, | |
1884 | 1); | |
771fe6b9 JG |
1885 | } |
1886 | subpixel_order = SubPixelHorizontalRGB; | |
c49948f4 AD |
1887 | connector->interlace_allowed = true; |
1888 | if (connector_type == DRM_MODE_CONNECTOR_DVII) | |
1889 | connector->doublescan_allowed = true; | |
1890 | else | |
1891 | connector->doublescan_allowed = false; | |
771fe6b9 JG |
1892 | break; |
1893 | case DRM_MODE_CONNECTOR_SVIDEO: | |
1894 | case DRM_MODE_CONNECTOR_Composite: | |
1895 | case DRM_MODE_CONNECTOR_9PinDIN: | |
cf4c12f9 AD |
1896 | drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); |
1897 | drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); | |
1898 | radeon_connector->dac_load_detect = true; | |
1899 | /* RS400,RC410,RS480 chipset seems to report a lot | |
1900 | * of false positive on load detect, we haven't yet | |
1901 | * found a way to make load detect reliable on those | |
1902 | * chipset, thus just disable it for TV. | |
1903 | */ | |
1904 | if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) | |
1905 | radeon_connector->dac_load_detect = false; | |
1906 | drm_connector_attach_property(&radeon_connector->base, | |
1907 | rdev->mode_info.load_detect_property, | |
1908 | radeon_connector->dac_load_detect); | |
1909 | drm_connector_attach_property(&radeon_connector->base, | |
1910 | rdev->mode_info.tv_std_property, | |
1911 | radeon_combios_get_tv_info(rdev)); | |
1912 | /* no HPD on analog connectors */ | |
1913 | radeon_connector->hpd.hpd = RADEON_HPD_NONE; | |
c49948f4 AD |
1914 | connector->interlace_allowed = false; |
1915 | connector->doublescan_allowed = false; | |
771fe6b9 JG |
1916 | break; |
1917 | case DRM_MODE_CONNECTOR_LVDS: | |
1918 | drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); | |
0b4c0f3f | 1919 | drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); |
771fe6b9 | 1920 | if (i2c_bus->valid) { |
f376b94f | 1921 | radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); |
771fe6b9 | 1922 | if (!radeon_connector->ddc_bus) |
a70882aa | 1923 | DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n"); |
771fe6b9 | 1924 | } |
445282db DA |
1925 | drm_connector_attach_property(&radeon_connector->base, |
1926 | dev->mode_config.scaling_mode_property, | |
1927 | DRM_MODE_SCALE_FULLSCREEN); | |
771fe6b9 | 1928 | subpixel_order = SubPixelHorizontalRGB; |
c49948f4 AD |
1929 | connector->interlace_allowed = false; |
1930 | connector->doublescan_allowed = false; | |
771fe6b9 JG |
1931 | break; |
1932 | } | |
1933 | ||
2581afcc | 1934 | if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) { |
eb1f8e4f DA |
1935 | if (i2c_bus->valid) |
1936 | connector->polled = DRM_CONNECTOR_POLL_CONNECT; | |
1937 | } else | |
1938 | connector->polled = DRM_CONNECTOR_POLL_HPD; | |
771fe6b9 JG |
1939 | connector->display_info.subpixel_order = subpixel_order; |
1940 | drm_sysfs_connector_add(connector); | |
63ec0119 MD |
1941 | if (connector_type == DRM_MODE_CONNECTOR_LVDS) { |
1942 | struct drm_encoder *drm_encoder; | |
1943 | ||
1944 | list_for_each_entry(drm_encoder, &dev->mode_config.encoder_list, head) { | |
1945 | struct radeon_encoder *radeon_encoder; | |
1946 | ||
1947 | radeon_encoder = to_radeon_encoder(drm_encoder); | |
1948 | if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_LVDS) | |
1949 | radeon_legacy_backlight_init(radeon_encoder, connector); | |
1950 | } | |
1951 | } | |
771fe6b9 | 1952 | } |