Skip to content

Commit ee352f6

Browse files
Timur Kristófalexdeucher
authored andcommitted
drm/amd/display: Share dce100_validate_bandwidth with DCE6-8
DCE6-8 have very similar capabilities to DCE10, they support the same DP and HDMI versions and work similarly. Share dce100_validate_bandwidth between DCE6-10 to reduce code duplication in the DC driver. Signed-off-by: Timur Kristóf <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent b8ae264 commit ee352f6

File tree

4 files changed

+18
-77
lines changed

4 files changed

+18
-77
lines changed

drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ static enum dc_status build_mapped_resource(
837837
return DC_OK;
838838
}
839839

840-
static enum dc_status dce100_validate_bandwidth(
840+
enum dc_status dce100_validate_bandwidth(
841841
struct dc *dc,
842842
struct dc_state *context,
843843
enum dc_validate_mode validate_mode)
@@ -862,7 +862,16 @@ static enum dc_status dce100_validate_bandwidth(
862862
context->bw_ctx.bw.dce.dispclk_khz = 681000;
863863
context->bw_ctx.bw.dce.yclk_khz = 250000 * MEMORY_TYPE_MULTIPLIER_CZ;
864864
} else {
865-
context->bw_ctx.bw.dce.dispclk_khz = 0;
865+
/* On DCE 6.0 and 6.4 the PLL0 is both the display engine clock and
866+
* the DP clock, and shouldn't be turned off. Just select the display
867+
* clock value from its low power mode.
868+
*/
869+
if (dc->ctx->dce_version == DCE_VERSION_6_0 ||
870+
dc->ctx->dce_version == DCE_VERSION_6_4)
871+
context->bw_ctx.bw.dce.dispclk_khz = 352000;
872+
else
873+
context->bw_ctx.bw.dce.dispclk_khz = 0;
874+
866875
context->bw_ctx.bw.dce.yclk_khz = 0;
867876
}
868877

drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ struct resource_pool *dce100_create_resource_pool(
4141

4242
enum dc_status dce100_validate_plane(const struct dc_plane_state *plane_state, struct dc_caps *caps);
4343

44+
enum dc_status dce100_validate_bandwidth(
45+
struct dc *dc,
46+
struct dc_state *context,
47+
enum dc_validate_mode validate_mode);
48+
4449
enum dc_status dce100_add_stream_to_ctx(
4550
struct dc *dc,
4651
struct dc_state *new_ctx,

drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -864,47 +864,6 @@ static void dce60_resource_destruct(struct dce110_resource_pool *pool)
864864
}
865865
}
866866

867-
static enum dc_status dce60_validate_bandwidth(
868-
struct dc *dc,
869-
struct dc_state *context,
870-
enum dc_validate_mode validate_mode)
871-
{
872-
int i;
873-
bool at_least_one_pipe = false;
874-
struct dc_stream_state *stream = NULL;
875-
const uint32_t max_pix_clk_khz = max(dc->clk_mgr->clks.max_supported_dispclk_khz, 400000);
876-
877-
for (i = 0; i < dc->res_pool->pipe_count; i++) {
878-
stream = context->res_ctx.pipe_ctx[i].stream;
879-
if (stream) {
880-
at_least_one_pipe = true;
881-
882-
if (stream->timing.pix_clk_100hz >= max_pix_clk_khz * 10)
883-
return DC_FAIL_BANDWIDTH_VALIDATE;
884-
}
885-
}
886-
887-
if (at_least_one_pipe) {
888-
/* TODO implement when needed but for now hardcode max value*/
889-
context->bw_ctx.bw.dce.dispclk_khz = 681000;
890-
context->bw_ctx.bw.dce.yclk_khz = 250000 * MEMORY_TYPE_MULTIPLIER_CZ;
891-
} else {
892-
/* On DCE 6.0 and 6.4 the PLL0 is both the display engine clock and
893-
* the DP clock, and shouldn't be turned off. Just select the display
894-
* clock value from its low power mode.
895-
*/
896-
if (dc->ctx->dce_version == DCE_VERSION_6_0 ||
897-
dc->ctx->dce_version == DCE_VERSION_6_4)
898-
context->bw_ctx.bw.dce.dispclk_khz = 352000;
899-
else
900-
context->bw_ctx.bw.dce.dispclk_khz = 0;
901-
902-
context->bw_ctx.bw.dce.yclk_khz = 0;
903-
}
904-
905-
return DC_OK;
906-
}
907-
908867
static bool dce60_validate_surface_sets(
909868
struct dc_state *context)
910869
{
@@ -948,7 +907,7 @@ static const struct resource_funcs dce60_res_pool_funcs = {
948907
.destroy = dce60_destroy_resource_pool,
949908
.link_enc_create = dce60_link_encoder_create,
950909
.panel_cntl_create = dce60_panel_cntl_create,
951-
.validate_bandwidth = dce60_validate_bandwidth,
910+
.validate_bandwidth = dce100_validate_bandwidth,
952911
.validate_plane = dce100_validate_plane,
953912
.add_stream_to_ctx = dce100_add_stream_to_ctx,
954913
.validate_global = dce60_validate_global,

drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -870,38 +870,6 @@ static void dce80_resource_destruct(struct dce110_resource_pool *pool)
870870
}
871871
}
872872

873-
static enum dc_status dce80_validate_bandwidth(
874-
struct dc *dc,
875-
struct dc_state *context,
876-
enum dc_validate_mode validate_mode)
877-
{
878-
int i;
879-
bool at_least_one_pipe = false;
880-
struct dc_stream_state *stream = NULL;
881-
const uint32_t max_pix_clk_khz = max(dc->clk_mgr->clks.max_supported_dispclk_khz, 400000);
882-
883-
for (i = 0; i < dc->res_pool->pipe_count; i++) {
884-
stream = context->res_ctx.pipe_ctx[i].stream;
885-
if (stream) {
886-
at_least_one_pipe = true;
887-
888-
if (stream->timing.pix_clk_100hz >= max_pix_clk_khz * 10)
889-
return DC_FAIL_BANDWIDTH_VALIDATE;
890-
}
891-
}
892-
893-
if (at_least_one_pipe) {
894-
/* TODO implement when needed but for now hardcode max value*/
895-
context->bw_ctx.bw.dce.dispclk_khz = 681000;
896-
context->bw_ctx.bw.dce.yclk_khz = 250000 * MEMORY_TYPE_MULTIPLIER_CZ;
897-
} else {
898-
context->bw_ctx.bw.dce.dispclk_khz = 0;
899-
context->bw_ctx.bw.dce.yclk_khz = 0;
900-
}
901-
902-
return DC_OK;
903-
}
904-
905873
static bool dce80_validate_surface_sets(
906874
struct dc_state *context)
907875
{
@@ -945,7 +913,7 @@ static const struct resource_funcs dce80_res_pool_funcs = {
945913
.destroy = dce80_destroy_resource_pool,
946914
.link_enc_create = dce80_link_encoder_create,
947915
.panel_cntl_create = dce80_panel_cntl_create,
948-
.validate_bandwidth = dce80_validate_bandwidth,
916+
.validate_bandwidth = dce100_validate_bandwidth,
949917
.validate_plane = dce100_validate_plane,
950918
.add_stream_to_ctx = dce100_add_stream_to_ctx,
951919
.validate_global = dce80_validate_global,

0 commit comments

Comments
 (0)