From a465feae60dc615d0e363ea5809b95a433b259d4 Mon Sep 17 00:00:00 2001 From: Charlene Liu Date: Mon, 16 Jul 2018 14:05:11 -0400 Subject: drm/amd/display: pass compat_level to hubp Signed-off-by: Charlene Liu Reviewed-by: Dmytro Laktyushkin Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c | 3 ++- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h | 3 ++- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 4 +++- drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c index 2138cd3c5d1d..fa1bacd7ba3a 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c @@ -485,7 +485,8 @@ void hubp1_program_surface_config( union plane_size *plane_size, enum dc_rotation_angle rotation, struct dc_plane_dcc_param *dcc, - bool horizontal_mirror) + bool horizontal_mirror, + unsigned int compat_level) { hubp1_dcc_control(hubp, dcc->enable, dcc->grph.independent_64b_blks); hubp1_program_tiling(hubp, tiling_info, format); diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h index f689feace82d..48c1907c78c6 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h @@ -664,7 +664,8 @@ void hubp1_program_surface_config( union plane_size *plane_size, enum dc_rotation_angle rotation, struct dc_plane_dcc_param *dcc, - bool horizontal_mirror); + bool horizontal_mirror, + unsigned int compat_level); void hubp1_program_deadline( struct hubp *hubp, diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index cfcc54f2ce65..41f6595891f1 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c @@ -2004,6 +2004,7 @@ static void update_dchubp_dpp( struct dpp *dpp = pipe_ctx->plane_res.dpp; struct dc_plane_state *plane_state = pipe_ctx->plane_state; union plane_size size = plane_state->plane_size; + unsigned int compat_level = 0; /* depends on DML calculation, DPP clock value may change dynamically */ /* If request max dpp clk is lower than current dispclk, no need to @@ -2095,7 +2096,8 @@ static void update_dchubp_dpp( &size, plane_state->rotation, &plane_state->dcc, - plane_state->horizontal_mirror); + plane_state->horizontal_mirror, + compat_level); } hubp->power_gated = false; diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h b/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h index 4f3f9e68ccfa..334c48cdafdc 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h @@ -96,7 +96,8 @@ struct hubp_funcs { union plane_size *plane_size, enum dc_rotation_angle rotation, struct dc_plane_dcc_param *dcc, - bool horizontal_mirror); + bool horizontal_mirror, + unsigned int compa_level); bool (*hubp_is_flip_pending)(struct hubp *hubp); -- cgit v1.2.3 From 265f5ba6c209875081da7c5f7affe8c2c1913a75 Mon Sep 17 00:00:00 2001 From: Jun Lei Date: Mon, 16 Jul 2018 10:40:31 -0400 Subject: drm/amd/display: Move PME to function pointer call semantics [why] Legacy IRI style is not linux friendly. [how] New function pointer call semantics will be used for all future PPLIB/DAL interfaces, and also some existing will be refactored. This change defines how the new function pointer structures will look, as well as implements Signed-off-by: Jun Lei Reviewed-by: Tony Cheng Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c | 7 ++ drivers/gpu/drm/amd/display/dc/dm_pp_smu.h | 92 ++++++++++++++---------- 2 files changed, 61 insertions(+), 38 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c index bd039322f697..32b34134c501 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c @@ -37,6 +37,13 @@ #define DC_LOGGER \ dc->ctx->logger + +#define WM_SET_COUNT 4 +#define WM_A 0 +#define WM_B 1 +#define WM_C 2 +#define WM_D 3 + /* * NOTE: * This file is gcc-parseable HW gospel, coming straight from HW engineers. diff --git a/drivers/gpu/drm/amd/display/dc/dm_pp_smu.h b/drivers/gpu/drm/amd/display/dc/dm_pp_smu.h index 58ed2055ef9f..f2ea8452d48f 100644 --- a/drivers/gpu/drm/amd/display/dc/dm_pp_smu.h +++ b/drivers/gpu/drm/amd/display/dc/dm_pp_smu.h @@ -30,33 +30,45 @@ * interface to PPLIB/SMU to setup clocks and pstate requirements on SoC */ +enum pp_smu_ver { + /* + * PP_SMU_INTERFACE_X should be interpreted as the interface defined + * starting from X, where X is some family of ASICs. This is as + * opposed to interfaces used only for X. There will be some degree + * of interface sharing between families of ASIcs. + */ + PP_SMU_UNSUPPORTED, + PP_SMU_VER_RV +}; struct pp_smu { - struct dc_context *ctx; -}; + enum pp_smu_ver ver; + const void *pp; -enum wm_set_id { - WM_A, - WM_B, - WM_C, - WM_D, - WM_SET_COUNT, + /* + * interim extra handle for backwards compatibility + * as some existing functionality not yet implemented + * by ppsmu + */ + const void *dm; }; struct pp_smu_wm_set_range { - enum wm_set_id wm_inst; + unsigned int wm_inst; uint32_t min_fill_clk_khz; uint32_t max_fill_clk_khz; uint32_t min_drain_clk_khz; uint32_t max_drain_clk_khz; }; +#define MAX_WATERMARK_SETS 4 + struct pp_smu_wm_range_sets { - uint32_t num_reader_wm_sets; - struct pp_smu_wm_set_range reader_wm_sets[WM_SET_COUNT]; + unsigned int num_reader_wm_sets; + struct pp_smu_wm_set_range reader_wm_sets[MAX_WATERMARK_SETS]; - uint32_t num_writer_wm_sets; - struct pp_smu_wm_set_range writer_wm_sets[WM_SET_COUNT]; + unsigned int num_writer_wm_sets; + struct pp_smu_wm_set_range writer_wm_sets[MAX_WATERMARK_SETS]; }; struct pp_smu_display_requirement_rv { @@ -85,48 +97,52 @@ struct pp_smu_display_requirement_rv { struct pp_smu_funcs_rv { struct pp_smu pp_smu; - void (*set_display_requirement)(struct pp_smu *pp, - struct pp_smu_display_requirement_rv *req); + /* PPSMC_MSG_SetDisplayCount + * 0 triggers S0i2 optimization + */ + void (*set_display_count)(struct pp_smu *pp, int count); /* which SMU message? are reader and writer WM separate SMU msg? */ void (*set_wm_ranges)(struct pp_smu *pp, struct pp_smu_wm_range_sets *ranges); - /* PME w/a */ - void (*set_pme_wa_enable)(struct pp_smu *pp); -}; -#if 0 -struct pp_smu_funcs_rv { + /* PPSMC_MSG_SetHardMinDcfclkByFreq + * fixed clock at requested freq, either from FCH bypass or DFS + */ + void (*set_hard_min_dcfclk_by_freq)(struct pp_smu *pp, int khz); - /* PPSMC_MSG_SetDisplayCount - * 0 triggers S0i2 optimization + /* PPSMC_MSG_SetMinDeepSleepDcfclk + * when DF is in cstate, dcf clock is further divided down + * to just above given frequency */ - void (*set_display_count)(struct pp_smu *pp, int count); + void (*set_min_deep_sleep_dcfclk)(struct pp_smu *pp, int mhz); /* PPSMC_MSG_SetHardMinFclkByFreq - * FCLK will vary with DPM, but never below requested hard min + * FCLK will vary with DPM, but never below requested hard min */ void (*set_hard_min_fclk_by_freq)(struct pp_smu *pp, int khz); - /* PPSMC_MSG_SetHardMinDcefclkByFreq - * fixed clock at requested freq, either from FCH bypass or DFS + /* PPSMC_MSG_SetHardMinSocclkByFreq + * Needed for DWB support */ - void (*set_hard_min_dcefclk_by_freq)(struct pp_smu *pp, int khz); + void (*set_hard_min_socclk_by_freq)(struct pp_smu *pp, int khz); - /* PPSMC_MSG_SetMinDeepSleepDcefclk - * when DF is in cstate, dcf clock is further divided down - * to just above given frequency - */ - void (*set_min_deep_sleep_dcefclk)(struct pp_smu *pp, int mhz); + /* PME w/a */ + void (*set_pme_wa_enable)(struct pp_smu *pp); - /* todo: aesthetic - * watermark range table + /* + * Legacy functions. Used for backwards comp. with existing + * PPlib code. */ + void (*set_display_requirement)(struct pp_smu *pp, + struct pp_smu_display_requirement_rv *req); +}; - /* todo: functional/feature - * PPSMC_MSG_SetHardMinSocclkByFreq: required to support DWB - */ +struct pp_smu_funcs { + struct pp_smu ctx; + union { + struct pp_smu_funcs_rv rv_funcs; + }; }; -#endif #endif /* DM_PP_SMU_IF__H */ -- cgit v1.2.3 From 2cb3bcdb33c0a18b25a23e7081de8c9a1698a80e Mon Sep 17 00:00:00 2001 From: Tony Cheng Date: Wed, 18 Jul 2018 20:28:12 -0400 Subject: drm/amd/display: dal 3.1.60 Signed-off-by: Tony Cheng Reviewed-by: Aric Cyr Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index 6c9990bef267..01af5356f2fc 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -38,7 +38,7 @@ #include "inc/compressor.h" #include "dml/display_mode_lib.h" -#define DC_VER "3.1.59" +#define DC_VER "3.1.60" #define MAX_SURFACES 3 #define MAX_STREAMS 6 -- cgit v1.2.3 From 4e60536d093f486229bb8d86c739e8ef6446df85 Mon Sep 17 00:00:00 2001 From: Nicholas Kazlauskas Date: Tue, 24 Jul 2018 13:19:49 -0400 Subject: drm/amd/display: Set DFS bypass flags for dce110 [Why] While there is support for using and quering DFS bypass clocks the hardware is never notified to enter DFS bypass mode for dce110. [How] Add a flag that can be set when programming the display engine PLL to enable DFS bypass mode. If this flag is set then the hardware is notified to enter DFS bypass mode and the correct display engine clock frequency can be acquired. Signed-off-by: Nicholas Kazlauskas Reviewed-by: Harry Wentland Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/bios/command_table.c | 3 +++ drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c | 3 +++ 2 files changed, 6 insertions(+) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/bios/command_table.c b/drivers/gpu/drm/amd/display/dc/bios/command_table.c index a558bfaa0c46..2bd7cd97e00d 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/command_table.c +++ b/drivers/gpu/drm/amd/display/dc/bios/command_table.c @@ -2201,6 +2201,9 @@ static enum bp_result program_clock_v6( if (bp_params->flags.SET_EXTERNAL_REF_DIV_SRC) params.sPCLKInput.ucMiscInfo |= PIXEL_CLOCK_MISC_REF_DIV_SRC; + if (bp_params->flags.SET_DISPCLK_DFS_BYPASS) + params.sPCLKInput.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_DPREFCLK_BYPASS; + if (EXEC_BIOS_CMD_TABLE(SetPixelClock, params)) { /* True display clock is returned by VBIOS if DFS bypass * is enabled. */ diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c index fb1f373d08a1..0782b74624d7 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c @@ -255,6 +255,9 @@ static int dce_set_clock( pxl_clk_params.target_pixel_clock = requested_clk_khz; pxl_clk_params.pll_id = CLOCK_SOURCE_ID_DFS; + if (clk_dce->dfs_bypass_enabled) + pxl_clk_params.flags.SET_DISPCLK_DFS_BYPASS = true; + bp->funcs->program_display_engine_pll(bp, &pxl_clk_params); if (clk_dce->dfs_bypass_enabled) { -- cgit v1.2.3 From 1c8faa9aa0cc1ccf02bed608d23966b7347d71a6 Mon Sep 17 00:00:00 2001 From: Nicholas Kazlauskas Date: Tue, 24 Jul 2018 09:42:23 -0400 Subject: drm/amd/display: Enable DFS bypass support in DC config [Why] We explicitly disable DFS bypass support when creating DC. Support for this feature should now be in place so it can be left implicitly enabled. [How] Remove the line that disables DFS bypass support. Note: This option was actually reset to false anyway for most of the hardware I've tested on making this particular line misleading in the first place. This patch also fixes this issue. Signed-off-by: Nicholas Kazlauskas Reviewed-by: Harry Wentland Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 6ae050dc3220..ebdf82044f73 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -706,8 +706,6 @@ struct dc *dc_create(const struct dc_init_data *init_params) DC_LOG_DC("Display Core initialized\n"); - /* TODO: missing feature to be enabled */ - dc->debug.disable_dfs_bypass = true; return dc; -- cgit v1.2.3 From 5a83c93249098df2ee3b0039ec8f4495b959fcd0 Mon Sep 17 00:00:00 2001 From: Nicholas Kazlauskas Date: Tue, 21 Aug 2018 14:36:49 -0500 Subject: drm/amd/display: Add support for toggling DFS bypass [Why] If the hardware supports DFS bypass it will always be enabled after creation of the DCCG. DFS bypass should only be enabled when the current stream consists of a single embedded panel and the minimum display clock is below the DFS bypass threshold. [How] Add a function to the DCCG table that updates the DFS bypass state when setting the bandwidth. If the DFS bypass state is changed, the clock needs to be reprogrammed to reflect this before the DPREFCLK is updated for audio endpoints. The existing display clock value is used as the target display clock value when reprogramming since the resulting change will be equal or larger to the current value. These changes only specifically target dce110 but do offer a framework for support on other applicable targets. Signed-off-by: Nicholas Kazlauskas Reviewed-by: David Francis Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c | 63 ++++++++++++++++++++-- drivers/gpu/drm/amd/display/dc/dce/dce_clocks.h | 2 + .../amd/display/dc/dce110/dce110_hw_sequencer.c | 12 ++++- .../gpu/drm/amd/display/dc/inc/hw/display_clock.h | 5 ++ 4 files changed, 76 insertions(+), 6 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c index 0782b74624d7..103dc3cf1c43 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c @@ -255,13 +255,12 @@ static int dce_set_clock( pxl_clk_params.target_pixel_clock = requested_clk_khz; pxl_clk_params.pll_id = CLOCK_SOURCE_ID_DFS; - if (clk_dce->dfs_bypass_enabled) + if (clk_dce->dfs_bypass_active) pxl_clk_params.flags.SET_DISPCLK_DFS_BYPASS = true; bp->funcs->program_display_engine_pll(bp, &pxl_clk_params); - if (clk_dce->dfs_bypass_enabled) { - + if (clk_dce->dfs_bypass_active) { /* Cache the fixed display clock*/ clk_dce->dfs_bypass_disp_clk = pxl_clk_params.dfs_bypass_display_clock; @@ -677,6 +676,61 @@ static void dce_update_clocks(struct dccg *dccg, } } +static bool dce_update_dfs_bypass( + struct dccg *dccg, + struct dc *dc, + struct dc_state *context, + int requested_clock_khz) +{ + struct dce_dccg *clk_dce = TO_DCE_CLOCKS(dccg); + struct resource_context *res_ctx = &context->res_ctx; + enum signal_type signal_type = SIGNAL_TYPE_NONE; + bool was_active = clk_dce->dfs_bypass_active; + int i; + + /* Disable DFS bypass by default. */ + clk_dce->dfs_bypass_active = false; + + /* Check that DFS bypass is available. */ + if (!clk_dce->dfs_bypass_enabled) + goto update; + + /* Check if the requested display clock is below the threshold. */ + if (requested_clock_khz >= 400000) + goto update; + + /* DFS-bypass should only be enabled on single stream setups */ + if (context->stream_count != 1) + goto update; + + /* Check that the stream's signal type is an embedded panel */ + for (i = 0; i < dc->res_pool->pipe_count; i++) { + if (res_ctx->pipe_ctx[i].stream) { + struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i]; + + signal_type = pipe_ctx->stream->sink->link->connector_signal; + break; + } + } + + if (signal_type == SIGNAL_TYPE_EDP || + signal_type == SIGNAL_TYPE_LVDS) + clk_dce->dfs_bypass_active = true; + +update: + /* Update the clock state. We don't need to respect safe_to_lower + * because DFS bypass should always be greater than the current + * display clock frequency. + */ + if (was_active != clk_dce->dfs_bypass_active) { + dccg->clks.dispclk_khz = + dccg->funcs->set_dispclk(dccg, dccg->clks.dispclk_khz); + return true; + } + + return false; +} + #ifdef CONFIG_DRM_AMD_DC_DCN1_0 static const struct display_clock_funcs dcn1_funcs = { .get_dp_ref_clk_frequency = dce12_get_dp_ref_freq_khz, @@ -700,7 +754,8 @@ static const struct display_clock_funcs dce112_funcs = { static const struct display_clock_funcs dce110_funcs = { .get_dp_ref_clk_frequency = dce_get_dp_ref_freq_khz, .set_dispclk = dce_psr_set_clock, - .update_clocks = dce_update_clocks + .update_clocks = dce_update_clocks, + .update_dfs_bypass = dce_update_dfs_bypass }; static const struct display_clock_funcs dce_funcs = { diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.h b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.h index 8a6b2d328467..8b5a53e98ad9 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.h @@ -78,6 +78,8 @@ struct dce_dccg { /* Cache the status of DFS-bypass feature*/ bool dfs_bypass_enabled; + /* True if the DFS-bypass feature is enabled and active. */ + bool dfs_bypass_active; /* Cache the display clock returned by VBIOS if DFS-bypass is enabled. * This is basically "Crystal Frequency In KHz" (XTALIN) frequency */ int dfs_bypass_disp_clk; diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c index 14384d9675a8..2f2c5155c5aa 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c @@ -2566,6 +2566,7 @@ void dce110_set_bandwidth( bool decrease_allowed) { struct dc_clocks req_clks; + struct dccg *dccg = dc->res_pool->dccg; req_clks.dispclk_khz = context->bw.dce.dispclk_khz; req_clks.phyclk_khz = get_max_pixel_clock_for_all_paths(dc, context); @@ -2575,8 +2576,15 @@ void dce110_set_bandwidth( else dce110_set_safe_displaymarks(&context->res_ctx, dc->res_pool); - dc->res_pool->dccg->funcs->update_clocks( - dc->res_pool->dccg, + if (dccg->funcs->update_dfs_bypass) + dccg->funcs->update_dfs_bypass( + dccg, + dc, + context, + req_clks.dispclk_khz); + + dccg->funcs->update_clocks( + dccg, &req_clks, decrease_allowed); pplib_apply_display_requirements(dc, context); diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/display_clock.h b/drivers/gpu/drm/amd/display/dc/inc/hw/display_clock.h index 3c7ccb68ecdb..689faa16c0ae 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/display_clock.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/display_clock.h @@ -53,6 +53,11 @@ struct display_clock_funcs { int requested_clock_khz); int (*get_dp_ref_clk_frequency)(struct dccg *dccg); + + bool (*update_dfs_bypass)(struct dccg *dccg, + struct dc *dc, + struct dc_state *context, + int requested_clock_khz); }; #endif /* __DISPLAY_CLOCK_H__ */ -- cgit v1.2.3 From 9b5349f74a85a6aa05c06d30f10b3a83d6ec00b1 Mon Sep 17 00:00:00 2001 From: Martin Tsai Date: Fri, 27 Jul 2018 15:39:47 +0800 Subject: drm/amd/display: correct image viewport calculation [why] We didn't transfer the camera/video viewport coordinate when doing rotation and mirror. [how] To correct the viewport coordinate in calculate_viewport(). Signed-off-by: Martin Tsai Reviewed-by: Charlene Liu Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index ea6beccfd89d..d10314016edb 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -487,6 +487,18 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx) pipe_ctx->bottom_pipe->plane_state == pipe_ctx->plane_state; bool sec_split = pipe_ctx->top_pipe && pipe_ctx->top_pipe->plane_state == pipe_ctx->plane_state; + bool flip_vert_scan_dir = false, flip_horz_scan_dir = false; + + /* + * Need to calculate the scan direction for viewport to properly determine offset + */ + if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_180) { + flip_vert_scan_dir = true; + flip_horz_scan_dir = true; + } else if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90) + flip_vert_scan_dir = true; + else if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) + flip_horz_scan_dir = true; if (stream->view_format == VIEW_3D_FORMAT_SIDE_BY_SIDE || stream->view_format == VIEW_3D_FORMAT_TOP_AND_BOTTOM) { @@ -530,6 +542,34 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx) data->viewport.height = clip.height * surf_src.height / plane_state->dst_rect.height; + /* To transfer the x, y to correct coordinate on mirror image (camera). + * deg 0 : transfer x, + * deg 90 : don't need to transfer, + * deg180 : transfer y, + * deg270 : transfer x and y. + * To transfer the x, y to correct coordinate on non-mirror image (video). + * deg 0 : don't need to transfer, + * deg 90 : transfer y, + * deg180 : transfer x and y, + * deg270 : transfer x. + */ + if (pipe_ctx->plane_state->horizontal_mirror) { + if (flip_horz_scan_dir && !flip_vert_scan_dir) { + data->viewport.y = surf_src.height - data->viewport.y - data->viewport.height; + data->viewport.x = surf_src.width - data->viewport.x - data->viewport.width; + } else if (flip_horz_scan_dir && flip_vert_scan_dir) + data->viewport.y = surf_src.height - data->viewport.y - data->viewport.height; + else { + if (!flip_horz_scan_dir && !flip_vert_scan_dir) + data->viewport.x = surf_src.width - data->viewport.x - data->viewport.width; + } + } else { + if (flip_horz_scan_dir) + data->viewport.x = surf_src.width - data->viewport.x - data->viewport.width; + if (flip_vert_scan_dir) + data->viewport.y = surf_src.height - data->viewport.y - data->viewport.height; + } + /* Round down, compensate in init */ data->viewport_c.x = data->viewport.x / vpc_div; data->viewport_c.y = data->viewport.y / vpc_div; @@ -725,6 +765,15 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct rect *r rect_swap_helper(&src); rect_swap_helper(&data->viewport_c); rect_swap_helper(&data->viewport); + + if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270 && + pipe_ctx->plane_state->horizontal_mirror) { + flip_vert_scan_dir = true; + } + if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90 && + pipe_ctx->plane_state->horizontal_mirror) { + flip_vert_scan_dir = false; + } } else if (pipe_ctx->plane_state->horizontal_mirror) flip_horz_scan_dir = !flip_horz_scan_dir; -- cgit v1.2.3 From d02e07948fcff46a7a48f8747260941d7290774b Mon Sep 17 00:00:00 2001 From: Nikola Cornij Date: Thu, 19 Jul 2018 14:03:14 -0400 Subject: drm/amd/display: Print DPP DTN log info only for enabled pipes [why] There is currently a dependency on the order in which tests are executed. This is because the non-relevant state info is being printed, which results in the output based on the state from the previous test. [how] Print DPP DTN log only if the pipe is enabled. In addition to the affected per-submission DTN golden logs, included in this change is also DTN golden log update for pre-submission tests. The other DTN golden logs affected by this change will be updated upon nightly test run (which will generate the updated DTN logs). Signed-off-by: Nikola Cornij Reviewed-by: Nikola Cornij Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c | 2 ++ drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 7 +++++-- drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c index bf8b68f8db4f..1d642552c743 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c @@ -103,6 +103,8 @@ void dpp_read_state(struct dpp *dpp_base, { struct dcn10_dpp *dpp = TO_DCN10_DPP(dpp_base); + REG_GET(DPP_CONTROL, + DPP_CLOCK_ENABLE, &s->is_enabled); REG_GET(CM_IGAM_CONTROL, CM_IGAM_LUT_MODE, &s->igam_lut_mode); REG_GET(CM_IGAM_CONTROL, diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index 41f6595891f1..cfd93557c428 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c @@ -88,7 +88,7 @@ static void log_mpc_crc(struct dc *dc) void dcn10_log_hubbub_state(struct dc *dc) { struct dc_context *dc_ctx = dc->ctx; - struct dcn_hubbub_wm wm; + struct dcn_hubbub_wm wm = {0}; int i; hubbub1_wm_read_state(dc->res_pool->hubbub, &wm); @@ -244,10 +244,13 @@ void dcn10_log_hw_state(struct dc *dc) "C31 C32 C33 C34\n"); for (i = 0; i < pool->pipe_count; i++) { struct dpp *dpp = pool->dpps[i]; - struct dcn_dpp_state s; + struct dcn_dpp_state s = {0}; dpp->funcs->dpp_read_state(dpp, &s); + if (!s.is_enabled) + continue; + DTN_INFO("[%2d]: %11xh %-11s %-11s %-11s" "%8x %08xh %08xh %08xh %08xh %08xh %08xh", dpp->inst, diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h b/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h index 74ad94b0e4f0..80a480b9f137 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h @@ -45,6 +45,7 @@ struct dpp_grph_csc_adjustment { }; struct dcn_dpp_state { + uint32_t is_enabled; uint32_t igam_lut_mode; uint32_t igam_input_format; uint32_t dgam_lut_mode; -- cgit v1.2.3 From f1220c876d4fb6bb41851f7f422efa4600d0bfa7 Mon Sep 17 00:00:00 2001 From: Tony Cheng Date: Wed, 18 Jul 2018 20:28:54 -0400 Subject: drm/amd/display: dc 3.1.61 Signed-off-by: Tony Cheng Reviewed-by: Steven Chiu Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index 01af5356f2fc..af57c3001a82 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -38,7 +38,7 @@ #include "inc/compressor.h" #include "dml/display_mode_lib.h" -#define DC_VER "3.1.60" +#define DC_VER "3.1.61" #define MAX_SURFACES 3 #define MAX_STREAMS 6 -- cgit v1.2.3 From 94a4ffd1d40b845dd19f9fdbb2cb6bf32de0946b Mon Sep 17 00:00:00 2001 From: Gloria Li Date: Thu, 26 Jul 2018 11:32:14 -0400 Subject: drm/amd/display: fix PIP bugs on Dal3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Why] There are outstanding bugs for PIP in Dal3: -Crash when toggling PIP visibility -Global Alpha is not working, Adjusting global alpha doesn’t have an effect -Cursor is not working with pip plane and pipe splits -One flash occurs when cursor enters PIP plane from top/bottom -Crash when moving PIP plane off the screen [How] Resolve divide by 0 error Implement global alpha Program cursor on all pipes Add dst rects' x and y offests into cursor position Disable cursor when it is beyond bottom/top edge Signed-off-by: Gloria Li Reviewed-by: Aric Cyr Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 3 +++ drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 9 ++++++--- drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 -- drivers/gpu/drm/amd/display/dc/dc.h | 5 +++++ drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c | 10 +++++++++- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h | 3 ++- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c | 7 +++++++ .../gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 18 ++++++++++++------ drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h | 3 ++- 9 files changed, 46 insertions(+), 14 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index ebdf82044f73..71742635e797 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -1106,6 +1106,9 @@ static enum surface_update_type get_plane_info_update_type(const struct dc_surfa if (u->plane_info->per_pixel_alpha != u->surface->per_pixel_alpha) update_flags->bits.per_pixel_alpha_change = 1; + if (u->plane_info->global_alpha_value != u->surface->global_alpha_value) + update_flags->bits.global_alpha_change = 1; + if (u->plane_info->dcc.enable != u->surface->dcc.enable || u->plane_info->dcc.grph.independent_64b_blks != u->surface->dcc.grph.independent_64b_blks || u->plane_info->dcc.grph.meta_pitch != u->surface->dcc.grph.meta_pitch) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index d10314016edb..2c348b11b9a5 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -589,8 +589,10 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx) data->viewport.width = (data->viewport.width + 1) / 2; data->viewport_c.width = (data->viewport_c.width + 1) / 2; } else if (pri_split) { - data->viewport.width /= 2; - data->viewport_c.width /= 2; + if (data->viewport.width > 1) + data->viewport.width /= 2; + if (data->viewport_c.width > 1) + data->viewport_c.width /= 2; } if (plane_state->rotation == ROTATION_ANGLE_90 || @@ -670,7 +672,8 @@ static void calculate_recout(struct pipe_ctx *pipe_ctx, struct rect *recout_full pipe_ctx->plane_res.scl_data.recout.width = (pipe_ctx->plane_res.scl_data.recout.width + 1) / 2; } else { - pipe_ctx->plane_res.scl_data.recout.width /= 2; + if (pipe_ctx->plane_res.scl_data.recout.width > 1) + pipe_ctx->plane_res.scl_data.recout.width /= 2; } } /* Unclipped recout offset = stream dst offset + ((surf dst offset - stream surf_src offset) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c index fdcc8ab19bf3..2ac848a106ba 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c @@ -205,8 +205,6 @@ bool dc_stream_set_cursor_attributes( if (pipe_ctx->stream != stream) continue; - if (pipe_ctx->top_pipe && pipe_ctx->plane_state != pipe_ctx->top_pipe->plane_state) - continue; if (!pipe_to_program) { pipe_to_program = pipe_ctx; diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index af57c3001a82..eb1de3ba622f 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -442,6 +442,7 @@ union surface_update_flags { uint32_t color_space_change:1; uint32_t horizontal_mirror_change:1; uint32_t per_pixel_alpha_change:1; + uint32_t global_alpha_change:1; uint32_t rotation_change:1; uint32_t swizzle_change:1; uint32_t scaling_change:1; @@ -496,6 +497,8 @@ struct dc_plane_state { bool is_tiling_rotated; bool per_pixel_alpha; + bool global_alpha; + int global_alpha_value; bool visible; bool flip_immediate; bool horizontal_mirror; @@ -522,6 +525,8 @@ struct dc_plane_info { bool horizontal_mirror; bool visible; bool per_pixel_alpha; + bool global_alpha; + int global_alpha_value; bool input_csc_enabled; }; diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c index 1d642552c743..5f2054a1d563 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c @@ -444,10 +444,12 @@ void dpp1_set_cursor_position( struct dpp *dpp_base, const struct dc_cursor_position *pos, const struct dc_cursor_mi_param *param, - uint32_t width) + uint32_t width, + uint32_t height) { struct dcn10_dpp *dpp = TO_DCN10_DPP(dpp_base); int src_x_offset = pos->x - pos->x_hotspot - param->viewport.x; + int src_y_offset = pos->y - pos->y_hotspot - param->viewport.y; uint32_t cur_en = pos->enable ? 1 : 0; if (src_x_offset >= (int)param->viewport.width) @@ -456,6 +458,12 @@ void dpp1_set_cursor_position( if (src_x_offset + (int)width <= 0) cur_en = 0; /* not visible beyond left edge*/ + if (src_y_offset >= (int)param->viewport.height) + cur_en = 0; /* not visible beyond bottom edge*/ + + if (src_y_offset < 0) + cur_en = 0; /* not visible beyond top edge*/ + REG_UPDATE(CURSOR0_CONTROL, CUR0_ENABLE, cur_en); diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h index e2889e61b18c..282e22f9b175 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h @@ -1374,7 +1374,8 @@ void dpp1_set_cursor_position( struct dpp *dpp_base, const struct dc_cursor_position *pos, const struct dc_cursor_mi_param *param, - uint32_t width); + uint32_t width, + uint32_t height); void dpp1_cnv_set_optional_cursor_attributes( struct dpp *dpp_base, diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c index fa1bacd7ba3a..ec4a5f665586 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c @@ -1070,6 +1070,7 @@ void hubp1_cursor_set_position( { struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); int src_x_offset = pos->x - pos->x_hotspot - param->viewport.x; + int src_y_offset = pos->y - pos->y_hotspot - param->viewport.y; int x_hotspot = pos->x_hotspot; int y_hotspot = pos->y_hotspot; uint32_t dst_x_offset; @@ -1113,6 +1114,12 @@ void hubp1_cursor_set_position( if (src_x_offset + (int)hubp->curs_attr.width <= 0) cur_en = 0; /* not visible beyond left edge*/ + if (src_y_offset >= (int)param->viewport.height) + cur_en = 0; /* not visible beyond bottom edge*/ + + if (src_y_offset < 0) //+ (int)hubp->curs_attr.height + cur_en = 0; /* not visible beyond top edge*/ + if (cur_en && REG_READ(CURSOR_SURFACE_ADDRESS) == 0) hubp->funcs->set_cursor_attributes(hubp, &hubp->curs_attr); diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index cfd93557c428..6d27f1db3c69 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c @@ -1932,9 +1932,13 @@ static void dcn10_update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx) blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA; blnd_cfg.overlap_only = false; - blnd_cfg.global_alpha = 0xff; blnd_cfg.global_gain = 0xff; + if (pipe_ctx->plane_state->global_alpha) + blnd_cfg.global_alpha = pipe_ctx->plane_state->global_alpha_value; + else + blnd_cfg.global_alpha = 0xff; + /* DCN1.0 has output CM before MPC which seems to screw with * pre-multiplied alpha. */ @@ -2049,11 +2053,13 @@ static void update_dchubp_dpp( update_dpp(dpp, plane_state); if (plane_state->update_flags.bits.full_update || - plane_state->update_flags.bits.per_pixel_alpha_change) + plane_state->update_flags.bits.per_pixel_alpha_change || + plane_state->update_flags.bits.global_alpha_change) dc->hwss.update_mpcc(dc, pipe_ctx); if (plane_state->update_flags.bits.full_update || plane_state->update_flags.bits.per_pixel_alpha_change || + plane_state->update_flags.bits.global_alpha_change || plane_state->update_flags.bits.scaling_change || plane_state->update_flags.bits.position_change) { update_scaler(pipe_ctx); @@ -2597,15 +2603,15 @@ static void dcn10_set_cursor_position(struct pipe_ctx *pipe_ctx) .mirror = pipe_ctx->plane_state->horizontal_mirror }; + pos_cpy.x -= pipe_ctx->plane_state->dst_rect.x; + pos_cpy.y -= pipe_ctx->plane_state->dst_rect.y; + if (pipe_ctx->plane_state->address.type == PLN_ADDR_TYPE_VIDEO_PROGRESSIVE) pos_cpy.enable = false; - if (pipe_ctx->top_pipe && pipe_ctx->plane_state != pipe_ctx->top_pipe->plane_state) - pos_cpy.enable = false; - hubp->funcs->set_cursor_position(hubp, &pos_cpy, ¶m); - dpp->funcs->set_cursor_position(dpp, &pos_cpy, ¶m, hubp->curs_attr.width); + dpp->funcs->set_cursor_position(dpp, &pos_cpy, ¶m, hubp->curs_attr.width, hubp->curs_attr.height); } static void dcn10_set_cursor_attribute(struct pipe_ctx *pipe_ctx) diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h b/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h index 80a480b9f137..e894e649ce5a 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h @@ -147,7 +147,8 @@ struct dpp_funcs { struct dpp *dpp_base, const struct dc_cursor_position *pos, const struct dc_cursor_mi_param *param, - uint32_t width + uint32_t width, + uint32_t height ); void (*dpp_set_hdr_multiplier)( struct dpp *dpp_base, -- cgit v1.2.3 From c4621988d49785849a9fa817721d960798d14e19 Mon Sep 17 00:00:00 2001 From: Dmytro Laktyushkin Date: Mon, 30 Jul 2018 14:41:01 -0400 Subject: drm/amd/display: Add dprefclk value to dce_dccg This allows us to avoid any vbios bugs when initializing clocks Signed-off-by: Dmytro Laktyushkin Reviewed-by: Charlene Liu Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c | 4 +++- drivers/gpu/drm/amd/display/dc/dce/dce_clocks.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c index 103dc3cf1c43..bf6261a1584b 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c @@ -202,7 +202,7 @@ static int dce12_get_dp_ref_freq_khz(struct dccg *clk) { struct dce_dccg *clk_dce = TO_DCE_CLOCKS(clk); - return dccg_adjust_dp_ref_freq_for_ss(clk_dce, 600000); + return dccg_adjust_dp_ref_freq_for_ss(clk_dce, clk_dce->dprefclk_khz); } static enum dm_pp_clocks_state dce_get_required_clocks_state( @@ -882,6 +882,7 @@ struct dccg *dce120_dccg_create(struct dc_context *ctx) dce_dccg_construct( clk_dce, ctx, NULL, NULL, NULL); + clk_dce->dprefclk_khz = 600000; clk_dce->base.funcs = &dce120_funcs; return &clk_dce->base; @@ -909,6 +910,7 @@ struct dccg *dcn1_dccg_create(struct dc_context *ctx) clk_dce->dprefclk_ss_divider = 1000; clk_dce->ss_on_dprefclk = false; + clk_dce->dprefclk_khz = 600000; if (bp->integrated_info) clk_dce->dentist_vco_freq_khz = bp->integrated_info->dentist_vco_freq; if (clk_dce->dentist_vco_freq_khz == 0) { diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.h b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.h index 8b5a53e98ad9..34fdb386c884 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.h @@ -90,6 +90,7 @@ struct dce_dccg { int dprefclk_ss_percentage; /* DPREFCLK SS percentage Divider (100 or 1000) */ int dprefclk_ss_divider; + int dprefclk_khz; }; -- cgit v1.2.3 From f137586b2b2bb3ea0b9886b0929055ddef5a32f4 Mon Sep 17 00:00:00 2001 From: Dmytro Laktyushkin Date: Tue, 17 Jul 2018 17:15:48 -0400 Subject: drm/amd/display: fix dml handling of mono8/16 pixel formats mono formats are treated exactly the same as equivallent bpp 444 formats. Dml validation however lacks 444 8 bit format while dml perf param calculation lacks mono format support This change makes them equivallent as far as the enum is concerned to avoid having to update dml Signed-off-by: Dmytro Laktyushkin Reviewed-by: Charlene Liu Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dml/display_mode_enums.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dml/display_mode_enums.h b/drivers/gpu/drm/amd/display/dc/dml/display_mode_enums.h index 47c19f8fe7d1..bea4e61b94c7 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/display_mode_enums.h +++ b/drivers/gpu/drm/amd/display/dc/dml/display_mode_enums.h @@ -40,8 +40,8 @@ enum source_format_class { dm_422_8 = 5, dm_422_10 = 6, dm_444_8 = 7, - dm_mono_8, - dm_mono_16 + dm_mono_8 = dm_444_8, + dm_mono_16 = dm_444_16 }; enum output_bpc_class { dm_out_6 = 0, dm_out_8 = 1, dm_out_10 = 2, dm_out_12 = 3, dm_out_16 = 4 -- cgit v1.2.3 From 2f14bc8968e3d97fc46bb464045d0fa8fbd2b013 Mon Sep 17 00:00:00 2001 From: Charlene Liu Date: Tue, 31 Jul 2018 20:14:26 -0400 Subject: drm/amd/display: add retimer log for HWQ tuning use. Signed-off-by: Charlene Liu Reviewed-by: Dmytro Laktyushkin Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index 567867915d32..1adfcdd588d6 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c @@ -54,6 +54,9 @@ DC_LOG_HW_HOTPLUG( \ __VA_ARGS__) +#define RETIMER_REDRIVER_INFO(...) \ + DC_LOG_RETIMER_REDRIVER( \ + __VA_ARGS__) /******************************************************************************* * Private structures ******************************************************************************/ @@ -1547,6 +1550,7 @@ static void write_i2c_retimer_setting( uint8_t value = 0; int i = 0; bool i2c_success = false; + DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger); memset(&buffer, 0, sizeof(buffer)); @@ -1560,6 +1564,9 @@ static void write_i2c_retimer_setting( buffer[1] = settings->reg_settings[i].i2c_reg_val; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_address = 0x%x,\ + offset = 0x%x, reg_val= 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ @@ -1590,6 +1597,9 @@ static void write_i2c_retimer_setting( buffer[1] = value | apply_rx_tx_change; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_address = 0x%x,\ + offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1607,6 +1617,9 @@ static void write_i2c_retimer_setting( buffer[1] = settings->reg_settings_6g[i].i2c_reg_val; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("above 340Mhz: retimer write to slave_address = 0x%x,\ + offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ @@ -1637,6 +1650,9 @@ static void write_i2c_retimer_setting( buffer[1] = value | apply_rx_tx_change; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_address = 0x%x,\ + offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1653,6 +1669,9 @@ static void write_i2c_retimer_setting( buffer[1] = 0x01; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_address = 0x%x,\ + offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1662,6 +1681,9 @@ static void write_i2c_retimer_setting( buffer[1] = 0x23; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_address = 0x%x,\ + offset = 0x%d, reg_val = 0x%d, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1671,6 +1693,9 @@ static void write_i2c_retimer_setting( buffer[1] = 0x00; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_address = 0x%x,\ + offset = 0x%d, reg_val = 0x%d, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1686,6 +1711,7 @@ static void write_i2c_default_retimer_setting( uint8_t slave_address = (0xBA >> 1); uint8_t buffer[2]; bool i2c_success = false; + DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger); memset(&buffer, 0, sizeof(buffer)); @@ -1695,6 +1721,9 @@ static void write_i2c_default_retimer_setting( buffer[1] = 0x13; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer writes default setting to slave_address = 0x%x,\ + offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1704,6 +1733,9 @@ static void write_i2c_default_retimer_setting( buffer[1] = 0x17; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_addr = 0x%x,\ + offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1713,6 +1745,9 @@ static void write_i2c_default_retimer_setting( buffer[1] = is_over_340mhz ? 0xDA : 0xD8; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_addr = 0x%x,\ + offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1722,6 +1757,9 @@ static void write_i2c_default_retimer_setting( buffer[1] = 0x17; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_addr = 0x%x,\ + offset = 0x%x, reg_val= 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1731,6 +1769,9 @@ static void write_i2c_default_retimer_setting( buffer[1] = is_over_340mhz ? 0x1D : 0x91; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_addr = 0x%x,\ + offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1740,6 +1781,9 @@ static void write_i2c_default_retimer_setting( buffer[1] = 0x17; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_addr = 0x%x,\ + offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1753,6 +1797,9 @@ static void write_i2c_default_retimer_setting( buffer[1] = 0x01; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_addr = 0x%x,\ + offset = 0x%x, reg_val = 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1762,6 +1809,9 @@ static void write_i2c_default_retimer_setting( buffer[1] = 0x23; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write to slave_addr = 0x%x,\ + offset = 0x%x, reg_val= 0x%x, i2c_success = %d\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1771,6 +1821,9 @@ static void write_i2c_default_retimer_setting( buffer[1] = 0x00; i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("retimer write default setting to slave_addr = 0x%x,\ + offset = 0x%x, reg_val= 0x%x, i2c_success = %d end here\n", + slave_address, buffer[0], buffer[1], i2c_success?1:0); if (!i2c_success) /* Write failure */ ASSERT(i2c_success); @@ -1784,6 +1837,7 @@ static void write_i2c_redriver_setting( uint8_t slave_address = (0xF0 >> 1); uint8_t buffer[16]; bool i2c_success = false; + DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger); memset(&buffer, 0, sizeof(buffer)); @@ -1795,6 +1849,11 @@ static void write_i2c_redriver_setting( i2c_success = i2c_write(pipe_ctx, slave_address, buffer, sizeof(buffer)); + RETIMER_REDRIVER_INFO("redriver write 0 to all 16 reg offset expect following:\n\ + \t slave_addr = 0x%x, offset[3] = 0x%x, offset[4] = 0x%x,\ + offset[5] = 0x%x,offset[6] is_over_340mhz = 0x%x,\ + i2c_success = %d\n", + slave_address, buffer[3], buffer[4], buffer[5], buffer[6], i2c_success?1:0); if (!i2c_success) /* Write failure */ -- cgit v1.2.3 From 56780940389a344a949d53ed7be77012a20ced7a Mon Sep 17 00:00:00 2001 From: "Leo (Sunpeng) Li" Date: Wed, 1 Aug 2018 10:20:53 -0400 Subject: drm/amd/display: Remove redundant non-zero and overflow check [Why] Unsigned int is guaranteed to be >= 0, and read_channel_reply checks for overflows. read_channel_reply also returns -1 on error, which is what dc_link_aux_transfer is expected to return on error. [How] Remove the if-statement. Return result of read_channel_reply directly. Signed-off-by: Leo (Sunpeng) Li Reviewed-by: Mikita Lipski Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c index 8def0d9fa0ff..506a97e16956 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c @@ -666,13 +666,9 @@ int dc_link_aux_transfer(struct ddc_service *ddc, switch (operation_result) { case AUX_CHANNEL_OPERATION_SUCCEEDED: - res = returned_bytes; - - if (res <= size && res >= 0) - res = aux_engine->funcs->read_channel_reply(aux_engine, size, - buffer, reply, - &status); - + res = aux_engine->funcs->read_channel_reply(aux_engine, size, + buffer, reply, + &status); break; case AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON: res = 0; -- cgit v1.2.3 From 5d0e7e5caa08e1548aa39ad316202bd99bf970c4 Mon Sep 17 00:00:00 2001 From: Tony Cheng Date: Wed, 18 Jul 2018 20:29:13 -0400 Subject: drm/amd/display: dc 3.1.62 Signed-off-by: Tony Cheng Reviewed-by: Steven Chiu Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index eb1de3ba622f..1cf4ec68e741 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -38,7 +38,7 @@ #include "inc/compressor.h" #include "dml/display_mode_lib.h" -#define DC_VER "3.1.61" +#define DC_VER "3.1.62" #define MAX_SURFACES 3 #define MAX_STREAMS 6 -- cgit v1.2.3 From 98e6436d3af5fef7ca9b59d865dd5807ede36fb9 Mon Sep 17 00:00:00 2001 From: Anthony Koo Date: Tue, 21 Aug 2018 14:40:28 -0500 Subject: drm/amd/display: Refactor FreeSync module Remove dependency on internal sink map and instead use existing stream and plane state Signed-off-by: Anthony Koo Signed-off-by: Harry Wentland Reviewed-by: Tony Cheng Acked-by: Harry Wentland Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 60 +++++++---- drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 3 + drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 110 +-------------------- drivers/gpu/drm/amd/display/dc/dc_hw_types.h | 6 -- drivers/gpu/drm/amd/display/dc/dc_stream.h | 29 +++--- drivers/gpu/drm/amd/display/dc/dc_types.h | 22 +---- .../amd/display/dc/dce110/dce110_hw_sequencer.c | 34 +++++-- .../drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 27 ++++- 8 files changed, 118 insertions(+), 173 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 71742635e797..a4df627d6936 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -188,11 +188,9 @@ failed_alloc: ***************************************************************************** */ bool dc_stream_adjust_vmin_vmax(struct dc *dc, - struct dc_stream_state **streams, int num_streams, - int vmin, int vmax) + struct dc_stream_state *stream, + struct dc_crtc_timing_adjust *adjust) { - /* TODO: Support multiple streams */ - struct dc_stream_state *stream = streams[0]; int i = 0; bool ret = false; @@ -200,11 +198,11 @@ bool dc_stream_adjust_vmin_vmax(struct dc *dc, struct pipe_ctx *pipe = &dc->current_state->res_ctx.pipe_ctx[i]; if (pipe->stream == stream && pipe->stream_res.stream_enc) { - dc->hwss.set_drr(&pipe, 1, vmin, vmax); - - /* build and update the info frame */ - resource_build_info_frame(pipe); - dc->hwss.update_info_frame(pipe); + pipe->stream->adjust = *adjust; + dc->hwss.set_drr(&pipe, + 1, + adjust->v_total_min, + adjust->v_total_max); ret = true; } @@ -217,7 +215,7 @@ bool dc_stream_get_crtc_position(struct dc *dc, unsigned int *v_pos, unsigned int *nom_v_pos) { /* TODO: Support multiple streams */ - struct dc_stream_state *stream = streams[0]; + const struct dc_stream_state *stream = streams[0]; int i = 0; bool ret = false; struct crtc_position position; @@ -1257,8 +1255,25 @@ static enum surface_update_type check_update_surfaces_for_stream( if (stream_status == NULL || stream_status->plane_count != surface_count) return UPDATE_TYPE_FULL; - if (stream_update) - return UPDATE_TYPE_FULL; + /* some stream updates require passive update */ + if (stream_update) { + if ((stream_update->src.height != 0) && + (stream_update->src.width != 0)) + return UPDATE_TYPE_FULL; + + if ((stream_update->dst.height != 0) && + (stream_update->dst.width != 0)) + return UPDATE_TYPE_FULL; + + if (stream_update->out_transfer_func) + return UPDATE_TYPE_FULL; + + if (stream_update->hdr_static_metadata) + return UPDATE_TYPE_FULL; + + if (stream_update->abm_level) + return UPDATE_TYPE_FULL; + } for (i = 0 ; i < surface_count; i++) { enum surface_update_type type = @@ -1337,7 +1352,6 @@ static void commit_planes_for_stream(struct dc *dc, return; } - /* Full fe update*/ for (j = 0; j < dc->res_pool->pipe_count; j++) { struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j]; @@ -1348,11 +1362,22 @@ static void commit_planes_for_stream(struct dc *dc, top_pipe_to_program = pipe_ctx; - if (update_type == UPDATE_TYPE_FAST || !pipe_ctx->plane_state) + if (!pipe_ctx->plane_state) + continue; + + /* Fast update*/ + // VRR program can be done as part of FAST UPDATE + if (stream_update && stream_update->adjust) + dc->hwss.set_drr(&pipe_ctx, 1, + stream_update->adjust->v_total_min, + stream_update->adjust->v_total_max); + + /* Full fe update*/ + if (update_type == UPDATE_TYPE_FAST) continue; stream_status = - stream_get_status(context, pipe_ctx->stream); + stream_get_status(context, pipe_ctx->stream); dc->hwss.apply_ctx_for_surface( dc, pipe_ctx->stream, stream_status->plane_count, context); @@ -1407,7 +1432,7 @@ static void commit_planes_for_stream(struct dc *dc, dc->hwss.pipe_control_lock(dc, top_pipe_to_program, false); } - if (stream && stream_update && update_type > UPDATE_TYPE_FAST) + if (stream && stream_update) for (j = 0; j < dc->res_pool->pipe_count; j++) { struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j]; @@ -1415,7 +1440,8 @@ static void commit_planes_for_stream(struct dc *dc, if (pipe_ctx->stream != stream) continue; - if (stream_update->hdr_static_metadata) { + if (stream_update->hdr_static_metadata || + (stream_update->vrr_infopacket)) { resource_build_info_frame(pipe_ctx); dc->hwss.update_info_frame(pipe_ctx); } diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c index a7553b6d59c2..d91df5ef0cb3 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c @@ -2389,6 +2389,9 @@ static bool retrieve_link_cap(struct dc_link *link) dp_wa_power_up_0010FA(link, dpcd_data, sizeof(dpcd_data)); + down_strm_port_count.raw = dpcd_data[DP_DOWN_STREAM_PORT_COUNT - + DP_DPCD_REV]; + link->dpcd_caps.allow_invalid_MSA_timing_param = down_strm_port_count.bits.IGNORE_MSA_TIMING_PARAM; diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index 2c348b11b9a5..4468b240929a 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -2475,119 +2475,13 @@ static void set_spd_info_packet( { /* SPD info packet for FreeSync */ - unsigned char checksum = 0; - unsigned int idx, payload_size = 0; - /* Check if Freesync is supported. Return if false. If true, * set the corresponding bit in the info packet */ - if (stream->freesync_ctx.supported == false) + if (!stream->vrr_infopacket.valid) return; - if (dc_is_hdmi_signal(stream->signal)) { - - /* HEADER */ - - /* HB0 = Packet Type = 0x83 (Source Product - * Descriptor InfoFrame) - */ - info_packet->hb0 = HDMI_INFOFRAME_TYPE_SPD; - - /* HB1 = Version = 0x01 */ - info_packet->hb1 = 0x01; - - /* HB2 = [Bits 7:5 = 0] [Bits 4:0 = Length = 0x08] */ - info_packet->hb2 = 0x08; - - payload_size = 0x08; - - } else if (dc_is_dp_signal(stream->signal)) { - - /* HEADER */ - - /* HB0 = Secondary-data Packet ID = 0 - Only non-zero - * when used to associate audio related info packets - */ - info_packet->hb0 = 0x00; - - /* HB1 = Packet Type = 0x83 (Source Product - * Descriptor InfoFrame) - */ - info_packet->hb1 = HDMI_INFOFRAME_TYPE_SPD; - - /* HB2 = [Bits 7:0 = Least significant eight bits - - * For INFOFRAME, the value must be 1Bh] - */ - info_packet->hb2 = 0x1B; - - /* HB3 = [Bits 7:2 = INFOFRAME SDP Version Number = 0x1] - * [Bits 1:0 = Most significant two bits = 0x00] - */ - info_packet->hb3 = 0x04; - - payload_size = 0x1B; - } - - /* PB1 = 0x1A (24bit AMD IEEE OUI (0x00001A) - Byte 0) */ - info_packet->sb[1] = 0x1A; - - /* PB2 = 0x00 (24bit AMD IEEE OUI (0x00001A) - Byte 1) */ - info_packet->sb[2] = 0x00; - - /* PB3 = 0x00 (24bit AMD IEEE OUI (0x00001A) - Byte 2) */ - info_packet->sb[3] = 0x00; - - /* PB4 = Reserved */ - info_packet->sb[4] = 0x00; - - /* PB5 = Reserved */ - info_packet->sb[5] = 0x00; - - /* PB6 = [Bits 7:3 = Reserved] */ - info_packet->sb[6] = 0x00; - - if (stream->freesync_ctx.supported == true) - /* PB6 = [Bit 0 = FreeSync Supported] */ - info_packet->sb[6] |= 0x01; - - if (stream->freesync_ctx.enabled == true) - /* PB6 = [Bit 1 = FreeSync Enabled] */ - info_packet->sb[6] |= 0x02; - - if (stream->freesync_ctx.active == true) - /* PB6 = [Bit 2 = FreeSync Active] */ - info_packet->sb[6] |= 0x04; - - /* PB7 = FreeSync Minimum refresh rate (Hz) */ - info_packet->sb[7] = (unsigned char) (stream->freesync_ctx. - min_refresh_in_micro_hz / 1000000); - - /* PB8 = FreeSync Maximum refresh rate (Hz) - * - * Note: We do not use the maximum capable refresh rate - * of the panel, because we should never go above the field - * rate of the mode timing set. - */ - info_packet->sb[8] = (unsigned char) (stream->freesync_ctx. - nominal_refresh_in_micro_hz / 1000000); - - /* PB9 - PB27 = Reserved */ - for (idx = 9; idx <= 27; idx++) - info_packet->sb[idx] = 0x00; - - /* Calculate checksum */ - checksum += info_packet->hb0; - checksum += info_packet->hb1; - checksum += info_packet->hb2; - checksum += info_packet->hb3; - - for (idx = 1; idx <= payload_size; idx++) - checksum += info_packet->sb[idx]; - - /* PB0 = Checksum (one byte complement) */ - info_packet->sb[0] = (unsigned char) (0x100 - checksum); - - info_packet->valid = true; + *info_packet = stream->vrr_infopacket; } static void set_hdr_static_info_packet( diff --git a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h index b789cb2b354b..57f57cf0fe2a 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h +++ b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h @@ -708,12 +708,6 @@ struct crtc_trigger_info { enum trigger_delay delay; }; -enum vrr_state { - VRR_STATE_OFF = 0, - VRR_STATE_VARIABLE, - VRR_STATE_FIXED, -}; - struct dc_crtc_timing_adjust { uint32_t v_total_min; uint32_t v_total_max; diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h index cbfe418006cb..67101a525e3d 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_stream.h +++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h @@ -45,19 +45,25 @@ struct dc_stream_status { struct dc_link *link; }; +// TODO: References to this needs to be removed.. +struct freesync_context { + bool dummy; +}; + struct dc_stream_state { struct dc_sink *sink; struct dc_crtc_timing timing; - struct dc_crtc_timing_adjust timing_adjust; - struct vrr_params vrr_params; + struct dc_crtc_timing_adjust adjust; + struct dc_info_packet vrr_infopacket; struct rect src; /* composition area */ struct rect dst; /* stream addressable area */ - struct audio_info audio_info; - + // TODO: References to this needs to be removed.. struct freesync_context freesync_ctx; + struct audio_info audio_info; + struct dc_info_packet hdr_static_metadata; PHYSICAL_ADDRESS_LOC dmdata_address; bool use_dynamic_meta; @@ -120,6 +126,8 @@ struct dc_stream_update { unsigned int *abm_level; unsigned long long *periodic_fn_vsync_delta; + struct dc_crtc_timing_adjust *adjust; + struct dc_info_packet *vrr_infopacket; }; bool dc_is_stream_unchanged( @@ -258,10 +266,8 @@ bool dc_stream_set_cursor_position( bool dc_stream_adjust_vmin_vmax(struct dc *dc, - struct dc_stream_state **stream, - int num_streams, - int vmin, - int vmax); + struct dc_stream_state *stream, + struct dc_crtc_timing_adjust *adjust); bool dc_stream_get_crtc_position(struct dc *dc, struct dc_stream_state **stream, @@ -288,13 +294,6 @@ void dc_stream_set_static_screen_events(struct dc *dc, void dc_stream_set_dither_option(struct dc_stream_state *stream, enum dc_dither_option option); - -bool dc_stream_adjust_vmin_vmax(struct dc *dc, - struct dc_stream_state **stream, - int num_streams, - int vmin, - int vmax); - bool dc_stream_get_crtc_position(struct dc *dc, struct dc_stream_state **stream, int num_streams, diff --git a/drivers/gpu/drm/amd/display/dc/dc_types.h b/drivers/gpu/drm/amd/display/dc/dc_types.h index 8c6eb78b0c3b..58a6ef80a60e 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_types.h +++ b/drivers/gpu/drm/amd/display/dc/dc_types.h @@ -513,13 +513,11 @@ struct audio_info { struct audio_mode modes[DC_MAX_AUDIO_DESC_COUNT]; }; -struct vrr_params { - enum vrr_state state; - uint32_t window_min; - uint32_t window_max; - uint32_t inserted_frame_duration_in_us; - uint32_t frames_to_insert; - uint32_t frame_counter; +enum dc_infoframe_type { + DC_HDMI_INFOFRAME_TYPE_VENDOR = 0x81, + DC_HDMI_INFOFRAME_TYPE_AVI = 0x82, + DC_HDMI_INFOFRAME_TYPE_SPD = 0x83, + DC_HDMI_INFOFRAME_TYPE_AUDIO = 0x84, }; struct dc_info_packet { @@ -539,16 +537,6 @@ struct dc_plane_flip_time { unsigned int prev_update_time_in_us; }; -// Will combine with vrr_params at some point. -struct freesync_context { - bool supported; - bool enabled; - bool active; - - unsigned int min_refresh_in_micro_hz; - unsigned int nominal_refresh_in_micro_hz; -}; - struct psr_config { unsigned char psr_version; unsigned int psr_rfb_setup_time; diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c index 2f2c5155c5aa..ae4792494fe7 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c @@ -1286,6 +1286,8 @@ static enum dc_status dce110_enable_stream_timing( struct pipe_ctx *pipe_ctx_old = &dc->current_state->res_ctx. pipe_ctx[pipe_ctx->pipe_idx]; struct tg_color black_color = {0}; + struct drr_params params = {0}; + unsigned int event_triggers = 0; if (!pipe_ctx_old->stream) { @@ -1315,9 +1317,19 @@ static enum dc_status dce110_enable_stream_timing( &stream->timing, true); - pipe_ctx->stream_res.tg->funcs->set_static_screen_control( - pipe_ctx->stream_res.tg, - 0x182); + params.vertical_total_min = stream->adjust.v_total_min; + params.vertical_total_max = stream->adjust.v_total_max; + if (pipe_ctx->stream_res.tg->funcs->set_drr) + pipe_ctx->stream_res.tg->funcs->set_drr( + pipe_ctx->stream_res.tg, ¶ms); + + // DRR should set trigger event to monitor surface update event + if (stream->adjust.v_total_min != 0 && + stream->adjust.v_total_max != 0) + event_triggers = 0x80; + if (pipe_ctx->stream_res.tg->funcs->set_static_screen_control) + pipe_ctx->stream_res.tg->funcs->set_static_screen_control( + pipe_ctx->stream_res.tg, event_triggers); } if (!pipe_ctx_old->stream) { @@ -1328,8 +1340,6 @@ static enum dc_status dce110_enable_stream_timing( } } - - return DC_OK; } @@ -1719,16 +1729,24 @@ static void set_drr(struct pipe_ctx **pipe_ctx, { int i = 0; struct drr_params params = {0}; + // DRR should set trigger event to monitor surface update event + unsigned int event_triggers = 0x80; params.vertical_total_max = vmax; params.vertical_total_min = vmin; /* TODO: If multiple pipes are to be supported, you need - * some GSL stuff + * some GSL stuff. Static screen triggers may be programmed differently + * as well. */ - for (i = 0; i < num_pipes; i++) { - pipe_ctx[i]->stream_res.tg->funcs->set_drr(pipe_ctx[i]->stream_res.tg, ¶ms); + pipe_ctx[i]->stream_res.tg->funcs->set_drr( + pipe_ctx[i]->stream_res.tg, ¶ms); + + if (vmax != 0 && vmin != 0) + pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control( + pipe_ctx[i]->stream_res.tg, + event_triggers); } } diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index 6d27f1db3c69..4b8bedb625b4 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c @@ -631,6 +631,8 @@ static enum dc_status dcn10_enable_stream_timing( struct dc_stream_state *stream = pipe_ctx->stream; enum dc_color_space color_space; struct tg_color black_color = {0}; + struct drr_params params = {0}; + unsigned int event_triggers = 0; /* by upper caller loop, pipe0 is parent pipe and be called first. * back end is set up by for pipe0. Other children pipe share back end @@ -698,6 +700,19 @@ static enum dc_status dcn10_enable_stream_timing( return DC_ERROR_UNEXPECTED; } + params.vertical_total_min = stream->adjust.v_total_min; + params.vertical_total_max = stream->adjust.v_total_max; + if (pipe_ctx->stream_res.tg->funcs->set_drr) + pipe_ctx->stream_res.tg->funcs->set_drr( + pipe_ctx->stream_res.tg, ¶ms); + + // DRR should set trigger event to monitor surface update event + if (stream->adjust.v_total_min != 0 && stream->adjust.v_total_max != 0) + event_triggers = 0x80; + if (pipe_ctx->stream_res.tg->funcs->set_static_screen_control) + pipe_ctx->stream_res.tg->funcs->set_static_screen_control( + pipe_ctx->stream_res.tg, event_triggers); + /* TODO program crtc source select for non-virtual signal*/ /* TODO program FMT */ /* TODO setup link_enc */ @@ -2399,15 +2414,23 @@ static void set_drr(struct pipe_ctx **pipe_ctx, { int i = 0; struct drr_params params = {0}; + // DRR should set trigger event to monitor surface update event + unsigned int event_triggers = 0x80; params.vertical_total_max = vmax; params.vertical_total_min = vmin; /* TODO: If multiple pipes are to be supported, you need - * some GSL stuff + * some GSL stuff. Static screen triggers may be programmed differently + * as well. */ for (i = 0; i < num_pipes; i++) { - pipe_ctx[i]->stream_res.tg->funcs->set_drr(pipe_ctx[i]->stream_res.tg, ¶ms); + pipe_ctx[i]->stream_res.tg->funcs->set_drr( + pipe_ctx[i]->stream_res.tg, ¶ms); + if (vmax != 0 && vmin != 0) + pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control( + pipe_ctx[i]->stream_res.tg, + event_triggers); } } -- cgit v1.2.3 From 4c1fa3630b44f03d5539a778ddcea319e9c8223a Mon Sep 17 00:00:00 2001 From: Harry Wentland Date: Sun, 25 Mar 2018 16:28:33 -0400 Subject: drm/amd/display: Don't force UPDATE_TYPE_FULL if stream_update has hdr_static_metadata This was missed when pushing public patch for 3e3a40b03847 (drm/amd/display: Updated HDR Static Metadata to directly take info packet raw) This is currently no problem yet since we're not doing HDR on Linux yet. Signed-off-by: Harry Wentland Acked-by: Alex Deucher Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index a4df627d6936..0179d2be9866 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -1268,9 +1268,6 @@ static enum surface_update_type check_update_surfaces_for_stream( if (stream_update->out_transfer_func) return UPDATE_TYPE_FULL; - if (stream_update->hdr_static_metadata) - return UPDATE_TYPE_FULL; - if (stream_update->abm_level) return UPDATE_TYPE_FULL; } -- cgit v1.2.3 From 1e7e86c43f38d2cc0183ae2a440c70f3c6163883 Mon Sep 17 00:00:00 2001 From: Samson Tam Date: Tue, 1 May 2018 10:39:26 -0400 Subject: drm/amd/display: decouple front and backend pgm using dpms_off as backend enable flag Signed-off-by: Samson Tam Reviewed-by: Anthony Koo Acked-by: Harry Wentland Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 125 +++++++++++++-------- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 34 ++++++ drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 6 + drivers/gpu/drm/amd/display/dc/dc_stream.h | 2 + .../amd/display/dc/dce110/dce110_hw_sequencer.c | 38 +------ 5 files changed, 123 insertions(+), 82 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 0179d2be9866..2d4a5a85f799 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -1270,6 +1270,9 @@ static enum surface_update_type check_update_surfaces_for_stream( if (stream_update->abm_level) return UPDATE_TYPE_FULL; + + if (stream_update->dpms_off) + return UPDATE_TYPE_FULL; } for (i = 0 ; i < surface_count; i++) { @@ -1324,6 +1327,71 @@ static struct dc_stream_status *stream_get_status( static const enum surface_update_type update_surface_trace_level = UPDATE_TYPE_FULL; +static void commit_planes_do_stream_update(struct dc *dc, + struct dc_stream_state *stream, + struct dc_stream_update *stream_update, + enum surface_update_type update_type, + struct dc_state *context) +{ + int j; + + // Stream updates + for (j = 0; j < dc->res_pool->pipe_count; j++) { + struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j]; + + if (!pipe_ctx->top_pipe && + pipe_ctx->stream && + pipe_ctx->stream == stream) { + + /* Fast update*/ + // VRR program can be done as part of FAST UPDATE + if (stream_update->adjust) + dc->hwss.set_drr(&pipe_ctx, 1, + stream_update->adjust->v_total_min, + stream_update->adjust->v_total_max); + + /* Full fe update*/ + if (update_type == UPDATE_TYPE_FAST) + continue; + + if (stream_update->dpms_off) { + if (*stream_update->dpms_off) { + core_link_disable_stream(pipe_ctx, KEEP_ACQUIRED_RESOURCE); + dc->hwss.pplib_apply_display_requirements( + dc, dc->current_state); + } else { + dc->hwss.pplib_apply_display_requirements( + dc, dc->current_state); + core_link_enable_stream(dc->current_state, pipe_ctx); + } + } + + if (stream_update->abm_level && pipe_ctx->stream_res.abm) { + if (pipe_ctx->stream_res.tg->funcs->is_blanked) { + // if otg funcs defined check if blanked before programming + if (!pipe_ctx->stream_res.tg->funcs->is_blanked(pipe_ctx->stream_res.tg)) + pipe_ctx->stream_res.abm->funcs->set_abm_level( + pipe_ctx->stream_res.abm, stream->abm_level); + } else + pipe_ctx->stream_res.abm->funcs->set_abm_level( + pipe_ctx->stream_res.abm, stream->abm_level); + } + + if (stream_update->periodic_fn_vsync_delta && + pipe_ctx->stream_res.tg->funcs->program_vline_interrupt) + pipe_ctx->stream_res.tg->funcs->program_vline_interrupt( + pipe_ctx->stream_res.tg, &pipe_ctx->stream->timing, + pipe_ctx->stream->periodic_fn_vsync_delta); + + if (stream_update->hdr_static_metadata || + stream_update->vrr_infopacket) { + resource_build_info_frame(pipe_ctx); + dc->hwss.update_info_frame(pipe_ctx); + } + } + } +} + static void commit_planes_for_stream(struct dc *dc, struct dc_surface_update *srf_updates, int surface_count, @@ -1340,15 +1408,20 @@ static void commit_planes_for_stream(struct dc *dc, context_clock_trace(dc, context); } + // Stream updates + if (stream_update) + commit_planes_do_stream_update(dc, stream, stream_update, update_type, context); + if (surface_count == 0) { /* * In case of turning off screen, no need to program front end a second time. - * just return after program front end. + * just return after program blank. */ - dc->hwss.apply_ctx_for_surface(dc, stream, surface_count, context); + dc->hwss.apply_ctx_for_surface(dc, stream, 0, context); return; } + // Update Type FULL, Surface updates for (j = 0; j < dc->res_pool->pipe_count; j++) { struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j]; @@ -1362,13 +1435,6 @@ static void commit_planes_for_stream(struct dc *dc, if (!pipe_ctx->plane_state) continue; - /* Fast update*/ - // VRR program can be done as part of FAST UPDATE - if (stream_update && stream_update->adjust) - dc->hwss.set_drr(&pipe_ctx, 1, - stream_update->adjust->v_total_min, - stream_update->adjust->v_total_max); - /* Full fe update*/ if (update_type == UPDATE_TYPE_FAST) continue; @@ -1378,34 +1444,18 @@ static void commit_planes_for_stream(struct dc *dc, dc->hwss.apply_ctx_for_surface( dc, pipe_ctx->stream, stream_status->plane_count, context); - - if (stream_update && stream_update->abm_level && pipe_ctx->stream_res.abm) { - if (pipe_ctx->stream_res.tg->funcs->is_blanked) { - // if otg funcs defined check if blanked before programming - if (!pipe_ctx->stream_res.tg->funcs->is_blanked(pipe_ctx->stream_res.tg)) - pipe_ctx->stream_res.abm->funcs->set_abm_level( - pipe_ctx->stream_res.abm, stream->abm_level); - } else - pipe_ctx->stream_res.abm->funcs->set_abm_level( - pipe_ctx->stream_res.abm, stream->abm_level); - } - - if (stream_update && stream_update->periodic_fn_vsync_delta && - pipe_ctx->stream_res.tg->funcs->program_vline_interrupt) - pipe_ctx->stream_res.tg->funcs->program_vline_interrupt( - pipe_ctx->stream_res.tg, &pipe_ctx->stream->timing, - pipe_ctx->stream->periodic_fn_vsync_delta); } } if (update_type == UPDATE_TYPE_FULL) context_timing_trace(dc, &context->res_ctx); - /* Lock the top pipe while updating plane addrs, since freesync requires - * plane addr update event triggers to be synchronized. - * top_pipe_to_program is expected to never be NULL - */ + // Update Type FAST, Surface updates if (update_type == UPDATE_TYPE_FAST) { + /* Lock the top pipe while updating plane addrs, since freesync requires + * plane addr update event triggers to be synchronized. + * top_pipe_to_program is expected to never be NULL + */ dc->hwss.pipe_control_lock(dc, top_pipe_to_program, true); /* Perform requested Updates */ @@ -1428,21 +1478,6 @@ static void commit_planes_for_stream(struct dc *dc, dc->hwss.pipe_control_lock(dc, top_pipe_to_program, false); } - - if (stream && stream_update) - for (j = 0; j < dc->res_pool->pipe_count; j++) { - struct pipe_ctx *pipe_ctx = - &context->res_ctx.pipe_ctx[j]; - - if (pipe_ctx->stream != stream) - continue; - - if (stream_update->hdr_static_metadata || - (stream_update->vrr_infopacket)) { - resource_build_info_frame(pipe_ctx); - dc->hwss.update_info_frame(pipe_ctx); - } - } } void dc_commit_updates_for_stream(struct dc *dc, diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index 1adfcdd588d6..739c6654d849 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c @@ -2458,9 +2458,43 @@ void core_link_enable_stream( struct pipe_ctx *pipe_ctx) { struct dc *core_dc = pipe_ctx->stream->ctx->dc; + struct dc_stream_state *stream = pipe_ctx->stream; enum dc_status status; DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger); + if (pipe_ctx->stream->signal != SIGNAL_TYPE_VIRTUAL) { + stream->sink->link->link_enc->funcs->setup( + stream->sink->link->link_enc, + pipe_ctx->stream->signal); + pipe_ctx->stream_res.stream_enc->funcs->setup_stereo_sync( + pipe_ctx->stream_res.stream_enc, + pipe_ctx->stream_res.tg->inst, + stream->timing.timing_3d_format != TIMING_3D_FORMAT_NONE); + } + + if (dc_is_dp_signal(pipe_ctx->stream->signal)) + pipe_ctx->stream_res.stream_enc->funcs->dp_set_stream_attribute( + pipe_ctx->stream_res.stream_enc, + &stream->timing, + stream->output_color_space); + + if (dc_is_hdmi_signal(pipe_ctx->stream->signal)) + pipe_ctx->stream_res.stream_enc->funcs->hdmi_set_stream_attribute( + pipe_ctx->stream_res.stream_enc, + &stream->timing, + stream->phy_pix_clk, + pipe_ctx->stream_res.audio != NULL); + + if (dc_is_dvi_signal(pipe_ctx->stream->signal)) + pipe_ctx->stream_res.stream_enc->funcs->dvi_set_stream_attribute( + pipe_ctx->stream_res.stream_enc, + &stream->timing, + (pipe_ctx->stream->signal == SIGNAL_TYPE_DVI_DUAL_LINK) ? + true : false); + + resource_build_info_frame(pipe_ctx); + core_dc->hwss.update_info_frame(pipe_ctx); + /* eDP lit up by bios already, no need to enable again. */ if (pipe_ctx->stream->signal == SIGNAL_TYPE_EDP && core_dc->apply_edp_fast_boot_optimization) { diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index 4468b240929a..9157f5d83b0d 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -1615,6 +1615,9 @@ static bool are_stream_backends_same( if (is_hdr_static_meta_changed(stream_a, stream_b)) return false; + if (stream_a->dpms_off != stream_b->dpms_off) + return false; + return true; } @@ -2716,6 +2719,9 @@ bool pipe_need_reprogram( if (is_hdr_static_meta_changed(pipe_ctx_old->stream, pipe_ctx->stream)) return true; + if (pipe_ctx_old->stream->dpms_off != pipe_ctx->stream->dpms_off) + return true; + return false; } diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h index 67101a525e3d..97d2dcf2547c 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_stream.h +++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h @@ -128,6 +128,8 @@ struct dc_stream_update { unsigned long long *periodic_fn_vsync_delta; struct dc_crtc_timing_adjust *adjust; struct dc_info_packet *vrr_infopacket; + + bool *dpms_off; }; bool dc_is_stream_unchanged( diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c index ae4792494fe7..ce1e0f6ec3ca 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c @@ -1349,8 +1349,6 @@ static enum dc_status apply_single_controller_ctx_to_hw( struct dc *dc) { struct dc_stream_state *stream = pipe_ctx->stream; - struct pipe_ctx *pipe_ctx_old = &dc->current_state->res_ctx. - pipe_ctx[pipe_ctx->pipe_idx]; if (pipe_ctx->stream_res.audio != NULL) { struct audio_output audio_output; @@ -1405,46 +1403,12 @@ static enum dc_status apply_single_controller_ctx_to_hw( stream->timing.display_color_depth, pipe_ctx->stream->signal); - if (pipe_ctx->stream->signal != SIGNAL_TYPE_VIRTUAL) - stream->sink->link->link_enc->funcs->setup( - stream->sink->link->link_enc, - pipe_ctx->stream->signal); - - if (pipe_ctx->stream->signal != SIGNAL_TYPE_VIRTUAL) - pipe_ctx->stream_res.stream_enc->funcs->setup_stereo_sync( - pipe_ctx->stream_res.stream_enc, - pipe_ctx->stream_res.tg->inst, - stream->timing.timing_3d_format != TIMING_3D_FORMAT_NONE); - - pipe_ctx->stream_res.opp->funcs->opp_program_fmt( pipe_ctx->stream_res.opp, &stream->bit_depth_params, &stream->clamping); - if (dc_is_dp_signal(pipe_ctx->stream->signal)) - pipe_ctx->stream_res.stream_enc->funcs->dp_set_stream_attribute( - pipe_ctx->stream_res.stream_enc, - &stream->timing, - stream->output_color_space); - - if (dc_is_hdmi_signal(pipe_ctx->stream->signal)) - pipe_ctx->stream_res.stream_enc->funcs->hdmi_set_stream_attribute( - pipe_ctx->stream_res.stream_enc, - &stream->timing, - stream->phy_pix_clk, - pipe_ctx->stream_res.audio != NULL); - - if (dc_is_dvi_signal(pipe_ctx->stream->signal)) - pipe_ctx->stream_res.stream_enc->funcs->dvi_set_stream_attribute( - pipe_ctx->stream_res.stream_enc, - &stream->timing, - (pipe_ctx->stream->signal == SIGNAL_TYPE_DVI_DUAL_LINK) ? - true : false); - - resource_build_info_frame(pipe_ctx); - dce110_update_info_frame(pipe_ctx); - if (!pipe_ctx_old->stream) + if (!stream->dpms_off) core_link_enable_stream(context, pipe_ctx); pipe_ctx->plane_res.scl_data.lb_params.alpha_en = pipe_ctx->bottom_pipe != 0; -- cgit v1.2.3 From 27e2e207747981ca3161dec16cea304f8e46cd65 Mon Sep 17 00:00:00 2001 From: SivapiriyanKumarasamy Date: Fri, 18 May 2018 17:05:52 -0400 Subject: drm/amd/display: Program vline interrupt on FAST update Signed-off-by: SivapiriyanKumarasamy Reviewed-by: Tony Cheng Reviewed-by: Anthony Koo Acked-by: Harry Wentland Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 2d4a5a85f799..699cb6f51121 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -1350,6 +1350,13 @@ static void commit_planes_do_stream_update(struct dc *dc, stream_update->adjust->v_total_min, stream_update->adjust->v_total_max); + if (stream_update->periodic_fn_vsync_delta && + pipe_ctx->stream_res.tg && + pipe_ctx->stream_res.tg->funcs->program_vline_interrupt) + pipe_ctx->stream_res.tg->funcs->program_vline_interrupt( + pipe_ctx->stream_res.tg, &pipe_ctx->stream->timing, + pipe_ctx->stream->periodic_fn_vsync_delta); + /* Full fe update*/ if (update_type == UPDATE_TYPE_FAST) continue; @@ -1377,12 +1384,6 @@ static void commit_planes_do_stream_update(struct dc *dc, pipe_ctx->stream_res.abm, stream->abm_level); } - if (stream_update->periodic_fn_vsync_delta && - pipe_ctx->stream_res.tg->funcs->program_vline_interrupt) - pipe_ctx->stream_res.tg->funcs->program_vline_interrupt( - pipe_ctx->stream_res.tg, &pipe_ctx->stream->timing, - pipe_ctx->stream->periodic_fn_vsync_delta); - if (stream_update->hdr_static_metadata || stream_update->vrr_infopacket) { resource_build_info_frame(pipe_ctx); -- cgit v1.2.3 From 1336926f43ccadf2a152ea89a27de725c4d17f62 Mon Sep 17 00:00:00 2001 From: Alvin lee Date: Mon, 4 Jun 2018 17:31:25 -0400 Subject: drm/amd/display: Enable Stereo in Dal3 - program infoframe for Stereo - program stereo flip control registers properly v2: Add missing license headers Signed-off-by: Alvin lee Reviewed-by: Tony Cheng Acked-by: Harry Wentland Acked-by: Alex Deucher Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 57 +++++++++-------------- drivers/gpu/drm/amd/display/dc/dc_stream.h | 1 + drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c | 18 ++++++- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h | 4 ++ 4 files changed, 43 insertions(+), 37 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index 9157f5d83b0d..07a1dd41666d 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -1578,6 +1578,20 @@ static bool is_hdr_static_meta_changed(struct dc_stream_state *cur_stream, return false; } +static bool is_vsc_info_packet_changed(struct dc_stream_state *cur_stream, + struct dc_stream_state *new_stream) +{ + if (cur_stream == NULL) + return true; + + if (memcmp(&cur_stream->vsc_infopacket, + &new_stream->vsc_infopacket, + sizeof(struct dc_info_packet)) != 0) + return true; + + return false; +} + static bool is_timing_changed(struct dc_stream_state *cur_stream, struct dc_stream_state *new_stream) { @@ -1618,6 +1632,9 @@ static bool are_stream_backends_same( if (stream_a->dpms_off != stream_b->dpms_off) return false; + if (is_vsc_info_packet_changed(stream_a, stream_b)) + return false; + return true; } @@ -2504,43 +2521,10 @@ static void set_vsc_info_packet( struct dc_info_packet *info_packet, struct dc_stream_state *stream) { - unsigned int vscPacketRevision = 0; - unsigned int i; - - /*VSC packet set to 2 when DP revision >= 1.2*/ - if (stream->psr_version != 0) { - vscPacketRevision = 2; - } - - /* VSC packet not needed based on the features - * supported by this DP display - */ - if (vscPacketRevision == 0) + if (!stream->vsc_infopacket.valid) return; - if (vscPacketRevision == 0x2) { - /* Secondary-data Packet ID = 0*/ - info_packet->hb0 = 0x00; - /* 07h - Packet Type Value indicating Video - * Stream Configuration packet - */ - info_packet->hb1 = 0x07; - /* 02h = VSC SDP supporting 3D stereo and PSR - * (applies to eDP v1.3 or higher). - */ - info_packet->hb2 = 0x02; - /* 08h = VSC packet supporting 3D stereo + PSR - * (HB2 = 02h). - */ - info_packet->hb3 = 0x08; - - for (i = 0; i < 28; i++) - info_packet->sb[i] = 0; - - info_packet->valid = true; - } - - /*TODO: stereo 3D support and extend pixel encoding colorimetry*/ + *info_packet = stream->vsc_infopacket; } void dc_resource_state_destruct(struct dc_state *context) @@ -2722,6 +2706,9 @@ bool pipe_need_reprogram( if (pipe_ctx_old->stream->dpms_off != pipe_ctx->stream->dpms_off) return true; + if (is_vsc_info_packet_changed(pipe_ctx_old->stream, pipe_ctx->stream)) + return true; + return false; } diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h index 97d2dcf2547c..8f81133ac0c1 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_stream.h +++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h @@ -55,6 +55,7 @@ struct dc_stream_state { struct dc_crtc_timing timing; struct dc_crtc_timing_adjust adjust; struct dc_info_packet vrr_infopacket; + struct dc_info_packet vsc_infopacket; struct rect src; /* composition area */ struct rect dst; /* stream addressable area */ diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c index ec4a5f665586..8da2b8a09a12 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c @@ -313,10 +313,24 @@ bool hubp1_program_surface_flip_and_addr( { struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); - /* program flip type */ - REG_SET(DCSURF_FLIP_CONTROL, 0, + + //program flip type + REG_UPDATE(DCSURF_FLIP_CONTROL, SURFACE_FLIP_TYPE, flip_immediate); + + if (address->type == PLN_ADDR_TYPE_GRPH_STEREO) { + REG_UPDATE(DCSURF_FLIP_CONTROL, SURFACE_FLIP_MODE_FOR_STEREOSYNC, 0x1); + REG_UPDATE(DCSURF_FLIP_CONTROL, SURFACE_FLIP_IN_STEREOSYNC, 0x1); + + } else { + // turn off stereo if not in stereo + REG_UPDATE(DCSURF_FLIP_CONTROL, SURFACE_FLIP_MODE_FOR_STEREOSYNC, 0x0); + REG_UPDATE(DCSURF_FLIP_CONTROL, SURFACE_FLIP_IN_STEREOSYNC, 0x0); + } + + + /* HW automatically latch rest of address register on write to * DCSURF_PRIMARY_SURFACE_ADDRESS if SURFACE_UPDATE_LOCK is not used * diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h index 48c1907c78c6..7605af9b4837 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h @@ -270,6 +270,8 @@ HUBP_SF(HUBPREQ0_DCSURF_SURFACE_PITCH_C, META_PITCH_C, mask_sh),\ HUBP_SF(HUBP0_DCSURF_SURFACE_CONFIG, SURFACE_PIXEL_FORMAT, mask_sh),\ HUBP_SF(HUBPREQ0_DCSURF_FLIP_CONTROL, SURFACE_FLIP_TYPE, mask_sh),\ + HUBP_SF(HUBPREQ0_DCSURF_FLIP_CONTROL, SURFACE_FLIP_MODE_FOR_STEREOSYNC, mask_sh),\ + HUBP_SF(HUBPREQ0_DCSURF_FLIP_CONTROL, SURFACE_FLIP_IN_STEREOSYNC, mask_sh),\ HUBP_SF(HUBPREQ0_DCSURF_FLIP_CONTROL, SURFACE_FLIP_PENDING, mask_sh),\ HUBP_SF(HUBPREQ0_DCSURF_FLIP_CONTROL, SURFACE_UPDATE_LOCK, mask_sh),\ HUBP_SF(HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION, PRI_VIEWPORT_WIDTH, mask_sh),\ @@ -451,6 +453,8 @@ type H_MIRROR_EN;\ type SURFACE_PIXEL_FORMAT;\ type SURFACE_FLIP_TYPE;\ + type SURFACE_FLIP_MODE_FOR_STEREOSYNC;\ + type SURFACE_FLIP_IN_STEREOSYNC;\ type SURFACE_UPDATE_LOCK;\ type SURFACE_FLIP_PENDING;\ type PRI_VIEWPORT_WIDTH; \ -- cgit v1.2.3 From 0e4af5f3675bd766dbf11e5f17428ea69b630035 Mon Sep 17 00:00:00 2001 From: Alvin lee Date: Fri, 8 Jun 2018 13:58:36 -0400 Subject: drm/amd/display: Program vsc_infopacket in commit_planes_for_stream Signed-off-by: Alvin lee Reviewed-by: Jun Lei Acked-by: Harry Wentland Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 3 ++- drivers/gpu/drm/amd/display/dc/dc_stream.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 699cb6f51121..eda21868c892 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -1385,7 +1385,8 @@ static void commit_planes_do_stream_update(struct dc *dc, } if (stream_update->hdr_static_metadata || - stream_update->vrr_infopacket) { + stream_update->vrr_infopacket || + stream_update->vsc_infopacket) { resource_build_info_frame(pipe_ctx); dc->hwss.update_info_frame(pipe_ctx); } diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h index 8f81133ac0c1..790beb5cb358 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_stream.h +++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h @@ -129,6 +129,7 @@ struct dc_stream_update { unsigned long long *periodic_fn_vsync_delta; struct dc_crtc_timing_adjust *adjust; struct dc_info_packet *vrr_infopacket; + struct dc_info_packet *vsc_infopacket; bool *dpms_off; }; -- cgit v1.2.3 From e71f8ca1a7db244642f9f882f1df003fa567ad43 Mon Sep 17 00:00:00 2001 From: Krunoslav Kovac Date: Thu, 5 Jul 2018 19:23:17 -0400 Subject: drm/amd/display: Handle HDR meta update as fast update [Why] Vesa DPMS tool sends different HDR meta in OS flips without changing output parameters. We don't properly update HDR info frame: - we label HDR meta update as fast update - when updating HW info frame, we only do it if full update [How] It should still be fast update, so when doing HW infoframe update, do it always no matter the update type. Also, don't request passive flip for HDR meta update only without output transfer function or color space changed. Signed-off-by: Krunoslav Kovac Reviewed-by: Tony Cheng Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index eda21868c892..9a947f8341bf 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -1357,6 +1357,13 @@ static void commit_planes_do_stream_update(struct dc *dc, pipe_ctx->stream_res.tg, &pipe_ctx->stream->timing, pipe_ctx->stream->periodic_fn_vsync_delta); + if (stream_update->hdr_static_metadata || + stream_update->vrr_infopacket || + stream_update->vsc_infopacket) { + resource_build_info_frame(pipe_ctx); + dc->hwss.update_info_frame(pipe_ctx); + } + /* Full fe update*/ if (update_type == UPDATE_TYPE_FAST) continue; @@ -1383,13 +1390,6 @@ static void commit_planes_do_stream_update(struct dc *dc, pipe_ctx->stream_res.abm->funcs->set_abm_level( pipe_ctx->stream_res.abm, stream->abm_level); } - - if (stream_update->hdr_static_metadata || - stream_update->vrr_infopacket || - stream_update->vsc_infopacket) { - resource_build_info_frame(pipe_ctx); - dc->hwss.update_info_frame(pipe_ctx); - } } } } -- cgit v1.2.3 From 72ac71a7e65260cc9a5f5e7dde5d14892d867c98 Mon Sep 17 00:00:00 2001 From: Krunoslav Kovac Date: Fri, 20 Jul 2018 15:44:08 -0400 Subject: drm/amd/display: HDR dynamic meta should be treated as stream update [Why] Recently we fixed HDR static meta using AFMT registers to be treated as fast stream update. Dynamic meta is still being treated as (full) surface update because it touches HUBP and it travels with pipe data. Here we change it to be (fast) stream update. Note, originally we also wanted to redesign here a bit, but without OS level support for true dynamic meta, it's left the same. We are simply using HW that can do dynamic meta to send HDR static meta, I still prefer keeping it in one static meta type then defining dynamic meta types to hold the same info. Once we know how OS interfaces look like, we can do proper design. [How] Move dyn meta update from update_hubp_dpp to commit_planes_do_stream_update Signed-off-by: Krunoslav Kovac Reviewed-by: Tony Cheng Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 9a947f8341bf..b5c7be1cdd81 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -1357,7 +1357,7 @@ static void commit_planes_do_stream_update(struct dc *dc, pipe_ctx->stream_res.tg, &pipe_ctx->stream->timing, pipe_ctx->stream->periodic_fn_vsync_delta); - if (stream_update->hdr_static_metadata || + if ((stream_update->hdr_static_metadata && !stream->use_dynamic_meta) || stream_update->vrr_infopacket || stream_update->vsc_infopacket) { resource_build_info_frame(pipe_ctx); -- cgit v1.2.3 From 8ab5617279507044682248f47c3afa9f753d8fe3 Mon Sep 17 00:00:00 2001 From: SivapiriyanKumarasamy Date: Thu, 26 Jul 2018 14:58:35 -0400 Subject: drm/amd/display: Program gamut remap as part of stream update Add gamut remap to dc_stream_update struct, and program if set when updating streams. Signed-off-by: SivapiriyanKumarasamy Reviewed-by: Anthony Koo Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 20 ++++++++++++++++++++ drivers/gpu/drm/amd/display/dc/dc_stream.h | 8 ++++++++ 2 files changed, 28 insertions(+) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index b5c7be1cdd81..b906b6adc5a8 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -359,6 +359,23 @@ void dc_stream_set_dither_option(struct dc_stream_state *stream, opp_program_bit_depth_reduction(pipes->stream_res.opp, ¶ms); } +bool dc_stream_set_gamut_remap(struct dc *dc, const struct dc_stream_state *stream) +{ + int i = 0; + bool ret = false; + struct pipe_ctx *pipes; + + for (i = 0; i < MAX_PIPES; i++) { + if (dc->current_state->res_ctx.pipe_ctx[i].stream == stream) { + pipes = &dc->current_state->res_ctx.pipe_ctx[i]; + dc->hwss.program_gamut_remap(pipes); + ret = true; + } + } + + return ret; +} + void dc_stream_set_static_screen_events(struct dc *dc, struct dc_stream_state **streams, int num_streams, @@ -1364,6 +1381,9 @@ static void commit_planes_do_stream_update(struct dc *dc, dc->hwss.update_info_frame(pipe_ctx); } + if (stream_update->gamut_remap) + dc_stream_set_gamut_remap(dc, stream); + /* Full fe update*/ if (update_type == UPDATE_TYPE_FAST) continue; diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h index 790beb5cb358..1479b41ec177 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_stream.h +++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h @@ -132,6 +132,11 @@ struct dc_stream_update { struct dc_info_packet *vsc_infopacket; bool *dpms_off; + + struct colorspace_transform *gamut_remap; + enum dc_color_space *output_color_space; + + }; bool dc_is_stream_unchanged( @@ -298,6 +303,9 @@ void dc_stream_set_static_screen_events(struct dc *dc, void dc_stream_set_dither_option(struct dc_stream_state *stream, enum dc_dither_option option); +bool dc_stream_set_gamut_remap(struct dc *dc, + const struct dc_stream_state *stream); + bool dc_stream_get_crtc_position(struct dc *dc, struct dc_stream_state **stream, int num_streams, -- cgit v1.2.3 From c85e6e546edd7e362693218a33a6f63217802fd3 Mon Sep 17 00:00:00 2001 From: David Francis Date: Mon, 23 Jul 2018 14:12:10 -0400 Subject: drm/amd/display: Create new i2c resource [Why] I2C code did not match dc resource model and was generally unpleasant [How] Move code into new svelte dce_i2c files, replacing various i2c objects with two structs: dce_i2c_sw and dce_i2c_hw. Fully split sw and hw code paths. Remove all redundant declarations. Use address lists to distinguish between versions. Change dce80 code to newer register access macros. Signed-off-by: David Francis Reviewed-by: Tony Cheng Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/bios/bios_parser.c | 10 +- drivers/gpu/drm/amd/display/dc/core/dc.c | 8 +- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 4 +- drivers/gpu/drm/amd/display/dc/dce/Makefile | 4 +- drivers/gpu/drm/amd/display/dc/dce/dce_i2c.c | 60 ++ drivers/gpu/drm/amd/display/dc/dce/dce_i2c.h | 71 ++ drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c | 951 +++++++++++++++++++++ drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h | 335 ++++++++ drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.c | 602 +++++++++++++ drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.h | 57 ++ .../drm/amd/display/dc/dce100/dce100_resource.c | 51 +- .../drm/amd/display/dc/dce110/dce110_resource.c | 51 +- .../drm/amd/display/dc/dce112/dce112_resource.c | 51 +- .../drm/amd/display/dc/dce120/dce120_resource.c | 65 +- .../gpu/drm/amd/display/dc/dce80/dce80_resource.c | 99 +++ .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 51 +- drivers/gpu/drm/amd/display/dc/inc/core_types.h | 3 + 17 files changed, 2448 insertions(+), 25 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_i2c.c create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_i2c.h create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.c create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.h (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c index be8a2494355a..bfa5816cfc92 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c @@ -42,7 +42,7 @@ #include "bios_parser_interface.h" #include "bios_parser_common.h" -/* TODO remove - only needed for default i2c speed */ + #include "dc.h" #define THREE_PERCENT_OF_10000 300 @@ -2671,11 +2671,9 @@ static bool i2c_read( cmd.payloads = payloads; cmd.number_of_payloads = ARRAY_SIZE(payloads); - - /* TODO route this through drm i2c_adapter */ - result = dal_i2caux_submit_i2c_command( - ddc->ctx->i2caux, - ddc, + result = dc_submit_i2c( + ddc->ctx->dc, + ddc->hw_info.ddc_channel, &cmd); } diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index b906b6adc5a8..99450293a1c5 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -54,6 +54,9 @@ #include "hubp.h" #include "dc_link_dp.h" + +#include "dce/dce_i2c.h" + #define DC_LOGGER \ dc->ctx->logger @@ -1673,9 +1676,8 @@ bool dc_submit_i2c( struct dc_link *link = dc->links[link_index]; struct ddc_service *ddc = link->ddc; - - return dal_i2caux_submit_i2c_command( - ddc->ctx->i2caux, + return dce_i2c_submit_command( + dc->res_pool, ddc->ddc_pin, cmd); } diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index 739c6654d849..6638251162b0 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c @@ -1530,8 +1530,8 @@ static bool i2c_write(struct pipe_ctx *pipe_ctx, payload.write = true; cmd.payloads = &payload; - if (dc_submit_i2c(pipe_ctx->stream->ctx->dc, - pipe_ctx->stream->sink->link->link_index, &cmd)) + if (dm_helpers_submit_i2c(pipe_ctx->stream->ctx, + pipe_ctx->stream->sink->link, &cmd)) return true; return false; diff --git a/drivers/gpu/drm/amd/display/dc/dce/Makefile b/drivers/gpu/drm/amd/display/dc/dce/Makefile index 825537bd4545..8f7f0e8b341f 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dce/Makefile @@ -28,8 +28,8 @@ DCE = dce_audio.o dce_stream_encoder.o dce_link_encoder.o dce_hwseq.o \ dce_mem_input.o dce_clock_source.o dce_scl_filters.o dce_transform.o \ -dce_clocks.o dce_opp.o dce_dmcu.o dce_abm.o dce_ipp.o dce_aux.o - +dce_clocks.o dce_opp.o dce_dmcu.o dce_abm.o dce_ipp.o dce_aux.o \ +dce_i2c.o dce_i2c_hw.o dce_i2c_sw.o AMD_DAL_DCE = $(addprefix $(AMDDALPATH)/dc/dce/,$(DCE)) diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c.c b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c.c new file mode 100644 index 000000000000..35a75398fcb4 --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c.c @@ -0,0 +1,60 @@ +/* + * Copyright 2018 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ +#include "dce_i2c.h" +#include "reg_helper.h" + +bool dce_i2c_submit_command( + struct resource_pool *pool, + struct ddc *ddc, + struct i2c_command *cmd) +{ + struct dce_i2c_hw *dce_i2c_hw; + struct dce_i2c_sw *dce_i2c_sw; + + if (!ddc) { + BREAK_TO_DEBUGGER(); + return false; + } + + if (!cmd) { + BREAK_TO_DEBUGGER(); + return false; + } + + /* The software engine is only available on dce8 */ + dce_i2c_sw = dce_i2c_acquire_i2c_sw_engine(pool, ddc); + + if (!dce_i2c_sw) { + dce_i2c_hw = acquire_i2c_hw_engine(pool, ddc); + + if (!dce_i2c_hw) + return false; + + return dce_i2c_submit_command_hw(pool, ddc, cmd, dce_i2c_hw); + } + + return dce_i2c_submit_command_sw(pool, ddc, cmd, dce_i2c_sw); + +} diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c.h b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c.h new file mode 100644 index 000000000000..d655f89578ca --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c.h @@ -0,0 +1,71 @@ +/* + * Copyright 2018 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ + +#ifndef __DCE_I2C_H__ +#define __DCE_I2C_H__ + +#include "inc/core_types.h" +#include "dce_i2c_hw.h" +#include "dce_i2c_sw.h" + +enum dce_i2c_transaction_status { + DCE_I2C_TRANSACTION_STATUS_UNKNOWN = (-1L), + DCE_I2C_TRANSACTION_STATUS_SUCCEEDED, + DCE_I2C_TRANSACTION_STATUS_FAILED_CHANNEL_BUSY, + DCE_I2C_TRANSACTION_STATUS_FAILED_TIMEOUT, + DCE_I2C_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR, + DCE_I2C_TRANSACTION_STATUS_FAILED_NACK, + DCE_I2C_TRANSACTION_STATUS_FAILED_INCOMPLETE, + DCE_I2C_TRANSACTION_STATUS_FAILED_OPERATION, + DCE_I2C_TRANSACTION_STATUS_FAILED_INVALID_OPERATION, + DCE_I2C_TRANSACTION_STATUS_FAILED_BUFFER_OVERFLOW, + DCE_I2C_TRANSACTION_STATUS_FAILED_HPD_DISCON +}; + +enum dce_i2c_transaction_operation { + DCE_I2C_TRANSACTION_READ, + DCE_I2C_TRANSACTION_WRITE +}; + +struct dce_i2c_transaction_payload { + enum dce_i2c_transaction_address_space address_space; + uint32_t address; + uint32_t length; + uint8_t *data; +}; + +struct dce_i2c_transaction_request { + enum dce_i2c_transaction_operation operation; + struct dce_i2c_transaction_payload payload; + enum dce_i2c_transaction_status status; +}; + + +bool dce_i2c_submit_command( + struct resource_pool *pool, + struct ddc *ddc, + struct i2c_command *cmd); + +#endif diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c new file mode 100644 index 000000000000..6a57c4874e6b --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c @@ -0,0 +1,951 @@ +/* + * Copyright 2018 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ +#include "dce_i2c.h" +#include "dce_i2c_hw.h" +#include "reg_helper.h" +#include "include/gpio_service_interface.h" + +#define CTX \ + dce_i2c_hw->ctx +#define REG(reg)\ + dce_i2c_hw->regs->reg + +#undef FN +#define FN(reg_name, field_name) \ + dce_i2c_hw->shifts->field_name, dce_i2c_hw->masks->field_name + + +static inline void reset_hw_engine(struct dce_i2c_hw *dce_i2c_hw) +{ + REG_UPDATE_2(DC_I2C_CONTROL, + DC_I2C_SW_STATUS_RESET, 1, + DC_I2C_SW_STATUS_RESET, 1); +} + +static bool is_hw_busy(struct dce_i2c_hw *dce_i2c_hw) +{ + uint32_t i2c_sw_status = 0; + + REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status); + if (i2c_sw_status == DC_I2C_STATUS__DC_I2C_STATUS_IDLE) + return false; + + reset_hw_engine(dce_i2c_hw); + + REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status); + return i2c_sw_status != DC_I2C_STATUS__DC_I2C_STATUS_IDLE; +} + +static void set_speed_hw_dce80( + struct dce_i2c_hw *dce_i2c_hw, + uint32_t speed) +{ + + if (speed) { + REG_UPDATE_N(SPEED, 2, + FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), dce_i2c_hw->reference_frequency / speed, + FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2); + } +} +static void set_speed_hw_dce100( + struct dce_i2c_hw *dce_i2c_hw, + uint32_t speed) +{ + + if (speed) { + if (dce_i2c_hw->masks->DC_I2C_DDC1_START_STOP_TIMING_CNTL) + REG_UPDATE_N(SPEED, 3, + FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), dce_i2c_hw->reference_frequency / speed, + FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2, + FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_START_STOP_TIMING_CNTL), speed > 50 ? 2:1); + else + REG_UPDATE_N(SPEED, 2, + FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), dce_i2c_hw->reference_frequency / speed, + FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2); + } +} +bool dce_i2c_hw_engine_acquire_engine( + struct dce_i2c_hw *dce_i2c_hw, + struct ddc *ddc) +{ + + enum gpio_result result; + uint32_t current_speed; + + result = dal_ddc_open(ddc, GPIO_MODE_HARDWARE, + GPIO_DDC_CONFIG_TYPE_MODE_I2C); + + if (result != GPIO_RESULT_OK) + return false; + + dce_i2c_hw->ddc = ddc; + + + current_speed = dce_i2c_hw->funcs->get_speed(dce_i2c_hw); + + if (current_speed) + dce_i2c_hw->original_speed = current_speed; + + return true; +} +bool dce_i2c_engine_acquire_hw( + struct dce_i2c_hw *dce_i2c_hw, + struct ddc *ddc_handle) +{ + + uint32_t counter = 0; + bool result; + + do { + result = dce_i2c_hw_engine_acquire_engine( + dce_i2c_hw, ddc_handle); + + if (result) + break; + + /* i2c_engine is busy by VBios, lets wait and retry */ + + udelay(10); + + ++counter; + } while (counter < 2); + + if (result) { + if (!dce_i2c_hw->funcs->setup_engine(dce_i2c_hw)) { + dce_i2c_hw->funcs->release_engine(dce_i2c_hw); + result = false; + } + } + + return result; +} +struct dce_i2c_hw *acquire_i2c_hw_engine( + struct resource_pool *pool, + struct ddc *ddc) +{ + + struct dce_i2c_hw *engine = NULL; + + if (!ddc) + return NULL; + + if (ddc->hw_info.hw_supported) { + enum gpio_ddc_line line = dal_ddc_get_line(ddc); + + if (line < pool->pipe_count) + engine = pool->hw_i2cs[line]; + } + + if (!engine) + return NULL; + + + if (!pool->i2c_hw_buffer_in_use && + dce_i2c_engine_acquire_hw(engine, ddc)) { + pool->i2c_hw_buffer_in_use = true; + return engine; + } + + + return NULL; +} + +static bool setup_engine_hw_dce100( + struct dce_i2c_hw *dce_i2c_hw) +{ + uint32_t i2c_setup_limit = I2C_SETUP_TIME_LIMIT_DCE; + + if (dce_i2c_hw->setup_limit != 0) + i2c_setup_limit = dce_i2c_hw->setup_limit; + /* Program pin select */ + REG_UPDATE_6(DC_I2C_CONTROL, + DC_I2C_GO, 0, + DC_I2C_SOFT_RESET, 0, + DC_I2C_SEND_RESET, 0, + DC_I2C_SW_STATUS_RESET, 1, + DC_I2C_TRANSACTION_COUNT, 0, + DC_I2C_DDC_SELECT, dce_i2c_hw->engine_id); + + /* Program time limit */ + if (dce_i2c_hw->send_reset_length == 0) { + /*pre-dcn*/ + REG_UPDATE_N(SETUP, 2, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_TIME_LIMIT), i2c_setup_limit, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_ENABLE), 1); + } + /* Program HW priority + * set to High - interrupt software I2C at any time + * Enable restart of SW I2C that was interrupted by HW + * disable queuing of software while I2C is in use by HW + */ + REG_UPDATE_2(DC_I2C_ARBITRATION, + DC_I2C_NO_QUEUED_SW_GO, 0, + DC_I2C_SW_PRIORITY, DC_I2C_ARBITRATION__DC_I2C_SW_PRIORITY_NORMAL); + + return true; +} +static bool setup_engine_hw_dce80( + struct dce_i2c_hw *dce_i2c_hw) +{ + + /* Program pin select */ + { + REG_UPDATE_6(DC_I2C_CONTROL, + DC_I2C_GO, 0, + DC_I2C_SOFT_RESET, 0, + DC_I2C_SEND_RESET, 0, + DC_I2C_SW_STATUS_RESET, 1, + DC_I2C_TRANSACTION_COUNT, 0, + DC_I2C_DDC_SELECT, dce_i2c_hw->engine_id); + } + + /* Program time limit */ + { + REG_UPDATE_2(SETUP, + DC_I2C_DDC1_TIME_LIMIT, I2C_SETUP_TIME_LIMIT_DCE, + DC_I2C_DDC1_ENABLE, 1); + } + + /* Program HW priority + * set to High - interrupt software I2C at any time + * Enable restart of SW I2C that was interrupted by HW + * disable queuing of software while I2C is in use by HW + */ + { + REG_UPDATE_2(DC_I2C_ARBITRATION, + DC_I2C_NO_QUEUED_SW_GO, 0, + DC_I2C_SW_PRIORITY, DC_I2C_ARBITRATION__DC_I2C_SW_PRIORITY_NORMAL); + } + + return true; +} + + + +static void process_channel_reply_hw_dce80( + struct dce_i2c_hw *dce_i2c_hw, + struct i2c_reply_transaction_data *reply) +{ + uint32_t length = reply->length; + uint8_t *buffer = reply->data; + + REG_SET_3(DC_I2C_DATA, 0, + DC_I2C_INDEX, length - 1, + DC_I2C_DATA_RW, 1, + DC_I2C_INDEX_WRITE, 1); + + while (length) { + /* after reading the status, + * if the I2C operation executed successfully + * (i.e. DC_I2C_STATUS_DONE = 1) then the I2C controller + * should read data bytes from I2C circular data buffer + */ + + uint32_t i2c_data; + + REG_GET(DC_I2C_DATA, DC_I2C_DATA, &i2c_data); + *buffer++ = i2c_data; + + --length; + } +} +static void process_channel_reply_hw_dce100( + struct dce_i2c_hw *dce_i2c_hw, + struct i2c_reply_transaction_data *reply) +{ + uint32_t length = reply->length; + uint8_t *buffer = reply->data; + + REG_SET_3(DC_I2C_DATA, 0, + DC_I2C_INDEX, dce_i2c_hw->buffer_used_write, + DC_I2C_DATA_RW, 1, + DC_I2C_INDEX_WRITE, 1); + + while (length) { + /* after reading the status, + * if the I2C operation executed successfully + * (i.e. DC_I2C_STATUS_DONE = 1) then the I2C controller + * should read data bytes from I2C circular data buffer + */ + + uint32_t i2c_data; + + REG_GET(DC_I2C_DATA, DC_I2C_DATA, &i2c_data); + *buffer++ = i2c_data; + + --length; + } +} +enum i2c_channel_operation_result dce_i2c_hw_engine_wait_on_operation_result( + struct dce_i2c_hw *dce_i2c_hw, + uint32_t timeout, + enum i2c_channel_operation_result expected_result) +{ + enum i2c_channel_operation_result result; + uint32_t i = 0; + + if (!timeout) + return I2C_CHANNEL_OPERATION_SUCCEEDED; + + do { + + result = dce_i2c_hw->funcs->get_channel_status( + dce_i2c_hw, NULL); + + if (result != expected_result) + break; + + udelay(1); + + ++i; + } while (i < timeout); + return result; +} +static enum i2c_channel_operation_result get_channel_status_hw( + struct dce_i2c_hw *dce_i2c_hw, + uint8_t *returned_bytes) +{ + uint32_t i2c_sw_status = 0; + uint32_t value = + REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status); + if (i2c_sw_status == DC_I2C_STATUS__DC_I2C_STATUS_USED_BY_SW) + return I2C_CHANNEL_OPERATION_ENGINE_BUSY; + else if (value & dce_i2c_hw->masks->DC_I2C_SW_STOPPED_ON_NACK) + return I2C_CHANNEL_OPERATION_NO_RESPONSE; + else if (value & dce_i2c_hw->masks->DC_I2C_SW_TIMEOUT) + return I2C_CHANNEL_OPERATION_TIMEOUT; + else if (value & dce_i2c_hw->masks->DC_I2C_SW_ABORTED) + return I2C_CHANNEL_OPERATION_FAILED; + else if (value & dce_i2c_hw->masks->DC_I2C_SW_DONE) + return I2C_CHANNEL_OPERATION_SUCCEEDED; + + /* + * this is the case when HW used for communication, I2C_SW_STATUS + * could be zero + */ + return I2C_CHANNEL_OPERATION_SUCCEEDED; +} + +static void submit_channel_request_hw( + struct dce_i2c_hw *dce_i2c_hw, + struct i2c_request_transaction_data *request) +{ + request->status = I2C_CHANNEL_OPERATION_SUCCEEDED; + + if (!dce_i2c_hw->funcs->process_transaction(dce_i2c_hw, request)) + return; + + if (dce_i2c_hw->funcs->is_hw_busy(dce_i2c_hw)) { + request->status = I2C_CHANNEL_OPERATION_ENGINE_BUSY; + return; + } + + dce_i2c_hw->funcs->execute_transaction(dce_i2c_hw); + + +} +uint32_t get_reference_clock( + struct dc_bios *bios) +{ + struct dc_firmware_info info = { { 0 } }; + + if (bios->funcs->get_firmware_info(bios, &info) != BP_RESULT_OK) + return 0; + + return info.pll_info.crystal_frequency; +} + +static void execute_transaction_hw( + struct dce_i2c_hw *dce_i2c_hw) +{ + REG_UPDATE_N(SETUP, 5, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_DATA_DRIVE_EN), 0, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_CLK_DRIVE_EN), 0, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_DATA_DRIVE_SEL), 0, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_INTRA_TRANSACTION_DELAY), 0, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_INTRA_BYTE_DELAY), 0); + + + REG_UPDATE_5(DC_I2C_CONTROL, + DC_I2C_SOFT_RESET, 0, + DC_I2C_SW_STATUS_RESET, 0, + DC_I2C_SEND_RESET, 0, + DC_I2C_GO, 0, + DC_I2C_TRANSACTION_COUNT, dce_i2c_hw->transaction_count - 1); + + /* start I2C transfer */ + REG_UPDATE(DC_I2C_CONTROL, DC_I2C_GO, 1); + + /* all transactions were executed and HW buffer became empty + * (even though it actually happens when status becomes DONE) + */ + dce_i2c_hw->transaction_count = 0; + dce_i2c_hw->buffer_used_bytes = 0; +} +static bool process_transaction_hw_dce80( + struct dce_i2c_hw *dce_i2c_hw, + struct i2c_request_transaction_data *request) +{ + uint32_t length = request->length; + uint8_t *buffer = request->data; + + bool last_transaction = false; + uint32_t value = 0; + + { + + last_transaction = ((dce_i2c_hw->transaction_count == 3) || + (request->action == DCE_I2C_TRANSACTION_ACTION_I2C_WRITE) || + (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ)); + + + switch (dce_i2c_hw->transaction_count) { + case 0: + REG_UPDATE_5(DC_I2C_TRANSACTION0, + DC_I2C_STOP_ON_NACK0, 1, + DC_I2C_START0, 1, + DC_I2C_RW0, 0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ), + DC_I2C_COUNT0, length, + DC_I2C_STOP0, last_transaction ? 1 : 0); + break; + case 1: + REG_UPDATE_5(DC_I2C_TRANSACTION1, + DC_I2C_STOP_ON_NACK0, 1, + DC_I2C_START0, 1, + DC_I2C_RW0, 0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ), + DC_I2C_COUNT0, length, + DC_I2C_STOP0, last_transaction ? 1 : 0); + break; + case 2: + REG_UPDATE_5(DC_I2C_TRANSACTION2, + DC_I2C_STOP_ON_NACK0, 1, + DC_I2C_START0, 1, + DC_I2C_RW0, 0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ), + DC_I2C_COUNT0, length, + DC_I2C_STOP0, last_transaction ? 1 : 0); + break; + case 3: + REG_UPDATE_5(DC_I2C_TRANSACTION3, + DC_I2C_STOP_ON_NACK0, 1, + DC_I2C_START0, 1, + DC_I2C_RW0, 0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ), + DC_I2C_COUNT0, length, + DC_I2C_STOP0, last_transaction ? 1 : 0); + break; + default: + /* TODO Warning ? */ + break; + } + } + + /* Write the I2C address and I2C data + * into the hardware circular buffer, one byte per entry. + * As an example, the 7-bit I2C slave address for CRT monitor + * for reading DDC/EDID information is 0b1010001. + * For an I2C send operation, the LSB must be programmed to 0; + * for I2C receive operation, the LSB must be programmed to 1. + */ + + { + if (dce_i2c_hw->transaction_count == 0) { + value = REG_SET_4(DC_I2C_DATA, 0, + DC_I2C_DATA_RW, false, + DC_I2C_DATA, request->address, + DC_I2C_INDEX, 0, + DC_I2C_INDEX_WRITE, 1); + } else + value = REG_SET_2(DC_I2C_DATA, 0, + DC_I2C_DATA_RW, false, + DC_I2C_DATA, request->address); + + if (!(request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ)) { + + while (length) { + REG_SET_2(DC_I2C_DATA, value, + DC_I2C_INDEX_WRITE, 0, + DC_I2C_DATA, *buffer++); + --length; + } + } + } + + ++dce_i2c_hw->transaction_count; + dce_i2c_hw->buffer_used_bytes += length + 1; + + return last_transaction; +} + +#define STOP_TRANS_PREDICAT \ + ((dce_i2c_hw->transaction_count == 3) || \ + (request->action == DCE_I2C_TRANSACTION_ACTION_I2C_WRITE) || \ + (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ)) + +#define SET_I2C_TRANSACTION(id) \ + do { \ + REG_UPDATE_N(DC_I2C_TRANSACTION##id, 5, \ + FN(DC_I2C_TRANSACTION0, DC_I2C_STOP_ON_NACK0), 1, \ + FN(DC_I2C_TRANSACTION0, DC_I2C_START0), 1, \ + FN(DC_I2C_TRANSACTION0, DC_I2C_STOP0), STOP_TRANS_PREDICAT ? 1:0, \ + FN(DC_I2C_TRANSACTION0, DC_I2C_RW0), (0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ)), \ + FN(DC_I2C_TRANSACTION0, DC_I2C_COUNT0), length); \ + if (STOP_TRANS_PREDICAT) \ + last_transaction = true; \ + } while (false) + +static bool process_transaction_hw_dce100( + struct dce_i2c_hw *dce_i2c_hw, + struct i2c_request_transaction_data *request) +{ + uint32_t length = request->length; + uint8_t *buffer = request->data; + uint32_t value = 0; + + bool last_transaction = false; + + switch (dce_i2c_hw->transaction_count) { + case 0: + SET_I2C_TRANSACTION(0); + break; + case 1: + SET_I2C_TRANSACTION(1); + break; + case 2: + SET_I2C_TRANSACTION(2); + break; + case 3: + SET_I2C_TRANSACTION(3); + break; + default: + /* TODO Warning ? */ + break; + } + + + /* Write the I2C address and I2C data + * into the hardware circular buffer, one byte per entry. + * As an example, the 7-bit I2C slave address for CRT monitor + * for reading DDC/EDID information is 0b1010001. + * For an I2C send operation, the LSB must be programmed to 0; + * for I2C receive operation, the LSB must be programmed to 1. + */ + if (dce_i2c_hw->transaction_count == 0) { + value = REG_SET_4(DC_I2C_DATA, 0, + DC_I2C_DATA_RW, false, + DC_I2C_DATA, request->address, + DC_I2C_INDEX, 0, + DC_I2C_INDEX_WRITE, 1); + dce_i2c_hw->buffer_used_write = 0; + } else + value = REG_SET_2(DC_I2C_DATA, 0, + DC_I2C_DATA_RW, false, + DC_I2C_DATA, request->address); + + dce_i2c_hw->buffer_used_write++; + + if (!(request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ)) { + while (length) { + REG_SET_2(DC_I2C_DATA, value, + DC_I2C_INDEX_WRITE, 0, + DC_I2C_DATA, *buffer++); + dce_i2c_hw->buffer_used_write++; + --length; + } + } + + ++dce_i2c_hw->transaction_count; + dce_i2c_hw->buffer_used_bytes += length + 1; + + return last_transaction; +} +static uint32_t get_transaction_timeout_hw( + const struct dce_i2c_hw *dce_i2c_hw, + uint32_t length) +{ + + uint32_t speed = dce_i2c_hw->funcs->get_speed(dce_i2c_hw); + + + + uint32_t period_timeout; + uint32_t num_of_clock_stretches; + + if (!speed) + return 0; + + period_timeout = (1000 * TRANSACTION_TIMEOUT_IN_I2C_CLOCKS) / speed; + + num_of_clock_stretches = 1 + (length << 3) + 1; + num_of_clock_stretches += + (dce_i2c_hw->buffer_used_bytes << 3) + + (dce_i2c_hw->transaction_count << 1); + + return period_timeout * num_of_clock_stretches; +} + +static void release_engine_dce_hw( + struct resource_pool *pool, + struct dce_i2c_hw *dce_i2c_hw) +{ + pool->i2c_hw_buffer_in_use = false; + + dce_i2c_hw->funcs->release_engine(dce_i2c_hw); + dal_ddc_close(dce_i2c_hw->ddc); + + dce_i2c_hw->ddc = NULL; +} + +static void release_engine_hw( + struct dce_i2c_hw *dce_i2c_hw) +{ + bool safe_to_reset; + + /* Restore original HW engine speed */ + + dce_i2c_hw->funcs->set_speed(dce_i2c_hw, dce_i2c_hw->original_speed); + + /* Release I2C */ + REG_UPDATE(DC_I2C_ARBITRATION, DC_I2C_SW_DONE_USING_I2C_REG, 1); + + /* Reset HW engine */ + { + uint32_t i2c_sw_status = 0; + + REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status); + /* if used by SW, safe to reset */ + safe_to_reset = (i2c_sw_status == 1); + } + + if (safe_to_reset) + REG_UPDATE_2(DC_I2C_CONTROL, + DC_I2C_SOFT_RESET, 1, + DC_I2C_SW_STATUS_RESET, 1); + else + REG_UPDATE(DC_I2C_CONTROL, DC_I2C_SW_STATUS_RESET, 1); + /* HW I2c engine - clock gating feature */ + if (!dce_i2c_hw->engine_keep_power_up_count) + dce_i2c_hw->funcs->disable_i2c_hw_engine(dce_i2c_hw); + +} + + +static void disable_i2c_hw_engine( + struct dce_i2c_hw *dce_i2c_hw) +{ + REG_UPDATE_N(SETUP, 1, FN(SETUP, DC_I2C_DDC1_ENABLE), 0); +} +static uint32_t get_speed_hw( + const struct dce_i2c_hw *dce_i2c_hw) +{ + uint32_t pre_scale = 0; + + REG_GET(SPEED, DC_I2C_DDC1_PRESCALE, &pre_scale); + + /* [anaumov] it seems following is unnecessary */ + /*ASSERT(value.bits.DC_I2C_DDC1_PRESCALE);*/ + return pre_scale ? + dce_i2c_hw->reference_frequency / pre_scale : + dce_i2c_hw->default_speed; +} +static uint32_t get_hw_buffer_available_size( + const struct dce_i2c_hw *dce_i2c_hw) +{ + return dce_i2c_hw->buffer_size - + dce_i2c_hw->buffer_used_bytes; +} +bool dce_i2c_hw_engine_submit_request( + struct dce_i2c_hw *dce_i2c_hw, + struct dce_i2c_transaction_request *dce_i2c_request, + bool middle_of_transaction) +{ + + struct i2c_request_transaction_data request; + + uint32_t transaction_timeout; + + enum i2c_channel_operation_result operation_result; + + bool result = false; + + /* We need following: + * transaction length will not exceed + * the number of free bytes in HW buffer (minus one for address) + */ + + if (dce_i2c_request->payload.length >= + get_hw_buffer_available_size(dce_i2c_hw)) { + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_BUFFER_OVERFLOW; + return false; + } + + if (dce_i2c_request->operation == DCE_I2C_TRANSACTION_READ) + request.action = middle_of_transaction ? + DCE_I2C_TRANSACTION_ACTION_I2C_READ_MOT : + DCE_I2C_TRANSACTION_ACTION_I2C_READ; + else if (dce_i2c_request->operation == DCE_I2C_TRANSACTION_WRITE) + request.action = middle_of_transaction ? + DCE_I2C_TRANSACTION_ACTION_I2C_WRITE_MOT : + DCE_I2C_TRANSACTION_ACTION_I2C_WRITE; + else { + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_INVALID_OPERATION; + /* [anaumov] in DAL2, there was no "return false" */ + return false; + } + + request.address = (uint8_t) dce_i2c_request->payload.address; + request.length = dce_i2c_request->payload.length; + request.data = dce_i2c_request->payload.data; + + /* obtain timeout value before submitting request */ + + transaction_timeout = get_transaction_timeout_hw( + dce_i2c_hw, dce_i2c_request->payload.length + 1); + + submit_channel_request_hw( + dce_i2c_hw, &request); + + if ((request.status == I2C_CHANNEL_OPERATION_FAILED) || + (request.status == I2C_CHANNEL_OPERATION_ENGINE_BUSY)) { + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_CHANNEL_BUSY; + return false; + } + + /* wait until transaction proceed */ + + operation_result = dce_i2c_hw_engine_wait_on_operation_result( + dce_i2c_hw, + transaction_timeout, + I2C_CHANNEL_OPERATION_ENGINE_BUSY); + + /* update transaction status */ + + switch (operation_result) { + case I2C_CHANNEL_OPERATION_SUCCEEDED: + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_SUCCEEDED; + result = true; + break; + case I2C_CHANNEL_OPERATION_NO_RESPONSE: + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_NACK; + break; + case I2C_CHANNEL_OPERATION_TIMEOUT: + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_TIMEOUT; + break; + case I2C_CHANNEL_OPERATION_FAILED: + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_INCOMPLETE; + break; + default: + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_OPERATION; + } + + if (result && (dce_i2c_request->operation == DCE_I2C_TRANSACTION_READ)) { + struct i2c_reply_transaction_data reply; + + reply.data = dce_i2c_request->payload.data; + reply.length = dce_i2c_request->payload.length; + + dce_i2c_hw->funcs->process_channel_reply(dce_i2c_hw, &reply); + + + } + + return result; +} + +bool dce_i2c_submit_command_hw( + struct resource_pool *pool, + struct ddc *ddc, + struct i2c_command *cmd, + struct dce_i2c_hw *dce_i2c_hw) +{ + uint8_t index_of_payload = 0; + bool result; + + dce_i2c_hw->funcs->set_speed(dce_i2c_hw, cmd->speed); + + result = true; + + while (index_of_payload < cmd->number_of_payloads) { + bool mot = (index_of_payload != cmd->number_of_payloads - 1); + + struct i2c_payload *payload = cmd->payloads + index_of_payload; + + struct dce_i2c_transaction_request request = { 0 }; + + request.operation = payload->write ? + DCE_I2C_TRANSACTION_WRITE : + DCE_I2C_TRANSACTION_READ; + + request.payload.address_space = + DCE_I2C_TRANSACTION_ADDRESS_SPACE_I2C; + request.payload.address = (payload->address << 1) | + !payload->write; + request.payload.length = payload->length; + request.payload.data = payload->data; + + + if (!dce_i2c_hw_engine_submit_request( + dce_i2c_hw, &request, mot)) { + result = false; + break; + } + + + + ++index_of_payload; + } + + release_engine_dce_hw(pool, dce_i2c_hw); + + return result; +} +static const struct dce_i2c_hw_funcs dce100_i2c_hw_funcs = { + .setup_engine = setup_engine_hw_dce100, + .set_speed = set_speed_hw_dce100, + .get_speed = get_speed_hw, + .release_engine = release_engine_hw, + .process_transaction = process_transaction_hw_dce100, + .process_channel_reply = process_channel_reply_hw_dce100, + .is_hw_busy = is_hw_busy, + .get_channel_status = get_channel_status_hw, + .execute_transaction = execute_transaction_hw, + .disable_i2c_hw_engine = disable_i2c_hw_engine +}; +static const struct dce_i2c_hw_funcs dce80_i2c_hw_funcs = { + .setup_engine = setup_engine_hw_dce80, + .set_speed = set_speed_hw_dce80, + .get_speed = get_speed_hw, + .release_engine = release_engine_hw, + .process_transaction = process_transaction_hw_dce80, + .process_channel_reply = process_channel_reply_hw_dce80, + .is_hw_busy = is_hw_busy, + .get_channel_status = get_channel_status_hw, + .execute_transaction = execute_transaction_hw, + .disable_i2c_hw_engine = disable_i2c_hw_engine +}; + + + +void dce_i2c_hw_construct( + struct dce_i2c_hw *dce_i2c_hw, + struct dc_context *ctx, + uint32_t engine_id, + const struct dce_i2c_registers *regs, + const struct dce_i2c_shift *shifts, + const struct dce_i2c_mask *masks) +{ + dce_i2c_hw->ctx = ctx; + dce_i2c_hw->engine_id = engine_id; + dce_i2c_hw->reference_frequency = get_reference_clock(ctx->dc_bios) >> 1; + dce_i2c_hw->regs = regs; + dce_i2c_hw->shifts = shifts; + dce_i2c_hw->masks = masks; + dce_i2c_hw->buffer_used_bytes = 0; + dce_i2c_hw->transaction_count = 0; + dce_i2c_hw->engine_keep_power_up_count = 1; + dce_i2c_hw->original_speed = DEFAULT_I2C_HW_SPEED; + dce_i2c_hw->default_speed = DEFAULT_I2C_HW_SPEED; + dce_i2c_hw->send_reset_length = 0; + dce_i2c_hw->setup_limit = I2C_SETUP_TIME_LIMIT_DCE; + dce_i2c_hw->funcs = &dce80_i2c_hw_funcs; + dce_i2c_hw->buffer_size = I2C_HW_BUFFER_SIZE_DCE; +} + +void dce100_i2c_hw_construct( + struct dce_i2c_hw *dce_i2c_hw, + struct dc_context *ctx, + uint32_t engine_id, + const struct dce_i2c_registers *regs, + const struct dce_i2c_shift *shifts, + const struct dce_i2c_mask *masks) +{ + + uint32_t xtal_ref_div = 0; + + dce_i2c_hw_construct(dce_i2c_hw, + ctx, + engine_id, + regs, + shifts, + masks); + dce_i2c_hw->funcs = &dce100_i2c_hw_funcs; + dce_i2c_hw->buffer_size = I2C_HW_BUFFER_SIZE_DCE100; + + REG_GET(MICROSECOND_TIME_BASE_DIV, XTAL_REF_DIV, &xtal_ref_div); + + if (xtal_ref_div == 0) + xtal_ref_div = 2; + + /*Calculating Reference Clock by divding original frequency by + * XTAL_REF_DIV. + * At upper level, uint32_t reference_frequency = + * dal_dce_i2c_get_reference_clock(as) >> 1 + * which already divided by 2. So we need x2 to get original + * reference clock from ppll_info + */ + dce_i2c_hw->reference_frequency = + (dce_i2c_hw->reference_frequency * 2) / xtal_ref_div; +} + +void dce112_i2c_hw_construct( + struct dce_i2c_hw *dce_i2c_hw, + struct dc_context *ctx, + uint32_t engine_id, + const struct dce_i2c_registers *regs, + const struct dce_i2c_shift *shifts, + const struct dce_i2c_mask *masks) +{ + dce100_i2c_hw_construct(dce_i2c_hw, + ctx, + engine_id, + regs, + shifts, + masks); + dce_i2c_hw->default_speed = DEFAULT_I2C_HW_SPEED_100KHZ; +} + +void dcn1_i2c_hw_construct( + struct dce_i2c_hw *dce_i2c_hw, + struct dc_context *ctx, + uint32_t engine_id, + const struct dce_i2c_registers *regs, + const struct dce_i2c_shift *shifts, + const struct dce_i2c_mask *masks) +{ + dce112_i2c_hw_construct(dce_i2c_hw, + ctx, + engine_id, + regs, + shifts, + masks); + dce_i2c_hw->setup_limit = I2C_SETUP_TIME_LIMIT_DCN; +} + diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h new file mode 100644 index 000000000000..8baef3916246 --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h @@ -0,0 +1,335 @@ +/* + * Copyright 2018 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ + +#ifndef __DCE_I2C_HW_H__ +#define __DCE_I2C_HW_H__ + +enum dc_i2c_status { + DC_I2C_STATUS__DC_I2C_STATUS_IDLE, + DC_I2C_STATUS__DC_I2C_STATUS_USED_BY_SW, + DC_I2C_STATUS__DC_I2C_STATUS_USED_BY_HW +}; + +enum dc_i2c_arbitration { + DC_I2C_ARBITRATION__DC_I2C_SW_PRIORITY_NORMAL, + DC_I2C_ARBITRATION__DC_I2C_SW_PRIORITY_HIGH +}; + +enum i2c_channel_operation_result { + I2C_CHANNEL_OPERATION_SUCCEEDED, + I2C_CHANNEL_OPERATION_FAILED, + I2C_CHANNEL_OPERATION_NOT_GRANTED, + I2C_CHANNEL_OPERATION_IS_BUSY, + I2C_CHANNEL_OPERATION_NO_HANDLE_PROVIDED, + I2C_CHANNEL_OPERATION_CHANNEL_IN_USE, + I2C_CHANNEL_OPERATION_CHANNEL_CLIENT_MAX_ALLOWED, + I2C_CHANNEL_OPERATION_ENGINE_BUSY, + I2C_CHANNEL_OPERATION_TIMEOUT, + I2C_CHANNEL_OPERATION_NO_RESPONSE, + I2C_CHANNEL_OPERATION_HW_REQUEST_I2C_BUS, + I2C_CHANNEL_OPERATION_WRONG_PARAMETER, + I2C_CHANNEL_OPERATION_OUT_NB_OF_RETRIES, + I2C_CHANNEL_OPERATION_NOT_STARTED +}; + + +enum dce_i2c_transaction_action { + DCE_I2C_TRANSACTION_ACTION_I2C_WRITE = 0x00, + DCE_I2C_TRANSACTION_ACTION_I2C_READ = 0x10, + DCE_I2C_TRANSACTION_ACTION_I2C_STATUS_REQUEST = 0x20, + + DCE_I2C_TRANSACTION_ACTION_I2C_WRITE_MOT = 0x40, + DCE_I2C_TRANSACTION_ACTION_I2C_READ_MOT = 0x50, + DCE_I2C_TRANSACTION_ACTION_I2C_STATUS_REQUEST_MOT = 0x60, + + DCE_I2C_TRANSACTION_ACTION_DP_WRITE = 0x80, + DCE_I2C_TRANSACTION_ACTION_DP_READ = 0x90 +}; + +enum { + I2C_SETUP_TIME_LIMIT_DCE = 255, + I2C_SETUP_TIME_LIMIT_DCN = 3, + I2C_HW_BUFFER_SIZE_DCE100 = 538, + I2C_HW_BUFFER_SIZE_DCE = 144, + I2C_SEND_RESET_LENGTH_9 = 9, + I2C_SEND_RESET_LENGTH_10 = 10, + DEFAULT_I2C_HW_SPEED = 50, + DEFAULT_I2C_HW_SPEED_100KHZ = 100, + TRANSACTION_TIMEOUT_IN_I2C_CLOCKS = 32, +}; + +#define I2C_HW_ENGINE_COMMON_REG_LIST(id)\ + SRI(SETUP, DC_I2C_DDC, id),\ + SRI(SPEED, DC_I2C_DDC, id),\ + SR(DC_I2C_ARBITRATION),\ + SR(DC_I2C_CONTROL),\ + SR(DC_I2C_SW_STATUS),\ + SR(DC_I2C_TRANSACTION0),\ + SR(DC_I2C_TRANSACTION1),\ + SR(DC_I2C_TRANSACTION2),\ + SR(DC_I2C_TRANSACTION3),\ + SR(DC_I2C_DATA),\ + SR(MICROSECOND_TIME_BASE_DIV) + +#define I2C_SF(reg_name, field_name, post_fix)\ + .field_name = reg_name ## __ ## field_name ## post_fix + +#define I2C_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh)\ + I2C_SF(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_ENABLE, mask_sh),\ + I2C_SF(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_TIME_LIMIT, mask_sh),\ + I2C_SF(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_DATA_DRIVE_EN, mask_sh),\ + I2C_SF(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_CLK_DRIVE_EN, mask_sh),\ + I2C_SF(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_DATA_DRIVE_SEL, mask_sh),\ + I2C_SF(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_INTRA_TRANSACTION_DELAY, mask_sh),\ + I2C_SF(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_INTRA_BYTE_DELAY, mask_sh),\ + I2C_SF(DC_I2C_ARBITRATION, DC_I2C_SW_DONE_USING_I2C_REG, mask_sh),\ + I2C_SF(DC_I2C_ARBITRATION, DC_I2C_NO_QUEUED_SW_GO, mask_sh),\ + I2C_SF(DC_I2C_ARBITRATION, DC_I2C_SW_PRIORITY, mask_sh),\ + I2C_SF(DC_I2C_CONTROL, DC_I2C_SOFT_RESET, mask_sh),\ + I2C_SF(DC_I2C_CONTROL, DC_I2C_SW_STATUS_RESET, mask_sh),\ + I2C_SF(DC_I2C_CONTROL, DC_I2C_GO, mask_sh),\ + I2C_SF(DC_I2C_CONTROL, DC_I2C_SEND_RESET, mask_sh),\ + I2C_SF(DC_I2C_CONTROL, DC_I2C_TRANSACTION_COUNT, mask_sh),\ + I2C_SF(DC_I2C_CONTROL, DC_I2C_DDC_SELECT, mask_sh),\ + I2C_SF(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE, mask_sh),\ + I2C_SF(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD, mask_sh),\ + I2C_SF(DC_I2C_SW_STATUS, DC_I2C_SW_STOPPED_ON_NACK, mask_sh),\ + I2C_SF(DC_I2C_SW_STATUS, DC_I2C_SW_TIMEOUT, mask_sh),\ + I2C_SF(DC_I2C_SW_STATUS, DC_I2C_SW_ABORTED, mask_sh),\ + I2C_SF(DC_I2C_SW_STATUS, DC_I2C_SW_DONE, mask_sh),\ + I2C_SF(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, mask_sh),\ + I2C_SF(DC_I2C_TRANSACTION0, DC_I2C_STOP_ON_NACK0, mask_sh),\ + I2C_SF(DC_I2C_TRANSACTION0, DC_I2C_START0, mask_sh),\ + I2C_SF(DC_I2C_TRANSACTION0, DC_I2C_RW0, mask_sh),\ + I2C_SF(DC_I2C_TRANSACTION0, DC_I2C_STOP0, mask_sh),\ + I2C_SF(DC_I2C_TRANSACTION0, DC_I2C_COUNT0, mask_sh),\ + I2C_SF(DC_I2C_DATA, DC_I2C_DATA_RW, mask_sh),\ + I2C_SF(DC_I2C_DATA, DC_I2C_DATA, mask_sh),\ + I2C_SF(DC_I2C_DATA, DC_I2C_INDEX, mask_sh),\ + I2C_SF(DC_I2C_DATA, DC_I2C_INDEX_WRITE, mask_sh),\ + I2C_SF(MICROSECOND_TIME_BASE_DIV, XTAL_REF_DIV, mask_sh) + +#define I2C_COMMON_MASK_SH_LIST_DCE110(mask_sh)\ + I2C_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh),\ + I2C_SF(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_START_STOP_TIMING_CNTL, mask_sh) + +struct dce_i2c_shift { + uint8_t DC_I2C_DDC1_ENABLE; + uint8_t DC_I2C_DDC1_TIME_LIMIT; + uint8_t DC_I2C_DDC1_DATA_DRIVE_EN; + uint8_t DC_I2C_DDC1_CLK_DRIVE_EN; + uint8_t DC_I2C_DDC1_DATA_DRIVE_SEL; + uint8_t DC_I2C_DDC1_INTRA_TRANSACTION_DELAY; + uint8_t DC_I2C_DDC1_INTRA_BYTE_DELAY; + uint8_t DC_I2C_SW_DONE_USING_I2C_REG; + uint8_t DC_I2C_NO_QUEUED_SW_GO; + uint8_t DC_I2C_SW_PRIORITY; + uint8_t DC_I2C_SOFT_RESET; + uint8_t DC_I2C_SW_STATUS_RESET; + uint8_t DC_I2C_GO; + uint8_t DC_I2C_SEND_RESET; + uint8_t DC_I2C_TRANSACTION_COUNT; + uint8_t DC_I2C_DDC_SELECT; + uint8_t DC_I2C_DDC1_PRESCALE; + uint8_t DC_I2C_DDC1_THRESHOLD; + uint8_t DC_I2C_DDC1_START_STOP_TIMING_CNTL; + uint8_t DC_I2C_SW_STOPPED_ON_NACK; + uint8_t DC_I2C_SW_TIMEOUT; + uint8_t DC_I2C_SW_ABORTED; + uint8_t DC_I2C_SW_DONE; + uint8_t DC_I2C_SW_STATUS; + uint8_t DC_I2C_STOP_ON_NACK0; + uint8_t DC_I2C_START0; + uint8_t DC_I2C_RW0; + uint8_t DC_I2C_STOP0; + uint8_t DC_I2C_COUNT0; + uint8_t DC_I2C_DATA_RW; + uint8_t DC_I2C_DATA; + uint8_t DC_I2C_INDEX; + uint8_t DC_I2C_INDEX_WRITE; + uint8_t XTAL_REF_DIV; +}; + +struct dce_i2c_mask { + uint32_t DC_I2C_DDC1_ENABLE; + uint32_t DC_I2C_DDC1_TIME_LIMIT; + uint32_t DC_I2C_DDC1_DATA_DRIVE_EN; + uint32_t DC_I2C_DDC1_CLK_DRIVE_EN; + uint32_t DC_I2C_DDC1_DATA_DRIVE_SEL; + uint32_t DC_I2C_DDC1_INTRA_TRANSACTION_DELAY; + uint32_t DC_I2C_DDC1_INTRA_BYTE_DELAY; + uint32_t DC_I2C_SW_DONE_USING_I2C_REG; + uint32_t DC_I2C_NO_QUEUED_SW_GO; + uint32_t DC_I2C_SW_PRIORITY; + uint32_t DC_I2C_SOFT_RESET; + uint32_t DC_I2C_SW_STATUS_RESET; + uint32_t DC_I2C_GO; + uint32_t DC_I2C_SEND_RESET; + uint32_t DC_I2C_TRANSACTION_COUNT; + uint32_t DC_I2C_DDC_SELECT; + uint32_t DC_I2C_DDC1_PRESCALE; + uint32_t DC_I2C_DDC1_THRESHOLD; + uint32_t DC_I2C_DDC1_START_STOP_TIMING_CNTL; + uint32_t DC_I2C_SW_STOPPED_ON_NACK; + uint32_t DC_I2C_SW_TIMEOUT; + uint32_t DC_I2C_SW_ABORTED; + uint32_t DC_I2C_SW_DONE; + uint32_t DC_I2C_SW_STATUS; + uint32_t DC_I2C_STOP_ON_NACK0; + uint32_t DC_I2C_START0; + uint32_t DC_I2C_RW0; + uint32_t DC_I2C_STOP0; + uint32_t DC_I2C_COUNT0; + uint32_t DC_I2C_DATA_RW; + uint32_t DC_I2C_DATA; + uint32_t DC_I2C_INDEX; + uint32_t DC_I2C_INDEX_WRITE; + uint32_t XTAL_REF_DIV; +}; + +struct dce_i2c_registers { + uint32_t SETUP; + uint32_t SPEED; + uint32_t DC_I2C_ARBITRATION; + uint32_t DC_I2C_CONTROL; + uint32_t DC_I2C_SW_STATUS; + uint32_t DC_I2C_TRANSACTION0; + uint32_t DC_I2C_TRANSACTION1; + uint32_t DC_I2C_TRANSACTION2; + uint32_t DC_I2C_TRANSACTION3; + uint32_t DC_I2C_DATA; + uint32_t MICROSECOND_TIME_BASE_DIV; +}; + +enum dce_i2c_transaction_address_space { + DCE_I2C_TRANSACTION_ADDRESS_SPACE_I2C = 1, + DCE_I2C_TRANSACTION_ADDRESS_SPACE_DPCD +}; + +struct i2c_request_transaction_data { + enum dce_i2c_transaction_action action; + enum i2c_channel_operation_result status; + uint8_t address; + uint32_t length; + uint8_t *data; +}; + +struct i2c_reply_transaction_data { + uint32_t length; + uint8_t *data; +}; + +struct dce_i2c_hw { + struct ddc *ddc; + uint32_t original_speed; + uint32_t engine_keep_power_up_count; + uint32_t transaction_count; + uint32_t buffer_used_bytes; + uint32_t buffer_used_write; + uint32_t reference_frequency; + uint32_t default_speed; + uint32_t engine_id; + uint32_t setup_limit; + uint32_t send_reset_length; + uint32_t buffer_size; + struct dc_context *ctx; + + const struct dce_i2c_hw_funcs *funcs; + const struct dce_i2c_registers *regs; + const struct dce_i2c_shift *shifts; + const struct dce_i2c_mask *masks; +}; + + +struct dce_i2c_hw_funcs { + bool (*setup_engine)( + struct dce_i2c_hw *dce_i2c_hw); + void (*set_speed)( + struct dce_i2c_hw *dce_i2c_hw, + uint32_t speed); + uint32_t (*get_speed)( + const struct dce_i2c_hw *dce_i2c_hw); + void (*release_engine)( + struct dce_i2c_hw *dce_i2c_hw); + bool (*process_transaction)( + struct dce_i2c_hw *dce_i2c_hw, + struct i2c_request_transaction_data *request); + void (*process_channel_reply)( + struct dce_i2c_hw *dce_i2c_hw, + struct i2c_reply_transaction_data *reply); + bool (*is_hw_busy)( + struct dce_i2c_hw *dce_i2c_hw); + enum i2c_channel_operation_result (*get_channel_status)( + struct dce_i2c_hw *dce_i2c_hw, + uint8_t *returned_bytes); + void (*execute_transaction)( + struct dce_i2c_hw *dce_i2c_hw); + void (*disable_i2c_hw_engine)( + struct dce_i2c_hw *dce_i2c_hw); +}; + +void dce_i2c_hw_construct( + struct dce_i2c_hw *dce_i2c_hw, + struct dc_context *ctx, + uint32_t engine_id, + const struct dce_i2c_registers *regs, + const struct dce_i2c_shift *shifts, + const struct dce_i2c_mask *masks); + +void dce100_i2c_hw_construct( + struct dce_i2c_hw *dce_i2c_hw, + struct dc_context *ctx, + uint32_t engine_id, + const struct dce_i2c_registers *regs, + const struct dce_i2c_shift *shifts, + const struct dce_i2c_mask *masks); + +void dce112_i2c_hw_construct( + struct dce_i2c_hw *dce_i2c_hw, + struct dc_context *ctx, + uint32_t engine_id, + const struct dce_i2c_registers *regs, + const struct dce_i2c_shift *shifts, + const struct dce_i2c_mask *masks); + +void dcn1_i2c_hw_construct( + struct dce_i2c_hw *dce_i2c_hw, + struct dc_context *ctx, + uint32_t engine_id, + const struct dce_i2c_registers *regs, + const struct dce_i2c_shift *shifts, + const struct dce_i2c_mask *masks); + +bool dce_i2c_submit_command_hw( + struct resource_pool *pool, + struct ddc *ddc, + struct i2c_command *cmd, + struct dce_i2c_hw *dce_i2c_hw); + +struct dce_i2c_hw *acquire_i2c_hw_engine( + struct resource_pool *pool, + struct ddc *ddc); + +#endif diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.c b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.c new file mode 100644 index 000000000000..ab11129ea425 --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.c @@ -0,0 +1,602 @@ +/* + * Copyright 2018 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ +#include "dce_i2c.h" +#include "dce_i2c_sw.h" +#include "include/gpio_service_interface.h" +#define SCL false +#define SDA true + +void dce_i2c_sw_construct( + struct dce_i2c_sw *dce_i2c_sw, + struct dc_context *ctx) +{ + dce_i2c_sw->ctx = ctx; +} + +static inline bool read_bit_from_ddc( + struct ddc *ddc, + bool data_nor_clock) +{ + uint32_t value = 0; + + if (data_nor_clock) + dal_gpio_get_value(ddc->pin_data, &value); + else + dal_gpio_get_value(ddc->pin_clock, &value); + + return (value != 0); +} + +static inline void write_bit_to_ddc( + struct ddc *ddc, + bool data_nor_clock, + bool bit) +{ + uint32_t value = bit ? 1 : 0; + + if (data_nor_clock) + dal_gpio_set_value(ddc->pin_data, value); + else + dal_gpio_set_value(ddc->pin_clock, value); +} + +static void release_engine_dce_sw( + struct resource_pool *pool, + struct dce_i2c_sw *dce_i2c_sw) +{ + dal_ddc_close(dce_i2c_sw->ddc); + dce_i2c_sw->ddc = NULL; +} + +enum i2c_channel_operation_result dce_i2c_sw_engine_get_channel_status( + struct dce_i2c_sw *engine, + uint8_t *returned_bytes) +{ + /* No arbitration with VBIOS is performed since DCE 6.0 */ + return I2C_CHANNEL_OPERATION_SUCCEEDED; +} +static bool get_hw_supported_ddc_line( + struct ddc *ddc, + enum gpio_ddc_line *line) +{ + enum gpio_ddc_line line_found; + + *line = GPIO_DDC_LINE_UNKNOWN; + + if (!ddc) { + BREAK_TO_DEBUGGER(); + return false; + } + + if (!ddc->hw_info.hw_supported) + return false; + + line_found = dal_ddc_get_line(ddc); + + if (line_found >= GPIO_DDC_LINE_COUNT) + return false; + + *line = line_found; + + return true; +} +static bool wait_for_scl_high_sw( + struct dc_context *ctx, + struct ddc *ddc, + uint16_t clock_delay_div_4) +{ + uint32_t scl_retry = 0; + uint32_t scl_retry_max = I2C_SW_TIMEOUT_DELAY / clock_delay_div_4; + + udelay(clock_delay_div_4); + + do { + if (read_bit_from_ddc(ddc, SCL)) + return true; + + udelay(clock_delay_div_4); + + ++scl_retry; + } while (scl_retry <= scl_retry_max); + + return false; +} +static bool write_byte_sw( + struct dc_context *ctx, + struct ddc *ddc_handle, + uint16_t clock_delay_div_4, + uint8_t byte) +{ + int32_t shift = 7; + bool ack; + + /* bits are transmitted serially, starting from MSB */ + + do { + udelay(clock_delay_div_4); + + write_bit_to_ddc(ddc_handle, SDA, (byte >> shift) & 1); + + udelay(clock_delay_div_4); + + write_bit_to_ddc(ddc_handle, SCL, true); + + if (!wait_for_scl_high_sw(ctx, ddc_handle, clock_delay_div_4)) + return false; + + write_bit_to_ddc(ddc_handle, SCL, false); + + --shift; + } while (shift >= 0); + + /* The display sends ACK by preventing the SDA from going high + * after the SCL pulse we use to send our last data bit. + * If the SDA goes high after that bit, it's a NACK + */ + + udelay(clock_delay_div_4); + + write_bit_to_ddc(ddc_handle, SDA, true); + + udelay(clock_delay_div_4); + + write_bit_to_ddc(ddc_handle, SCL, true); + + if (!wait_for_scl_high_sw(ctx, ddc_handle, clock_delay_div_4)) + return false; + + /* read ACK bit */ + + ack = !read_bit_from_ddc(ddc_handle, SDA); + + udelay(clock_delay_div_4 << 1); + + write_bit_to_ddc(ddc_handle, SCL, false); + + udelay(clock_delay_div_4 << 1); + + return ack; +} + +static bool read_byte_sw( + struct dc_context *ctx, + struct ddc *ddc_handle, + uint16_t clock_delay_div_4, + uint8_t *byte, + bool more) +{ + int32_t shift = 7; + + uint8_t data = 0; + + /* The data bits are read from MSB to LSB; + * bit is read while SCL is high + */ + + do { + write_bit_to_ddc(ddc_handle, SCL, true); + + if (!wait_for_scl_high_sw(ctx, ddc_handle, clock_delay_div_4)) + return false; + + if (read_bit_from_ddc(ddc_handle, SDA)) + data |= (1 << shift); + + write_bit_to_ddc(ddc_handle, SCL, false); + + udelay(clock_delay_div_4 << 1); + + --shift; + } while (shift >= 0); + + /* read only whole byte */ + + *byte = data; + + udelay(clock_delay_div_4); + + /* send the acknowledge bit: + * SDA low means ACK, SDA high means NACK + */ + + write_bit_to_ddc(ddc_handle, SDA, !more); + + udelay(clock_delay_div_4); + + write_bit_to_ddc(ddc_handle, SCL, true); + + if (!wait_for_scl_high_sw(ctx, ddc_handle, clock_delay_div_4)) + return false; + + write_bit_to_ddc(ddc_handle, SCL, false); + + udelay(clock_delay_div_4); + + write_bit_to_ddc(ddc_handle, SDA, true); + + udelay(clock_delay_div_4); + + return true; +} +static bool stop_sync_sw( + struct dc_context *ctx, + struct ddc *ddc_handle, + uint16_t clock_delay_div_4) +{ + uint32_t retry = 0; + + /* The I2C communications stop signal is: + * the SDA going high from low, while the SCL is high. + */ + + write_bit_to_ddc(ddc_handle, SCL, false); + + udelay(clock_delay_div_4); + + write_bit_to_ddc(ddc_handle, SDA, false); + + udelay(clock_delay_div_4); + + write_bit_to_ddc(ddc_handle, SCL, true); + + if (!wait_for_scl_high_sw(ctx, ddc_handle, clock_delay_div_4)) + return false; + + write_bit_to_ddc(ddc_handle, SDA, true); + + do { + udelay(clock_delay_div_4); + + if (read_bit_from_ddc(ddc_handle, SDA)) + return true; + + ++retry; + } while (retry <= 2); + + return false; +} +static bool i2c_write_sw( + struct dc_context *ctx, + struct ddc *ddc_handle, + uint16_t clock_delay_div_4, + uint8_t address, + uint32_t length, + const uint8_t *data) +{ + uint32_t i = 0; + + if (!write_byte_sw(ctx, ddc_handle, clock_delay_div_4, address)) + return false; + + while (i < length) { + if (!write_byte_sw(ctx, ddc_handle, clock_delay_div_4, data[i])) + return false; + ++i; + } + + return true; +} + +static bool i2c_read_sw( + struct dc_context *ctx, + struct ddc *ddc_handle, + uint16_t clock_delay_div_4, + uint8_t address, + uint32_t length, + uint8_t *data) +{ + uint32_t i = 0; + + if (!write_byte_sw(ctx, ddc_handle, clock_delay_div_4, address)) + return false; + + while (i < length) { + if (!read_byte_sw(ctx, ddc_handle, clock_delay_div_4, data + i, + i < length - 1)) + return false; + ++i; + } + + return true; +} + + + +static bool start_sync_sw( + struct dc_context *ctx, + struct ddc *ddc_handle, + uint16_t clock_delay_div_4) +{ + uint32_t retry = 0; + + /* The I2C communications start signal is: + * the SDA going low from high, while the SCL is high. + */ + + write_bit_to_ddc(ddc_handle, SCL, true); + + udelay(clock_delay_div_4); + + do { + write_bit_to_ddc(ddc_handle, SDA, true); + + if (!read_bit_from_ddc(ddc_handle, SDA)) { + ++retry; + continue; + } + + udelay(clock_delay_div_4); + + write_bit_to_ddc(ddc_handle, SCL, true); + + if (!wait_for_scl_high_sw(ctx, ddc_handle, clock_delay_div_4)) + break; + + write_bit_to_ddc(ddc_handle, SDA, false); + + udelay(clock_delay_div_4); + + write_bit_to_ddc(ddc_handle, SCL, false); + + udelay(clock_delay_div_4); + + return true; + } while (retry <= I2C_SW_RETRIES); + + return false; +} + +void dce_i2c_sw_engine_set_speed( + struct dce_i2c_sw *engine, + uint32_t speed) +{ + ASSERT(speed); + + engine->speed = speed ? speed : DCE_I2C_DEFAULT_I2C_SW_SPEED; + + engine->clock_delay = 1000 / engine->speed; + + if (engine->clock_delay < 12) + engine->clock_delay = 12; +} + +bool dce_i2c_sw_engine_acquire_engine( + struct dce_i2c_sw *engine, + struct ddc *ddc) +{ + enum gpio_result result; + + result = dal_ddc_open(ddc, GPIO_MODE_FAST_OUTPUT, + GPIO_DDC_CONFIG_TYPE_MODE_I2C); + + if (result != GPIO_RESULT_OK) + return false; + + engine->ddc = ddc; + + return true; +} +bool dce_i2c_engine_acquire_sw( + struct dce_i2c_sw *dce_i2c_sw, + struct ddc *ddc_handle) +{ + uint32_t counter = 0; + bool result; + + do { + + result = dce_i2c_sw_engine_acquire_engine( + dce_i2c_sw, ddc_handle); + + if (result) + break; + + /* i2c_engine is busy by VBios, lets wait and retry */ + + udelay(10); + + ++counter; + } while (counter < 2); + + return result; +} + + + + +void dce_i2c_sw_engine_submit_channel_request( + struct dce_i2c_sw *engine, + struct i2c_request_transaction_data *req) +{ + struct ddc *ddc = engine->ddc; + uint16_t clock_delay_div_4 = engine->clock_delay >> 2; + + /* send sync (start / repeated start) */ + + bool result = start_sync_sw(engine->ctx, ddc, clock_delay_div_4); + + /* process payload */ + + if (result) { + switch (req->action) { + case DCE_I2C_TRANSACTION_ACTION_I2C_WRITE: + case DCE_I2C_TRANSACTION_ACTION_I2C_WRITE_MOT: + result = i2c_write_sw(engine->ctx, ddc, clock_delay_div_4, + req->address, req->length, req->data); + break; + case DCE_I2C_TRANSACTION_ACTION_I2C_READ: + case DCE_I2C_TRANSACTION_ACTION_I2C_READ_MOT: + result = i2c_read_sw(engine->ctx, ddc, clock_delay_div_4, + req->address, req->length, req->data); + break; + default: + result = false; + break; + } + } + + /* send stop if not 'mot' or operation failed */ + + if (!result || + (req->action == DCE_I2C_TRANSACTION_ACTION_I2C_WRITE) || + (req->action == DCE_I2C_TRANSACTION_ACTION_I2C_READ)) + if (!stop_sync_sw(engine->ctx, ddc, clock_delay_div_4)) + result = false; + + req->status = result ? + I2C_CHANNEL_OPERATION_SUCCEEDED : + I2C_CHANNEL_OPERATION_FAILED; +} +bool dce_i2c_sw_engine_submit_request( + struct dce_i2c_sw *engine, + struct dce_i2c_transaction_request *dce_i2c_request, + bool middle_of_transaction) +{ + struct i2c_request_transaction_data request; + bool operation_succeeded = false; + + if (dce_i2c_request->operation == DCE_I2C_TRANSACTION_READ) + request.action = middle_of_transaction ? + DCE_I2C_TRANSACTION_ACTION_I2C_READ_MOT : + DCE_I2C_TRANSACTION_ACTION_I2C_READ; + else if (dce_i2c_request->operation == DCE_I2C_TRANSACTION_WRITE) + request.action = middle_of_transaction ? + DCE_I2C_TRANSACTION_ACTION_I2C_WRITE_MOT : + DCE_I2C_TRANSACTION_ACTION_I2C_WRITE; + else { + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_INVALID_OPERATION; + /* in DAL2, there was no "return false" */ + return false; + } + + request.address = (uint8_t)dce_i2c_request->payload.address; + request.length = dce_i2c_request->payload.length; + request.data = dce_i2c_request->payload.data; + + dce_i2c_sw_engine_submit_channel_request(engine, &request); + + if ((request.status == I2C_CHANNEL_OPERATION_ENGINE_BUSY) || + (request.status == I2C_CHANNEL_OPERATION_FAILED)) + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_CHANNEL_BUSY; + else { + enum i2c_channel_operation_result operation_result; + + do { + operation_result = + dce_i2c_sw_engine_get_channel_status(engine, NULL); + + switch (operation_result) { + case I2C_CHANNEL_OPERATION_SUCCEEDED: + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_SUCCEEDED; + operation_succeeded = true; + break; + case I2C_CHANNEL_OPERATION_NO_RESPONSE: + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_NACK; + break; + case I2C_CHANNEL_OPERATION_TIMEOUT: + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_TIMEOUT; + break; + case I2C_CHANNEL_OPERATION_FAILED: + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_INCOMPLETE; + break; + default: + dce_i2c_request->status = + DCE_I2C_TRANSACTION_STATUS_FAILED_OPERATION; + break; + } + } while (operation_result == I2C_CHANNEL_OPERATION_ENGINE_BUSY); + } + + return operation_succeeded; +} +bool dce_i2c_submit_command_sw( + struct resource_pool *pool, + struct ddc *ddc, + struct i2c_command *cmd, + struct dce_i2c_sw *dce_i2c_sw) +{ + uint8_t index_of_payload = 0; + bool result; + + dce_i2c_sw_engine_set_speed(dce_i2c_sw, cmd->speed); + + result = true; + + while (index_of_payload < cmd->number_of_payloads) { + bool mot = (index_of_payload != cmd->number_of_payloads - 1); + + struct i2c_payload *payload = cmd->payloads + index_of_payload; + + struct dce_i2c_transaction_request request = { 0 }; + + request.operation = payload->write ? + DCE_I2C_TRANSACTION_WRITE : + DCE_I2C_TRANSACTION_READ; + + request.payload.address_space = + DCE_I2C_TRANSACTION_ADDRESS_SPACE_I2C; + request.payload.address = (payload->address << 1) | + !payload->write; + request.payload.length = payload->length; + request.payload.data = payload->data; + + + if (!dce_i2c_sw_engine_submit_request( + dce_i2c_sw, &request, mot)) { + result = false; + break; + } + + ++index_of_payload; + } + + release_engine_dce_sw(pool, dce_i2c_sw); + + return result; +} +struct dce_i2c_sw *dce_i2c_acquire_i2c_sw_engine( + struct resource_pool *pool, + struct ddc *ddc) +{ + enum gpio_ddc_line line; + struct dce_i2c_sw *engine = NULL; + + if (get_hw_supported_ddc_line(ddc, &line)) + engine = pool->sw_i2cs[line]; + + if (!engine) + return NULL; + + if (!dce_i2c_engine_acquire_sw(engine, ddc)) + return NULL; + + return engine; +} diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.h b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.h new file mode 100644 index 000000000000..5bbcdd455614 --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.h @@ -0,0 +1,57 @@ +/* + * Copyright 2018 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ + +#ifndef __DCE_I2C_SW_H__ +#define __DCE_I2C_SW_H__ + +enum { + DCE_I2C_DEFAULT_I2C_SW_SPEED = 50, + I2C_SW_RETRIES = 10, + I2C_SW_TIMEOUT_DELAY = 3000, +}; + +struct dce_i2c_sw { + struct ddc *ddc; + struct dc_context *ctx; + uint32_t clock_delay; + uint32_t speed; +}; + +void dce_i2c_sw_construct( + struct dce_i2c_sw *dce_i2c_sw, + struct dc_context *ctx); + +bool dce_i2c_submit_command_sw( + struct resource_pool *pool, + struct ddc *ddc, + struct i2c_command *cmd, + struct dce_i2c_sw *dce_i2c_sw); + +struct dce_i2c_sw *dce_i2c_acquire_i2c_sw_engine( + struct resource_pool *pool, + struct ddc *ddc); + +#endif + diff --git a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c index 3f76e6019546..ae613b025756 100644 --- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c @@ -54,6 +54,7 @@ #include "dce/dce_dmcu.h" #include "dce/dce_aux.h" #include "dce/dce_abm.h" +#include "dce/dce_i2c.h" #ifndef mmMC_HUB_RDREQ_DMIF_LIMIT #include "gmc/gmc_8_2_d.h" @@ -602,7 +603,40 @@ struct aux_engine *dce100_aux_engine_create( return &aux_engine->base; } +#define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST(id) } + +static const struct dce_i2c_registers i2c_hw_regs[] = { + i2c_inst_regs(1), + i2c_inst_regs(2), + i2c_inst_regs(3), + i2c_inst_regs(4), + i2c_inst_regs(5), + i2c_inst_regs(6), +}; + +static const struct dce_i2c_shift i2c_shifts = { + I2C_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(__SHIFT) +}; + +static const struct dce_i2c_mask i2c_masks = { + I2C_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(_MASK) +}; + +struct dce_i2c_hw *dce100_i2c_hw_create( + struct dc_context *ctx, + uint32_t inst) +{ + struct dce_i2c_hw *dce_i2c_hw = + kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL); + + if (!dce_i2c_hw) + return NULL; + + dce100_i2c_hw_construct(dce_i2c_hw, ctx, inst, + &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks); + return dce_i2c_hw; +} struct clock_source *dce100_clock_source_create( struct dc_context *ctx, struct dc_bios *bios, @@ -658,7 +692,14 @@ static void destruct(struct dce110_resource_pool *pool) if (pool->base.engines[i] != NULL) dce110_engine_destroy(&pool->base.engines[i]); - + if (pool->base.hw_i2cs[i] != NULL) { + kfree(pool->base.hw_i2cs[i]); + pool->base.hw_i2cs[i] = NULL; + } + if (pool->base.sw_i2cs[i] != NULL) { + kfree(pool->base.sw_i2cs[i]); + pool->base.sw_i2cs[i] = NULL; + } } for (i = 0; i < pool->base.stream_enc_count; i++) { @@ -970,6 +1011,14 @@ static bool construct( "DC:failed to create aux engine!!\n"); goto res_create_fail; } + pool->base.hw_i2cs[i] = dce100_i2c_hw_create(ctx, i); + if (pool->base.hw_i2cs[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create i2c engine!!\n"); + goto res_create_fail; + } + pool->base.sw_i2cs[i] = NULL; } dc->caps.max_planes = pool->base.pipe_count; diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c index e5e9e92521e9..49c5c7037be2 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c @@ -52,6 +52,7 @@ #include "dce/dce_aux.h" #include "dce/dce_abm.h" #include "dce/dce_dmcu.h" +#include "dce/dce_i2c.h" #define DC_LOGGER \ dc->ctx->logger @@ -620,7 +621,40 @@ struct aux_engine *dce110_aux_engine_create( return &aux_engine->base; } +#define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST(id) } + +static const struct dce_i2c_registers i2c_hw_regs[] = { + i2c_inst_regs(1), + i2c_inst_regs(2), + i2c_inst_regs(3), + i2c_inst_regs(4), + i2c_inst_regs(5), + i2c_inst_regs(6), +}; + +static const struct dce_i2c_shift i2c_shifts = { + I2C_COMMON_MASK_SH_LIST_DCE110(__SHIFT) +}; + +static const struct dce_i2c_mask i2c_masks = { + I2C_COMMON_MASK_SH_LIST_DCE110(_MASK) +}; + +struct dce_i2c_hw *dce110_i2c_hw_create( + struct dc_context *ctx, + uint32_t inst) +{ + struct dce_i2c_hw *dce_i2c_hw = + kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL); + + if (!dce_i2c_hw) + return NULL; + + dce100_i2c_hw_construct(dce_i2c_hw, ctx, inst, + &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks); + return dce_i2c_hw; +} struct clock_source *dce110_clock_source_create( struct dc_context *ctx, struct dc_bios *bios, @@ -687,7 +721,14 @@ static void destruct(struct dce110_resource_pool *pool) if (pool->base.engines[i] != NULL) dce110_engine_destroy(&pool->base.engines[i]); - + if (pool->base.hw_i2cs[i] != NULL) { + kfree(pool->base.hw_i2cs[i]); + pool->base.hw_i2cs[i] = NULL; + } + if (pool->base.sw_i2cs[i] != NULL) { + kfree(pool->base.sw_i2cs[i]); + pool->base.sw_i2cs[i] = NULL; + } } for (i = 0; i < pool->base.stream_enc_count; i++) { @@ -1303,6 +1344,14 @@ static bool construct( "DC:failed to create aux engine!!\n"); goto res_create_fail; } + pool->base.hw_i2cs[i] = dce110_i2c_hw_create(ctx, i); + if (pool->base.hw_i2cs[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create i2c engine!!\n"); + goto res_create_fail; + } + pool->base.sw_i2cs[i] = NULL; } dc->fbc_compressor = dce110_compressor_create(ctx); diff --git a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c index 288129343c77..d35dc730e01c 100644 --- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c @@ -50,6 +50,7 @@ #include "dce/dce_abm.h" #include "dce/dce_dmcu.h" #include "dce/dce_aux.h" +#include "dce/dce_i2c.h" #include "reg_helper.h" @@ -620,7 +621,40 @@ struct aux_engine *dce112_aux_engine_create( return &aux_engine->base; } +#define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST(id) } + +static const struct dce_i2c_registers i2c_hw_regs[] = { + i2c_inst_regs(1), + i2c_inst_regs(2), + i2c_inst_regs(3), + i2c_inst_regs(4), + i2c_inst_regs(5), + i2c_inst_regs(6), +}; + +static const struct dce_i2c_shift i2c_shifts = { + I2C_COMMON_MASK_SH_LIST_DCE110(__SHIFT) +}; + +static const struct dce_i2c_mask i2c_masks = { + I2C_COMMON_MASK_SH_LIST_DCE110(_MASK) +}; + +struct dce_i2c_hw *dce112_i2c_hw_create( + struct dc_context *ctx, + uint32_t inst) +{ + struct dce_i2c_hw *dce_i2c_hw = + kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL); + + if (!dce_i2c_hw) + return NULL; + + dce112_i2c_hw_construct(dce_i2c_hw, ctx, inst, + &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks); + return dce_i2c_hw; +} struct clock_source *dce112_clock_source_create( struct dc_context *ctx, struct dc_bios *bios, @@ -676,7 +710,14 @@ static void destruct(struct dce110_resource_pool *pool) kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i])); pool->base.timing_generators[i] = NULL; } - + if (pool->base.hw_i2cs[i] != NULL) { + kfree(pool->base.hw_i2cs[i]); + pool->base.hw_i2cs[i] = NULL; + } + if (pool->base.sw_i2cs[i] != NULL) { + kfree(pool->base.sw_i2cs[i]); + pool->base.sw_i2cs[i] = NULL; + } } for (i = 0; i < pool->base.stream_enc_count; i++) { @@ -1252,6 +1293,14 @@ static bool construct( "DC:failed to create aux engine!!\n"); goto res_create_fail; } + pool->base.hw_i2cs[i] = dce112_i2c_hw_create(ctx, i); + if (pool->base.hw_i2cs[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create i2c engine!!\n"); + goto res_create_fail; + } + pool->base.sw_i2cs[i] = NULL; } if (!resource_construct(num_virtual_links, dc, &pool->base, diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c index d43f37d99c7d..b2fb06f37648 100644 --- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c @@ -54,6 +54,7 @@ #include "dce/dce_abm.h" #include "dce/dce_dmcu.h" #include "dce/dce_aux.h" +#include "dce/dce_i2c.h" #include "dce/dce_12_0_offset.h" #include "dce/dce_12_0_sh_mask.h" @@ -392,7 +393,40 @@ struct aux_engine *dce120_aux_engine_create( return &aux_engine->base; } +#define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST(id) } + +static const struct dce_i2c_registers i2c_hw_regs[] = { + i2c_inst_regs(1), + i2c_inst_regs(2), + i2c_inst_regs(3), + i2c_inst_regs(4), + i2c_inst_regs(5), + i2c_inst_regs(6), +}; + +static const struct dce_i2c_shift i2c_shifts = { + I2C_COMMON_MASK_SH_LIST_DCE110(__SHIFT) +}; +static const struct dce_i2c_mask i2c_masks = { + I2C_COMMON_MASK_SH_LIST_DCE110(_MASK) +}; + +struct dce_i2c_hw *dce120_i2c_hw_create( + struct dc_context *ctx, + uint32_t inst) +{ + struct dce_i2c_hw *dce_i2c_hw = + kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL); + + if (!dce_i2c_hw) + return NULL; + + dce112_i2c_hw_construct(dce_i2c_hw, ctx, inst, + &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks); + + return dce_i2c_hw; +} static const struct bios_registers bios_regs = { .BIOS_SCRATCH_6 = mmBIOS_SCRATCH_6 + NBIO_BASE(mmBIOS_SCRATCH_6_BASE_IDX) }; @@ -501,7 +535,14 @@ static void destruct(struct dce110_resource_pool *pool) if (pool->base.engines[i] != NULL) dce110_engine_destroy(&pool->base.engines[i]); - + if (pool->base.hw_i2cs[i] != NULL) { + kfree(pool->base.hw_i2cs[i]); + pool->base.hw_i2cs[i] = NULL; + } + if (pool->base.sw_i2cs[i] != NULL) { + kfree(pool->base.sw_i2cs[i]); + pool->base.sw_i2cs[i] = NULL; + } } for (i = 0; i < pool->base.audio_count; i++) { @@ -957,6 +998,7 @@ static bool construct( goto res_create_fail; } + irq_init_data.ctx = dc->ctx; pool->base.irqs = dal_irq_service_dce120_create(&irq_init_data); if (!pool->base.irqs) @@ -1021,13 +1063,20 @@ static bool construct( "DC: failed to create output pixel processor!\n"); } pool->base.engines[i] = dce120_aux_engine_create(ctx, i); - if (pool->base.engines[i] == NULL) { - BREAK_TO_DEBUGGER(); - dm_error( - "DC:failed to create aux engine!!\n"); - goto res_create_fail; - } - + if (pool->base.engines[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create aux engine!!\n"); + goto res_create_fail; + } + pool->base.hw_i2cs[i] = dce120_i2c_hw_create(ctx, i); + if (pool->base.hw_i2cs[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create i2c engine!!\n"); + goto res_create_fail; + } + pool->base.sw_i2cs[i] = NULL; /* check next valid pipe */ j++; } diff --git a/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c b/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c index 604c62969ead..4eae859e6383 100644 --- a/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c @@ -56,6 +56,7 @@ #include "dce/dce_dmcu.h" #include "dce/dce_aux.h" #include "dce/dce_abm.h" +#include "dce/dce_i2c.h" /* TODO remove this include */ #ifndef mmMC_HUB_RDREQ_DMIF_LIMIT @@ -480,7 +481,54 @@ struct aux_engine *dce80_aux_engine_create( return &aux_engine->base; } +#define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST(id) } + +static const struct dce_i2c_registers i2c_hw_regs[] = { + i2c_inst_regs(1), + i2c_inst_regs(2), + i2c_inst_regs(3), + i2c_inst_regs(4), + i2c_inst_regs(5), + i2c_inst_regs(6), +}; + +static const struct dce_i2c_shift i2c_shifts = { + I2C_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(__SHIFT) +}; + +static const struct dce_i2c_mask i2c_masks = { + I2C_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(_MASK) +}; + +struct dce_i2c_hw *dce80_i2c_hw_create( + struct dc_context *ctx, + uint32_t inst) +{ + struct dce_i2c_hw *dce_i2c_hw = + kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL); + + if (!dce_i2c_hw) + return NULL; + + dce_i2c_hw_construct(dce_i2c_hw, ctx, inst, + &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks); + return dce_i2c_hw; +} + +struct dce_i2c_sw *dce80_i2c_sw_create( + struct dc_context *ctx) +{ + struct dce_i2c_sw *dce_i2c_sw = + kzalloc(sizeof(struct dce_i2c_sw), GFP_KERNEL); + + if (!dce_i2c_sw) + return NULL; + + dce_i2c_sw_construct(dce_i2c_sw, ctx); + + return dce_i2c_sw; +} static struct stream_encoder *dce80_stream_encoder_create( enum engine_id eng_id, struct dc_context *ctx) @@ -691,6 +739,14 @@ static void destruct(struct dce110_resource_pool *pool) if (pool->base.engines[i] != NULL) dce110_engine_destroy(&pool->base.engines[i]); + if (pool->base.hw_i2cs[i] != NULL) { + kfree(pool->base.hw_i2cs[i]); + pool->base.hw_i2cs[i] = NULL; + } + if (pool->base.sw_i2cs[i] != NULL) { + kfree(pool->base.sw_i2cs[i]); + pool->base.sw_i2cs[i] = NULL; + } } for (i = 0; i < pool->base.stream_enc_count; i++) { @@ -887,6 +943,7 @@ static bool dce80_construct( BREAK_TO_DEBUGGER(); goto res_create_fail; } + if (dm_pp_get_static_clocks(ctx, &static_clk_info)) pool->base.dccg->max_clks_state = static_clk_info.max_clocks_state; @@ -943,6 +1000,20 @@ static bool dce80_construct( "DC:failed to create aux engine!!\n"); goto res_create_fail; } + pool->base.hw_i2cs[i] = dce80_i2c_hw_create(ctx, i); + if (pool->base.hw_i2cs[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create i2c engine!!\n"); + goto res_create_fail; + } + pool->base.sw_i2cs[i] = dce80_i2c_sw_create(ctx); + if (pool->base.sw_i2cs[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create sw i2c!!\n"); + goto res_create_fail; + } } dc->caps.max_planes = pool->base.pipe_count; @@ -1129,6 +1200,20 @@ static bool dce81_construct( dm_error("DC: failed to create output pixel processor!\n"); goto res_create_fail; } + pool->base.hw_i2cs[i] = dce80_i2c_hw_create(ctx, i); + if (pool->base.hw_i2cs[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create i2c engine!!\n"); + goto res_create_fail; + } + pool->base.sw_i2cs[i] = dce80_i2c_sw_create(ctx); + if (pool->base.sw_i2cs[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create sw i2c!!\n"); + goto res_create_fail; + } } dc->caps.max_planes = pool->base.pipe_count; @@ -1311,6 +1396,20 @@ static bool dce83_construct( dm_error("DC: failed to create output pixel processor!\n"); goto res_create_fail; } + pool->base.hw_i2cs[i] = dce80_i2c_hw_create(ctx, i); + if (pool->base.hw_i2cs[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create i2c engine!!\n"); + goto res_create_fail; + } + pool->base.sw_i2cs[i] = dce80_i2c_sw_create(ctx); + if (pool->base.sw_i2cs[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create sw i2c!!\n"); + goto res_create_fail; + } } dc->caps.max_planes = pool->base.pipe_count; diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c index 6b44ed3697a4..28ebad8c3ec4 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c @@ -65,6 +65,7 @@ #include "dce/dce_abm.h" #include "dce/dce_dmcu.h" #include "dce/dce_aux.h" +#include "dce/dce_i2c.h" const struct _vcs_dpi_ip_params_st dcn1_0_ip = { .rob_buffer_size_kbytes = 64, @@ -610,7 +611,40 @@ struct aux_engine *dcn10_aux_engine_create( return &aux_engine->base; } +#define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST(id) } + +static const struct dce_i2c_registers i2c_hw_regs[] = { + i2c_inst_regs(1), + i2c_inst_regs(2), + i2c_inst_regs(3), + i2c_inst_regs(4), + i2c_inst_regs(5), + i2c_inst_regs(6), +}; + +static const struct dce_i2c_shift i2c_shifts = { + I2C_COMMON_MASK_SH_LIST_DCE110(__SHIFT) +}; + +static const struct dce_i2c_mask i2c_masks = { + I2C_COMMON_MASK_SH_LIST_DCE110(_MASK) +}; + +struct dce_i2c_hw *dcn10_i2c_hw_create( + struct dc_context *ctx, + uint32_t inst) +{ + struct dce_i2c_hw *dce_i2c_hw = + kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL); + + if (!dce_i2c_hw) + return NULL; + + dcn1_i2c_hw_construct(dce_i2c_hw, ctx, inst, + &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks); + return dce_i2c_hw; +} static struct mpc *dcn10_mpc_create(struct dc_context *ctx) { struct dcn10_mpc *mpc10 = kzalloc(sizeof(struct dcn10_mpc), @@ -862,6 +896,14 @@ static void destruct(struct dcn10_resource_pool *pool) if (pool->base.engines[i] != NULL) pool->base.engines[i]->funcs->destroy_engine(&pool->base.engines[i]); + if (pool->base.hw_i2cs[i] != NULL) { + kfree(pool->base.hw_i2cs[i]); + pool->base.hw_i2cs[i] = NULL; + } + if (pool->base.sw_i2cs[i] != NULL) { + kfree(pool->base.sw_i2cs[i]); + pool->base.sw_i2cs[i] = NULL; + } } for (i = 0; i < pool->base.stream_enc_count; i++) @@ -1300,7 +1342,14 @@ static bool construct( "DC:failed to create aux engine!!\n"); goto fail; } - + pool->base.hw_i2cs[i] = dcn10_i2c_hw_create(ctx, i); + if (pool->base.hw_i2cs[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create hw i2c!!\n"); + goto fail; + } + pool->base.sw_i2cs[i] = NULL; /* check next valid pipe */ j++; } diff --git a/drivers/gpu/drm/amd/display/dc/inc/core_types.h b/drivers/gpu/drm/amd/display/dc/inc/core_types.h index c0b9ca13393b..609bff8ed72e 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/core_types.h +++ b/drivers/gpu/drm/amd/display/dc/inc/core_types.h @@ -144,6 +144,9 @@ struct resource_pool { struct mpc *mpc; struct pp_smu_funcs_rv *pp_smu; struct pp_smu_display_requirement_rv pp_smu_req; + struct dce_i2c_hw *hw_i2cs[MAX_PIPES]; + struct dce_i2c_sw *sw_i2cs[MAX_PIPES]; + bool i2c_hw_buffer_in_use; unsigned int pipe_count; unsigned int underlay_pipe_index; -- cgit v1.2.3 From eb385204b2416f88aea6e1d1cfbbf5b8dbddcaa5 Mon Sep 17 00:00:00 2001 From: SivapiriyanKumarasamy Date: Thu, 26 Jul 2018 14:58:35 -0400 Subject: drm/amd/display: Program csc matrix as part of stream update Add csc_transform struct to dc_stream_update, and program if set when updating streams Signed-off-by: SivapiriyanKumarasamy Reviewed-by: Anthony Koo Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/amd/display/dc/dc_stream.h | 4 ++++ 2 files changed, 28 insertions(+) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 99450293a1c5..32318b4e0d1e 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -379,6 +379,27 @@ bool dc_stream_set_gamut_remap(struct dc *dc, const struct dc_stream_state *stre return ret; } +bool dc_stream_program_csc_matrix(struct dc *dc, struct dc_stream_state *stream) +{ + int i = 0; + bool ret = false; + struct pipe_ctx *pipes; + + for (i = 0; i < MAX_PIPES; i++) { + if (dc->current_state->res_ctx.pipe_ctx[i].stream + == stream) { + + pipes = &dc->current_state->res_ctx.pipe_ctx[i]; + dc->hwss.program_csc_matrix(pipes, + stream->output_color_space, + stream->csc_color_matrix.matrix); + ret = true; + } + } + + return ret; +} + void dc_stream_set_static_screen_events(struct dc *dc, struct dc_stream_state **streams, int num_streams, @@ -1387,6 +1408,9 @@ static void commit_planes_do_stream_update(struct dc *dc, if (stream_update->gamut_remap) dc_stream_set_gamut_remap(dc, stream); + if (stream_update->output_csc_transform) + dc_stream_program_csc_matrix(dc, stream); + /* Full fe update*/ if (update_type == UPDATE_TYPE_FAST) continue; diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h index 1479b41ec177..4a9f7e5daccf 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_stream.h +++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h @@ -136,6 +136,7 @@ struct dc_stream_update { struct colorspace_transform *gamut_remap; enum dc_color_space *output_color_space; + struct dc_csc_transform *output_csc_transform; }; @@ -306,6 +307,9 @@ void dc_stream_set_dither_option(struct dc_stream_state *stream, bool dc_stream_set_gamut_remap(struct dc *dc, const struct dc_stream_state *stream); +bool dc_stream_program_csc_matrix(struct dc *dc, + struct dc_stream_state *stream); + bool dc_stream_get_crtc_position(struct dc *dc, struct dc_stream_state **stream, int num_streams, -- cgit v1.2.3 From d75de8ac943beef397375d96d01be15aed3fdf27 Mon Sep 17 00:00:00 2001 From: Nikola Cornij Date: Fri, 13 Jul 2018 18:19:07 -0400 Subject: drm/amd/display: Define registers for dcn10 Define register for dcn10 for future changes Signed-off-by: Nikola Cornij Reviewed-by: Tony Cheng Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h index 6b3e4ded155b..67f3e4dd95c1 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h @@ -260,6 +260,7 @@ struct dcn10_stream_enc_registers { SE_SF(DP0_DP_SEC_CNTL, DP_SEC_GSP5_ENABLE, mask_sh),\ SE_SF(DP0_DP_SEC_CNTL, DP_SEC_GSP6_ENABLE, mask_sh),\ SE_SF(DP0_DP_SEC_CNTL, DP_SEC_GSP7_ENABLE, mask_sh),\ + SE_SF(DP0_DP_SEC_CNTL2, DP_SEC_GSP7_SEND, mask_sh),\ SE_SF(DP0_DP_DB_CNTL, DP_DB_DISABLE, mask_sh),\ SE_SF(DP0_DP_MSA_COLORIMETRY, DP_MSA_MISC0, mask_sh),\ SE_SF(DP0_DP_MSA_TIMING_PARAM1, DP_MSA_HTOTAL, mask_sh),\ @@ -364,6 +365,7 @@ struct dcn10_stream_enc_registers { type DP_SEC_GSP5_ENABLE;\ type DP_SEC_GSP6_ENABLE;\ type DP_SEC_GSP7_ENABLE;\ + type DP_SEC_GSP7_SEND;\ type DP_SEC_MPG_ENABLE;\ type DP_VID_STREAM_DIS_DEFER;\ type DP_VID_STREAM_ENABLE;\ -- cgit v1.2.3 From 728098352ea493584feea20be114006c30d76bca Mon Sep 17 00:00:00 2001 From: David Francis Date: Thu, 9 Aug 2018 13:15:36 -0400 Subject: drm/amd/display: Combine dce80 and dce100 i2c hw functions [Why] There are two versions of the hw function pointers: one for dce80 and one for all other versions. These paired functions are nearly identical. dce80 and dce100 should not require different i2c access functions. [How] Combine each pair of functions into a single function. Mostly the new functions are based on the dce100 versions as those versions are newer, support more features, and were more maintained. Signed-off-by: David Francis Reviewed-by: Sun peng Li Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c | 237 ++++-------------------- 1 file changed, 40 insertions(+), 197 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c index 6a57c4874e6b..3a63e3cbb91d 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c @@ -58,18 +58,7 @@ static bool is_hw_busy(struct dce_i2c_hw *dce_i2c_hw) return i2c_sw_status != DC_I2C_STATUS__DC_I2C_STATUS_IDLE; } -static void set_speed_hw_dce80( - struct dce_i2c_hw *dce_i2c_hw, - uint32_t speed) -{ - - if (speed) { - REG_UPDATE_N(SPEED, 2, - FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), dce_i2c_hw->reference_frequency / speed, - FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2); - } -} -static void set_speed_hw_dce100( +static void set_speed( struct dce_i2c_hw *dce_i2c_hw, uint32_t speed) { @@ -86,6 +75,7 @@ static void set_speed_hw_dce100( FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2); } } + bool dce_i2c_hw_engine_acquire_engine( struct dce_i2c_hw *dce_i2c_hw, struct ddc *ddc) @@ -172,7 +162,7 @@ struct dce_i2c_hw *acquire_i2c_hw_engine( return NULL; } -static bool setup_engine_hw_dce100( +static bool setup_engine( struct dce_i2c_hw *dce_i2c_hw) { uint32_t i2c_setup_limit = I2C_SETUP_TIME_LIMIT_DCE; @@ -206,72 +196,11 @@ static bool setup_engine_hw_dce100( return true; } -static bool setup_engine_hw_dce80( - struct dce_i2c_hw *dce_i2c_hw) -{ - - /* Program pin select */ - { - REG_UPDATE_6(DC_I2C_CONTROL, - DC_I2C_GO, 0, - DC_I2C_SOFT_RESET, 0, - DC_I2C_SEND_RESET, 0, - DC_I2C_SW_STATUS_RESET, 1, - DC_I2C_TRANSACTION_COUNT, 0, - DC_I2C_DDC_SELECT, dce_i2c_hw->engine_id); - } - - /* Program time limit */ - { - REG_UPDATE_2(SETUP, - DC_I2C_DDC1_TIME_LIMIT, I2C_SETUP_TIME_LIMIT_DCE, - DC_I2C_DDC1_ENABLE, 1); - } - - /* Program HW priority - * set to High - interrupt software I2C at any time - * Enable restart of SW I2C that was interrupted by HW - * disable queuing of software while I2C is in use by HW - */ - { - REG_UPDATE_2(DC_I2C_ARBITRATION, - DC_I2C_NO_QUEUED_SW_GO, 0, - DC_I2C_SW_PRIORITY, DC_I2C_ARBITRATION__DC_I2C_SW_PRIORITY_NORMAL); - } - return true; -} -static void process_channel_reply_hw_dce80( - struct dce_i2c_hw *dce_i2c_hw, - struct i2c_reply_transaction_data *reply) -{ - uint32_t length = reply->length; - uint8_t *buffer = reply->data; - - REG_SET_3(DC_I2C_DATA, 0, - DC_I2C_INDEX, length - 1, - DC_I2C_DATA_RW, 1, - DC_I2C_INDEX_WRITE, 1); - - while (length) { - /* after reading the status, - * if the I2C operation executed successfully - * (i.e. DC_I2C_STATUS_DONE = 1) then the I2C controller - * should read data bytes from I2C circular data buffer - */ - - uint32_t i2c_data; - - REG_GET(DC_I2C_DATA, DC_I2C_DATA, &i2c_data); - *buffer++ = i2c_data; - - --length; - } -} -static void process_channel_reply_hw_dce100( +static void process_channel_reply( struct dce_i2c_hw *dce_i2c_hw, struct i2c_reply_transaction_data *reply) { @@ -404,7 +333,7 @@ static void execute_transaction_hw( dce_i2c_hw->transaction_count = 0; dce_i2c_hw->buffer_used_bytes = 0; } -static bool process_transaction_hw_dce80( +static bool process_transaction( struct dce_i2c_hw *dce_i2c_hw, struct i2c_request_transaction_data *request) { @@ -414,135 +343,49 @@ static bool process_transaction_hw_dce80( bool last_transaction = false; uint32_t value = 0; - { - - last_transaction = ((dce_i2c_hw->transaction_count == 3) || - (request->action == DCE_I2C_TRANSACTION_ACTION_I2C_WRITE) || - (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ)); + last_transaction = ((dce_i2c_hw->transaction_count == 3) || + (request->action == DCE_I2C_TRANSACTION_ACTION_I2C_WRITE) || + (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ)); - switch (dce_i2c_hw->transaction_count) { - case 0: - REG_UPDATE_5(DC_I2C_TRANSACTION0, - DC_I2C_STOP_ON_NACK0, 1, - DC_I2C_START0, 1, - DC_I2C_RW0, 0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ), - DC_I2C_COUNT0, length, - DC_I2C_STOP0, last_transaction ? 1 : 0); - break; - case 1: - REG_UPDATE_5(DC_I2C_TRANSACTION1, - DC_I2C_STOP_ON_NACK0, 1, - DC_I2C_START0, 1, - DC_I2C_RW0, 0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ), - DC_I2C_COUNT0, length, - DC_I2C_STOP0, last_transaction ? 1 : 0); - break; - case 2: - REG_UPDATE_5(DC_I2C_TRANSACTION2, - DC_I2C_STOP_ON_NACK0, 1, - DC_I2C_START0, 1, - DC_I2C_RW0, 0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ), - DC_I2C_COUNT0, length, - DC_I2C_STOP0, last_transaction ? 1 : 0); - break; - case 3: - REG_UPDATE_5(DC_I2C_TRANSACTION3, - DC_I2C_STOP_ON_NACK0, 1, - DC_I2C_START0, 1, - DC_I2C_RW0, 0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ), - DC_I2C_COUNT0, length, - DC_I2C_STOP0, last_transaction ? 1 : 0); - break; - default: - /* TODO Warning ? */ - break; - } - } - - /* Write the I2C address and I2C data - * into the hardware circular buffer, one byte per entry. - * As an example, the 7-bit I2C slave address for CRT monitor - * for reading DDC/EDID information is 0b1010001. - * For an I2C send operation, the LSB must be programmed to 0; - * for I2C receive operation, the LSB must be programmed to 1. - */ - - { - if (dce_i2c_hw->transaction_count == 0) { - value = REG_SET_4(DC_I2C_DATA, 0, - DC_I2C_DATA_RW, false, - DC_I2C_DATA, request->address, - DC_I2C_INDEX, 0, - DC_I2C_INDEX_WRITE, 1); - } else - value = REG_SET_2(DC_I2C_DATA, 0, - DC_I2C_DATA_RW, false, - DC_I2C_DATA, request->address); - - if (!(request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ)) { - - while (length) { - REG_SET_2(DC_I2C_DATA, value, - DC_I2C_INDEX_WRITE, 0, - DC_I2C_DATA, *buffer++); - --length; - } - } - } - - ++dce_i2c_hw->transaction_count; - dce_i2c_hw->buffer_used_bytes += length + 1; - - return last_transaction; -} - -#define STOP_TRANS_PREDICAT \ - ((dce_i2c_hw->transaction_count == 3) || \ - (request->action == DCE_I2C_TRANSACTION_ACTION_I2C_WRITE) || \ - (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ)) - -#define SET_I2C_TRANSACTION(id) \ - do { \ - REG_UPDATE_N(DC_I2C_TRANSACTION##id, 5, \ - FN(DC_I2C_TRANSACTION0, DC_I2C_STOP_ON_NACK0), 1, \ - FN(DC_I2C_TRANSACTION0, DC_I2C_START0), 1, \ - FN(DC_I2C_TRANSACTION0, DC_I2C_STOP0), STOP_TRANS_PREDICAT ? 1:0, \ - FN(DC_I2C_TRANSACTION0, DC_I2C_RW0), (0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ)), \ - FN(DC_I2C_TRANSACTION0, DC_I2C_COUNT0), length); \ - if (STOP_TRANS_PREDICAT) \ - last_transaction = true; \ - } while (false) - -static bool process_transaction_hw_dce100( - struct dce_i2c_hw *dce_i2c_hw, - struct i2c_request_transaction_data *request) -{ - uint32_t length = request->length; - uint8_t *buffer = request->data; - uint32_t value = 0; - - bool last_transaction = false; - switch (dce_i2c_hw->transaction_count) { case 0: - SET_I2C_TRANSACTION(0); + REG_UPDATE_5(DC_I2C_TRANSACTION0, + DC_I2C_STOP_ON_NACK0, 1, + DC_I2C_START0, 1, + DC_I2C_RW0, 0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ), + DC_I2C_COUNT0, length, + DC_I2C_STOP0, last_transaction ? 1 : 0); break; case 1: - SET_I2C_TRANSACTION(1); + REG_UPDATE_5(DC_I2C_TRANSACTION1, + DC_I2C_STOP_ON_NACK0, 1, + DC_I2C_START0, 1, + DC_I2C_RW0, 0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ), + DC_I2C_COUNT0, length, + DC_I2C_STOP0, last_transaction ? 1 : 0); break; case 2: - SET_I2C_TRANSACTION(2); + REG_UPDATE_5(DC_I2C_TRANSACTION2, + DC_I2C_STOP_ON_NACK0, 1, + DC_I2C_START0, 1, + DC_I2C_RW0, 0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ), + DC_I2C_COUNT0, length, + DC_I2C_STOP0, last_transaction ? 1 : 0); break; case 3: - SET_I2C_TRANSACTION(3); + REG_UPDATE_5(DC_I2C_TRANSACTION3, + DC_I2C_STOP_ON_NACK0, 1, + DC_I2C_START0, 1, + DC_I2C_RW0, 0 != (request->action & DCE_I2C_TRANSACTION_ACTION_I2C_READ), + DC_I2C_COUNT0, length, + DC_I2C_STOP0, last_transaction ? 1 : 0); break; default: /* TODO Warning ? */ break; } - /* Write the I2C address and I2C data * into the hardware circular buffer, one byte per entry. * As an example, the 7-bit I2C slave address for CRT monitor @@ -828,24 +671,24 @@ bool dce_i2c_submit_command_hw( return result; } static const struct dce_i2c_hw_funcs dce100_i2c_hw_funcs = { - .setup_engine = setup_engine_hw_dce100, - .set_speed = set_speed_hw_dce100, + .setup_engine = setup_engine, + .set_speed = set_speed, .get_speed = get_speed_hw, .release_engine = release_engine_hw, - .process_transaction = process_transaction_hw_dce100, - .process_channel_reply = process_channel_reply_hw_dce100, + .process_transaction = process_transaction, + .process_channel_reply = process_channel_reply, .is_hw_busy = is_hw_busy, .get_channel_status = get_channel_status_hw, .execute_transaction = execute_transaction_hw, .disable_i2c_hw_engine = disable_i2c_hw_engine }; static const struct dce_i2c_hw_funcs dce80_i2c_hw_funcs = { - .setup_engine = setup_engine_hw_dce80, - .set_speed = set_speed_hw_dce80, + .setup_engine = setup_engine, + .set_speed = set_speed, .get_speed = get_speed_hw, .release_engine = release_engine_hw, - .process_transaction = process_transaction_hw_dce80, - .process_channel_reply = process_channel_reply_hw_dce80, + .process_transaction = process_transaction, + .process_channel_reply = process_channel_reply, .is_hw_busy = is_hw_busy, .get_channel_status = get_channel_status_hw, .execute_transaction = execute_transaction_hw, -- cgit v1.2.3 From d82f99422b21c0e9d174be453d0a5062da40568e Mon Sep 17 00:00:00 2001 From: Anthony Koo Date: Tue, 21 Aug 2018 14:28:05 -0500 Subject: drm/amd/display: move edp fast boot optimization flag to stream [Why] During S4/S3 stress test it is possible to resume from S4 without calling mode set on eDP, meaning high level optimization flag is not reset. If this is followed by an S3 resume call, driver will see optimization flag is set and consume it and think backend is powered on when in fact it is not. This results in PHY being off in sequence where S4->Resume->S3->Resume->ApplyOpt->black screen. [How] Move optimization flag to stream instead of a DC flag. Signed-off-by: Anthony Koo Reviewed-by: Tony Cheng Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 4 ++-- drivers/gpu/drm/amd/display/dc/dc.h | 2 -- drivers/gpu/drm/amd/display/dc/dc_stream.h | 1 + .../amd/display/dc/dce110/dce110_hw_sequencer.c | 28 ++++++++++++++-------- 4 files changed, 21 insertions(+), 14 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index 6638251162b0..53ce2a9b7eed 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c @@ -2497,8 +2497,8 @@ void core_link_enable_stream( /* eDP lit up by bios already, no need to enable again. */ if (pipe_ctx->stream->signal == SIGNAL_TYPE_EDP && - core_dc->apply_edp_fast_boot_optimization) { - core_dc->apply_edp_fast_boot_optimization = false; + pipe_ctx->stream->apply_edp_fast_boot_optimization) { + pipe_ctx->stream->apply_edp_fast_boot_optimization = false; pipe_ctx->stream->dpms_off = false; return; } diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index 1cf4ec68e741..3564f4fe420a 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -311,8 +311,6 @@ struct dc { bool optimized_required; - bool apply_edp_fast_boot_optimization; - /* FBC compressor */ struct compressor *fbc_compressor; diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h index 4a9f7e5daccf..c5bd1fbb6982 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_stream.h +++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h @@ -102,6 +102,7 @@ struct dc_stream_state { int phy_pix_clk; enum signal_type signal; bool dpms_off; + bool apply_edp_fast_boot_optimization; struct dc_stream_status status; diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c index ce1e0f6ec3ca..dc1eed5ba996 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c @@ -1557,32 +1557,40 @@ static struct dc_link *get_link_for_edp_not_in_use( */ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context) { + int i; struct dc_link *edp_link_to_turnoff = NULL; struct dc_link *edp_link = get_link_for_edp(dc); - bool can_eDP_fast_boot_optimize = false; + bool can_edp_fast_boot_optimize = false; + bool apply_edp_fast_boot_optimization = false; if (edp_link) { /* this seems to cause blank screens on DCE8 */ if ((dc->ctx->dce_version == DCE_VERSION_8_0) || (dc->ctx->dce_version == DCE_VERSION_8_1) || (dc->ctx->dce_version == DCE_VERSION_8_3)) - can_eDP_fast_boot_optimize = false; + can_edp_fast_boot_optimize = false; else - can_eDP_fast_boot_optimize = + can_edp_fast_boot_optimize = edp_link->link_enc->funcs->is_dig_enabled(edp_link->link_enc); } - if (can_eDP_fast_boot_optimize) { + if (can_edp_fast_boot_optimize) edp_link_to_turnoff = get_link_for_edp_not_in_use(dc, context); - /* if OS doesn't light up eDP and eDP link is available, we want to disable - * If resume from S4/S5, should optimization. - */ - if (!edp_link_to_turnoff) - dc->apply_edp_fast_boot_optimization = true; + /* if OS doesn't light up eDP and eDP link is available, we want to disable + * If resume from S4/S5, should optimization. + */ + if (can_edp_fast_boot_optimize && !edp_link_to_turnoff) { + /* Find eDP stream and set optimization flag */ + for (i = 0; i < context->stream_count; i++) { + if (context->streams[i]->signal == SIGNAL_TYPE_EDP) { + context->streams[i]->apply_edp_fast_boot_optimization = true; + apply_edp_fast_boot_optimization = true; + } + } } - if (!dc->apply_edp_fast_boot_optimization) { + if (!apply_edp_fast_boot_optimization) { if (edp_link_to_turnoff) { /*turn off backlight before DP_blank and encoder powered down*/ dc->hwss.edp_backlight_control(edp_link_to_turnoff, false); -- cgit v1.2.3 From dd73043534515c1b8bf31f78f0e9945f5d95e0e6 Mon Sep 17 00:00:00 2001 From: Jun Lei Date: Wed, 8 Aug 2018 11:53:39 -0400 Subject: drm/amd/display: implement DPMS DTN test v2 [why] Existing DTN infrastructure in driver is hacky. It uses implicit log names, and also incorrect escape ID. [how] - Implement using generic DTN escape ID. - Move file logging functionality from driver to to script; driver now outputs to string/buffer - Move HWSS debug functionality to separate c file - Add debug functionalty for per-block logging as CSV - Add pretty print in python Signed-off-by: Jun Lei Reviewed-by: Tony Cheng Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dcn10/Makefile | 2 +- .../drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 2 +- .../drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h | 5 + .../display/dc/dcn10/dcn10_hw_sequencer_debug.c | 510 +++++++++++++++++++++ drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h | 1 + 5 files changed, 518 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/Makefile b/drivers/gpu/drm/amd/display/dc/dcn10/Makefile index 84f52c63d95c..032f872be89c 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dcn10/Makefile @@ -22,7 +22,7 @@ # # Makefile for DCN. -DCN10 = dcn10_resource.o dcn10_ipp.o dcn10_hw_sequencer.o \ +DCN10 = dcn10_resource.o dcn10_ipp.o dcn10_hw_sequencer.o dcn10_hw_sequencer_debug.o \ dcn10_dpp.o dcn10_opp.o dcn10_optc.o \ dcn10_hubp.o dcn10_mpc.o \ dcn10_dpp_dscl.o dcn10_dpp_cm.o dcn10_cm_common.o \ diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index 4b8bedb625b4..051f427868ca 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c @@ -71,7 +71,6 @@ void print_microsec(struct dc_context *dc_ctx, uint32_t ref_cycle) us_x10 % frac); } - static void log_mpc_crc(struct dc *dc) { struct dc_context *dc_ctx = dc->ctx; @@ -2712,6 +2711,7 @@ static const struct hw_sequencer_funcs dcn10_funcs = { .setup_stereo = dcn10_setup_stereo, .set_avmute = dce110_set_avmute, .log_hw_state = dcn10_log_hw_state, + .get_hw_state = dcn10_get_hw_state, .wait_for_mpcc_disconnect = dcn10_wait_for_mpcc_disconnect, .ready_shared_resources = ready_shared_resources, .optimize_shared_resources = optimize_shared_resources, diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h index 7139fb73e966..84d461e0ed3e 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h @@ -46,4 +46,9 @@ void dcn10_program_pipe( struct pipe_ctx *pipe_ctx, struct dc_state *context); +void dcn10_get_hw_state( + struct dc *dc, + char *pBuf, unsigned int bufSize, + unsigned int mask); + #endif /* __DC_HWSS_DCN10_H__ */ diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c new file mode 100644 index 000000000000..9288b00e49b4 --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c @@ -0,0 +1,510 @@ +/* + * Copyright 2016 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ + +#include "dm_services.h" +#include "core_types.h" +#include "resource.h" +#include "custom_float.h" +#include "dcn10_hw_sequencer.h" +#include "dce110/dce110_hw_sequencer.h" +#include "dce/dce_hwseq.h" +#include "abm.h" +#include "dmcu.h" +#include "dcn10_optc.h" +#include "dcn10/dcn10_dpp.h" +#include "dcn10/dcn10_mpc.h" +#include "timing_generator.h" +#include "opp.h" +#include "ipp.h" +#include "mpc.h" +#include "reg_helper.h" +#include "custom_float.h" +#include "dcn10_hubp.h" +#include "dcn10_hubbub.h" +#include "dcn10_cm_common.h" + +static unsigned int snprintf_count(char *pBuf, unsigned int bufSize, char *fmt, ...) +{ + unsigned int ret_vsnprintf; + unsigned int chars_printed; + + va_list args; + va_start(args, fmt); + + ret_vsnprintf = vsnprintf(pBuf, bufSize, fmt, args); + + va_end(args); + + if (ret_vsnprintf > 0) { + if (ret_vsnprintf < bufSize) + chars_printed = ret_vsnprintf; + else + chars_printed = bufSize - 1; + } else + chars_printed = 0; + + return chars_printed; +} + +static unsigned int dcn10_get_hubbub_state(struct dc *dc, char *pBuf, unsigned int bufSize) +{ + struct dc_context *dc_ctx = dc->ctx; + struct dcn_hubbub_wm wm = {0}; + int i; + + unsigned int chars_printed = 0; + unsigned int remaining_buffer = bufSize; + + const uint32_t ref_clk_mhz = dc_ctx->dc->res_pool->ref_clock_inKhz / 1000; + static const unsigned int frac = 1000; + + hubbub1_wm_read_state(dc->res_pool->hubbub, &wm); + + chars_printed = snprintf_count(pBuf, remaining_buffer, "wm_set_index,data_urgent,pte_meta_urgent,sr_enter,sr_exit,dram_clk_chanage\n"); + remaining_buffer -= chars_printed; + pBuf += chars_printed; + + for (i = 0; i < 4; i++) { + struct dcn_hubbub_wm_set *s; + + s = &wm.sets[i]; + + chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%d.%03d,%d.%03d,%d.%03d,%d.%03d,%d.%03d\n", + s->wm_set, + (s->data_urgent * frac) / ref_clk_mhz / frac, (s->data_urgent * frac) / ref_clk_mhz % frac, + (s->pte_meta_urgent * frac) / ref_clk_mhz / frac, (s->pte_meta_urgent * frac) / ref_clk_mhz % frac, + (s->sr_enter * frac) / ref_clk_mhz / frac, (s->sr_enter * frac) / ref_clk_mhz % frac, + (s->sr_exit * frac) / ref_clk_mhz / frac, (s->sr_exit * frac) / ref_clk_mhz % frac, + (s->dram_clk_chanage * frac) / ref_clk_mhz / frac, (s->dram_clk_chanage * frac) / ref_clk_mhz % frac); + remaining_buffer -= chars_printed; + pBuf += chars_printed; + } + + return bufSize - remaining_buffer; +} + +static unsigned int dcn10_get_hubp_states(struct dc *dc, char *pBuf, unsigned int bufSize) +{ + struct dc_context *dc_ctx = dc->ctx; + struct resource_pool *pool = dc->res_pool; + int i; + + unsigned int chars_printed = 0; + unsigned int remaining_buffer = bufSize; + + const uint32_t ref_clk_mhz = dc_ctx->dc->res_pool->ref_clock_inKhz / 1000; + static const unsigned int frac = 1000; + + chars_printed = snprintf_count(pBuf, remaining_buffer, "instance,format,addr_hi,width,height,rotation,mirror,sw_mode,dcc_en,blank_en,ttu_dis,underflow," + "min_ttu_vblank,qos_low_wm,qos_high_wm" + "\n"); + remaining_buffer -= chars_printed; + pBuf += chars_printed; + + for (i = 0; i < pool->pipe_count; i++) { + struct hubp *hubp = pool->hubps[i]; + struct dcn_hubp_state *s = &(TO_DCN10_HUBP(hubp)->state); + + hubp->funcs->hubp_read_state(hubp); + + if (!s->blank_en) { + chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%x,%x,%d,%d,%x,%x,%x,%x,%x,%x,%x," + "%d.%03d,%d.%03d,%d.%03d" + "\n", + hubp->inst, + s->pixel_format, + s->inuse_addr_hi, + s->viewport_width, + s->viewport_height, + s->rotation_angle, + s->h_mirror_en, + s->sw_mode, + s->dcc_en, + s->blank_en, + s->ttu_disable, + s->underflow_status, + (s->min_ttu_vblank * frac) / ref_clk_mhz / frac, (s->min_ttu_vblank * frac) / ref_clk_mhz % frac, + (s->qos_level_low_wm * frac) / ref_clk_mhz / frac, (s->qos_level_low_wm * frac) / ref_clk_mhz % frac, + (s->qos_level_high_wm * frac) / ref_clk_mhz / frac, (s->qos_level_high_wm * frac) / ref_clk_mhz % frac); + + remaining_buffer -= chars_printed; + pBuf += chars_printed; + } + } + + return bufSize - remaining_buffer; +} + +static unsigned int dcn10_get_rq_states(struct dc *dc, char *pBuf, unsigned int bufSize) +{ + struct resource_pool *pool = dc->res_pool; + int i; + + unsigned int chars_printed = 0; + unsigned int remaining_buffer = bufSize; + + chars_printed = snprintf_count(pBuf, remaining_buffer, "instance,drq_exp_m,prq_exp_m,mrq_exp_m,crq_exp_m,plane1_ba," + "luma_chunk_s,luma_min_chu_s,luma_meta_ch_s,luma_min_m_c_s,luma_dpte_gr_s,luma_mpte_gr_s,luma_swath_hei,luma_pte_row_h," + "chroma_chunk_s,chroma_min_chu_s,chroma_meta_ch_s,chroma_min_m_c_s,chroma_dpte_gr_s,chroma_mpte_gr_s,chroma_swath_hei,chroma_pte_row_h" + "\n"); + remaining_buffer -= chars_printed; + pBuf += chars_printed; + + for (i = 0; i < pool->pipe_count; i++) { + struct dcn_hubp_state *s = &(TO_DCN10_HUBP(pool->hubps[i])->state); + struct _vcs_dpi_display_rq_regs_st *rq_regs = &s->rq_regs; + + if (!s->blank_en) { + chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%x,%x,%x,%x,%x," + "%x,%x,%x,%x,%x,%x,%x,%x," + "%x,%x,%x,%x,%x,%x,%x,%x" + "\n", + pool->hubps[i]->inst, rq_regs->drq_expansion_mode, rq_regs->prq_expansion_mode, rq_regs->mrq_expansion_mode, + rq_regs->crq_expansion_mode, rq_regs->plane1_base_address, rq_regs->rq_regs_l.chunk_size, + rq_regs->rq_regs_l.min_chunk_size, rq_regs->rq_regs_l.meta_chunk_size, + rq_regs->rq_regs_l.min_meta_chunk_size, rq_regs->rq_regs_l.dpte_group_size, + rq_regs->rq_regs_l.mpte_group_size, rq_regs->rq_regs_l.swath_height, + rq_regs->rq_regs_l.pte_row_height_linear, rq_regs->rq_regs_c.chunk_size, rq_regs->rq_regs_c.min_chunk_size, + rq_regs->rq_regs_c.meta_chunk_size, rq_regs->rq_regs_c.min_meta_chunk_size, + rq_regs->rq_regs_c.dpte_group_size, rq_regs->rq_regs_c.mpte_group_size, + rq_regs->rq_regs_c.swath_height, rq_regs->rq_regs_c.pte_row_height_linear); + + remaining_buffer -= chars_printed; + pBuf += chars_printed; + } + } + + return bufSize - remaining_buffer; +} + +static unsigned int dcn10_get_dlg_states(struct dc *dc, char *pBuf, unsigned int bufSize) +{ + struct resource_pool *pool = dc->res_pool; + int i; + + unsigned int chars_printed = 0; + unsigned int remaining_buffer = bufSize; + + chars_printed = snprintf_count(pBuf, remaining_buffer, "instance,rc_hbe,dlg_vbe,min_d_y_n,rc_per_ht,rc_x_a_s," + "dst_y_a_s,dst_y_pf,dst_y_vvb,dst_y_rvb,dst_y_vfl,dst_y_rfl,rf_pix_fq," + "vratio_pf,vrat_pf_c,rc_pg_vbl,rc_pg_vbc,rc_mc_vbl,rc_mc_vbc,rc_pg_fll," + "rc_pg_flc,rc_mc_fll,rc_mc_flc,pr_nom_l,pr_nom_c,rc_pg_nl,rc_pg_nc," + "mr_nom_l,mr_nom_c,rc_mc_nl,rc_mc_nc,rc_ld_pl,rc_ld_pc,rc_ld_l," + "rc_ld_c,cha_cur0,ofst_cur1,cha_cur1,vr_af_vc0,ddrq_limt,x_rt_dlay,x_rp_dlay,x_rr_sfl" + "\n"); + remaining_buffer -= chars_printed; + pBuf += chars_printed; + + for (i = 0; i < pool->pipe_count; i++) { + struct dcn_hubp_state *s = &(TO_DCN10_HUBP(pool->hubps[i])->state); + struct _vcs_dpi_display_dlg_regs_st *dlg_regs = &s->dlg_attr; + + if (!s->blank_en) { + chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%x,%x,%x,%x," + "%x,%x,%x,%x,%x,%x,%x," + "%x,%x,%x,%x,%x,%x,%x," + "%x,%x,%x,%x,%x,%x,%x," + "%x,%x,%x,%x,%x,%x,%x," + "%x,%x,%x,%x,%x,%x,%x,%x,%x,%x" + "\n", + pool->hubps[i]->inst, dlg_regs->refcyc_h_blank_end, dlg_regs->dlg_vblank_end, dlg_regs->min_dst_y_next_start, + dlg_regs->refcyc_per_htotal, dlg_regs->refcyc_x_after_scaler, dlg_regs->dst_y_after_scaler, + dlg_regs->dst_y_prefetch, dlg_regs->dst_y_per_vm_vblank, dlg_regs->dst_y_per_row_vblank, + dlg_regs->dst_y_per_vm_flip, dlg_regs->dst_y_per_row_flip, dlg_regs->ref_freq_to_pix_freq, + dlg_regs->vratio_prefetch, dlg_regs->vratio_prefetch_c, dlg_regs->refcyc_per_pte_group_vblank_l, + dlg_regs->refcyc_per_pte_group_vblank_c, dlg_regs->refcyc_per_meta_chunk_vblank_l, + dlg_regs->refcyc_per_meta_chunk_vblank_c, dlg_regs->refcyc_per_pte_group_flip_l, + dlg_regs->refcyc_per_pte_group_flip_c, dlg_regs->refcyc_per_meta_chunk_flip_l, + dlg_regs->refcyc_per_meta_chunk_flip_c, dlg_regs->dst_y_per_pte_row_nom_l, + dlg_regs->dst_y_per_pte_row_nom_c, dlg_regs->refcyc_per_pte_group_nom_l, + dlg_regs->refcyc_per_pte_group_nom_c, dlg_regs->dst_y_per_meta_row_nom_l, + dlg_regs->dst_y_per_meta_row_nom_c, dlg_regs->refcyc_per_meta_chunk_nom_l, + dlg_regs->refcyc_per_meta_chunk_nom_c, dlg_regs->refcyc_per_line_delivery_pre_l, + dlg_regs->refcyc_per_line_delivery_pre_c, dlg_regs->refcyc_per_line_delivery_l, + dlg_regs->refcyc_per_line_delivery_c, dlg_regs->chunk_hdl_adjust_cur0, dlg_regs->dst_y_offset_cur1, + dlg_regs->chunk_hdl_adjust_cur1, dlg_regs->vready_after_vcount0, dlg_regs->dst_y_delta_drq_limit, + dlg_regs->xfc_reg_transfer_delay, dlg_regs->xfc_reg_precharge_delay, + dlg_regs->xfc_reg_remote_surface_flip_latency); + + remaining_buffer -= chars_printed; + pBuf += chars_printed; + } + } + + return bufSize - remaining_buffer; +} + +static unsigned int dcn10_get_ttu_states(struct dc *dc, char *pBuf, unsigned int bufSize) +{ + struct resource_pool *pool = dc->res_pool; + int i; + + unsigned int chars_printed = 0; + unsigned int remaining_buffer = bufSize; + + chars_printed = snprintf_count(pBuf, remaining_buffer, "instance,qos_ll_wm,qos_lh_wm,mn_ttu_vb,qos_l_flp,rc_rd_p_l,rc_rd_l,rc_rd_p_c," + "rc_rd_c,rc_rd_c0,rc_rd_pc0,rc_rd_c1,rc_rd_pc1,qos_lf_l,qos_rds_l," + "qos_lf_c,qos_rds_c,qos_lf_c0,qos_rds_c0,qos_lf_c1,qos_rds_c1" + "\n"); + remaining_buffer -= chars_printed; + pBuf += chars_printed; + + for (i = 0; i < pool->pipe_count; i++) { + struct dcn_hubp_state *s = &(TO_DCN10_HUBP(pool->hubps[i])->state); + struct _vcs_dpi_display_ttu_regs_st *ttu_regs = &s->ttu_attr; + + if (!s->blank_en) { + chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%x,%x,%x,%x,%x,%x,%x," + "%x,%x,%x,%x,%x,%x,%x," + "%x,%x,%x,%x,%x,%x" + "\n", + pool->hubps[i]->inst, ttu_regs->qos_level_low_wm, ttu_regs->qos_level_high_wm, ttu_regs->min_ttu_vblank, + ttu_regs->qos_level_flip, ttu_regs->refcyc_per_req_delivery_pre_l, ttu_regs->refcyc_per_req_delivery_l, + ttu_regs->refcyc_per_req_delivery_pre_c, ttu_regs->refcyc_per_req_delivery_c, ttu_regs->refcyc_per_req_delivery_cur0, + ttu_regs->refcyc_per_req_delivery_pre_cur0, ttu_regs->refcyc_per_req_delivery_cur1, + ttu_regs->refcyc_per_req_delivery_pre_cur1, ttu_regs->qos_level_fixed_l, ttu_regs->qos_ramp_disable_l, + ttu_regs->qos_level_fixed_c, ttu_regs->qos_ramp_disable_c, ttu_regs->qos_level_fixed_cur0, + ttu_regs->qos_ramp_disable_cur0, ttu_regs->qos_level_fixed_cur1, ttu_regs->qos_ramp_disable_cur1); + + remaining_buffer -= chars_printed; + pBuf += chars_printed; + } + } + + return bufSize - remaining_buffer; +} + +static unsigned int dcn10_get_cm_states(struct dc *dc, char *pBuf, unsigned int bufSize) +{ + struct resource_pool *pool = dc->res_pool; + int i; + + unsigned int chars_printed = 0; + unsigned int remaining_buffer = bufSize; + + chars_printed = snprintf_count(pBuf, remaining_buffer, "instance,igam_format,igam_mode,dgam_mode,rgam_mode,gamut_mode," + "c11_c12,c13_c14,c21_c22,c23_c24,c31_c32,c33_c34" + "\n"); + remaining_buffer -= chars_printed; + pBuf += chars_printed; + + for (i = 0; i < pool->pipe_count; i++) { + struct dpp *dpp = pool->dpps[i]; + struct dcn_dpp_state s = {0}; + + dpp->funcs->dpp_read_state(dpp, &s); + + if (s.is_enabled) { + chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%x,%x,%x,%x,%x," + "%08x,%08x,%08x,%08x,%08x,%08x" + "\n", + dpp->inst, s.igam_input_format, s.igam_lut_mode, s.dgam_lut_mode, + s.rgam_lut_mode, s.gamut_remap_mode, s.gamut_remap_c11_c12, + s.gamut_remap_c13_c14, s.gamut_remap_c21_c22, s.gamut_remap_c23_c24, + s.gamut_remap_c31_c32, s.gamut_remap_c33_c34); + + remaining_buffer -= chars_printed; + pBuf += chars_printed; + } + } + + return bufSize - remaining_buffer; +} + +static unsigned int dcn10_get_mpcc_states(struct dc *dc, char *pBuf, unsigned int bufSize) +{ + struct resource_pool *pool = dc->res_pool; + int i; + + unsigned int chars_printed = 0; + unsigned int remaining_buffer = bufSize; + + chars_printed = snprintf_count(pBuf, remaining_buffer, "instance,opp,dpp,mpccbot,mode,alpha_mode,premult,overlap_only,idle\n"); + remaining_buffer -= chars_printed; + pBuf += chars_printed; + + for (i = 0; i < pool->pipe_count; i++) { + struct mpcc_state s = {0}; + + pool->mpc->funcs->read_mpcc_state(pool->mpc, i, &s); + + if (s.opp_id != 0xf) { + chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%x,%x,%x,%x,%x,%x,%x,%x\n", + i, s.opp_id, s.dpp_id, s.bot_mpcc_id, + s.mode, s.alpha_mode, s.pre_multiplied_alpha, s.overlap_only, + s.idle); + + remaining_buffer -= chars_printed; + pBuf += chars_printed; + } + } + + return bufSize - remaining_buffer; +} + +static unsigned int dcn10_get_otg_states(struct dc *dc, char *pBuf, unsigned int bufSize) +{ + struct resource_pool *pool = dc->res_pool; + int i; + + unsigned int chars_printed = 0; + unsigned int remaining_buffer = bufSize; + + chars_printed = snprintf_count(pBuf, remaining_buffer, "instance,v_bs,v_be,v_ss,v_se,vpol,vmax,vmin,vmax_sel,vmin_sel," + "h_bs,h_be,h_ss,h_se,hpol,htot,vtot,underflow\n"); + remaining_buffer -= chars_printed; + pBuf += chars_printed; + + for (i = 0; i < pool->timing_generator_count; i++) { + struct timing_generator *tg = pool->timing_generators[i]; + struct dcn_otg_state s = {0}; + + optc1_read_otg_state(DCN10TG_FROM_TG(tg), &s); + + //only print if OTG master is enabled + if (s.otg_enabled & 1) { + chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%d,%d,%d,%d,%d,%d,%d,%d,%d," + "%d,%d,%d,%d,%d,%d,%d,%d" + "\n", + tg->inst, + s.v_blank_start, + s.v_blank_end, + s.v_sync_a_start, + s.v_sync_a_end, + s.v_sync_a_pol, + s.v_total_max, + s.v_total_min, + s.v_total_max_sel, + s.v_total_min_sel, + s.h_blank_start, + s.h_blank_end, + s.h_sync_a_start, + s.h_sync_a_end, + s.h_sync_a_pol, + s.h_total, + s.v_total, + s.underflow_occurred_status); + + remaining_buffer -= chars_printed; + pBuf += chars_printed; + + // Clear underflow for debug purposes + // We want to keep underflow sticky bit on for the longevity tests outside of test environment. + // This function is called only from Windows or Diags test environment, hence it's safe to clear + // it from here without affecting the original intent. + tg->funcs->clear_optc_underflow(tg); + } + } + + return bufSize - remaining_buffer; +} + +static unsigned int dcn10_get_clock_states(struct dc *dc, char *pBuf, unsigned int bufSize) +{ + unsigned int chars_printed = 0; + + chars_printed = snprintf_count(pBuf, bufSize, "dcfclk_khz,dcfclk_deep_sleep_khz,dispclk_khz," + "dppclk_khz,max_supported_dppclk_khz,fclk_khz,socclk_khz\n" + "%d,%d,%d,%d,%d,%d,%d\n", + dc->current_state->bw.dcn.clk.dcfclk_khz, + dc->current_state->bw.dcn.clk.dcfclk_deep_sleep_khz, + dc->current_state->bw.dcn.clk.dispclk_khz, + dc->current_state->bw.dcn.clk.dppclk_khz, + dc->current_state->bw.dcn.clk.max_supported_dppclk_khz, + dc->current_state->bw.dcn.clk.fclk_khz, + dc->current_state->bw.dcn.clk.socclk_khz); + + return chars_printed; +} + +void dcn10_get_hw_state(struct dc *dc, char *pBuf, unsigned int bufSize, unsigned int mask) +{ + const unsigned int DC_HW_STATE_MASK_HUBBUB = 0x1; + const unsigned int DC_HW_STATE_MASK_HUBP = 0x2; + const unsigned int DC_HW_STATE_MASK_RQ = 0x4; + const unsigned int DC_HW_STATE_MASK_DLG = 0x8; + const unsigned int DC_HW_STATE_MASK_TTU = 0x10; + const unsigned int DC_HW_STATE_MASK_CM = 0x20; + const unsigned int DC_HW_STATE_MASK_MPCC = 0x40; + const unsigned int DC_HW_STATE_MASK_OTG = 0x80; + const unsigned int DC_HW_STATE_MASK_CLOCKS = 0x100; + + unsigned int chars_printed = 0; + unsigned int remaining_buf_size = bufSize; + + if (mask == 0x0) + mask = 0xFFFF; + + if ((mask & DC_HW_STATE_MASK_HUBBUB) && remaining_buf_size > 0) { + chars_printed = dcn10_get_hubbub_state(dc, pBuf, remaining_buf_size); + pBuf += chars_printed; + remaining_buf_size -= chars_printed; + } + + if ((mask & DC_HW_STATE_MASK_HUBP) && remaining_buf_size > 0) { + chars_printed = dcn10_get_hubp_states(dc, pBuf, remaining_buf_size); + pBuf += chars_printed; + remaining_buf_size -= chars_printed; + } + + if ((mask & DC_HW_STATE_MASK_RQ) && remaining_buf_size > 0) { + chars_printed = dcn10_get_rq_states(dc, pBuf, remaining_buf_size); + pBuf += chars_printed; + remaining_buf_size -= chars_printed; + } + + if ((mask & DC_HW_STATE_MASK_DLG) && remaining_buf_size > 0) { + chars_printed = dcn10_get_dlg_states(dc, pBuf, remaining_buf_size); + pBuf += chars_printed; + remaining_buf_size -= chars_printed; + } + + if ((mask & DC_HW_STATE_MASK_TTU) && remaining_buf_size > 0) { + chars_printed = dcn10_get_ttu_states(dc, pBuf, remaining_buf_size); + pBuf += chars_printed; + remaining_buf_size -= chars_printed; + } + + if ((mask & DC_HW_STATE_MASK_CM) && remaining_buf_size > 0) { + chars_printed = dcn10_get_cm_states(dc, pBuf, remaining_buf_size); + pBuf += chars_printed; + remaining_buf_size -= chars_printed; + } + + if ((mask & DC_HW_STATE_MASK_MPCC) && remaining_buf_size > 0) { + chars_printed = dcn10_get_mpcc_states(dc, pBuf, remaining_buf_size); + pBuf += chars_printed; + remaining_buf_size -= chars_printed; + } + + if ((mask & DC_HW_STATE_MASK_OTG) && remaining_buf_size > 0) { + chars_printed = dcn10_get_otg_states(dc, pBuf, remaining_buf_size); + pBuf += chars_printed; + remaining_buf_size -= chars_printed; + } + + if ((mask & DC_HW_STATE_MASK_CLOCKS) && remaining_buf_size > 0) + chars_printed = dcn10_get_clock_states(dc, pBuf, remaining_buf_size); +} diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h index a14ce4de80b2..9a97356923e2 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h @@ -203,6 +203,7 @@ struct hw_sequencer_funcs { void (*set_avmute)(struct pipe_ctx *pipe_ctx, bool enable); void (*log_hw_state)(struct dc *dc); + void (*get_hw_state)(struct dc *dc, char *pBuf, unsigned int bufSize, unsigned int mask); void (*wait_for_mpcc_disconnect)(struct dc *dc, struct resource_pool *res_pool, -- cgit v1.2.3 From 35fb7220742b80dadd7218448b4bee5b190c9f07 Mon Sep 17 00:00:00 2001 From: Wen Yang Date: Fri, 17 Aug 2018 11:09:48 +0800 Subject: drm/amd/display: fix a compile warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix comile warning like, CC [M] drivers/gpu/drm/i915/gvt/execlist.o CC [M] drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.o CC [M] drivers/gpu/drm/radeon/btc_dpm.o CC [M] drivers/isdn/hisax/avm_a1p.o CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_dpp.o drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_hw_sequencer.c: In function ‘dcn10_update_mpcc’: drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_hw_sequencer.c:1903:9: warning: missing braces around initializer [-Wmissing-braces] struct mpcc_blnd_cfg blnd_cfg = {0}; ^ drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_hw_sequencer.c:1903:9: warning: (near initialization for ‘blnd_cfg.black_color’) [-Wmissing-braces] Acked-by: Randy Dunlap Signed-off-by: Wen Yang Reviewed-by: Jiang Biao Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index 051f427868ca..1c5bb148efb7 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c @@ -1917,7 +1917,7 @@ static void update_dpp(struct dpp *dpp, struct dc_plane_state *plane_state) static void dcn10_update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx) { struct hubp *hubp = pipe_ctx->plane_res.hubp; - struct mpcc_blnd_cfg blnd_cfg = {0}; + struct mpcc_blnd_cfg blnd_cfg = {{0}}; bool per_pixel_alpha = pipe_ctx->plane_state->per_pixel_alpha && pipe_ctx->bottom_pipe; int mpcc_id; struct mpcc *new_mpcc; -- cgit v1.2.3 From 43fbbe89f15b297e269388dee63901715e55d712 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 14 Aug 2018 12:09:45 +0300 Subject: drm/amd/display: indent an if statement The if statement isn't indented and it makes static checkers complain. Signed-off-by: Dan Carpenter Reviewed-by: Harry Wentland Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index 07a1dd41666d..f85fa7b55efb 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -367,7 +367,7 @@ static bool is_dp_and_hdmi_sharable( if (stream1->clamping.c_depth != COLOR_DEPTH_888 || stream2->clamping.c_depth != COLOR_DEPTH_888) - return false; + return false; return true; -- cgit v1.2.3 From 11c3ee48bd7c232c0a750b4dde8ee48f315dcdf3 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Tue, 14 Aug 2018 14:53:52 -0500 Subject: drm/amdgpu/display: add support for LVDS (v5) This adds support for LVDS displays. v2: add support for spread spectrum, sink detect v3: clean up enable_lvds_output v4: fix up link_detect v5: remove assert on 888 format Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105880 Reviewed-by: Harry Wentland Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 45 ++++++++++++++++++++++ .../gpu/drm/amd/display/dc/dce/dce_clock_source.c | 10 +++++ .../gpu/drm/amd/display/dc/dce/dce_clock_source.h | 2 + .../gpu/drm/amd/display/dc/dce/dce_link_encoder.c | 34 ++++++++++++++++ .../gpu/drm/amd/display/dc/dce/dce_link_encoder.h | 6 +++ .../drm/amd/display/dc/dce/dce_stream_encoder.c | 24 ++++++++++++ .../gpu/drm/amd/display/dc/inc/hw/link_encoder.h | 3 ++ .../gpu/drm/amd/display/dc/inc/hw/stream_encoder.h | 4 ++ 8 files changed, 128 insertions(+) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index 53ce2a9b7eed..309059871706 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c @@ -203,6 +203,11 @@ static bool detect_sink(struct dc_link *link, enum dc_connection_type *type) uint32_t is_hpd_high = 0; struct gpio *hpd_pin; + if (link->connector_signal == SIGNAL_TYPE_LVDS) { + *type = dc_connection_single; + return true; + } + /* todo: may need to lock gpio access */ hpd_pin = get_hpd_gpio(link->ctx->dc_bios, link->link_id, link->ctx->gpio_service); if (hpd_pin == NULL) @@ -616,6 +621,10 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) link->local_sink) return true; + if (link->connector_signal == SIGNAL_TYPE_LVDS && + link->local_sink) + return true; + prev_sink = link->local_sink; if (prev_sink != NULL) { dc_sink_retain(prev_sink); @@ -649,6 +658,12 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) break; } + case SIGNAL_TYPE_LVDS: { + sink_caps.transaction_type = DDC_TRANSACTION_TYPE_I2C; + sink_caps.signal = SIGNAL_TYPE_LVDS; + break; + } + case SIGNAL_TYPE_EDP: { detect_edp_sink_caps(link); sink_caps.transaction_type = @@ -1087,6 +1102,9 @@ static bool construct( dal_irq_get_rx_source(hpd_gpio); } break; + case CONNECTOR_ID_LVDS: + link->connector_signal = SIGNAL_TYPE_LVDS; + break; default: DC_LOG_WARNING("Unsupported Connector type:%d!\n", link->link_id.id); goto create_fail; @@ -1920,6 +1938,24 @@ static void enable_link_hdmi(struct pipe_ctx *pipe_ctx) dal_ddc_service_read_scdc_data(link->ddc); } +static void enable_link_lvds(struct pipe_ctx *pipe_ctx) +{ + struct dc_stream_state *stream = pipe_ctx->stream; + struct dc_link *link = stream->sink->link; + + if (stream->phy_pix_clk == 0) + stream->phy_pix_clk = stream->timing.pix_clk_khz; + + memset(&stream->sink->link->cur_link_settings, 0, + sizeof(struct dc_link_settings)); + + link->link_enc->funcs->enable_lvds_output( + link->link_enc, + pipe_ctx->clock_source->id, + stream->phy_pix_clk); + +} + /****************************enable_link***********************************/ static enum dc_status enable_link( struct dc_state *state, @@ -1943,6 +1979,10 @@ static enum dc_status enable_link( enable_link_hdmi(pipe_ctx); status = DC_OK; break; + case SIGNAL_TYPE_LVDS: + enable_link_lvds(pipe_ctx); + status = DC_OK; + break; case SIGNAL_TYPE_VIRTUAL: status = DC_OK; break; @@ -2492,6 +2532,11 @@ void core_link_enable_stream( (pipe_ctx->stream->signal == SIGNAL_TYPE_DVI_DUAL_LINK) ? true : false); + if (dc_is_lvds_signal(pipe_ctx->stream->signal)) + pipe_ctx->stream_res.stream_enc->funcs->lvds_set_stream_attribute( + pipe_ctx->stream_res.stream_enc, + &stream->timing); + resource_build_info_frame(pipe_ctx); core_dc->hwss.update_info_frame(pipe_ctx); diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c index ca137757a69e..1f23224d495a 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c @@ -75,6 +75,11 @@ static const struct spread_spectrum_data *get_ss_data_entry( entrys_num = clk_src->hdmi_ss_params_cnt; break; + case SIGNAL_TYPE_LVDS: + ss_parm = clk_src->lvds_ss_params; + entrys_num = clk_src->lvds_ss_params_cnt; + break; + case SIGNAL_TYPE_DISPLAY_PORT: case SIGNAL_TYPE_DISPLAY_PORT_MST: case SIGNAL_TYPE_EDP: @@ -1184,6 +1189,11 @@ static void ss_info_from_atombios_create( AS_SIGNAL_TYPE_DVI, &clk_src->dvi_ss_params, &clk_src->dvi_ss_params_cnt); + get_ss_info_from_atombios( + clk_src, + AS_SIGNAL_TYPE_LVDS, + &clk_src->lvds_ss_params, + &clk_src->lvds_ss_params_cnt); } static bool calc_pll_max_vco_construct( diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.h b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.h index c45e2f76189e..cdeb96a268fb 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.h @@ -125,6 +125,8 @@ struct dce110_clk_src { uint32_t hdmi_ss_params_cnt; struct spread_spectrum_data *dvi_ss_params; uint32_t dvi_ss_params_cnt; + struct spread_spectrum_data *lvds_ss_params; + uint32_t lvds_ss_params_cnt; uint32_t ext_clk_khz; uint32_t ref_freq_khz; diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c b/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c index eff7d22d78fb..4942590e8b9c 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c @@ -102,6 +102,7 @@ static const struct link_encoder_funcs dce110_lnk_enc_funcs = { .enable_tmds_output = dce110_link_encoder_enable_tmds_output, .enable_dp_output = dce110_link_encoder_enable_dp_output, .enable_dp_mst_output = dce110_link_encoder_enable_dp_mst_output, + .enable_lvds_output = dce110_link_encoder_enable_lvds_output, .disable_output = dce110_link_encoder_disable_output, .dp_set_lane_settings = dce110_link_encoder_dp_set_lane_settings, .dp_set_phy_pattern = dce110_link_encoder_dp_set_phy_pattern, @@ -814,6 +815,7 @@ bool dce110_link_encoder_validate_output_with_stream( enc110, &stream->timing); break; case SIGNAL_TYPE_EDP: + case SIGNAL_TYPE_LVDS: is_valid = (stream->timing. pixel_encoding == PIXEL_ENCODING_RGB) ? true : false; @@ -955,6 +957,38 @@ void dce110_link_encoder_enable_tmds_output( } } +/* TODO: still need depth or just pass in adjusted pixel clock? */ +void dce110_link_encoder_enable_lvds_output( + struct link_encoder *enc, + enum clock_source_id clock_source, + uint32_t pixel_clock) +{ + struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc); + struct bp_transmitter_control cntl = { 0 }; + enum bp_result result; + + /* Enable the PHY */ + cntl.connector_obj_id = enc110->base.connector; + cntl.action = TRANSMITTER_CONTROL_ENABLE; + cntl.engine_id = enc->preferred_engine; + cntl.transmitter = enc110->base.transmitter; + cntl.pll_id = clock_source; + cntl.signal = SIGNAL_TYPE_LVDS; + cntl.lanes_number = 4; + + cntl.hpd_sel = enc110->base.hpd_source; + + cntl.pixel_clock = pixel_clock; + + result = link_transmitter_control(enc110, &cntl); + + if (result != BP_RESULT_OK) { + DC_LOG_ERROR("%s: Failed to execute VBIOS command table!\n", + __func__); + BREAK_TO_DEBUGGER(); + } +} + /* enables DP PHY output */ void dce110_link_encoder_enable_dp_output( struct link_encoder *enc, diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.h b/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.h index 347069461a22..3c9368df4093 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.h @@ -225,6 +225,12 @@ void dce110_link_encoder_enable_dp_mst_output( const struct dc_link_settings *link_settings, enum clock_source_id clock_source); +/* enables LVDS PHY output */ +void dce110_link_encoder_enable_lvds_output( + struct link_encoder *enc, + enum clock_source_id clock_source, + uint32_t pixel_clock); + /* disable PHY output */ void dce110_link_encoder_disable_output( struct link_encoder *enc, diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c b/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c index 91642e684858..c47c81883d3c 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c @@ -674,6 +674,28 @@ static void dce110_stream_encoder_dvi_set_stream_attribute( dce110_stream_encoder_set_stream_attribute_helper(enc110, crtc_timing); } +/* setup stream encoder in LVDS mode */ +static void dce110_stream_encoder_lvds_set_stream_attribute( + struct stream_encoder *enc, + struct dc_crtc_timing *crtc_timing) +{ + struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc); + struct bp_encoder_control cntl = {0}; + + cntl.action = ENCODER_CONTROL_SETUP; + cntl.engine_id = enc110->base.id; + cntl.signal = SIGNAL_TYPE_LVDS; + cntl.enable_dp_audio = false; + cntl.pixel_clock = crtc_timing->pix_clk_khz; + cntl.lanes_number = LANE_COUNT_FOUR; + + if (enc110->base.bp->funcs->encoder_control( + enc110->base.bp, &cntl) != BP_RESULT_OK) + return; + + ASSERT(crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB); +} + static void dce110_stream_encoder_set_mst_bandwidth( struct stream_encoder *enc, struct fixed31_32 avg_time_slots_per_mtp) @@ -1564,6 +1586,8 @@ static const struct stream_encoder_funcs dce110_str_enc_funcs = { dce110_stream_encoder_hdmi_set_stream_attribute, .dvi_set_stream_attribute = dce110_stream_encoder_dvi_set_stream_attribute, + .lvds_set_stream_attribute = + dce110_stream_encoder_lvds_set_stream_attribute, .set_mst_bandwidth = dce110_stream_encoder_set_mst_bandwidth, .update_hdmi_info_packets = diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/link_encoder.h b/drivers/gpu/drm/amd/display/dc/inc/hw/link_encoder.h index cf6df2e7beb2..58818920ed41 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/link_encoder.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/link_encoder.h @@ -131,6 +131,9 @@ struct link_encoder_funcs { void (*enable_dp_mst_output)(struct link_encoder *enc, const struct dc_link_settings *link_settings, enum clock_source_id clock_source); + void (*enable_lvds_output)(struct link_encoder *enc, + enum clock_source_id clock_source, + uint32_t pixel_clock); void (*disable_output)(struct link_encoder *link_enc, enum signal_type signal); void (*dp_set_lane_settings)(struct link_encoder *enc, diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/stream_encoder.h b/drivers/gpu/drm/amd/display/dc/inc/hw/stream_encoder.h index cfa7ec9517ae..53a9b64df11a 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/stream_encoder.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/stream_encoder.h @@ -101,6 +101,10 @@ struct stream_encoder_funcs { struct dc_crtc_timing *crtc_timing, bool is_dual_link); + void (*lvds_set_stream_attribute)( + struct stream_encoder *enc, + struct dc_crtc_timing *crtc_timing); + void (*set_mst_bandwidth)( struct stream_encoder *enc, struct fixed31_32 avg_time_slots_per_mtp); -- cgit v1.2.3 From 9bbdb0f345f50e2a9afd7d7c475e3b788eec402b Mon Sep 17 00:00:00 2001 From: David Francis Date: Thu, 9 Aug 2018 13:20:04 -0400 Subject: drm/amd/display: Eliminate i2c hw function pointers [Why] The function pointers of the dce_i2c_hw struct were never accessed from outside dce_i2c_hw.c and had only one version. As function pointers take up space and make debugging difficult, and they are not needed in this case, they should be removed. [How] Remove the dce_i2c_hw_funcs struct and make static all functions that were previously a part of it. Reorder the functions in dce_i2c_hw.c. Signed-off-by: David Francis Reviewed-by: Sun peng Li Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c | 607 ++++++++++++------------ drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h | 29 -- 2 files changed, 291 insertions(+), 345 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c index 3a63e3cbb91d..cd7da59794d0 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c @@ -36,223 +36,41 @@ #define FN(reg_name, field_name) \ dce_i2c_hw->shifts->field_name, dce_i2c_hw->masks->field_name - -static inline void reset_hw_engine(struct dce_i2c_hw *dce_i2c_hw) -{ - REG_UPDATE_2(DC_I2C_CONTROL, - DC_I2C_SW_STATUS_RESET, 1, - DC_I2C_SW_STATUS_RESET, 1); -} - -static bool is_hw_busy(struct dce_i2c_hw *dce_i2c_hw) -{ - uint32_t i2c_sw_status = 0; - - REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status); - if (i2c_sw_status == DC_I2C_STATUS__DC_I2C_STATUS_IDLE) - return false; - - reset_hw_engine(dce_i2c_hw); - - REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status); - return i2c_sw_status != DC_I2C_STATUS__DC_I2C_STATUS_IDLE; -} - -static void set_speed( - struct dce_i2c_hw *dce_i2c_hw, - uint32_t speed) -{ - - if (speed) { - if (dce_i2c_hw->masks->DC_I2C_DDC1_START_STOP_TIMING_CNTL) - REG_UPDATE_N(SPEED, 3, - FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), dce_i2c_hw->reference_frequency / speed, - FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2, - FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_START_STOP_TIMING_CNTL), speed > 50 ? 2:1); - else - REG_UPDATE_N(SPEED, 2, - FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), dce_i2c_hw->reference_frequency / speed, - FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2); - } -} - -bool dce_i2c_hw_engine_acquire_engine( - struct dce_i2c_hw *dce_i2c_hw, - struct ddc *ddc) -{ - - enum gpio_result result; - uint32_t current_speed; - - result = dal_ddc_open(ddc, GPIO_MODE_HARDWARE, - GPIO_DDC_CONFIG_TYPE_MODE_I2C); - - if (result != GPIO_RESULT_OK) - return false; - - dce_i2c_hw->ddc = ddc; - - - current_speed = dce_i2c_hw->funcs->get_speed(dce_i2c_hw); - - if (current_speed) - dce_i2c_hw->original_speed = current_speed; - - return true; -} -bool dce_i2c_engine_acquire_hw( - struct dce_i2c_hw *dce_i2c_hw, - struct ddc *ddc_handle) -{ - - uint32_t counter = 0; - bool result; - - do { - result = dce_i2c_hw_engine_acquire_engine( - dce_i2c_hw, ddc_handle); - - if (result) - break; - - /* i2c_engine is busy by VBios, lets wait and retry */ - - udelay(10); - - ++counter; - } while (counter < 2); - - if (result) { - if (!dce_i2c_hw->funcs->setup_engine(dce_i2c_hw)) { - dce_i2c_hw->funcs->release_engine(dce_i2c_hw); - result = false; - } - } - - return result; -} -struct dce_i2c_hw *acquire_i2c_hw_engine( - struct resource_pool *pool, - struct ddc *ddc) +static void disable_i2c_hw_engine( + struct dce_i2c_hw *dce_i2c_hw) { - - struct dce_i2c_hw *engine = NULL; - - if (!ddc) - return NULL; - - if (ddc->hw_info.hw_supported) { - enum gpio_ddc_line line = dal_ddc_get_line(ddc); - - if (line < pool->pipe_count) - engine = pool->hw_i2cs[line]; - } - - if (!engine) - return NULL; - - - if (!pool->i2c_hw_buffer_in_use && - dce_i2c_engine_acquire_hw(engine, ddc)) { - pool->i2c_hw_buffer_in_use = true; - return engine; - } - - - return NULL; + REG_UPDATE_N(SETUP, 1, FN(SETUP, DC_I2C_DDC1_ENABLE), 0); } -static bool setup_engine( +static void execute_transaction( struct dce_i2c_hw *dce_i2c_hw) { - uint32_t i2c_setup_limit = I2C_SETUP_TIME_LIMIT_DCE; + REG_UPDATE_N(SETUP, 5, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_DATA_DRIVE_EN), 0, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_CLK_DRIVE_EN), 0, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_DATA_DRIVE_SEL), 0, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_INTRA_TRANSACTION_DELAY), 0, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_INTRA_BYTE_DELAY), 0); - if (dce_i2c_hw->setup_limit != 0) - i2c_setup_limit = dce_i2c_hw->setup_limit; - /* Program pin select */ - REG_UPDATE_6(DC_I2C_CONTROL, - DC_I2C_GO, 0, + + REG_UPDATE_5(DC_I2C_CONTROL, DC_I2C_SOFT_RESET, 0, + DC_I2C_SW_STATUS_RESET, 0, DC_I2C_SEND_RESET, 0, - DC_I2C_SW_STATUS_RESET, 1, - DC_I2C_TRANSACTION_COUNT, 0, - DC_I2C_DDC_SELECT, dce_i2c_hw->engine_id); - - /* Program time limit */ - if (dce_i2c_hw->send_reset_length == 0) { - /*pre-dcn*/ - REG_UPDATE_N(SETUP, 2, - FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_TIME_LIMIT), i2c_setup_limit, - FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_ENABLE), 1); - } - /* Program HW priority - * set to High - interrupt software I2C at any time - * Enable restart of SW I2C that was interrupted by HW - * disable queuing of software while I2C is in use by HW - */ - REG_UPDATE_2(DC_I2C_ARBITRATION, - DC_I2C_NO_QUEUED_SW_GO, 0, - DC_I2C_SW_PRIORITY, DC_I2C_ARBITRATION__DC_I2C_SW_PRIORITY_NORMAL); - - return true; -} - - - - -static void process_channel_reply( - struct dce_i2c_hw *dce_i2c_hw, - struct i2c_reply_transaction_data *reply) -{ - uint32_t length = reply->length; - uint8_t *buffer = reply->data; - - REG_SET_3(DC_I2C_DATA, 0, - DC_I2C_INDEX, dce_i2c_hw->buffer_used_write, - DC_I2C_DATA_RW, 1, - DC_I2C_INDEX_WRITE, 1); - - while (length) { - /* after reading the status, - * if the I2C operation executed successfully - * (i.e. DC_I2C_STATUS_DONE = 1) then the I2C controller - * should read data bytes from I2C circular data buffer - */ - - uint32_t i2c_data; + DC_I2C_GO, 0, + DC_I2C_TRANSACTION_COUNT, dce_i2c_hw->transaction_count - 1); - REG_GET(DC_I2C_DATA, DC_I2C_DATA, &i2c_data); - *buffer++ = i2c_data; + /* start I2C transfer */ + REG_UPDATE(DC_I2C_CONTROL, DC_I2C_GO, 1); - --length; - } + /* all transactions were executed and HW buffer became empty + * (even though it actually happens when status becomes DONE) + */ + dce_i2c_hw->transaction_count = 0; + dce_i2c_hw->buffer_used_bytes = 0; } -enum i2c_channel_operation_result dce_i2c_hw_engine_wait_on_operation_result( - struct dce_i2c_hw *dce_i2c_hw, - uint32_t timeout, - enum i2c_channel_operation_result expected_result) -{ - enum i2c_channel_operation_result result; - uint32_t i = 0; - - if (!timeout) - return I2C_CHANNEL_OPERATION_SUCCEEDED; - - do { - result = dce_i2c_hw->funcs->get_channel_status( - dce_i2c_hw, NULL); - - if (result != expected_result) - break; - - udelay(1); - - ++i; - } while (i < timeout); - return result; -} -static enum i2c_channel_operation_result get_channel_status_hw( +static enum i2c_channel_operation_result get_channel_status( struct dce_i2c_hw *dce_i2c_hw, uint8_t *returned_bytes) { @@ -277,24 +95,13 @@ static enum i2c_channel_operation_result get_channel_status_hw( return I2C_CHANNEL_OPERATION_SUCCEEDED; } -static void submit_channel_request_hw( - struct dce_i2c_hw *dce_i2c_hw, - struct i2c_request_transaction_data *request) +static uint32_t get_hw_buffer_available_size( + const struct dce_i2c_hw *dce_i2c_hw) { - request->status = I2C_CHANNEL_OPERATION_SUCCEEDED; - - if (!dce_i2c_hw->funcs->process_transaction(dce_i2c_hw, request)) - return; - - if (dce_i2c_hw->funcs->is_hw_busy(dce_i2c_hw)) { - request->status = I2C_CHANNEL_OPERATION_ENGINE_BUSY; - return; - } - - dce_i2c_hw->funcs->execute_transaction(dce_i2c_hw); - - + return dce_i2c_hw->buffer_size - + dce_i2c_hw->buffer_used_bytes; } + uint32_t get_reference_clock( struct dc_bios *bios) { @@ -306,33 +113,48 @@ uint32_t get_reference_clock( return info.pll_info.crystal_frequency; } -static void execute_transaction_hw( - struct dce_i2c_hw *dce_i2c_hw) +static uint32_t get_speed( + const struct dce_i2c_hw *dce_i2c_hw) { - REG_UPDATE_N(SETUP, 5, - FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_DATA_DRIVE_EN), 0, - FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_CLK_DRIVE_EN), 0, - FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_DATA_DRIVE_SEL), 0, - FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_INTRA_TRANSACTION_DELAY), 0, - FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_INTRA_BYTE_DELAY), 0); + uint32_t pre_scale = 0; + REG_GET(SPEED, DC_I2C_DDC1_PRESCALE, &pre_scale); - REG_UPDATE_5(DC_I2C_CONTROL, - DC_I2C_SOFT_RESET, 0, - DC_I2C_SW_STATUS_RESET, 0, - DC_I2C_SEND_RESET, 0, - DC_I2C_GO, 0, - DC_I2C_TRANSACTION_COUNT, dce_i2c_hw->transaction_count - 1); + /* [anaumov] it seems following is unnecessary */ + /*ASSERT(value.bits.DC_I2C_DDC1_PRESCALE);*/ + return pre_scale ? + dce_i2c_hw->reference_frequency / pre_scale : + dce_i2c_hw->default_speed; +} - /* start I2C transfer */ - REG_UPDATE(DC_I2C_CONTROL, DC_I2C_GO, 1); +static void process_channel_reply( + struct dce_i2c_hw *dce_i2c_hw, + struct i2c_reply_transaction_data *reply) +{ + uint32_t length = reply->length; + uint8_t *buffer = reply->data; - /* all transactions were executed and HW buffer became empty - * (even though it actually happens when status becomes DONE) - */ - dce_i2c_hw->transaction_count = 0; - dce_i2c_hw->buffer_used_bytes = 0; + REG_SET_3(DC_I2C_DATA, 0, + DC_I2C_INDEX, dce_i2c_hw->buffer_used_write, + DC_I2C_DATA_RW, 1, + DC_I2C_INDEX_WRITE, 1); + + while (length) { + /* after reading the status, + * if the I2C operation executed successfully + * (i.e. DC_I2C_STATUS_DONE = 1) then the I2C controller + * should read data bytes from I2C circular data buffer + */ + + uint32_t i2c_data; + + REG_GET(DC_I2C_DATA, DC_I2C_DATA, &i2c_data); + *buffer++ = i2c_data; + + --length; + } } + static bool process_transaction( struct dce_i2c_hw *dce_i2c_hw, struct i2c_request_transaction_data *request) @@ -422,51 +244,89 @@ static bool process_transaction( return last_transaction; } -static uint32_t get_transaction_timeout_hw( - const struct dce_i2c_hw *dce_i2c_hw, - uint32_t length) -{ - - uint32_t speed = dce_i2c_hw->funcs->get_speed(dce_i2c_hw); +static inline void reset_hw_engine(struct dce_i2c_hw *dce_i2c_hw) +{ + REG_UPDATE_2(DC_I2C_CONTROL, + DC_I2C_SW_STATUS_RESET, 1, + DC_I2C_SW_STATUS_RESET, 1); +} +static void set_speed( + struct dce_i2c_hw *dce_i2c_hw, + uint32_t speed) +{ - uint32_t period_timeout; - uint32_t num_of_clock_stretches; + if (speed) { + if (dce_i2c_hw->masks->DC_I2C_DDC1_START_STOP_TIMING_CNTL) + REG_UPDATE_N(SPEED, 3, + FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), dce_i2c_hw->reference_frequency / speed, + FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2, + FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_START_STOP_TIMING_CNTL), speed > 50 ? 2:1); + else + REG_UPDATE_N(SPEED, 2, + FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_PRESCALE), dce_i2c_hw->reference_frequency / speed, + FN(DC_I2C_DDC1_SPEED, DC_I2C_DDC1_THRESHOLD), 2); + } +} - if (!speed) - return 0; +static bool setup_engine( + struct dce_i2c_hw *dce_i2c_hw) +{ + uint32_t i2c_setup_limit = I2C_SETUP_TIME_LIMIT_DCE; - period_timeout = (1000 * TRANSACTION_TIMEOUT_IN_I2C_CLOCKS) / speed; + if (dce_i2c_hw->setup_limit != 0) + i2c_setup_limit = dce_i2c_hw->setup_limit; + /* Program pin select */ + REG_UPDATE_6(DC_I2C_CONTROL, + DC_I2C_GO, 0, + DC_I2C_SOFT_RESET, 0, + DC_I2C_SEND_RESET, 0, + DC_I2C_SW_STATUS_RESET, 1, + DC_I2C_TRANSACTION_COUNT, 0, + DC_I2C_DDC_SELECT, dce_i2c_hw->engine_id); - num_of_clock_stretches = 1 + (length << 3) + 1; - num_of_clock_stretches += - (dce_i2c_hw->buffer_used_bytes << 3) + - (dce_i2c_hw->transaction_count << 1); + /* Program time limit */ + if (dce_i2c_hw->send_reset_length == 0) { + /*pre-dcn*/ + REG_UPDATE_N(SETUP, 2, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_TIME_LIMIT), i2c_setup_limit, + FN(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_ENABLE), 1); + } + /* Program HW priority + * set to High - interrupt software I2C at any time + * Enable restart of SW I2C that was interrupted by HW + * disable queuing of software while I2C is in use by HW + */ + REG_UPDATE_2(DC_I2C_ARBITRATION, + DC_I2C_NO_QUEUED_SW_GO, 0, + DC_I2C_SW_PRIORITY, DC_I2C_ARBITRATION__DC_I2C_SW_PRIORITY_NORMAL); - return period_timeout * num_of_clock_stretches; + return true; } -static void release_engine_dce_hw( - struct resource_pool *pool, - struct dce_i2c_hw *dce_i2c_hw) +static bool is_hw_busy(struct dce_i2c_hw *dce_i2c_hw) { - pool->i2c_hw_buffer_in_use = false; + uint32_t i2c_sw_status = 0; - dce_i2c_hw->funcs->release_engine(dce_i2c_hw); - dal_ddc_close(dce_i2c_hw->ddc); + REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status); + if (i2c_sw_status == DC_I2C_STATUS__DC_I2C_STATUS_IDLE) + return false; - dce_i2c_hw->ddc = NULL; + reset_hw_engine(dce_i2c_hw); + + REG_GET(DC_I2C_SW_STATUS, DC_I2C_SW_STATUS, &i2c_sw_status); + return i2c_sw_status != DC_I2C_STATUS__DC_I2C_STATUS_IDLE; } -static void release_engine_hw( +static void release_engine( struct dce_i2c_hw *dce_i2c_hw) { bool safe_to_reset; /* Restore original HW engine speed */ - dce_i2c_hw->funcs->set_speed(dce_i2c_hw, dce_i2c_hw->original_speed); + set_speed(dce_i2c_hw, dce_i2c_hw->original_speed); /* Release I2C */ REG_UPDATE(DC_I2C_ARBITRATION, DC_I2C_SW_DONE_USING_I2C_REG, 1); @@ -488,35 +348,180 @@ static void release_engine_hw( REG_UPDATE(DC_I2C_CONTROL, DC_I2C_SW_STATUS_RESET, 1); /* HW I2c engine - clock gating feature */ if (!dce_i2c_hw->engine_keep_power_up_count) - dce_i2c_hw->funcs->disable_i2c_hw_engine(dce_i2c_hw); + disable_i2c_hw_engine(dce_i2c_hw); } - -static void disable_i2c_hw_engine( +static void release_engine_dce_hw( + struct resource_pool *pool, struct dce_i2c_hw *dce_i2c_hw) { - REG_UPDATE_N(SETUP, 1, FN(SETUP, DC_I2C_DDC1_ENABLE), 0); + pool->i2c_hw_buffer_in_use = false; + + release_engine(dce_i2c_hw); + dal_ddc_close(dce_i2c_hw->ddc); + + dce_i2c_hw->ddc = NULL; } -static uint32_t get_speed_hw( - const struct dce_i2c_hw *dce_i2c_hw) + +bool dce_i2c_hw_engine_acquire_engine( + struct dce_i2c_hw *dce_i2c_hw, + struct ddc *ddc) { - uint32_t pre_scale = 0; - REG_GET(SPEED, DC_I2C_DDC1_PRESCALE, &pre_scale); + enum gpio_result result; + uint32_t current_speed; - /* [anaumov] it seems following is unnecessary */ - /*ASSERT(value.bits.DC_I2C_DDC1_PRESCALE);*/ - return pre_scale ? - dce_i2c_hw->reference_frequency / pre_scale : - dce_i2c_hw->default_speed; + result = dal_ddc_open(ddc, GPIO_MODE_HARDWARE, + GPIO_DDC_CONFIG_TYPE_MODE_I2C); + + if (result != GPIO_RESULT_OK) + return false; + + dce_i2c_hw->ddc = ddc; + + + current_speed = get_speed(dce_i2c_hw); + + if (current_speed) + dce_i2c_hw->original_speed = current_speed; + + return true; } -static uint32_t get_hw_buffer_available_size( - const struct dce_i2c_hw *dce_i2c_hw) + +bool dce_i2c_engine_acquire_hw( + struct dce_i2c_hw *dce_i2c_hw, + struct ddc *ddc_handle) { - return dce_i2c_hw->buffer_size - - dce_i2c_hw->buffer_used_bytes; + + uint32_t counter = 0; + bool result; + + do { + result = dce_i2c_hw_engine_acquire_engine( + dce_i2c_hw, ddc_handle); + + if (result) + break; + + /* i2c_engine is busy by VBios, lets wait and retry */ + + udelay(10); + + ++counter; + } while (counter < 2); + + if (result) { + if (!setup_engine(dce_i2c_hw)) { + release_engine(dce_i2c_hw); + result = false; + } + } + + return result; +} + +struct dce_i2c_hw *acquire_i2c_hw_engine( + struct resource_pool *pool, + struct ddc *ddc) +{ + + struct dce_i2c_hw *engine = NULL; + + if (!ddc) + return NULL; + + if (ddc->hw_info.hw_supported) { + enum gpio_ddc_line line = dal_ddc_get_line(ddc); + + if (line < pool->pipe_count) + engine = pool->hw_i2cs[line]; + } + + if (!engine) + return NULL; + + + if (!pool->i2c_hw_buffer_in_use && + dce_i2c_engine_acquire_hw(engine, ddc)) { + pool->i2c_hw_buffer_in_use = true; + return engine; + } + + + return NULL; +} + +enum i2c_channel_operation_result dce_i2c_hw_engine_wait_on_operation_result( + struct dce_i2c_hw *dce_i2c_hw, + uint32_t timeout, + enum i2c_channel_operation_result expected_result) +{ + enum i2c_channel_operation_result result; + uint32_t i = 0; + + if (!timeout) + return I2C_CHANNEL_OPERATION_SUCCEEDED; + + do { + + result = get_channel_status( + dce_i2c_hw, NULL); + + if (result != expected_result) + break; + + udelay(1); + + ++i; + } while (i < timeout); + return result; +} + +static void submit_channel_request_hw( + struct dce_i2c_hw *dce_i2c_hw, + struct i2c_request_transaction_data *request) +{ + request->status = I2C_CHANNEL_OPERATION_SUCCEEDED; + + if (!process_transaction(dce_i2c_hw, request)) + return; + + if (is_hw_busy(dce_i2c_hw)) { + request->status = I2C_CHANNEL_OPERATION_ENGINE_BUSY; + return; + } + + execute_transaction(dce_i2c_hw); + + +} + +static uint32_t get_transaction_timeout_hw( + const struct dce_i2c_hw *dce_i2c_hw, + uint32_t length) +{ + + uint32_t speed = get_speed(dce_i2c_hw); + + + + uint32_t period_timeout; + uint32_t num_of_clock_stretches; + + if (!speed) + return 0; + + period_timeout = (1000 * TRANSACTION_TIMEOUT_IN_I2C_CLOCKS) / speed; + + num_of_clock_stretches = 1 + (length << 3) + 1; + num_of_clock_stretches += + (dce_i2c_hw->buffer_used_bytes << 3) + + (dce_i2c_hw->transaction_count << 1); + + return period_timeout * num_of_clock_stretches; } + bool dce_i2c_hw_engine_submit_request( struct dce_i2c_hw *dce_i2c_hw, struct dce_i2c_transaction_request *dce_i2c_request, @@ -615,9 +620,7 @@ bool dce_i2c_hw_engine_submit_request( reply.data = dce_i2c_request->payload.data; reply.length = dce_i2c_request->payload.length; - dce_i2c_hw->funcs->process_channel_reply(dce_i2c_hw, &reply); - - + process_channel_reply(dce_i2c_hw, &reply); } return result; @@ -632,7 +635,7 @@ bool dce_i2c_submit_command_hw( uint8_t index_of_payload = 0; bool result; - dce_i2c_hw->funcs->set_speed(dce_i2c_hw, cmd->speed); + set_speed(dce_i2c_hw, cmd->speed); result = true; @@ -670,32 +673,6 @@ bool dce_i2c_submit_command_hw( return result; } -static const struct dce_i2c_hw_funcs dce100_i2c_hw_funcs = { - .setup_engine = setup_engine, - .set_speed = set_speed, - .get_speed = get_speed_hw, - .release_engine = release_engine_hw, - .process_transaction = process_transaction, - .process_channel_reply = process_channel_reply, - .is_hw_busy = is_hw_busy, - .get_channel_status = get_channel_status_hw, - .execute_transaction = execute_transaction_hw, - .disable_i2c_hw_engine = disable_i2c_hw_engine -}; -static const struct dce_i2c_hw_funcs dce80_i2c_hw_funcs = { - .setup_engine = setup_engine, - .set_speed = set_speed, - .get_speed = get_speed_hw, - .release_engine = release_engine_hw, - .process_transaction = process_transaction, - .process_channel_reply = process_channel_reply, - .is_hw_busy = is_hw_busy, - .get_channel_status = get_channel_status_hw, - .execute_transaction = execute_transaction_hw, - .disable_i2c_hw_engine = disable_i2c_hw_engine -}; - - void dce_i2c_hw_construct( struct dce_i2c_hw *dce_i2c_hw, @@ -718,7 +695,6 @@ void dce_i2c_hw_construct( dce_i2c_hw->default_speed = DEFAULT_I2C_HW_SPEED; dce_i2c_hw->send_reset_length = 0; dce_i2c_hw->setup_limit = I2C_SETUP_TIME_LIMIT_DCE; - dce_i2c_hw->funcs = &dce80_i2c_hw_funcs; dce_i2c_hw->buffer_size = I2C_HW_BUFFER_SIZE_DCE; } @@ -739,7 +715,6 @@ void dce100_i2c_hw_construct( regs, shifts, masks); - dce_i2c_hw->funcs = &dce100_i2c_hw_funcs; dce_i2c_hw->buffer_size = I2C_HW_BUFFER_SIZE_DCE100; REG_GET(MICROSECOND_TIME_BASE_DIV, XTAL_REF_DIV, &xtal_ref_div); diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h index 8baef3916246..742c1da84d45 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h @@ -256,40 +256,11 @@ struct dce_i2c_hw { uint32_t buffer_size; struct dc_context *ctx; - const struct dce_i2c_hw_funcs *funcs; const struct dce_i2c_registers *regs; const struct dce_i2c_shift *shifts; const struct dce_i2c_mask *masks; }; - -struct dce_i2c_hw_funcs { - bool (*setup_engine)( - struct dce_i2c_hw *dce_i2c_hw); - void (*set_speed)( - struct dce_i2c_hw *dce_i2c_hw, - uint32_t speed); - uint32_t (*get_speed)( - const struct dce_i2c_hw *dce_i2c_hw); - void (*release_engine)( - struct dce_i2c_hw *dce_i2c_hw); - bool (*process_transaction)( - struct dce_i2c_hw *dce_i2c_hw, - struct i2c_request_transaction_data *request); - void (*process_channel_reply)( - struct dce_i2c_hw *dce_i2c_hw, - struct i2c_reply_transaction_data *reply); - bool (*is_hw_busy)( - struct dce_i2c_hw *dce_i2c_hw); - enum i2c_channel_operation_result (*get_channel_status)( - struct dce_i2c_hw *dce_i2c_hw, - uint8_t *returned_bytes); - void (*execute_transaction)( - struct dce_i2c_hw *dce_i2c_hw); - void (*disable_i2c_hw_engine)( - struct dce_i2c_hw *dce_i2c_hw); -}; - void dce_i2c_hw_construct( struct dce_i2c_hw *dce_i2c_hw, struct dc_context *ctx, -- cgit v1.2.3 From 58382a445b7616ef60f2d8fc4717f90fc8472d45 Mon Sep 17 00:00:00 2001 From: Tony Cheng Date: Wed, 18 Jul 2018 20:29:46 -0400 Subject: drm/amd/display: dc 3.1.63 Signed-off-by: Tony Cheng Reviewed-by: Steven Chiu Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index 3564f4fe420a..2faff1b8821d 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -38,7 +38,7 @@ #include "inc/compressor.h" #include "dml/display_mode_lib.h" -#define DC_VER "3.1.62" +#define DC_VER "3.1.63" #define MAX_SURFACES 3 #define MAX_STREAMS 6 -- cgit v1.2.3 From 18e4aa33bdfba0e7ac4e5a62d0665becb78ce012 Mon Sep 17 00:00:00 2001 From: Ken Chalmers Date: Fri, 10 Aug 2018 15:51:59 -0400 Subject: drm/amd/display: eliminate long wait between register polls on Maximus [Why] Now that we "scale" time delays correctly on Maximus (as of diags svn r170115), the forced "35 ms" wait time now becomes 35 ms * 500 = 17.5 seconds, which is far too long. Even having to repeat polling a register once causes excessive delays on Maximus. [How] Just use the regular wait time passed to the generic_reg_wait() function. This is sufficient for Maximus now, and it also means that there's one less "Maximus-only" code path in DAL. Also disable the "REG_WAIT taking a while:" message on Maximus, since things do take a while longer there and 1-2ms delays are not uncommon (and nothing to worry about). Signed-off-by: Ken Chalmers Reviewed-by: Eric Bernstein Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dc_helper.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dc_helper.c b/drivers/gpu/drm/amd/display/dc/dc_helper.c index e68077e65565..fcfd50b5dba0 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_helper.c +++ b/drivers/gpu/drm/amd/display/dc/dc_helper.c @@ -219,12 +219,6 @@ uint32_t generic_reg_wait(const struct dc_context *ctx, /* something is terribly wrong if time out is > 200ms. (5Hz) */ ASSERT(delay_between_poll_us * time_out_num_tries <= 200000); - if (IS_FPGA_MAXIMUS_DC(ctx->dce_environment)) { - /* 35 seconds */ - delay_between_poll_us = 35000; - time_out_num_tries = 1000; - } - for (i = 0; i <= time_out_num_tries; i++) { if (i) { if (delay_between_poll_us >= 1000) @@ -238,7 +232,8 @@ uint32_t generic_reg_wait(const struct dc_context *ctx, field_value = get_reg_field_value_ex(reg_val, mask, shift); if (field_value == condition_value) { - if (i * delay_between_poll_us > 1000) + if (i * delay_between_poll_us > 1000 && + !IS_FPGA_MAXIMUS_DC(ctx->dce_environment)) dm_output_to_console("REG_WAIT taking a while: %dms in %s line:%d\n", delay_between_poll_us * i / 1000, func_name, line); -- cgit v1.2.3 From 219097df0f9d47fd882791144c60f3155750a6a7 Mon Sep 17 00:00:00 2001 From: SivapiriyanKumarasamy Date: Wed, 15 Aug 2018 16:55:18 -0400 Subject: drm/amd/display: Fix memory leak caused by missed dc_sink_release [Why] There is currently an intermittent hang from a memory leak in DTN stress testing. It is caused by unfreed memory during driver disable. [How] Do a dc_sink_release in the case that skips it incorrectly. Signed-off-by: SivapiriyanKumarasamy Reviewed-by: Aric Cyr Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index 309059871706..9d8dc2c1ca65 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c @@ -772,8 +772,12 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) * fail-safe mode */ if (dc_is_hdmi_signal(link->connector_signal) || - dc_is_dvi_signal(link->connector_signal)) + dc_is_dvi_signal(link->connector_signal)) { + if (prev_sink != NULL) + dc_sink_release(prev_sink); + return false; + } default: break; } -- cgit v1.2.3 From 46659a83e4662ed92000ec13445b8c0ca96fd2cc Mon Sep 17 00:00:00 2001 From: Nicholas Kazlauskas Date: Wed, 15 Aug 2018 12:00:23 -0400 Subject: drm/amd/display: Support reading hw state from debugfs file [Why] Logging hardware state can be done by triggering a write to the debugfs file. It would also be useful to be able to read the hardware state from the debugfs file to be able to generate a clean log without timestamps. [How] Usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log Threading is an obvious concern when dealing with multiple debugfs operations and blocking on global state in dm or dc seems unfavorable. Adding an extra parameter for the debugfs log context state is the implementation done here. Existing code that made use of DTN_INFO and its associated macros needed to be refactored to support this. We don't know the size of the log in advance so it reallocates the log string dynamically. Once the log has been generated it's copied into the user supplied buffer for the debugfs. This allows for seeking support but it's worth nothing that unlike triggering output via dmesg the hardware state might change in-between reads if your buffer size is too small. Signed-off-by: Nicholas Kazlauskas Reviewed-by: Jordan Lazare Acked-by: Leo Li Signed-off-by: Alex Deucher --- .../drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 24 +++++++++++++--------- drivers/gpu/drm/amd/display/dc/dm_services.h | 10 ++++++--- drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h | 3 ++- 3 files changed, 23 insertions(+), 14 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index 1c5bb148efb7..6bd4ec39f869 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c @@ -58,9 +58,11 @@ /*print is 17 wide, first two characters are spaces*/ #define DTN_INFO_MICRO_SEC(ref_cycle) \ - print_microsec(dc_ctx, ref_cycle) + print_microsec(dc_ctx, log_ctx, ref_cycle) -void print_microsec(struct dc_context *dc_ctx, uint32_t ref_cycle) +void print_microsec(struct dc_context *dc_ctx, + struct dc_log_buffer_ctx *log_ctx, + uint32_t ref_cycle) { const uint32_t ref_clk_mhz = dc_ctx->dc->res_pool->ref_clock_inKhz / 1000; static const unsigned int frac = 1000; @@ -71,7 +73,8 @@ void print_microsec(struct dc_context *dc_ctx, uint32_t ref_cycle) us_x10 % frac); } -static void log_mpc_crc(struct dc *dc) +static void log_mpc_crc(struct dc *dc, + struct dc_log_buffer_ctx *log_ctx) { struct dc_context *dc_ctx = dc->ctx; struct dce_hwseq *hws = dc->hwseq; @@ -84,7 +87,7 @@ static void log_mpc_crc(struct dc *dc) REG_READ(DPP_TOP0_DPP_CRC_VAL_B_A), REG_READ(DPP_TOP0_DPP_CRC_VAL_R_G)); } -void dcn10_log_hubbub_state(struct dc *dc) +void dcn10_log_hubbub_state(struct dc *dc, struct dc_log_buffer_ctx *log_ctx) { struct dc_context *dc_ctx = dc->ctx; struct dcn_hubbub_wm wm = {0}; @@ -111,7 +114,7 @@ void dcn10_log_hubbub_state(struct dc *dc) DTN_INFO("\n"); } -static void dcn10_log_hubp_states(struct dc *dc) +static void dcn10_log_hubp_states(struct dc *dc, void *log_ctx) { struct dc_context *dc_ctx = dc->ctx; struct resource_pool *pool = dc->res_pool; @@ -226,7 +229,8 @@ static void dcn10_log_hubp_states(struct dc *dc) DTN_INFO("\n"); } -void dcn10_log_hw_state(struct dc *dc) +void dcn10_log_hw_state(struct dc *dc, + struct dc_log_buffer_ctx *log_ctx) { struct dc_context *dc_ctx = dc->ctx; struct resource_pool *pool = dc->res_pool; @@ -234,9 +238,9 @@ void dcn10_log_hw_state(struct dc *dc) DTN_INFO_BEGIN(); - dcn10_log_hubbub_state(dc); + dcn10_log_hubbub_state(dc, log_ctx); - dcn10_log_hubp_states(dc); + dcn10_log_hubp_states(dc, log_ctx); DTN_INFO("DPP: IGAM format IGAM mode DGAM mode RGAM mode" " GAMUT mode C11 C12 C13 C14 C21 C22 C23 C24 " @@ -347,7 +351,7 @@ void dcn10_log_hw_state(struct dc *dc) dc->current_state->bw.dcn.clk.fclk_khz, dc->current_state->bw.dcn.clk.socclk_khz); - log_mpc_crc(dc); + log_mpc_crc(dc, log_ctx); DTN_INFO_END(); } @@ -857,7 +861,7 @@ void dcn10_verify_allow_pstate_change_high(struct dc *dc) if (!hubbub1_verify_allow_pstate_change_high(dc->res_pool->hubbub)) { if (should_log_hw_state) { - dcn10_log_hw_state(dc); + dcn10_log_hw_state(dc, NULL); } BREAK_TO_DEBUGGER(); if (dcn10_hw_wa_force_recovery(dc)) { diff --git a/drivers/gpu/drm/amd/display/dc/dm_services.h b/drivers/gpu/drm/amd/display/dc/dm_services.h index eb5ab3978e84..28128c02de00 100644 --- a/drivers/gpu/drm/amd/display/dc/dm_services.h +++ b/drivers/gpu/drm/amd/display/dc/dm_services.h @@ -359,8 +359,12 @@ void dm_perf_trace_timestamp(const char *func_name, unsigned int line); * Debug and verification hooks */ -void dm_dtn_log_begin(struct dc_context *ctx); -void dm_dtn_log_append_v(struct dc_context *ctx, const char *msg, ...); -void dm_dtn_log_end(struct dc_context *ctx); +void dm_dtn_log_begin(struct dc_context *ctx, + struct dc_log_buffer_ctx *log_ctx); +void dm_dtn_log_append_v(struct dc_context *ctx, + struct dc_log_buffer_ctx *log_ctx, + const char *msg, ...); +void dm_dtn_log_end(struct dc_context *ctx, + struct dc_log_buffer_ctx *log_ctx); #endif /* __DM_SERVICES_H__ */ diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h index 9a97356923e2..26f29d5da3d8 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h @@ -202,7 +202,8 @@ struct hw_sequencer_funcs { void (*set_avmute)(struct pipe_ctx *pipe_ctx, bool enable); - void (*log_hw_state)(struct dc *dc); + void (*log_hw_state)(struct dc *dc, + struct dc_log_buffer_ctx *log_ctx); void (*get_hw_state)(struct dc *dc, char *pBuf, unsigned int bufSize, unsigned int mask); void (*wait_for_mpcc_disconnect)(struct dc *dc, -- cgit v1.2.3 From d377ae4e3754ee3f81f63a0d9e3eadba7830d3e3 Mon Sep 17 00:00:00 2001 From: David Francis Date: Fri, 3 Aug 2018 14:25:19 -0400 Subject: drm/amd/display: Remove redundant i2c structs [Why] The i2c code contains two structs that contain the same information as i2c_payload [How] Replace references to those structs with references to i2c_payload dce_i2c_transaction_request->status was written to but never read, so all references to it are removed Signed-off-by: David Francis Reviewed-by: Jordan Lazare Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dce/dce_i2c.h | 33 ---------- drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c | 84 +++++-------------------- drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h | 5 -- drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.c | 83 ++++-------------------- 4 files changed, 28 insertions(+), 177 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c.h b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c.h index d655f89578ca..a171c5cd8439 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c.h @@ -30,39 +30,6 @@ #include "dce_i2c_hw.h" #include "dce_i2c_sw.h" -enum dce_i2c_transaction_status { - DCE_I2C_TRANSACTION_STATUS_UNKNOWN = (-1L), - DCE_I2C_TRANSACTION_STATUS_SUCCEEDED, - DCE_I2C_TRANSACTION_STATUS_FAILED_CHANNEL_BUSY, - DCE_I2C_TRANSACTION_STATUS_FAILED_TIMEOUT, - DCE_I2C_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR, - DCE_I2C_TRANSACTION_STATUS_FAILED_NACK, - DCE_I2C_TRANSACTION_STATUS_FAILED_INCOMPLETE, - DCE_I2C_TRANSACTION_STATUS_FAILED_OPERATION, - DCE_I2C_TRANSACTION_STATUS_FAILED_INVALID_OPERATION, - DCE_I2C_TRANSACTION_STATUS_FAILED_BUFFER_OVERFLOW, - DCE_I2C_TRANSACTION_STATUS_FAILED_HPD_DISCON -}; - -enum dce_i2c_transaction_operation { - DCE_I2C_TRANSACTION_READ, - DCE_I2C_TRANSACTION_WRITE -}; - -struct dce_i2c_transaction_payload { - enum dce_i2c_transaction_address_space address_space; - uint32_t address; - uint32_t length; - uint8_t *data; -}; - -struct dce_i2c_transaction_request { - enum dce_i2c_transaction_operation operation; - struct dce_i2c_transaction_payload payload; - enum dce_i2c_transaction_status status; -}; - - bool dce_i2c_submit_command( struct resource_pool *pool, struct ddc *ddc, diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c index cd7da59794d0..2800d3fa49da 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c @@ -129,7 +129,7 @@ static uint32_t get_speed( static void process_channel_reply( struct dce_i2c_hw *dce_i2c_hw, - struct i2c_reply_transaction_data *reply) + struct i2c_payload *reply) { uint32_t length = reply->length; uint8_t *buffer = reply->data; @@ -522,9 +522,9 @@ static uint32_t get_transaction_timeout_hw( return period_timeout * num_of_clock_stretches; } -bool dce_i2c_hw_engine_submit_request( +bool dce_i2c_hw_engine_submit_payload( struct dce_i2c_hw *dce_i2c_hw, - struct dce_i2c_transaction_request *dce_i2c_request, + struct i2c_payload *payload, bool middle_of_transaction) { @@ -541,46 +541,36 @@ bool dce_i2c_hw_engine_submit_request( * the number of free bytes in HW buffer (minus one for address) */ - if (dce_i2c_request->payload.length >= + if (payload->length >= get_hw_buffer_available_size(dce_i2c_hw)) { - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_BUFFER_OVERFLOW; return false; } - if (dce_i2c_request->operation == DCE_I2C_TRANSACTION_READ) + if (!payload->write) request.action = middle_of_transaction ? DCE_I2C_TRANSACTION_ACTION_I2C_READ_MOT : DCE_I2C_TRANSACTION_ACTION_I2C_READ; - else if (dce_i2c_request->operation == DCE_I2C_TRANSACTION_WRITE) + else request.action = middle_of_transaction ? DCE_I2C_TRANSACTION_ACTION_I2C_WRITE_MOT : DCE_I2C_TRANSACTION_ACTION_I2C_WRITE; - else { - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_INVALID_OPERATION; - /* [anaumov] in DAL2, there was no "return false" */ - return false; - } - request.address = (uint8_t) dce_i2c_request->payload.address; - request.length = dce_i2c_request->payload.length; - request.data = dce_i2c_request->payload.data; + + request.address = (uint8_t) ((payload->address << 1) | !payload->write); + request.length = payload->length; + request.data = payload->data; /* obtain timeout value before submitting request */ transaction_timeout = get_transaction_timeout_hw( - dce_i2c_hw, dce_i2c_request->payload.length + 1); + dce_i2c_hw, payload->length + 1); submit_channel_request_hw( dce_i2c_hw, &request); if ((request.status == I2C_CHANNEL_OPERATION_FAILED) || - (request.status == I2C_CHANNEL_OPERATION_ENGINE_BUSY)) { - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_CHANNEL_BUSY; + (request.status == I2C_CHANNEL_OPERATION_ENGINE_BUSY)) return false; - } /* wait until transaction proceed */ @@ -591,37 +581,11 @@ bool dce_i2c_hw_engine_submit_request( /* update transaction status */ - switch (operation_result) { - case I2C_CHANNEL_OPERATION_SUCCEEDED: - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_SUCCEEDED; + if (operation_result == I2C_CHANNEL_OPERATION_SUCCEEDED) result = true; - break; - case I2C_CHANNEL_OPERATION_NO_RESPONSE: - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_NACK; - break; - case I2C_CHANNEL_OPERATION_TIMEOUT: - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_TIMEOUT; - break; - case I2C_CHANNEL_OPERATION_FAILED: - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_INCOMPLETE; - break; - default: - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_OPERATION; - } - if (result && (dce_i2c_request->operation == DCE_I2C_TRANSACTION_READ)) { - struct i2c_reply_transaction_data reply; - - reply.data = dce_i2c_request->payload.data; - reply.length = dce_i2c_request->payload.length; - - process_channel_reply(dce_i2c_hw, &reply); - } + if (result && (!payload->write)) + process_channel_reply(dce_i2c_hw, payload); return result; } @@ -644,22 +608,8 @@ bool dce_i2c_submit_command_hw( struct i2c_payload *payload = cmd->payloads + index_of_payload; - struct dce_i2c_transaction_request request = { 0 }; - - request.operation = payload->write ? - DCE_I2C_TRANSACTION_WRITE : - DCE_I2C_TRANSACTION_READ; - - request.payload.address_space = - DCE_I2C_TRANSACTION_ADDRESS_SPACE_I2C; - request.payload.address = (payload->address << 1) | - !payload->write; - request.payload.length = payload->length; - request.payload.data = payload->data; - - - if (!dce_i2c_hw_engine_submit_request( - dce_i2c_hw, &request, mot)) { + if (!dce_i2c_hw_engine_submit_payload( + dce_i2c_hw, payload, mot)) { result = false; break; } diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h index 742c1da84d45..7f19bb439665 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.h @@ -236,11 +236,6 @@ struct i2c_request_transaction_data { uint8_t *data; }; -struct i2c_reply_transaction_data { - uint32_t length; - uint8_t *data; -}; - struct dce_i2c_hw { struct ddc *ddc; uint32_t original_speed; diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.c b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.c index ab11129ea425..f0266694cb56 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_sw.c @@ -70,13 +70,6 @@ static void release_engine_dce_sw( dce_i2c_sw->ddc = NULL; } -enum i2c_channel_operation_result dce_i2c_sw_engine_get_channel_status( - struct dce_i2c_sw *engine, - uint8_t *returned_bytes) -{ - /* No arbitration with VBIOS is performed since DCE 6.0 */ - return I2C_CHANNEL_OPERATION_SUCCEEDED; -} static bool get_hw_supported_ddc_line( struct ddc *ddc, enum gpio_ddc_line *line) @@ -469,73 +462,33 @@ void dce_i2c_sw_engine_submit_channel_request( I2C_CHANNEL_OPERATION_SUCCEEDED : I2C_CHANNEL_OPERATION_FAILED; } -bool dce_i2c_sw_engine_submit_request( +bool dce_i2c_sw_engine_submit_payload( struct dce_i2c_sw *engine, - struct dce_i2c_transaction_request *dce_i2c_request, + struct i2c_payload *payload, bool middle_of_transaction) { struct i2c_request_transaction_data request; - bool operation_succeeded = false; - if (dce_i2c_request->operation == DCE_I2C_TRANSACTION_READ) + if (!payload->write) request.action = middle_of_transaction ? DCE_I2C_TRANSACTION_ACTION_I2C_READ_MOT : DCE_I2C_TRANSACTION_ACTION_I2C_READ; - else if (dce_i2c_request->operation == DCE_I2C_TRANSACTION_WRITE) + else request.action = middle_of_transaction ? DCE_I2C_TRANSACTION_ACTION_I2C_WRITE_MOT : DCE_I2C_TRANSACTION_ACTION_I2C_WRITE; - else { - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_INVALID_OPERATION; - /* in DAL2, there was no "return false" */ - return false; - } - request.address = (uint8_t)dce_i2c_request->payload.address; - request.length = dce_i2c_request->payload.length; - request.data = dce_i2c_request->payload.data; + request.address = (uint8_t) ((payload->address << 1) | !payload->write); + request.length = payload->length; + request.data = payload->data; dce_i2c_sw_engine_submit_channel_request(engine, &request); if ((request.status == I2C_CHANNEL_OPERATION_ENGINE_BUSY) || (request.status == I2C_CHANNEL_OPERATION_FAILED)) - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_CHANNEL_BUSY; - else { - enum i2c_channel_operation_result operation_result; - - do { - operation_result = - dce_i2c_sw_engine_get_channel_status(engine, NULL); - - switch (operation_result) { - case I2C_CHANNEL_OPERATION_SUCCEEDED: - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_SUCCEEDED; - operation_succeeded = true; - break; - case I2C_CHANNEL_OPERATION_NO_RESPONSE: - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_NACK; - break; - case I2C_CHANNEL_OPERATION_TIMEOUT: - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_TIMEOUT; - break; - case I2C_CHANNEL_OPERATION_FAILED: - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_INCOMPLETE; - break; - default: - dce_i2c_request->status = - DCE_I2C_TRANSACTION_STATUS_FAILED_OPERATION; - break; - } - } while (operation_result == I2C_CHANNEL_OPERATION_ENGINE_BUSY); - } + return false; - return operation_succeeded; + return true; } bool dce_i2c_submit_command_sw( struct resource_pool *pool, @@ -555,22 +508,8 @@ bool dce_i2c_submit_command_sw( struct i2c_payload *payload = cmd->payloads + index_of_payload; - struct dce_i2c_transaction_request request = { 0 }; - - request.operation = payload->write ? - DCE_I2C_TRANSACTION_WRITE : - DCE_I2C_TRANSACTION_READ; - - request.payload.address_space = - DCE_I2C_TRANSACTION_ADDRESS_SPACE_I2C; - request.payload.address = (payload->address << 1) | - !payload->write; - request.payload.length = payload->length; - request.payload.data = payload->data; - - - if (!dce_i2c_sw_engine_submit_request( - dce_i2c_sw, &request, mot)) { + if (!dce_i2c_sw_engine_submit_payload( + dce_i2c_sw, payload, mot)) { result = false; break; } -- cgit v1.2.3 From ad908423ef86f1787b635a8830d49f50ff862295 Mon Sep 17 00:00:00 2001 From: Eric Yang Date: Wed, 15 Aug 2018 17:35:50 -0400 Subject: drm/amd/display: support 48 MHZ refclk off [Why] On PCO and up, whenever SMU receive message to indicate active display count = 0. SMU will turn off 48MHZ TMDP reference clock by writing to 1 TMDP_48M_Refclk_Driver_PWDN. Once this clock is off, no PHY register will respond to register access. This means our current sequence of notifying display count along with requesting clock will cause driver to hang when accessing PHY registers after displays count goes to 0. [How] Separate the PPSMC_MSG_SetDisplayCount message from the SMU messages that request clocks, have display own sequencing of this message so that we can send it at the appropriate time. Do not redundantly power off HW when entering S3, S4, since display should already be called to disable all streams. And ASIC soon be powered down. Signed-off-by: Eric Yang Reviewed-by: Tony Cheng Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 36 +++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 32318b4e0d1e..1c438eedf77a 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -1367,6 +1367,34 @@ static struct dc_stream_status *stream_get_status( static const enum surface_update_type update_surface_trace_level = UPDATE_TYPE_FULL; +static void notify_display_count_to_smu( + struct dc *dc, + struct dc_state *context) +{ + int i, display_count; + struct pp_smu_funcs_rv *pp_smu = dc->res_pool->pp_smu; + + /* + * if function pointer not set up, this message is + * sent as part of pplib_apply_display_requirements. + * So just return. + */ + if (!pp_smu->set_display_count) + return; + + display_count = 0; + for (i = 0; i < context->stream_count; i++) { + const struct dc_stream_state *stream = context->streams[i]; + + /* only notify active stream */ + if (stream->dpms_off) + continue; + + display_count++; + } + + pp_smu->set_display_count(&pp_smu->pp_smu, display_count); +} static void commit_planes_do_stream_update(struct dc *dc, struct dc_stream_state *stream, @@ -1420,13 +1448,17 @@ static void commit_planes_do_stream_update(struct dc *dc, core_link_disable_stream(pipe_ctx, KEEP_ACQUIRED_RESOURCE); dc->hwss.pplib_apply_display_requirements( dc, dc->current_state); + notify_display_count_to_smu(dc, dc->current_state); } else { dc->hwss.pplib_apply_display_requirements( dc, dc->current_state); + notify_display_count_to_smu(dc, dc->current_state); core_link_enable_stream(dc->current_state, pipe_ctx); } } + + if (stream_update->abm_level && pipe_ctx->stream_res.abm) { if (pipe_ctx->stream_res.tg->funcs->is_blanked) { // if otg funcs defined check if blanked before programming @@ -1662,9 +1694,7 @@ void dc_set_power_state( dc->hwss.init_hw(dc); break; default: - - dc->hwss.power_down(dc); - + ASSERT(dc->current_state->stream_count == 0); /* Zero out the current context so that on resume we start with * clean state, and dc hw programming optimizations will not * cause any trouble. -- cgit v1.2.3 From 9bbf6a5341092e8a9b4e7b02bea6721e29ced9ef Mon Sep 17 00:00:00 2001 From: David Francis Date: Fri, 3 Aug 2018 13:24:28 -0400 Subject: drm/amd/display: Flatten unnecessary i2c functions [Why] The dce_i2c_hw code contained four funtcions that were only called in one place and did not have a clearly delineated purpose. [How] Inline these functions, keeping the same functionality. This is not a functional change. The functions disable_i2c_hw_engine and release_engine_dce_hw were pulled into their respective callers. The most interesting part of this change is the acquire functions. dce_i2c_hw_engine_acquire_engine was pulled into dce_i2c_engine_acquire_hw, and dce_i2c_engine_acquire_hw was pulled into acquire_i2c_hw_engine. Some notes to show that this change is not functional: -Failure conditions in any function resulted in a cascade of calls that ended in a 'return NULL'. Those are replaced with a direct 'return NULL'. -The variable result is the one from dce_i2c_hw_engine_acquire_engine. The boolean result used as part of return logic was removed. -As the second half of dce_i2c_hw_engine_acquire_engine is only executed if that function is returning true and therefore exiting the do-while loop in dce_i2c_engine_acquire_hw, those lines were moved outside of the loop. Signed-off-by: David Francis Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c | 111 ++++++++---------------- 1 file changed, 34 insertions(+), 77 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c index 2800d3fa49da..40f2d6e0b122 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_i2c_hw.c @@ -36,12 +36,6 @@ #define FN(reg_name, field_name) \ dce_i2c_hw->shifts->field_name, dce_i2c_hw->masks->field_name -static void disable_i2c_hw_engine( - struct dce_i2c_hw *dce_i2c_hw) -{ - REG_UPDATE_N(SETUP, 1, FN(SETUP, DC_I2C_DDC1_ENABLE), 0); -} - static void execute_transaction( struct dce_i2c_hw *dce_i2c_hw) { @@ -348,60 +342,40 @@ static void release_engine( REG_UPDATE(DC_I2C_CONTROL, DC_I2C_SW_STATUS_RESET, 1); /* HW I2c engine - clock gating feature */ if (!dce_i2c_hw->engine_keep_power_up_count) - disable_i2c_hw_engine(dce_i2c_hw); + REG_UPDATE_N(SETUP, 1, FN(SETUP, DC_I2C_DDC1_ENABLE), 0); } -static void release_engine_dce_hw( +struct dce_i2c_hw *acquire_i2c_hw_engine( struct resource_pool *pool, - struct dce_i2c_hw *dce_i2c_hw) -{ - pool->i2c_hw_buffer_in_use = false; - - release_engine(dce_i2c_hw); - dal_ddc_close(dce_i2c_hw->ddc); - - dce_i2c_hw->ddc = NULL; -} - -bool dce_i2c_hw_engine_acquire_engine( - struct dce_i2c_hw *dce_i2c_hw, struct ddc *ddc) { - + uint32_t counter = 0; enum gpio_result result; uint32_t current_speed; + struct dce_i2c_hw *dce_i2c_hw = NULL; - result = dal_ddc_open(ddc, GPIO_MODE_HARDWARE, - GPIO_DDC_CONFIG_TYPE_MODE_I2C); - - if (result != GPIO_RESULT_OK) - return false; - - dce_i2c_hw->ddc = ddc; - - - current_speed = get_speed(dce_i2c_hw); + if (!ddc) + return NULL; - if (current_speed) - dce_i2c_hw->original_speed = current_speed; + if (ddc->hw_info.hw_supported) { + enum gpio_ddc_line line = dal_ddc_get_line(ddc); - return true; -} + if (line < pool->pipe_count) + dce_i2c_hw = pool->hw_i2cs[line]; + } -bool dce_i2c_engine_acquire_hw( - struct dce_i2c_hw *dce_i2c_hw, - struct ddc *ddc_handle) -{ + if (!dce_i2c_hw) + return NULL; - uint32_t counter = 0; - bool result; + if (pool->i2c_hw_buffer_in_use) + return NULL; do { - result = dce_i2c_hw_engine_acquire_engine( - dce_i2c_hw, ddc_handle); + result = dal_ddc_open(ddc, GPIO_MODE_HARDWARE, + GPIO_DDC_CONFIG_TYPE_MODE_I2C); - if (result) + if (result == GPIO_RESULT_OK) break; /* i2c_engine is busy by VBios, lets wait and retry */ @@ -411,45 +385,23 @@ bool dce_i2c_engine_acquire_hw( ++counter; } while (counter < 2); - if (result) { - if (!setup_engine(dce_i2c_hw)) { - release_engine(dce_i2c_hw); - result = false; - } - } - - return result; -} - -struct dce_i2c_hw *acquire_i2c_hw_engine( - struct resource_pool *pool, - struct ddc *ddc) -{ - - struct dce_i2c_hw *engine = NULL; - - if (!ddc) + if (result != GPIO_RESULT_OK) return NULL; - if (ddc->hw_info.hw_supported) { - enum gpio_ddc_line line = dal_ddc_get_line(ddc); - - if (line < pool->pipe_count) - engine = pool->hw_i2cs[line]; - } + dce_i2c_hw->ddc = ddc; - if (!engine) - return NULL; + current_speed = get_speed(dce_i2c_hw); + if (current_speed) + dce_i2c_hw->original_speed = current_speed; - if (!pool->i2c_hw_buffer_in_use && - dce_i2c_engine_acquire_hw(engine, ddc)) { - pool->i2c_hw_buffer_in_use = true; - return engine; + if (!setup_engine(dce_i2c_hw)) { + release_engine(dce_i2c_hw); + return NULL; } - - return NULL; + pool->i2c_hw_buffer_in_use = true; + return dce_i2c_hw; } enum i2c_channel_operation_result dce_i2c_hw_engine_wait_on_operation_result( @@ -619,7 +571,12 @@ bool dce_i2c_submit_command_hw( ++index_of_payload; } - release_engine_dce_hw(pool, dce_i2c_hw); + pool->i2c_hw_buffer_in_use = false; + + release_engine(dce_i2c_hw); + dal_ddc_close(dce_i2c_hw->ddc); + + dce_i2c_hw->ddc = NULL; return result; } -- cgit v1.2.3 From 43c40a02c1b1bbedbf7c1c10392cf885a0bb3f46 Mon Sep 17 00:00:00 2001 From: Tony Cheng Date: Wed, 18 Jul 2018 20:30:09 -0400 Subject: drm/amd/display: dc 3.1.64 Signed-off-by: Tony Cheng Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index 2faff1b8821d..dee0f28e683d 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -38,7 +38,7 @@ #include "inc/compressor.h" #include "dml/display_mode_lib.h" -#define DC_VER "3.1.63" +#define DC_VER "3.1.64" #define MAX_SURFACES 3 #define MAX_STREAMS 6 -- cgit v1.2.3 From 550db288129591c4b2f669d724f12e43a380c286 Mon Sep 17 00:00:00 2001 From: Gary Kattan Date: Mon, 20 Aug 2018 15:12:14 -0700 Subject: drm/amd/display: Fix DAL217 tests modify DTN logs for other tests [Why]Update Code to get DTN golden log check to pass for tests run after DAL217 tests. [How]Change how dcn10_log_hw_state function prints HW state info (CM_GAMUT_REMAP_Cx_Cx registers) when GAMUT REMAP is in bypass mode. Signed-off-by: Gary Kattan Reviewed-by: Dmytro Laktyushkin Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c index 5f2054a1d563..dcb3c5530236 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c @@ -116,12 +116,14 @@ void dpp_read_state(struct dpp *dpp_base, REG_GET(CM_GAMUT_REMAP_CONTROL, CM_GAMUT_REMAP_MODE, &s->gamut_remap_mode); - s->gamut_remap_c11_c12 = REG_READ(CM_GAMUT_REMAP_C11_C12); - s->gamut_remap_c13_c14 = REG_READ(CM_GAMUT_REMAP_C13_C14); - s->gamut_remap_c21_c22 = REG_READ(CM_GAMUT_REMAP_C21_C22); - s->gamut_remap_c23_c24 = REG_READ(CM_GAMUT_REMAP_C23_C24); - s->gamut_remap_c31_c32 = REG_READ(CM_GAMUT_REMAP_C31_C32); - s->gamut_remap_c33_c34 = REG_READ(CM_GAMUT_REMAP_C33_C34); + if (s->gamut_remap_mode) { + s->gamut_remap_c11_c12 = REG_READ(CM_GAMUT_REMAP_C11_C12); + s->gamut_remap_c13_c14 = REG_READ(CM_GAMUT_REMAP_C13_C14); + s->gamut_remap_c21_c22 = REG_READ(CM_GAMUT_REMAP_C21_C22); + s->gamut_remap_c23_c24 = REG_READ(CM_GAMUT_REMAP_C23_C24); + s->gamut_remap_c31_c32 = REG_READ(CM_GAMUT_REMAP_C31_C32); + s->gamut_remap_c33_c34 = REG_READ(CM_GAMUT_REMAP_C33_C34); + } } /* Program gamut remap in bypass mode */ -- cgit v1.2.3 From 61ea4c6f70ffd18eed7fc0d3fb678245f499c756 Mon Sep 17 00:00:00 2001 From: Jun Lei Date: Mon, 13 Aug 2018 15:11:44 -0400 Subject: drm/amd/display: Add driver-side parsing for CM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Although 4 unique register values exist for gamma modes, two are actually the same (the two RAMs) It’s not possible for caller to understand this HW specific behavior, so some parsing is necessary in driver Signed-off-by: Jun Lei Reviewed-by: Wesley Chalmers Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- .../display/dc/dcn10/dcn10_hw_sequencer_debug.c | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c index 9288b00e49b4..9c218252004f 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c @@ -314,14 +314,35 @@ static unsigned int dcn10_get_cm_states(struct dc *dc, char *pBuf, unsigned int struct dpp *dpp = pool->dpps[i]; struct dcn_dpp_state s = {0}; + + + dpp->funcs->dpp_read_state(dpp, &s); if (s.is_enabled) { - chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%x,%x,%x,%x,%x," - "%08x,%08x,%08x,%08x,%08x,%08x" + chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%x," + "%s,%s,%s," + "%x,%08x,%08x,%08x,%08x,%08x,%08x" "\n", - dpp->inst, s.igam_input_format, s.igam_lut_mode, s.dgam_lut_mode, - s.rgam_lut_mode, s.gamut_remap_mode, s.gamut_remap_c11_c12, + dpp->inst, s.igam_input_format, + (s.igam_lut_mode == 0) ? "BypassFixed" : + ((s.igam_lut_mode == 1) ? "BypassFloat" : + ((s.igam_lut_mode == 2) ? "RAM" : + ((s.igam_lut_mode == 3) ? "RAM" : + "Unknown"))), + (s.dgam_lut_mode == 0) ? "Bypass" : + ((s.dgam_lut_mode == 1) ? "sRGB" : + ((s.dgam_lut_mode == 2) ? "Ycc" : + ((s.dgam_lut_mode == 3) ? "RAM" : + ((s.dgam_lut_mode == 4) ? "RAM" : + "Unknown")))), + (s.rgam_lut_mode == 0) ? "Bypass" : + ((s.rgam_lut_mode == 1) ? "sRGB" : + ((s.rgam_lut_mode == 2) ? "Ycc" : + ((s.rgam_lut_mode == 3) ? "RAM" : + ((s.rgam_lut_mode == 4) ? "RAM" : + "Unknown")))), + s.gamut_remap_mode, s.gamut_remap_c11_c12, s.gamut_remap_c13_c14, s.gamut_remap_c21_c22, s.gamut_remap_c23_c24, s.gamut_remap_c31_c32, s.gamut_remap_c33_c34); -- cgit v1.2.3 From 5a8132b9f6063b36369b2afd85112ff37d56e183 Mon Sep 17 00:00:00 2001 From: Dmytro Laktyushkin Date: Tue, 14 Aug 2018 16:12:54 -0400 Subject: drm/amd/display: remove dead dc vbios code Signed-off-by: Dmytro Laktyushkin Reviewed-by: Charlene Liu Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/bios/bios_parser.c | 1177 -------------------- drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | 312 +----- drivers/gpu/drm/amd/display/dc/dc_bios_types.h | 64 -- 3 files changed, 39 insertions(+), 1514 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c index bfa5816cfc92..0e1dc1b1a48d 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c @@ -52,24 +52,13 @@ #define DC_LOGGER \ bp->base.ctx->logger -/* GUID to validate external display connection info table (aka OPM module) */ -static const uint8_t ext_display_connection_guid[NUMBER_OF_UCHAR_FOR_GUID] = { - 0x91, 0x6E, 0x57, 0x09, - 0x3F, 0x6D, 0xD2, 0x11, - 0x39, 0x8E, 0x00, 0xA0, - 0xC9, 0x69, 0x72, 0x3B}; - #define DATA_TABLES(table) (bp->master_data_tbl->ListOfDataTables.table) static void get_atom_data_table_revision( ATOM_COMMON_TABLE_HEADER *atom_data_tbl, struct atom_data_revision *tbl_revision); -static uint32_t get_dst_number_from_object(struct bios_parser *bp, - ATOM_OBJECT *object); static uint32_t get_src_obj_list(struct bios_parser *bp, ATOM_OBJECT *object, uint16_t **id_list); -static uint32_t get_dest_obj_list(struct bios_parser *bp, - ATOM_OBJECT *object, uint16_t **id_list); static ATOM_OBJECT *get_bios_object(struct bios_parser *bp, struct graphics_object_id id); static enum bp_result get_gpio_i2c_info(struct bios_parser *bp, @@ -163,29 +152,6 @@ static uint8_t bios_parser_get_connectors_number(struct dc_bios *dcb) le16_to_cpu(bp->object_info_tbl.v1_1->usConnectorObjectTableOffset)); } -static struct graphics_object_id bios_parser_get_encoder_id( - struct dc_bios *dcb, - uint32_t i) -{ - struct bios_parser *bp = BP_FROM_DCB(dcb); - struct graphics_object_id object_id = dal_graphics_object_id_init( - 0, ENUM_ID_UNKNOWN, OBJECT_TYPE_UNKNOWN); - - uint32_t encoder_table_offset = bp->object_info_tbl_offset - + le16_to_cpu(bp->object_info_tbl.v1_1->usEncoderObjectTableOffset); - - ATOM_OBJECT_TABLE *tbl = - GET_IMAGE(ATOM_OBJECT_TABLE, encoder_table_offset); - - if (tbl && tbl->ucNumberOfObjects > i) { - const uint16_t id = le16_to_cpu(tbl->asObjects[i].usObjectID); - - object_id = object_id_from_bios_object_id(id); - } - - return object_id; -} - static struct graphics_object_id bios_parser_get_connector_id( struct dc_bios *dcb, uint8_t i) @@ -217,15 +183,6 @@ static struct graphics_object_id bios_parser_get_connector_id( return object_id; } -static uint32_t bios_parser_get_dst_number(struct dc_bios *dcb, - struct graphics_object_id id) -{ - struct bios_parser *bp = BP_FROM_DCB(dcb); - ATOM_OBJECT *object = get_bios_object(bp, id); - - return get_dst_number_from_object(bp, object); -} - static enum bp_result bios_parser_get_src_obj(struct dc_bios *dcb, struct graphics_object_id object_id, uint32_t index, struct graphics_object_id *src_object_id) @@ -255,30 +212,6 @@ static enum bp_result bios_parser_get_src_obj(struct dc_bios *dcb, return BP_RESULT_OK; } -static enum bp_result bios_parser_get_dst_obj(struct dc_bios *dcb, - struct graphics_object_id object_id, uint32_t index, - struct graphics_object_id *dest_object_id) -{ - uint32_t number; - uint16_t *id = NULL; - ATOM_OBJECT *object; - struct bios_parser *bp = BP_FROM_DCB(dcb); - - if (!dest_object_id) - return BP_RESULT_BADINPUT; - - object = get_bios_object(bp, object_id); - - number = get_dest_obj_list(bp, object, &id); - - if (number <= index || !id) - return BP_RESULT_BADINPUT; - - *dest_object_id = object_id_from_bios_object_id(id[index]); - - return BP_RESULT_OK; -} - static enum bp_result bios_parser_get_i2c_info(struct dc_bios *dcb, struct graphics_object_id id, struct graphics_object_i2c_info *info) @@ -325,196 +258,6 @@ static enum bp_result bios_parser_get_i2c_info(struct dc_bios *dcb, return BP_RESULT_NORECORD; } -static enum bp_result get_voltage_ddc_info_v1(uint8_t *i2c_line, - ATOM_COMMON_TABLE_HEADER *header, - uint8_t *address) -{ - enum bp_result result = BP_RESULT_NORECORD; - ATOM_VOLTAGE_OBJECT_INFO *info = - (ATOM_VOLTAGE_OBJECT_INFO *) address; - - uint8_t *voltage_current_object = (uint8_t *) &info->asVoltageObj[0]; - - while ((address + le16_to_cpu(header->usStructureSize)) > voltage_current_object) { - ATOM_VOLTAGE_OBJECT *object = - (ATOM_VOLTAGE_OBJECT *) voltage_current_object; - - if ((object->ucVoltageType == SET_VOLTAGE_INIT_MODE) && - (object->ucVoltageType & - VOLTAGE_CONTROLLED_BY_I2C_MASK)) { - - *i2c_line = object->asControl.ucVoltageControlI2cLine - ^ 0x90; - result = BP_RESULT_OK; - break; - } - - voltage_current_object += object->ucSize; - } - return result; -} - -static enum bp_result get_voltage_ddc_info_v3(uint8_t *i2c_line, - uint32_t index, - ATOM_COMMON_TABLE_HEADER *header, - uint8_t *address) -{ - enum bp_result result = BP_RESULT_NORECORD; - ATOM_VOLTAGE_OBJECT_INFO_V3_1 *info = - (ATOM_VOLTAGE_OBJECT_INFO_V3_1 *) address; - - uint8_t *voltage_current_object = - (uint8_t *) (&(info->asVoltageObj[0])); - - while ((address + le16_to_cpu(header->usStructureSize)) > voltage_current_object) { - ATOM_I2C_VOLTAGE_OBJECT_V3 *object = - (ATOM_I2C_VOLTAGE_OBJECT_V3 *) voltage_current_object; - - if (object->sHeader.ucVoltageMode == - ATOM_INIT_VOLTAGE_REGULATOR) { - if (object->sHeader.ucVoltageType == index) { - *i2c_line = object->ucVoltageControlI2cLine - ^ 0x90; - result = BP_RESULT_OK; - break; - } - } - - voltage_current_object += le16_to_cpu(object->sHeader.usSize); - } - return result; -} - -static enum bp_result bios_parser_get_thermal_ddc_info( - struct dc_bios *dcb, - uint32_t i2c_channel_id, - struct graphics_object_i2c_info *info) -{ - struct bios_parser *bp = BP_FROM_DCB(dcb); - ATOM_I2C_ID_CONFIG_ACCESS *config; - ATOM_I2C_RECORD record; - - if (!info) - return BP_RESULT_BADINPUT; - - config = (ATOM_I2C_ID_CONFIG_ACCESS *) &i2c_channel_id; - - record.sucI2cId.bfHW_Capable = config->sbfAccess.bfHW_Capable; - record.sucI2cId.bfI2C_LineMux = config->sbfAccess.bfI2C_LineMux; - record.sucI2cId.bfHW_EngineID = config->sbfAccess.bfHW_EngineID; - - return get_gpio_i2c_info(bp, &record, info); -} - -static enum bp_result bios_parser_get_voltage_ddc_info(struct dc_bios *dcb, - uint32_t index, - struct graphics_object_i2c_info *info) -{ - uint8_t i2c_line = 0; - enum bp_result result = BP_RESULT_NORECORD; - uint8_t *voltage_info_address; - ATOM_COMMON_TABLE_HEADER *header; - struct atom_data_revision revision = {0}; - struct bios_parser *bp = BP_FROM_DCB(dcb); - - if (!DATA_TABLES(VoltageObjectInfo)) - return result; - - voltage_info_address = bios_get_image(&bp->base, DATA_TABLES(VoltageObjectInfo), sizeof(ATOM_COMMON_TABLE_HEADER)); - - header = (ATOM_COMMON_TABLE_HEADER *) voltage_info_address; - - get_atom_data_table_revision(header, &revision); - - switch (revision.major) { - case 1: - case 2: - result = get_voltage_ddc_info_v1(&i2c_line, header, - voltage_info_address); - break; - case 3: - if (revision.minor != 1) - break; - result = get_voltage_ddc_info_v3(&i2c_line, index, header, - voltage_info_address); - break; - } - - if (result == BP_RESULT_OK) - result = bios_parser_get_thermal_ddc_info(dcb, - i2c_line, info); - - return result; -} - -/* TODO: temporary commented out to suppress 'defined but not used' warning */ -#if 0 -static enum bp_result bios_parser_get_ddc_info_for_i2c_line( - struct bios_parser *bp, - uint8_t i2c_line, struct graphics_object_i2c_info *info) -{ - uint32_t offset; - ATOM_OBJECT *object; - ATOM_OBJECT_TABLE *table; - uint32_t i; - - if (!info) - return BP_RESULT_BADINPUT; - - offset = le16_to_cpu(bp->object_info_tbl.v1_1->usConnectorObjectTableOffset); - - offset += bp->object_info_tbl_offset; - - table = GET_IMAGE(ATOM_OBJECT_TABLE, offset); - - if (!table) - return BP_RESULT_BADBIOSTABLE; - - for (i = 0; i < table->ucNumberOfObjects; i++) { - object = &table->asObjects[i]; - - if (!object) { - BREAK_TO_DEBUGGER(); /* Invalid object id */ - return BP_RESULT_BADINPUT; - } - - offset = le16_to_cpu(object->usRecordOffset) - + bp->object_info_tbl_offset; - - for (;;) { - ATOM_COMMON_RECORD_HEADER *header = - GET_IMAGE(ATOM_COMMON_RECORD_HEADER, offset); - - if (!header) - return BP_RESULT_BADBIOSTABLE; - - offset += header->ucRecordSize; - - if (LAST_RECORD_TYPE == header->ucRecordType || - !header->ucRecordSize) - break; - - if (ATOM_I2C_RECORD_TYPE == header->ucRecordType - && sizeof(ATOM_I2C_RECORD) <= - header->ucRecordSize) { - ATOM_I2C_RECORD *record = - (ATOM_I2C_RECORD *) header; - - if (i2c_line != record->sucI2cId.bfI2C_LineMux) - continue; - - /* get the I2C info */ - if (get_gpio_i2c_info(bp, record, info) == - BP_RESULT_OK) - return BP_RESULT_OK; - } - } - } - - return BP_RESULT_NORECORD; -} -#endif - static enum bp_result bios_parser_get_hpd_info(struct dc_bios *dcb, struct graphics_object_id id, struct graphics_object_hpd_info *info) @@ -1129,62 +872,6 @@ static bool bios_parser_is_device_id_supported( return (le16_to_cpu(bp->object_info_tbl.v1_1->usDeviceSupport) & mask) != 0; } -static enum bp_result bios_parser_crt_control( - struct dc_bios *dcb, - enum engine_id engine_id, - bool enable, - uint32_t pixel_clock) -{ - struct bios_parser *bp = BP_FROM_DCB(dcb); - uint8_t standard; - - if (!bp->cmd_tbl.dac1_encoder_control && - engine_id == ENGINE_ID_DACA) - return BP_RESULT_FAILURE; - if (!bp->cmd_tbl.dac2_encoder_control && - engine_id == ENGINE_ID_DACB) - return BP_RESULT_FAILURE; - /* validate params */ - switch (engine_id) { - case ENGINE_ID_DACA: - case ENGINE_ID_DACB: - break; - default: - /* unsupported engine */ - return BP_RESULT_FAILURE; - } - - standard = ATOM_DAC1_PS2; /* == ATOM_DAC2_PS2 */ - - if (enable) { - if (engine_id == ENGINE_ID_DACA) { - bp->cmd_tbl.dac1_encoder_control(bp, enable, - pixel_clock, standard); - if (bp->cmd_tbl.dac1_output_control != NULL) - bp->cmd_tbl.dac1_output_control(bp, enable); - } else { - bp->cmd_tbl.dac2_encoder_control(bp, enable, - pixel_clock, standard); - if (bp->cmd_tbl.dac2_output_control != NULL) - bp->cmd_tbl.dac2_output_control(bp, enable); - } - } else { - if (engine_id == ENGINE_ID_DACA) { - if (bp->cmd_tbl.dac1_output_control != NULL) - bp->cmd_tbl.dac1_output_control(bp, enable); - bp->cmd_tbl.dac1_encoder_control(bp, enable, - pixel_clock, standard); - } else { - if (bp->cmd_tbl.dac2_output_control != NULL) - bp->cmd_tbl.dac2_output_control(bp, enable); - bp->cmd_tbl.dac2_encoder_control(bp, enable, - pixel_clock, standard); - } - } - - return BP_RESULT_OK; -} - static ATOM_HPD_INT_RECORD *get_hpd_record(struct bios_parser *bp, ATOM_OBJECT *object) { @@ -1219,49 +906,6 @@ static ATOM_HPD_INT_RECORD *get_hpd_record(struct bios_parser *bp, return NULL; } -/** - * Get I2C information of input object id - * - * search all records to find the ATOM_I2C_RECORD_TYPE record IR - */ -static ATOM_I2C_RECORD *get_i2c_record( - struct bios_parser *bp, - ATOM_OBJECT *object) -{ - uint32_t offset; - ATOM_COMMON_RECORD_HEADER *record_header; - - if (!object) { - BREAK_TO_DEBUGGER(); - /* Invalid object */ - return NULL; - } - - offset = le16_to_cpu(object->usRecordOffset) - + bp->object_info_tbl_offset; - - for (;;) { - record_header = GET_IMAGE(ATOM_COMMON_RECORD_HEADER, offset); - - if (!record_header) - return NULL; - - if (LAST_RECORD_TYPE == record_header->ucRecordType || - 0 == record_header->ucRecordSize) - break; - - if (ATOM_I2C_RECORD_TYPE == record_header->ucRecordType && - sizeof(ATOM_I2C_RECORD) <= - record_header->ucRecordSize) { - return (ATOM_I2C_RECORD *)record_header; - } - - offset += record_header->ucRecordSize; - } - - return NULL; -} - static enum bp_result get_ss_info_from_ss_info_table( struct bios_parser *bp, uint32_t id, @@ -2356,40 +2000,6 @@ static ATOM_OBJECT *get_bios_object(struct bios_parser *bp, return NULL; } -static uint32_t get_dest_obj_list(struct bios_parser *bp, - ATOM_OBJECT *object, uint16_t **id_list) -{ - uint32_t offset; - uint8_t *number; - - if (!object) { - BREAK_TO_DEBUGGER(); /* Invalid object id */ - return 0; - } - - offset = le16_to_cpu(object->usSrcDstTableOffset) - + bp->object_info_tbl_offset; - - number = GET_IMAGE(uint8_t, offset); - if (!number) - return 0; - - offset += sizeof(uint8_t); - offset += sizeof(uint16_t) * (*number); - - number = GET_IMAGE(uint8_t, offset); - if ((!number) || (!*number)) - return 0; - - offset += sizeof(uint8_t); - *id_list = (uint16_t *)bios_get_image(&bp->base, offset, *number * sizeof(uint16_t)); - - if (!*id_list) - return 0; - - return *number; -} - static uint32_t get_src_obj_list(struct bios_parser *bp, ATOM_OBJECT *object, uint16_t **id_list) { @@ -2417,35 +2027,6 @@ static uint32_t get_src_obj_list(struct bios_parser *bp, ATOM_OBJECT *object, return *number; } -static uint32_t get_dst_number_from_object(struct bios_parser *bp, - ATOM_OBJECT *object) -{ - uint32_t offset; - uint8_t *number; - - if (!object) { - BREAK_TO_DEBUGGER(); /* Invalid encoder object id*/ - return 0; - } - - offset = le16_to_cpu(object->usSrcDstTableOffset) - + bp->object_info_tbl_offset; - - number = GET_IMAGE(uint8_t, offset); - if (!number) - return 0; - - offset += sizeof(uint8_t); - offset += sizeof(uint16_t) * (*number); - - number = GET_IMAGE(uint8_t, offset); - - if (!number) - return 0; - - return *number; -} - static struct device_id device_type_from_device_id(uint16_t device_id) { @@ -2624,750 +2205,6 @@ static uint32_t get_support_mask_for_device_id(struct device_id device_id) return 0; } -/** - * HwContext interface for writing MM registers - */ - -static bool i2c_read( - struct bios_parser *bp, - struct graphics_object_i2c_info *i2c_info, - uint8_t *buffer, - uint32_t length) -{ - struct ddc *ddc; - uint8_t offset[2] = { 0, 0 }; - bool result = false; - struct i2c_command cmd; - struct gpio_ddc_hw_info hw_info = { - i2c_info->i2c_hw_assist, - i2c_info->i2c_line }; - - ddc = dal_gpio_create_ddc(bp->base.ctx->gpio_service, - i2c_info->gpio_info.clk_a_register_index, - (1 << i2c_info->gpio_info.clk_a_shift), &hw_info); - - if (!ddc) - return result; - - /*Using SW engine */ - cmd.engine = I2C_COMMAND_ENGINE_SW; - cmd.speed = ddc->ctx->dc->caps.i2c_speed_in_khz; - - { - struct i2c_payload payloads[] = { - { - .address = i2c_info->i2c_slave_address >> 1, - .data = offset, - .length = sizeof(offset), - .write = true - }, - { - .address = i2c_info->i2c_slave_address >> 1, - .data = buffer, - .length = length, - .write = false - } - }; - - cmd.payloads = payloads; - cmd.number_of_payloads = ARRAY_SIZE(payloads); - result = dc_submit_i2c( - ddc->ctx->dc, - ddc->hw_info.ddc_channel, - &cmd); - } - - dal_gpio_destroy_ddc(&ddc); - - return result; -} - -/** - * Read external display connection info table through i2c. - * validate the GUID and checksum. - * - * @return enum bp_result whether all data was sucessfully read - */ -static enum bp_result get_ext_display_connection_info( - struct bios_parser *bp, - ATOM_OBJECT *opm_object, - ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO *ext_display_connection_info_tbl) -{ - bool config_tbl_present = false; - ATOM_I2C_RECORD *i2c_record = NULL; - uint32_t i = 0; - - if (opm_object == NULL) - return BP_RESULT_BADINPUT; - - i2c_record = get_i2c_record(bp, opm_object); - - if (i2c_record != NULL) { - ATOM_GPIO_I2C_INFO *gpio_i2c_header; - struct graphics_object_i2c_info i2c_info; - - gpio_i2c_header = GET_IMAGE(ATOM_GPIO_I2C_INFO, - bp->master_data_tbl->ListOfDataTables.GPIO_I2C_Info); - - if (NULL == gpio_i2c_header) - return BP_RESULT_BADBIOSTABLE; - - if (get_gpio_i2c_info(bp, i2c_record, &i2c_info) != - BP_RESULT_OK) - return BP_RESULT_BADBIOSTABLE; - - if (i2c_read(bp, - &i2c_info, - (uint8_t *)ext_display_connection_info_tbl, - sizeof(ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO))) { - config_tbl_present = true; - } - } - - /* Validate GUID */ - if (config_tbl_present) - for (i = 0; i < NUMBER_OF_UCHAR_FOR_GUID; i++) { - if (ext_display_connection_info_tbl->ucGuid[i] - != ext_display_connection_guid[i]) { - config_tbl_present = false; - break; - } - } - - /* Validate checksum */ - if (config_tbl_present) { - uint8_t check_sum = 0; - uint8_t *buf = - (uint8_t *)ext_display_connection_info_tbl; - - for (i = 0; i < sizeof(ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO); - i++) { - check_sum += buf[i]; - } - - if (check_sum != 0) - config_tbl_present = false; - } - - if (config_tbl_present) - return BP_RESULT_OK; - else - return BP_RESULT_FAILURE; -} - -/* - * Gets the first device ID in the same group as the given ID for enumerating. - * For instance, if any DFP device ID is passed, returns the device ID for DFP1. - * - * The first device ID in the same group as the passed device ID, or 0 if no - * matching device group found. - */ -static uint32_t enum_first_device_id(uint32_t dev_id) -{ - /* Return the first in the group that this ID belongs to. */ - if (dev_id & ATOM_DEVICE_CRT_SUPPORT) - return ATOM_DEVICE_CRT1_SUPPORT; - else if (dev_id & ATOM_DEVICE_DFP_SUPPORT) - return ATOM_DEVICE_DFP1_SUPPORT; - else if (dev_id & ATOM_DEVICE_LCD_SUPPORT) - return ATOM_DEVICE_LCD1_SUPPORT; - else if (dev_id & ATOM_DEVICE_TV_SUPPORT) - return ATOM_DEVICE_TV1_SUPPORT; - else if (dev_id & ATOM_DEVICE_CV_SUPPORT) - return ATOM_DEVICE_CV_SUPPORT; - - /* No group found for this device ID. */ - - dm_error("%s: incorrect input %d\n", __func__, dev_id); - /* No matching support flag for given device ID */ - return 0; -} - -/* - * Gets the next device ID in the group for a given device ID. - * - * The current device ID being enumerated on. - * - * The next device ID in the group, or 0 if no device exists. - */ -static uint32_t enum_next_dev_id(uint32_t dev_id) -{ - /* Get next device ID in the group. */ - switch (dev_id) { - case ATOM_DEVICE_CRT1_SUPPORT: - return ATOM_DEVICE_CRT2_SUPPORT; - case ATOM_DEVICE_LCD1_SUPPORT: - return ATOM_DEVICE_LCD2_SUPPORT; - case ATOM_DEVICE_DFP1_SUPPORT: - return ATOM_DEVICE_DFP2_SUPPORT; - case ATOM_DEVICE_DFP2_SUPPORT: - return ATOM_DEVICE_DFP3_SUPPORT; - case ATOM_DEVICE_DFP3_SUPPORT: - return ATOM_DEVICE_DFP4_SUPPORT; - case ATOM_DEVICE_DFP4_SUPPORT: - return ATOM_DEVICE_DFP5_SUPPORT; - case ATOM_DEVICE_DFP5_SUPPORT: - return ATOM_DEVICE_DFP6_SUPPORT; - } - - /* Done enumerating through devices. */ - return 0; -} - -/* - * Returns the new device tag record for patched BIOS object. - * - * [IN] pExtDisplayPath - External display path to copy device tag from. - * [IN] deviceSupport - Bit vector for device ID support flags. - * [OUT] pDeviceTag - Device tag structure to fill with patched data. - * - * True if a compatible device ID was found, false otherwise. - */ -static bool get_patched_device_tag( - struct bios_parser *bp, - EXT_DISPLAY_PATH *ext_display_path, - uint32_t device_support, - ATOM_CONNECTOR_DEVICE_TAG *device_tag) -{ - uint32_t dev_id; - /* Use fallback behaviour if not supported. */ - if (!bp->remap_device_tags) { - device_tag->ulACPIDeviceEnum = - cpu_to_le32((uint32_t) le16_to_cpu(ext_display_path->usDeviceACPIEnum)); - device_tag->usDeviceID = - cpu_to_le16(le16_to_cpu(ext_display_path->usDeviceTag)); - return true; - } - - /* Find the first unused in the same group. */ - dev_id = enum_first_device_id(le16_to_cpu(ext_display_path->usDeviceTag)); - while (dev_id != 0) { - /* Assign this device ID if supported. */ - if ((device_support & dev_id) != 0) { - device_tag->ulACPIDeviceEnum = - cpu_to_le32((uint32_t) le16_to_cpu(ext_display_path->usDeviceACPIEnum)); - device_tag->usDeviceID = cpu_to_le16((USHORT) dev_id); - return true; - } - - dev_id = enum_next_dev_id(dev_id); - } - - /* No compatible device ID found. */ - return false; -} - -/* - * Adds a device tag to a BIOS object's device tag record if there is - * matching device ID supported. - * - * pObject - Pointer to the BIOS object to add the device tag to. - * pExtDisplayPath - Display path to retrieve base device ID from. - * pDeviceSupport - Pointer to bit vector for supported device IDs. - */ -static void add_device_tag_from_ext_display_path( - struct bios_parser *bp, - ATOM_OBJECT *object, - EXT_DISPLAY_PATH *ext_display_path, - uint32_t *device_support) -{ - /* Get device tag record for object. */ - ATOM_CONNECTOR_DEVICE_TAG *device_tag = NULL; - ATOM_CONNECTOR_DEVICE_TAG_RECORD *device_tag_record = NULL; - enum bp_result result = - bios_parser_get_device_tag_record( - bp, object, &device_tag_record); - - if ((le16_to_cpu(ext_display_path->usDeviceTag) != CONNECTOR_OBJECT_ID_NONE) - && (result == BP_RESULT_OK)) { - uint8_t index; - - if ((device_tag_record->ucNumberOfDevice == 1) && - (le16_to_cpu(device_tag_record->asDeviceTag[0].usDeviceID) == 0)) { - /*Workaround bug in current VBIOS releases where - * ucNumberOfDevice = 1 but there is no actual device - * tag data. This w/a is temporary until the updated - * VBIOS is distributed. */ - device_tag_record->ucNumberOfDevice = - device_tag_record->ucNumberOfDevice - 1; - } - - /* Attempt to find a matching device ID. */ - index = device_tag_record->ucNumberOfDevice; - device_tag = &device_tag_record->asDeviceTag[index]; - if (get_patched_device_tag( - bp, - ext_display_path, - *device_support, - device_tag)) { - /* Update cached device support to remove assigned ID. - */ - *device_support &= ~le16_to_cpu(device_tag->usDeviceID); - device_tag_record->ucNumberOfDevice++; - } - } -} - -/* - * Read out a single EXT_DISPLAY_PATH from the external display connection info - * table. The specific entry in the table is determined by the enum_id passed - * in. - * - * EXT_DISPLAY_PATH describing a single Configuration table entry - */ - -#define INVALID_CONNECTOR 0xffff - -static EXT_DISPLAY_PATH *get_ext_display_path_entry( - ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO *config_table, - uint32_t bios_object_id) -{ - EXT_DISPLAY_PATH *ext_display_path; - uint32_t ext_display_path_index = - ((bios_object_id & ENUM_ID_MASK) >> ENUM_ID_SHIFT) - 1; - - if (ext_display_path_index >= MAX_NUMBER_OF_EXT_DISPLAY_PATH) - return NULL; - - ext_display_path = &config_table->sPath[ext_display_path_index]; - - if (le16_to_cpu(ext_display_path->usDeviceConnector) == INVALID_CONNECTOR) - ext_display_path->usDeviceConnector = cpu_to_le16(0); - - return ext_display_path; -} - -/* - * Get AUX/DDC information of input object id - * - * search all records to find the ATOM_CONNECTOR_AUXDDC_LUT_RECORD_TYPE record - * IR - */ -static ATOM_CONNECTOR_AUXDDC_LUT_RECORD *get_ext_connector_aux_ddc_lut_record( - struct bios_parser *bp, - ATOM_OBJECT *object) -{ - uint32_t offset; - ATOM_COMMON_RECORD_HEADER *header; - - if (!object) { - BREAK_TO_DEBUGGER(); - /* Invalid object */ - return NULL; - } - - offset = le16_to_cpu(object->usRecordOffset) - + bp->object_info_tbl_offset; - - for (;;) { - header = GET_IMAGE(ATOM_COMMON_RECORD_HEADER, offset); - - if (!header) - return NULL; - - if (LAST_RECORD_TYPE == header->ucRecordType || - 0 == header->ucRecordSize) - break; - - if (ATOM_CONNECTOR_AUXDDC_LUT_RECORD_TYPE == - header->ucRecordType && - sizeof(ATOM_CONNECTOR_AUXDDC_LUT_RECORD) <= - header->ucRecordSize) - return (ATOM_CONNECTOR_AUXDDC_LUT_RECORD *)(header); - - offset += header->ucRecordSize; - } - - return NULL; -} - -/* - * Get AUX/DDC information of input object id - * - * search all records to find the ATOM_CONNECTOR_AUXDDC_LUT_RECORD_TYPE record - * IR - */ -static ATOM_CONNECTOR_HPDPIN_LUT_RECORD *get_ext_connector_hpd_pin_lut_record( - struct bios_parser *bp, - ATOM_OBJECT *object) -{ - uint32_t offset; - ATOM_COMMON_RECORD_HEADER *header; - - if (!object) { - BREAK_TO_DEBUGGER(); - /* Invalid object */ - return NULL; - } - - offset = le16_to_cpu(object->usRecordOffset) - + bp->object_info_tbl_offset; - - for (;;) { - header = GET_IMAGE(ATOM_COMMON_RECORD_HEADER, offset); - - if (!header) - return NULL; - - if (LAST_RECORD_TYPE == header->ucRecordType || - 0 == header->ucRecordSize) - break; - - if (ATOM_CONNECTOR_HPDPIN_LUT_RECORD_TYPE == - header->ucRecordType && - sizeof(ATOM_CONNECTOR_HPDPIN_LUT_RECORD) <= - header->ucRecordSize) - return (ATOM_CONNECTOR_HPDPIN_LUT_RECORD *)header; - - offset += header->ucRecordSize; - } - - return NULL; -} - -/* - * Check whether we need to patch the VBIOS connector info table with - * data from an external display connection info table. This is - * necessary to support MXM boards with an OPM (output personality - * module). With these designs, the VBIOS connector info table - * specifies an MXM_CONNECTOR with a unique ID. The driver retrieves - * the external connection info table through i2c and then looks up the - * connector ID to find the real connector type (e.g. DFP1). - * - */ -static enum bp_result patch_bios_image_from_ext_display_connection_info( - struct bios_parser *bp) -{ - ATOM_OBJECT_TABLE *connector_tbl; - uint32_t connector_tbl_offset; - struct graphics_object_id object_id; - ATOM_OBJECT *object; - ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO ext_display_connection_info_tbl; - EXT_DISPLAY_PATH *ext_display_path; - ATOM_CONNECTOR_AUXDDC_LUT_RECORD *aux_ddc_lut_record = NULL; - ATOM_I2C_RECORD *i2c_record = NULL; - ATOM_CONNECTOR_HPDPIN_LUT_RECORD *hpd_pin_lut_record = NULL; - ATOM_HPD_INT_RECORD *hpd_record = NULL; - ATOM_OBJECT_TABLE *encoder_table; - uint32_t encoder_table_offset; - ATOM_OBJECT *opm_object = NULL; - uint32_t i = 0; - struct graphics_object_id opm_object_id = - dal_graphics_object_id_init( - GENERIC_ID_MXM_OPM, - ENUM_ID_1, - OBJECT_TYPE_GENERIC); - ATOM_CONNECTOR_DEVICE_TAG_RECORD *dev_tag_record; - uint32_t cached_device_support = - le16_to_cpu(bp->object_info_tbl.v1_1->usDeviceSupport); - - uint32_t dst_number; - uint16_t *dst_object_id_list; - - opm_object = get_bios_object(bp, opm_object_id); - if (!opm_object) - return BP_RESULT_UNSUPPORTED; - - memset(&ext_display_connection_info_tbl, 0, - sizeof(ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO)); - - connector_tbl_offset = bp->object_info_tbl_offset - + le16_to_cpu(bp->object_info_tbl.v1_1->usConnectorObjectTableOffset); - connector_tbl = GET_IMAGE(ATOM_OBJECT_TABLE, connector_tbl_offset); - - /* Read Connector info table from EEPROM through i2c */ - if (get_ext_display_connection_info(bp, - opm_object, - &ext_display_connection_info_tbl) != BP_RESULT_OK) { - - DC_LOG_WARNING("%s: Failed to read Connection Info Table", __func__); - return BP_RESULT_UNSUPPORTED; - } - - /* Get pointer to AUX/DDC and HPD LUTs */ - aux_ddc_lut_record = - get_ext_connector_aux_ddc_lut_record(bp, opm_object); - hpd_pin_lut_record = - get_ext_connector_hpd_pin_lut_record(bp, opm_object); - - if ((aux_ddc_lut_record == NULL) || (hpd_pin_lut_record == NULL)) - return BP_RESULT_UNSUPPORTED; - - /* Cache support bits for currently unmapped device types. */ - if (bp->remap_device_tags) { - for (i = 0; i < connector_tbl->ucNumberOfObjects; ++i) { - uint32_t j; - /* Remove support for all non-MXM connectors. */ - object = &connector_tbl->asObjects[i]; - object_id = object_id_from_bios_object_id( - le16_to_cpu(object->usObjectID)); - if ((OBJECT_TYPE_CONNECTOR != object_id.type) || - (CONNECTOR_ID_MXM == object_id.id)) - continue; - - /* Remove support for all device tags. */ - if (bios_parser_get_device_tag_record( - bp, object, &dev_tag_record) != BP_RESULT_OK) - continue; - - for (j = 0; j < dev_tag_record->ucNumberOfDevice; ++j) { - ATOM_CONNECTOR_DEVICE_TAG *device_tag = - &dev_tag_record->asDeviceTag[j]; - cached_device_support &= - ~le16_to_cpu(device_tag->usDeviceID); - } - } - } - - /* Find all MXM connector objects and patch them with connector info - * from the external display connection info table. */ - for (i = 0; i < connector_tbl->ucNumberOfObjects; i++) { - uint32_t j; - - object = &connector_tbl->asObjects[i]; - object_id = object_id_from_bios_object_id(le16_to_cpu(object->usObjectID)); - if ((OBJECT_TYPE_CONNECTOR != object_id.type) || - (CONNECTOR_ID_MXM != object_id.id)) - continue; - - /* Get the correct connection info table entry based on the enum - * id. */ - ext_display_path = get_ext_display_path_entry( - &ext_display_connection_info_tbl, - le16_to_cpu(object->usObjectID)); - if (!ext_display_path) - return BP_RESULT_FAILURE; - - /* Patch device connector ID */ - object->usObjectID = - cpu_to_le16(le16_to_cpu(ext_display_path->usDeviceConnector)); - - /* Patch device tag, ulACPIDeviceEnum. */ - add_device_tag_from_ext_display_path( - bp, - object, - ext_display_path, - &cached_device_support); - - /* Patch HPD info */ - if (ext_display_path->ucExtHPDPINLutIndex < - MAX_NUMBER_OF_EXT_HPDPIN_LUT_ENTRIES) { - hpd_record = get_hpd_record(bp, object); - if (hpd_record) { - uint8_t index = - ext_display_path->ucExtHPDPINLutIndex; - hpd_record->ucHPDIntGPIOID = - hpd_pin_lut_record->ucHPDPINMap[index]; - } else { - BREAK_TO_DEBUGGER(); - /* Invalid hpd record */ - return BP_RESULT_FAILURE; - } - } - - /* Patch I2C/AUX info */ - if (ext_display_path->ucExtHPDPINLutIndex < - MAX_NUMBER_OF_EXT_AUXDDC_LUT_ENTRIES) { - i2c_record = get_i2c_record(bp, object); - if (i2c_record) { - uint8_t index = - ext_display_path->ucExtAUXDDCLutIndex; - i2c_record->sucI2cId = - aux_ddc_lut_record->ucAUXDDCMap[index]; - } else { - BREAK_TO_DEBUGGER(); - /* Invalid I2C record */ - return BP_RESULT_FAILURE; - } - } - - /* Merge with other MXM connectors that map to the same physical - * connector. */ - for (j = i + 1; - j < connector_tbl->ucNumberOfObjects; j++) { - ATOM_OBJECT *next_object; - struct graphics_object_id next_object_id; - EXT_DISPLAY_PATH *next_ext_display_path; - - next_object = &connector_tbl->asObjects[j]; - next_object_id = object_id_from_bios_object_id( - le16_to_cpu(next_object->usObjectID)); - - if ((OBJECT_TYPE_CONNECTOR != next_object_id.type) && - (CONNECTOR_ID_MXM == next_object_id.id)) - continue; - - next_ext_display_path = get_ext_display_path_entry( - &ext_display_connection_info_tbl, - le16_to_cpu(next_object->usObjectID)); - - if (next_ext_display_path == NULL) - return BP_RESULT_FAILURE; - - /* Merge if using same connector. */ - if ((le16_to_cpu(next_ext_display_path->usDeviceConnector) == - le16_to_cpu(ext_display_path->usDeviceConnector)) && - (le16_to_cpu(ext_display_path->usDeviceConnector) != 0)) { - /* Clear duplicate connector from table. */ - next_object->usObjectID = cpu_to_le16(0); - add_device_tag_from_ext_display_path( - bp, - object, - ext_display_path, - &cached_device_support); - } - } - } - - /* Find all encoders which have an MXM object as their destination. - * Replace the MXM object with the real connector Id from the external - * display connection info table */ - - encoder_table_offset = bp->object_info_tbl_offset - + le16_to_cpu(bp->object_info_tbl.v1_1->usEncoderObjectTableOffset); - encoder_table = GET_IMAGE(ATOM_OBJECT_TABLE, encoder_table_offset); - - for (i = 0; i < encoder_table->ucNumberOfObjects; i++) { - uint32_t j; - - object = &encoder_table->asObjects[i]; - - dst_number = get_dest_obj_list(bp, object, &dst_object_id_list); - - for (j = 0; j < dst_number; j++) { - object_id = object_id_from_bios_object_id( - dst_object_id_list[j]); - - if ((OBJECT_TYPE_CONNECTOR != object_id.type) || - (CONNECTOR_ID_MXM != object_id.id)) - continue; - - /* Get the correct connection info table entry based on - * the enum id. */ - ext_display_path = - get_ext_display_path_entry( - &ext_display_connection_info_tbl, - dst_object_id_list[j]); - - if (ext_display_path == NULL) - return BP_RESULT_FAILURE; - - dst_object_id_list[j] = - le16_to_cpu(ext_display_path->usDeviceConnector); - } - } - - return BP_RESULT_OK; -} - -/* - * Check whether we need to patch the VBIOS connector info table with - * data from an external display connection info table. This is - * necessary to support MXM boards with an OPM (output personality - * module). With these designs, the VBIOS connector info table - * specifies an MXM_CONNECTOR with a unique ID. The driver retrieves - * the external connection info table through i2c and then looks up the - * connector ID to find the real connector type (e.g. DFP1). - * - */ - -static void process_ext_display_connection_info(struct bios_parser *bp) -{ - ATOM_OBJECT_TABLE *connector_tbl; - uint32_t connector_tbl_offset; - struct graphics_object_id object_id; - ATOM_OBJECT *object; - bool mxm_connector_found = false; - bool null_entry_found = false; - uint32_t i = 0; - - connector_tbl_offset = bp->object_info_tbl_offset + - le16_to_cpu(bp->object_info_tbl.v1_1->usConnectorObjectTableOffset); - connector_tbl = GET_IMAGE(ATOM_OBJECT_TABLE, connector_tbl_offset); - - /* Look for MXM connectors to determine whether we need patch the VBIOS - * connector info table. Look for null entries to determine whether we - * need to compact connector table. */ - for (i = 0; i < connector_tbl->ucNumberOfObjects; i++) { - object = &connector_tbl->asObjects[i]; - object_id = object_id_from_bios_object_id(le16_to_cpu(object->usObjectID)); - - if ((OBJECT_TYPE_CONNECTOR == object_id.type) && - (CONNECTOR_ID_MXM == object_id.id)) { - /* Once we found MXM connector - we can break */ - mxm_connector_found = true; - break; - } else if (OBJECT_TYPE_CONNECTOR != object_id.type) { - /* We need to continue looping - to check if MXM - * connector present */ - null_entry_found = true; - } - } - - /* Patch BIOS image */ - if (mxm_connector_found || null_entry_found) { - uint32_t connectors_num = 0; - uint8_t *original_bios; - /* Step 1: Replace bios image with the new copy which will be - * patched */ - bp->base.bios_local_image = kzalloc(bp->base.bios_size, - GFP_KERNEL); - if (bp->base.bios_local_image == NULL) { - BREAK_TO_DEBUGGER(); - /* Failed to alloc bp->base.bios_local_image */ - return; - } - - memmove(bp->base.bios_local_image, bp->base.bios, bp->base.bios_size); - original_bios = bp->base.bios; - bp->base.bios = bp->base.bios_local_image; - connector_tbl = - GET_IMAGE(ATOM_OBJECT_TABLE, connector_tbl_offset); - - /* Step 2: (only if MXM connector found) Patch BIOS image with - * info from external module */ - if (mxm_connector_found && - patch_bios_image_from_ext_display_connection_info(bp) != - BP_RESULT_OK) { - /* Patching the bios image has failed. We will copy - * again original image provided and afterwards - * only remove null entries */ - memmove( - bp->base.bios_local_image, - original_bios, - bp->base.bios_size); - } - - /* Step 3: Compact connector table (remove null entries, valid - * entries moved to beginning) */ - for (i = 0; i < connector_tbl->ucNumberOfObjects; i++) { - object = &connector_tbl->asObjects[i]; - object_id = object_id_from_bios_object_id( - le16_to_cpu(object->usObjectID)); - - if (OBJECT_TYPE_CONNECTOR != object_id.type) - continue; - - if (i != connectors_num) { - memmove( - &connector_tbl-> - asObjects[connectors_num], - object, - sizeof(ATOM_OBJECT)); - } - ++connectors_num; - } - connector_tbl->ucNumberOfObjects = (uint8_t)connectors_num; - } -} - -static void bios_parser_post_init(struct dc_bios *dcb) -{ - struct bios_parser *bp = BP_FROM_DCB(dcb); - - process_ext_display_connection_info(bp); -} - /** * bios_parser_set_scratch_critical_state * @@ -3959,22 +2796,12 @@ static enum bp_result bios_get_board_layout_info( static const struct dc_vbios_funcs vbios_funcs = { .get_connectors_number = bios_parser_get_connectors_number, - .get_encoder_id = bios_parser_get_encoder_id, - .get_connector_id = bios_parser_get_connector_id, - .get_dst_number = bios_parser_get_dst_number, - .get_src_obj = bios_parser_get_src_obj, - .get_dst_obj = bios_parser_get_dst_obj, - .get_i2c_info = bios_parser_get_i2c_info, - .get_voltage_ddc_info = bios_parser_get_voltage_ddc_info, - - .get_thermal_ddc_info = bios_parser_get_thermal_ddc_info, - .get_hpd_info = bios_parser_get_hpd_info, .get_device_tag = bios_parser_get_device_tag, @@ -3993,7 +2820,6 @@ static const struct dc_vbios_funcs vbios_funcs = { /* bios scratch register communication */ .is_accelerated_mode = bios_is_accelerated_mode, - .get_vga_enabled_displays = bios_get_vga_enabled_displays, .set_scratch_critical_state = bios_parser_set_scratch_critical_state, @@ -4004,8 +2830,6 @@ static const struct dc_vbios_funcs vbios_funcs = { .transmitter_control = bios_parser_transmitter_control, - .crt_control = bios_parser_crt_control, /* not used in DAL3. keep for now in case we need to support VGA on Bonaire */ - .enable_crtc = bios_parser_enable_crtc, .adjust_pixel_clock = bios_parser_adjust_pixel_clock, @@ -4025,7 +2849,6 @@ static const struct dc_vbios_funcs vbios_funcs = { .enable_disp_power_gating = bios_parser_enable_disp_power_gating, /* SW init and patch */ - .post_init = bios_parser_post_init, /* patch vbios table for mxm module by reading i2c */ .bios_parser_destroy = bios_parser_destroy, diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c index eab007e1793c..ff764da21b6f 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c @@ -166,21 +166,6 @@ static uint8_t bios_parser_get_connectors_number(struct dc_bios *dcb) return count; } -static struct graphics_object_id bios_parser_get_encoder_id( - struct dc_bios *dcb, - uint32_t i) -{ - struct bios_parser *bp = BP_FROM_DCB(dcb); - struct graphics_object_id object_id = dal_graphics_object_id_init( - 0, ENUM_ID_UNKNOWN, OBJECT_TYPE_UNKNOWN); - - if (bp->object_info_tbl.v1_4->number_of_path > i) - object_id = object_id_from_bios_object_id( - bp->object_info_tbl.v1_4->display_path[i].encoderobjid); - - return object_id; -} - static struct graphics_object_id bios_parser_get_connector_id( struct dc_bios *dcb, uint8_t i) @@ -204,26 +189,6 @@ static struct graphics_object_id bios_parser_get_connector_id( return object_id; } - -/* TODO: GetNumberOfSrc*/ - -static uint32_t bios_parser_get_dst_number(struct dc_bios *dcb, - struct graphics_object_id id) -{ - /* connector has 1 Dest, encoder has 0 Dest */ - switch (id.type) { - case OBJECT_TYPE_ENCODER: - return 0; - case OBJECT_TYPE_CONNECTOR: - return 1; - default: - return 0; - } -} - -/* removed getSrcObjList, getDestObjList*/ - - static enum bp_result bios_parser_get_src_obj(struct dc_bios *dcb, struct graphics_object_id object_id, uint32_t index, struct graphics_object_id *src_object_id) @@ -283,52 +248,10 @@ static enum bp_result bios_parser_get_src_obj(struct dc_bios *dcb, return bp_result; } -static enum bp_result bios_parser_get_dst_obj(struct dc_bios *dcb, - struct graphics_object_id object_id, uint32_t index, - struct graphics_object_id *dest_object_id) -{ - struct bios_parser *bp = BP_FROM_DCB(dcb); - unsigned int i; - enum bp_result bp_result = BP_RESULT_BADINPUT; - struct graphics_object_id obj_id = {0}; - struct object_info_table *tbl = &bp->object_info_tbl; - - if (!dest_object_id) - return BP_RESULT_BADINPUT; - - switch (object_id.type) { - case OBJECT_TYPE_ENCODER: - /* TODO: since num of src must be less than 2. - * If found in for loop, should break. - * DAL2 implementation may be changed too - */ - for (i = 0; i < tbl->v1_4->number_of_path; i++) { - obj_id = object_id_from_bios_object_id( - tbl->v1_4->display_path[i].encoderobjid); - if (object_id.type == obj_id.type && - object_id.id == obj_id.id && - object_id.enum_id == - obj_id.enum_id) { - *dest_object_id = - object_id_from_bios_object_id( - tbl->v1_4->display_path[i].display_objid); - /* break; */ - } - } - bp_result = BP_RESULT_OK; - break; - default: - break; - } - - return bp_result; -} - - /* from graphics_object_id, find display path which includes the object_id */ static struct atom_display_object_path_v2 *get_bios_object( - struct bios_parser *bp, - struct graphics_object_id id) + struct bios_parser *bp, + struct graphics_object_id id) { unsigned int i; struct graphics_object_id obj_id = {0}; @@ -337,27 +260,22 @@ static struct atom_display_object_path_v2 *get_bios_object( case OBJECT_TYPE_ENCODER: for (i = 0; i < bp->object_info_tbl.v1_4->number_of_path; i++) { obj_id = object_id_from_bios_object_id( - bp->object_info_tbl.v1_4->display_path[i].encoderobjid); - if (id.type == obj_id.type && - id.id == obj_id.id && - id.enum_id == obj_id.enum_id) - return - &bp->object_info_tbl.v1_4->display_path[i]; + bp->object_info_tbl.v1_4->display_path[i].encoderobjid); + if (id.type == obj_id.type && id.id == obj_id.id + && id.enum_id == obj_id.enum_id) + return &bp->object_info_tbl.v1_4->display_path[i]; } case OBJECT_TYPE_CONNECTOR: case OBJECT_TYPE_GENERIC: /* Both Generic and Connector Object ID * will be stored on display_objid - */ + */ for (i = 0; i < bp->object_info_tbl.v1_4->number_of_path; i++) { obj_id = object_id_from_bios_object_id( - bp->object_info_tbl.v1_4->display_path[i].display_objid - ); - if (id.type == obj_id.type && - id.id == obj_id.id && - id.enum_id == obj_id.enum_id) - return - &bp->object_info_tbl.v1_4->display_path[i]; + bp->object_info_tbl.v1_4->display_path[i].display_objid); + if (id.type == obj_id.type && id.id == obj_id.id + && id.enum_id == obj_id.enum_id) + return &bp->object_info_tbl.v1_4->display_path[i]; } default: return NULL; @@ -489,99 +407,6 @@ static enum bp_result get_gpio_i2c_info( return BP_RESULT_OK; } -static enum bp_result get_voltage_ddc_info_v4( - uint8_t *i2c_line, - uint32_t index, - struct atom_common_table_header *header, - uint8_t *address) -{ - enum bp_result result = BP_RESULT_NORECORD; - struct atom_voltage_objects_info_v4_1 *info = - (struct atom_voltage_objects_info_v4_1 *) address; - - uint8_t *voltage_current_object = - (uint8_t *) (&(info->voltage_object[0])); - - while ((address + le16_to_cpu(header->structuresize)) > - voltage_current_object) { - struct atom_i2c_voltage_object_v4 *object = - (struct atom_i2c_voltage_object_v4 *) - voltage_current_object; - - if (object->header.voltage_mode == - ATOM_INIT_VOLTAGE_REGULATOR) { - if (object->header.voltage_type == index) { - *i2c_line = object->i2c_id ^ 0x90; - result = BP_RESULT_OK; - break; - } - } - - voltage_current_object += - le16_to_cpu(object->header.object_size); - } - return result; -} - -static enum bp_result bios_parser_get_thermal_ddc_info( - struct dc_bios *dcb, - uint32_t i2c_channel_id, - struct graphics_object_i2c_info *info) -{ - struct bios_parser *bp = BP_FROM_DCB(dcb); - struct i2c_id_config_access *config; - struct atom_i2c_record record; - - if (!info) - return BP_RESULT_BADINPUT; - - config = (struct i2c_id_config_access *) &i2c_channel_id; - - record.i2c_id = config->bfHW_Capable; - record.i2c_id |= config->bfI2C_LineMux; - record.i2c_id |= config->bfHW_EngineID; - - return get_gpio_i2c_info(bp, &record, info); -} - -static enum bp_result bios_parser_get_voltage_ddc_info(struct dc_bios *dcb, - uint32_t index, - struct graphics_object_i2c_info *info) -{ - uint8_t i2c_line = 0; - enum bp_result result = BP_RESULT_NORECORD; - uint8_t *voltage_info_address; - struct atom_common_table_header *header; - struct atom_data_revision revision = {0}; - struct bios_parser *bp = BP_FROM_DCB(dcb); - - if (!DATA_TABLES(voltageobject_info)) - return result; - - voltage_info_address = bios_get_image(&bp->base, - DATA_TABLES(voltageobject_info), - sizeof(struct atom_common_table_header)); - - header = (struct atom_common_table_header *) voltage_info_address; - - get_atom_data_table_revision(header, &revision); - - switch (revision.major) { - case 4: - if (revision.minor != 1) - break; - result = get_voltage_ddc_info_v4(&i2c_line, index, header, - voltage_info_address); - break; - } - - if (result == BP_RESULT_OK) - result = bios_parser_get_thermal_ddc_info(dcb, - i2c_line, info); - - return result; -} - static enum bp_result bios_parser_get_hpd_info( struct dc_bios *dcb, struct graphics_object_id id, @@ -997,8 +822,8 @@ static enum bp_result bios_parser_get_spread_spectrum_info( } static enum bp_result get_embedded_panel_info_v2_1( - struct bios_parser *bp, - struct embedded_panel_info *info) + struct bios_parser *bp, + struct embedded_panel_info *info) { struct lcd_info_v2_1 *lvds; @@ -1021,92 +846,78 @@ static enum bp_result get_embedded_panel_info_v2_1( memset(info, 0, sizeof(struct embedded_panel_info)); /* We need to convert from 10KHz units into KHz units */ - info->lcd_timing.pixel_clk = - le16_to_cpu(lvds->lcd_timing.pixclk) * 10; + info->lcd_timing.pixel_clk = le16_to_cpu(lvds->lcd_timing.pixclk) * 10; /* usHActive does not include borders, according to VBIOS team */ - info->lcd_timing.horizontal_addressable = - le16_to_cpu(lvds->lcd_timing.h_active); + info->lcd_timing.horizontal_addressable = le16_to_cpu(lvds->lcd_timing.h_active); /* usHBlanking_Time includes borders, so we should really be * subtractingborders duing this translation, but LVDS generally * doesn't have borders, so we should be okay leaving this as is for * now. May need to revisit if we ever have LVDS with borders */ - info->lcd_timing.horizontal_blanking_time = - le16_to_cpu(lvds->lcd_timing.h_blanking_time); + info->lcd_timing.horizontal_blanking_time = le16_to_cpu(lvds->lcd_timing.h_blanking_time); /* usVActive does not include borders, according to VBIOS team*/ - info->lcd_timing.vertical_addressable = - le16_to_cpu(lvds->lcd_timing.v_active); + info->lcd_timing.vertical_addressable = le16_to_cpu(lvds->lcd_timing.v_active); /* usVBlanking_Time includes borders, so we should really be * subtracting borders duing this translation, but LVDS generally * doesn't have borders, so we should be okay leaving this as is for * now. May need to revisit if we ever have LVDS with borders */ - info->lcd_timing.vertical_blanking_time = - le16_to_cpu(lvds->lcd_timing.v_blanking_time); - info->lcd_timing.horizontal_sync_offset = - le16_to_cpu(lvds->lcd_timing.h_sync_offset); - info->lcd_timing.horizontal_sync_width = - le16_to_cpu(lvds->lcd_timing.h_sync_width); - info->lcd_timing.vertical_sync_offset = - le16_to_cpu(lvds->lcd_timing.v_sync_offset); - info->lcd_timing.vertical_sync_width = - le16_to_cpu(lvds->lcd_timing.v_syncwidth); + info->lcd_timing.vertical_blanking_time = le16_to_cpu(lvds->lcd_timing.v_blanking_time); + info->lcd_timing.horizontal_sync_offset = le16_to_cpu(lvds->lcd_timing.h_sync_offset); + info->lcd_timing.horizontal_sync_width = le16_to_cpu(lvds->lcd_timing.h_sync_width); + info->lcd_timing.vertical_sync_offset = le16_to_cpu(lvds->lcd_timing.v_sync_offset); + info->lcd_timing.vertical_sync_width = le16_to_cpu(lvds->lcd_timing.v_syncwidth); info->lcd_timing.horizontal_border = lvds->lcd_timing.h_border; info->lcd_timing.vertical_border = lvds->lcd_timing.v_border; /* not provided by VBIOS */ info->lcd_timing.misc_info.HORIZONTAL_CUT_OFF = 0; - info->lcd_timing.misc_info.H_SYNC_POLARITY = - ~(uint32_t) - (lvds->lcd_timing.miscinfo & ATOM_HSYNC_POLARITY); - info->lcd_timing.misc_info.V_SYNC_POLARITY = - ~(uint32_t) - (lvds->lcd_timing.miscinfo & ATOM_VSYNC_POLARITY); + info->lcd_timing.misc_info.H_SYNC_POLARITY = ~(uint32_t) (lvds->lcd_timing.miscinfo + & ATOM_HSYNC_POLARITY); + info->lcd_timing.misc_info.V_SYNC_POLARITY = ~(uint32_t) (lvds->lcd_timing.miscinfo + & ATOM_VSYNC_POLARITY); /* not provided by VBIOS */ info->lcd_timing.misc_info.VERTICAL_CUT_OFF = 0; - info->lcd_timing.misc_info.H_REPLICATION_BY2 = - !!(lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2); - info->lcd_timing.misc_info.V_REPLICATION_BY2 = - !!(lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2); - info->lcd_timing.misc_info.COMPOSITE_SYNC = - !!(lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC); - info->lcd_timing.misc_info.INTERLACE = - !!(lvds->lcd_timing.miscinfo & ATOM_INTERLACE); + info->lcd_timing.misc_info.H_REPLICATION_BY2 = !!(lvds->lcd_timing.miscinfo + & ATOM_H_REPLICATIONBY2); + info->lcd_timing.misc_info.V_REPLICATION_BY2 = !!(lvds->lcd_timing.miscinfo + & ATOM_V_REPLICATIONBY2); + info->lcd_timing.misc_info.COMPOSITE_SYNC = !!(lvds->lcd_timing.miscinfo + & ATOM_COMPOSITESYNC); + info->lcd_timing.misc_info.INTERLACE = !!(lvds->lcd_timing.miscinfo & ATOM_INTERLACE); /* not provided by VBIOS*/ info->lcd_timing.misc_info.DOUBLE_CLOCK = 0; /* not provided by VBIOS*/ info->ss_id = 0; - info->realtek_eDPToLVDS = - !!(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID); + info->realtek_eDPToLVDS = !!(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID); return BP_RESULT_OK; } static enum bp_result bios_parser_get_embedded_panel_info( - struct dc_bios *dcb, - struct embedded_panel_info *info) + struct dc_bios *dcb, + struct embedded_panel_info *info) { - struct bios_parser *bp = BP_FROM_DCB(dcb); + struct bios_parser + *bp = BP_FROM_DCB(dcb); struct atom_common_table_header *header; struct atom_data_revision tbl_revision; if (!DATA_TABLES(lcd_info)) return BP_RESULT_FAILURE; - header = GET_IMAGE(struct atom_common_table_header, - DATA_TABLES(lcd_info)); + header = GET_IMAGE(struct atom_common_table_header, DATA_TABLES(lcd_info)); if (!header) return BP_RESULT_BADBIOSTABLE; get_atom_data_table_revision(header, &tbl_revision); - switch (tbl_revision.major) { case 2: switch (tbl_revision.minor) { @@ -1174,12 +985,6 @@ static bool bios_parser_is_device_id_supported( mask) != 0; } -static void bios_parser_post_init( - struct dc_bios *dcb) -{ - /* TODO for OPM module. Need implement later */ -} - static uint32_t bios_parser_get_ss_entry_number( struct dc_bios *dcb, enum as_signal_type signal) @@ -1238,17 +1043,6 @@ static enum bp_result bios_parser_set_dce_clock( return bp->cmd_tbl.set_dce_clock(bp, bp_params); } -static unsigned int bios_parser_get_smu_clock_info( - struct dc_bios *dcb) -{ - struct bios_parser *bp = BP_FROM_DCB(dcb); - - if (!bp->cmd_tbl.get_smu_clock_info) - return BP_RESULT_FAILURE; - - return bp->cmd_tbl.get_smu_clock_info(bp, 0); -} - static enum bp_result bios_parser_program_crtc_timing( struct dc_bios *dcb, struct bp_hw_crtc_timing_parameters *bp_params) @@ -1306,13 +1100,6 @@ static bool bios_parser_is_accelerated_mode( return bios_is_accelerated_mode(dcb); } -static uint32_t bios_parser_get_vga_enabled_displays( - struct dc_bios *bios) -{ - return bios_get_vga_enabled_displays(bios); -} - - /** * bios_parser_set_scratch_critical_state * @@ -2071,22 +1858,12 @@ static enum bp_result bios_get_board_layout_info( static const struct dc_vbios_funcs vbios_funcs = { .get_connectors_number = bios_parser_get_connectors_number, - .get_encoder_id = bios_parser_get_encoder_id, - .get_connector_id = bios_parser_get_connector_id, - .get_dst_number = bios_parser_get_dst_number, - .get_src_obj = bios_parser_get_src_obj, - .get_dst_obj = bios_parser_get_dst_obj, - .get_i2c_info = bios_parser_get_i2c_info, - .get_voltage_ddc_info = bios_parser_get_voltage_ddc_info, - - .get_thermal_ddc_info = bios_parser_get_thermal_ddc_info, - .get_hpd_info = bios_parser_get_hpd_info, .get_device_tag = bios_parser_get_device_tag, @@ -2105,10 +1882,7 @@ static const struct dc_vbios_funcs vbios_funcs = { .is_device_id_supported = bios_parser_is_device_id_supported, - - .is_accelerated_mode = bios_parser_is_accelerated_mode, - .get_vga_enabled_displays = bios_parser_get_vga_enabled_displays, .set_scratch_critical_state = bios_parser_set_scratch_critical_state, @@ -2126,20 +1900,12 @@ static const struct dc_vbios_funcs vbios_funcs = { .program_crtc_timing = bios_parser_program_crtc_timing, - /* .blank_crtc = bios_parser_blank_crtc, */ - .crtc_source_select = bios_parser_crtc_source_select, - /* .external_encoder_control = bios_parser_external_encoder_control, */ - .enable_disp_power_gating = bios_parser_enable_disp_power_gating, - .post_init = bios_parser_post_init, - .bios_parser_destroy = firmware_parser_destroy, - .get_smu_clock_info = bios_parser_get_smu_clock_info, - .get_board_layout_info = bios_get_board_layout_info, }; diff --git a/drivers/gpu/drm/amd/display/dc/dc_bios_types.h b/drivers/gpu/drm/amd/display/dc/dc_bios_types.h index 90082bab71f0..8130b95ccc53 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_bios_types.h +++ b/drivers/gpu/drm/amd/display/dc/dc_bios_types.h @@ -41,38 +41,17 @@ struct dc_vbios_funcs { uint8_t (*get_connectors_number)(struct dc_bios *bios); - struct graphics_object_id (*get_encoder_id)( - struct dc_bios *bios, - uint32_t i); struct graphics_object_id (*get_connector_id)( struct dc_bios *bios, uint8_t connector_index); - uint32_t (*get_dst_number)( - struct dc_bios *bios, - struct graphics_object_id id); - enum bp_result (*get_src_obj)( struct dc_bios *bios, struct graphics_object_id object_id, uint32_t index, struct graphics_object_id *src_object_id); - enum bp_result (*get_dst_obj)( - struct dc_bios *bios, - struct graphics_object_id object_id, uint32_t index, - struct graphics_object_id *dest_object_id); - enum bp_result (*get_i2c_info)( struct dc_bios *dcb, struct graphics_object_id id, struct graphics_object_i2c_info *info); - - enum bp_result (*get_voltage_ddc_info)( - struct dc_bios *bios, - uint32_t index, - struct graphics_object_i2c_info *info); - enum bp_result (*get_thermal_ddc_info)( - struct dc_bios *bios, - uint32_t i2c_channel_id, - struct graphics_object_i2c_info *info); enum bp_result (*get_hpd_info)( struct dc_bios *bios, struct graphics_object_id id, @@ -105,35 +84,8 @@ struct dc_vbios_funcs { struct graphics_object_id object_id, struct bp_encoder_cap_info *info); - bool (*is_lid_status_changed)( - struct dc_bios *bios); - bool (*is_display_config_changed)( - struct dc_bios *bios); bool (*is_accelerated_mode)( struct dc_bios *bios); - uint32_t (*get_vga_enabled_displays)( - struct dc_bios *bios); - void (*get_bios_event_info)( - struct dc_bios *bios, - struct bios_event_info *info); - void (*update_requested_backlight_level)( - struct dc_bios *bios, - uint32_t backlight_8bit); - uint32_t (*get_requested_backlight_level)( - struct dc_bios *bios); - void (*take_backlight_control)( - struct dc_bios *bios, - bool cntl); - - bool (*is_active_display)( - struct dc_bios *bios, - enum signal_type signal, - const struct connector_device_tag_info *device_tag); - enum controller_id (*get_embedded_display_controller_id)( - struct dc_bios *bios); - uint32_t (*get_embedded_display_refresh_rate)( - struct dc_bios *bios); - void (*set_scratch_critical_state)( struct dc_bios *bios, bool state); @@ -149,11 +101,6 @@ struct dc_vbios_funcs { enum bp_result (*transmitter_control)( struct dc_bios *bios, struct bp_transmitter_control *cntl); - enum bp_result (*crt_control)( - struct dc_bios *bios, - enum engine_id engine_id, - bool enable, - uint32_t pixel_clock); enum bp_result (*enable_crtc)( struct dc_bios *bios, enum controller_id id, @@ -167,8 +114,6 @@ struct dc_vbios_funcs { enum bp_result (*set_dce_clock)( struct dc_bios *bios, struct bp_set_dce_clock_parameters *bp_params); - unsigned int (*get_smu_clock_info)( - struct dc_bios *bios); enum bp_result (*enable_spread_spectrum_on_ppll)( struct dc_bios *bios, struct bp_spread_spectrum_parameters *bp_params, @@ -183,20 +128,11 @@ struct dc_vbios_funcs { enum bp_result (*program_display_engine_pll)( struct dc_bios *bios, struct bp_pixel_clock_parameters *bp_params); - - enum signal_type (*dac_load_detect)( - struct dc_bios *bios, - struct graphics_object_id encoder, - struct graphics_object_id connector, - enum signal_type display_signal); - enum bp_result (*enable_disp_power_gating)( struct dc_bios *bios, enum controller_id controller_id, enum bp_pipe_control_action action); - void (*post_init)(struct dc_bios *bios); - void (*bios_parser_destroy)(struct dc_bios **dcb); enum bp_result (*get_board_layout_info)( -- cgit v1.2.3 From e6ada54126cff629b422924e6497a13ce8bd890d Mon Sep 17 00:00:00 2001 From: Dmytro Laktyushkin Date: Mon, 30 Jul 2018 14:45:42 -0400 Subject: drm/amd/display: remove unused clk_src code Signed-off-by: Dmytro Laktyushkin Reviewed-by: Charlene Liu Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- .../gpu/drm/amd/display/dc/dce/dce_clock_source.c | 87 +--------------------- drivers/gpu/drm/amd/display/dc/inc/clock_source.h | 4 - 2 files changed, 1 insertion(+), 90 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c index 1f23224d495a..5a9f3601ffb6 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c @@ -611,90 +611,6 @@ static uint32_t dce110_get_pix_clk_dividers( return pll_calc_error; } -static uint32_t dce110_get_pll_pixel_rate_in_hz( - struct clock_source *cs, - struct pixel_clk_params *pix_clk_params, - struct pll_settings *pll_settings) -{ - uint32_t inst = pix_clk_params->controller_id - CONTROLLER_ID_D0; - struct dc *dc_core = cs->ctx->dc; - struct dc_state *context = dc_core->current_state; - struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[inst]; - - /* This function need separate to different DCE version, before separate, just use pixel clock */ - return pipe_ctx->stream->phy_pix_clk; - -} - -static uint32_t dce110_get_dp_pixel_rate_from_combo_phy_pll( - struct clock_source *cs, - struct pixel_clk_params *pix_clk_params, - struct pll_settings *pll_settings) -{ - uint32_t inst = pix_clk_params->controller_id - CONTROLLER_ID_D0; - struct dc *dc_core = cs->ctx->dc; - struct dc_state *context = dc_core->current_state; - struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[inst]; - - /* This function need separate to different DCE version, before separate, just use pixel clock */ - return pipe_ctx->stream->phy_pix_clk; -} - -static uint32_t dce110_get_d_to_pixel_rate_in_hz( - struct clock_source *cs, - struct pixel_clk_params *pix_clk_params, - struct pll_settings *pll_settings) -{ - uint32_t inst = pix_clk_params->controller_id - CONTROLLER_ID_D0; - struct dce110_clk_src *clk_src = TO_DCE110_CLK_SRC(cs); - int dto_enabled = 0; - struct fixed31_32 pix_rate; - - REG_GET(PIXEL_RATE_CNTL[inst], DP_DTO0_ENABLE, &dto_enabled); - - if (dto_enabled) { - uint32_t phase = 0; - uint32_t modulo = 0; - REG_GET(PHASE[inst], DP_DTO0_PHASE, &phase); - REG_GET(MODULO[inst], DP_DTO0_MODULO, &modulo); - - if (modulo == 0) { - return 0; - } - - pix_rate = dc_fixpt_from_int(clk_src->ref_freq_khz); - pix_rate = dc_fixpt_mul_int(pix_rate, 1000); - pix_rate = dc_fixpt_mul_int(pix_rate, phase); - pix_rate = dc_fixpt_div_int(pix_rate, modulo); - - return dc_fixpt_round(pix_rate); - } else { - return dce110_get_dp_pixel_rate_from_combo_phy_pll(cs, pix_clk_params, pll_settings); - } -} - -static uint32_t dce110_get_pix_rate_in_hz( - struct clock_source *cs, - struct pixel_clk_params *pix_clk_params, - struct pll_settings *pll_settings) -{ - uint32_t pix_rate = 0; - switch (pix_clk_params->signal_type) { - case SIGNAL_TYPE_DISPLAY_PORT: - case SIGNAL_TYPE_DISPLAY_PORT_MST: - case SIGNAL_TYPE_EDP: - case SIGNAL_TYPE_VIRTUAL: - pix_rate = dce110_get_d_to_pixel_rate_in_hz(cs, pix_clk_params, pll_settings); - break; - case SIGNAL_TYPE_HDMI_TYPE_A: - default: - pix_rate = dce110_get_pll_pixel_rate_in_hz(cs, pix_clk_params, pll_settings); - break; - } - - return pix_rate; -} - static bool disable_spread_spectrum(struct dce110_clk_src *clk_src) { enum bp_result result; @@ -1046,8 +962,7 @@ static bool dce110_clock_source_power_down( static const struct clock_source_funcs dce110_clk_src_funcs = { .cs_power_down = dce110_clock_source_power_down, .program_pix_clk = dce110_program_pix_clk, - .get_pix_clk_dividers = dce110_get_pix_clk_dividers, - .get_pix_rate_in_hz = dce110_get_pix_rate_in_hz + .get_pix_clk_dividers = dce110_get_pix_clk_dividers }; static void get_ss_info_from_atombios( diff --git a/drivers/gpu/drm/amd/display/dc/inc/clock_source.h b/drivers/gpu/drm/amd/display/dc/inc/clock_source.h index ebcf67b5fc57..47ef90495376 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/clock_source.h +++ b/drivers/gpu/drm/amd/display/dc/inc/clock_source.h @@ -166,10 +166,6 @@ struct clock_source_funcs { struct clock_source *, struct pixel_clk_params *, struct pll_settings *); - uint32_t (*get_pix_rate_in_hz)( - struct clock_source *, - struct pixel_clk_params *, - struct pll_settings *); }; struct clock_source { -- cgit v1.2.3 From 491e08c9b858a328e0d7d09a557edd748f2d1b93 Mon Sep 17 00:00:00 2001 From: Derek Lai Date: Thu, 23 Aug 2018 15:13:23 +0800 Subject: drm/amd/display: add disconnect_delay to dc_panel_patch Some display need disconnect delay. Adding this parameter for future use Signed-off-by: Derek Lai Reviewed-by: Charlene Liu Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dc_types.h | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dc_types.h b/drivers/gpu/drm/amd/display/dc/dc_types.h index 58a6ef80a60e..4fb62780a696 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_types.h +++ b/drivers/gpu/drm/amd/display/dc/dc_types.h @@ -191,6 +191,7 @@ union display_content_support { }; struct dc_panel_patch { + unsigned int disconnect_delay; unsigned int dppowerup_delay; unsigned int extra_t12_ms; }; -- cgit v1.2.3 From 86a2da705cc29a3a006c6571cadfa45676150622 Mon Sep 17 00:00:00 2001 From: Chiawen Huang Date: Fri, 24 Aug 2018 17:45:28 +0800 Subject: drm/amd/display: add aux transition event log. [Why] Enhance aux transition debugging information. [How] Added Aux request and reply event log. Signed-off-by: Chiawen Huang Reviewed-by: Tony Cheng Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dm_event_log.h | 39 ++++++++++++++++++++++ drivers/gpu/drm/amd/display/dc/i2caux/aux_engine.c | 13 ++++++++ .../display/dc/i2caux/dce110/aux_engine_dce110.c | 7 +++- .../gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c | 18 ++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/display/dc/dm_event_log.h (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dm_event_log.h b/drivers/gpu/drm/amd/display/dc/dm_event_log.h new file mode 100644 index 000000000000..c1ce2dd52f9b --- /dev/null +++ b/drivers/gpu/drm/amd/display/dc/dm_event_log.h @@ -0,0 +1,39 @@ +/* + * Copyright 2018 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ + +/** + * This file defines external dependencies of Display Core. + */ + +#ifndef __DM_EVENT_LOG_H__ + +#define __DM_EVENT_LOG_H__ + +#define EVENT_LOG_I2CAUX_READ(transType, dcc, address, status, len, data) +#define EVENT_LOG_I2CAUX_WRITE(transType, dcc, address, status, len, data) +#define EVENT_LOG_AUX_REQ(dcc, type, action, address, len, data) +#define EVENT_LOG_AUX_Reply(dcc, type, swStatus, replyStatus, len, data) + +#endif diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/aux_engine.c b/drivers/gpu/drm/amd/display/dc/i2caux/aux_engine.c index 0afd2fa57bbe..03292c52b18d 100644 --- a/drivers/gpu/drm/amd/display/dc/i2caux/aux_engine.c +++ b/drivers/gpu/drm/amd/display/dc/i2caux/aux_engine.c @@ -24,6 +24,7 @@ */ #include "dm_services.h" +#include "dm_event_log.h" /* * Pre-requisites: headers required by header of this unit @@ -296,6 +297,12 @@ static bool read_command( if (request->payload.address_space == I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD) { + EVENT_LOG_I2CAUX_READ(request->payload.address_space, + engine->base.ddc->pin_data->en, + request->payload.address, + request->status, + request->payload.length, + request->payload.data); DC_LOG_I2C_AUX("READ: addr:0x%x value:0x%x Result:%d", request->payload.address, request->payload.data[0], @@ -512,6 +519,12 @@ static bool write_command( if (request->payload.address_space == I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD) { + EVENT_LOG_I2CAUX_WRITE(request->payload.address_space, + engine->base.ddc->pin_data->en, + request->payload.address, + request->status, + request->payload.length, + request->payload.data); DC_LOG_I2C_AUX("WRITE: addr:0x%x value:0x%x Result:%d", request->payload.address, request->payload.data[0], diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c b/drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c index ae5caa97caca..4a88fc76614e 100644 --- a/drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c +++ b/drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c @@ -24,6 +24,7 @@ */ #include "dm_services.h" +#include "dm_event_log.h" /* * Pre-requisites: headers required by header of this unit @@ -273,6 +274,8 @@ static void submit_channel_request( REG_WAIT(AUX_SW_STATUS, AUX_SW_DONE, 0, 10, aux110->timeout_period/10); REG_UPDATE(AUX_SW_CONTROL, AUX_SW_GO, 1); + EVENT_LOG_AUX_REQ(engine->base.ddc->pin_data->en, Native, request->action, + request->address, request->length, request->data); } static int read_channel_reply(struct aux_engine *engine, uint32_t size, @@ -336,7 +339,9 @@ static void process_channel_reply( uint32_t sw_status; bytes_replied = read_channel_reply(engine, reply->length, reply->data, - &reply_result, &sw_status); + &reply_result, &sw_status); + EVENT_LOG_AUX_Reply(engine->base.ddc->pin_data->en, Native, + sw_status, reply_result, bytes_replied, reply->data); /* in case HPD is LOW, exit AUX transaction */ if ((sw_status & AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK)) { diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c b/drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c index 4b54fcfb28ec..1747b9f5f10e 100644 --- a/drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c +++ b/drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c @@ -24,6 +24,7 @@ */ #include "dm_services.h" +#include "dm_event_log.h" /* * Pre-requisites: headers required by header of this unit @@ -170,6 +171,23 @@ bool dal_i2c_hw_engine_submit_request( process_channel_reply(&hw_engine->base, &reply); } + if (i2caux_request->operation == I2CAUX_TRANSACTION_READ) { + EVENT_LOG_I2CAUX_READ(i2caux_request->payload.address_space, + engine->ddc->pin_data->en, + i2caux_request->payload.address, + i2caux_request->status, + i2caux_request->payload.length, + i2caux_request->payload.data); + } else if (i2caux_request->operation == I2CAUX_TRANSACTION_WRITE) { + EVENT_LOG_I2CAUX_WRITE(i2caux_request->payload.address_space, + engine->ddc->pin_data->en, + i2caux_request->payload.address, + i2caux_request->status, + i2caux_request->payload.length, + i2caux_request->payload.data); + } + + return result; } -- cgit v1.2.3 From 0e8e4fbf8d8905071c045f2922de55adbe1a6abe Mon Sep 17 00:00:00 2001 From: Hersen Wu Date: Tue, 21 Aug 2018 09:35:47 -0400 Subject: drm/amd/display: num of sw i2c/aux engines less than num of connectors [why] AMD Stoney reference board, there are only 2 pipes (not include underlay), and 3 connectors. resource creation, only 2 I2C/AUX engines are created. Within dc_link_aux_transfer, when pin_data_en =2, refer to enengines[ddc_pin->pin_data->en] = NULL. NULL point is referred later causing system crash. [how] each asic design has fixed number of ddc engines at hw side. for each ddc engine, create its i2x/aux engine at sw side. Signed-off-by: Hersen Wu Reviewed-by: Tony Cheng Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- .../drm/amd/display/dc/dce100/dce100_resource.c | 6 +++++- .../drm/amd/display/dc/dce110/dce110_resource.c | 4 ++++ .../drm/amd/display/dc/dce112/dce112_resource.c | 5 +++++ .../drm/amd/display/dc/dce120/dce120_resource.c | 9 ++++++-- .../gpu/drm/amd/display/dc/dce80/dce80_resource.c | 25 ++++++++++++++++++++++ .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 7 ++++-- drivers/gpu/drm/amd/display/dc/inc/resource.h | 1 + 7 files changed, 52 insertions(+), 5 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c index ae613b025756..b1cc38827f09 100644 --- a/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c @@ -372,7 +372,8 @@ static const struct resource_caps res_cap = { .num_timing_generator = 6, .num_audio = 6, .num_stream_encoder = 6, - .num_pll = 3 + .num_pll = 3, + .num_ddc = 6, }; #define CTX ctx @@ -1004,6 +1005,9 @@ static bool construct( "DC: failed to create output pixel processor!\n"); goto res_create_fail; } + } + + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { pool->base.engines[i] = dce100_aux_engine_create(ctx, i); if (pool->base.engines[i] == NULL) { BREAK_TO_DEBUGGER(); diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c index 49c5c7037be2..9f44f1cad221 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c @@ -378,6 +378,7 @@ static const struct resource_caps carrizo_resource_cap = { .num_audio = 3, .num_stream_encoder = 3, .num_pll = 2, + .num_ddc = 3, }; static const struct resource_caps stoney_resource_cap = { @@ -386,6 +387,7 @@ static const struct resource_caps stoney_resource_cap = { .num_audio = 3, .num_stream_encoder = 3, .num_pll = 2, + .num_ddc = 3, }; #define CTX ctx @@ -1336,7 +1338,9 @@ static bool construct( "DC: failed to create output pixel processor!\n"); goto res_create_fail; } + } + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { pool->base.engines[i] = dce110_aux_engine_create(ctx, i); if (pool->base.engines[i] == NULL) { BREAK_TO_DEBUGGER(); diff --git a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c index d35dc730e01c..2aa922cdcc58 100644 --- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c @@ -384,6 +384,7 @@ static const struct resource_caps polaris_10_resource_cap = { .num_audio = 6, .num_stream_encoder = 6, .num_pll = 8, /* why 8? 6 combo PHY PLL + 2 regular PLLs? */ + .num_ddc = 6, }; static const struct resource_caps polaris_11_resource_cap = { @@ -391,6 +392,7 @@ static const struct resource_caps polaris_11_resource_cap = { .num_audio = 5, .num_stream_encoder = 5, .num_pll = 8, /* why 8? 6 combo PHY PLL + 2 regular PLLs? */ + .num_ddc = 5, }; #define CTX ctx @@ -1286,6 +1288,9 @@ static bool construct( "DC:failed to create output pixel processor!\n"); goto res_create_fail; } + } + + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { pool->base.engines[i] = dce112_aux_engine_create(ctx, i); if (pool->base.engines[i] == NULL) { BREAK_TO_DEBUGGER(); diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c index b2fb06f37648..465f68655db2 100644 --- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c @@ -436,6 +436,7 @@ static const struct resource_caps res_cap = { .num_audio = 7, .num_stream_encoder = 6, .num_pll = 6, + .num_ddc = 6, }; static const struct dc_debug_options debug_defaults = { @@ -1062,6 +1063,12 @@ static bool construct( dm_error( "DC: failed to create output pixel processor!\n"); } + + /* check next valid pipe */ + j++; + } + + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { pool->base.engines[i] = dce120_aux_engine_create(ctx, i); if (pool->base.engines[i] == NULL) { BREAK_TO_DEBUGGER(); @@ -1077,8 +1084,6 @@ static bool construct( goto res_create_fail; } pool->base.sw_i2cs[i] = NULL; - /* check next valid pipe */ - j++; } /* valid pipe num */ diff --git a/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c b/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c index 4eae859e6383..1dc590ccc5f9 100644 --- a/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c @@ -367,6 +367,7 @@ static const struct resource_caps res_cap = { .num_audio = 6, .num_stream_encoder = 6, .num_pll = 3, + .num_ddc = 6, }; static const struct resource_caps res_cap_81 = { @@ -374,6 +375,7 @@ static const struct resource_caps res_cap_81 = { .num_audio = 7, .num_stream_encoder = 7, .num_pll = 3, + .num_ddc = 6, }; static const struct resource_caps res_cap_83 = { @@ -381,6 +383,7 @@ static const struct resource_caps res_cap_83 = { .num_audio = 6, .num_stream_encoder = 6, .num_pll = 2, + .num_ddc = 2, }; static const struct dce_dmcu_registers dmcu_regs = { @@ -992,7 +995,9 @@ static bool dce80_construct( dm_error("DC: failed to create output pixel processor!\n"); goto res_create_fail; } + } + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { pool->base.engines[i] = dce80_aux_engine_create(ctx, i); if (pool->base.engines[i] == NULL) { BREAK_TO_DEBUGGER(); @@ -1200,6 +1205,16 @@ static bool dce81_construct( dm_error("DC: failed to create output pixel processor!\n"); goto res_create_fail; } + } + + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { + pool->base.engines[i] = dce80_aux_engine_create(ctx, i); + if (pool->base.engines[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create aux engine!!\n"); + goto res_create_fail; + } pool->base.hw_i2cs[i] = dce80_i2c_hw_create(ctx, i); if (pool->base.hw_i2cs[i] == NULL) { BREAK_TO_DEBUGGER(); @@ -1396,6 +1411,16 @@ static bool dce83_construct( dm_error("DC: failed to create output pixel processor!\n"); goto res_create_fail; } + } + + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { + pool->base.engines[i] = dce80_aux_engine_create(ctx, i); + if (pool->base.engines[i] == NULL) { + BREAK_TO_DEBUGGER(); + dm_error( + "DC:failed to create aux engine!!\n"); + goto res_create_fail; + } pool->base.hw_i2cs[i] = dce80_i2c_hw_create(ctx, i); if (pool->base.hw_i2cs[i] == NULL) { BREAK_TO_DEBUGGER(); diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c index 28ebad8c3ec4..1b519f8f044f 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c @@ -501,6 +501,7 @@ static const struct resource_caps res_cap = { .num_audio = 4, .num_stream_encoder = 4, .num_pll = 4, + .num_ddc = 4, }; static const struct dc_debug_options debug_defaults_drv = { @@ -1334,7 +1335,11 @@ static bool construct( dm_error("DC: failed to create tg!\n"); goto fail; } + /* check next valid pipe */ + j++; + } + for (i = 0; i < pool->base.res_cap->num_ddc; i++) { pool->base.engines[i] = dcn10_aux_engine_create(ctx, i); if (pool->base.engines[i] == NULL) { BREAK_TO_DEBUGGER(); @@ -1350,8 +1355,6 @@ static bool construct( goto fail; } pool->base.sw_i2cs[i] = NULL; - /* check next valid pipe */ - j++; } /* valid pipe num */ diff --git a/drivers/gpu/drm/amd/display/dc/inc/resource.h b/drivers/gpu/drm/amd/display/dc/inc/resource.h index 5b321008b0b5..76d00c6dbca9 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/resource.h +++ b/drivers/gpu/drm/amd/display/dc/inc/resource.h @@ -44,6 +44,7 @@ struct resource_caps { int num_stream_encoder; int num_pll; int num_dwb; + int num_ddc; }; struct resource_straps { -- cgit v1.2.3 From 43af9e040905ed71a77785b29d81889d87264bcb Mon Sep 17 00:00:00 2001 From: David Francis Date: Thu, 9 Aug 2018 10:05:10 -0400 Subject: drm/amd/display: Reorder resource_pool to put i2c with aux [Why] The i2c and aux engines are similar, and should be placed next to eachother for readability [How] Reorder the elements of the resource_pool struct Signed-off-by: David Francis Reviewed-by: Tony Cheng Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/inc/core_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/inc/core_types.h b/drivers/gpu/drm/amd/display/dc/inc/core_types.h index 609bff8ed72e..831a1bdf622c 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/core_types.h +++ b/drivers/gpu/drm/amd/display/dc/inc/core_types.h @@ -139,11 +139,11 @@ struct resource_pool { struct output_pixel_processor *opps[MAX_PIPES]; struct timing_generator *timing_generators[MAX_PIPES]; struct stream_encoder *stream_enc[MAX_PIPES * 2]; - struct aux_engine *engines[MAX_PIPES]; struct hubbub *hubbub; struct mpc *mpc; struct pp_smu_funcs_rv *pp_smu; struct pp_smu_display_requirement_rv pp_smu_req; + struct aux_engine *engines[MAX_PIPES]; struct dce_i2c_hw *hw_i2cs[MAX_PIPES]; struct dce_i2c_sw *sw_i2cs[MAX_PIPES]; bool i2c_hw_buffer_in_use; -- cgit v1.2.3 From 2222f4486bbe66dc130296623342cb04ed778968 Mon Sep 17 00:00:00 2001 From: Tony Cheng Date: Mon, 27 Aug 2018 13:35:13 -0400 Subject: drm/amd/display: dc 3.1.65 Signed-off-by: Tony Cheng Reviewed-by: Steven Chiu Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index dee0f28e683d..a769d07d947f 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -38,7 +38,7 @@ #include "inc/compressor.h" #include "dml/display_mode_lib.h" -#define DC_VER "3.1.64" +#define DC_VER "3.1.65" #define MAX_SURFACES 3 #define MAX_STREAMS 6 -- cgit v1.2.3 From cae50a43b931c6d70c7e16e1128af10398d8635a Mon Sep 17 00:00:00 2001 From: Eric Yang Date: Fri, 24 Aug 2018 16:54:14 -0400 Subject: drm/amd/display: use link type to decide stream enc acquisition [Why] Virtual sink is used when set mode happens on a disconnected display to allow the mode set to proceed. This did not work with MST because the logic for acquiring stream encoder uses stream signal to determine the special handling is required, and stream signal is virtual instead of DP in this case. [How] Use link type to decide instead. Signed-off-by: Eric Yang Reviewed-by: Tony Cheng Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index f85fa7b55efb..d981755d1e4d 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -1762,7 +1762,7 @@ static struct stream_encoder *find_first_free_match_stream_enc_for_link( * required for non DP connectors. */ - if (j >= 0 && dc_is_dp_signal(stream->signal)) + if (j >= 0 && link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT) return pool->stream_enc[j]; return NULL; -- cgit v1.2.3 From 6787359b14710488a8646dcd243f78e1846b1037 Mon Sep 17 00:00:00 2001 From: Chiawen Huang Date: Tue, 28 Aug 2018 13:38:34 +0800 Subject: drm/amd/display: clean code for transition event log. [Why] There are same purpose transition events. [How] remove the redundant event log. Signed-off-by: Chiawen Huang Reviewed-by: Tony Cheng Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dm_event_log.h | 2 -- drivers/gpu/drm/amd/display/dc/i2caux/aux_engine.c | 12 ------------ drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c | 15 --------------- 3 files changed, 29 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dm_event_log.h b/drivers/gpu/drm/amd/display/dc/dm_event_log.h index c1ce2dd52f9b..00a275dfa472 100644 --- a/drivers/gpu/drm/amd/display/dc/dm_event_log.h +++ b/drivers/gpu/drm/amd/display/dc/dm_event_log.h @@ -31,8 +31,6 @@ #define __DM_EVENT_LOG_H__ -#define EVENT_LOG_I2CAUX_READ(transType, dcc, address, status, len, data) -#define EVENT_LOG_I2CAUX_WRITE(transType, dcc, address, status, len, data) #define EVENT_LOG_AUX_REQ(dcc, type, action, address, len, data) #define EVENT_LOG_AUX_Reply(dcc, type, swStatus, replyStatus, len, data) diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/aux_engine.c b/drivers/gpu/drm/amd/display/dc/i2caux/aux_engine.c index 03292c52b18d..8cbf38b2470d 100644 --- a/drivers/gpu/drm/amd/display/dc/i2caux/aux_engine.c +++ b/drivers/gpu/drm/amd/display/dc/i2caux/aux_engine.c @@ -297,12 +297,6 @@ static bool read_command( if (request->payload.address_space == I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD) { - EVENT_LOG_I2CAUX_READ(request->payload.address_space, - engine->base.ddc->pin_data->en, - request->payload.address, - request->status, - request->payload.length, - request->payload.data); DC_LOG_I2C_AUX("READ: addr:0x%x value:0x%x Result:%d", request->payload.address, request->payload.data[0], @@ -519,12 +513,6 @@ static bool write_command( if (request->payload.address_space == I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD) { - EVENT_LOG_I2CAUX_WRITE(request->payload.address_space, - engine->base.ddc->pin_data->en, - request->payload.address, - request->status, - request->payload.length, - request->payload.data); DC_LOG_I2C_AUX("WRITE: addr:0x%x value:0x%x Result:%d", request->payload.address, request->payload.data[0], diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c b/drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c index 1747b9f5f10e..c995ef4ea5a4 100644 --- a/drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c +++ b/drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c @@ -171,21 +171,6 @@ bool dal_i2c_hw_engine_submit_request( process_channel_reply(&hw_engine->base, &reply); } - if (i2caux_request->operation == I2CAUX_TRANSACTION_READ) { - EVENT_LOG_I2CAUX_READ(i2caux_request->payload.address_space, - engine->ddc->pin_data->en, - i2caux_request->payload.address, - i2caux_request->status, - i2caux_request->payload.length, - i2caux_request->payload.data); - } else if (i2caux_request->operation == I2CAUX_TRANSACTION_WRITE) { - EVENT_LOG_I2CAUX_WRITE(i2caux_request->payload.address_space, - engine->ddc->pin_data->en, - i2caux_request->payload.address, - i2caux_request->status, - i2caux_request->payload.length, - i2caux_request->payload.data); - } return result; -- cgit v1.2.3 From afd0384c2af286bcf72ff378e56d6d446d30b52e Mon Sep 17 00:00:00 2001 From: Jun Lei Date: Wed, 22 Aug 2018 17:00:34 -0400 Subject: drm/amd/display: Add invariant support instrumentation in driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Existing debug dump are all invariant, new “low 32-bit of address” dump is not invariant Signed-off-by: Jun Lei Reviewed-by: Eric Yang Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c | 3 + drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h | 1 + .../display/dc/dcn10/dcn10_hw_sequencer_debug.c | 84 +++++++++++++++------- 3 files changed, 61 insertions(+), 27 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c index 8da2b8a09a12..74132a1f3046 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c @@ -974,6 +974,9 @@ void hubp1_read_state(struct hubp *hubp) REG_GET(DCSURF_SURFACE_EARLIEST_INUSE_HIGH, SURFACE_EARLIEST_INUSE_ADDRESS_HIGH, &s->inuse_addr_hi); + REG_GET(DCSURF_SURFACE_EARLIEST_INUSE, + SURFACE_EARLIEST_INUSE_ADDRESS, &s->inuse_addr_lo); + REG_GET_2(DCSURF_PRI_VIEWPORT_DIMENSION, PRI_VIEWPORT_WIDTH, &s->viewport_width, PRI_VIEWPORT_HEIGHT, &s->viewport_height); diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h index 7605af9b4837..4890273b632b 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h @@ -639,6 +639,7 @@ struct dcn_hubp_state { struct _vcs_dpi_display_rq_regs_st rq_regs; uint32_t pixel_format; uint32_t inuse_addr_hi; + uint32_t inuse_addr_lo; uint32_t viewport_width; uint32_t viewport_height; uint32_t rotation_angle; diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c index 9c218252004f..64158900730f 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer_debug.c @@ -105,7 +105,7 @@ static unsigned int dcn10_get_hubbub_state(struct dc *dc, char *pBuf, unsigned i return bufSize - remaining_buffer; } -static unsigned int dcn10_get_hubp_states(struct dc *dc, char *pBuf, unsigned int bufSize) +static unsigned int dcn10_get_hubp_states(struct dc *dc, char *pBuf, unsigned int bufSize, bool invarOnly) { struct dc_context *dc_ctx = dc->ctx; struct resource_pool *pool = dc->res_pool; @@ -117,9 +117,15 @@ static unsigned int dcn10_get_hubp_states(struct dc *dc, char *pBuf, unsigned in const uint32_t ref_clk_mhz = dc_ctx->dc->res_pool->ref_clock_inKhz / 1000; static const unsigned int frac = 1000; - chars_printed = snprintf_count(pBuf, remaining_buffer, "instance,format,addr_hi,width,height,rotation,mirror,sw_mode,dcc_en,blank_en,ttu_dis,underflow," - "min_ttu_vblank,qos_low_wm,qos_high_wm" - "\n"); + if (invarOnly) + chars_printed = snprintf_count(pBuf, remaining_buffer, "instance,format,addr_hi,width,height,rotation,mirror,sw_mode,dcc_en,blank_en,ttu_dis,underflow," + "min_ttu_vblank,qos_low_wm,qos_high_wm" + "\n"); + else + chars_printed = snprintf_count(pBuf, remaining_buffer, "instance,format,addr_hi,addr_lo,width,height,rotation,mirror,sw_mode,dcc_en,blank_en,ttu_dis,underflow," + "min_ttu_vblank,qos_low_wm,qos_high_wm" + "\n"); + remaining_buffer -= chars_printed; pBuf += chars_printed; @@ -130,24 +136,45 @@ static unsigned int dcn10_get_hubp_states(struct dc *dc, char *pBuf, unsigned in hubp->funcs->hubp_read_state(hubp); if (!s->blank_en) { - chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%x,%x,%d,%d,%x,%x,%x,%x,%x,%x,%x," - "%d.%03d,%d.%03d,%d.%03d" - "\n", - hubp->inst, - s->pixel_format, - s->inuse_addr_hi, - s->viewport_width, - s->viewport_height, - s->rotation_angle, - s->h_mirror_en, - s->sw_mode, - s->dcc_en, - s->blank_en, - s->ttu_disable, - s->underflow_status, - (s->min_ttu_vblank * frac) / ref_clk_mhz / frac, (s->min_ttu_vblank * frac) / ref_clk_mhz % frac, - (s->qos_level_low_wm * frac) / ref_clk_mhz / frac, (s->qos_level_low_wm * frac) / ref_clk_mhz % frac, - (s->qos_level_high_wm * frac) / ref_clk_mhz / frac, (s->qos_level_high_wm * frac) / ref_clk_mhz % frac); + if (invarOnly) + chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%x,%x,%d,%d,%x,%x,%x,%x,%x,%x,%x," + "%d.%03d,%d.%03d,%d.%03d" + "\n", + hubp->inst, + s->pixel_format, + s->inuse_addr_hi, + s->viewport_width, + s->viewport_height, + s->rotation_angle, + s->h_mirror_en, + s->sw_mode, + s->dcc_en, + s->blank_en, + s->ttu_disable, + s->underflow_status, + (s->min_ttu_vblank * frac) / ref_clk_mhz / frac, (s->min_ttu_vblank * frac) / ref_clk_mhz % frac, + (s->qos_level_low_wm * frac) / ref_clk_mhz / frac, (s->qos_level_low_wm * frac) / ref_clk_mhz % frac, + (s->qos_level_high_wm * frac) / ref_clk_mhz / frac, (s->qos_level_high_wm * frac) / ref_clk_mhz % frac); + else + chars_printed = snprintf_count(pBuf, remaining_buffer, "%x,%x,%x,%x,%d,%d,%x,%x,%x,%x,%x,%x,%x," + "%d.%03d,%d.%03d,%d.%03d" + "\n", + hubp->inst, + s->pixel_format, + s->inuse_addr_hi, + s->inuse_addr_lo, + s->viewport_width, + s->viewport_height, + s->rotation_angle, + s->h_mirror_en, + s->sw_mode, + s->dcc_en, + s->blank_en, + s->ttu_disable, + s->underflow_status, + (s->min_ttu_vblank * frac) / ref_clk_mhz / frac, (s->min_ttu_vblank * frac) / ref_clk_mhz % frac, + (s->qos_level_low_wm * frac) / ref_clk_mhz / frac, (s->qos_level_low_wm * frac) / ref_clk_mhz % frac, + (s->qos_level_high_wm * frac) / ref_clk_mhz / frac, (s->qos_level_high_wm * frac) / ref_clk_mhz % frac); remaining_buffer -= chars_printed; pBuf += chars_printed; @@ -314,9 +341,6 @@ static unsigned int dcn10_get_cm_states(struct dc *dc, char *pBuf, unsigned int struct dpp *dpp = pool->dpps[i]; struct dcn_dpp_state s = {0}; - - - dpp->funcs->dpp_read_state(dpp, &s); if (s.is_enabled) { @@ -462,6 +486,11 @@ static unsigned int dcn10_get_clock_states(struct dc *dc, char *pBuf, unsigned i void dcn10_get_hw_state(struct dc *dc, char *pBuf, unsigned int bufSize, unsigned int mask) { + /* + * Mask Format + * Bit 0 - 15: Hardware block mask + * Bit 15: 1 = Invariant Only, 0 = All + */ const unsigned int DC_HW_STATE_MASK_HUBBUB = 0x1; const unsigned int DC_HW_STATE_MASK_HUBP = 0x2; const unsigned int DC_HW_STATE_MASK_RQ = 0x4; @@ -471,12 +500,13 @@ void dcn10_get_hw_state(struct dc *dc, char *pBuf, unsigned int bufSize, unsigne const unsigned int DC_HW_STATE_MASK_MPCC = 0x40; const unsigned int DC_HW_STATE_MASK_OTG = 0x80; const unsigned int DC_HW_STATE_MASK_CLOCKS = 0x100; + const unsigned int DC_HW_STATE_INVAR_ONLY = 0x8000; unsigned int chars_printed = 0; unsigned int remaining_buf_size = bufSize; if (mask == 0x0) - mask = 0xFFFF; + mask = 0xFFFF; // Default, capture all, invariant only if ((mask & DC_HW_STATE_MASK_HUBBUB) && remaining_buf_size > 0) { chars_printed = dcn10_get_hubbub_state(dc, pBuf, remaining_buf_size); @@ -485,7 +515,7 @@ void dcn10_get_hw_state(struct dc *dc, char *pBuf, unsigned int bufSize, unsigne } if ((mask & DC_HW_STATE_MASK_HUBP) && remaining_buf_size > 0) { - chars_printed = dcn10_get_hubp_states(dc, pBuf, remaining_buf_size); + chars_printed = dcn10_get_hubp_states(dc, pBuf, remaining_buf_size, mask & DC_HW_STATE_INVAR_ONLY); pBuf += chars_printed; remaining_buf_size -= chars_printed; } -- cgit v1.2.3 From 0e3d73f1a440eaca270a028bff51649ae99df113 Mon Sep 17 00:00:00 2001 From: Bhawanpreet Lakha Date: Mon, 22 Jan 2018 16:12:27 -0500 Subject: drm/amd/display: Add Raven2 definitions in dc Add Raven2 definitions in the dc code Signed-off-by: Bhawanpreet Lakha Reviewed-by: Harry Wentland Reviewed-by: Huang Rui Acked-by: Alex Deucher --- .../amd/display/dc/bios/command_table_helper2.c | 5 +++ drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 7 +++++ .../gpu/drm/amd/display/dc/dce/dce_clock_source.c | 7 +++++ .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 36 +++++++++++++++++++++- drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c | 5 +++ drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c | 5 +++ drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c | 4 +++ 7 files changed, 68 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/bios/command_table_helper2.c b/drivers/gpu/drm/amd/display/dc/bios/command_table_helper2.c index bbbcef566c55..65b006ad372e 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/command_table_helper2.c +++ b/drivers/gpu/drm/amd/display/dc/bios/command_table_helper2.c @@ -61,6 +61,11 @@ bool dal_bios_parser_init_cmd_tbl_helper2( return true; #endif +#if defined(CONFIG_DRM_AMD_DC_DCN1_01) + case DCN_VERSION_1_01: + *h = dal_cmd_tbl_helper_dce112_get_table2(); + return true; +#endif case DCE_VERSION_12_0: *h = dal_cmd_tbl_helper_dce112_get_table2(); return true; diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index d981755d1e4d..721dd13d2ed2 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -88,6 +88,10 @@ enum dce_version resource_parse_asic_id(struct hw_asic_id asic_id) #if defined(CONFIG_DRM_AMD_DC_DCN1_0) case FAMILY_RV: dc_version = DCN_VERSION_1_0; +#if defined(CONFIG_DRM_AMD_DC_DCN1_01) + if (ASICREV_IS_RAVEN2(asic_id.hw_internal_rev)) + dc_version = DCN_VERSION_1_01; +#endif break; #endif default: @@ -138,6 +142,9 @@ struct resource_pool *dc_create_resource_pool( #if defined(CONFIG_DRM_AMD_DC_DCN1_0) case DCN_VERSION_1_0: +#if defined(CONFIG_DRM_AMD_DC_DCN1_01) + case DCN_VERSION_1_01: +#endif res_pool = dcn10_create_resource_pool( num_virtual_links, dc); break; diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c index 5a9f3601ffb6..ae3c44aff1c8 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c @@ -601,6 +601,9 @@ static uint32_t dce110_get_pix_clk_dividers( case DCN_VERSION_1_0: #endif +#if defined(CONFIG_DRM_AMD_DC_DCN1_01) + case DCN_VERSION_1_01: +#endif dce112_get_pix_clk_dividers_helper(clk_src, pll_settings, pix_clk_params); break; @@ -907,6 +910,10 @@ static bool dce110_program_pix_clk( case DCN_VERSION_1_0: #endif +#if defined(CONFIG_DRM_AMD_DC_DCN1_01) + case DCN_VERSION_1_01: +#endif + if (clock_source->id != CLOCK_SOURCE_ID_DP_DTO) { bp_pc_params.flags.SET_GENLOCK_REF_DIV_SRC = pll_settings->use_external_clk; diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c index 1b519f8f044f..65a596ffa02a 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c @@ -152,7 +152,10 @@ enum dcn10_clk_src_array_id { DCN10_CLK_SRC_PLL1, DCN10_CLK_SRC_PLL2, DCN10_CLK_SRC_PLL3, - DCN10_CLK_SRC_TOTAL + DCN10_CLK_SRC_TOTAL, +#if defined(CONFIG_DRM_AMD_DC_DCN1_01) + DCN101_CLK_SRC_TOTAL = DCN10_CLK_SRC_PLL3 +#endif }; /* begin ********************* @@ -1163,6 +1166,10 @@ static bool construct( /* max pipe num for ASIC before check pipe fuses */ pool->base.pipe_count = pool->base.res_cap->num_timing_generator; +#if defined(CONFIG_DRM_AMD_DC_DCN1_01) + if (dc->ctx->dce_version == DCN_VERSION_1_01) + pool->base.pipe_count = 3; +#endif dc->caps.max_video_width = 3840; dc->caps.max_downscale_ratio = 200; dc->caps.i2c_speed_in_khz = 100; @@ -1194,13 +1201,28 @@ static bool construct( dcn10_clock_source_create(ctx, ctx->dc_bios, CLOCK_SOURCE_COMBO_PHY_PLL2, &clk_src_regs[2], false); + +#ifdef CONFIG_DRM_AMD_DC_DCN1_01 + if (dc->ctx->dce_version == DCN_VERSION_1_0) { + pool->base.clock_sources[DCN10_CLK_SRC_PLL3] = + dcn10_clock_source_create(ctx, ctx->dc_bios, + CLOCK_SOURCE_COMBO_PHY_PLL3, + &clk_src_regs[3], false); + } +#else pool->base.clock_sources[DCN10_CLK_SRC_PLL3] = dcn10_clock_source_create(ctx, ctx->dc_bios, CLOCK_SOURCE_COMBO_PHY_PLL3, &clk_src_regs[3], false); +#endif pool->base.clk_src_count = DCN10_CLK_SRC_TOTAL; +#if defined(CONFIG_DRM_AMD_DC_DCN1_01) + if (dc->ctx->dce_version == DCN_VERSION_1_01) + pool->base.clk_src_count = DCN101_CLK_SRC_TOTAL; +#endif + pool->base.dp_clock_source = dcn10_clock_source_create(ctx, ctx->dc_bios, CLOCK_SOURCE_ID_DP_DTO, @@ -1246,6 +1268,18 @@ static bool construct( memcpy(dc->dcn_ip, &dcn10_ip_defaults, sizeof(dcn10_ip_defaults)); memcpy(dc->dcn_soc, &dcn10_soc_defaults, sizeof(dcn10_soc_defaults)); +#if defined(CONFIG_DRM_AMD_DC_DCN1_01) + if (dc->ctx->dce_version == DCN_VERSION_1_01) { + struct dcn_soc_bounding_box *dcn_soc = dc->dcn_soc; + struct dcn_ip_params *dcn_ip = dc->dcn_ip; + struct display_mode_lib *dml = &dc->dml; + + dml->ip.max_num_dpp = 3; + /* TODO how to handle 23.84? */ + dcn_soc->dram_clock_change_latency = 23; + dcn_ip->max_num_dpp = 3; + } +#endif if (ASICREV_IS_RV1_F0(dc->ctx->asic_id.hw_internal_rev)) { dc->dcn_soc->urgent_latency = 3; dc->debug.disable_dmcu = true; diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c index 0caee3523017..a683f4102e65 100644 --- a/drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c +++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_factory.c @@ -86,6 +86,11 @@ bool dal_hw_factory_init( dal_hw_factory_dcn10_init(factory); return true; #endif +#if defined(CONFIG_DRM_AMD_DC_DCN1_01) + case DCN_VERSION_1_01: + dal_hw_factory_dcn10_init(factory); + return true; +#endif default: ASSERT_CRITICAL(false); diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c index 55c707488541..096f45628630 100644 --- a/drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c +++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_translate.c @@ -83,6 +83,11 @@ bool dal_hw_translate_init( dal_hw_translate_dcn10_init(translate); return true; #endif +#if defined(CONFIG_DRM_AMD_DC_DCN1_01) + case DCN_VERSION_1_01: + dal_hw_translate_dcn10_init(translate); + return true; +#endif default: BREAK_TO_DEBUGGER(); diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c b/drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c index 9b0bcc6b769b..e56093f26eed 100644 --- a/drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c +++ b/drivers/gpu/drm/amd/display/dc/i2caux/i2caux.c @@ -96,6 +96,10 @@ struct i2caux *dal_i2caux_create( return dal_i2caux_dcn10_create(ctx); #endif +#if defined(CONFIG_DRM_AMD_DC_DCN1_01) + case DCN_VERSION_1_01: + return dal_i2caux_dcn10_create(ctx); +#endif default: BREAK_TO_DEBUGGER(); return NULL; -- cgit v1.2.3 From d77f778e59ca858e1fb1e9d4946080d689c04711 Mon Sep 17 00:00:00 2001 From: Charlene Liu Date: Mon, 27 Aug 2018 11:31:08 -0400 Subject: drm/amd/display: Fix 3D stereo issues. We were not providing the correct pixel clocks to DML for marks calculation. Signed-off-by: Charlene Liu Reviewed-by: Dmytro Laktyushkin Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c | 6 +++++- drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c | 5 +++-- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 5 ++++- drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c | 3 +++ drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 2 ++ 5 files changed, 17 insertions(+), 4 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c index 160d11a15eac..9ebe30ba4dab 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c @@ -2881,6 +2881,7 @@ static void populate_initial_data( /* Pipes without underlay after */ for (i = 0; i < pipe_count; i++) { + unsigned int pixel_clock_khz; if (!pipe[i].stream || pipe[i].bottom_pipe) continue; @@ -2889,7 +2890,10 @@ static void populate_initial_data( data->lpt_en[num_displays + 4] = false; data->h_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.h_total); data->v_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.v_total); - data->pixel_rate[num_displays + 4] = bw_frc_to_fixed(pipe[i].stream->timing.pix_clk_khz, 1000); + pixel_clock_khz = pipe[i].stream->timing.pix_clk_khz; + if (pipe[i].stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING) + pixel_clock_khz *= 2; + data->pixel_rate[num_displays + 4] = bw_frc_to_fixed(pixel_clock_khz, 1000); if (pipe[i].plane_state) { data->src_width[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.viewport.width); data->pitch_in_pixels[num_displays + 4] = data->src_width[num_displays + 4]; diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c index 32b34134c501..80ec09eef44f 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c @@ -852,8 +852,9 @@ bool dcn_validate_bandwidth( v->v_sync_plus_back_porch[input_idx] = pipe->stream->timing.v_total - v->vactive[input_idx] - pipe->stream->timing.v_front_porch; - v->pixel_clock[input_idx] = pipe->stream->timing.pix_clk_khz / 1000.0f; - + v->pixel_clock[input_idx] = pipe->stream->timing.pix_clk_khz/1000.0; + if (pipe->stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING) + v->pixel_clock[input_idx] *= 2; if (!pipe->plane_state) { v->dcc_enable[input_idx] = dcn_bw_yes; v->source_pixel_format[input_idx] = dcn_bw_rgb_sub_32; diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index 721dd13d2ed2..2d6a4300bfa4 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -363,6 +363,9 @@ bool resource_are_streams_timing_synchronizable( || !dc_is_dp_signal(stream2->signal))) return false; + if (stream1->view_format != stream2->view_format) + return false; + return true; } static bool is_dp_and_hdmi_sharable( @@ -373,7 +376,7 @@ static bool is_dp_and_hdmi_sharable( return false; if (stream1->clamping.c_depth != COLOR_DEPTH_888 || - stream2->clamping.c_depth != COLOR_DEPTH_888) + stream2->clamping.c_depth != COLOR_DEPTH_888) return false; return true; diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c index 9f44f1cad221..b44cc7042249 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c @@ -798,6 +798,9 @@ static void get_pixel_clock_parameters( if (stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR420) { pixel_clk_params->requested_pix_clk = pixel_clk_params->requested_pix_clk / 2; } + if (stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING) + pixel_clk_params->requested_pix_clk *= 2; + } void dce110_resource_build_pipe_hw_param(struct pipe_ctx *pipe_ctx) diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c index 65a596ffa02a..f628b62d75fc 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c @@ -980,6 +980,8 @@ static void get_pixel_clock_parameters( if (stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR420) pixel_clk_params->requested_pix_clk /= 2; + if (stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING) + pixel_clk_params->requested_pix_clk *= 2; } -- cgit v1.2.3 From b07971d43c4d321c65240749765bba2b2eaeeb30 Mon Sep 17 00:00:00 2001 From: Dmytro Laktyushkin Date: Wed, 29 Aug 2018 16:23:59 -0400 Subject: drm/amd/display: stop using switch for different CS revisions Clock sources currently have support for asic specific function pointers. But actual separation into functions was never performed, leaving us with giant functions that rely on switch. This change creates separate functions, removing switch use. Signed-off-by: Dmytro Laktyushkin Reviewed-by: Tony Cheng Acked-by: Leo Li Signed-off-by: Alex Deucher --- .../gpu/drm/amd/display/dc/dce/dce_clock_source.c | 369 ++++++++++++--------- .../gpu/drm/amd/display/dc/dce/dce_clock_source.h | 9 + .../drm/amd/display/dc/dce112/dce112_resource.c | 2 +- .../drm/amd/display/dc/dce120/dce120_resource.c | 2 +- .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 2 +- 5 files changed, 217 insertions(+), 167 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c index ae3c44aff1c8..723ce80ed89c 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c @@ -584,34 +584,42 @@ static uint32_t dce110_get_pix_clk_dividers( return 0; } - switch (cs->ctx->dce_version) { - case DCE_VERSION_8_0: - case DCE_VERSION_8_1: - case DCE_VERSION_8_3: - case DCE_VERSION_10_0: - case DCE_VERSION_11_0: - pll_calc_error = - dce110_get_pix_clk_dividers_helper(clk_src, + pll_calc_error = dce110_get_pix_clk_dividers_helper(clk_src, pll_settings, pix_clk_params); - break; - case DCE_VERSION_11_2: - case DCE_VERSION_11_22: - case DCE_VERSION_12_0: -#if defined(CONFIG_DRM_AMD_DC_DCN1_0) - case DCN_VERSION_1_0: -#endif -#if defined(CONFIG_DRM_AMD_DC_DCN1_01) - case DCN_VERSION_1_01: -#endif - dce112_get_pix_clk_dividers_helper(clk_src, - pll_settings, pix_clk_params); - break; - default: - break; + return pll_calc_error; +} + +static uint32_t dce112_get_pix_clk_dividers( + struct clock_source *cs, + struct pixel_clk_params *pix_clk_params, + struct pll_settings *pll_settings) +{ + struct dce110_clk_src *clk_src = TO_DCE110_CLK_SRC(cs); + DC_LOGGER_INIT(); + + if (pix_clk_params == NULL || pll_settings == NULL + || pix_clk_params->requested_pix_clk == 0) { + DC_LOG_ERROR( + "%s: Invalid parameters!!\n", __func__); + return -1; } - return pll_calc_error; + memset(pll_settings, 0, sizeof(*pll_settings)); + + if (cs->id == CLOCK_SOURCE_ID_DP_DTO || + cs->id == CLOCK_SOURCE_ID_EXTERNAL) { + pll_settings->adjusted_pix_clk = clk_src->ext_clk_khz; + pll_settings->calculated_pix_clk = clk_src->ext_clk_khz; + pll_settings->actual_pix_clk = + pix_clk_params->requested_pix_clk; + return -1; + } + + dce112_get_pix_clk_dividers_helper(clk_src, + pll_settings, pix_clk_params); + + return 0; } static bool disable_spread_spectrum(struct dce110_clk_src *clk_src) @@ -833,6 +841,65 @@ static bool dce110_program_pix_clk( struct dce110_clk_src *clk_src = TO_DCE110_CLK_SRC(clock_source); struct bp_pixel_clock_parameters bp_pc_params = {0}; + /* First disable SS + * ATOMBIOS will enable by default SS on PLL for DP, + * do not disable it here + */ + if (clock_source->id != CLOCK_SOURCE_ID_EXTERNAL && + !dc_is_dp_signal(pix_clk_params->signal_type) && + clock_source->ctx->dce_version <= DCE_VERSION_11_0) + disable_spread_spectrum(clk_src); + + /*ATOMBIOS expects pixel rate adjusted by deep color ratio)*/ + bp_pc_params.controller_id = pix_clk_params->controller_id; + bp_pc_params.pll_id = clock_source->id; + bp_pc_params.target_pixel_clock = pll_settings->actual_pix_clk; + bp_pc_params.encoder_object_id = pix_clk_params->encoder_object_id; + bp_pc_params.signal_type = pix_clk_params->signal_type; + + bp_pc_params.reference_divider = pll_settings->reference_divider; + bp_pc_params.feedback_divider = pll_settings->feedback_divider; + bp_pc_params.fractional_feedback_divider = + pll_settings->fract_feedback_divider; + bp_pc_params.pixel_clock_post_divider = + pll_settings->pix_clk_post_divider; + bp_pc_params.flags.SET_EXTERNAL_REF_DIV_SRC = + pll_settings->use_external_clk; + + if (clk_src->bios->funcs->set_pixel_clock( + clk_src->bios, &bp_pc_params) != BP_RESULT_OK) + return false; + /* Enable SS + * ATOMBIOS will enable by default SS for DP on PLL ( DP ID clock), + * based on HW display PLL team, SS control settings should be programmed + * during PLL Reset, but they do not have effect + * until SS_EN is asserted.*/ + if (clock_source->id != CLOCK_SOURCE_ID_EXTERNAL + && !dc_is_dp_signal(pix_clk_params->signal_type)) { + + if (pix_clk_params->flags.ENABLE_SS) + if (!enable_spread_spectrum(clk_src, + pix_clk_params->signal_type, + pll_settings)) + return false; + + /* Resync deep color DTO */ + dce110_program_pixel_clk_resync(clk_src, + pix_clk_params->signal_type, + pix_clk_params->color_depth); + } + + return true; +} + +static bool dce112_program_pix_clk( + struct clock_source *clock_source, + struct pixel_clk_params *pix_clk_params, + struct pll_settings *pll_settings) +{ + struct dce110_clk_src *clk_src = TO_DCE110_CLK_SRC(clock_source); + struct bp_pixel_clock_parameters bp_pc_params = {0}; + #if defined(CONFIG_DRM_AMD_DC_DCN1_0) if (IS_FPGA_MAXIMUS_DC(clock_source->ctx->dce_environment)) { unsigned int inst = pix_clk_params->controller_id - CONTROLLER_ID_D0; @@ -864,82 +931,29 @@ static bool dce110_program_pix_clk( bp_pc_params.encoder_object_id = pix_clk_params->encoder_object_id; bp_pc_params.signal_type = pix_clk_params->signal_type; - switch (clock_source->ctx->dce_version) { - case DCE_VERSION_8_0: - case DCE_VERSION_8_1: - case DCE_VERSION_8_3: - case DCE_VERSION_10_0: - case DCE_VERSION_11_0: - bp_pc_params.reference_divider = pll_settings->reference_divider; - bp_pc_params.feedback_divider = pll_settings->feedback_divider; - bp_pc_params.fractional_feedback_divider = - pll_settings->fract_feedback_divider; - bp_pc_params.pixel_clock_post_divider = - pll_settings->pix_clk_post_divider; - bp_pc_params.flags.SET_EXTERNAL_REF_DIV_SRC = + if (clock_source->id != CLOCK_SOURCE_ID_DP_DTO) { + bp_pc_params.flags.SET_GENLOCK_REF_DIV_SRC = pll_settings->use_external_clk; - - if (clk_src->bios->funcs->set_pixel_clock( - clk_src->bios, &bp_pc_params) != BP_RESULT_OK) - return false; - /* Enable SS - * ATOMBIOS will enable by default SS for DP on PLL ( DP ID clock), - * based on HW display PLL team, SS control settings should be programmed - * during PLL Reset, but they do not have effect - * until SS_EN is asserted.*/ - if (clock_source->id != CLOCK_SOURCE_ID_EXTERNAL - && !dc_is_dp_signal(pix_clk_params->signal_type)) { - - if (pix_clk_params->flags.ENABLE_SS) - if (!enable_spread_spectrum(clk_src, - pix_clk_params->signal_type, - pll_settings)) - return false; - - /* Resync deep color DTO */ - dce110_program_pixel_clk_resync(clk_src, - pix_clk_params->signal_type, - pix_clk_params->color_depth); + bp_pc_params.flags.SET_XTALIN_REF_SRC = + !pll_settings->use_external_clk; + if (pix_clk_params->flags.SUPPORT_YCBCR420) { + bp_pc_params.flags.SUPPORT_YUV_420 = 1; } - - break; - case DCE_VERSION_11_2: - case DCE_VERSION_11_22: - case DCE_VERSION_12_0: -#if defined(CONFIG_DRM_AMD_DC_DCN1_0) - case DCN_VERSION_1_0: -#endif - -#if defined(CONFIG_DRM_AMD_DC_DCN1_01) - case DCN_VERSION_1_01: -#endif - - if (clock_source->id != CLOCK_SOURCE_ID_DP_DTO) { - bp_pc_params.flags.SET_GENLOCK_REF_DIV_SRC = - pll_settings->use_external_clk; - bp_pc_params.flags.SET_XTALIN_REF_SRC = - !pll_settings->use_external_clk; - if (pix_clk_params->flags.SUPPORT_YCBCR420) { - bp_pc_params.flags.SUPPORT_YUV_420 = 1; - } - } - if (clk_src->bios->funcs->set_pixel_clock( - clk_src->bios, &bp_pc_params) != BP_RESULT_OK) - return false; - /* Resync deep color DTO */ - if (clock_source->id != CLOCK_SOURCE_ID_DP_DTO) - dce112_program_pixel_clk_resync(clk_src, - pix_clk_params->signal_type, - pix_clk_params->color_depth, - pix_clk_params->flags.SUPPORT_YCBCR420); - break; - default: - break; } + if (clk_src->bios->funcs->set_pixel_clock( + clk_src->bios, &bp_pc_params) != BP_RESULT_OK) + return false; + /* Resync deep color DTO */ + if (clock_source->id != CLOCK_SOURCE_ID_DP_DTO) + dce112_program_pixel_clk_resync(clk_src, + pix_clk_params->signal_type, + pix_clk_params->color_depth, + pix_clk_params->flags.SUPPORT_YCBCR420); return true; } + static bool dce110_clock_source_power_down( struct clock_source *clk_src) { @@ -966,12 +980,19 @@ static bool dce110_clock_source_power_down( /*****************************************/ /* Constructor */ /*****************************************/ + +static const struct clock_source_funcs dce112_clk_src_funcs = { + .cs_power_down = dce110_clock_source_power_down, + .program_pix_clk = dce112_program_pix_clk, + .get_pix_clk_dividers = dce112_get_pix_clk_dividers +}; static const struct clock_source_funcs dce110_clk_src_funcs = { .cs_power_down = dce110_clock_source_power_down, .program_pix_clk = dce110_program_pix_clk, .get_pix_clk_dividers = dce110_get_pix_clk_dividers }; + static void get_ss_info_from_atombios( struct dce110_clk_src *clk_src, enum as_signal_type as_signal, @@ -1227,81 +1248,70 @@ bool dce110_clk_src_construct( clk_src->ext_clk_khz = fw_info.external_clock_source_frequency_for_dp; - switch (clk_src->base.ctx->dce_version) { - case DCE_VERSION_8_0: - case DCE_VERSION_8_1: - case DCE_VERSION_8_3: - case DCE_VERSION_10_0: - case DCE_VERSION_11_0: - - /* structure normally used with PLL ranges from ATOMBIOS; DS on by default */ - calc_pll_cs_init_data.bp = bios; - calc_pll_cs_init_data.min_pix_clk_pll_post_divider = 1; - calc_pll_cs_init_data.max_pix_clk_pll_post_divider = - clk_src->cs_mask->PLL_POST_DIV_PIXCLK; - calc_pll_cs_init_data.min_pll_ref_divider = 1; - calc_pll_cs_init_data.max_pll_ref_divider = clk_src->cs_mask->PLL_REF_DIV; - /* when 0 use minInputPxlClkPLLFrequencyInKHz from firmwareInfo*/ - calc_pll_cs_init_data.min_override_input_pxl_clk_pll_freq_khz = 0; - /* when 0 use maxInputPxlClkPLLFrequencyInKHz from firmwareInfo*/ - calc_pll_cs_init_data.max_override_input_pxl_clk_pll_freq_khz = 0; - /*numberOfFractFBDividerDecimalPoints*/ - calc_pll_cs_init_data.num_fract_fb_divider_decimal_point = - FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM; - /*number of decimal point to round off for fractional feedback divider value*/ - calc_pll_cs_init_data.num_fract_fb_divider_decimal_point_precision = - FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM; - calc_pll_cs_init_data.ctx = ctx; - - /*structure for HDMI, no SS or SS% <= 0.06% for 27 MHz Ref clock */ - calc_pll_cs_init_data_hdmi.bp = bios; - calc_pll_cs_init_data_hdmi.min_pix_clk_pll_post_divider = 1; - calc_pll_cs_init_data_hdmi.max_pix_clk_pll_post_divider = - clk_src->cs_mask->PLL_POST_DIV_PIXCLK; - calc_pll_cs_init_data_hdmi.min_pll_ref_divider = 1; - calc_pll_cs_init_data_hdmi.max_pll_ref_divider = clk_src->cs_mask->PLL_REF_DIV; - /* when 0 use minInputPxlClkPLLFrequencyInKHz from firmwareInfo*/ - calc_pll_cs_init_data_hdmi.min_override_input_pxl_clk_pll_freq_khz = 13500; - /* when 0 use maxInputPxlClkPLLFrequencyInKHz from firmwareInfo*/ - calc_pll_cs_init_data_hdmi.max_override_input_pxl_clk_pll_freq_khz = 27000; - /*numberOfFractFBDividerDecimalPoints*/ - calc_pll_cs_init_data_hdmi.num_fract_fb_divider_decimal_point = - FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM; - /*number of decimal point to round off for fractional feedback divider value*/ - calc_pll_cs_init_data_hdmi.num_fract_fb_divider_decimal_point_precision = - FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM; - calc_pll_cs_init_data_hdmi.ctx = ctx; - - clk_src->ref_freq_khz = fw_info.pll_info.crystal_frequency; - - if (clk_src->base.id == CLOCK_SOURCE_ID_EXTERNAL) - return true; - - /* PLL only from here on */ - ss_info_from_atombios_create(clk_src); - - if (!calc_pll_max_vco_construct( - &clk_src->calc_pll, - &calc_pll_cs_init_data)) { - ASSERT_CRITICAL(false); - goto unexpected_failure; - } + /* structure normally used with PLL ranges from ATOMBIOS; DS on by default */ + calc_pll_cs_init_data.bp = bios; + calc_pll_cs_init_data.min_pix_clk_pll_post_divider = 1; + calc_pll_cs_init_data.max_pix_clk_pll_post_divider = + clk_src->cs_mask->PLL_POST_DIV_PIXCLK; + calc_pll_cs_init_data.min_pll_ref_divider = 1; + calc_pll_cs_init_data.max_pll_ref_divider = clk_src->cs_mask->PLL_REF_DIV; + /* when 0 use minInputPxlClkPLLFrequencyInKHz from firmwareInfo*/ + calc_pll_cs_init_data.min_override_input_pxl_clk_pll_freq_khz = 0; + /* when 0 use maxInputPxlClkPLLFrequencyInKHz from firmwareInfo*/ + calc_pll_cs_init_data.max_override_input_pxl_clk_pll_freq_khz = 0; + /*numberOfFractFBDividerDecimalPoints*/ + calc_pll_cs_init_data.num_fract_fb_divider_decimal_point = + FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM; + /*number of decimal point to round off for fractional feedback divider value*/ + calc_pll_cs_init_data.num_fract_fb_divider_decimal_point_precision = + FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM; + calc_pll_cs_init_data.ctx = ctx; + + /*structure for HDMI, no SS or SS% <= 0.06% for 27 MHz Ref clock */ + calc_pll_cs_init_data_hdmi.bp = bios; + calc_pll_cs_init_data_hdmi.min_pix_clk_pll_post_divider = 1; + calc_pll_cs_init_data_hdmi.max_pix_clk_pll_post_divider = + clk_src->cs_mask->PLL_POST_DIV_PIXCLK; + calc_pll_cs_init_data_hdmi.min_pll_ref_divider = 1; + calc_pll_cs_init_data_hdmi.max_pll_ref_divider = clk_src->cs_mask->PLL_REF_DIV; + /* when 0 use minInputPxlClkPLLFrequencyInKHz from firmwareInfo*/ + calc_pll_cs_init_data_hdmi.min_override_input_pxl_clk_pll_freq_khz = 13500; + /* when 0 use maxInputPxlClkPLLFrequencyInKHz from firmwareInfo*/ + calc_pll_cs_init_data_hdmi.max_override_input_pxl_clk_pll_freq_khz = 27000; + /*numberOfFractFBDividerDecimalPoints*/ + calc_pll_cs_init_data_hdmi.num_fract_fb_divider_decimal_point = + FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM; + /*number of decimal point to round off for fractional feedback divider value*/ + calc_pll_cs_init_data_hdmi.num_fract_fb_divider_decimal_point_precision = + FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM; + calc_pll_cs_init_data_hdmi.ctx = ctx; + + clk_src->ref_freq_khz = fw_info.pll_info.crystal_frequency; + + if (clk_src->base.id == CLOCK_SOURCE_ID_EXTERNAL) + return true; + /* PLL only from here on */ + ss_info_from_atombios_create(clk_src); - calc_pll_cs_init_data_hdmi. - min_override_input_pxl_clk_pll_freq_khz = clk_src->ref_freq_khz/2; - calc_pll_cs_init_data_hdmi. - max_override_input_pxl_clk_pll_freq_khz = clk_src->ref_freq_khz; + if (!calc_pll_max_vco_construct( + &clk_src->calc_pll, + &calc_pll_cs_init_data)) { + ASSERT_CRITICAL(false); + goto unexpected_failure; + } - if (!calc_pll_max_vco_construct( - &clk_src->calc_pll_hdmi, &calc_pll_cs_init_data_hdmi)) { - ASSERT_CRITICAL(false); - goto unexpected_failure; - } - break; - default: - break; + calc_pll_cs_init_data_hdmi. + min_override_input_pxl_clk_pll_freq_khz = clk_src->ref_freq_khz/2; + calc_pll_cs_init_data_hdmi. + max_override_input_pxl_clk_pll_freq_khz = clk_src->ref_freq_khz; + + + if (!calc_pll_max_vco_construct( + &clk_src->calc_pll_hdmi, &calc_pll_cs_init_data_hdmi)) { + ASSERT_CRITICAL(false); + goto unexpected_failure; } return true; @@ -1310,3 +1320,34 @@ unexpected_failure: return false; } +bool dce112_clk_src_construct( + struct dce110_clk_src *clk_src, + struct dc_context *ctx, + struct dc_bios *bios, + enum clock_source_id id, + const struct dce110_clk_src_regs *regs, + const struct dce110_clk_src_shift *cs_shift, + const struct dce110_clk_src_mask *cs_mask) +{ + struct dc_firmware_info fw_info = { { 0 } }; + + clk_src->base.ctx = ctx; + clk_src->bios = bios; + clk_src->base.id = id; + clk_src->base.funcs = &dce112_clk_src_funcs; + + clk_src->regs = regs; + clk_src->cs_shift = cs_shift; + clk_src->cs_mask = cs_mask; + + if (clk_src->bios->funcs->get_firmware_info( + clk_src->bios, &fw_info) != BP_RESULT_OK) { + ASSERT_CRITICAL(false); + return false; + } + + clk_src->ext_clk_khz = fw_info.external_clock_source_frequency_for_dp; + + return true; +} + diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.h b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.h index cdeb96a268fb..1ed7695a76d3 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.h @@ -144,4 +144,13 @@ bool dce110_clk_src_construct( const struct dce110_clk_src_shift *cs_shift, const struct dce110_clk_src_mask *cs_mask); +bool dce112_clk_src_construct( + struct dce110_clk_src *clk_src, + struct dc_context *ctx, + struct dc_bios *bios, + enum clock_source_id id, + const struct dce110_clk_src_regs *regs, + const struct dce110_clk_src_shift *cs_shift, + const struct dce110_clk_src_mask *cs_mask); + #endif diff --git a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c index 2aa922cdcc58..0f8332ea1160 100644 --- a/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c @@ -670,7 +670,7 @@ struct clock_source *dce112_clock_source_create( if (!clk_src) return NULL; - if (dce110_clk_src_construct(clk_src, ctx, bios, id, + if (dce112_clk_src_construct(clk_src, ctx, bios, id, regs, &cs_shift, &cs_mask)) { clk_src->base.dp_clk_src = dp_clk_src; return &clk_src->base; diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c index 465f68655db2..59055801af44 100644 --- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c @@ -456,7 +456,7 @@ struct clock_source *dce120_clock_source_create( if (!clk_src) return NULL; - if (dce110_clk_src_construct(clk_src, ctx, bios, id, + if (dce112_clk_src_construct(clk_src, ctx, bios, id, regs, &cs_shift, &cs_mask)) { clk_src->base.dp_clk_src = dp_clk_src; return &clk_src->base; diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c index f628b62d75fc..cb1b134b8fcb 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c @@ -749,7 +749,7 @@ struct clock_source *dcn10_clock_source_create( if (!clk_src) return NULL; - if (dce110_clk_src_construct(clk_src, ctx, bios, id, + if (dce112_clk_src_construct(clk_src, ctx, bios, id, regs, &cs_shift, &cs_mask)) { clk_src->base.dp_clk_src = dp_clk_src; return &clk_src->base; -- cgit v1.2.3 From c276f81b72401d64eac221d53ba24986186c502a Mon Sep 17 00:00:00 2001 From: Chiawen Huang Date: Wed, 29 Aug 2018 18:39:38 +0800 Subject: drm/amd/display: add aux i2c event log. [Why] support i2c transition event log [How] refined aux REQ and REP events in aux flow. commented REQ and REP events in i2c flow. note: i2c event log is currently commented out. more work is required to find an portocol parser to and generate event for the parser Signed-off-by: Chiawen Huang Reviewed-by: Tony Cheng Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dm_event_log.h | 5 +++-- drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c | 9 +++++---- drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c | 4 ++++ 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dm_event_log.h b/drivers/gpu/drm/amd/display/dc/dm_event_log.h index 00a275dfa472..34a701ca879e 100644 --- a/drivers/gpu/drm/amd/display/dc/dm_event_log.h +++ b/drivers/gpu/drm/amd/display/dc/dm_event_log.h @@ -31,7 +31,8 @@ #define __DM_EVENT_LOG_H__ -#define EVENT_LOG_AUX_REQ(dcc, type, action, address, len, data) -#define EVENT_LOG_AUX_Reply(dcc, type, swStatus, replyStatus, len, data) +#define EVENT_LOG_AUX_REQ(ddc, type, action, address, len, data) +#define EVENT_LOG_AUX_REP(ddc, type, replyStatus, len, data) #endif + diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c b/drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c index 4a88fc76614e..8eee8ace1259 100644 --- a/drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c +++ b/drivers/gpu/drm/amd/display/dc/i2caux/dce110/aux_engine_dce110.c @@ -274,8 +274,8 @@ static void submit_channel_request( REG_WAIT(AUX_SW_STATUS, AUX_SW_DONE, 0, 10, aux110->timeout_period/10); REG_UPDATE(AUX_SW_CONTROL, AUX_SW_GO, 1); - EVENT_LOG_AUX_REQ(engine->base.ddc->pin_data->en, Native, request->action, - request->address, request->length, request->data); + EVENT_LOG_AUX_REQ(engine->base.ddc->pin_data->en, EVENT_LOG_AUX_ORIGIN_NATIVE, + request->action, request->address, request->length, request->data); } static int read_channel_reply(struct aux_engine *engine, uint32_t size, @@ -340,8 +340,9 @@ static void process_channel_reply( bytes_replied = read_channel_reply(engine, reply->length, reply->data, &reply_result, &sw_status); - EVENT_LOG_AUX_Reply(engine->base.ddc->pin_data->en, Native, - sw_status, reply_result, bytes_replied, reply->data); + EVENT_LOG_AUX_REP(engine->base.ddc->pin_data->en, + EVENT_LOG_AUX_ORIGIN_NATIVE, reply_result, + bytes_replied, reply->data); /* in case HPD is LOW, exit AUX transaction */ if ((sw_status & AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK)) { diff --git a/drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c b/drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c index c995ef4ea5a4..141898533e8e 100644 --- a/drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c +++ b/drivers/gpu/drm/amd/display/dc/i2caux/i2c_hw_engine.c @@ -121,6 +121,8 @@ bool dal_i2c_hw_engine_submit_request( hw_engine->base.funcs->submit_channel_request( &hw_engine->base, &request); + /* EVENT_LOG_AUX_REQ(engine->ddc->pin_data->en, EVENT_LOG_AUX_ORIGIN_I2C, */ + /* request.action, request.address, request.length, request.data); */ if ((request.status == I2C_CHANNEL_OPERATION_FAILED) || (request.status == I2C_CHANNEL_OPERATION_ENGINE_BUSY)) { @@ -169,6 +171,8 @@ bool dal_i2c_hw_engine_submit_request( hw_engine->base.funcs-> process_channel_reply(&hw_engine->base, &reply); + /* EVENT_LOG_AUX_REP(engine->ddc->pin_data->en, EVENT_LOG_AUX_ORIGIN_I2C, */ + /* AUX_TRANSACTION_REPLY_I2C_ACK, reply.length, reply.data); */ } -- cgit v1.2.3 From cac7643a27ff15a3be2bf375fe7abd4cced228c3 Mon Sep 17 00:00:00 2001 From: Tony Cheng Date: Mon, 27 Aug 2018 13:35:31 -0400 Subject: drm/amd/display: dc 3.1.66 Signed-off-by: Tony Cheng Reviewed-by: Steven Chiu Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index a769d07d947f..7691139363a9 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -38,7 +38,7 @@ #include "inc/compressor.h" #include "dml/display_mode_lib.h" -#define DC_VER "3.1.65" +#define DC_VER "3.1.66" #define MAX_SURFACES 3 #define MAX_STREAMS 6 -- cgit v1.2.3 From 16f4c69549ef676bc278be8b267a811b6f8f59ad Mon Sep 17 00:00:00 2001 From: Chiawen Huang Date: Wed, 5 Sep 2018 20:34:57 +0800 Subject: drm/amd/display: add query HPD interface. [Why] current dc_link_detect function is not only detection but also update some link data. [How] added a pure get HPD state function. Signed-off-by: Chiawen Huang Reviewed-by: Tony Cheng Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 18 ++++++++++++++++++ drivers/gpu/drm/amd/display/dc/dc_link.h | 1 + 2 files changed, 19 insertions(+) (limited to 'drivers/gpu/drm/amd/display/dc') diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index 9d8dc2c1ca65..bd58dbae7d3e 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c @@ -890,6 +890,24 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) return true; } +bool dc_link_get_hpd_state(struct dc_link *dc_link) +{ + struct gpio *hpd_pin; + uint32_t state; + + hpd_pin = get_hpd_gpio(dc_link->ctx->dc_bios, + dc_link->link_id, dc_link->ctx->gpio_service); + if (hpd_pin == NULL) + ASSERT(false); + + dal_gpio_open(hpd_pin, GPIO_MODE_INTERRUPT); + dal_gpio_get_value(hpd_pin, &state); + dal_gpio_close(hpd_pin); + dal_gpio_destroy_irq(&hpd_pin); + + return state; +} + static enum hpd_source_id get_hpd_line( struct dc_link *link) { diff --git a/drivers/gpu/drm/amd/display/dc/dc_link.h b/drivers/gpu/drm/amd/display/dc/dc_link.h index d43cefbc43d3..438fb35d87b8 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_link.h +++ b/drivers/gpu/drm/amd/display/dc/dc_link.h @@ -167,6 +167,7 @@ enum dc_detect_reason { }; bool dc_link_detect(struct dc_link *dc_link, enum dc_detect_reason reason); +bool dc_link_get_hpd_state(struct dc_link *dc_link); /* Notify DC about DP RX Interrupt (aka Short Pulse Interrupt). * Return: -- cgit v1.2.3