On Mon, Aug 25, 2025 at 10:16:22PM +0800, Yongxing Mou wrote:
> From: Abhinav Kumar <quic_abhin...@quicinc.com>
> 
> Use msm_dp_get_mst_intf_id() to get the interface ID for the DP MST
> controller as the intf_id is unique for each MST stream of each
> DP controller.

I think we have one sensible exception: SC8180X, where we have several
DP controllers and one shared DP interface, but let's forget about it
for now...

> 
> Signed-off-by: Abhinav Kumar <quic_abhin...@quicinc.com>
> Signed-off-by: Yongxing Mou <yongxing....@oss.qualcomm.com>
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 51 
> +++++++++++++++++++++++++----
>  1 file changed, 44 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> index 
> 05e5f3463e30c9a6bd5b740580720ae2bf6b3246..2eb5397d15732b224372c68d0b2b7167da9f2896
>  100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> @@ -1429,17 +1429,52 @@ static void dpu_encoder_virt_atomic_disable(struct 
> drm_encoder *drm_enc,
>  
>  static struct dpu_hw_intf *dpu_encoder_get_intf(const struct dpu_mdss_cfg 
> *catalog,
>               struct dpu_rm *dpu_rm,
> -             enum dpu_intf_type type, u32 controller_id)
> +             enum dpu_intf_type type, int enc_type, u32 id)
>  {
> -     int i = 0;
> +     int i = 0, cnt = 0;
> +     int controller_id = id >> 16;
> +     int stream_id = id & 0x0F;
>  
>       if (type == INTF_WB)
>               return NULL;
>  
> -     for (i = 0; i < catalog->intf_count; i++) {
> -             if (catalog->intf[i].type == type
> -                 && catalog->intf[i].controller_id == controller_id) {
> -                     return dpu_rm_get_intf(dpu_rm, catalog->intf[i].id);
> +     if (enc_type == DRM_MODE_ENCODER_DPMST) {
> +             /* The intf order in dpu_intf_cfg matches the mapping in the DP 
> HPG.
> +              * example:
> +              * DPU_8_4_0 - DP Controller intf to stream Mapping
> +              *
> +              * +-------------+----------+----------+----------+----------+
> +              * | stream_id   |    0     |    1     |    2     |    3     |
> +              * +-------------+----------+----------+----------+----------+
> +              * | DP0         | INTF_0   | INTF_3   | INTF_6   | INTF_7   |
> +              * | DP1         | INTF_4   | INTF_8   |          |          |
> +              * +-------------+----------+----------+----------+----------+
> +              *
> +              * DPU_9_2_0 - DP Controller intf to stream Mapping
> +              *
> +              * +-------------+----------+----------+
> +              * | Controller  |    0     |    1     |
> +              * +-------------+----------+----------+
> +              * | DP0         | INTF_0   | INTF_3   |
> +              * | DP1         | INTF_4   | INTF_8   |
> +              * | DP2         | INTF_6   | INTF_7   |
> +              * +-------------+----------+----------+
> +              */
> +             DPU_DEBUG("controller_id %d for stream_id = %d\n", 
> controller_id, stream_id);
> +             for (i = 0; i < catalog->intf_count; i++) {
> +                     if (catalog->intf[i].type == INTF_DP
> +                     && controller_id == catalog->intf[i].controller_id) {

&& should be on the previous line

> +                             if (cnt == stream_id)

if (cnt++ == stream_id) return;

> +                                     return dpu_rm_get_intf(dpu_rm, 
> catalog->intf[i].id);
> +                             cnt++;
> +                     }
> +             }

return NULL, drop else{}

> +     } else {
> +             for (i = 0; i < catalog->intf_count; i++) {
> +                     if (catalog->intf[i].type == type
> +                     && catalog->intf[i].controller_id == controller_id) {
> +                             return dpu_rm_get_intf(dpu_rm, 
> catalog->intf[i].id);
> +                     }
>               }
>       }
>  
> @@ -2670,7 +2705,9 @@ static int dpu_encoder_setup_display(struct 
> dpu_encoder_virt *dpu_enc,
>  
>               phys_params.hw_intf = dpu_encoder_get_intf(dpu_kms->catalog, 
> &dpu_kms->rm,
>                                                          disp_info->intf_type,
> -                                                        controller_id);
> +                                                        
> dpu_enc->base.encoder_type,
> +                                                        controller_id << 16
> +                                                        | 
> disp_info->stream_id);

No need to, just pass whole disp_info pointer.

>  
>               if (disp_info->intf_type == INTF_WB && controller_id < WB_MAX)
>                       phys_params.hw_wb = dpu_rm_get_wb(&dpu_kms->rm, 
> controller_id);
> 
> -- 
> 2.34.1
> 

-- 
With best wishes
Dmitry

Reply via email to