Commit fefe92fe authored by Anthony Koo's avatar Anthony Koo Committed by Alex Deucher

drm/amd/display: make all backlight calls link based

[Why]
Backlight adjustment is tied to a specific display.  So make the calls
target a link rather than making it a global state.

[How]
make all backlight calls link based
Signed-off-by: default avatarAnthony Koo <Anthony.Koo@amd.com>
Reviewed-by: default avatarTony Cheng <Tony.Cheng@amd.com>
Acked-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 06535a48
...@@ -1228,8 +1228,9 @@ static int current_backlight_read(struct seq_file *m, void *data) ...@@ -1228,8 +1228,9 @@ static int current_backlight_read(struct seq_file *m, void *data)
struct drm_info_node *node = (struct drm_info_node *)m->private; struct drm_info_node *node = (struct drm_info_node *)m->private;
struct drm_device *dev = node->minor->dev; struct drm_device *dev = node->minor->dev;
struct amdgpu_device *adev = dev->dev_private; struct amdgpu_device *adev = dev->dev_private;
struct dc *dc = adev->dm.dc; struct amdgpu_display_manager *dm = &adev->dm;
unsigned int backlight = dc_get_current_backlight_pwm(dc);
unsigned int backlight = dc_link_get_backlight_level(dm->backlight_link);
seq_printf(m, "0x%x\n", backlight); seq_printf(m, "0x%x\n", backlight);
return 0; return 0;
...@@ -1245,8 +1246,9 @@ static int target_backlight_read(struct seq_file *m, void *data) ...@@ -1245,8 +1246,9 @@ static int target_backlight_read(struct seq_file *m, void *data)
struct drm_info_node *node = (struct drm_info_node *)m->private; struct drm_info_node *node = (struct drm_info_node *)m->private;
struct drm_device *dev = node->minor->dev; struct drm_device *dev = node->minor->dev;
struct amdgpu_device *adev = dev->dev_private; struct amdgpu_device *adev = dev->dev_private;
struct dc *dc = adev->dm.dc; struct amdgpu_display_manager *dm = &adev->dm;
unsigned int backlight = dc_get_target_backlight_pwm(dc);
unsigned int backlight = dc_link_get_target_backlight_pwm(dm->backlight_link);
seq_printf(m, "0x%x\n", backlight); seq_printf(m, "0x%x\n", backlight);
return 0; return 0;
......
...@@ -2646,33 +2646,12 @@ void dc_set_power_state( ...@@ -2646,33 +2646,12 @@ void dc_set_power_state(
void dc_resume(struct dc *dc) void dc_resume(struct dc *dc)
{ {
uint32_t i; uint32_t i;
for (i = 0; i < dc->link_count; i++) for (i = 0; i < dc->link_count; i++)
core_link_resume(dc->links[i]); core_link_resume(dc->links[i]);
} }
unsigned int dc_get_current_backlight_pwm(struct dc *dc)
{
struct abm *abm = dc->res_pool->abm;
if (abm)
return abm->funcs->get_current_backlight(abm);
return 0;
}
unsigned int dc_get_target_backlight_pwm(struct dc *dc)
{
struct abm *abm = dc->res_pool->abm;
if (abm)
return abm->funcs->get_target_backlight(abm);
return 0;
}
bool dc_is_dmcu_initialized(struct dc *dc) bool dc_is_dmcu_initialized(struct dc *dc)
{ {
struct dmcu *dmcu = dc->res_pool->dmcu; struct dmcu *dmcu = dc->res_pool->dmcu;
......
...@@ -2450,6 +2450,16 @@ int dc_link_get_backlight_level(const struct dc_link *link) ...@@ -2450,6 +2450,16 @@ int dc_link_get_backlight_level(const struct dc_link *link)
return (int) abm->funcs->get_current_backlight(abm); return (int) abm->funcs->get_current_backlight(abm);
} }
int dc_link_get_target_backlight_pwm(const struct dc_link *link)
{
struct abm *abm = link->ctx->dc->res_pool->abm;
if (abm == NULL || abm->funcs->get_target_backlight == NULL)
return DC_ERROR_UNEXPECTED;
return (int) abm->funcs->get_target_backlight(abm);
}
bool dc_link_set_backlight_level(const struct dc_link *link, bool dc_link_set_backlight_level(const struct dc_link *link,
uint32_t backlight_pwm_u16_16, uint32_t backlight_pwm_u16_16,
uint32_t frame_ramp) uint32_t frame_ramp)
...@@ -2507,14 +2517,24 @@ bool dc_link_set_backlight_level(const struct dc_link *link, ...@@ -2507,14 +2517,24 @@ bool dc_link_set_backlight_level(const struct dc_link *link,
bool dc_link_set_abm_disable(const struct dc_link *link) bool dc_link_set_abm_disable(const struct dc_link *link)
{ {
struct dc *dc = link->ctx->dc; struct dc *dc = link->ctx->dc;
struct abm *abm = dc->res_pool->abm; struct abm *abm = NULL;
bool success = false;
int i;
if ((abm == NULL) || (abm->funcs->set_backlight_level_pwm == NULL)) for (i = 0; i < MAX_PIPES; i++) {
return false; struct pipe_ctx pipe_ctx = dc->current_state->res_ctx.pipe_ctx[i];
struct dc_stream_state *stream = pipe_ctx.stream;
if (stream && stream->link == link) {
abm = pipe_ctx.stream_res.abm;
break;
}
}
abm->funcs->set_abm_immediate_disable(abm); if (abm)
success = abm->funcs->set_abm_immediate_disable(abm);
return true; return success;
} }
bool dc_link_set_psr_allow_active(struct dc_link *link, bool allow_active, bool wait) bool dc_link_set_psr_allow_active(struct dc_link *link, bool allow_active, bool wait)
......
...@@ -1139,8 +1139,6 @@ void dc_set_power_state( ...@@ -1139,8 +1139,6 @@ void dc_set_power_state(
struct dc *dc, struct dc *dc,
enum dc_acpi_cm_power_state power_state); enum dc_acpi_cm_power_state power_state);
void dc_resume(struct dc *dc); void dc_resume(struct dc *dc);
unsigned int dc_get_current_backlight_pwm(struct dc *dc);
unsigned int dc_get_target_backlight_pwm(struct dc *dc);
#if defined(CONFIG_DRM_AMD_DC_HDCP) #if defined(CONFIG_DRM_AMD_DC_HDCP)
/* /*
......
...@@ -217,6 +217,8 @@ bool dc_link_set_default_brightness_aux(struct dc_link *link); ...@@ -217,6 +217,8 @@ bool dc_link_set_default_brightness_aux(struct dc_link *link);
int dc_link_get_backlight_level(const struct dc_link *dc_link); int dc_link_get_backlight_level(const struct dc_link *dc_link);
int dc_link_get_target_backlight_pwm(const struct dc_link *link);
bool dc_link_set_abm_disable(const struct dc_link *dc_link); bool dc_link_set_abm_disable(const struct dc_link *dc_link);
bool dc_link_set_psr_allow_active(struct dc_link *dc_link, bool enable, bool wait); bool dc_link_set_psr_allow_active(struct dc_link *dc_link, bool enable, bool wait);
......
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