Hi, Nancy:

On Wed, 2021-12-08 at 10:44 +0800, Nancy.Lin wrote:
> MT8195 have two mmsys. Modify drm for MT8195 multi-mmsys support.
> The two mmsys (vdosys0 and vdosys1) will bring up two drm drivers,
> only one drm driver register as the drm device.
> Each drm driver binds its own component. The last bind drm driver
> allocates and registers the drm device to drm core.
> Each crtc path is created with the corresponding drm driver data.
> 
> Signed-off-by: Nancy.Lin <nancy....@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c |  24 +-
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.h |   3 +-
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 300 ++++++++++++++++++--
> ----
>  drivers/gpu/drm/mediatek/mtk_drm_drv.h  |  10 +-
>  4 files changed, 246 insertions(+), 91 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index d661edf7e0fe..fe2871aca859 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -847,21 +847,28 @@ static int mtk_drm_crtc_init_comp_planes(struct
> drm_device *drm_dev,
>  }
>  
>  int mtk_drm_crtc_create(struct drm_device *drm_dev,
> -                     const enum mtk_ddp_comp_id *path, unsigned int
> path_len)
> +                     const enum mtk_ddp_comp_id *path, unsigned int
> path_len,
> +                     int priv_data_index)
>  {
>       struct mtk_drm_private *priv = drm_dev->dev_private;
>       struct device *dev = drm_dev->dev;
>       struct mtk_drm_crtc *mtk_crtc;
>       unsigned int num_comp_planes = 0;
> -     int pipe = priv->num_pipes;
>       int ret;
>       int i;
>       bool has_ctm = false;
>       uint gamma_lut_size = 0;
> +     struct drm_crtc *tmp;
> +     int crtc_i = 0;
>  
>       if (!path)
>               return 0;
>  
> +     priv = priv->all_drm_private[priv_data_index];
> +
> +     drm_for_each_crtc(tmp, drm_dev)
> +             crtc_i++;
> +
>       for (i = 0; i < path_len; i++) {
>               enum mtk_ddp_comp_id comp_id = path[i];
>               struct device_node *node;
> @@ -873,7 +880,7 @@ int mtk_drm_crtc_create(struct drm_device
> *drm_dev,
>               if (!node) {
>                       dev_info(dev,
>                                "Not creating crtc %d because
> component %d is disabled or missing\n",
> -                              pipe, comp_id);
> +                              crtc_i, comp_id);
>                       return 0;
>               }
>  
> @@ -926,29 +933,28 @@ int mtk_drm_crtc_create(struct drm_device
> *drm_dev,
>  
>       for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
>               ret = mtk_drm_crtc_init_comp_planes(drm_dev, mtk_crtc,
> i,
> -                                                 pipe);
> +                                                 crtc_i);
>               if (ret)
>                       return ret;
>       }
>  
> -     ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, pipe);
> +     ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, crtc_i);
>       if (ret < 0)
>               return ret;
>  
>       if (gamma_lut_size)
>               drm_mode_crtc_set_gamma_size(&mtk_crtc->base,
> gamma_lut_size);
>       drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, has_ctm,
> gamma_lut_size);
> -     priv->num_pipes++;
>       mutex_init(&mtk_crtc->hw_lock);
>  
>  #if IS_REACHABLE(CONFIG_MTK_CMDQ)
> +     i = (priv->data->mbox_index) ? priv->data-
> >mbox_index[drm_crtc_index(&mtk_crtc->base)] : 0;
>       mtk_crtc->cmdq_client.client.dev = mtk_crtc->mmsys_dev;
>       mtk_crtc->cmdq_client.client.tx_block = false;
>       mtk_crtc->cmdq_client.client.knows_txdone = true;
>       mtk_crtc->cmdq_client.client.rx_callback = ddp_cmdq_cb;
>       mtk_crtc->cmdq_client.chan =
> -                     mbox_request_channel(&mtk_crtc-
> >cmdq_client.client,
> -                                          drm_crtc_index(&mtk_crtc-
> >base));
> +                     mbox_request_channel(&mtk_crtc-
> >cmdq_client.client, i);

I really do not understand how does i work. Could you give an example
of the i value for mt8173 crtc0, mt8173 crtc1, and all mt8195 crtcs.

>       if (IS_ERR(mtk_crtc->cmdq_client.chan)) {
>               dev_dbg(dev, "mtk_crtc %d failed to create mailbox
> client, writing register by CPU now\n",
>                       drm_crtc_index(&mtk_crtc->base));
> @@ -958,7 +964,7 @@ int mtk_drm_crtc_create(struct drm_device
> *drm_dev,
>       if (mtk_crtc->cmdq_client.chan) {
>               ret = of_property_read_u32_index(priv->mutex_node,
>                                                "mediatek,gce-events",
> -                                              drm_crtc_index(&mtk_cr
> tc->base),
> +                                              i,
>                                                &mtk_crtc-
> >cmdq_event);
>               if (ret) {
>                       dev_dbg(dev, "mtk_crtc %d failed to get
> mediatek,gce-events property\n",
> 

[snip]

>  
>  static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data
> = {
>       .main_path = mt8195_mtk_ddp_main,
>       .main_len = ARRAY_SIZE(mt8195_mtk_ddp_main),
> +     .mmsys_dev_num = 2,

After this patch, vdosys0 would not work. So set this to 1 in this
patch, and set this to 2 in the mt8195 vdosys1 patch.

Regards,
CK

>  };
>  
> 

Reply via email to