AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Hung <alex.hung@amd.com>
To: "Timur Kristóf" <timur.kristof@gmail.com>,
	amd-gfx@lists.freedesktop.org, Alexander.Deucher@amd.com,
	Christian.Koenig@amd.com,
	"Mario Limonciello" <mario.limonciello@amd.com>,
	"Ivan Lipski" <ivan.lipski@amd.com>,
	"Prike Liang" <Prike.Liang@amd.com>,
	"Leo Li" <sunpeng.li@amd.com>, "Ray Wu" <Ray.Wu@amd.com>,
	siqueira@igalia.com
Subject: Re: [PATCH 05/14] drm/amd/display: Refactor DAC load detection, move to HWSS
Date: Fri, 30 Jan 2026 13:00:52 -0700	[thread overview]
Message-ID: <e1d478b2-99a4-40af-94c9-5eddc72a717b@amd.com> (raw)
In-Reply-To: <20260126210837.21885-6-timur.kristof@gmail.com>



On 1/26/26 14:08, Timur Kristóf wrote:
> Slightly refactor and simplify DAC load detection.
> This prepares the code to be used for also executing DAC
> load detection on external DP bridge encoders.
> 
> DAC load detection belongs better in the hardware sequencer
> code because the implementation is HW dependent and not all
> chips support the functionality. The code is cleaner when
> link detection probably doesn't call the VBIOS directly.
> 
> Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
> ---
>   .../gpu/drm/amd/display/dc/bios/bios_parser.c | 25 ++++++++-----------
>   .../gpu/drm/amd/display/dc/dc_bios_types.h    |  4 +--
>   .../amd/display/dc/hwss/dce110/dce110_hwseq.c | 12 +++++++++
>   .../drm/amd/display/dc/hwss/hw_sequencer.h    |  1 +
>   .../drm/amd/display/dc/link/link_detection.c  | 24 +++---------------
>   5 files changed, 28 insertions(+), 38 deletions(-)
> 
> 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 9f11e6ca4051..e2b74dda00fc 100644
> --- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
> +++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c
> @@ -782,26 +782,17 @@ static enum bp_result bios_parser_encoder_control(
>   
>   static enum bp_result bios_parser_dac_load_detection(
>   	struct dc_bios *dcb,
> -	enum engine_id engine_id,
> -	enum dal_device_type device_type,
> -	uint32_t enum_id)
> +	enum engine_id engine_id)
>   {
>   	struct bios_parser *bp = BP_FROM_DCB(dcb);
>   	struct dc_context *ctx = dcb->ctx;
>   	struct bp_load_detection_parameters bp_params = {0};
> -	enum bp_result bp_result;
> +	enum bp_result bp_result = BP_RESULT_UNSUPPORTED;
>   	uint32_t bios_0_scratch;
>   	uint32_t device_id_mask = 0;
>   
> -	bp_params.engine_id = engine_id;
> -	bp_params.device_id = get_support_mask_for_device_id(device_type, enum_id);
> -
> -	if (engine_id != ENGINE_ID_DACA &&
> -	    engine_id != ENGINE_ID_DACB)
> -		return BP_RESULT_UNSUPPORTED;
> -
> -	if (!bp->cmd_tbl.dac_load_detection)
> -		return BP_RESULT_UNSUPPORTED;
> +	bp_params.device_id = get_support_mask_for_device_id(
> +		DEVICE_TYPE_CRT, engine_id == ENGINE_ID_DACB ? 2 : 1);
>   
>   	if (bp_params.device_id == ATOM_DEVICE_CRT1_SUPPORT)
>   		device_id_mask = ATOM_S0_CRT1_MASK;
> @@ -815,7 +806,13 @@ static enum bp_result bios_parser_dac_load_detection(
>   	bios_0_scratch &= ~device_id_mask;
>   	dm_write_reg(ctx, bp->base.regs->BIOS_SCRATCH_0, bios_0_scratch);
>   
> -	bp_result = bp->cmd_tbl.dac_load_detection(bp, &bp_params);
> +	if (engine_id == ENGINE_ID_DACA || engine_id == ENGINE_ID_DACB) {
> +		if (!bp->cmd_tbl.dac_load_detection)
> +			return BP_RESULT_UNSUPPORTED;
> +
> +		bp_params.engine_id = engine_id;
> +		bp_result = bp->cmd_tbl.dac_load_detection(bp, &bp_params);
> +	}
>   
>   	if (bp_result != BP_RESULT_OK)
>   		return bp_result;
> 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 40d7a7d83c40..06fdde281a0c 100644
> --- a/drivers/gpu/drm/amd/display/dc/dc_bios_types.h
> +++ b/drivers/gpu/drm/amd/display/dc/dc_bios_types.h
> @@ -99,9 +99,7 @@ struct dc_vbios_funcs {
>   		struct bp_encoder_control *cntl);
>   	enum bp_result (*dac_load_detection)(
>   		struct dc_bios *bios,
> -		enum engine_id engine_id,
> -		enum dal_device_type device_type,
> -		uint32_t enum_id);
> +		enum engine_id engine_id);
>   	enum bp_result (*transmitter_control)(
>   		struct dc_bios *bios,
>   		struct bp_transmitter_control *cntl);
> diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c b/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
> index 4659e1b489ba..4e820020252b 100644
> --- a/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
> +++ b/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
> @@ -674,6 +674,17 @@ dce110_dac_encoder_control(struct pipe_ctx *pipe_ctx, bool enable)
>   	bios->funcs->encoder_control(bios, &encoder_control);
>   }
>   
> +static bool
> +dce110_dac_load_detect(struct dc_link *link)
> +{
> +	struct dc_bios *bios = link->ctx->dc_bios;
> +	struct link_encoder *link_enc = link->link_enc;
> +	enum bp_result bp_result = BP_RESULT_FAILURE;

Nitpick - bp_result is assigned below right away so it doesn't have to 
be assigned here <-- complained by Coverity.

> +
> +	bp_result = bios->funcs->dac_load_detection(bios, link_enc->analog_engine);
> +	return bp_result == BP_RESULT_OK;
> +}
> +
>   void dce110_enable_stream(struct pipe_ctx *pipe_ctx)
>   {
>   	enum dc_lane_count lane_count =
> @@ -3442,6 +3453,7 @@ static const struct hw_sequencer_funcs dce110_funcs = {
>   	.enable_tmds_link_output = dce110_enable_tmds_link_output,
>   	.enable_dp_link_output = dce110_enable_dp_link_output,
>   	.disable_link_output = dce110_disable_link_output,
> +	.dac_load_detect = dce110_dac_load_detect,
>   };
>   
>   static const struct hwseq_private_funcs dce110_private_funcs = {
> diff --git a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
> index 51b0f0fd8fcd..5c9a758fde37 100644
> --- a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
> +++ b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
> @@ -1187,6 +1187,7 @@ struct hw_sequencer_funcs {
>   	void (*disable_link_output)(struct dc_link *link,
>   			const struct link_resource *link_res,
>   			enum signal_type signal);
> +	bool (*dac_load_detect)(struct dc_link *link);
>   
>   	void (*get_dcc_en_bits)(struct dc *dc, int *dcc_en_bits);
>   
> diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
> index 578509e8d0e2..1585cce65b0e 100644
> --- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
> +++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
> @@ -932,28 +932,10 @@ static bool link_detect_ddc_probe(struct dc_link *link)
>    */
>   static bool link_detect_dac_load_detect(struct dc_link *link)
>   {
> -	struct dc_bios *bios = link->ctx->dc_bios;
> -	struct link_encoder *link_enc = link->link_enc;
> -	enum engine_id engine_id = link_enc->preferred_engine;
> -	enum dal_device_type device_type = DEVICE_TYPE_CRT;
> -	enum bp_result bp_result = BP_RESULT_UNSUPPORTED;
> -	uint32_t enum_id;
> -
> -	switch (engine_id) {
> -	case ENGINE_ID_DACB:
> -		enum_id = 2;
> -		break;
> -	case ENGINE_ID_DACA:
> -	default:
> -		engine_id = ENGINE_ID_DACA;
> -		enum_id = 1;
> -		break;
> -	}
> -
> -	if (bios->funcs->dac_load_detection)
> -		bp_result = bios->funcs->dac_load_detection(bios, engine_id, device_type, enum_id);
> +	if (!link->dc->hwss.dac_load_detect)
> +		return false;
>   
> -	return bp_result == BP_RESULT_OK;
> +	return link->dc->hwss.dac_load_detect(link);
>   }
>   
>   /*


  reply	other threads:[~2026-01-30 20:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-26 21:08 [PATCH 00/14] drm/amd/display: Add support for external DP bridge encoders in DC Timur Kristóf
2026-01-26 21:08 ` [PATCH 01/14] drm/amd/display: Use DCE 6 link encoder for DCE 6 analog connectors Timur Kristóf
2026-01-26 21:08 ` [PATCH 02/14] drm/amd/display: Only use analog link encoder with analog engine Timur Kristóf
2026-01-26 21:08 ` [PATCH 03/14] drm/amd/display: Only use analog stream " Timur Kristóf
2026-01-26 21:08 ` [PATCH 04/14] drm/amd/display: Add color depth helper function to BIOS parser Timur Kristóf
2026-01-26 21:08 ` [PATCH 05/14] drm/amd/display: Refactor DAC load detection, move to HWSS Timur Kristóf
2026-01-30 20:00   ` Alex Hung [this message]
2026-01-26 21:08 ` [PATCH 06/14] drm/amd/display: Implement BIOS parser external encoder control Timur Kristóf
2026-01-26 21:08 ` [PATCH 07/14] drm/amd/display: Implement DDC probe over AUX channel Timur Kristóf
2026-01-30 19:53   ` Alex Hung
2026-01-26 21:08 ` [PATCH 08/14] drm/amd/display: Add ability for HWSS to prepare the DDC before use Timur Kristóf
2026-01-26 21:08 ` [PATCH 09/14] drm/amd/display: Use preferred DP link rate if specified Timur Kristóf
2026-01-26 21:08 ` [PATCH 10/14] drm/amd/display: Add DCE HWSS support for external DP bridge encoders Timur Kristóf
2026-01-26 21:08 ` [PATCH 11/14] drm/amd/display: Link detection " Timur Kristóf
2026-01-26 21:08 ` [PATCH 12/14] drm/amd/display: Use " Timur Kristóf
2026-01-26 21:08 ` [PATCH 13/14] drm/amd/display: Implement DAC load detection on " Timur Kristóf
2026-01-26 21:08 ` [PATCH 14/14] drm/amdgpu: Use DC by default on CIK APUs Timur Kristóf
2026-02-09 15:35 ` [PATCH 00/14] drm/amd/display: Add support for external DP bridge encoders in DC Rodrigo Siqueira
2026-02-09 18:12   ` Alex Hung
2026-02-09 22:10     ` Timur Kristóf
2026-02-09 23:14       ` Alex Hung
2026-02-16  4:33         ` Alex Hung

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e1d478b2-99a4-40af-94c9-5eddc72a717b@amd.com \
    --to=alex.hung@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=Prike.Liang@amd.com \
    --cc=Ray.Wu@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=ivan.lipski@amd.com \
    --cc=mario.limonciello@amd.com \
    --cc=siqueira@igalia.com \
    --cc=sunpeng.li@amd.com \
    --cc=timur.kristof@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox