All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/mediatek: fix crtc index computation
@ 2022-05-30 14:24 ` Fabien Parent
  0 siblings, 0 replies; 7+ messages in thread
From: Fabien Parent @ 2022-05-30 14:24 UTC (permalink / raw)
  To: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
	Matthias Brugger
  Cc: Fabien Parent, dri-devel, linux-mediatek, linux-arm-kernel, linux-kernel

The code always assume that the main path is enabled, which is not
always the case. When the main path is not enabled, the CRTC index
of the ext path is incorrect which makes the secondary path
not usable. Fix the CRTC index calculation.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 46 +++++++++++++++------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
index 5d7504a72b11..6f2abfc608fb 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
@@ -430,25 +430,47 @@ int mtk_ddp_comp_get_id(struct device_node *node,
 	return -EINVAL;
 }
 
+static bool mtk_drm_comp_is_enabled(struct drm_device *drm,
+				    const enum mtk_ddp_comp_id *path,
+				    unsigned int path_len)
+{
+	struct mtk_drm_private *priv = drm->dev_private;
+
+	return path && path_len && !!priv->comp_node[path[path_len - 1]];
+}
+
 unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
 						struct device *dev)
 {
 	struct mtk_drm_private *private = drm->dev_private;
-	unsigned int ret = 0;
+	unsigned int index = 0;
 
-	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path, private->data->main_len,
+	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path,
+				     private->data->main_len,
 				     private->ddp_comp))
-		ret = BIT(0);
-	else if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
-					  private->data->ext_len, private->ddp_comp))
-		ret = BIT(1);
-	else if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
-					  private->data->third_len, private->ddp_comp))
-		ret = BIT(2);
-	else
-		DRM_INFO("Failed to find comp in ddp table\n");
+		return BIT(index);
+
+	if (mtk_drm_comp_is_enabled(drm, private->data->main_path,
+				    private->data->main_len))
+		index++;
 
-	return ret;
+	if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
+				     private->data->ext_len,
+				     private->ddp_comp))
+		return BIT(index);
+
+	if (mtk_drm_comp_is_enabled(drm, private->data->ext_path,
+				    private->data->ext_len))
+		index++;
+
+	if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
+					  private->data->third_len,
+					  private->ddp_comp))
+		return BIT(index);
+
+	DRM_INFO("Failed to find comp in ddp table\n");
+
+	return 0;
 }
 
 int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] drm/mediatek: fix crtc index computation
@ 2022-05-30 14:24 ` Fabien Parent
  0 siblings, 0 replies; 7+ messages in thread
From: Fabien Parent @ 2022-05-30 14:24 UTC (permalink / raw)
  To: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
	Matthias Brugger
  Cc: Fabien Parent, dri-devel, linux-mediatek, linux-arm-kernel, linux-kernel

The code always assume that the main path is enabled, which is not
always the case. When the main path is not enabled, the CRTC index
of the ext path is incorrect which makes the secondary path
not usable. Fix the CRTC index calculation.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 46 +++++++++++++++------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
index 5d7504a72b11..6f2abfc608fb 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
@@ -430,25 +430,47 @@ int mtk_ddp_comp_get_id(struct device_node *node,
 	return -EINVAL;
 }
 
+static bool mtk_drm_comp_is_enabled(struct drm_device *drm,
+				    const enum mtk_ddp_comp_id *path,
+				    unsigned int path_len)
+{
+	struct mtk_drm_private *priv = drm->dev_private;
+
+	return path && path_len && !!priv->comp_node[path[path_len - 1]];
+}
+
 unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
 						struct device *dev)
 {
 	struct mtk_drm_private *private = drm->dev_private;
-	unsigned int ret = 0;
+	unsigned int index = 0;
 
-	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path, private->data->main_len,
+	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path,
+				     private->data->main_len,
 				     private->ddp_comp))
-		ret = BIT(0);
-	else if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
-					  private->data->ext_len, private->ddp_comp))
-		ret = BIT(1);
-	else if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
-					  private->data->third_len, private->ddp_comp))
-		ret = BIT(2);
-	else
-		DRM_INFO("Failed to find comp in ddp table\n");
+		return BIT(index);
+
+	if (mtk_drm_comp_is_enabled(drm, private->data->main_path,
+				    private->data->main_len))
+		index++;
 
-	return ret;
+	if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
+				     private->data->ext_len,
+				     private->ddp_comp))
+		return BIT(index);
+
+	if (mtk_drm_comp_is_enabled(drm, private->data->ext_path,
+				    private->data->ext_len))
+		index++;
+
+	if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
+					  private->data->third_len,
+					  private->ddp_comp))
+		return BIT(index);
+
+	DRM_INFO("Failed to find comp in ddp table\n");
+
+	return 0;
 }
 
 int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
-- 
2.36.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] drm/mediatek: fix crtc index computation
@ 2022-05-30 14:24 ` Fabien Parent
  0 siblings, 0 replies; 7+ messages in thread
From: Fabien Parent @ 2022-05-30 14:24 UTC (permalink / raw)
  To: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
	Matthias Brugger
  Cc: Fabien Parent, dri-devel, linux-mediatek, linux-arm-kernel, linux-kernel

The code always assume that the main path is enabled, which is not
always the case. When the main path is not enabled, the CRTC index
of the ext path is incorrect which makes the secondary path
not usable. Fix the CRTC index calculation.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 46 +++++++++++++++------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
index 5d7504a72b11..6f2abfc608fb 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
@@ -430,25 +430,47 @@ int mtk_ddp_comp_get_id(struct device_node *node,
 	return -EINVAL;
 }
 
+static bool mtk_drm_comp_is_enabled(struct drm_device *drm,
+				    const enum mtk_ddp_comp_id *path,
+				    unsigned int path_len)
+{
+	struct mtk_drm_private *priv = drm->dev_private;
+
+	return path && path_len && !!priv->comp_node[path[path_len - 1]];
+}
+
 unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
 						struct device *dev)
 {
 	struct mtk_drm_private *private = drm->dev_private;
-	unsigned int ret = 0;
+	unsigned int index = 0;
 
-	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path, private->data->main_len,
+	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path,
+				     private->data->main_len,
 				     private->ddp_comp))
-		ret = BIT(0);
-	else if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
-					  private->data->ext_len, private->ddp_comp))
-		ret = BIT(1);
-	else if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
-					  private->data->third_len, private->ddp_comp))
-		ret = BIT(2);
-	else
-		DRM_INFO("Failed to find comp in ddp table\n");
+		return BIT(index);
+
+	if (mtk_drm_comp_is_enabled(drm, private->data->main_path,
+				    private->data->main_len))
+		index++;
 
-	return ret;
+	if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
+				     private->data->ext_len,
+				     private->ddp_comp))
+		return BIT(index);
+
+	if (mtk_drm_comp_is_enabled(drm, private->data->ext_path,
+				    private->data->ext_len))
+		index++;
+
+	if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
+					  private->data->third_len,
+					  private->ddp_comp))
+		return BIT(index);
+
+	DRM_INFO("Failed to find comp in ddp table\n");
+
+	return 0;
 }
 
 int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] drm/mediatek: fix crtc index computation
@ 2022-05-30 14:24 ` Fabien Parent
  0 siblings, 0 replies; 7+ messages in thread
From: Fabien Parent @ 2022-05-30 14:24 UTC (permalink / raw)
  To: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
	Matthias Brugger
  Cc: Fabien Parent, linux-mediatek, linux-arm-kernel, dri-devel, linux-kernel

The code always assume that the main path is enabled, which is not
always the case. When the main path is not enabled, the CRTC index
of the ext path is incorrect which makes the secondary path
not usable. Fix the CRTC index calculation.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 46 +++++++++++++++------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
index 5d7504a72b11..6f2abfc608fb 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
@@ -430,25 +430,47 @@ int mtk_ddp_comp_get_id(struct device_node *node,
 	return -EINVAL;
 }
 
+static bool mtk_drm_comp_is_enabled(struct drm_device *drm,
+				    const enum mtk_ddp_comp_id *path,
+				    unsigned int path_len)
+{
+	struct mtk_drm_private *priv = drm->dev_private;
+
+	return path && path_len && !!priv->comp_node[path[path_len - 1]];
+}
+
 unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
 						struct device *dev)
 {
 	struct mtk_drm_private *private = drm->dev_private;
-	unsigned int ret = 0;
+	unsigned int index = 0;
 
-	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path, private->data->main_len,
+	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path,
+				     private->data->main_len,
 				     private->ddp_comp))
-		ret = BIT(0);
-	else if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
-					  private->data->ext_len, private->ddp_comp))
-		ret = BIT(1);
-	else if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
-					  private->data->third_len, private->ddp_comp))
-		ret = BIT(2);
-	else
-		DRM_INFO("Failed to find comp in ddp table\n");
+		return BIT(index);
+
+	if (mtk_drm_comp_is_enabled(drm, private->data->main_path,
+				    private->data->main_len))
+		index++;
 
-	return ret;
+	if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
+				     private->data->ext_len,
+				     private->ddp_comp))
+		return BIT(index);
+
+	if (mtk_drm_comp_is_enabled(drm, private->data->ext_path,
+				    private->data->ext_len))
+		index++;
+
+	if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
+					  private->data->third_len,
+					  private->ddp_comp))
+		return BIT(index);
+
+	DRM_INFO("Failed to find comp in ddp table\n");
+
+	return 0;
 }
 
 int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/mediatek: fix crtc index computation
  2022-05-30 14:24 ` Fabien Parent
  (?)
@ 2022-06-17  5:23   ` CK Hu
  -1 siblings, 0 replies; 7+ messages in thread
From: CK Hu @ 2022-06-17  5:23 UTC (permalink / raw)
  To: Fabien Parent, Chun-Kuang Hu, Philipp Zabel, David Airlie,
	Daniel Vetter, Matthias Brugger
  Cc: dri-devel, linux-mediatek, linux-arm-kernel, linux-kernel

Hi, Fabien:

On Mon, 2022-05-30 at 16:24 +0200, Fabien Parent wrote:
> The code always assume that the main path is enabled, which is not
> always the case. When the main path is not enabled, the CRTC index
> of the ext path is incorrect which makes the secondary path
> not usable. Fix the CRTC index calculation.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 46 +++++++++++++++--
> ----
>  1 file changed, 34 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> index 5d7504a72b11..6f2abfc608fb 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> @@ -430,25 +430,47 @@ int mtk_ddp_comp_get_id(struct device_node
> *node,
>  	return -EINVAL;
>  }
>  
> +static bool mtk_drm_comp_is_enabled(struct drm_device *drm,
> +				    const enum mtk_ddp_comp_id *path,
> +				    unsigned int path_len)
> +{
> +	struct mtk_drm_private *priv = drm->dev_private;
> +
> +	return path && path_len && !!priv->comp_node[path[path_len -
> 1]];

Why just check priv->comp_node[path[path_len - 1]]?
In mtk_drm_crtc_create(), crtc would not be created if any comp node in
the path is null.

Regards,
CK

> +}
> +
>  unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device
> *drm,
>  						struct device *dev)
>  {
>  	struct mtk_drm_private *private = drm->dev_private;
> -	unsigned int ret = 0;
> +	unsigned int index = 0;
>  
> -	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path,
> private->data->main_len,
> +	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path,
> +				     private->data->main_len,
>  				     private->ddp_comp))
> -		ret = BIT(0);
> -	else if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
> -					  private->data->ext_len,
> private->ddp_comp))
> -		ret = BIT(1);
> -	else if (mtk_drm_find_comp_in_ddp(dev, private->data-
> >third_path,
> -					  private->data->third_len,
> private->ddp_comp))
> -		ret = BIT(2);
> -	else
> -		DRM_INFO("Failed to find comp in ddp table\n");
> +		return BIT(index);
> +
> +	if (mtk_drm_comp_is_enabled(drm, private->data->main_path,
> +				    private->data->main_len))
> +		index++;
>  
> -	return ret;
> +	if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
> +				     private->data->ext_len,
> +				     private->ddp_comp))
> +		return BIT(index);
> +
> +	if (mtk_drm_comp_is_enabled(drm, private->data->ext_path,
> +				    private->data->ext_len))
> +		index++;
> +
> +	if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
> +					  private->data->third_len,
> +					  private->ddp_comp))
> +		return BIT(index);
> +
> +	DRM_INFO("Failed to find comp in ddp table\n");
> +
> +	return 0;
>  }
>  
>  int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp
> *comp,


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/mediatek: fix crtc index computation
@ 2022-06-17  5:23   ` CK Hu
  0 siblings, 0 replies; 7+ messages in thread
From: CK Hu @ 2022-06-17  5:23 UTC (permalink / raw)
  To: Fabien Parent, Chun-Kuang Hu, Philipp Zabel, David Airlie,
	Daniel Vetter, Matthias Brugger
  Cc: linux-mediatek, linux-arm-kernel, dri-devel, linux-kernel

Hi, Fabien:

On Mon, 2022-05-30 at 16:24 +0200, Fabien Parent wrote:
> The code always assume that the main path is enabled, which is not
> always the case. When the main path is not enabled, the CRTC index
> of the ext path is incorrect which makes the secondary path
> not usable. Fix the CRTC index calculation.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 46 +++++++++++++++--
> ----
>  1 file changed, 34 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> index 5d7504a72b11..6f2abfc608fb 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> @@ -430,25 +430,47 @@ int mtk_ddp_comp_get_id(struct device_node
> *node,
>  	return -EINVAL;
>  }
>  
> +static bool mtk_drm_comp_is_enabled(struct drm_device *drm,
> +				    const enum mtk_ddp_comp_id *path,
> +				    unsigned int path_len)
> +{
> +	struct mtk_drm_private *priv = drm->dev_private;
> +
> +	return path && path_len && !!priv->comp_node[path[path_len -
> 1]];

Why just check priv->comp_node[path[path_len - 1]]?
In mtk_drm_crtc_create(), crtc would not be created if any comp node in
the path is null.

Regards,
CK

> +}
> +
>  unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device
> *drm,
>  						struct device *dev)
>  {
>  	struct mtk_drm_private *private = drm->dev_private;
> -	unsigned int ret = 0;
> +	unsigned int index = 0;
>  
> -	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path,
> private->data->main_len,
> +	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path,
> +				     private->data->main_len,
>  				     private->ddp_comp))
> -		ret = BIT(0);
> -	else if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
> -					  private->data->ext_len,
> private->ddp_comp))
> -		ret = BIT(1);
> -	else if (mtk_drm_find_comp_in_ddp(dev, private->data-
> >third_path,
> -					  private->data->third_len,
> private->ddp_comp))
> -		ret = BIT(2);
> -	else
> -		DRM_INFO("Failed to find comp in ddp table\n");
> +		return BIT(index);
> +
> +	if (mtk_drm_comp_is_enabled(drm, private->data->main_path,
> +				    private->data->main_len))
> +		index++;
>  
> -	return ret;
> +	if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
> +				     private->data->ext_len,
> +				     private->ddp_comp))
> +		return BIT(index);
> +
> +	if (mtk_drm_comp_is_enabled(drm, private->data->ext_path,
> +				    private->data->ext_len))
> +		index++;
> +
> +	if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
> +					  private->data->third_len,
> +					  private->ddp_comp))
> +		return BIT(index);
> +
> +	DRM_INFO("Failed to find comp in ddp table\n");
> +
> +	return 0;
>  }
>  
>  int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp
> *comp,


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/mediatek: fix crtc index computation
@ 2022-06-17  5:23   ` CK Hu
  0 siblings, 0 replies; 7+ messages in thread
From: CK Hu @ 2022-06-17  5:23 UTC (permalink / raw)
  To: Fabien Parent, Chun-Kuang Hu, Philipp Zabel, David Airlie,
	Daniel Vetter, Matthias Brugger
  Cc: dri-devel, linux-mediatek, linux-arm-kernel, linux-kernel

Hi, Fabien:

On Mon, 2022-05-30 at 16:24 +0200, Fabien Parent wrote:
> The code always assume that the main path is enabled, which is not
> always the case. When the main path is not enabled, the CRTC index
> of the ext path is incorrect which makes the secondary path
> not usable. Fix the CRTC index calculation.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 46 +++++++++++++++--
> ----
>  1 file changed, 34 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> index 5d7504a72b11..6f2abfc608fb 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> @@ -430,25 +430,47 @@ int mtk_ddp_comp_get_id(struct device_node
> *node,
>  	return -EINVAL;
>  }
>  
> +static bool mtk_drm_comp_is_enabled(struct drm_device *drm,
> +				    const enum mtk_ddp_comp_id *path,
> +				    unsigned int path_len)
> +{
> +	struct mtk_drm_private *priv = drm->dev_private;
> +
> +	return path && path_len && !!priv->comp_node[path[path_len -
> 1]];

Why just check priv->comp_node[path[path_len - 1]]?
In mtk_drm_crtc_create(), crtc would not be created if any comp node in
the path is null.

Regards,
CK

> +}
> +
>  unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device
> *drm,
>  						struct device *dev)
>  {
>  	struct mtk_drm_private *private = drm->dev_private;
> -	unsigned int ret = 0;
> +	unsigned int index = 0;
>  
> -	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path,
> private->data->main_len,
> +	if (mtk_drm_find_comp_in_ddp(dev, private->data->main_path,
> +				     private->data->main_len,
>  				     private->ddp_comp))
> -		ret = BIT(0);
> -	else if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
> -					  private->data->ext_len,
> private->ddp_comp))
> -		ret = BIT(1);
> -	else if (mtk_drm_find_comp_in_ddp(dev, private->data-
> >third_path,
> -					  private->data->third_len,
> private->ddp_comp))
> -		ret = BIT(2);
> -	else
> -		DRM_INFO("Failed to find comp in ddp table\n");
> +		return BIT(index);
> +
> +	if (mtk_drm_comp_is_enabled(drm, private->data->main_path,
> +				    private->data->main_len))
> +		index++;
>  
> -	return ret;
> +	if (mtk_drm_find_comp_in_ddp(dev, private->data->ext_path,
> +				     private->data->ext_len,
> +				     private->ddp_comp))
> +		return BIT(index);
> +
> +	if (mtk_drm_comp_is_enabled(drm, private->data->ext_path,
> +				    private->data->ext_len))
> +		index++;
> +
> +	if (mtk_drm_find_comp_in_ddp(dev, private->data->third_path,
> +					  private->data->third_len,
> +					  private->ddp_comp))
> +		return BIT(index);
> +
> +	DRM_INFO("Failed to find comp in ddp table\n");
> +
> +	return 0;
>  }
>  
>  int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp
> *comp,


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-06-17  5:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-30 14:24 [PATCH] drm/mediatek: fix crtc index computation Fabien Parent
2022-05-30 14:24 ` Fabien Parent
2022-05-30 14:24 ` Fabien Parent
2022-05-30 14:24 ` Fabien Parent
2022-06-17  5:23 ` CK Hu
2022-06-17  5:23   ` CK Hu
2022-06-17  5:23   ` CK Hu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.