2 * Copyright 2007-8 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
23 * Authors: Dave Airlie
27 #include <drm/drm_edid.h>
28 #include <drm/drm_crtc_helper.h>
29 #include <drm/drm_fb_helper.h>
30 #include <drm/amdgpu_drm.h>
33 #include "atombios_encoders.h"
34 #include "atombios_dp.h"
35 #include "amdgpu_connectors.h"
36 #include "amdgpu_i2c.h"
38 #include <linux/pm_runtime.h>
40 void amdgpu_connector_hotplug(struct drm_connector
*connector
)
42 struct drm_device
*dev
= connector
->dev
;
43 struct amdgpu_device
*adev
= dev
->dev_private
;
44 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
46 /* bail if the connector does not have hpd pin, e.g.,
49 if (amdgpu_connector
->hpd
.hpd
== AMDGPU_HPD_NONE
)
52 amdgpu_display_hpd_set_polarity(adev
, amdgpu_connector
->hpd
.hpd
);
54 /* if the connector is already off, don't turn it back on */
55 if (connector
->dpms
!= DRM_MODE_DPMS_ON
)
58 /* just deal with DP (not eDP) here. */
59 if (connector
->connector_type
== DRM_MODE_CONNECTOR_DisplayPort
) {
60 struct amdgpu_connector_atom_dig
*dig_connector
=
61 amdgpu_connector
->con_priv
;
63 /* if existing sink type was not DP no need to retrain */
64 if (dig_connector
->dp_sink_type
!= CONNECTOR_OBJECT_ID_DISPLAYPORT
)
67 /* first get sink type as it may be reset after (un)plug */
68 dig_connector
->dp_sink_type
= amdgpu_atombios_dp_get_sinktype(amdgpu_connector
);
69 /* don't do anything if sink is not display port, i.e.,
70 * passive dp->(dvi|hdmi) adaptor
72 if (dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
&&
73 amdgpu_display_hpd_sense(adev
, amdgpu_connector
->hpd
.hpd
) &&
74 amdgpu_atombios_dp_needs_link_train(amdgpu_connector
)) {
75 /* Don't start link training before we have the DPCD */
76 if (amdgpu_atombios_dp_get_dpcd(amdgpu_connector
))
79 /* Turn the connector off and back on immediately, which
80 * will trigger link training
82 drm_helper_connector_dpms(connector
, DRM_MODE_DPMS_OFF
);
83 drm_helper_connector_dpms(connector
, DRM_MODE_DPMS_ON
);
88 static void amdgpu_connector_property_change_mode(struct drm_encoder
*encoder
)
90 struct drm_crtc
*crtc
= encoder
->crtc
;
92 if (crtc
&& crtc
->enabled
) {
93 drm_crtc_helper_set_mode(crtc
, &crtc
->mode
,
94 crtc
->x
, crtc
->y
, crtc
->primary
->fb
);
98 int amdgpu_connector_get_monitor_bpc(struct drm_connector
*connector
)
100 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
101 struct amdgpu_connector_atom_dig
*dig_connector
;
103 unsigned mode_clock
, max_tmds_clock
;
105 switch (connector
->connector_type
) {
106 case DRM_MODE_CONNECTOR_DVII
:
107 case DRM_MODE_CONNECTOR_HDMIB
:
108 if (amdgpu_connector
->use_digital
) {
109 if (drm_detect_hdmi_monitor(amdgpu_connector_edid(connector
))) {
110 if (connector
->display_info
.bpc
)
111 bpc
= connector
->display_info
.bpc
;
115 case DRM_MODE_CONNECTOR_DVID
:
116 case DRM_MODE_CONNECTOR_HDMIA
:
117 if (drm_detect_hdmi_monitor(amdgpu_connector_edid(connector
))) {
118 if (connector
->display_info
.bpc
)
119 bpc
= connector
->display_info
.bpc
;
122 case DRM_MODE_CONNECTOR_DisplayPort
:
123 dig_connector
= amdgpu_connector
->con_priv
;
124 if ((dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
125 (dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
) ||
126 drm_detect_hdmi_monitor(amdgpu_connector_edid(connector
))) {
127 if (connector
->display_info
.bpc
)
128 bpc
= connector
->display_info
.bpc
;
131 case DRM_MODE_CONNECTOR_eDP
:
132 case DRM_MODE_CONNECTOR_LVDS
:
133 if (connector
->display_info
.bpc
)
134 bpc
= connector
->display_info
.bpc
;
136 const struct drm_connector_helper_funcs
*connector_funcs
=
137 connector
->helper_private
;
138 struct drm_encoder
*encoder
= connector_funcs
->best_encoder(connector
);
139 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
140 struct amdgpu_encoder_atom_dig
*dig
= amdgpu_encoder
->enc_priv
;
142 if (dig
->lcd_misc
& ATOM_PANEL_MISC_V13_6BIT_PER_COLOR
)
144 else if (dig
->lcd_misc
& ATOM_PANEL_MISC_V13_8BIT_PER_COLOR
)
150 if (drm_detect_hdmi_monitor(amdgpu_connector_edid(connector
))) {
152 * Pre DCE-8 hw can't handle > 12 bpc, and more than 12 bpc doesn't make
153 * much sense without support for > 12 bpc framebuffers. RGB 4:4:4 at
154 * 12 bpc is always supported on hdmi deep color sinks, as this is
155 * required by the HDMI-1.3 spec. Clamp to a safe 12 bpc maximum.
158 DRM_DEBUG("%s: HDMI deep color %d bpc unsupported. Using 12 bpc.\n",
159 connector
->name
, bpc
);
163 /* Any defined maximum tmds clock limit we must not exceed? */
164 if (connector
->display_info
.max_tmds_clock
> 0) {
165 /* mode_clock is clock in kHz for mode to be modeset on this connector */
166 mode_clock
= amdgpu_connector
->pixelclock_for_modeset
;
168 /* Maximum allowable input clock in kHz */
169 max_tmds_clock
= connector
->display_info
.max_tmds_clock
;
171 DRM_DEBUG("%s: hdmi mode dotclock %d kHz, max tmds input clock %d kHz.\n",
172 connector
->name
, mode_clock
, max_tmds_clock
);
174 /* Check if bpc is within clock limit. Try to degrade gracefully otherwise */
175 if ((bpc
== 12) && (mode_clock
* 3/2 > max_tmds_clock
)) {
176 if ((connector
->display_info
.edid_hdmi_dc_modes
& DRM_EDID_HDMI_DC_30
) &&
177 (mode_clock
* 5/4 <= max_tmds_clock
))
182 DRM_DEBUG("%s: HDMI deep color 12 bpc exceeds max tmds clock. Using %d bpc.\n",
183 connector
->name
, bpc
);
186 if ((bpc
== 10) && (mode_clock
* 5/4 > max_tmds_clock
)) {
188 DRM_DEBUG("%s: HDMI deep color 10 bpc exceeds max tmds clock. Using %d bpc.\n",
189 connector
->name
, bpc
);
191 } else if (bpc
> 8) {
192 /* max_tmds_clock missing, but hdmi spec mandates it for deep color. */
193 DRM_DEBUG("%s: Required max tmds clock for HDMI deep color missing. Using 8 bpc.\n",
199 if ((amdgpu_deep_color
== 0) && (bpc
> 8)) {
200 DRM_DEBUG("%s: Deep color disabled. Set amdgpu module param deep_color=1 to enable.\n",
205 DRM_DEBUG("%s: Display bpc=%d, returned bpc=%d\n",
206 connector
->name
, connector
->display_info
.bpc
, bpc
);
212 amdgpu_connector_update_scratch_regs(struct drm_connector
*connector
,
213 enum drm_connector_status status
)
215 struct drm_encoder
*best_encoder
;
216 struct drm_encoder
*encoder
;
217 const struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
221 best_encoder
= connector_funcs
->best_encoder(connector
);
223 drm_connector_for_each_possible_encoder(connector
, encoder
, i
) {
224 if ((encoder
== best_encoder
) && (status
== connector_status_connected
))
229 amdgpu_atombios_encoder_set_bios_scratch_regs(connector
, encoder
, connected
);
233 static struct drm_encoder
*
234 amdgpu_connector_find_encoder(struct drm_connector
*connector
,
237 struct drm_encoder
*encoder
;
240 drm_connector_for_each_possible_encoder(connector
, encoder
, i
) {
241 if (encoder
->encoder_type
== encoder_type
)
248 struct edid
*amdgpu_connector_edid(struct drm_connector
*connector
)
250 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
251 struct drm_property_blob
*edid_blob
= connector
->edid_blob_ptr
;
253 if (amdgpu_connector
->edid
) {
254 return amdgpu_connector
->edid
;
255 } else if (edid_blob
) {
256 struct edid
*edid
= kmemdup(edid_blob
->data
, edid_blob
->length
, GFP_KERNEL
);
258 amdgpu_connector
->edid
= edid
;
260 return amdgpu_connector
->edid
;
264 amdgpu_connector_get_hardcoded_edid(struct amdgpu_device
*adev
)
268 if (adev
->mode_info
.bios_hardcoded_edid
) {
269 edid
= kmalloc(adev
->mode_info
.bios_hardcoded_edid_size
, GFP_KERNEL
);
271 memcpy((unsigned char *)edid
,
272 (unsigned char *)adev
->mode_info
.bios_hardcoded_edid
,
273 adev
->mode_info
.bios_hardcoded_edid_size
);
280 static void amdgpu_connector_get_edid(struct drm_connector
*connector
)
282 struct drm_device
*dev
= connector
->dev
;
283 struct amdgpu_device
*adev
= dev
->dev_private
;
284 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
286 if (amdgpu_connector
->edid
)
289 /* on hw with routers, select right port */
290 if (amdgpu_connector
->router
.ddc_valid
)
291 amdgpu_i2c_router_select_ddc_port(amdgpu_connector
);
293 if ((amdgpu_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
294 ENCODER_OBJECT_ID_NONE
) &&
295 amdgpu_connector
->ddc_bus
->has_aux
) {
296 amdgpu_connector
->edid
= drm_get_edid(connector
,
297 &amdgpu_connector
->ddc_bus
->aux
.ddc
);
298 } else if ((connector
->connector_type
== DRM_MODE_CONNECTOR_DisplayPort
) ||
299 (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
)) {
300 struct amdgpu_connector_atom_dig
*dig
= amdgpu_connector
->con_priv
;
302 if ((dig
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
||
303 dig
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
) &&
304 amdgpu_connector
->ddc_bus
->has_aux
)
305 amdgpu_connector
->edid
= drm_get_edid(connector
,
306 &amdgpu_connector
->ddc_bus
->aux
.ddc
);
307 else if (amdgpu_connector
->ddc_bus
)
308 amdgpu_connector
->edid
= drm_get_edid(connector
,
309 &amdgpu_connector
->ddc_bus
->adapter
);
310 } else if (amdgpu_connector
->ddc_bus
) {
311 amdgpu_connector
->edid
= drm_get_edid(connector
,
312 &amdgpu_connector
->ddc_bus
->adapter
);
315 if (!amdgpu_connector
->edid
) {
316 /* some laptops provide a hardcoded edid in rom for LCDs */
317 if (((connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
) ||
318 (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
)))
319 amdgpu_connector
->edid
= amdgpu_connector_get_hardcoded_edid(adev
);
323 static void amdgpu_connector_free_edid(struct drm_connector
*connector
)
325 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
327 kfree(amdgpu_connector
->edid
);
328 amdgpu_connector
->edid
= NULL
;
331 static int amdgpu_connector_ddc_get_modes(struct drm_connector
*connector
)
333 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
336 if (amdgpu_connector
->edid
) {
337 drm_connector_update_edid_property(connector
, amdgpu_connector
->edid
);
338 ret
= drm_add_edid_modes(connector
, amdgpu_connector
->edid
);
341 drm_connector_update_edid_property(connector
, NULL
);
345 static struct drm_encoder
*
346 amdgpu_connector_best_single_encoder(struct drm_connector
*connector
)
348 struct drm_encoder
*encoder
;
351 /* pick the first one */
352 drm_connector_for_each_possible_encoder(connector
, encoder
, i
)
358 static void amdgpu_get_native_mode(struct drm_connector
*connector
)
360 struct drm_encoder
*encoder
= amdgpu_connector_best_single_encoder(connector
);
361 struct amdgpu_encoder
*amdgpu_encoder
;
366 amdgpu_encoder
= to_amdgpu_encoder(encoder
);
368 if (!list_empty(&connector
->probed_modes
)) {
369 struct drm_display_mode
*preferred_mode
=
370 list_first_entry(&connector
->probed_modes
,
371 struct drm_display_mode
, head
);
373 amdgpu_encoder
->native_mode
= *preferred_mode
;
375 amdgpu_encoder
->native_mode
.clock
= 0;
379 static struct drm_display_mode
*
380 amdgpu_connector_lcd_native_mode(struct drm_encoder
*encoder
)
382 struct drm_device
*dev
= encoder
->dev
;
383 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
384 struct drm_display_mode
*mode
= NULL
;
385 struct drm_display_mode
*native_mode
= &amdgpu_encoder
->native_mode
;
387 if (native_mode
->hdisplay
!= 0 &&
388 native_mode
->vdisplay
!= 0 &&
389 native_mode
->clock
!= 0) {
390 mode
= drm_mode_duplicate(dev
, native_mode
);
391 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
392 drm_mode_set_name(mode
);
394 DRM_DEBUG_KMS("Adding native panel mode %s\n", mode
->name
);
395 } else if (native_mode
->hdisplay
!= 0 &&
396 native_mode
->vdisplay
!= 0) {
397 /* mac laptops without an edid */
398 /* Note that this is not necessarily the exact panel mode,
399 * but an approximation based on the cvt formula. For these
400 * systems we should ideally read the mode info out of the
401 * registers or add a mode table, but this works and is much
404 mode
= drm_cvt_mode(dev
, native_mode
->hdisplay
, native_mode
->vdisplay
, 60, true, false, false);
405 mode
->type
= DRM_MODE_TYPE_PREFERRED
| DRM_MODE_TYPE_DRIVER
;
406 DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode
->name
);
411 static void amdgpu_connector_add_common_modes(struct drm_encoder
*encoder
,
412 struct drm_connector
*connector
)
414 struct drm_device
*dev
= encoder
->dev
;
415 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
416 struct drm_display_mode
*mode
= NULL
;
417 struct drm_display_mode
*native_mode
= &amdgpu_encoder
->native_mode
;
419 static const struct mode_size
{
422 } common_modes
[17] = {
442 for (i
= 0; i
< 17; i
++) {
443 if (amdgpu_encoder
->devices
& (ATOM_DEVICE_TV_SUPPORT
)) {
444 if (common_modes
[i
].w
> 1024 ||
445 common_modes
[i
].h
> 768)
448 if (amdgpu_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
449 if (common_modes
[i
].w
> native_mode
->hdisplay
||
450 common_modes
[i
].h
> native_mode
->vdisplay
||
451 (common_modes
[i
].w
== native_mode
->hdisplay
&&
452 common_modes
[i
].h
== native_mode
->vdisplay
))
455 if (common_modes
[i
].w
< 320 || common_modes
[i
].h
< 200)
458 mode
= drm_cvt_mode(dev
, common_modes
[i
].w
, common_modes
[i
].h
, 60, false, false, false);
459 drm_mode_probed_add(connector
, mode
);
463 static int amdgpu_connector_set_property(struct drm_connector
*connector
,
464 struct drm_property
*property
,
467 struct drm_device
*dev
= connector
->dev
;
468 struct amdgpu_device
*adev
= dev
->dev_private
;
469 struct drm_encoder
*encoder
;
470 struct amdgpu_encoder
*amdgpu_encoder
;
472 if (property
== adev
->mode_info
.coherent_mode_property
) {
473 struct amdgpu_encoder_atom_dig
*dig
;
474 bool new_coherent_mode
;
476 /* need to find digital encoder on connector */
477 encoder
= amdgpu_connector_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
481 amdgpu_encoder
= to_amdgpu_encoder(encoder
);
483 if (!amdgpu_encoder
->enc_priv
)
486 dig
= amdgpu_encoder
->enc_priv
;
487 new_coherent_mode
= val
? true : false;
488 if (dig
->coherent_mode
!= new_coherent_mode
) {
489 dig
->coherent_mode
= new_coherent_mode
;
490 amdgpu_connector_property_change_mode(&amdgpu_encoder
->base
);
494 if (property
== adev
->mode_info
.audio_property
) {
495 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
496 /* need to find digital encoder on connector */
497 encoder
= amdgpu_connector_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
501 amdgpu_encoder
= to_amdgpu_encoder(encoder
);
503 if (amdgpu_connector
->audio
!= val
) {
504 amdgpu_connector
->audio
= val
;
505 amdgpu_connector_property_change_mode(&amdgpu_encoder
->base
);
509 if (property
== adev
->mode_info
.dither_property
) {
510 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
511 /* need to find digital encoder on connector */
512 encoder
= amdgpu_connector_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
516 amdgpu_encoder
= to_amdgpu_encoder(encoder
);
518 if (amdgpu_connector
->dither
!= val
) {
519 amdgpu_connector
->dither
= val
;
520 amdgpu_connector_property_change_mode(&amdgpu_encoder
->base
);
524 if (property
== adev
->mode_info
.underscan_property
) {
525 /* need to find digital encoder on connector */
526 encoder
= amdgpu_connector_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
530 amdgpu_encoder
= to_amdgpu_encoder(encoder
);
532 if (amdgpu_encoder
->underscan_type
!= val
) {
533 amdgpu_encoder
->underscan_type
= val
;
534 amdgpu_connector_property_change_mode(&amdgpu_encoder
->base
);
538 if (property
== adev
->mode_info
.underscan_hborder_property
) {
539 /* need to find digital encoder on connector */
540 encoder
= amdgpu_connector_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
544 amdgpu_encoder
= to_amdgpu_encoder(encoder
);
546 if (amdgpu_encoder
->underscan_hborder
!= val
) {
547 amdgpu_encoder
->underscan_hborder
= val
;
548 amdgpu_connector_property_change_mode(&amdgpu_encoder
->base
);
552 if (property
== adev
->mode_info
.underscan_vborder_property
) {
553 /* need to find digital encoder on connector */
554 encoder
= amdgpu_connector_find_encoder(connector
, DRM_MODE_ENCODER_TMDS
);
558 amdgpu_encoder
= to_amdgpu_encoder(encoder
);
560 if (amdgpu_encoder
->underscan_vborder
!= val
) {
561 amdgpu_encoder
->underscan_vborder
= val
;
562 amdgpu_connector_property_change_mode(&amdgpu_encoder
->base
);
566 if (property
== adev
->mode_info
.load_detect_property
) {
567 struct amdgpu_connector
*amdgpu_connector
=
568 to_amdgpu_connector(connector
);
571 amdgpu_connector
->dac_load_detect
= false;
573 amdgpu_connector
->dac_load_detect
= true;
576 if (property
== dev
->mode_config
.scaling_mode_property
) {
577 enum amdgpu_rmx_type rmx_type
;
579 if (connector
->encoder
) {
580 amdgpu_encoder
= to_amdgpu_encoder(connector
->encoder
);
582 const struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
583 amdgpu_encoder
= to_amdgpu_encoder(connector_funcs
->best_encoder(connector
));
588 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
589 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
590 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
591 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
593 if (amdgpu_encoder
->rmx_type
== rmx_type
)
596 if ((rmx_type
!= DRM_MODE_SCALE_NONE
) &&
597 (amdgpu_encoder
->native_mode
.clock
== 0))
600 amdgpu_encoder
->rmx_type
= rmx_type
;
602 amdgpu_connector_property_change_mode(&amdgpu_encoder
->base
);
609 amdgpu_connector_fixup_lcd_native_mode(struct drm_encoder
*encoder
,
610 struct drm_connector
*connector
)
612 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
613 struct drm_display_mode
*native_mode
= &amdgpu_encoder
->native_mode
;
614 struct drm_display_mode
*t
, *mode
;
616 /* If the EDID preferred mode doesn't match the native mode, use it */
617 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
618 if (mode
->type
& DRM_MODE_TYPE_PREFERRED
) {
619 if (mode
->hdisplay
!= native_mode
->hdisplay
||
620 mode
->vdisplay
!= native_mode
->vdisplay
)
621 memcpy(native_mode
, mode
, sizeof(*mode
));
625 /* Try to get native mode details from EDID if necessary */
626 if (!native_mode
->clock
) {
627 list_for_each_entry_safe(mode
, t
, &connector
->probed_modes
, head
) {
628 if (mode
->hdisplay
== native_mode
->hdisplay
&&
629 mode
->vdisplay
== native_mode
->vdisplay
) {
630 *native_mode
= *mode
;
631 drm_mode_set_crtcinfo(native_mode
, CRTC_INTERLACE_HALVE_V
);
632 DRM_DEBUG_KMS("Determined LVDS native mode details from EDID\n");
638 if (!native_mode
->clock
) {
639 DRM_DEBUG_KMS("No LVDS native mode details, disabling RMX\n");
640 amdgpu_encoder
->rmx_type
= RMX_OFF
;
644 static int amdgpu_connector_lvds_get_modes(struct drm_connector
*connector
)
646 struct drm_encoder
*encoder
;
648 struct drm_display_mode
*mode
;
650 amdgpu_connector_get_edid(connector
);
651 ret
= amdgpu_connector_ddc_get_modes(connector
);
653 encoder
= amdgpu_connector_best_single_encoder(connector
);
655 amdgpu_connector_fixup_lcd_native_mode(encoder
, connector
);
656 /* add scaled modes */
657 amdgpu_connector_add_common_modes(encoder
, connector
);
662 encoder
= amdgpu_connector_best_single_encoder(connector
);
666 /* we have no EDID modes */
667 mode
= amdgpu_connector_lcd_native_mode(encoder
);
670 drm_mode_probed_add(connector
, mode
);
671 /* add the width/height from vbios tables if available */
672 connector
->display_info
.width_mm
= mode
->width_mm
;
673 connector
->display_info
.height_mm
= mode
->height_mm
;
674 /* add scaled modes */
675 amdgpu_connector_add_common_modes(encoder
, connector
);
681 static enum drm_mode_status
amdgpu_connector_lvds_mode_valid(struct drm_connector
*connector
,
682 struct drm_display_mode
*mode
)
684 struct drm_encoder
*encoder
= amdgpu_connector_best_single_encoder(connector
);
686 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
690 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
691 struct drm_display_mode
*native_mode
= &amdgpu_encoder
->native_mode
;
693 /* AVIVO hardware supports downscaling modes larger than the panel
694 * to the panel size, but I'm not sure this is desirable.
696 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
697 (mode
->vdisplay
> native_mode
->vdisplay
))
700 /* if scaling is disabled, block non-native modes */
701 if (amdgpu_encoder
->rmx_type
== RMX_OFF
) {
702 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
703 (mode
->vdisplay
!= native_mode
->vdisplay
))
711 static enum drm_connector_status
712 amdgpu_connector_lvds_detect(struct drm_connector
*connector
, bool force
)
714 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
715 struct drm_encoder
*encoder
= amdgpu_connector_best_single_encoder(connector
);
716 enum drm_connector_status ret
= connector_status_disconnected
;
719 if (!drm_kms_helper_is_poll_worker()) {
720 r
= pm_runtime_get_sync(connector
->dev
->dev
);
722 return connector_status_disconnected
;
726 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
727 struct drm_display_mode
*native_mode
= &amdgpu_encoder
->native_mode
;
729 /* check if panel is valid */
730 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
731 ret
= connector_status_connected
;
735 /* check for edid as well */
736 amdgpu_connector_get_edid(connector
);
737 if (amdgpu_connector
->edid
)
738 ret
= connector_status_connected
;
739 /* check acpi lid status ??? */
741 amdgpu_connector_update_scratch_regs(connector
, ret
);
743 if (!drm_kms_helper_is_poll_worker()) {
744 pm_runtime_mark_last_busy(connector
->dev
->dev
);
745 pm_runtime_put_autosuspend(connector
->dev
->dev
);
751 static void amdgpu_connector_unregister(struct drm_connector
*connector
)
753 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
755 if (amdgpu_connector
->ddc_bus
&& amdgpu_connector
->ddc_bus
->has_aux
) {
756 drm_dp_aux_unregister(&amdgpu_connector
->ddc_bus
->aux
);
757 amdgpu_connector
->ddc_bus
->has_aux
= false;
761 static void amdgpu_connector_destroy(struct drm_connector
*connector
)
763 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
765 amdgpu_connector_free_edid(connector
);
766 kfree(amdgpu_connector
->con_priv
);
767 drm_connector_unregister(connector
);
768 drm_connector_cleanup(connector
);
772 static int amdgpu_connector_set_lcd_property(struct drm_connector
*connector
,
773 struct drm_property
*property
,
776 struct drm_device
*dev
= connector
->dev
;
777 struct amdgpu_encoder
*amdgpu_encoder
;
778 enum amdgpu_rmx_type rmx_type
;
781 if (property
!= dev
->mode_config
.scaling_mode_property
)
784 if (connector
->encoder
)
785 amdgpu_encoder
= to_amdgpu_encoder(connector
->encoder
);
787 const struct drm_connector_helper_funcs
*connector_funcs
= connector
->helper_private
;
788 amdgpu_encoder
= to_amdgpu_encoder(connector_funcs
->best_encoder(connector
));
792 case DRM_MODE_SCALE_NONE
: rmx_type
= RMX_OFF
; break;
793 case DRM_MODE_SCALE_CENTER
: rmx_type
= RMX_CENTER
; break;
794 case DRM_MODE_SCALE_ASPECT
: rmx_type
= RMX_ASPECT
; break;
796 case DRM_MODE_SCALE_FULLSCREEN
: rmx_type
= RMX_FULL
; break;
798 if (amdgpu_encoder
->rmx_type
== rmx_type
)
801 amdgpu_encoder
->rmx_type
= rmx_type
;
803 amdgpu_connector_property_change_mode(&amdgpu_encoder
->base
);
808 static const struct drm_connector_helper_funcs amdgpu_connector_lvds_helper_funcs
= {
809 .get_modes
= amdgpu_connector_lvds_get_modes
,
810 .mode_valid
= amdgpu_connector_lvds_mode_valid
,
811 .best_encoder
= amdgpu_connector_best_single_encoder
,
814 static const struct drm_connector_funcs amdgpu_connector_lvds_funcs
= {
815 .dpms
= drm_helper_connector_dpms
,
816 .detect
= amdgpu_connector_lvds_detect
,
817 .fill_modes
= drm_helper_probe_single_connector_modes
,
818 .early_unregister
= amdgpu_connector_unregister
,
819 .destroy
= amdgpu_connector_destroy
,
820 .set_property
= amdgpu_connector_set_lcd_property
,
823 static int amdgpu_connector_vga_get_modes(struct drm_connector
*connector
)
827 amdgpu_connector_get_edid(connector
);
828 ret
= amdgpu_connector_ddc_get_modes(connector
);
833 static enum drm_mode_status
amdgpu_connector_vga_mode_valid(struct drm_connector
*connector
,
834 struct drm_display_mode
*mode
)
836 struct drm_device
*dev
= connector
->dev
;
837 struct amdgpu_device
*adev
= dev
->dev_private
;
839 /* XXX check mode bandwidth */
841 if ((mode
->clock
/ 10) > adev
->clock
.max_pixel_clock
)
842 return MODE_CLOCK_HIGH
;
847 static enum drm_connector_status
848 amdgpu_connector_vga_detect(struct drm_connector
*connector
, bool force
)
850 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
851 struct drm_encoder
*encoder
;
852 const struct drm_encoder_helper_funcs
*encoder_funcs
;
854 enum drm_connector_status ret
= connector_status_disconnected
;
857 if (!drm_kms_helper_is_poll_worker()) {
858 r
= pm_runtime_get_sync(connector
->dev
->dev
);
860 return connector_status_disconnected
;
863 encoder
= amdgpu_connector_best_single_encoder(connector
);
865 ret
= connector_status_disconnected
;
867 if (amdgpu_connector
->ddc_bus
)
868 dret
= amdgpu_display_ddc_probe(amdgpu_connector
, false);
870 amdgpu_connector
->detected_by_load
= false;
871 amdgpu_connector_free_edid(connector
);
872 amdgpu_connector_get_edid(connector
);
874 if (!amdgpu_connector
->edid
) {
875 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
877 ret
= connector_status_connected
;
879 amdgpu_connector
->use_digital
=
880 !!(amdgpu_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
882 /* some oems have boards with separate digital and analog connectors
883 * with a shared ddc line (often vga + hdmi)
885 if (amdgpu_connector
->use_digital
&& amdgpu_connector
->shared_ddc
) {
886 amdgpu_connector_free_edid(connector
);
887 ret
= connector_status_disconnected
;
889 ret
= connector_status_connected
;
894 /* if we aren't forcing don't do destructive polling */
896 /* only return the previous status if we last
897 * detected a monitor via load.
899 if (amdgpu_connector
->detected_by_load
)
900 ret
= connector
->status
;
904 if (amdgpu_connector
->dac_load_detect
&& encoder
) {
905 encoder_funcs
= encoder
->helper_private
;
906 ret
= encoder_funcs
->detect(encoder
, connector
);
907 if (ret
!= connector_status_disconnected
)
908 amdgpu_connector
->detected_by_load
= true;
912 amdgpu_connector_update_scratch_regs(connector
, ret
);
915 if (!drm_kms_helper_is_poll_worker()) {
916 pm_runtime_mark_last_busy(connector
->dev
->dev
);
917 pm_runtime_put_autosuspend(connector
->dev
->dev
);
923 static const struct drm_connector_helper_funcs amdgpu_connector_vga_helper_funcs
= {
924 .get_modes
= amdgpu_connector_vga_get_modes
,
925 .mode_valid
= amdgpu_connector_vga_mode_valid
,
926 .best_encoder
= amdgpu_connector_best_single_encoder
,
929 static const struct drm_connector_funcs amdgpu_connector_vga_funcs
= {
930 .dpms
= drm_helper_connector_dpms
,
931 .detect
= amdgpu_connector_vga_detect
,
932 .fill_modes
= drm_helper_probe_single_connector_modes
,
933 .early_unregister
= amdgpu_connector_unregister
,
934 .destroy
= amdgpu_connector_destroy
,
935 .set_property
= amdgpu_connector_set_property
,
939 amdgpu_connector_check_hpd_status_unchanged(struct drm_connector
*connector
)
941 struct drm_device
*dev
= connector
->dev
;
942 struct amdgpu_device
*adev
= dev
->dev_private
;
943 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
944 enum drm_connector_status status
;
946 if (amdgpu_connector
->hpd
.hpd
!= AMDGPU_HPD_NONE
) {
947 if (amdgpu_display_hpd_sense(adev
, amdgpu_connector
->hpd
.hpd
))
948 status
= connector_status_connected
;
950 status
= connector_status_disconnected
;
951 if (connector
->status
== status
)
960 * Do a DDC probe, if DDC probe passes, get the full EDID so
961 * we can do analog/digital monitor detection at this point.
962 * If the monitor is an analog monitor or we got no DDC,
963 * we need to find the DAC encoder object for this connector.
964 * If we got no DDC, we do load detection on the DAC encoder object.
965 * If we got analog DDC or load detection passes on the DAC encoder
966 * we have to check if this analog encoder is shared with anyone else (TV)
967 * if its shared we have to set the other connector to disconnected.
969 static enum drm_connector_status
970 amdgpu_connector_dvi_detect(struct drm_connector
*connector
, bool force
)
972 struct drm_device
*dev
= connector
->dev
;
973 struct amdgpu_device
*adev
= dev
->dev_private
;
974 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
975 const struct drm_encoder_helper_funcs
*encoder_funcs
;
977 enum drm_connector_status ret
= connector_status_disconnected
;
978 bool dret
= false, broken_edid
= false;
980 if (!drm_kms_helper_is_poll_worker()) {
981 r
= pm_runtime_get_sync(connector
->dev
->dev
);
983 return connector_status_disconnected
;
986 if (!force
&& amdgpu_connector_check_hpd_status_unchanged(connector
)) {
987 ret
= connector
->status
;
991 if (amdgpu_connector
->ddc_bus
)
992 dret
= amdgpu_display_ddc_probe(amdgpu_connector
, false);
994 amdgpu_connector
->detected_by_load
= false;
995 amdgpu_connector_free_edid(connector
);
996 amdgpu_connector_get_edid(connector
);
998 if (!amdgpu_connector
->edid
) {
999 DRM_ERROR("%s: probed a monitor but no|invalid EDID\n",
1001 ret
= connector_status_connected
;
1002 broken_edid
= true; /* defer use_digital to later */
1004 amdgpu_connector
->use_digital
=
1005 !!(amdgpu_connector
->edid
->input
& DRM_EDID_INPUT_DIGITAL
);
1007 /* some oems have boards with separate digital and analog connectors
1008 * with a shared ddc line (often vga + hdmi)
1010 if ((!amdgpu_connector
->use_digital
) && amdgpu_connector
->shared_ddc
) {
1011 amdgpu_connector_free_edid(connector
);
1012 ret
= connector_status_disconnected
;
1014 ret
= connector_status_connected
;
1017 /* This gets complicated. We have boards with VGA + HDMI with a
1018 * shared DDC line and we have boards with DVI-D + HDMI with a shared
1019 * DDC line. The latter is more complex because with DVI<->HDMI adapters
1020 * you don't really know what's connected to which port as both are digital.
1022 if (amdgpu_connector
->shared_ddc
&& (ret
== connector_status_connected
)) {
1023 struct drm_connector
*list_connector
;
1024 struct amdgpu_connector
*list_amdgpu_connector
;
1025 list_for_each_entry(list_connector
, &dev
->mode_config
.connector_list
, head
) {
1026 if (connector
== list_connector
)
1028 list_amdgpu_connector
= to_amdgpu_connector(list_connector
);
1029 if (list_amdgpu_connector
->shared_ddc
&&
1030 (list_amdgpu_connector
->ddc_bus
->rec
.i2c_id
==
1031 amdgpu_connector
->ddc_bus
->rec
.i2c_id
)) {
1032 /* cases where both connectors are digital */
1033 if (list_connector
->connector_type
!= DRM_MODE_CONNECTOR_VGA
) {
1034 /* hpd is our only option in this case */
1035 if (!amdgpu_display_hpd_sense(adev
, amdgpu_connector
->hpd
.hpd
)) {
1036 amdgpu_connector_free_edid(connector
);
1037 ret
= connector_status_disconnected
;
1046 if ((ret
== connector_status_connected
) && (amdgpu_connector
->use_digital
== true))
1049 /* DVI-D and HDMI-A are digital only */
1050 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_DVID
) ||
1051 (connector
->connector_type
== DRM_MODE_CONNECTOR_HDMIA
))
1054 /* if we aren't forcing don't do destructive polling */
1056 /* only return the previous status if we last
1057 * detected a monitor via load.
1059 if (amdgpu_connector
->detected_by_load
)
1060 ret
= connector
->status
;
1064 /* find analog encoder */
1065 if (amdgpu_connector
->dac_load_detect
) {
1066 struct drm_encoder
*encoder
;
1069 drm_connector_for_each_possible_encoder(connector
, encoder
, i
) {
1070 if (encoder
->encoder_type
!= DRM_MODE_ENCODER_DAC
&&
1071 encoder
->encoder_type
!= DRM_MODE_ENCODER_TVDAC
)
1074 encoder_funcs
= encoder
->helper_private
;
1075 if (encoder_funcs
->detect
) {
1077 if (ret
!= connector_status_connected
) {
1078 /* deal with analog monitors without DDC */
1079 ret
= encoder_funcs
->detect(encoder
, connector
);
1080 if (ret
== connector_status_connected
) {
1081 amdgpu_connector
->use_digital
= false;
1083 if (ret
!= connector_status_disconnected
)
1084 amdgpu_connector
->detected_by_load
= true;
1087 enum drm_connector_status lret
;
1088 /* assume digital unless load detected otherwise */
1089 amdgpu_connector
->use_digital
= true;
1090 lret
= encoder_funcs
->detect(encoder
, connector
);
1091 DRM_DEBUG_KMS("load_detect %x returned: %x\n",encoder
->encoder_type
,lret
);
1092 if (lret
== connector_status_connected
)
1093 amdgpu_connector
->use_digital
= false;
1101 /* updated in get modes as well since we need to know if it's analog or digital */
1102 amdgpu_connector_update_scratch_regs(connector
, ret
);
1105 if (!drm_kms_helper_is_poll_worker()) {
1106 pm_runtime_mark_last_busy(connector
->dev
->dev
);
1107 pm_runtime_put_autosuspend(connector
->dev
->dev
);
1113 /* okay need to be smart in here about which encoder to pick */
1114 static struct drm_encoder
*
1115 amdgpu_connector_dvi_encoder(struct drm_connector
*connector
)
1117 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
1118 struct drm_encoder
*encoder
;
1121 drm_connector_for_each_possible_encoder(connector
, encoder
, i
) {
1122 if (amdgpu_connector
->use_digital
== true) {
1123 if (encoder
->encoder_type
== DRM_MODE_ENCODER_TMDS
)
1126 if (encoder
->encoder_type
== DRM_MODE_ENCODER_DAC
||
1127 encoder
->encoder_type
== DRM_MODE_ENCODER_TVDAC
)
1132 /* see if we have a default encoder TODO */
1134 /* then check use digitial */
1135 /* pick the first one */
1136 drm_connector_for_each_possible_encoder(connector
, encoder
, i
)
1142 static void amdgpu_connector_dvi_force(struct drm_connector
*connector
)
1144 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
1145 if (connector
->force
== DRM_FORCE_ON
)
1146 amdgpu_connector
->use_digital
= false;
1147 if (connector
->force
== DRM_FORCE_ON_DIGITAL
)
1148 amdgpu_connector
->use_digital
= true;
1151 static enum drm_mode_status
amdgpu_connector_dvi_mode_valid(struct drm_connector
*connector
,
1152 struct drm_display_mode
*mode
)
1154 struct drm_device
*dev
= connector
->dev
;
1155 struct amdgpu_device
*adev
= dev
->dev_private
;
1156 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
1158 /* XXX check mode bandwidth */
1160 if (amdgpu_connector
->use_digital
&& (mode
->clock
> 165000)) {
1161 if ((amdgpu_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
) ||
1162 (amdgpu_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
) ||
1163 (amdgpu_connector
->connector_object_id
== CONNECTOR_OBJECT_ID_HDMI_TYPE_B
)) {
1165 } else if (drm_detect_hdmi_monitor(amdgpu_connector_edid(connector
))) {
1166 /* HDMI 1.3+ supports max clock of 340 Mhz */
1167 if (mode
->clock
> 340000)
1168 return MODE_CLOCK_HIGH
;
1172 return MODE_CLOCK_HIGH
;
1176 /* check against the max pixel clock */
1177 if ((mode
->clock
/ 10) > adev
->clock
.max_pixel_clock
)
1178 return MODE_CLOCK_HIGH
;
1183 static const struct drm_connector_helper_funcs amdgpu_connector_dvi_helper_funcs
= {
1184 .get_modes
= amdgpu_connector_vga_get_modes
,
1185 .mode_valid
= amdgpu_connector_dvi_mode_valid
,
1186 .best_encoder
= amdgpu_connector_dvi_encoder
,
1189 static const struct drm_connector_funcs amdgpu_connector_dvi_funcs
= {
1190 .dpms
= drm_helper_connector_dpms
,
1191 .detect
= amdgpu_connector_dvi_detect
,
1192 .fill_modes
= drm_helper_probe_single_connector_modes
,
1193 .set_property
= amdgpu_connector_set_property
,
1194 .early_unregister
= amdgpu_connector_unregister
,
1195 .destroy
= amdgpu_connector_destroy
,
1196 .force
= amdgpu_connector_dvi_force
,
1199 static int amdgpu_connector_dp_get_modes(struct drm_connector
*connector
)
1201 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
1202 struct amdgpu_connector_atom_dig
*amdgpu_dig_connector
= amdgpu_connector
->con_priv
;
1203 struct drm_encoder
*encoder
= amdgpu_connector_best_single_encoder(connector
);
1206 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1207 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1208 struct drm_display_mode
*mode
;
1210 if (connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) {
1211 if (!amdgpu_dig_connector
->edp_on
)
1212 amdgpu_atombios_encoder_set_edp_panel_power(connector
,
1213 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1214 amdgpu_connector_get_edid(connector
);
1215 ret
= amdgpu_connector_ddc_get_modes(connector
);
1216 if (!amdgpu_dig_connector
->edp_on
)
1217 amdgpu_atombios_encoder_set_edp_panel_power(connector
,
1218 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1220 /* need to setup ddc on the bridge */
1221 if (amdgpu_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1222 ENCODER_OBJECT_ID_NONE
) {
1224 amdgpu_atombios_encoder_setup_ext_encoder_ddc(encoder
);
1226 amdgpu_connector_get_edid(connector
);
1227 ret
= amdgpu_connector_ddc_get_modes(connector
);
1232 amdgpu_connector_fixup_lcd_native_mode(encoder
, connector
);
1233 /* add scaled modes */
1234 amdgpu_connector_add_common_modes(encoder
, connector
);
1242 /* we have no EDID modes */
1243 mode
= amdgpu_connector_lcd_native_mode(encoder
);
1246 drm_mode_probed_add(connector
, mode
);
1247 /* add the width/height from vbios tables if available */
1248 connector
->display_info
.width_mm
= mode
->width_mm
;
1249 connector
->display_info
.height_mm
= mode
->height_mm
;
1250 /* add scaled modes */
1251 amdgpu_connector_add_common_modes(encoder
, connector
);
1254 /* need to setup ddc on the bridge */
1255 if (amdgpu_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1256 ENCODER_OBJECT_ID_NONE
) {
1258 amdgpu_atombios_encoder_setup_ext_encoder_ddc(encoder
);
1260 amdgpu_connector_get_edid(connector
);
1261 ret
= amdgpu_connector_ddc_get_modes(connector
);
1263 amdgpu_get_native_mode(connector
);
1269 u16
amdgpu_connector_encoder_get_dp_bridge_encoder_id(struct drm_connector
*connector
)
1271 struct drm_encoder
*encoder
;
1272 struct amdgpu_encoder
*amdgpu_encoder
;
1275 drm_connector_for_each_possible_encoder(connector
, encoder
, i
) {
1276 amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1278 switch (amdgpu_encoder
->encoder_id
) {
1279 case ENCODER_OBJECT_ID_TRAVIS
:
1280 case ENCODER_OBJECT_ID_NUTMEG
:
1281 return amdgpu_encoder
->encoder_id
;
1287 return ENCODER_OBJECT_ID_NONE
;
1290 static bool amdgpu_connector_encoder_is_hbr2(struct drm_connector
*connector
)
1292 struct drm_encoder
*encoder
;
1293 struct amdgpu_encoder
*amdgpu_encoder
;
1297 drm_connector_for_each_possible_encoder(connector
, encoder
, i
) {
1298 amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1299 if (amdgpu_encoder
->caps
& ATOM_ENCODER_CAP_RECORD_HBR2
)
1306 bool amdgpu_connector_is_dp12_capable(struct drm_connector
*connector
)
1308 struct drm_device
*dev
= connector
->dev
;
1309 struct amdgpu_device
*adev
= dev
->dev_private
;
1311 if ((adev
->clock
.default_dispclk
>= 53900) &&
1312 amdgpu_connector_encoder_is_hbr2(connector
)) {
1319 static enum drm_connector_status
1320 amdgpu_connector_dp_detect(struct drm_connector
*connector
, bool force
)
1322 struct drm_device
*dev
= connector
->dev
;
1323 struct amdgpu_device
*adev
= dev
->dev_private
;
1324 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
1325 enum drm_connector_status ret
= connector_status_disconnected
;
1326 struct amdgpu_connector_atom_dig
*amdgpu_dig_connector
= amdgpu_connector
->con_priv
;
1327 struct drm_encoder
*encoder
= amdgpu_connector_best_single_encoder(connector
);
1330 if (!drm_kms_helper_is_poll_worker()) {
1331 r
= pm_runtime_get_sync(connector
->dev
->dev
);
1333 return connector_status_disconnected
;
1336 if (!force
&& amdgpu_connector_check_hpd_status_unchanged(connector
)) {
1337 ret
= connector
->status
;
1341 amdgpu_connector_free_edid(connector
);
1343 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1344 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1346 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1347 struct drm_display_mode
*native_mode
= &amdgpu_encoder
->native_mode
;
1349 /* check if panel is valid */
1350 if (native_mode
->hdisplay
>= 320 && native_mode
->vdisplay
>= 240)
1351 ret
= connector_status_connected
;
1353 /* eDP is always DP */
1354 amdgpu_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1355 if (!amdgpu_dig_connector
->edp_on
)
1356 amdgpu_atombios_encoder_set_edp_panel_power(connector
,
1357 ATOM_TRANSMITTER_ACTION_POWER_ON
);
1358 if (!amdgpu_atombios_dp_get_dpcd(amdgpu_connector
))
1359 ret
= connector_status_connected
;
1360 if (!amdgpu_dig_connector
->edp_on
)
1361 amdgpu_atombios_encoder_set_edp_panel_power(connector
,
1362 ATOM_TRANSMITTER_ACTION_POWER_OFF
);
1363 } else if (amdgpu_connector_encoder_get_dp_bridge_encoder_id(connector
) !=
1364 ENCODER_OBJECT_ID_NONE
) {
1365 /* DP bridges are always DP */
1366 amdgpu_dig_connector
->dp_sink_type
= CONNECTOR_OBJECT_ID_DISPLAYPORT
;
1367 /* get the DPCD from the bridge */
1368 amdgpu_atombios_dp_get_dpcd(amdgpu_connector
);
1371 /* setup ddc on the bridge */
1372 amdgpu_atombios_encoder_setup_ext_encoder_ddc(encoder
);
1373 /* bridge chips are always aux */
1375 if (amdgpu_display_ddc_probe(amdgpu_connector
, true))
1376 ret
= connector_status_connected
;
1377 else if (amdgpu_connector
->dac_load_detect
) { /* try load detection */
1378 const struct drm_encoder_helper_funcs
*encoder_funcs
= encoder
->helper_private
;
1379 ret
= encoder_funcs
->detect(encoder
, connector
);
1383 amdgpu_dig_connector
->dp_sink_type
=
1384 amdgpu_atombios_dp_get_sinktype(amdgpu_connector
);
1385 if (amdgpu_display_hpd_sense(adev
, amdgpu_connector
->hpd
.hpd
)) {
1386 ret
= connector_status_connected
;
1387 if (amdgpu_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
)
1388 amdgpu_atombios_dp_get_dpcd(amdgpu_connector
);
1390 if (amdgpu_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) {
1391 if (!amdgpu_atombios_dp_get_dpcd(amdgpu_connector
))
1392 ret
= connector_status_connected
;
1394 /* try non-aux ddc (DP to DVI/HDMI/etc. adapter) */
1395 if (amdgpu_display_ddc_probe(amdgpu_connector
,
1397 ret
= connector_status_connected
;
1402 amdgpu_connector_update_scratch_regs(connector
, ret
);
1404 if (!drm_kms_helper_is_poll_worker()) {
1405 pm_runtime_mark_last_busy(connector
->dev
->dev
);
1406 pm_runtime_put_autosuspend(connector
->dev
->dev
);
1412 static enum drm_mode_status
amdgpu_connector_dp_mode_valid(struct drm_connector
*connector
,
1413 struct drm_display_mode
*mode
)
1415 struct amdgpu_connector
*amdgpu_connector
= to_amdgpu_connector(connector
);
1416 struct amdgpu_connector_atom_dig
*amdgpu_dig_connector
= amdgpu_connector
->con_priv
;
1418 /* XXX check mode bandwidth */
1420 if ((connector
->connector_type
== DRM_MODE_CONNECTOR_eDP
) ||
1421 (connector
->connector_type
== DRM_MODE_CONNECTOR_LVDS
)) {
1422 struct drm_encoder
*encoder
= amdgpu_connector_best_single_encoder(connector
);
1424 if ((mode
->hdisplay
< 320) || (mode
->vdisplay
< 240))
1428 struct amdgpu_encoder
*amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1429 struct drm_display_mode
*native_mode
= &amdgpu_encoder
->native_mode
;
1431 /* AVIVO hardware supports downscaling modes larger than the panel
1432 * to the panel size, but I'm not sure this is desirable.
1434 if ((mode
->hdisplay
> native_mode
->hdisplay
) ||
1435 (mode
->vdisplay
> native_mode
->vdisplay
))
1438 /* if scaling is disabled, block non-native modes */
1439 if (amdgpu_encoder
->rmx_type
== RMX_OFF
) {
1440 if ((mode
->hdisplay
!= native_mode
->hdisplay
) ||
1441 (mode
->vdisplay
!= native_mode
->vdisplay
))
1447 if ((amdgpu_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_DISPLAYPORT
) ||
1448 (amdgpu_dig_connector
->dp_sink_type
== CONNECTOR_OBJECT_ID_eDP
)) {
1449 return amdgpu_atombios_dp_mode_valid_helper(connector
, mode
);
1451 if (drm_detect_hdmi_monitor(amdgpu_connector_edid(connector
))) {
1452 /* HDMI 1.3+ supports max clock of 340 Mhz */
1453 if (mode
->clock
> 340000)
1454 return MODE_CLOCK_HIGH
;
1456 if (mode
->clock
> 165000)
1457 return MODE_CLOCK_HIGH
;
1465 static const struct drm_connector_helper_funcs amdgpu_connector_dp_helper_funcs
= {
1466 .get_modes
= amdgpu_connector_dp_get_modes
,
1467 .mode_valid
= amdgpu_connector_dp_mode_valid
,
1468 .best_encoder
= amdgpu_connector_dvi_encoder
,
1471 static const struct drm_connector_funcs amdgpu_connector_dp_funcs
= {
1472 .dpms
= drm_helper_connector_dpms
,
1473 .detect
= amdgpu_connector_dp_detect
,
1474 .fill_modes
= drm_helper_probe_single_connector_modes
,
1475 .set_property
= amdgpu_connector_set_property
,
1476 .early_unregister
= amdgpu_connector_unregister
,
1477 .destroy
= amdgpu_connector_destroy
,
1478 .force
= amdgpu_connector_dvi_force
,
1481 static const struct drm_connector_funcs amdgpu_connector_edp_funcs
= {
1482 .dpms
= drm_helper_connector_dpms
,
1483 .detect
= amdgpu_connector_dp_detect
,
1484 .fill_modes
= drm_helper_probe_single_connector_modes
,
1485 .set_property
= amdgpu_connector_set_lcd_property
,
1486 .early_unregister
= amdgpu_connector_unregister
,
1487 .destroy
= amdgpu_connector_destroy
,
1488 .force
= amdgpu_connector_dvi_force
,
1492 amdgpu_connector_add(struct amdgpu_device
*adev
,
1493 uint32_t connector_id
,
1494 uint32_t supported_device
,
1496 struct amdgpu_i2c_bus_rec
*i2c_bus
,
1497 uint16_t connector_object_id
,
1498 struct amdgpu_hpd
*hpd
,
1499 struct amdgpu_router
*router
)
1501 struct drm_device
*dev
= adev
->ddev
;
1502 struct drm_connector
*connector
;
1503 struct amdgpu_connector
*amdgpu_connector
;
1504 struct amdgpu_connector_atom_dig
*amdgpu_dig_connector
;
1505 struct drm_encoder
*encoder
;
1506 struct amdgpu_encoder
*amdgpu_encoder
;
1507 uint32_t subpixel_order
= SubPixelNone
;
1508 bool shared_ddc
= false;
1509 bool is_dp_bridge
= false;
1510 bool has_aux
= false;
1512 if (connector_type
== DRM_MODE_CONNECTOR_Unknown
)
1515 /* see if we already added it */
1516 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
1517 amdgpu_connector
= to_amdgpu_connector(connector
);
1518 if (amdgpu_connector
->connector_id
== connector_id
) {
1519 amdgpu_connector
->devices
|= supported_device
;
1522 if (amdgpu_connector
->ddc_bus
&& i2c_bus
->valid
) {
1523 if (amdgpu_connector
->ddc_bus
->rec
.i2c_id
== i2c_bus
->i2c_id
) {
1524 amdgpu_connector
->shared_ddc
= true;
1527 if (amdgpu_connector
->router_bus
&& router
->ddc_valid
&&
1528 (amdgpu_connector
->router
.router_id
== router
->router_id
)) {
1529 amdgpu_connector
->shared_ddc
= false;
1535 /* check if it's a dp bridge */
1536 list_for_each_entry(encoder
, &dev
->mode_config
.encoder_list
, head
) {
1537 amdgpu_encoder
= to_amdgpu_encoder(encoder
);
1538 if (amdgpu_encoder
->devices
& supported_device
) {
1539 switch (amdgpu_encoder
->encoder_id
) {
1540 case ENCODER_OBJECT_ID_TRAVIS
:
1541 case ENCODER_OBJECT_ID_NUTMEG
:
1542 is_dp_bridge
= true;
1550 amdgpu_connector
= kzalloc(sizeof(struct amdgpu_connector
), GFP_KERNEL
);
1551 if (!amdgpu_connector
)
1554 connector
= &amdgpu_connector
->base
;
1556 amdgpu_connector
->connector_id
= connector_id
;
1557 amdgpu_connector
->devices
= supported_device
;
1558 amdgpu_connector
->shared_ddc
= shared_ddc
;
1559 amdgpu_connector
->connector_object_id
= connector_object_id
;
1560 amdgpu_connector
->hpd
= *hpd
;
1562 amdgpu_connector
->router
= *router
;
1563 if (router
->ddc_valid
|| router
->cd_valid
) {
1564 amdgpu_connector
->router_bus
= amdgpu_i2c_lookup(adev
, &router
->i2c_info
);
1565 if (!amdgpu_connector
->router_bus
)
1566 DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n");
1570 amdgpu_dig_connector
= kzalloc(sizeof(struct amdgpu_connector_atom_dig
), GFP_KERNEL
);
1571 if (!amdgpu_dig_connector
)
1573 amdgpu_connector
->con_priv
= amdgpu_dig_connector
;
1574 if (i2c_bus
->valid
) {
1575 amdgpu_connector
->ddc_bus
= amdgpu_i2c_lookup(adev
, i2c_bus
);
1576 if (amdgpu_connector
->ddc_bus
)
1579 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1581 switch (connector_type
) {
1582 case DRM_MODE_CONNECTOR_VGA
:
1583 case DRM_MODE_CONNECTOR_DVIA
:
1585 drm_connector_init(dev
, &amdgpu_connector
->base
,
1586 &amdgpu_connector_dp_funcs
, connector_type
);
1587 drm_connector_helper_add(&amdgpu_connector
->base
,
1588 &amdgpu_connector_dp_helper_funcs
);
1589 connector
->interlace_allowed
= true;
1590 connector
->doublescan_allowed
= true;
1591 amdgpu_connector
->dac_load_detect
= true;
1592 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1593 adev
->mode_info
.load_detect_property
,
1595 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1596 dev
->mode_config
.scaling_mode_property
,
1597 DRM_MODE_SCALE_NONE
);
1599 case DRM_MODE_CONNECTOR_DVII
:
1600 case DRM_MODE_CONNECTOR_DVID
:
1601 case DRM_MODE_CONNECTOR_HDMIA
:
1602 case DRM_MODE_CONNECTOR_HDMIB
:
1603 case DRM_MODE_CONNECTOR_DisplayPort
:
1604 drm_connector_init(dev
, &amdgpu_connector
->base
,
1605 &amdgpu_connector_dp_funcs
, connector_type
);
1606 drm_connector_helper_add(&amdgpu_connector
->base
,
1607 &amdgpu_connector_dp_helper_funcs
);
1608 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1609 adev
->mode_info
.underscan_property
,
1611 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1612 adev
->mode_info
.underscan_hborder_property
,
1614 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1615 adev
->mode_info
.underscan_vborder_property
,
1618 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1619 dev
->mode_config
.scaling_mode_property
,
1620 DRM_MODE_SCALE_NONE
);
1622 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1623 adev
->mode_info
.dither_property
,
1624 AMDGPU_FMT_DITHER_DISABLE
);
1626 if (amdgpu_audio
!= 0)
1627 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1628 adev
->mode_info
.audio_property
,
1631 subpixel_order
= SubPixelHorizontalRGB
;
1632 connector
->interlace_allowed
= true;
1633 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
1634 connector
->doublescan_allowed
= true;
1636 connector
->doublescan_allowed
= false;
1637 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1638 amdgpu_connector
->dac_load_detect
= true;
1639 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1640 adev
->mode_info
.load_detect_property
,
1644 case DRM_MODE_CONNECTOR_LVDS
:
1645 case DRM_MODE_CONNECTOR_eDP
:
1646 drm_connector_init(dev
, &amdgpu_connector
->base
,
1647 &amdgpu_connector_edp_funcs
, connector_type
);
1648 drm_connector_helper_add(&amdgpu_connector
->base
,
1649 &amdgpu_connector_dp_helper_funcs
);
1650 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1651 dev
->mode_config
.scaling_mode_property
,
1652 DRM_MODE_SCALE_FULLSCREEN
);
1653 subpixel_order
= SubPixelHorizontalRGB
;
1654 connector
->interlace_allowed
= false;
1655 connector
->doublescan_allowed
= false;
1659 switch (connector_type
) {
1660 case DRM_MODE_CONNECTOR_VGA
:
1661 drm_connector_init(dev
, &amdgpu_connector
->base
, &amdgpu_connector_vga_funcs
, connector_type
);
1662 drm_connector_helper_add(&amdgpu_connector
->base
, &amdgpu_connector_vga_helper_funcs
);
1663 if (i2c_bus
->valid
) {
1664 amdgpu_connector
->ddc_bus
= amdgpu_i2c_lookup(adev
, i2c_bus
);
1665 if (!amdgpu_connector
->ddc_bus
)
1666 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1668 amdgpu_connector
->dac_load_detect
= true;
1669 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1670 adev
->mode_info
.load_detect_property
,
1672 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1673 dev
->mode_config
.scaling_mode_property
,
1674 DRM_MODE_SCALE_NONE
);
1675 /* no HPD on analog connectors */
1676 amdgpu_connector
->hpd
.hpd
= AMDGPU_HPD_NONE
;
1677 connector
->interlace_allowed
= true;
1678 connector
->doublescan_allowed
= true;
1680 case DRM_MODE_CONNECTOR_DVIA
:
1681 drm_connector_init(dev
, &amdgpu_connector
->base
, &amdgpu_connector_vga_funcs
, connector_type
);
1682 drm_connector_helper_add(&amdgpu_connector
->base
, &amdgpu_connector_vga_helper_funcs
);
1683 if (i2c_bus
->valid
) {
1684 amdgpu_connector
->ddc_bus
= amdgpu_i2c_lookup(adev
, i2c_bus
);
1685 if (!amdgpu_connector
->ddc_bus
)
1686 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1688 amdgpu_connector
->dac_load_detect
= true;
1689 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1690 adev
->mode_info
.load_detect_property
,
1692 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1693 dev
->mode_config
.scaling_mode_property
,
1694 DRM_MODE_SCALE_NONE
);
1695 /* no HPD on analog connectors */
1696 amdgpu_connector
->hpd
.hpd
= AMDGPU_HPD_NONE
;
1697 connector
->interlace_allowed
= true;
1698 connector
->doublescan_allowed
= true;
1700 case DRM_MODE_CONNECTOR_DVII
:
1701 case DRM_MODE_CONNECTOR_DVID
:
1702 amdgpu_dig_connector
= kzalloc(sizeof(struct amdgpu_connector_atom_dig
), GFP_KERNEL
);
1703 if (!amdgpu_dig_connector
)
1705 amdgpu_connector
->con_priv
= amdgpu_dig_connector
;
1706 drm_connector_init(dev
, &amdgpu_connector
->base
, &amdgpu_connector_dvi_funcs
, connector_type
);
1707 drm_connector_helper_add(&amdgpu_connector
->base
, &amdgpu_connector_dvi_helper_funcs
);
1708 if (i2c_bus
->valid
) {
1709 amdgpu_connector
->ddc_bus
= amdgpu_i2c_lookup(adev
, i2c_bus
);
1710 if (!amdgpu_connector
->ddc_bus
)
1711 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1713 subpixel_order
= SubPixelHorizontalRGB
;
1714 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1715 adev
->mode_info
.coherent_mode_property
,
1717 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1718 adev
->mode_info
.underscan_property
,
1720 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1721 adev
->mode_info
.underscan_hborder_property
,
1723 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1724 adev
->mode_info
.underscan_vborder_property
,
1726 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1727 dev
->mode_config
.scaling_mode_property
,
1728 DRM_MODE_SCALE_NONE
);
1730 if (amdgpu_audio
!= 0) {
1731 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1732 adev
->mode_info
.audio_property
,
1735 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1736 adev
->mode_info
.dither_property
,
1737 AMDGPU_FMT_DITHER_DISABLE
);
1738 if (connector_type
== DRM_MODE_CONNECTOR_DVII
) {
1739 amdgpu_connector
->dac_load_detect
= true;
1740 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1741 adev
->mode_info
.load_detect_property
,
1744 connector
->interlace_allowed
= true;
1745 if (connector_type
== DRM_MODE_CONNECTOR_DVII
)
1746 connector
->doublescan_allowed
= true;
1748 connector
->doublescan_allowed
= false;
1750 case DRM_MODE_CONNECTOR_HDMIA
:
1751 case DRM_MODE_CONNECTOR_HDMIB
:
1752 amdgpu_dig_connector
= kzalloc(sizeof(struct amdgpu_connector_atom_dig
), GFP_KERNEL
);
1753 if (!amdgpu_dig_connector
)
1755 amdgpu_connector
->con_priv
= amdgpu_dig_connector
;
1756 drm_connector_init(dev
, &amdgpu_connector
->base
, &amdgpu_connector_dvi_funcs
, connector_type
);
1757 drm_connector_helper_add(&amdgpu_connector
->base
, &amdgpu_connector_dvi_helper_funcs
);
1758 if (i2c_bus
->valid
) {
1759 amdgpu_connector
->ddc_bus
= amdgpu_i2c_lookup(adev
, i2c_bus
);
1760 if (!amdgpu_connector
->ddc_bus
)
1761 DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1763 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1764 adev
->mode_info
.coherent_mode_property
,
1766 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1767 adev
->mode_info
.underscan_property
,
1769 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1770 adev
->mode_info
.underscan_hborder_property
,
1772 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1773 adev
->mode_info
.underscan_vborder_property
,
1775 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1776 dev
->mode_config
.scaling_mode_property
,
1777 DRM_MODE_SCALE_NONE
);
1778 if (amdgpu_audio
!= 0) {
1779 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1780 adev
->mode_info
.audio_property
,
1783 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1784 adev
->mode_info
.dither_property
,
1785 AMDGPU_FMT_DITHER_DISABLE
);
1786 subpixel_order
= SubPixelHorizontalRGB
;
1787 connector
->interlace_allowed
= true;
1788 if (connector_type
== DRM_MODE_CONNECTOR_HDMIB
)
1789 connector
->doublescan_allowed
= true;
1791 connector
->doublescan_allowed
= false;
1793 case DRM_MODE_CONNECTOR_DisplayPort
:
1794 amdgpu_dig_connector
= kzalloc(sizeof(struct amdgpu_connector_atom_dig
), GFP_KERNEL
);
1795 if (!amdgpu_dig_connector
)
1797 amdgpu_connector
->con_priv
= amdgpu_dig_connector
;
1798 drm_connector_init(dev
, &amdgpu_connector
->base
, &amdgpu_connector_dp_funcs
, connector_type
);
1799 drm_connector_helper_add(&amdgpu_connector
->base
, &amdgpu_connector_dp_helper_funcs
);
1800 if (i2c_bus
->valid
) {
1801 amdgpu_connector
->ddc_bus
= amdgpu_i2c_lookup(adev
, i2c_bus
);
1802 if (amdgpu_connector
->ddc_bus
)
1805 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1807 subpixel_order
= SubPixelHorizontalRGB
;
1808 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1809 adev
->mode_info
.coherent_mode_property
,
1811 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1812 adev
->mode_info
.underscan_property
,
1814 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1815 adev
->mode_info
.underscan_hborder_property
,
1817 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1818 adev
->mode_info
.underscan_vborder_property
,
1820 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1821 dev
->mode_config
.scaling_mode_property
,
1822 DRM_MODE_SCALE_NONE
);
1823 if (amdgpu_audio
!= 0) {
1824 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1825 adev
->mode_info
.audio_property
,
1828 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1829 adev
->mode_info
.dither_property
,
1830 AMDGPU_FMT_DITHER_DISABLE
);
1831 connector
->interlace_allowed
= true;
1832 /* in theory with a DP to VGA converter... */
1833 connector
->doublescan_allowed
= false;
1835 case DRM_MODE_CONNECTOR_eDP
:
1836 amdgpu_dig_connector
= kzalloc(sizeof(struct amdgpu_connector_atom_dig
), GFP_KERNEL
);
1837 if (!amdgpu_dig_connector
)
1839 amdgpu_connector
->con_priv
= amdgpu_dig_connector
;
1840 drm_connector_init(dev
, &amdgpu_connector
->base
, &amdgpu_connector_edp_funcs
, connector_type
);
1841 drm_connector_helper_add(&amdgpu_connector
->base
, &amdgpu_connector_dp_helper_funcs
);
1842 if (i2c_bus
->valid
) {
1843 amdgpu_connector
->ddc_bus
= amdgpu_i2c_lookup(adev
, i2c_bus
);
1844 if (amdgpu_connector
->ddc_bus
)
1847 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1849 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1850 dev
->mode_config
.scaling_mode_property
,
1851 DRM_MODE_SCALE_FULLSCREEN
);
1852 subpixel_order
= SubPixelHorizontalRGB
;
1853 connector
->interlace_allowed
= false;
1854 connector
->doublescan_allowed
= false;
1856 case DRM_MODE_CONNECTOR_LVDS
:
1857 amdgpu_dig_connector
= kzalloc(sizeof(struct amdgpu_connector_atom_dig
), GFP_KERNEL
);
1858 if (!amdgpu_dig_connector
)
1860 amdgpu_connector
->con_priv
= amdgpu_dig_connector
;
1861 drm_connector_init(dev
, &amdgpu_connector
->base
, &amdgpu_connector_lvds_funcs
, connector_type
);
1862 drm_connector_helper_add(&amdgpu_connector
->base
, &amdgpu_connector_lvds_helper_funcs
);
1863 if (i2c_bus
->valid
) {
1864 amdgpu_connector
->ddc_bus
= amdgpu_i2c_lookup(adev
, i2c_bus
);
1865 if (!amdgpu_connector
->ddc_bus
)
1866 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1868 drm_object_attach_property(&amdgpu_connector
->base
.base
,
1869 dev
->mode_config
.scaling_mode_property
,
1870 DRM_MODE_SCALE_FULLSCREEN
);
1871 subpixel_order
= SubPixelHorizontalRGB
;
1872 connector
->interlace_allowed
= false;
1873 connector
->doublescan_allowed
= false;
1878 if (amdgpu_connector
->hpd
.hpd
== AMDGPU_HPD_NONE
) {
1879 if (i2c_bus
->valid
) {
1880 connector
->polled
= DRM_CONNECTOR_POLL_CONNECT
|
1881 DRM_CONNECTOR_POLL_DISCONNECT
;
1884 connector
->polled
= DRM_CONNECTOR_POLL_HPD
;
1886 connector
->display_info
.subpixel_order
= subpixel_order
;
1887 drm_connector_register(connector
);
1890 amdgpu_atombios_dp_aux_init(amdgpu_connector
);
1895 drm_connector_cleanup(connector
);