Commit f196198c authored by Hans de Goede's avatar Hans de Goede Committed by Alex Deucher

drm/amd/display/amdgpu_dm: Add a bl_idx to amdgpu_dm_connector

Currently functions like update_connector_ext_caps() and
amdgpu_dm_connector_destroy() are iterating over dm->backlight_link[i]
to find the index of the (optional) backlight_dev associated with
the connector.

Instead make register_backlight_device() store the dm->backlight_dev[]
index used for the connector inside the amdgpu_dm_connector struct.

This removes the need to iterate over the dm->backlight_link[]
array and this is necessary as a preparation patch for moving
the actual backlight_device_register()
call to drm_connector_funcs.late_register.

While reworking update_connector_ext_caps() also remove the aconnector
and aconnector->dc_link NULL checks in this function. These are both
never NULL and are unconditionally derefed in its callers.
Reviewed-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 0e909e4f
...@@ -2975,30 +2975,18 @@ static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = { ...@@ -2975,30 +2975,18 @@ static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = {
static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector) static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
{ {
struct amdgpu_dm_backlight_caps *caps; struct amdgpu_dm_backlight_caps *caps;
struct amdgpu_display_manager *dm;
struct drm_connector *conn_base; struct drm_connector *conn_base;
struct amdgpu_device *adev; struct amdgpu_device *adev;
struct dc_link *link = NULL;
struct drm_luminance_range_info *luminance_range; struct drm_luminance_range_info *luminance_range;
int i;
if (!aconnector || !aconnector->dc_link)
return;
link = aconnector->dc_link; if (aconnector->bl_idx == -1 ||
if (link->connector_signal != SIGNAL_TYPE_EDP) aconnector->dc_link->connector_signal != SIGNAL_TYPE_EDP)
return; return;
conn_base = &aconnector->base; conn_base = &aconnector->base;
adev = drm_to_adev(conn_base->dev); adev = drm_to_adev(conn_base->dev);
dm = &adev->dm;
for (i = 0; i < dm->num_of_edps; i++) { caps = &adev->dm.backlight_caps[aconnector->bl_idx];
if (link == dm->backlight_link[i])
break;
}
if (i >= dm->num_of_edps)
return;
caps = &dm->backlight_caps[i];
caps->ext_caps = &aconnector->dc_link->dpcd_sink_ext_caps; caps->ext_caps = &aconnector->dc_link->dpcd_sink_ext_caps;
caps->aux_support = false; caps->aux_support = false;
...@@ -4266,8 +4254,9 @@ static int initialize_plane(struct amdgpu_display_manager *dm, ...@@ -4266,8 +4254,9 @@ static int initialize_plane(struct amdgpu_display_manager *dm,
static void register_backlight_device(struct amdgpu_display_manager *dm, static void register_backlight_device(struct amdgpu_display_manager *dm,
struct dc_link *link) struct amdgpu_dm_connector *aconnector)
{ {
struct dc_link *link = aconnector->dc_link;
int bl_idx = dm->num_of_edps; int bl_idx = dm->num_of_edps;
if (!(link->connector_signal & (SIGNAL_TYPE_EDP | SIGNAL_TYPE_LVDS)) || if (!(link->connector_signal & (SIGNAL_TYPE_EDP | SIGNAL_TYPE_LVDS)) ||
...@@ -4279,9 +4268,13 @@ static void register_backlight_device(struct amdgpu_display_manager *dm, ...@@ -4279,9 +4268,13 @@ static void register_backlight_device(struct amdgpu_display_manager *dm,
return; return;
} }
aconnector->bl_idx = bl_idx;
amdgpu_dm_register_backlight_device(dm); amdgpu_dm_register_backlight_device(dm);
if (!dm->backlight_dev[bl_idx]) if (!dm->backlight_dev[bl_idx]) {
aconnector->bl_idx = -1;
return; return;
}
dm->backlight_link[bl_idx] = link; dm->backlight_link[bl_idx] = link;
dm->num_of_edps++; dm->num_of_edps++;
...@@ -4464,7 +4457,7 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) ...@@ -4464,7 +4457,7 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)
if (ret) { if (ret) {
amdgpu_dm_update_connector_after_detect(aconnector); amdgpu_dm_update_connector_after_detect(aconnector);
register_backlight_device(dm, link); register_backlight_device(dm, aconnector);
if (dm->num_of_edps) if (dm->num_of_edps)
update_connector_ext_caps(aconnector); update_connector_ext_caps(aconnector);
...@@ -6243,10 +6236,8 @@ static void amdgpu_dm_connector_unregister(struct drm_connector *connector) ...@@ -6243,10 +6236,8 @@ static void amdgpu_dm_connector_unregister(struct drm_connector *connector)
static void amdgpu_dm_connector_destroy(struct drm_connector *connector) static void amdgpu_dm_connector_destroy(struct drm_connector *connector)
{ {
struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
const struct dc_link *link = aconnector->dc_link;
struct amdgpu_device *adev = drm_to_adev(connector->dev); struct amdgpu_device *adev = drm_to_adev(connector->dev);
struct amdgpu_display_manager *dm = &adev->dm; struct amdgpu_display_manager *dm = &adev->dm;
int i;
/* /*
* Call only if mst_mgr was initialized before since it's not done * Call only if mst_mgr was initialized before since it's not done
...@@ -6255,11 +6246,9 @@ static void amdgpu_dm_connector_destroy(struct drm_connector *connector) ...@@ -6255,11 +6246,9 @@ static void amdgpu_dm_connector_destroy(struct drm_connector *connector)
if (aconnector->mst_mgr.dev) if (aconnector->mst_mgr.dev)
drm_dp_mst_topology_mgr_destroy(&aconnector->mst_mgr); drm_dp_mst_topology_mgr_destroy(&aconnector->mst_mgr);
for (i = 0; i < dm->num_of_edps; i++) { if (aconnector->bl_idx != -1) {
if ((link == dm->backlight_link[i]) && dm->backlight_dev[i]) { backlight_device_unregister(dm->backlight_dev[aconnector->bl_idx]);
backlight_device_unregister(dm->backlight_dev[i]); dm->backlight_dev[aconnector->bl_idx] = NULL;
dm->backlight_dev[i] = NULL;
}
} }
if (aconnector->dc_em_sink) if (aconnector->dc_em_sink)
...@@ -7229,6 +7218,7 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm, ...@@ -7229,6 +7218,7 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
aconnector->base.funcs->reset(&aconnector->base); aconnector->base.funcs->reset(&aconnector->base);
aconnector->connector_id = link_index; aconnector->connector_id = link_index;
aconnector->bl_idx = -1;
aconnector->dc_link = link; aconnector->dc_link = link;
aconnector->base.interlace_allowed = false; aconnector->base.interlace_allowed = false;
aconnector->base.doublescan_allowed = false; aconnector->base.doublescan_allowed = false;
......
...@@ -610,6 +610,7 @@ struct amdgpu_dm_connector { ...@@ -610,6 +610,7 @@ struct amdgpu_dm_connector {
struct drm_connector base; struct drm_connector base;
uint32_t connector_id; uint32_t connector_id;
int bl_idx;
/* we need to mind the EDID between detect /* we need to mind the EDID between detect
and get modes due to analog/digital/tvencoder */ and get modes due to analog/digital/tvencoder */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment