diff mbox series

[v9,2/7] drm/mediatek: Add crtc path enum for all_drm_priv array

Message ID 20230809181525.7561-3-jason-jh.lin@mediatek.com (mailing list archive)
State New, archived
Headers show
Series Add connector dynamic selection capability | expand

Commit Message

Jason-JH.Lin Aug. 9, 2023, 6:15 p.m. UTC
Add mtk_drm_crtc_path enum for each display path.

Instead of using array index of all_drm_priv in mtk_drm_kms_init(),
mtk_drm_crtc_path enum can make code more readable.

Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 6 +++---
 drivers/gpu/drm/mediatek/mtk_drm_drv.h | 8 +++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)

Comments

Fei Shao Aug. 10, 2023, 5:35 a.m. UTC | #1
On Thu, Aug 10, 2023 at 2:15 AM Jason-JH.Lin <jason-jh.lin@mediatek.com> wrote:
>
> Add mtk_drm_crtc_path enum for each display path.
>
> Instead of using array index of all_drm_priv in mtk_drm_kms_init(),
> mtk_drm_crtc_path enum can make code more readable.
>
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>

Tested with MT8188 and the internal display is up and functioning.

Reviewed-by: Fei Shao <fshao@chromium.org>
Tested-by: Fei Shao <fshao@chromium.org>
CK Hu (胡俊光) Aug. 21, 2023, 6:31 a.m. UTC | #2
On Thu, 2023-08-10 at 02:15 +0800, Jason-JH.Lin wrote:
> Add mtk_drm_crtc_path enum for each display path.
> 
> Instead of using array index of all_drm_priv in mtk_drm_kms_init(),
> mtk_drm_crtc_path enum can make code more readable.

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> 
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 6 +++---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.h | 8 +++++++-
>  2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 249c9fd6347e..89a38561ba27 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -465,21 +465,21 @@ static int mtk_drm_kms_init(struct drm_device
> *drm)
>  		for (j = 0; j < private->data->mmsys_dev_num; j++) {
>  			priv_n = private->all_drm_private[j];
>  
> -			if (i == 0 && priv_n->data->main_len) {
> +			if (i == CRTC_MAIN && priv_n->data->main_len) {
>  				ret = mtk_drm_crtc_create(drm, priv_n-
> >data->main_path,
>  							  priv_n->data-
> >main_len, j);
>  				if (ret)
>  					goto err_component_unbind;
>  
>  				continue;
> -			} else if (i == 1 && priv_n->data->ext_len) {
> +			} else if (i == CRTC_EXT && priv_n->data-
> >ext_len) {
>  				ret = mtk_drm_crtc_create(drm, priv_n-
> >data->ext_path,
>  							  priv_n->data-
> >ext_len, j);
>  				if (ret)
>  					goto err_component_unbind;
>  
>  				continue;
> -			} else if (i == 2 && priv_n->data->third_len) {
> +			} else if (i == CRTC_THIRD && priv_n->data-
> >third_len) {
>  				ret = mtk_drm_crtc_create(drm, priv_n-
> >data->third_path,
>  							  priv_n->data-
> >third_len, j);
>  				if (ret)
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> index eb2fd45941f0..f4de8bb27685 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> @@ -9,11 +9,17 @@
>  #include <linux/io.h>
>  #include "mtk_drm_ddp_comp.h"
>  
> -#define MAX_CRTC	3
>  #define MAX_CONNECTOR	2
>  #define DDP_COMPONENT_DRM_OVL_ADAPTOR (DDP_COMPONENT_ID_MAX + 1)
>  #define DDP_COMPONENT_DRM_ID_MAX (DDP_COMPONENT_DRM_OVL_ADAPTOR + 1)
>  
> +enum mtk_drm_crtc_path {
> +	CRTC_MAIN,
> +	CRTC_EXT,
> +	CRTC_THIRD,
> +	MAX_CRTC,
> +};
> +
>  struct device;
>  struct device_node;
>  struct drm_crtc;
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 249c9fd6347e..89a38561ba27 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -465,21 +465,21 @@  static int mtk_drm_kms_init(struct drm_device *drm)
 		for (j = 0; j < private->data->mmsys_dev_num; j++) {
 			priv_n = private->all_drm_private[j];
 
-			if (i == 0 && priv_n->data->main_len) {
+			if (i == CRTC_MAIN && priv_n->data->main_len) {
 				ret = mtk_drm_crtc_create(drm, priv_n->data->main_path,
 							  priv_n->data->main_len, j);
 				if (ret)
 					goto err_component_unbind;
 
 				continue;
-			} else if (i == 1 && priv_n->data->ext_len) {
+			} else if (i == CRTC_EXT && priv_n->data->ext_len) {
 				ret = mtk_drm_crtc_create(drm, priv_n->data->ext_path,
 							  priv_n->data->ext_len, j);
 				if (ret)
 					goto err_component_unbind;
 
 				continue;
-			} else if (i == 2 && priv_n->data->third_len) {
+			} else if (i == CRTC_THIRD && priv_n->data->third_len) {
 				ret = mtk_drm_crtc_create(drm, priv_n->data->third_path,
 							  priv_n->data->third_len, j);
 				if (ret)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
index eb2fd45941f0..f4de8bb27685 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
@@ -9,11 +9,17 @@ 
 #include <linux/io.h>
 #include "mtk_drm_ddp_comp.h"
 
-#define MAX_CRTC	3
 #define MAX_CONNECTOR	2
 #define DDP_COMPONENT_DRM_OVL_ADAPTOR (DDP_COMPONENT_ID_MAX + 1)
 #define DDP_COMPONENT_DRM_ID_MAX (DDP_COMPONENT_DRM_OVL_ADAPTOR + 1)
 
+enum mtk_drm_crtc_path {
+	CRTC_MAIN,
+	CRTC_EXT,
+	CRTC_THIRD,
+	MAX_CRTC,
+};
+
 struct device;
 struct device_node;
 struct drm_crtc;