On Wed, Mar 26, 2025 at 01:34:17PM +0800, Hermes Wu via B4 Relay wrote:
> From: Hermes Wu <hermes...@ite.com.tw>
> 
> When connect to device which can only training done by
> step training, skip auto training when link training restart,
> usually happen when display resolution is changed.
> 
> Signed-off-by: Hermes Wu <hermes...@ite.com.tw>
> ---
>  drivers/gpu/drm/bridge/ite-it6505.c | 29 +++++++++++++++++------------
>  1 file changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c 
> b/drivers/gpu/drm/bridge/ite-it6505.c
> index 
> 2bbe787ccb1b57906f2a31a011dd92f327019b08..47f8134df8b6f5c2172c6cfdbc91da8063993a05
>  100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> @@ -467,6 +467,7 @@ struct it6505 {
>       struct delayed_work hdcp_work;
>       struct work_struct hdcp_wait_ksv_list;
>       struct completion extcon_completion;
> +     u8 step_train_only;
>       bool hdcp_desired;
>       bool is_repeater;
>       u8 hdcp_down_stream_count;
> @@ -2457,11 +2458,13 @@ static void it6505_link_step_train_process(struct 
> it6505 *it6505)
>                                    ret ? "pass" : "failed", i + 1);
>               if (ret) {
>                       it6505_link_train_ok(it6505);
> +                     it6505->step_train_only = true;
>                       return;
>               }
>       }
>  
>       DRM_DEV_DEBUG_DRIVER(dev, "training fail");
> +     it6505->step_train_only = false;
>       it6505->link_state = LINK_IDLE;
>       it6505_video_reset(it6505);
>  }
> @@ -2477,18 +2480,19 @@ static void it6505_link_training_work(struct 
> work_struct *work)
>  
>       if (!it6505_get_sink_hpd_status(it6505))
>               return;
> -
> -     for (retry = AUTO_TRAIN_RETRY; retry > 0; retry--) {
> -             it6505_link_training_setup(it6505);
> -             it6505_reset_hdcp(it6505);
> -             it6505_aux_reset(it6505);
> -
> -             ret = it6505_link_start_auto_train(it6505);
> -             DRM_DEV_DEBUG_DRIVER(dev, "auto train %s,",
> -                                  ret ? "pass" : "failed");
> -             if (ret) {
> -                     it6505_link_train_ok(it6505);
> -                     return;
> +     if (!it6505->step_train_only) {

No need to. Just

                for (retry = AUTO_TRAIN_RETRY; retry > 0 && 
!it6505->step_train_only; retry--) {

> +             for (retry = AUTO_TRAIN_RETRY; retry > 0; retry--) {
> +                     it6505_link_training_setup(it6505);
> +                     it6505_reset_hdcp(it6505);
> +                     it6505_aux_reset(it6505);
> +
> +                     ret = it6505_link_start_auto_train(it6505);
> +                     DRM_DEV_DEBUG_DRIVER(dev, "auto train %s,",
> +                                          ret ? "pass" : "failed");
> +                     if (ret) {
> +                             it6505_link_train_ok(it6505);
> +                             return;
> +                     }
>               }
>       }
>  
> @@ -2599,6 +2603,7 @@ static void it6505_irq_hpd(struct it6505 *it6505)
>                       it6505_variable_config(it6505);
>                       it6505_parse_link_capabilities(it6505);
>               }
> +             it6505->step_train_only = false;
>  
>               it6505_drm_dp_link_set_power(&it6505->aux, &it6505->link,
>                                            DP_SET_POWER_D0);
> 
> -- 
> 2.34.1
> 
> 

-- 
With best wishes
Dmitry

Reply via email to