Commit 0749ddeb authored by Eryk Brol's avatar Eryk Brol Committed by Alex Deucher

drm/amd/display: Add DSC force disable to dsc_clock_en debugfs entry

[why]
For debug purposes we want not to enable DSC on certain connectors
even if algorithm deesires to do so, instead it should enable DSC
on other capable connectors or fail the atomic check.

[how]
Adding the third option to connector's debugfs entry dsc_clock_en.

Accepted inputs:
     0x0 - connector is using default DSC enablement policy
     0x1 - force enable DSC on the connector, if it supports DSC
     0x2 - force disable DSC on the connector, if DSC is supported

Ex. # echo 0x2 > /sys/kernel/debug/dri/0/DP-1/dsc_clock_en
Signed-off-by: default avatarEryk Brol <eryk.brol@amd.com>
Signed-off-by: default avatarMikita Lipski <mikita.lipski@amd.com>
Acked-by: default avatarAurabindo Pillai <aurabindo.pillai@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 20cc44c9
...@@ -4685,9 +4685,10 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -4685,9 +4685,10 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
dc_link_get_link_cap(aconnector->dc_link)); dc_link_get_link_cap(aconnector->dc_link));
#if defined(CONFIG_DRM_AMD_DC_DCN) #if defined(CONFIG_DRM_AMD_DC_DCN)
if (dsc_caps.is_dsc_supported) { if (aconnector->dsc_settings.dsc_force_enable != DSC_CLK_FORCE_DISABLE && dsc_caps.is_dsc_supported) {
/* Set DSC policy according to dsc_clock_en */ /* Set DSC policy according to dsc_clock_en */
dc_dsc_policy_set_enable_dsc_when_not_needed(aconnector->dsc_settings.dsc_clock_en); dc_dsc_policy_set_enable_dsc_when_not_needed(
aconnector->dsc_settings.dsc_force_enable == DSC_CLK_FORCE_ENABLE);
if (dc_dsc_compute_config(aconnector->dc_link->ctx->dc->res_pool->dscs[0], if (dc_dsc_compute_config(aconnector->dc_link->ctx->dc->res_pool->dscs[0],
&dsc_caps, &dsc_caps,
...@@ -4697,7 +4698,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -4697,7 +4698,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
&stream->timing.dsc_cfg)) &stream->timing.dsc_cfg))
stream->timing.flags.DSC = 1; stream->timing.flags.DSC = 1;
/* Overwrite the stream flag if DSC is enabled through debugfs */ /* Overwrite the stream flag if DSC is enabled through debugfs */
if (aconnector->dsc_settings.dsc_clock_en) if (aconnector->dsc_settings.dsc_force_enable == DSC_CLK_FORCE_ENABLE)
stream->timing.flags.DSC = 1; stream->timing.flags.DSC = 1;
if (stream->timing.flags.DSC && aconnector->dsc_settings.dsc_slice_width) if (stream->timing.flags.DSC && aconnector->dsc_settings.dsc_slice_width)
......
...@@ -340,11 +340,17 @@ struct amdgpu_display_manager { ...@@ -340,11 +340,17 @@ struct amdgpu_display_manager {
* fake encoders used for DP MST. * fake encoders used for DP MST.
*/ */
struct amdgpu_encoder mst_encoders[AMDGPU_DM_MAX_CRTC]; struct amdgpu_encoder mst_encoders[AMDGPU_DM_MAX_CRTC];
bool force_timing_sync; bool force_timing_sync;
};
enum dsc_clock_force_state {
DSC_CLK_FORCE_DEFAULT = 0,
DSC_CLK_FORCE_ENABLE,
DSC_CLK_FORCE_DISABLE,
}; };
struct dsc_preferred_settings { struct dsc_preferred_settings {
bool dsc_clock_en; enum dsc_clock_force_state dsc_force_enable;
uint32_t dsc_slice_width; uint32_t dsc_slice_width;
uint32_t dsc_slice_height; uint32_t dsc_slice_height;
uint32_t dsc_bits_per_pixel; uint32_t dsc_bits_per_pixel;
......
...@@ -111,7 +111,6 @@ static int parse_write_buffer_into_params(char *wr_buf, uint32_t wr_buf_size, ...@@ -111,7 +111,6 @@ static int parse_write_buffer_into_params(char *wr_buf, uint32_t wr_buf_size,
if (*param_nums > max_param_num) if (*param_nums > max_param_num)
*param_nums = max_param_num; *param_nums = max_param_num;
;
wr_buf_ptr = wr_buf; /* reset buf pointer */ wr_buf_ptr = wr_buf; /* reset buf pointer */
wr_buf_count = 0; /* number of char already checked */ wr_buf_count = 0; /* number of char already checked */
...@@ -1200,9 +1199,14 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, char __user *buf, ...@@ -1200,9 +1199,14 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, char __user *buf,
* *
* The write function: dp_dsc_clock_en_write * The write function: dp_dsc_clock_en_write
* enables to force DSC on the connector. * enables to force DSC on the connector.
* User can write to either force enable DSC * User can write to either force enable or force disable DSC
* on the next modeset or set it to driver default * on the next modeset or set it to driver default
* *
* Accepted inputs:
* 0 - default DSC enablement policy
* 1 - force enable DSC on the connector
* 2 - force disable DSC on the connector (might cause fail in atomic_check)
*
* Writing DSC settings is done with the following command: * Writing DSC settings is done with the following command:
* - To force enable DSC (you need to specify * - To force enable DSC (you need to specify
* connector like DP-1): * connector like DP-1):
...@@ -1262,7 +1266,12 @@ static ssize_t dp_dsc_clock_en_write(struct file *f, const char __user *buf, ...@@ -1262,7 +1266,12 @@ static ssize_t dp_dsc_clock_en_write(struct file *f, const char __user *buf,
if (!pipe_ctx || !pipe_ctx->stream) if (!pipe_ctx || !pipe_ctx->stream)
goto done; goto done;
aconnector->dsc_settings.dsc_clock_en = param[0]; if (param[0] == 1)
aconnector->dsc_settings.dsc_force_enable = DSC_CLK_FORCE_ENABLE;
else if (param[0] == 2)
aconnector->dsc_settings.dsc_force_enable = DSC_CLK_FORCE_DISABLE;
else
aconnector->dsc_settings.dsc_force_enable = DSC_CLK_FORCE_DEFAULT;
done: done:
kfree(wr_buf); kfree(wr_buf);
......
...@@ -453,7 +453,7 @@ struct dsc_mst_fairness_params { ...@@ -453,7 +453,7 @@ struct dsc_mst_fairness_params {
struct dc_dsc_bw_range bw_range; struct dc_dsc_bw_range bw_range;
bool compression_possible; bool compression_possible;
struct drm_dp_mst_port *port; struct drm_dp_mst_port *port;
bool clock_overwrite; enum dsc_clock_force_state clock_force_enable;
uint32_t slice_width_overwrite; uint32_t slice_width_overwrite;
uint32_t slice_height_overwrite; uint32_t slice_height_overwrite;
uint32_t bpp_overwrite; uint32_t bpp_overwrite;
...@@ -638,7 +638,7 @@ static void try_disable_dsc(struct drm_atomic_state *state, ...@@ -638,7 +638,7 @@ static void try_disable_dsc(struct drm_atomic_state *state,
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (vars[i].dsc_enabled if (vars[i].dsc_enabled
&& vars[i].bpp_x16 == params[i].bw_range.max_target_bpp_x16 && vars[i].bpp_x16 == params[i].bw_range.max_target_bpp_x16
&& !params[i].clock_overwrite) { && !params[i].clock_force_enable == DSC_CLK_FORCE_DEFAULT) {
kbps_increase[i] = params[i].bw_range.stream_kbps - params[i].bw_range.max_kbps; kbps_increase[i] = params[i].bw_range.stream_kbps - params[i].bw_range.max_kbps;
tried[i] = false; tried[i] = false;
remaining_to_try += 1; remaining_to_try += 1;
...@@ -718,8 +718,8 @@ static bool compute_mst_dsc_configs_for_link(struct drm_atomic_state *state, ...@@ -718,8 +718,8 @@ static bool compute_mst_dsc_configs_for_link(struct drm_atomic_state *state,
params[count].sink = stream->sink; params[count].sink = stream->sink;
aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context; aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
params[count].port = aconnector->port; params[count].port = aconnector->port;
params[count].clock_overwrite = aconnector->dsc_settings.dsc_clock_en; params[count].clock_force_enable = aconnector->dsc_settings.dsc_force_enable;
if (params[count].clock_overwrite) if (params[count].clock_force_enable == DSC_CLK_FORCE_ENABLE)
debugfs_overwrite = true; debugfs_overwrite = true;
params[count].slice_width_overwrite = aconnector->dsc_settings.dsc_slice_width; params[count].slice_width_overwrite = aconnector->dsc_settings.dsc_slice_width;
params[count].slice_height_overwrite = aconnector->dsc_settings.dsc_slice_height; params[count].slice_height_overwrite = aconnector->dsc_settings.dsc_slice_height;
...@@ -756,7 +756,7 @@ static bool compute_mst_dsc_configs_for_link(struct drm_atomic_state *state, ...@@ -756,7 +756,7 @@ static bool compute_mst_dsc_configs_for_link(struct drm_atomic_state *state,
/* Try max compression */ /* Try max compression */
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (params[i].compression_possible) { if (params[i].compression_possible && params[i].clock_force_enable != DSC_CLK_FORCE_DISABLE) {
vars[i].pbn = kbps_to_peak_pbn(params[i].bw_range.min_kbps); vars[i].pbn = kbps_to_peak_pbn(params[i].bw_range.min_kbps);
vars[i].dsc_enabled = true; vars[i].dsc_enabled = true;
vars[i].bpp_x16 = params[i].bw_range.min_target_bpp_x16; vars[i].bpp_x16 = params[i].bw_range.min_target_bpp_x16;
......
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