On Sat, 2025-12-06 at 03:31 +0100, Timur Kristóf wrote:
> Just like for other signal types, call the encoder control
> command in the VBIOS to setup the DAC encoder.
> The DAC doesn't work well without this on some GPUs,
> for example the Radeon HD 7790 needs this.
>
> Fixes: 7d63519cd9ca ("drm/amd/display: Add concept of analog encoders
> (v2)")
> Signed-off-by: Timur Kristóf <[email protected]>
> ---
> .../amd/display/dc/dce/dce_stream_encoder.c | 25
> ++++++++++++++++++-
> .../amd/display/dc/inc/hw/stream_encoder.h | 4 +++
> .../amd/display/dc/link/hwss/link_hwss_dio.c | 4 +++
> 3 files changed, 32 insertions(+), 1 deletion(-)
>
> 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 574618d5d4a4..1fbf6263c235 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
> @@ -693,6 +693,24 @@ static void
> dce110_stream_encoder_lvds_set_stream_attribute(
> ASSERT(crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB);
> }
>
> +static void dce110_stream_encoder_analog_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;
Found a mistake here.
This should use the analog_id added in the previous patch.
> + cntl.pixel_clock = crtc_timing->pix_clk_100hz / 10;
> +
> + 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_throttled_vcp_size(
> struct stream_encoder *enc,
> struct fixed31_32 avg_time_slots_per_mtp)
> @@ -1521,6 +1539,8 @@ static const struct stream_encoder_funcs
> dce110_str_enc_funcs = {
> dce110_stream_encoder_dvi_set_stream_attribute,
> .lvds_set_stream_attribute =
> dce110_stream_encoder_lvds_set_stream_attribute,
> + .analog_set_stream_attribute =
> + dce110_stream_encoder_analog_set_stream_attribute,
> .set_throttled_vcp_size =
> dce110_stream_encoder_set_throttled_vcp_size,
> .update_hdmi_info_packets =
> @@ -1568,7 +1588,10 @@ void dce110_stream_encoder_construct(
> enc110->se_mask = se_mask;
> }
>
> -static const struct stream_encoder_funcs dce110_an_str_enc_funcs =
> {};
> +static const struct stream_encoder_funcs dce110_an_str_enc_funcs = {
> + .analog_set_stream_attribute =
> + dce110_stream_encoder_analog_set_stream_attribute,
> +};
>
> void dce110_analog_stream_encoder_construct(
> struct dce110_stream_encoder *enc110,
> 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 27f950ae45ee..9658b06f32f7 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
> @@ -153,6 +153,10 @@ struct stream_encoder_funcs {
> struct stream_encoder *enc,
> struct dc_crtc_timing *crtc_timing);
>
> + void (*analog_set_stream_attribute)(
> + struct stream_encoder *enc,
> + struct dc_crtc_timing *crtc_timing);
> +
> void (*set_throttled_vcp_size)(
> struct stream_encoder *enc,
> struct fixed31_32 avg_time_slots_per_mtp);
> diff --git a/drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c
> b/drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c
> index befa67b2b2ae..90ff4fdd79b7 100644
> --- a/drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c
> +++ b/drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c
> @@ -148,6 +148,10 @@ void setup_dio_stream_attribute(struct pipe_ctx
> *pipe_ctx)
> stream_encoder->funcs->lvds_set_stream_attribute(
> stream_encoder,
> &stream->timing);
> + else if (dc_is_rgb_signal(stream->signal))
> + stream_encoder->funcs->analog_set_stream_attribute(
> + stream_encoder,
> + &stream->timing);
>
> if (dc_is_dp_signal(stream->signal))
> link->dc->link_srv->dp_trace_source_sequence(link,