Skip to content

Commit 89fc8d4

Browse files
Harry Wentlandalexdeucher
authored andcommitted
drm/amd/display: Only register backlight device if embedded panel connected
Signed-off-by: Harry Wentland <[email protected]> Reviewed-by: Tony Cheng <[email protected]> Acked-by: Harry Wentland <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent c3d7bad commit 89fc8d4

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,28 @@ static int initialize_plane(struct amdgpu_display_manager *dm,
14031403
return ret;
14041404
}
14051405

1406+
1407+
static void register_backlight_device(struct amdgpu_display_manager *dm,
1408+
struct dc_link *link)
1409+
{
1410+
#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) ||\
1411+
defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
1412+
1413+
if ((link->connector_signal & (SIGNAL_TYPE_EDP | SIGNAL_TYPE_LVDS)) &&
1414+
link->type != dc_connection_none) {
1415+
/* Event if registration failed, we should continue with
1416+
* DM initialization because not having a backlight control
1417+
* is better then a black screen.
1418+
*/
1419+
amdgpu_dm_register_backlight_device(dm);
1420+
1421+
if (dm->backlight_dev)
1422+
dm->backlight_link = link;
1423+
}
1424+
#endif
1425+
}
1426+
1427+
14061428
/* In this architecture, the association
14071429
* connector -> encoder -> crtc
14081430
* id not really requried. The crtc and connector will hold the
@@ -1456,6 +1478,7 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
14561478

14571479
/* loops over all connectors on the board */
14581480
for (i = 0; i < link_cnt; i++) {
1481+
struct dc_link *link = NULL;
14591482

14601483
if (i > AMDGPU_DM_MAX_DISPLAY_INDEX) {
14611484
DRM_ERROR(
@@ -1482,9 +1505,14 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
14821505
goto fail;
14831506
}
14841507

1485-
if (dc_link_detect(dc_get_link_at_index(dm->dc, i),
1486-
DETECT_REASON_BOOT))
1508+
link = dc_get_link_at_index(dm->dc, i);
1509+
1510+
if (dc_link_detect(link, DETECT_REASON_BOOT)) {
14871511
amdgpu_dm_update_connector_after_detect(aconnector);
1512+
register_backlight_device(dm, link);
1513+
}
1514+
1515+
14881516
}
14891517

14901518
/* Software is initialized. Now we can register interrupt handlers. */
@@ -2685,7 +2713,8 @@ static void amdgpu_dm_connector_destroy(struct drm_connector *connector)
26852713
#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) ||\
26862714
defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
26872715

2688-
if (link->connector_signal & (SIGNAL_TYPE_EDP | SIGNAL_TYPE_LVDS)) {
2716+
if ((link->connector_signal & (SIGNAL_TYPE_EDP | SIGNAL_TYPE_LVDS)) &&
2717+
link->type != dc_connection_none) {
26892718
amdgpu_dm_register_backlight_device(dm);
26902719

26912720
if (dm->backlight_dev) {
@@ -3561,6 +3590,7 @@ create_i2c(struct ddc_service *ddc_service,
35613590
return i2c;
35623591
}
35633592

3593+
35643594
/* Note: this function assumes that dc_link_detect() was called for the
35653595
* dc_link which will be represented by this aconnector.
35663596
*/
@@ -3630,28 +3660,6 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
36303660
|| connector_type == DRM_MODE_CONNECTOR_eDP)
36313661
amdgpu_dm_initialize_dp_connector(dm, aconnector);
36323662

3633-
#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) ||\
3634-
defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
3635-
3636-
/* NOTE: this currently will create backlight device even if a panel
3637-
* is not connected to the eDP/LVDS connector.
3638-
*
3639-
* This is less than ideal but we don't have sink information at this
3640-
* stage since detection happens after. We can't do detection earlier
3641-
* since MST detection needs connectors to be created first.
3642-
*/
3643-
if (link->connector_signal & (SIGNAL_TYPE_EDP | SIGNAL_TYPE_LVDS)) {
3644-
/* Event if registration failed, we should continue with
3645-
* DM initialization because not having a backlight control
3646-
* is better then a black screen.
3647-
*/
3648-
amdgpu_dm_register_backlight_device(dm);
3649-
3650-
if (dm->backlight_dev)
3651-
dm->backlight_link = link;
3652-
}
3653-
#endif
3654-
36553663
out_free:
36563664
if (res) {
36573665
kfree(i2c);

0 commit comments

Comments
 (0)