]>
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 | ||
445282db DA |
43 | static void radeon_property_change_mode(struct drm_encoder *encoder) |
44 | { | |
45 | struct drm_crtc *crtc = encoder->crtc; | |
46 | ||
47 | if (crtc && crtc->enabled) { | |
48 | drm_crtc_helper_set_mode(crtc, &crtc->mode, | |
49 | crtc->x, crtc->y, crtc->fb); | |
50 | } | |
51 | } | |
771fe6b9 JG |
52 | static void |
53 | radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_connector_status status) | |
54 | { | |
55 | struct drm_device *dev = connector->dev; | |
56 | struct radeon_device *rdev = dev->dev_private; | |
57 | struct drm_encoder *best_encoder = NULL; | |
58 | struct drm_encoder *encoder = NULL; | |
59 | struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; | |
60 | struct drm_mode_object *obj; | |
61 | bool connected; | |
62 | int i; | |
63 | ||
64 | best_encoder = connector_funcs->best_encoder(connector); | |
65 | ||
66 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | |
67 | if (connector->encoder_ids[i] == 0) | |
68 | break; | |
69 | ||
70 | obj = drm_mode_object_find(connector->dev, | |
71 | connector->encoder_ids[i], | |
72 | DRM_MODE_OBJECT_ENCODER); | |
73 | if (!obj) | |
74 | continue; | |
75 | ||
76 | encoder = obj_to_encoder(obj); | |
77 | ||
78 | if ((encoder == best_encoder) && (status == connector_status_connected)) | |
79 | connected = true; | |
80 | else | |
81 | connected = false; | |
82 | ||
83 | if (rdev->is_atom_bios) | |
84 | radeon_atombios_connected_scratch_regs(connector, encoder, connected); | |
85 | else | |
86 | radeon_combios_connected_scratch_regs(connector, encoder, connected); | |
87 | ||
88 | } | |
89 | } | |
90 | ||
445282db DA |
91 | struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type) |
92 | { | |
93 | struct drm_mode_object *obj; | |
94 | struct drm_encoder *encoder; | |
95 | int i; | |
96 | ||
97 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | |
98 | if (connector->encoder_ids[i] == 0) | |
99 | break; | |
100 | ||
101 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); | |
102 | if (!obj) | |
103 | continue; | |
104 | ||
105 | encoder = obj_to_encoder(obj); | |
106 | if (encoder->encoder_type == encoder_type) | |
107 | return encoder; | |
108 | } | |
109 | return NULL; | |
110 | } | |
111 | ||
771fe6b9 JG |
112 | struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector) |
113 | { | |
114 | int enc_id = connector->encoder_ids[0]; | |
115 | struct drm_mode_object *obj; | |
116 | struct drm_encoder *encoder; | |
117 | ||
118 | /* pick the encoder ids */ | |
119 | if (enc_id) { | |
120 | obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); | |
121 | if (!obj) | |
122 | return NULL; | |
123 | encoder = obj_to_encoder(obj); | |
124 | return encoder; | |
125 | } | |
126 | return NULL; | |
127 | } | |
128 | ||
4ce001ab DA |
129 | /* |
130 | * radeon_connector_analog_encoder_conflict_solve | |
131 | * - search for other connectors sharing this encoder | |
132 | * if priority is true, then set them disconnected if this is connected | |
133 | * if priority is false, set us disconnected if they are connected | |
134 | */ | |
135 | static enum drm_connector_status | |
136 | radeon_connector_analog_encoder_conflict_solve(struct drm_connector *connector, | |
137 | struct drm_encoder *encoder, | |
138 | enum drm_connector_status current_status, | |
139 | bool priority) | |
140 | { | |
141 | struct drm_device *dev = connector->dev; | |
142 | struct drm_connector *conflict; | |
143 | int i; | |
144 | ||
145 | list_for_each_entry(conflict, &dev->mode_config.connector_list, head) { | |
146 | if (conflict == connector) | |
147 | continue; | |
148 | ||
149 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | |
150 | if (conflict->encoder_ids[i] == 0) | |
151 | break; | |
152 | ||
153 | /* if the IDs match */ | |
154 | if (conflict->encoder_ids[i] == encoder->base.id) { | |
155 | if (conflict->status != connector_status_connected) | |
156 | continue; | |
157 | ||
158 | if (priority == true) { | |
159 | DRM_INFO("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict)); | |
160 | DRM_INFO("in favor of %s\n", drm_get_connector_name(connector)); | |
161 | conflict->status = connector_status_disconnected; | |
162 | radeon_connector_update_scratch_regs(conflict, connector_status_disconnected); | |
163 | } else { | |
164 | DRM_INFO("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector)); | |
165 | DRM_INFO("in favor of %s\n", drm_get_connector_name(conflict)); | |
166 | current_status = connector_status_disconnected; | |
167 | } | |
168 | break; | |
169 | } | |
170 | } | |
171 | } | |
172 | return current_status; | |
173 | ||
174 | } | |
175 | ||
771fe6b9 JG |
176 | static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encoder) |
177 | { | |
178 | struct drm_device *dev = encoder->dev; | |
179 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | |
180 | struct drm_display_mode *mode = NULL; | |
181 | struct radeon_native_mode *native_mode = &radeon_encoder->native_mode; | |
182 | ||
183 | if (native_mode->panel_xres != 0 && | |
184 | native_mode->panel_yres != 0 && | |
185 | native_mode->dotclock != 0) { | |
186 | mode = drm_mode_create(dev); | |
187 | ||
188 | mode->hdisplay = native_mode->panel_xres; | |
189 | mode->vdisplay = native_mode->panel_yres; | |
190 | ||
191 | mode->htotal = mode->hdisplay + native_mode->hblank; | |
192 | mode->hsync_start = mode->hdisplay + native_mode->hoverplus; | |
193 | mode->hsync_end = mode->hsync_start + native_mode->hsync_width; | |
194 | mode->vtotal = mode->vdisplay + native_mode->vblank; | |
195 | mode->vsync_start = mode->vdisplay + native_mode->voverplus; | |
196 | mode->vsync_end = mode->vsync_start + native_mode->vsync_width; | |
197 | mode->clock = native_mode->dotclock; | |
198 | mode->flags = 0; | |
199 | ||
200 | mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; | |
201 | drm_mode_set_name(mode); | |
202 | ||
203 | DRM_DEBUG("Adding native panel mode %s\n", mode->name); | |
204 | } | |
205 | return mode; | |
206 | } | |
207 | ||
923f6848 AD |
208 | static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_connector *connector) |
209 | { | |
210 | struct drm_device *dev = encoder->dev; | |
211 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | |
212 | struct drm_display_mode *mode = NULL; | |
213 | struct radeon_native_mode *native_mode = &radeon_encoder->native_mode; | |
214 | int i; | |
215 | struct mode_size { | |
216 | int w; | |
217 | int h; | |
218 | } common_modes[17] = { | |
219 | { 640, 480}, | |
220 | { 720, 480}, | |
221 | { 800, 600}, | |
222 | { 848, 480}, | |
223 | {1024, 768}, | |
224 | {1152, 768}, | |
225 | {1280, 720}, | |
226 | {1280, 800}, | |
227 | {1280, 854}, | |
228 | {1280, 960}, | |
229 | {1280, 1024}, | |
230 | {1440, 900}, | |
231 | {1400, 1050}, | |
232 | {1680, 1050}, | |
233 | {1600, 1200}, | |
234 | {1920, 1080}, | |
235 | {1920, 1200} | |
236 | }; | |
237 | ||
238 | for (i = 0; i < 17; i++) { | |
239 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { | |
fb1fbf8e MD |
240 | if (common_modes[i].w > native_mode->panel_xres || |
241 | common_modes[i].h > native_mode->panel_yres || | |
242 | (common_modes[i].w == native_mode->panel_xres && | |
243 | common_modes[i].h == native_mode->panel_yres)) | |
923f6848 AD |
244 | continue; |
245 | } | |
246 | if (common_modes[i].w < 320 || common_modes[i].h < 200) | |
247 | continue; | |
248 | ||
d50ba256 | 249 | mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false); |
923f6848 AD |
250 | drm_mode_probed_add(connector, mode); |
251 | } | |
252 | } | |
253 | ||
771fe6b9 JG |
254 | int radeon_connector_set_property(struct drm_connector *connector, struct drm_property *property, |
255 | uint64_t val) | |
256 | { | |
445282db DA |
257 | struct drm_device *dev = connector->dev; |
258 | struct radeon_device *rdev = dev->dev_private; | |
259 | struct drm_encoder *encoder; | |
260 | struct radeon_encoder *radeon_encoder; | |
261 | ||
262 | if (property == rdev->mode_info.coherent_mode_property) { | |
263 | struct radeon_encoder_atom_dig *dig; | |
264 | ||
265 | /* need to find digital encoder on connector */ | |
266 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); | |
267 | if (!encoder) | |
268 | return 0; | |
269 | ||
270 | radeon_encoder = to_radeon_encoder(encoder); | |
271 | ||
272 | if (!radeon_encoder->enc_priv) | |
273 | return 0; | |
274 | ||
275 | dig = radeon_encoder->enc_priv; | |
276 | dig->coherent_mode = val ? true : false; | |
277 | radeon_property_change_mode(&radeon_encoder->base); | |
278 | } | |
279 | ||
280 | if (property == rdev->mode_info.tv_std_property) { | |
281 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TVDAC); | |
282 | if (!encoder) { | |
283 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_DAC); | |
284 | } | |
285 | ||
286 | if (!encoder) | |
287 | return 0; | |
288 | ||
289 | radeon_encoder = to_radeon_encoder(encoder); | |
290 | if (!radeon_encoder->enc_priv) | |
291 | return 0; | |
292 | if (rdev->is_atom_bios) { | |
293 | struct radeon_encoder_atom_dac *dac_int; | |
294 | dac_int = radeon_encoder->enc_priv; | |
295 | dac_int->tv_std = val; | |
296 | } else { | |
297 | struct radeon_encoder_tv_dac *dac_int; | |
298 | dac_int = radeon_encoder->enc_priv; | |
299 | dac_int->tv_std = val; | |
300 | } | |
301 | radeon_property_change_mode(&radeon_encoder->base); | |
302 | } | |
303 | ||
304 | if (property == rdev->mode_info.load_detect_property) { | |
305 | struct radeon_connector *radeon_connector = | |
306 | to_radeon_connector(connector); | |
307 | ||
308 | if (val == 0) | |
309 | radeon_connector->dac_load_detect = false; | |
310 | else | |
311 | radeon_connector->dac_load_detect = true; | |
312 | } | |
313 | ||
314 | if (property == rdev->mode_info.tmds_pll_property) { | |
315 | struct radeon_encoder_int_tmds *tmds = NULL; | |
316 | bool ret = false; | |
317 | /* need to find digital encoder on connector */ | |
318 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); | |
319 | if (!encoder) | |
320 | return 0; | |
321 | ||
322 | radeon_encoder = to_radeon_encoder(encoder); | |
323 | ||
324 | tmds = radeon_encoder->enc_priv; | |
325 | if (!tmds) | |
326 | return 0; | |
327 | ||
328 | if (val == 0) { | |
329 | if (rdev->is_atom_bios) | |
330 | ret = radeon_atombios_get_tmds_info(radeon_encoder, tmds); | |
331 | else | |
332 | ret = radeon_legacy_get_tmds_info_from_combios(radeon_encoder, tmds); | |
333 | } | |
334 | if (val == 1 || ret == false) { | |
335 | radeon_legacy_get_tmds_info_from_table(radeon_encoder, tmds); | |
336 | } | |
337 | radeon_property_change_mode(&radeon_encoder->base); | |
338 | } | |
339 | ||
771fe6b9 JG |
340 | return 0; |
341 | } | |
342 | ||
8dfaa8a7 MD |
343 | static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder, |
344 | struct drm_connector *connector) | |
345 | { | |
346 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | |
347 | struct radeon_native_mode *native_mode = &radeon_encoder->native_mode; | |
348 | ||
349 | /* Try to get native mode details from EDID if necessary */ | |
350 | if (!native_mode->dotclock) { | |
351 | struct drm_display_mode *t, *mode; | |
352 | ||
353 | list_for_each_entry_safe(mode, t, &connector->probed_modes, head) { | |
354 | if (mode->hdisplay == native_mode->panel_xres && | |
355 | mode->vdisplay == native_mode->panel_yres) { | |
356 | native_mode->hblank = mode->htotal - mode->hdisplay; | |
357 | native_mode->hoverplus = mode->hsync_start - mode->hdisplay; | |
358 | native_mode->hsync_width = mode->hsync_end - mode->hsync_start; | |
359 | native_mode->vblank = mode->vtotal - mode->vdisplay; | |
360 | native_mode->voverplus = mode->vsync_start - mode->vdisplay; | |
361 | native_mode->vsync_width = mode->vsync_end - mode->vsync_start; | |
362 | native_mode->dotclock = mode->clock; | |
363 | DRM_INFO("Determined LVDS native mode details from EDID\n"); | |
364 | break; | |
365 | } | |
366 | } | |
367 | } | |
368 | if (!native_mode->dotclock) { | |
369 | DRM_INFO("No LVDS native mode details, disabling RMX\n"); | |
370 | radeon_encoder->rmx_type = RMX_OFF; | |
371 | } | |
372 | } | |
771fe6b9 JG |
373 | |
374 | static int radeon_lvds_get_modes(struct drm_connector *connector) | |
375 | { | |
376 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
377 | struct drm_encoder *encoder; | |
378 | int ret = 0; | |
379 | struct drm_display_mode *mode; | |
380 | ||
381 | if (radeon_connector->ddc_bus) { | |
382 | ret = radeon_ddc_get_modes(radeon_connector); | |
383 | if (ret > 0) { | |
7747b713 | 384 | encoder = radeon_best_single_encoder(connector); |
8dfaa8a7 MD |
385 | if (encoder) { |
386 | radeon_fixup_lvds_native_mode(encoder, connector); | |
7747b713 AD |
387 | /* add scaled modes */ |
388 | radeon_add_common_modes(encoder, connector); | |
8dfaa8a7 | 389 | } |
771fe6b9 JG |
390 | return ret; |
391 | } | |
392 | } | |
393 | ||
394 | encoder = radeon_best_single_encoder(connector); | |
395 | if (!encoder) | |
396 | return 0; | |
397 | ||
398 | /* we have no EDID modes */ | |
399 | mode = radeon_fp_native_mode(encoder); | |
400 | if (mode) { | |
401 | ret = 1; | |
402 | drm_mode_probed_add(connector, mode); | |
7747b713 AD |
403 | /* add scaled modes */ |
404 | radeon_add_common_modes(encoder, connector); | |
771fe6b9 | 405 | } |
923f6848 | 406 | |
771fe6b9 JG |
407 | return ret; |
408 | } | |
409 | ||
410 | static int radeon_lvds_mode_valid(struct drm_connector *connector, | |
411 | struct drm_display_mode *mode) | |
412 | { | |
413 | return MODE_OK; | |
414 | } | |
415 | ||
416 | static enum drm_connector_status radeon_lvds_detect(struct drm_connector *connector) | |
417 | { | |
418 | enum drm_connector_status ret = connector_status_connected; | |
419 | /* check acpi lid status ??? */ | |
420 | radeon_connector_update_scratch_regs(connector, ret); | |
421 | return ret; | |
422 | } | |
423 | ||
424 | static void radeon_connector_destroy(struct drm_connector *connector) | |
425 | { | |
426 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
427 | ||
428 | if (radeon_connector->ddc_bus) | |
429 | radeon_i2c_destroy(radeon_connector->ddc_bus); | |
430 | kfree(radeon_connector->con_priv); | |
431 | drm_sysfs_connector_remove(connector); | |
432 | drm_connector_cleanup(connector); | |
433 | kfree(connector); | |
434 | } | |
435 | ||
445282db DA |
436 | static int radeon_lvds_set_property(struct drm_connector *connector, |
437 | struct drm_property *property, | |
438 | uint64_t value) | |
439 | { | |
440 | struct drm_device *dev = connector->dev; | |
441 | struct radeon_encoder *radeon_encoder; | |
442 | enum radeon_rmx_type rmx_type; | |
443 | ||
444 | DRM_DEBUG("\n"); | |
445 | if (property != dev->mode_config.scaling_mode_property) | |
446 | return 0; | |
447 | ||
448 | if (connector->encoder) | |
449 | radeon_encoder = to_radeon_encoder(connector->encoder); | |
450 | else { | |
451 | struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; | |
452 | radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector)); | |
453 | } | |
454 | ||
455 | switch (value) { | |
456 | case DRM_MODE_SCALE_NONE: rmx_type = RMX_OFF; break; | |
457 | case DRM_MODE_SCALE_CENTER: rmx_type = RMX_CENTER; break; | |
458 | case DRM_MODE_SCALE_ASPECT: rmx_type = RMX_ASPECT; break; | |
459 | default: | |
460 | case DRM_MODE_SCALE_FULLSCREEN: rmx_type = RMX_FULL; break; | |
461 | } | |
462 | if (radeon_encoder->rmx_type == rmx_type) | |
463 | return 0; | |
464 | ||
465 | radeon_encoder->rmx_type = rmx_type; | |
466 | ||
467 | radeon_property_change_mode(&radeon_encoder->base); | |
468 | return 0; | |
469 | } | |
470 | ||
471 | ||
771fe6b9 JG |
472 | struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs = { |
473 | .get_modes = radeon_lvds_get_modes, | |
474 | .mode_valid = radeon_lvds_mode_valid, | |
475 | .best_encoder = radeon_best_single_encoder, | |
476 | }; | |
477 | ||
478 | struct drm_connector_funcs radeon_lvds_connector_funcs = { | |
479 | .dpms = drm_helper_connector_dpms, | |
480 | .detect = radeon_lvds_detect, | |
481 | .fill_modes = drm_helper_probe_single_connector_modes, | |
482 | .destroy = radeon_connector_destroy, | |
445282db | 483 | .set_property = radeon_lvds_set_property, |
771fe6b9 JG |
484 | }; |
485 | ||
486 | static int radeon_vga_get_modes(struct drm_connector *connector) | |
487 | { | |
488 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
489 | int ret; | |
490 | ||
491 | ret = radeon_ddc_get_modes(radeon_connector); | |
492 | ||
493 | return ret; | |
494 | } | |
495 | ||
496 | static int radeon_vga_mode_valid(struct drm_connector *connector, | |
497 | struct drm_display_mode *mode) | |
498 | { | |
771fe6b9 JG |
499 | return MODE_OK; |
500 | } | |
501 | ||
502 | static enum drm_connector_status radeon_vga_detect(struct drm_connector *connector) | |
503 | { | |
504 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
505 | struct drm_encoder *encoder; | |
506 | struct drm_encoder_helper_funcs *encoder_funcs; | |
507 | bool dret; | |
508 | enum drm_connector_status ret = connector_status_disconnected; | |
509 | ||
4ce001ab DA |
510 | encoder = radeon_best_single_encoder(connector); |
511 | if (!encoder) | |
512 | ret = connector_status_disconnected; | |
513 | ||
771fe6b9 JG |
514 | radeon_i2c_do_lock(radeon_connector, 1); |
515 | dret = radeon_ddc_probe(radeon_connector); | |
516 | radeon_i2c_do_lock(radeon_connector, 0); | |
517 | if (dret) | |
518 | ret = connector_status_connected; | |
519 | else { | |
445282db DA |
520 | if (radeon_connector->dac_load_detect) { |
521 | encoder_funcs = encoder->helper_private; | |
522 | ret = encoder_funcs->detect(encoder, connector); | |
523 | } | |
771fe6b9 JG |
524 | } |
525 | ||
4ce001ab DA |
526 | if (ret == connector_status_connected) |
527 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); | |
771fe6b9 JG |
528 | radeon_connector_update_scratch_regs(connector, ret); |
529 | return ret; | |
530 | } | |
531 | ||
532 | struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs = { | |
533 | .get_modes = radeon_vga_get_modes, | |
534 | .mode_valid = radeon_vga_mode_valid, | |
535 | .best_encoder = radeon_best_single_encoder, | |
536 | }; | |
537 | ||
538 | struct drm_connector_funcs radeon_vga_connector_funcs = { | |
539 | .dpms = drm_helper_connector_dpms, | |
540 | .detect = radeon_vga_detect, | |
541 | .fill_modes = drm_helper_probe_single_connector_modes, | |
542 | .destroy = radeon_connector_destroy, | |
543 | .set_property = radeon_connector_set_property, | |
544 | }; | |
545 | ||
4ce001ab DA |
546 | static int radeon_tv_get_modes(struct drm_connector *connector) |
547 | { | |
548 | struct drm_device *dev = connector->dev; | |
923f6848 | 549 | struct radeon_device *rdev = dev->dev_private; |
4ce001ab | 550 | struct drm_display_mode *tv_mode; |
923f6848 | 551 | struct drm_encoder *encoder; |
4ce001ab | 552 | |
923f6848 AD |
553 | encoder = radeon_best_single_encoder(connector); |
554 | if (!encoder) | |
555 | return 0; | |
4ce001ab | 556 | |
923f6848 AD |
557 | /* avivo chips can scale any mode */ |
558 | if (rdev->family >= CHIP_RS600) | |
559 | /* add scaled modes */ | |
560 | radeon_add_common_modes(encoder, connector); | |
561 | else { | |
562 | /* only 800x600 is supported right now on pre-avivo chips */ | |
d50ba256 | 563 | tv_mode = drm_cvt_mode(dev, 800, 600, 60, false, false, false); |
923f6848 AD |
564 | tv_mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; |
565 | drm_mode_probed_add(connector, tv_mode); | |
566 | } | |
4ce001ab DA |
567 | return 1; |
568 | } | |
569 | ||
570 | static int radeon_tv_mode_valid(struct drm_connector *connector, | |
571 | struct drm_display_mode *mode) | |
572 | { | |
573 | return MODE_OK; | |
574 | } | |
575 | ||
576 | static enum drm_connector_status radeon_tv_detect(struct drm_connector *connector) | |
577 | { | |
578 | struct drm_encoder *encoder; | |
579 | struct drm_encoder_helper_funcs *encoder_funcs; | |
445282db DA |
580 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
581 | enum drm_connector_status ret = connector_status_disconnected; | |
582 | ||
583 | if (!radeon_connector->dac_load_detect) | |
584 | return ret; | |
4ce001ab DA |
585 | |
586 | encoder = radeon_best_single_encoder(connector); | |
587 | if (!encoder) | |
588 | ret = connector_status_disconnected; | |
589 | else { | |
590 | encoder_funcs = encoder->helper_private; | |
591 | ret = encoder_funcs->detect(encoder, connector); | |
592 | } | |
593 | if (ret == connector_status_connected) | |
594 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false); | |
595 | radeon_connector_update_scratch_regs(connector, ret); | |
596 | return ret; | |
597 | } | |
598 | ||
599 | struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs = { | |
600 | .get_modes = radeon_tv_get_modes, | |
601 | .mode_valid = radeon_tv_mode_valid, | |
602 | .best_encoder = radeon_best_single_encoder, | |
603 | }; | |
604 | ||
605 | struct drm_connector_funcs radeon_tv_connector_funcs = { | |
606 | .dpms = drm_helper_connector_dpms, | |
607 | .detect = radeon_tv_detect, | |
608 | .fill_modes = drm_helper_probe_single_connector_modes, | |
609 | .destroy = radeon_connector_destroy, | |
610 | .set_property = radeon_connector_set_property, | |
611 | }; | |
612 | ||
771fe6b9 JG |
613 | static int radeon_dvi_get_modes(struct drm_connector *connector) |
614 | { | |
615 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
616 | int ret; | |
617 | ||
618 | ret = radeon_ddc_get_modes(radeon_connector); | |
771fe6b9 JG |
619 | return ret; |
620 | } | |
621 | ||
4ce001ab DA |
622 | /* |
623 | * DVI is complicated | |
624 | * Do a DDC probe, if DDC probe passes, get the full EDID so | |
625 | * we can do analog/digital monitor detection at this point. | |
626 | * If the monitor is an analog monitor or we got no DDC, | |
627 | * we need to find the DAC encoder object for this connector. | |
628 | * If we got no DDC, we do load detection on the DAC encoder object. | |
629 | * If we got analog DDC or load detection passes on the DAC encoder | |
630 | * we have to check if this analog encoder is shared with anyone else (TV) | |
631 | * if its shared we have to set the other connector to disconnected. | |
632 | */ | |
771fe6b9 JG |
633 | static enum drm_connector_status radeon_dvi_detect(struct drm_connector *connector) |
634 | { | |
635 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
4ce001ab | 636 | struct drm_encoder *encoder = NULL; |
771fe6b9 JG |
637 | struct drm_encoder_helper_funcs *encoder_funcs; |
638 | struct drm_mode_object *obj; | |
639 | int i; | |
640 | enum drm_connector_status ret = connector_status_disconnected; | |
641 | bool dret; | |
642 | ||
643 | radeon_i2c_do_lock(radeon_connector, 1); | |
644 | dret = radeon_ddc_probe(radeon_connector); | |
645 | radeon_i2c_do_lock(radeon_connector, 0); | |
4ce001ab DA |
646 | if (dret) { |
647 | radeon_i2c_do_lock(radeon_connector, 1); | |
648 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter); | |
649 | radeon_i2c_do_lock(radeon_connector, 0); | |
650 | ||
651 | if (!radeon_connector->edid) { | |
652 | DRM_ERROR("DDC responded but not EDID found for %s\n", | |
653 | drm_get_connector_name(connector)); | |
654 | } else { | |
655 | radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); | |
656 | ||
657 | /* if this isn't a digital monitor | |
658 | then we need to make sure we don't have any | |
659 | TV conflicts */ | |
660 | ret = connector_status_connected; | |
661 | } | |
662 | } | |
663 | ||
664 | if ((ret == connector_status_connected) && (radeon_connector->use_digital == true)) | |
665 | goto out; | |
666 | ||
667 | /* find analog encoder */ | |
445282db DA |
668 | if (radeon_connector->dac_load_detect) { |
669 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | |
670 | if (connector->encoder_ids[i] == 0) | |
671 | break; | |
771fe6b9 | 672 | |
445282db DA |
673 | obj = drm_mode_object_find(connector->dev, |
674 | connector->encoder_ids[i], | |
675 | DRM_MODE_OBJECT_ENCODER); | |
676 | if (!obj) | |
677 | continue; | |
771fe6b9 | 678 | |
445282db | 679 | encoder = obj_to_encoder(obj); |
771fe6b9 | 680 | |
445282db DA |
681 | encoder_funcs = encoder->helper_private; |
682 | if (encoder_funcs->detect) { | |
683 | if (ret != connector_status_connected) { | |
684 | ret = encoder_funcs->detect(encoder, connector); | |
685 | if (ret == connector_status_connected) { | |
686 | radeon_connector->use_digital = false; | |
687 | } | |
771fe6b9 | 688 | } |
445282db | 689 | break; |
771fe6b9 JG |
690 | } |
691 | } | |
692 | } | |
693 | ||
4ce001ab DA |
694 | if ((ret == connector_status_connected) && (radeon_connector->use_digital == false) && |
695 | encoder) { | |
696 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); | |
697 | } | |
698 | ||
699 | out: | |
771fe6b9 JG |
700 | /* updated in get modes as well since we need to know if it's analog or digital */ |
701 | radeon_connector_update_scratch_regs(connector, ret); | |
702 | return ret; | |
703 | } | |
704 | ||
705 | /* okay need to be smart in here about which encoder to pick */ | |
706 | struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector) | |
707 | { | |
708 | int enc_id = connector->encoder_ids[0]; | |
709 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
710 | struct drm_mode_object *obj; | |
711 | struct drm_encoder *encoder; | |
712 | int i; | |
713 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | |
714 | if (connector->encoder_ids[i] == 0) | |
715 | break; | |
716 | ||
717 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); | |
718 | if (!obj) | |
719 | continue; | |
720 | ||
721 | encoder = obj_to_encoder(obj); | |
722 | ||
4ce001ab | 723 | if (radeon_connector->use_digital == true) { |
771fe6b9 JG |
724 | if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) |
725 | return encoder; | |
726 | } else { | |
727 | if (encoder->encoder_type == DRM_MODE_ENCODER_DAC || | |
728 | encoder->encoder_type == DRM_MODE_ENCODER_TVDAC) | |
729 | return encoder; | |
730 | } | |
731 | } | |
732 | ||
733 | /* see if we have a default encoder TODO */ | |
734 | ||
735 | /* then check use digitial */ | |
736 | /* pick the first one */ | |
737 | if (enc_id) { | |
738 | obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); | |
739 | if (!obj) | |
740 | return NULL; | |
741 | encoder = obj_to_encoder(obj); | |
742 | return encoder; | |
743 | } | |
744 | return NULL; | |
745 | } | |
746 | ||
d50ba256 DA |
747 | static void radeon_dvi_force(struct drm_connector *connector) |
748 | { | |
749 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | |
750 | if (connector->force == DRM_FORCE_ON) | |
751 | radeon_connector->use_digital = false; | |
752 | if (connector->force == DRM_FORCE_ON_DIGITAL) | |
753 | radeon_connector->use_digital = true; | |
754 | } | |
755 | ||
771fe6b9 JG |
756 | struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs = { |
757 | .get_modes = radeon_dvi_get_modes, | |
758 | .mode_valid = radeon_vga_mode_valid, | |
759 | .best_encoder = radeon_dvi_encoder, | |
760 | }; | |
761 | ||
762 | struct drm_connector_funcs radeon_dvi_connector_funcs = { | |
763 | .dpms = drm_helper_connector_dpms, | |
764 | .detect = radeon_dvi_detect, | |
765 | .fill_modes = drm_helper_probe_single_connector_modes, | |
766 | .set_property = radeon_connector_set_property, | |
767 | .destroy = radeon_connector_destroy, | |
d50ba256 | 768 | .force = radeon_dvi_force, |
771fe6b9 JG |
769 | }; |
770 | ||
771 | void | |
772 | radeon_add_atom_connector(struct drm_device *dev, | |
773 | uint32_t connector_id, | |
774 | uint32_t supported_device, | |
775 | int connector_type, | |
776 | struct radeon_i2c_bus_rec *i2c_bus, | |
777 | bool linkb, | |
778 | uint32_t igp_lane_info) | |
779 | { | |
445282db | 780 | struct radeon_device *rdev = dev->dev_private; |
771fe6b9 JG |
781 | struct drm_connector *connector; |
782 | struct radeon_connector *radeon_connector; | |
783 | struct radeon_connector_atom_dig *radeon_dig_connector; | |
784 | uint32_t subpixel_order = SubPixelNone; | |
d50ba256 | 785 | int ret; |
771fe6b9 JG |
786 | |
787 | /* fixme - tv/cv/din */ | |
4ce001ab | 788 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
771fe6b9 JG |
789 | return; |
790 | ||
791 | /* see if we already added it */ | |
792 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | |
793 | radeon_connector = to_radeon_connector(connector); | |
794 | if (radeon_connector->connector_id == connector_id) { | |
795 | radeon_connector->devices |= supported_device; | |
796 | return; | |
797 | } | |
798 | } | |
799 | ||
800 | radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); | |
801 | if (!radeon_connector) | |
802 | return; | |
803 | ||
804 | connector = &radeon_connector->base; | |
805 | ||
806 | radeon_connector->connector_id = connector_id; | |
807 | radeon_connector->devices = supported_device; | |
808 | switch (connector_type) { | |
809 | case DRM_MODE_CONNECTOR_VGA: | |
810 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); | |
811 | drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); | |
812 | if (i2c_bus->valid) { | |
813 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "VGA"); | |
814 | if (!radeon_connector->ddc_bus) | |
815 | goto failed; | |
816 | } | |
35e4b7af | 817 | radeon_connector->dac_load_detect = true; |
445282db DA |
818 | drm_connector_attach_property(&radeon_connector->base, |
819 | rdev->mode_info.load_detect_property, | |
820 | 1); | |
771fe6b9 JG |
821 | break; |
822 | case DRM_MODE_CONNECTOR_DVIA: | |
823 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); | |
824 | drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); | |
825 | if (i2c_bus->valid) { | |
826 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); | |
827 | if (!radeon_connector->ddc_bus) | |
828 | goto failed; | |
829 | } | |
35e4b7af | 830 | radeon_connector->dac_load_detect = true; |
445282db DA |
831 | drm_connector_attach_property(&radeon_connector->base, |
832 | rdev->mode_info.load_detect_property, | |
833 | 1); | |
771fe6b9 JG |
834 | break; |
835 | case DRM_MODE_CONNECTOR_DVII: | |
836 | case DRM_MODE_CONNECTOR_DVID: | |
837 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); | |
838 | if (!radeon_dig_connector) | |
839 | goto failed; | |
840 | radeon_dig_connector->linkb = linkb; | |
841 | radeon_dig_connector->igp_lane_info = igp_lane_info; | |
842 | radeon_connector->con_priv = radeon_dig_connector; | |
843 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); | |
844 | drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); | |
845 | if (i2c_bus->valid) { | |
846 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); | |
847 | if (!radeon_connector->ddc_bus) | |
848 | goto failed; | |
849 | } | |
850 | subpixel_order = SubPixelHorizontalRGB; | |
445282db DA |
851 | drm_connector_attach_property(&radeon_connector->base, |
852 | rdev->mode_info.coherent_mode_property, | |
853 | 1); | |
35e4b7af | 854 | radeon_connector->dac_load_detect = true; |
445282db DA |
855 | drm_connector_attach_property(&radeon_connector->base, |
856 | rdev->mode_info.load_detect_property, | |
857 | 1); | |
771fe6b9 JG |
858 | break; |
859 | case DRM_MODE_CONNECTOR_HDMIA: | |
860 | case DRM_MODE_CONNECTOR_HDMIB: | |
861 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); | |
862 | if (!radeon_dig_connector) | |
863 | goto failed; | |
864 | radeon_dig_connector->linkb = linkb; | |
865 | radeon_dig_connector->igp_lane_info = igp_lane_info; | |
866 | radeon_connector->con_priv = radeon_dig_connector; | |
867 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); | |
868 | drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); | |
869 | if (i2c_bus->valid) { | |
870 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "HDMI"); | |
871 | if (!radeon_connector->ddc_bus) | |
872 | goto failed; | |
873 | } | |
445282db DA |
874 | drm_connector_attach_property(&radeon_connector->base, |
875 | rdev->mode_info.coherent_mode_property, | |
876 | 1); | |
771fe6b9 JG |
877 | subpixel_order = SubPixelHorizontalRGB; |
878 | break; | |
879 | case DRM_MODE_CONNECTOR_DisplayPort: | |
880 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); | |
881 | if (!radeon_dig_connector) | |
882 | goto failed; | |
883 | radeon_dig_connector->linkb = linkb; | |
884 | radeon_dig_connector->igp_lane_info = igp_lane_info; | |
885 | radeon_connector->con_priv = radeon_dig_connector; | |
886 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); | |
887 | drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); | |
888 | if (i2c_bus->valid) { | |
889 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DP"); | |
890 | if (!radeon_connector->ddc_bus) | |
891 | goto failed; | |
892 | } | |
893 | subpixel_order = SubPixelHorizontalRGB; | |
894 | break; | |
895 | case DRM_MODE_CONNECTOR_SVIDEO: | |
896 | case DRM_MODE_CONNECTOR_Composite: | |
897 | case DRM_MODE_CONNECTOR_9PinDIN: | |
4ce001ab DA |
898 | if (radeon_tv == 1) { |
899 | drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); | |
900 | drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); | |
901 | } | |
35e4b7af | 902 | radeon_connector->dac_load_detect = true; |
445282db DA |
903 | drm_connector_attach_property(&radeon_connector->base, |
904 | rdev->mode_info.load_detect_property, | |
905 | 1); | |
771fe6b9 JG |
906 | break; |
907 | case DRM_MODE_CONNECTOR_LVDS: | |
908 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); | |
909 | if (!radeon_dig_connector) | |
910 | goto failed; | |
911 | radeon_dig_connector->linkb = linkb; | |
912 | radeon_dig_connector->igp_lane_info = igp_lane_info; | |
913 | radeon_connector->con_priv = radeon_dig_connector; | |
914 | drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); | |
915 | drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); | |
916 | if (i2c_bus->valid) { | |
917 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "LVDS"); | |
918 | if (!radeon_connector->ddc_bus) | |
919 | goto failed; | |
920 | } | |
445282db DA |
921 | drm_mode_create_scaling_mode_property(dev); |
922 | drm_connector_attach_property(&radeon_connector->base, | |
923 | dev->mode_config.scaling_mode_property, | |
924 | DRM_MODE_SCALE_FULLSCREEN); | |
771fe6b9 JG |
925 | subpixel_order = SubPixelHorizontalRGB; |
926 | break; | |
927 | } | |
928 | ||
d50ba256 DA |
929 | ret = drm_fb_helper_add_connector(connector); |
930 | if (ret) | |
931 | goto failed; | |
932 | ||
771fe6b9 JG |
933 | connector->display_info.subpixel_order = subpixel_order; |
934 | drm_sysfs_connector_add(connector); | |
935 | return; | |
936 | ||
937 | failed: | |
938 | if (radeon_connector->ddc_bus) | |
939 | radeon_i2c_destroy(radeon_connector->ddc_bus); | |
940 | drm_connector_cleanup(connector); | |
941 | kfree(connector); | |
942 | } | |
943 | ||
944 | void | |
945 | radeon_add_legacy_connector(struct drm_device *dev, | |
946 | uint32_t connector_id, | |
947 | uint32_t supported_device, | |
948 | int connector_type, | |
949 | struct radeon_i2c_bus_rec *i2c_bus) | |
950 | { | |
445282db | 951 | struct radeon_device *rdev = dev->dev_private; |
771fe6b9 JG |
952 | struct drm_connector *connector; |
953 | struct radeon_connector *radeon_connector; | |
954 | uint32_t subpixel_order = SubPixelNone; | |
d50ba256 | 955 | int ret; |
771fe6b9 JG |
956 | |
957 | /* fixme - tv/cv/din */ | |
4ce001ab | 958 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
771fe6b9 JG |
959 | return; |
960 | ||
961 | /* see if we already added it */ | |
962 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | |
963 | radeon_connector = to_radeon_connector(connector); | |
964 | if (radeon_connector->connector_id == connector_id) { | |
965 | radeon_connector->devices |= supported_device; | |
966 | return; | |
967 | } | |
968 | } | |
969 | ||
970 | radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); | |
971 | if (!radeon_connector) | |
972 | return; | |
973 | ||
974 | connector = &radeon_connector->base; | |
975 | ||
976 | radeon_connector->connector_id = connector_id; | |
977 | radeon_connector->devices = supported_device; | |
978 | switch (connector_type) { | |
979 | case DRM_MODE_CONNECTOR_VGA: | |
980 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); | |
981 | drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); | |
982 | if (i2c_bus->valid) { | |
983 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "VGA"); | |
984 | if (!radeon_connector->ddc_bus) | |
985 | goto failed; | |
986 | } | |
35e4b7af | 987 | radeon_connector->dac_load_detect = true; |
445282db DA |
988 | drm_connector_attach_property(&radeon_connector->base, |
989 | rdev->mode_info.load_detect_property, | |
990 | 1); | |
771fe6b9 JG |
991 | break; |
992 | case DRM_MODE_CONNECTOR_DVIA: | |
993 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); | |
994 | drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); | |
995 | if (i2c_bus->valid) { | |
996 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); | |
997 | if (!radeon_connector->ddc_bus) | |
998 | goto failed; | |
999 | } | |
35e4b7af | 1000 | radeon_connector->dac_load_detect = true; |
445282db DA |
1001 | drm_connector_attach_property(&radeon_connector->base, |
1002 | rdev->mode_info.load_detect_property, | |
1003 | 1); | |
771fe6b9 JG |
1004 | break; |
1005 | case DRM_MODE_CONNECTOR_DVII: | |
1006 | case DRM_MODE_CONNECTOR_DVID: | |
1007 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); | |
1008 | drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); | |
1009 | if (i2c_bus->valid) { | |
1010 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); | |
1011 | if (!radeon_connector->ddc_bus) | |
1012 | goto failed; | |
35e4b7af | 1013 | radeon_connector->dac_load_detect = true; |
445282db DA |
1014 | drm_connector_attach_property(&radeon_connector->base, |
1015 | rdev->mode_info.load_detect_property, | |
1016 | 1); | |
771fe6b9 JG |
1017 | } |
1018 | subpixel_order = SubPixelHorizontalRGB; | |
1019 | break; | |
1020 | case DRM_MODE_CONNECTOR_SVIDEO: | |
1021 | case DRM_MODE_CONNECTOR_Composite: | |
1022 | case DRM_MODE_CONNECTOR_9PinDIN: | |
4ce001ab DA |
1023 | if (radeon_tv == 1) { |
1024 | drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); | |
1025 | drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); | |
35e4b7af | 1026 | radeon_connector->dac_load_detect = true; |
445282db DA |
1027 | drm_connector_attach_property(&radeon_connector->base, |
1028 | rdev->mode_info.load_detect_property, | |
1029 | 1); | |
4ce001ab | 1030 | } |
771fe6b9 JG |
1031 | break; |
1032 | case DRM_MODE_CONNECTOR_LVDS: | |
1033 | drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); | |
1034 | drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); | |
1035 | if (i2c_bus->valid) { | |
1036 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "LVDS"); | |
1037 | if (!radeon_connector->ddc_bus) | |
1038 | goto failed; | |
1039 | } | |
445282db DA |
1040 | drm_connector_attach_property(&radeon_connector->base, |
1041 | dev->mode_config.scaling_mode_property, | |
1042 | DRM_MODE_SCALE_FULLSCREEN); | |
771fe6b9 JG |
1043 | subpixel_order = SubPixelHorizontalRGB; |
1044 | break; | |
1045 | } | |
1046 | ||
d50ba256 DA |
1047 | ret = drm_fb_helper_add_connector(connector); |
1048 | if (ret) | |
1049 | goto failed; | |
1050 | ||
771fe6b9 JG |
1051 | connector->display_info.subpixel_order = subpixel_order; |
1052 | drm_sysfs_connector_add(connector); | |
1053 | return; | |
1054 | ||
1055 | failed: | |
1056 | if (radeon_connector->ddc_bus) | |
1057 | radeon_i2c_destroy(radeon_connector->ddc_bus); | |
1058 | drm_connector_cleanup(connector); | |
1059 | kfree(connector); | |
1060 | } |