blob: 1331351c517860973e2fc00bc9724bf7df89a730 [file] [log] [blame]
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001/*
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"
Dave Airlied50ba252009-09-23 14:44:08 +100029#include "drm_fb_helper.h"
Jerome Glisse771fe6b2009-06-05 14:42:42 +020030#include "radeon_drm.h"
31#include "radeon.h"
Alex Deucher923f6842009-09-10 17:53:39 -040032#include "atom.h"
Jerome Glisse771fe6b2009-06-05 14:42:42 +020033
34extern void
35radeon_combios_connected_scratch_regs(struct drm_connector *connector,
36 struct drm_encoder *encoder,
37 bool connected);
38extern void
39radeon_atombios_connected_scratch_regs(struct drm_connector *connector,
40 struct drm_encoder *encoder,
41 bool connected);
42
Alex Deucherd4877cf2009-12-04 16:56:37 -050043void radeon_connector_hotplug(struct drm_connector *connector)
44{
45 struct drm_device *dev = connector->dev;
46 struct radeon_device *rdev = dev->dev_private;
47 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
48
49 if (radeon_connector->hpd.hpd != RADEON_HPD_NONE)
50 radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd);
51
Alex Deucher196c58d2010-01-07 14:22:32 -050052 if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||
53 (connector->connector_type == DRM_MODE_CONNECTOR_eDP)) {
54 if ((radeon_dp_getsinktype(radeon_connector) == CONNECTOR_OBJECT_ID_DISPLAYPORT) ||
55 (radeon_dp_getsinktype(radeon_connector) == CONNECTOR_OBJECT_ID_eDP)) {
Alex Deucherd4877cf2009-12-04 16:56:37 -050056 if (radeon_dp_needs_link_train(radeon_connector)) {
57 if (connector->encoder)
58 dp_link_train(connector->encoder, connector);
59 }
60 }
61 }
62
63}
64
Dave Airlie445282d2009-09-09 17:40:54 +100065static void radeon_property_change_mode(struct drm_encoder *encoder)
66{
67 struct drm_crtc *crtc = encoder->crtc;
68
69 if (crtc && crtc->enabled) {
70 drm_crtc_helper_set_mode(crtc, &crtc->mode,
71 crtc->x, crtc->y, crtc->fb);
72 }
73}
Jerome Glisse771fe6b2009-06-05 14:42:42 +020074static void
75radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_connector_status status)
76{
77 struct drm_device *dev = connector->dev;
78 struct radeon_device *rdev = dev->dev_private;
79 struct drm_encoder *best_encoder = NULL;
80 struct drm_encoder *encoder = NULL;
81 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private;
82 struct drm_mode_object *obj;
83 bool connected;
84 int i;
85
86 best_encoder = connector_funcs->best_encoder(connector);
87
88 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
89 if (connector->encoder_ids[i] == 0)
90 break;
91
92 obj = drm_mode_object_find(connector->dev,
93 connector->encoder_ids[i],
94 DRM_MODE_OBJECT_ENCODER);
95 if (!obj)
96 continue;
97
98 encoder = obj_to_encoder(obj);
99
100 if ((encoder == best_encoder) && (status == connector_status_connected))
101 connected = true;
102 else
103 connected = false;
104
105 if (rdev->is_atom_bios)
106 radeon_atombios_connected_scratch_regs(connector, encoder, connected);
107 else
108 radeon_combios_connected_scratch_regs(connector, encoder, connected);
109
110 }
111}
112
Dave Airlie445282d2009-09-09 17:40:54 +1000113struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type)
114{
115 struct drm_mode_object *obj;
116 struct drm_encoder *encoder;
117 int i;
118
119 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
120 if (connector->encoder_ids[i] == 0)
121 break;
122
123 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER);
124 if (!obj)
125 continue;
126
127 encoder = obj_to_encoder(obj);
128 if (encoder->encoder_type == encoder_type)
129 return encoder;
130 }
131 return NULL;
132}
133
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200134struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector)
135{
136 int enc_id = connector->encoder_ids[0];
137 struct drm_mode_object *obj;
138 struct drm_encoder *encoder;
139
140 /* pick the encoder ids */
141 if (enc_id) {
142 obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER);
143 if (!obj)
144 return NULL;
145 encoder = obj_to_encoder(obj);
146 return encoder;
147 }
148 return NULL;
149}
150
Dave Airlie4ce001a2009-08-13 16:32:14 +1000151/*
152 * radeon_connector_analog_encoder_conflict_solve
153 * - search for other connectors sharing this encoder
154 * if priority is true, then set them disconnected if this is connected
155 * if priority is false, set us disconnected if they are connected
156 */
157static enum drm_connector_status
158radeon_connector_analog_encoder_conflict_solve(struct drm_connector *connector,
159 struct drm_encoder *encoder,
160 enum drm_connector_status current_status,
161 bool priority)
162{
163 struct drm_device *dev = connector->dev;
164 struct drm_connector *conflict;
Alex Deucher08d07512010-04-15 13:31:12 -0400165 struct radeon_connector *radeon_conflict;
Dave Airlie4ce001a2009-08-13 16:32:14 +1000166 int i;
167
168 list_for_each_entry(conflict, &dev->mode_config.connector_list, head) {
169 if (conflict == connector)
170 continue;
171
Alex Deucher08d07512010-04-15 13:31:12 -0400172 radeon_conflict = to_radeon_connector(conflict);
Dave Airlie4ce001a2009-08-13 16:32:14 +1000173 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
174 if (conflict->encoder_ids[i] == 0)
175 break;
176
177 /* if the IDs match */
178 if (conflict->encoder_ids[i] == encoder->base.id) {
179 if (conflict->status != connector_status_connected)
180 continue;
181
Alex Deucher08d07512010-04-15 13:31:12 -0400182 if (radeon_conflict->use_digital)
183 continue;
184
Dave Airlie4ce001a2009-08-13 16:32:14 +1000185 if (priority == true) {
186 DRM_INFO("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict));
187 DRM_INFO("in favor of %s\n", drm_get_connector_name(connector));
188 conflict->status = connector_status_disconnected;
189 radeon_connector_update_scratch_regs(conflict, connector_status_disconnected);
190 } else {
191 DRM_INFO("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector));
192 DRM_INFO("in favor of %s\n", drm_get_connector_name(conflict));
193 current_status = connector_status_disconnected;
194 }
195 break;
196 }
197 }
198 }
199 return current_status;
200
201}
202
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200203static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encoder)
204{
205 struct drm_device *dev = encoder->dev;
206 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
207 struct drm_display_mode *mode = NULL;
Alex Deucherde2103e2009-10-09 15:14:30 -0400208 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200209
Alex Deucherde2103e2009-10-09 15:14:30 -0400210 if (native_mode->hdisplay != 0 &&
211 native_mode->vdisplay != 0 &&
212 native_mode->clock != 0) {
Alex Deucherfb06ca82009-10-12 11:25:05 -0400213 mode = drm_mode_duplicate(dev, native_mode);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200214 mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
215 drm_mode_set_name(mode);
216
217 DRM_DEBUG("Adding native panel mode %s\n", mode->name);
Alex Deucherd2efdf62009-12-22 10:06:49 -0500218 } else if (native_mode->hdisplay != 0 &&
219 native_mode->vdisplay != 0) {
220 /* mac laptops without an edid */
221 /* Note that this is not necessarily the exact panel mode,
222 * but an approximation based on the cvt formula. For these
223 * systems we should ideally read the mode info out of the
224 * registers or add a mode table, but this works and is much
225 * simpler.
226 */
227 mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false);
228 mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
229 DRM_DEBUG("Adding cvt approximation of native panel mode %s\n", mode->name);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200230 }
231 return mode;
232}
233
Alex Deucher923f6842009-09-10 17:53:39 -0400234static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_connector *connector)
235{
236 struct drm_device *dev = encoder->dev;
237 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
238 struct drm_display_mode *mode = NULL;
Alex Deucherde2103e2009-10-09 15:14:30 -0400239 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
Alex Deucher923f6842009-09-10 17:53:39 -0400240 int i;
241 struct mode_size {
242 int w;
243 int h;
244 } common_modes[17] = {
245 { 640, 480},
246 { 720, 480},
247 { 800, 600},
248 { 848, 480},
249 {1024, 768},
250 {1152, 768},
251 {1280, 720},
252 {1280, 800},
253 {1280, 854},
254 {1280, 960},
255 {1280, 1024},
256 {1440, 900},
257 {1400, 1050},
258 {1680, 1050},
259 {1600, 1200},
260 {1920, 1080},
261 {1920, 1200}
262 };
263
264 for (i = 0; i < 17; i++) {
Alex Deucherdfdd6462009-10-13 12:48:44 -0400265 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) {
266 if (common_modes[i].w > 1024 ||
267 common_modes[i].h > 768)
268 continue;
269 }
Alex Deucher923f6842009-09-10 17:53:39 -0400270 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
Alex Deucherde2103e2009-10-09 15:14:30 -0400271 if (common_modes[i].w > native_mode->hdisplay ||
272 common_modes[i].h > native_mode->vdisplay ||
273 (common_modes[i].w == native_mode->hdisplay &&
274 common_modes[i].h == native_mode->vdisplay))
Alex Deucher923f6842009-09-10 17:53:39 -0400275 continue;
276 }
277 if (common_modes[i].w < 320 || common_modes[i].h < 200)
278 continue;
279
Dave Airlied50ba252009-09-23 14:44:08 +1000280 mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false);
Alex Deucher923f6842009-09-10 17:53:39 -0400281 drm_mode_probed_add(connector, mode);
282 }
283}
284
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200285int radeon_connector_set_property(struct drm_connector *connector, struct drm_property *property,
286 uint64_t val)
287{
Dave Airlie445282d2009-09-09 17:40:54 +1000288 struct drm_device *dev = connector->dev;
289 struct radeon_device *rdev = dev->dev_private;
290 struct drm_encoder *encoder;
291 struct radeon_encoder *radeon_encoder;
292
293 if (property == rdev->mode_info.coherent_mode_property) {
294 struct radeon_encoder_atom_dig *dig;
Dave Airliece227c42010-04-09 06:27:00 +0000295 bool new_coherent_mode;
Dave Airlie445282d2009-09-09 17:40:54 +1000296
297 /* need to find digital encoder on connector */
298 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
299 if (!encoder)
300 return 0;
301
302 radeon_encoder = to_radeon_encoder(encoder);
303
304 if (!radeon_encoder->enc_priv)
305 return 0;
306
307 dig = radeon_encoder->enc_priv;
Dave Airliece227c42010-04-09 06:27:00 +0000308 new_coherent_mode = val ? true : false;
309 if (dig->coherent_mode != new_coherent_mode) {
310 dig->coherent_mode = new_coherent_mode;
311 radeon_property_change_mode(&radeon_encoder->base);
312 }
Dave Airlie445282d2009-09-09 17:40:54 +1000313 }
314
315 if (property == rdev->mode_info.tv_std_property) {
316 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TVDAC);
317 if (!encoder) {
318 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_DAC);
319 }
320
321 if (!encoder)
322 return 0;
323
324 radeon_encoder = to_radeon_encoder(encoder);
325 if (!radeon_encoder->enc_priv)
326 return 0;
Alex Deucher643acac2010-04-05 23:57:52 -0400327 if (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom) {
Dave Airlie445282d2009-09-09 17:40:54 +1000328 struct radeon_encoder_atom_dac *dac_int;
329 dac_int = radeon_encoder->enc_priv;
330 dac_int->tv_std = val;
331 } else {
332 struct radeon_encoder_tv_dac *dac_int;
333 dac_int = radeon_encoder->enc_priv;
334 dac_int->tv_std = val;
335 }
336 radeon_property_change_mode(&radeon_encoder->base);
337 }
338
339 if (property == rdev->mode_info.load_detect_property) {
340 struct radeon_connector *radeon_connector =
341 to_radeon_connector(connector);
342
343 if (val == 0)
344 radeon_connector->dac_load_detect = false;
345 else
346 radeon_connector->dac_load_detect = true;
347 }
348
349 if (property == rdev->mode_info.tmds_pll_property) {
350 struct radeon_encoder_int_tmds *tmds = NULL;
351 bool ret = false;
352 /* need to find digital encoder on connector */
353 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
354 if (!encoder)
355 return 0;
356
357 radeon_encoder = to_radeon_encoder(encoder);
358
359 tmds = radeon_encoder->enc_priv;
360 if (!tmds)
361 return 0;
362
363 if (val == 0) {
364 if (rdev->is_atom_bios)
365 ret = radeon_atombios_get_tmds_info(radeon_encoder, tmds);
366 else
367 ret = radeon_legacy_get_tmds_info_from_combios(radeon_encoder, tmds);
368 }
369 if (val == 1 || ret == false) {
370 radeon_legacy_get_tmds_info_from_table(radeon_encoder, tmds);
371 }
372 radeon_property_change_mode(&radeon_encoder->base);
373 }
374
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200375 return 0;
376}
377
Michel Dänzer8dfaa8a2009-09-15 17:09:27 +0200378static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,
379 struct drm_connector *connector)
380{
381 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
Alex Deucherde2103e2009-10-09 15:14:30 -0400382 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
Michel Dänzer8dfaa8a2009-09-15 17:09:27 +0200383
384 /* Try to get native mode details from EDID if necessary */
Alex Deucherde2103e2009-10-09 15:14:30 -0400385 if (!native_mode->clock) {
Michel Dänzer8dfaa8a2009-09-15 17:09:27 +0200386 struct drm_display_mode *t, *mode;
387
388 list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
Alex Deucherde2103e2009-10-09 15:14:30 -0400389 if (mode->hdisplay == native_mode->hdisplay &&
390 mode->vdisplay == native_mode->vdisplay) {
391 *native_mode = *mode;
392 drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
Michel Dänzer8dfaa8a2009-09-15 17:09:27 +0200393 DRM_INFO("Determined LVDS native mode details from EDID\n");
394 break;
395 }
396 }
397 }
Alex Deucherde2103e2009-10-09 15:14:30 -0400398 if (!native_mode->clock) {
Michel Dänzer8dfaa8a2009-09-15 17:09:27 +0200399 DRM_INFO("No LVDS native mode details, disabling RMX\n");
400 radeon_encoder->rmx_type = RMX_OFF;
401 }
402}
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200403
404static int radeon_lvds_get_modes(struct drm_connector *connector)
405{
406 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
407 struct drm_encoder *encoder;
408 int ret = 0;
409 struct drm_display_mode *mode;
410
411 if (radeon_connector->ddc_bus) {
412 ret = radeon_ddc_get_modes(radeon_connector);
413 if (ret > 0) {
Alex Deucher7747b712009-09-11 11:15:43 -0400414 encoder = radeon_best_single_encoder(connector);
Michel Dänzer8dfaa8a2009-09-15 17:09:27 +0200415 if (encoder) {
416 radeon_fixup_lvds_native_mode(encoder, connector);
Alex Deucher7747b712009-09-11 11:15:43 -0400417 /* add scaled modes */
418 radeon_add_common_modes(encoder, connector);
Michel Dänzer8dfaa8a2009-09-15 17:09:27 +0200419 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200420 return ret;
421 }
422 }
423
424 encoder = radeon_best_single_encoder(connector);
425 if (!encoder)
426 return 0;
427
428 /* we have no EDID modes */
429 mode = radeon_fp_native_mode(encoder);
430 if (mode) {
431 ret = 1;
432 drm_mode_probed_add(connector, mode);
Alex Deucher7747b712009-09-11 11:15:43 -0400433 /* add scaled modes */
434 radeon_add_common_modes(encoder, connector);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200435 }
Alex Deucher923f6842009-09-10 17:53:39 -0400436
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200437 return ret;
438}
439
440static int radeon_lvds_mode_valid(struct drm_connector *connector,
441 struct drm_display_mode *mode)
442{
Alex Deuchera3fa6322009-11-05 11:57:07 -0500443 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
444
445 if ((mode->hdisplay < 320) || (mode->vdisplay < 240))
446 return MODE_PANEL;
447
448 if (encoder) {
449 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
450 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
451
452 /* AVIVO hardware supports downscaling modes larger than the panel
453 * to the panel size, but I'm not sure this is desirable.
454 */
455 if ((mode->hdisplay > native_mode->hdisplay) ||
456 (mode->vdisplay > native_mode->vdisplay))
457 return MODE_PANEL;
458
459 /* if scaling is disabled, block non-native modes */
460 if (radeon_encoder->rmx_type == RMX_OFF) {
461 if ((mode->hdisplay != native_mode->hdisplay) ||
462 (mode->vdisplay != native_mode->vdisplay))
463 return MODE_PANEL;
464 }
465 }
466
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200467 return MODE_OK;
468}
469
470static enum drm_connector_status radeon_lvds_detect(struct drm_connector *connector)
471{
Alex Deucher0549a0612009-10-09 18:41:19 -0400472 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
Alex Deucher2ffb8422009-10-08 13:02:19 -0400473 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
Alex Deucher0549a0612009-10-09 18:41:19 -0400474 enum drm_connector_status ret = connector_status_disconnected;
Alex Deucher2ffb8422009-10-08 13:02:19 -0400475
476 if (encoder) {
477 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
Alex Deucherde2103e2009-10-09 15:14:30 -0400478 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
Alex Deucher2ffb8422009-10-08 13:02:19 -0400479
480 /* check if panel is valid */
Alex Deucherde2103e2009-10-09 15:14:30 -0400481 if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240)
Alex Deucher2ffb8422009-10-08 13:02:19 -0400482 ret = connector_status_connected;
483
484 }
Alex Deucher0549a0612009-10-09 18:41:19 -0400485
486 /* check for edid as well */
Alex Deucher0294cf4f2009-10-15 16:16:35 -0400487 if (radeon_connector->edid)
488 ret = connector_status_connected;
489 else {
490 if (radeon_connector->ddc_bus) {
Alex Deucher0294cf4f2009-10-15 16:16:35 -0400491 radeon_connector->edid = drm_get_edid(&radeon_connector->base,
492 &radeon_connector->ddc_bus->adapter);
Alex Deucher0294cf4f2009-10-15 16:16:35 -0400493 if (radeon_connector->edid)
494 ret = connector_status_connected;
495 }
Alex Deucher0549a0612009-10-09 18:41:19 -0400496 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200497 /* check acpi lid status ??? */
Alex Deucher2ffb8422009-10-08 13:02:19 -0400498
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200499 radeon_connector_update_scratch_regs(connector, ret);
500 return ret;
501}
502
503static void radeon_connector_destroy(struct drm_connector *connector)
504{
505 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
506
507 if (radeon_connector->ddc_bus)
508 radeon_i2c_destroy(radeon_connector->ddc_bus);
Alex Deucher0294cf4f2009-10-15 16:16:35 -0400509 if (radeon_connector->edid)
510 kfree(radeon_connector->edid);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200511 kfree(radeon_connector->con_priv);
512 drm_sysfs_connector_remove(connector);
513 drm_connector_cleanup(connector);
514 kfree(connector);
515}
516
Dave Airlie445282d2009-09-09 17:40:54 +1000517static int radeon_lvds_set_property(struct drm_connector *connector,
518 struct drm_property *property,
519 uint64_t value)
520{
521 struct drm_device *dev = connector->dev;
522 struct radeon_encoder *radeon_encoder;
523 enum radeon_rmx_type rmx_type;
524
525 DRM_DEBUG("\n");
526 if (property != dev->mode_config.scaling_mode_property)
527 return 0;
528
529 if (connector->encoder)
530 radeon_encoder = to_radeon_encoder(connector->encoder);
531 else {
532 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private;
533 radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector));
534 }
535
536 switch (value) {
537 case DRM_MODE_SCALE_NONE: rmx_type = RMX_OFF; break;
538 case DRM_MODE_SCALE_CENTER: rmx_type = RMX_CENTER; break;
539 case DRM_MODE_SCALE_ASPECT: rmx_type = RMX_ASPECT; break;
540 default:
541 case DRM_MODE_SCALE_FULLSCREEN: rmx_type = RMX_FULL; break;
542 }
543 if (radeon_encoder->rmx_type == rmx_type)
544 return 0;
545
546 radeon_encoder->rmx_type = rmx_type;
547
548 radeon_property_change_mode(&radeon_encoder->base);
549 return 0;
550}
551
552
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200553struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs = {
554 .get_modes = radeon_lvds_get_modes,
555 .mode_valid = radeon_lvds_mode_valid,
556 .best_encoder = radeon_best_single_encoder,
557};
558
559struct drm_connector_funcs radeon_lvds_connector_funcs = {
560 .dpms = drm_helper_connector_dpms,
561 .detect = radeon_lvds_detect,
562 .fill_modes = drm_helper_probe_single_connector_modes,
563 .destroy = radeon_connector_destroy,
Dave Airlie445282d2009-09-09 17:40:54 +1000564 .set_property = radeon_lvds_set_property,
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200565};
566
567static int radeon_vga_get_modes(struct drm_connector *connector)
568{
569 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
570 int ret;
571
572 ret = radeon_ddc_get_modes(radeon_connector);
573
574 return ret;
575}
576
577static int radeon_vga_mode_valid(struct drm_connector *connector,
578 struct drm_display_mode *mode)
579{
Alex Deuchera3fa6322009-11-05 11:57:07 -0500580 /* XXX check mode bandwidth */
581 /* XXX verify against max DAC output frequency */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200582 return MODE_OK;
583}
584
585static enum drm_connector_status radeon_vga_detect(struct drm_connector *connector)
586{
587 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
588 struct drm_encoder *encoder;
589 struct drm_encoder_helper_funcs *encoder_funcs;
Dave Airlie4b9d2a22010-02-08 13:16:55 +1000590 bool dret = false;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200591 enum drm_connector_status ret = connector_status_disconnected;
592
Dave Airlie4ce001a2009-08-13 16:32:14 +1000593 encoder = radeon_best_single_encoder(connector);
594 if (!encoder)
595 ret = connector_status_disconnected;
596
Dave Airlieeb6b6d72010-02-25 13:44:04 +1000597 if (radeon_connector->ddc_bus)
Dave Airlie4b9d2a22010-02-08 13:16:55 +1000598 dret = radeon_ddc_probe(radeon_connector);
Alex Deucher0294cf4f2009-10-15 16:16:35 -0400599 if (dret) {
600 if (radeon_connector->edid) {
601 kfree(radeon_connector->edid);
602 radeon_connector->edid = NULL;
603 }
Alex Deucher0294cf4f2009-10-15 16:16:35 -0400604 radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter);
Alex Deucher0294cf4f2009-10-15 16:16:35 -0400605
606 if (!radeon_connector->edid) {
Jerome Glissef82f5f32009-11-12 14:13:53 +0100607 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
608 drm_get_connector_name(connector));
609 ret = connector_status_connected;
Alex Deucher0294cf4f2009-10-15 16:16:35 -0400610 } else {
611 radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL);
612
613 /* some oems have boards with separate digital and analog connectors
614 * with a shared ddc line (often vga + hdmi)
615 */
616 if (radeon_connector->use_digital && radeon_connector->shared_ddc) {
617 kfree(radeon_connector->edid);
618 radeon_connector->edid = NULL;
619 ret = connector_status_disconnected;
620 } else
621 ret = connector_status_connected;
622 }
623 } else {
Darren Jenkinsd8a7f792009-12-30 12:22:55 +1100624 if (radeon_connector->dac_load_detect && encoder) {
Dave Airlie445282d2009-09-09 17:40:54 +1000625 encoder_funcs = encoder->helper_private;
626 ret = encoder_funcs->detect(encoder, connector);
627 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200628 }
629
Dave Airlie4ce001a2009-08-13 16:32:14 +1000630 if (ret == connector_status_connected)
631 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200632 radeon_connector_update_scratch_regs(connector, ret);
633 return ret;
634}
635
636struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs = {
637 .get_modes = radeon_vga_get_modes,
638 .mode_valid = radeon_vga_mode_valid,
639 .best_encoder = radeon_best_single_encoder,
640};
641
642struct drm_connector_funcs radeon_vga_connector_funcs = {
643 .dpms = drm_helper_connector_dpms,
644 .detect = radeon_vga_detect,
645 .fill_modes = drm_helper_probe_single_connector_modes,
646 .destroy = radeon_connector_destroy,
647 .set_property = radeon_connector_set_property,
648};
649
Dave Airlie4ce001a2009-08-13 16:32:14 +1000650static int radeon_tv_get_modes(struct drm_connector *connector)
651{
652 struct drm_device *dev = connector->dev;
Alex Deucher923f6842009-09-10 17:53:39 -0400653 struct radeon_device *rdev = dev->dev_private;
Dave Airlie4ce001a2009-08-13 16:32:14 +1000654 struct drm_display_mode *tv_mode;
Alex Deucher923f6842009-09-10 17:53:39 -0400655 struct drm_encoder *encoder;
Dave Airlie4ce001a2009-08-13 16:32:14 +1000656
Alex Deucher923f6842009-09-10 17:53:39 -0400657 encoder = radeon_best_single_encoder(connector);
658 if (!encoder)
659 return 0;
Dave Airlie4ce001a2009-08-13 16:32:14 +1000660
Alex Deucher923f6842009-09-10 17:53:39 -0400661 /* avivo chips can scale any mode */
662 if (rdev->family >= CHIP_RS600)
663 /* add scaled modes */
664 radeon_add_common_modes(encoder, connector);
665 else {
666 /* only 800x600 is supported right now on pre-avivo chips */
Dave Airlied50ba252009-09-23 14:44:08 +1000667 tv_mode = drm_cvt_mode(dev, 800, 600, 60, false, false, false);
Alex Deucher923f6842009-09-10 17:53:39 -0400668 tv_mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
669 drm_mode_probed_add(connector, tv_mode);
670 }
Dave Airlie4ce001a2009-08-13 16:32:14 +1000671 return 1;
672}
673
674static int radeon_tv_mode_valid(struct drm_connector *connector,
675 struct drm_display_mode *mode)
676{
Alex Deuchera3fa6322009-11-05 11:57:07 -0500677 if ((mode->hdisplay > 1024) || (mode->vdisplay > 768))
678 return MODE_CLOCK_RANGE;
Dave Airlie4ce001a2009-08-13 16:32:14 +1000679 return MODE_OK;
680}
681
682static enum drm_connector_status radeon_tv_detect(struct drm_connector *connector)
683{
684 struct drm_encoder *encoder;
685 struct drm_encoder_helper_funcs *encoder_funcs;
Dave Airlie445282d2009-09-09 17:40:54 +1000686 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
687 enum drm_connector_status ret = connector_status_disconnected;
688
689 if (!radeon_connector->dac_load_detect)
690 return ret;
Dave Airlie4ce001a2009-08-13 16:32:14 +1000691
692 encoder = radeon_best_single_encoder(connector);
693 if (!encoder)
694 ret = connector_status_disconnected;
695 else {
696 encoder_funcs = encoder->helper_private;
697 ret = encoder_funcs->detect(encoder, connector);
698 }
699 if (ret == connector_status_connected)
700 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false);
701 radeon_connector_update_scratch_regs(connector, ret);
702 return ret;
703}
704
705struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs = {
706 .get_modes = radeon_tv_get_modes,
707 .mode_valid = radeon_tv_mode_valid,
708 .best_encoder = radeon_best_single_encoder,
709};
710
711struct drm_connector_funcs radeon_tv_connector_funcs = {
712 .dpms = drm_helper_connector_dpms,
713 .detect = radeon_tv_detect,
714 .fill_modes = drm_helper_probe_single_connector_modes,
715 .destroy = radeon_connector_destroy,
716 .set_property = radeon_connector_set_property,
717};
718
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200719static int radeon_dvi_get_modes(struct drm_connector *connector)
720{
721 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
722 int ret;
723
724 ret = radeon_ddc_get_modes(radeon_connector);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200725 return ret;
726}
727
Dave Airlie4ce001a2009-08-13 16:32:14 +1000728/*
729 * DVI is complicated
730 * Do a DDC probe, if DDC probe passes, get the full EDID so
731 * we can do analog/digital monitor detection at this point.
732 * If the monitor is an analog monitor or we got no DDC,
733 * we need to find the DAC encoder object for this connector.
734 * If we got no DDC, we do load detection on the DAC encoder object.
735 * If we got analog DDC or load detection passes on the DAC encoder
736 * we have to check if this analog encoder is shared with anyone else (TV)
737 * if its shared we have to set the other connector to disconnected.
738 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200739static enum drm_connector_status radeon_dvi_detect(struct drm_connector *connector)
740{
741 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
Dave Airlie4ce001a2009-08-13 16:32:14 +1000742 struct drm_encoder *encoder = NULL;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200743 struct drm_encoder_helper_funcs *encoder_funcs;
744 struct drm_mode_object *obj;
745 int i;
746 enum drm_connector_status ret = connector_status_disconnected;
Dave Airlie4b9d2a22010-02-08 13:16:55 +1000747 bool dret = false;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200748
Dave Airlieeb6b6d72010-02-25 13:44:04 +1000749 if (radeon_connector->ddc_bus)
Dave Airlie4b9d2a22010-02-08 13:16:55 +1000750 dret = radeon_ddc_probe(radeon_connector);
Dave Airlie4ce001a2009-08-13 16:32:14 +1000751 if (dret) {
Alex Deucher0294cf4f2009-10-15 16:16:35 -0400752 if (radeon_connector->edid) {
753 kfree(radeon_connector->edid);
754 radeon_connector->edid = NULL;
755 }
Dave Airlie4ce001a2009-08-13 16:32:14 +1000756 radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200757
Dave Airlie4ce001a2009-08-13 16:32:14 +1000758 if (!radeon_connector->edid) {
Jerome Glissef82f5f32009-11-12 14:13:53 +0100759 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
760 drm_get_connector_name(connector));
Dave Airlie4ce001a2009-08-13 16:32:14 +1000761 } else {
762 radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200763
Alex Deucher0294cf4f2009-10-15 16:16:35 -0400764 /* some oems have boards with separate digital and analog connectors
765 * with a shared ddc line (often vga + hdmi)
766 */
767 if ((!radeon_connector->use_digital) && radeon_connector->shared_ddc) {
768 kfree(radeon_connector->edid);
769 radeon_connector->edid = NULL;
770 ret = connector_status_disconnected;
771 } else
772 ret = connector_status_connected;
Alex Deucher71407c42009-11-17 15:44:01 -0500773
774 /* multiple connectors on the same encoder with the same ddc line
775 * This tends to be HDMI and DVI on the same encoder with the
776 * same ddc line. If the edid says HDMI, consider the HDMI port
777 * connected and the DVI port disconnected. If the edid doesn't
778 * say HDMI, vice versa.
779 */
Alex Deucherd3932d62010-02-19 02:13:56 -0500780 if (radeon_connector->shared_ddc && (ret == connector_status_connected)) {
Alex Deucher71407c42009-11-17 15:44:01 -0500781 struct drm_device *dev = connector->dev;
782 struct drm_connector *list_connector;
783 struct radeon_connector *list_radeon_connector;
784 list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) {
785 if (connector == list_connector)
786 continue;
787 list_radeon_connector = to_radeon_connector(list_connector);
788 if (radeon_connector->devices == list_radeon_connector->devices) {
789 if (drm_detect_hdmi_monitor(radeon_connector->edid)) {
790 if (connector->connector_type == DRM_MODE_CONNECTOR_DVID) {
791 kfree(radeon_connector->edid);
792 radeon_connector->edid = NULL;
793 ret = connector_status_disconnected;
794 }
795 } else {
796 if ((connector->connector_type == DRM_MODE_CONNECTOR_HDMIA) ||
797 (connector->connector_type == DRM_MODE_CONNECTOR_HDMIB)) {
798 kfree(radeon_connector->edid);
799 radeon_connector->edid = NULL;
800 ret = connector_status_disconnected;
801 }
802 }
803 }
804 }
805 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200806 }
807 }
808
Dave Airlie4ce001a2009-08-13 16:32:14 +1000809 if ((ret == connector_status_connected) && (radeon_connector->use_digital == true))
810 goto out;
811
812 /* find analog encoder */
Dave Airlie445282d2009-09-09 17:40:54 +1000813 if (radeon_connector->dac_load_detect) {
814 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
815 if (connector->encoder_ids[i] == 0)
816 break;
Dave Airlie4ce001a2009-08-13 16:32:14 +1000817
Dave Airlie445282d2009-09-09 17:40:54 +1000818 obj = drm_mode_object_find(connector->dev,
819 connector->encoder_ids[i],
820 DRM_MODE_OBJECT_ENCODER);
821 if (!obj)
822 continue;
Dave Airlie4ce001a2009-08-13 16:32:14 +1000823
Dave Airlie445282d2009-09-09 17:40:54 +1000824 encoder = obj_to_encoder(obj);
Dave Airlie4ce001a2009-08-13 16:32:14 +1000825
Dave Airlie445282d2009-09-09 17:40:54 +1000826 encoder_funcs = encoder->helper_private;
827 if (encoder_funcs->detect) {
828 if (ret != connector_status_connected) {
829 ret = encoder_funcs->detect(encoder, connector);
830 if (ret == connector_status_connected) {
831 radeon_connector->use_digital = false;
832 }
Dave Airlie4ce001a2009-08-13 16:32:14 +1000833 }
Dave Airlie445282d2009-09-09 17:40:54 +1000834 break;
Dave Airlie4ce001a2009-08-13 16:32:14 +1000835 }
Dave Airlie4ce001a2009-08-13 16:32:14 +1000836 }
837 }
838
839 if ((ret == connector_status_connected) && (radeon_connector->use_digital == false) &&
840 encoder) {
841 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true);
842 }
843
844out:
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200845 /* updated in get modes as well since we need to know if it's analog or digital */
846 radeon_connector_update_scratch_regs(connector, ret);
847 return ret;
848}
849
850/* okay need to be smart in here about which encoder to pick */
851struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector)
852{
853 int enc_id = connector->encoder_ids[0];
854 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
855 struct drm_mode_object *obj;
856 struct drm_encoder *encoder;
857 int i;
858 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
859 if (connector->encoder_ids[i] == 0)
860 break;
861
862 obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER);
863 if (!obj)
864 continue;
865
866 encoder = obj_to_encoder(obj);
867
Dave Airlie4ce001a2009-08-13 16:32:14 +1000868 if (radeon_connector->use_digital == true) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200869 if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS)
870 return encoder;
871 } else {
872 if (encoder->encoder_type == DRM_MODE_ENCODER_DAC ||
873 encoder->encoder_type == DRM_MODE_ENCODER_TVDAC)
874 return encoder;
875 }
876 }
877
878 /* see if we have a default encoder TODO */
879
880 /* then check use digitial */
881 /* pick the first one */
882 if (enc_id) {
883 obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER);
884 if (!obj)
885 return NULL;
886 encoder = obj_to_encoder(obj);
887 return encoder;
888 }
889 return NULL;
890}
891
Dave Airlied50ba252009-09-23 14:44:08 +1000892static void radeon_dvi_force(struct drm_connector *connector)
893{
894 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
895 if (connector->force == DRM_FORCE_ON)
896 radeon_connector->use_digital = false;
897 if (connector->force == DRM_FORCE_ON_DIGITAL)
898 radeon_connector->use_digital = true;
899}
900
Alex Deuchera3fa6322009-11-05 11:57:07 -0500901static int radeon_dvi_mode_valid(struct drm_connector *connector,
902 struct drm_display_mode *mode)
903{
Alex Deucher1b242032010-01-11 15:02:31 -0500904 struct drm_device *dev = connector->dev;
905 struct radeon_device *rdev = dev->dev_private;
Alex Deuchera3fa6322009-11-05 11:57:07 -0500906 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
907
908 /* XXX check mode bandwidth */
909
Alex Deucher1b242032010-01-11 15:02:31 -0500910 /* clocks over 135 MHz have heat issues with DVI on RV100 */
911 if (radeon_connector->use_digital &&
912 (rdev->family == CHIP_RV100) &&
913 (mode->clock > 135000))
914 return MODE_CLOCK_HIGH;
915
Alex Deuchera3fa6322009-11-05 11:57:07 -0500916 if (radeon_connector->use_digital && (mode->clock > 165000)) {
917 if ((radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I) ||
918 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) ||
919 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B))
920 return MODE_OK;
921 else
922 return MODE_CLOCK_HIGH;
923 }
924 return MODE_OK;
925}
926
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200927struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs = {
928 .get_modes = radeon_dvi_get_modes,
Alex Deuchera3fa6322009-11-05 11:57:07 -0500929 .mode_valid = radeon_dvi_mode_valid,
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200930 .best_encoder = radeon_dvi_encoder,
931};
932
933struct drm_connector_funcs radeon_dvi_connector_funcs = {
934 .dpms = drm_helper_connector_dpms,
935 .detect = radeon_dvi_detect,
936 .fill_modes = drm_helper_probe_single_connector_modes,
937 .set_property = radeon_connector_set_property,
938 .destroy = radeon_connector_destroy,
Dave Airlied50ba252009-09-23 14:44:08 +1000939 .force = radeon_dvi_force,
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200940};
941
Alex Deucherffd09c62009-11-24 16:13:23 -0500942static void radeon_dp_connector_destroy(struct drm_connector *connector)
943{
944 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
945 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
946
947 if (radeon_connector->ddc_bus)
948 radeon_i2c_destroy(radeon_connector->ddc_bus);
949 if (radeon_connector->edid)
950 kfree(radeon_connector->edid);
951 if (radeon_dig_connector->dp_i2c_bus)
Alex Deucherac1aade2010-03-14 12:22:44 -0400952 radeon_i2c_destroy(radeon_dig_connector->dp_i2c_bus);
Alex Deucherffd09c62009-11-24 16:13:23 -0500953 kfree(radeon_connector->con_priv);
954 drm_sysfs_connector_remove(connector);
955 drm_connector_cleanup(connector);
956 kfree(connector);
957}
958
Dave Airlie746c1aa2009-12-08 07:07:28 +1000959static int radeon_dp_get_modes(struct drm_connector *connector)
960{
961 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
962 int ret;
963
964 ret = radeon_ddc_get_modes(radeon_connector);
965 return ret;
966}
967
968static enum drm_connector_status radeon_dp_detect(struct drm_connector *connector)
969{
970 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
Dave Airlie746c1aa2009-12-08 07:07:28 +1000971 enum drm_connector_status ret = connector_status_disconnected;
Alex Deucher4143e912009-11-23 18:02:35 -0500972 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
973 u8 sink_type;
Dave Airlie746c1aa2009-12-08 07:07:28 +1000974
975 if (radeon_connector->edid) {
976 kfree(radeon_connector->edid);
977 radeon_connector->edid = NULL;
978 }
979
980 sink_type = radeon_dp_getsinktype(radeon_connector);
Alex Deucher196c58d2010-01-07 14:22:32 -0500981 if ((sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) ||
982 (sink_type == CONNECTOR_OBJECT_ID_eDP)) {
Alex Deucher9fa05c92009-11-27 13:01:46 -0500983 if (radeon_dp_getdpcd(radeon_connector)) {
984 radeon_dig_connector->dp_sink_type = sink_type;
985 ret = connector_status_connected;
986 }
Alex Deucher4143e912009-11-23 18:02:35 -0500987 } else {
Alex Deucher4143e912009-11-23 18:02:35 -0500988 if (radeon_ddc_probe(radeon_connector)) {
989 radeon_dig_connector->dp_sink_type = sink_type;
990 ret = connector_status_connected;
991 }
Dave Airlie746c1aa2009-12-08 07:07:28 +1000992 }
Alex Deucher4143e912009-11-23 18:02:35 -0500993
Dave Airlie746c1aa2009-12-08 07:07:28 +1000994 return ret;
995}
996
Alex Deucher5801ead2009-11-24 13:32:59 -0500997static int radeon_dp_mode_valid(struct drm_connector *connector,
998 struct drm_display_mode *mode)
999{
1000 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1001 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
1002
1003 /* XXX check mode bandwidth */
1004
Alex Deucher196c58d2010-01-07 14:22:32 -05001005 if ((radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) ||
1006 (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP))
Alex Deucher5801ead2009-11-24 13:32:59 -05001007 return radeon_dp_mode_valid_helper(radeon_connector, mode);
1008 else
1009 return MODE_OK;
1010}
1011
Dave Airlie746c1aa2009-12-08 07:07:28 +10001012struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = {
1013 .get_modes = radeon_dp_get_modes,
Alex Deucher5801ead2009-11-24 13:32:59 -05001014 .mode_valid = radeon_dp_mode_valid,
Dave Airlie746c1aa2009-12-08 07:07:28 +10001015 .best_encoder = radeon_dvi_encoder,
1016};
1017
1018struct drm_connector_funcs radeon_dp_connector_funcs = {
1019 .dpms = drm_helper_connector_dpms,
1020 .detect = radeon_dp_detect,
1021 .fill_modes = drm_helper_probe_single_connector_modes,
1022 .set_property = radeon_connector_set_property,
Alex Deucherffd09c62009-11-24 16:13:23 -05001023 .destroy = radeon_dp_connector_destroy,
Dave Airlie746c1aa2009-12-08 07:07:28 +10001024 .force = radeon_dvi_force,
1025};
1026
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001027void
1028radeon_add_atom_connector(struct drm_device *dev,
1029 uint32_t connector_id,
1030 uint32_t supported_device,
1031 int connector_type,
1032 struct radeon_i2c_bus_rec *i2c_bus,
1033 bool linkb,
Alex Deucherb75fad02009-11-05 13:16:01 -05001034 uint32_t igp_lane_info,
Alex Deuchereed45b32009-12-04 14:45:27 -05001035 uint16_t connector_object_id,
1036 struct radeon_hpd *hpd)
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001037{
Dave Airlie445282d2009-09-09 17:40:54 +10001038 struct radeon_device *rdev = dev->dev_private;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001039 struct drm_connector *connector;
1040 struct radeon_connector *radeon_connector;
1041 struct radeon_connector_atom_dig *radeon_dig_connector;
1042 uint32_t subpixel_order = SubPixelNone;
Alex Deucher0294cf4f2009-10-15 16:16:35 -04001043 bool shared_ddc = false;
Dave Airlied50ba252009-09-23 14:44:08 +10001044 int ret;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001045
1046 /* fixme - tv/cv/din */
Dave Airlie4ce001a2009-08-13 16:32:14 +10001047 if (connector_type == DRM_MODE_CONNECTOR_Unknown)
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001048 return;
1049
1050 /* see if we already added it */
1051 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1052 radeon_connector = to_radeon_connector(connector);
1053 if (radeon_connector->connector_id == connector_id) {
1054 radeon_connector->devices |= supported_device;
1055 return;
1056 }
Alex Deucher0294cf4f2009-10-15 16:16:35 -04001057 if (radeon_connector->ddc_bus && i2c_bus->valid) {
Alex Deucherd3932d62010-02-19 02:13:56 -05001058 if (radeon_connector->ddc_bus->rec.i2c_id == i2c_bus->i2c_id) {
Alex Deucher0294cf4f2009-10-15 16:16:35 -04001059 radeon_connector->shared_ddc = true;
1060 shared_ddc = true;
1061 }
1062 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001063 }
1064
1065 radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL);
1066 if (!radeon_connector)
1067 return;
1068
1069 connector = &radeon_connector->base;
1070
1071 radeon_connector->connector_id = connector_id;
1072 radeon_connector->devices = supported_device;
Alex Deucher0294cf4f2009-10-15 16:16:35 -04001073 radeon_connector->shared_ddc = shared_ddc;
Alex Deucherb75fad02009-11-05 13:16:01 -05001074 radeon_connector->connector_object_id = connector_object_id;
Alex Deuchereed45b32009-12-04 14:45:27 -05001075 radeon_connector->hpd = *hpd;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001076 switch (connector_type) {
1077 case DRM_MODE_CONNECTOR_VGA:
1078 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
Dave Airlie74bf2ad2009-09-28 15:31:10 +10001079 ret = drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
1080 if (ret)
1081 goto failed;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001082 if (i2c_bus->valid) {
1083 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "VGA");
1084 if (!radeon_connector->ddc_bus)
1085 goto failed;
1086 }
Dave Airlie35e4b7a2009-09-25 11:56:50 +10001087 radeon_connector->dac_load_detect = true;
Dave Airlie445282d2009-09-09 17:40:54 +10001088 drm_connector_attach_property(&radeon_connector->base,
1089 rdev->mode_info.load_detect_property,
1090 1);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001091 break;
1092 case DRM_MODE_CONNECTOR_DVIA:
1093 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
Dave Airlie74bf2ad2009-09-28 15:31:10 +10001094 ret = drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
1095 if (ret)
1096 goto failed;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001097 if (i2c_bus->valid) {
1098 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI");
1099 if (!radeon_connector->ddc_bus)
1100 goto failed;
1101 }
Dave Airlie35e4b7a2009-09-25 11:56:50 +10001102 radeon_connector->dac_load_detect = true;
Dave Airlie445282d2009-09-09 17:40:54 +10001103 drm_connector_attach_property(&radeon_connector->base,
1104 rdev->mode_info.load_detect_property,
1105 1);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001106 break;
1107 case DRM_MODE_CONNECTOR_DVII:
1108 case DRM_MODE_CONNECTOR_DVID:
1109 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL);
1110 if (!radeon_dig_connector)
1111 goto failed;
1112 radeon_dig_connector->linkb = linkb;
1113 radeon_dig_connector->igp_lane_info = igp_lane_info;
1114 radeon_connector->con_priv = radeon_dig_connector;
1115 drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type);
Dave Airlie74bf2ad2009-09-28 15:31:10 +10001116 ret = drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs);
1117 if (ret)
1118 goto failed;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001119 if (i2c_bus->valid) {
1120 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI");
1121 if (!radeon_connector->ddc_bus)
1122 goto failed;
1123 }
1124 subpixel_order = SubPixelHorizontalRGB;
Dave Airlie445282d2009-09-09 17:40:54 +10001125 drm_connector_attach_property(&radeon_connector->base,
1126 rdev->mode_info.coherent_mode_property,
1127 1);
Alex Deucher390d0bb2009-12-08 12:48:20 -05001128 if (connector_type == DRM_MODE_CONNECTOR_DVII) {
1129 radeon_connector->dac_load_detect = true;
1130 drm_connector_attach_property(&radeon_connector->base,
1131 rdev->mode_info.load_detect_property,
1132 1);
1133 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001134 break;
1135 case DRM_MODE_CONNECTOR_HDMIA:
1136 case DRM_MODE_CONNECTOR_HDMIB:
1137 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL);
1138 if (!radeon_dig_connector)
1139 goto failed;
1140 radeon_dig_connector->linkb = linkb;
1141 radeon_dig_connector->igp_lane_info = igp_lane_info;
1142 radeon_connector->con_priv = radeon_dig_connector;
1143 drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type);
Dave Airlie74bf2ad2009-09-28 15:31:10 +10001144 ret = drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs);
1145 if (ret)
1146 goto failed;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001147 if (i2c_bus->valid) {
1148 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "HDMI");
1149 if (!radeon_connector->ddc_bus)
1150 goto failed;
1151 }
Dave Airlie445282d2009-09-09 17:40:54 +10001152 drm_connector_attach_property(&radeon_connector->base,
1153 rdev->mode_info.coherent_mode_property,
1154 1);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001155 subpixel_order = SubPixelHorizontalRGB;
1156 break;
1157 case DRM_MODE_CONNECTOR_DisplayPort:
Alex Deucher196c58d2010-01-07 14:22:32 -05001158 case DRM_MODE_CONNECTOR_eDP:
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001159 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL);
1160 if (!radeon_dig_connector)
1161 goto failed;
1162 radeon_dig_connector->linkb = linkb;
1163 radeon_dig_connector->igp_lane_info = igp_lane_info;
1164 radeon_connector->con_priv = radeon_dig_connector;
Dave Airlie746c1aa2009-12-08 07:07:28 +10001165 drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type);
1166 ret = drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs);
Dave Airlie74bf2ad2009-09-28 15:31:10 +10001167 if (ret)
1168 goto failed;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001169 if (i2c_bus->valid) {
Alex Deucher390d0bb2009-12-08 12:48:20 -05001170 /* add DP i2c bus */
Alex Deucher196c58d2010-01-07 14:22:32 -05001171 if (connector_type == DRM_MODE_CONNECTOR_eDP)
1172 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch");
1173 else
1174 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch");
Alex Deucher390d0bb2009-12-08 12:48:20 -05001175 if (!radeon_dig_connector->dp_i2c_bus)
1176 goto failed;
Alex Deucher196c58d2010-01-07 14:22:32 -05001177 if (connector_type == DRM_MODE_CONNECTOR_eDP)
1178 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "eDP");
1179 else
1180 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DP");
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001181 if (!radeon_connector->ddc_bus)
1182 goto failed;
1183 }
1184 subpixel_order = SubPixelHorizontalRGB;
Alex Deucher390d0bb2009-12-08 12:48:20 -05001185 drm_connector_attach_property(&radeon_connector->base,
1186 rdev->mode_info.coherent_mode_property,
1187 1);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001188 break;
1189 case DRM_MODE_CONNECTOR_SVIDEO:
1190 case DRM_MODE_CONNECTOR_Composite:
1191 case DRM_MODE_CONNECTOR_9PinDIN:
Dave Airlie4ce001a2009-08-13 16:32:14 +10001192 if (radeon_tv == 1) {
1193 drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type);
Dave Airlie74bf2ad2009-09-28 15:31:10 +10001194 ret = drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs);
1195 if (ret)
1196 goto failed;
1197 radeon_connector->dac_load_detect = true;
1198 drm_connector_attach_property(&radeon_connector->base,
1199 rdev->mode_info.load_detect_property,
1200 1);
Alex Deuchered160142009-12-01 14:12:14 -05001201 drm_connector_attach_property(&radeon_connector->base,
1202 rdev->mode_info.tv_std_property,
Alex Deucherd79766f2009-12-17 19:00:29 -05001203 radeon_atombios_get_tv_info(rdev));
Dave Airlie4ce001a2009-08-13 16:32:14 +10001204 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001205 break;
1206 case DRM_MODE_CONNECTOR_LVDS:
1207 radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL);
1208 if (!radeon_dig_connector)
1209 goto failed;
1210 radeon_dig_connector->linkb = linkb;
1211 radeon_dig_connector->igp_lane_info = igp_lane_info;
1212 radeon_connector->con_priv = radeon_dig_connector;
1213 drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type);
Dave Airlie74bf2ad2009-09-28 15:31:10 +10001214 ret = drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs);
1215 if (ret)
1216 goto failed;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001217 if (i2c_bus->valid) {
1218 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "LVDS");
1219 if (!radeon_connector->ddc_bus)
1220 goto failed;
1221 }
Dave Airlie445282d2009-09-09 17:40:54 +10001222 drm_connector_attach_property(&radeon_connector->base,
1223 dev->mode_config.scaling_mode_property,
1224 DRM_MODE_SCALE_FULLSCREEN);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001225 subpixel_order = SubPixelHorizontalRGB;
1226 break;
1227 }
1228
1229 connector->display_info.subpixel_order = subpixel_order;
1230 drm_sysfs_connector_add(connector);
1231 return;
1232
1233failed:
1234 if (radeon_connector->ddc_bus)
1235 radeon_i2c_destroy(radeon_connector->ddc_bus);
1236 drm_connector_cleanup(connector);
1237 kfree(connector);
1238}
1239
1240void
1241radeon_add_legacy_connector(struct drm_device *dev,
1242 uint32_t connector_id,
1243 uint32_t supported_device,
1244 int connector_type,
Alex Deucherb75fad02009-11-05 13:16:01 -05001245 struct radeon_i2c_bus_rec *i2c_bus,
Alex Deuchereed45b32009-12-04 14:45:27 -05001246 uint16_t connector_object_id,
1247 struct radeon_hpd *hpd)
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001248{
Dave Airlie445282d2009-09-09 17:40:54 +10001249 struct radeon_device *rdev = dev->dev_private;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001250 struct drm_connector *connector;
1251 struct radeon_connector *radeon_connector;
1252 uint32_t subpixel_order = SubPixelNone;
Dave Airlied50ba252009-09-23 14:44:08 +10001253 int ret;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001254
1255 /* fixme - tv/cv/din */
Dave Airlie4ce001a2009-08-13 16:32:14 +10001256 if (connector_type == DRM_MODE_CONNECTOR_Unknown)
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001257 return;
1258
1259 /* see if we already added it */
1260 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1261 radeon_connector = to_radeon_connector(connector);
1262 if (radeon_connector->connector_id == connector_id) {
1263 radeon_connector->devices |= supported_device;
1264 return;
1265 }
1266 }
1267
1268 radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL);
1269 if (!radeon_connector)
1270 return;
1271
1272 connector = &radeon_connector->base;
1273
1274 radeon_connector->connector_id = connector_id;
1275 radeon_connector->devices = supported_device;
Alex Deucherb75fad02009-11-05 13:16:01 -05001276 radeon_connector->connector_object_id = connector_object_id;
Alex Deuchereed45b32009-12-04 14:45:27 -05001277 radeon_connector->hpd = *hpd;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001278 switch (connector_type) {
1279 case DRM_MODE_CONNECTOR_VGA:
1280 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
Dave Airlie74bf2ad2009-09-28 15:31:10 +10001281 ret = drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
1282 if (ret)
1283 goto failed;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001284 if (i2c_bus->valid) {
1285 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "VGA");
1286 if (!radeon_connector->ddc_bus)
1287 goto failed;
1288 }
Dave Airlie35e4b7a2009-09-25 11:56:50 +10001289 radeon_connector->dac_load_detect = true;
Dave Airlie445282d2009-09-09 17:40:54 +10001290 drm_connector_attach_property(&radeon_connector->base,
1291 rdev->mode_info.load_detect_property,
1292 1);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001293 break;
1294 case DRM_MODE_CONNECTOR_DVIA:
1295 drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
Dave Airlie74bf2ad2009-09-28 15:31:10 +10001296 ret = drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
1297 if (ret)
1298 goto failed;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001299 if (i2c_bus->valid) {
1300 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI");
1301 if (!radeon_connector->ddc_bus)
1302 goto failed;
1303 }
Dave Airlie35e4b7a2009-09-25 11:56:50 +10001304 radeon_connector->dac_load_detect = true;
Dave Airlie445282d2009-09-09 17:40:54 +10001305 drm_connector_attach_property(&radeon_connector->base,
1306 rdev->mode_info.load_detect_property,
1307 1);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001308 break;
1309 case DRM_MODE_CONNECTOR_DVII:
1310 case DRM_MODE_CONNECTOR_DVID:
1311 drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type);
Dave Airlie74bf2ad2009-09-28 15:31:10 +10001312 ret = drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs);
1313 if (ret)
1314 goto failed;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001315 if (i2c_bus->valid) {
1316 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI");
1317 if (!radeon_connector->ddc_bus)
1318 goto failed;
Dave Airlie35e4b7a2009-09-25 11:56:50 +10001319 radeon_connector->dac_load_detect = true;
Dave Airlie445282d2009-09-09 17:40:54 +10001320 drm_connector_attach_property(&radeon_connector->base,
1321 rdev->mode_info.load_detect_property,
1322 1);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001323 }
1324 subpixel_order = SubPixelHorizontalRGB;
1325 break;
1326 case DRM_MODE_CONNECTOR_SVIDEO:
1327 case DRM_MODE_CONNECTOR_Composite:
1328 case DRM_MODE_CONNECTOR_9PinDIN:
Dave Airlie4ce001a2009-08-13 16:32:14 +10001329 if (radeon_tv == 1) {
1330 drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type);
Dave Airlie74bf2ad2009-09-28 15:31:10 +10001331 ret = drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs);
1332 if (ret)
1333 goto failed;
Dave Airlie35e4b7a2009-09-25 11:56:50 +10001334 radeon_connector->dac_load_detect = true;
Jerome Glisse0beb81a2009-11-13 20:56:35 +01001335 /* RS400,RC410,RS480 chipset seems to report a lot
1336 * of false positive on load detect, we haven't yet
1337 * found a way to make load detect reliable on those
1338 * chipset, thus just disable it for TV.
1339 */
1340 if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480)
1341 radeon_connector->dac_load_detect = false;
Dave Airlie445282d2009-09-09 17:40:54 +10001342 drm_connector_attach_property(&radeon_connector->base,
1343 rdev->mode_info.load_detect_property,
Dave Airlie624ab4f2010-01-27 16:07:15 +10001344 radeon_connector->dac_load_detect);
Alex Deuchered160142009-12-01 14:12:14 -05001345 drm_connector_attach_property(&radeon_connector->base,
1346 rdev->mode_info.tv_std_property,
Alex Deucherd79766f2009-12-17 19:00:29 -05001347 radeon_combios_get_tv_info(rdev));
Dave Airlie4ce001a2009-08-13 16:32:14 +10001348 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001349 break;
1350 case DRM_MODE_CONNECTOR_LVDS:
1351 drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type);
Dave Airlie74bf2ad2009-09-28 15:31:10 +10001352 ret = drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs);
1353 if (ret)
1354 goto failed;
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001355 if (i2c_bus->valid) {
1356 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "LVDS");
1357 if (!radeon_connector->ddc_bus)
1358 goto failed;
1359 }
Dave Airlie445282d2009-09-09 17:40:54 +10001360 drm_connector_attach_property(&radeon_connector->base,
1361 dev->mode_config.scaling_mode_property,
1362 DRM_MODE_SCALE_FULLSCREEN);
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001363 subpixel_order = SubPixelHorizontalRGB;
1364 break;
1365 }
1366
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001367 connector->display_info.subpixel_order = subpixel_order;
1368 drm_sysfs_connector_add(connector);
1369 return;
1370
1371failed:
1372 if (radeon_connector->ddc_bus)
1373 radeon_i2c_destroy(radeon_connector->ddc_bus);
1374 drm_connector_cleanup(connector);
1375 kfree(connector);
1376}