diff mbox series

drm/mediatek: Find the cursor plane instead of hard coding it

Message ID 20200207152348.1.Ie0633018fc787dda6e869cae23df76ae30f2a686@changeid (mailing list archive)
State Mainlined
Commit 318caac7c81cdf5806df30c3d72385659a5f0f53
Headers show
Series drm/mediatek: Find the cursor plane instead of hard coding it | expand

Commit Message

Evan Benn Feb. 7, 2020, 4:23 a.m. UTC
The cursor and primary planes were hard coded.
Now search for them for passing to drm_crtc_init_with_planes

Signed-off-by: Evan Benn <evanbenn@chromium.org>
---

 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Comments

Evan Benn Feb. 7, 2020, 4:52 a.m. UTC | #1
Apologies for the confusing thread. Please apply the above patch:
'drm/mediatek: Find the cursor plane instead of hard coding it'
before Sean Paul's original patch:
'drm/mediatek: Ensure the cursor plane is on top of other overlays'

This way authorship is correctly preserved, but we do not introduce the bug.

Thanks


On Fri, Feb 7, 2020 at 3:23 PM Evan Benn <evanbenn@chromium.org> wrote:
>
> The cursor and primary planes were hard coded.
> Now search for them for passing to drm_crtc_init_with_planes
>
> Signed-off-by: Evan Benn <evanbenn@chromium.org>
> ---
>
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 7b392d6c71cc..935652990afa 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -658,10 +658,18 @@ static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = {
>
>  static int mtk_drm_crtc_init(struct drm_device *drm,
>                              struct mtk_drm_crtc *mtk_crtc,
> -                            struct drm_plane *primary,
> -                            struct drm_plane *cursor, unsigned int pipe)
> +                            unsigned int pipe)
>  {
> -       int ret;
> +       struct drm_plane *primary = NULL;
> +       struct drm_plane *cursor = NULL;
> +       int i, ret;
> +
> +       for (i = 0; i < mtk_crtc->layer_nr; i++) {
> +               if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_PRIMARY)
> +                       primary = &mtk_crtc->planes[i];
> +               else if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_CURSOR)
> +                       cursor = &mtk_crtc->planes[i];
> +       }
>
>         ret = drm_crtc_init_with_planes(drm, &mtk_crtc->base, primary, cursor,
>                                         &mtk_crtc_funcs, NULL);
> @@ -830,9 +838,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
>                         return ret;
>         }
>
> -       ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0],
> -                               mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] :
> -                               NULL, pipe);
> +       ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, pipe);
>         if (ret < 0)
>                 return ret;
>
> --
> 2.25.0.341.g760bfbb309-goog
>
CK Hu (胡俊光) Feb. 7, 2020, 8:34 a.m. UTC | #2
Hi, Evan:

On Fri, 2020-02-07 at 15:23 +1100, Evan Benn wrote:
> The cursor and primary planes were hard coded.
> Now search for them for passing to drm_crtc_init_with_planes
> 

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

> Signed-off-by: Evan Benn <evanbenn@chromium.org>
> ---
> 
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 7b392d6c71cc..935652990afa 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -658,10 +658,18 @@ static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = {
>  
>  static int mtk_drm_crtc_init(struct drm_device *drm,
>  			     struct mtk_drm_crtc *mtk_crtc,
> -			     struct drm_plane *primary,
> -			     struct drm_plane *cursor, unsigned int pipe)
> +			     unsigned int pipe)
>  {
> -	int ret;
> +	struct drm_plane *primary = NULL;
> +	struct drm_plane *cursor = NULL;
> +	int i, ret;
> +
> +	for (i = 0; i < mtk_crtc->layer_nr; i++) {
> +		if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_PRIMARY)
> +			primary = &mtk_crtc->planes[i];
> +		else if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_CURSOR)
> +			cursor = &mtk_crtc->planes[i];
> +	}
>  
>  	ret = drm_crtc_init_with_planes(drm, &mtk_crtc->base, primary, cursor,
>  					&mtk_crtc_funcs, NULL);
> @@ -830,9 +838,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
>  			return ret;
>  	}
>  
> -	ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0],
> -				mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] :
> -				NULL, pipe);
> +	ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, pipe);
>  	if (ret < 0)
>  		return ret;
>
Sean Paul Feb. 7, 2020, 5:28 p.m. UTC | #3
On Thu, Feb 6, 2020 at 11:24 PM Evan Benn <evanbenn@chromium.org> wrote:
>
> The cursor and primary planes were hard coded.
> Now search for them for passing to drm_crtc_init_with_planes
>
> Signed-off-by: Evan Benn <evanbenn@chromium.org>

I like it!

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> ---
>
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 7b392d6c71cc..935652990afa 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -658,10 +658,18 @@ static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = {
>
>  static int mtk_drm_crtc_init(struct drm_device *drm,
>                              struct mtk_drm_crtc *mtk_crtc,
> -                            struct drm_plane *primary,
> -                            struct drm_plane *cursor, unsigned int pipe)
> +                            unsigned int pipe)
>  {
> -       int ret;
> +       struct drm_plane *primary = NULL;
> +       struct drm_plane *cursor = NULL;
> +       int i, ret;
> +
> +       for (i = 0; i < mtk_crtc->layer_nr; i++) {
> +               if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_PRIMARY)
> +                       primary = &mtk_crtc->planes[i];
> +               else if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_CURSOR)
> +                       cursor = &mtk_crtc->planes[i];
> +       }
>
>         ret = drm_crtc_init_with_planes(drm, &mtk_crtc->base, primary, cursor,
>                                         &mtk_crtc_funcs, NULL);
> @@ -830,9 +838,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
>                         return ret;
>         }
>
> -       ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0],
> -                               mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] :
> -                               NULL, pipe);
> +       ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, pipe);
>         if (ret < 0)
>                 return ret;
>
> --
> 2.25.0.341.g760bfbb309-goog
>
CK Hu (胡俊光) Feb. 10, 2020, 2:53 a.m. UTC | #4
Hi, Evan:

On Fri, 2020-02-07 at 16:34 +0800, CK Hu wrote:
> Hi, Evan:
> 
> On Fri, 2020-02-07 at 15:23 +1100, Evan Benn wrote:
> > The cursor and primary planes were hard coded.
> > Now search for them for passing to drm_crtc_init_with_planes
> > 
> 
> Reviewed-by: CK Hu <ck.hu@mediatek.com>

Applied to mediatek-drm-fixes-5.6 [1], thanks.

[1]
https://github.com/ckhu-mediatek/linux.git-tags/commits/mediatek-drm-fixes-5.6

Regards,
CK

> 
> > Signed-off-by: Evan Benn <evanbenn@chromium.org>
> > ---
> > 
> >  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 18 ++++++++++++------
> >  1 file changed, 12 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > index 7b392d6c71cc..935652990afa 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > @@ -658,10 +658,18 @@ static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = {
> >  
> >  static int mtk_drm_crtc_init(struct drm_device *drm,
> >  			     struct mtk_drm_crtc *mtk_crtc,
> > -			     struct drm_plane *primary,
> > -			     struct drm_plane *cursor, unsigned int pipe)
> > +			     unsigned int pipe)
> >  {
> > -	int ret;
> > +	struct drm_plane *primary = NULL;
> > +	struct drm_plane *cursor = NULL;
> > +	int i, ret;
> > +
> > +	for (i = 0; i < mtk_crtc->layer_nr; i++) {
> > +		if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_PRIMARY)
> > +			primary = &mtk_crtc->planes[i];
> > +		else if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_CURSOR)
> > +			cursor = &mtk_crtc->planes[i];
> > +	}
> >  
> >  	ret = drm_crtc_init_with_planes(drm, &mtk_crtc->base, primary, cursor,
> >  					&mtk_crtc_funcs, NULL);
> > @@ -830,9 +838,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
> >  			return ret;
> >  	}
> >  
> > -	ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0],
> > -				mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] :
> > -				NULL, pipe);
> > +	ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, pipe);
> >  	if (ret < 0)
> >  		return ret;
> >  
>
Sean Paul Feb. 10, 2020, 2:10 p.m. UTC | #5
On Sun, Feb 9, 2020 at 9:53 PM CK Hu <ck.hu@mediatek.com> wrote:
>
> Hi, Evan:
>
> On Fri, 2020-02-07 at 16:34 +0800, CK Hu wrote:
> > Hi, Evan:
> >
> > On Fri, 2020-02-07 at 15:23 +1100, Evan Benn wrote:
> > > The cursor and primary planes were hard coded.
> > > Now search for them for passing to drm_crtc_init_with_planes
> > >
> >
> > Reviewed-by: CK Hu <ck.hu@mediatek.com>
>
> Applied to mediatek-drm-fixes-5.6 [1], thanks.
>

Hi CK,
Thanks for picking this up. Before you send the pull, could you please
reverse the order of these 2 patches? Evan's should come before mine
to prevent a regression.

Sean

> [1]
> https://github.com/ckhu-mediatek/linux.git-tags/commits/mediatek-drm-fixes-5.6
>
> Regards,
> CK
>
> >
> > > Signed-off-by: Evan Benn <evanbenn@chromium.org>
> > > ---
> > >
> > >  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 18 ++++++++++++------
> > >  1 file changed, 12 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > index 7b392d6c71cc..935652990afa 100644
> > > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > @@ -658,10 +658,18 @@ static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = {
> > >
> > >  static int mtk_drm_crtc_init(struct drm_device *drm,
> > >                          struct mtk_drm_crtc *mtk_crtc,
> > > -                        struct drm_plane *primary,
> > > -                        struct drm_plane *cursor, unsigned int pipe)
> > > +                        unsigned int pipe)
> > >  {
> > > -   int ret;
> > > +   struct drm_plane *primary = NULL;
> > > +   struct drm_plane *cursor = NULL;
> > > +   int i, ret;
> > > +
> > > +   for (i = 0; i < mtk_crtc->layer_nr; i++) {
> > > +           if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_PRIMARY)
> > > +                   primary = &mtk_crtc->planes[i];
> > > +           else if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_CURSOR)
> > > +                   cursor = &mtk_crtc->planes[i];
> > > +   }
> > >
> > >     ret = drm_crtc_init_with_planes(drm, &mtk_crtc->base, primary, cursor,
> > >                                     &mtk_crtc_funcs, NULL);
> > > @@ -830,9 +838,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
> > >                     return ret;
> > >     }
> > >
> > > -   ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0],
> > > -                           mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] :
> > > -                           NULL, pipe);
> > > +   ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, pipe);
> > >     if (ret < 0)
> > >             return ret;
> > >
> >
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
CK Hu (胡俊光) Feb. 11, 2020, 1:19 a.m. UTC | #6
On Mon, 2020-02-10 at 09:10 -0500, Sean Paul wrote:
> On Sun, Feb 9, 2020 at 9:53 PM CK Hu <ck.hu@mediatek.com> wrote:
> >
> > Hi, Evan:
> >
> > On Fri, 2020-02-07 at 16:34 +0800, CK Hu wrote:
> > > Hi, Evan:
> > >
> > > On Fri, 2020-02-07 at 15:23 +1100, Evan Benn wrote:
> > > > The cursor and primary planes were hard coded.
> > > > Now search for them for passing to drm_crtc_init_with_planes
> > > >
> > >
> > > Reviewed-by: CK Hu <ck.hu@mediatek.com>
> >
> > Applied to mediatek-drm-fixes-5.6 [1], thanks.
> >
> 
> Hi CK,
> Thanks for picking this up. Before you send the pull, could you please
> reverse the order of these 2 patches? Evan's should come before mine
> to prevent a regression.
> 
> Sean
> 

Hi, Sean:

Thanks for your notice. I've reversed the order.

Regards,
CK

> > [1]
> > https://github.com/ckhu-mediatek/linux.git-tags/commits/mediatek-drm-fixes-5.6
> >
> > Regards,
> > CK
> >
> > >
> > > > Signed-off-by: Evan Benn <evanbenn@chromium.org>
> > > > ---
> > > >
> > > >  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 18 ++++++++++++------
> > > >  1 file changed, 12 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > > index 7b392d6c71cc..935652990afa 100644
> > > > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > > @@ -658,10 +658,18 @@ static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = {
> > > >
> > > >  static int mtk_drm_crtc_init(struct drm_device *drm,
> > > >                          struct mtk_drm_crtc *mtk_crtc,
> > > > -                        struct drm_plane *primary,
> > > > -                        struct drm_plane *cursor, unsigned int pipe)
> > > > +                        unsigned int pipe)
> > > >  {
> > > > -   int ret;
> > > > +   struct drm_plane *primary = NULL;
> > > > +   struct drm_plane *cursor = NULL;
> > > > +   int i, ret;
> > > > +
> > > > +   for (i = 0; i < mtk_crtc->layer_nr; i++) {
> > > > +           if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_PRIMARY)
> > > > +                   primary = &mtk_crtc->planes[i];
> > > > +           else if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_CURSOR)
> > > > +                   cursor = &mtk_crtc->planes[i];
> > > > +   }
> > > >
> > > >     ret = drm_crtc_init_with_planes(drm, &mtk_crtc->base, primary, cursor,
> > > >                                     &mtk_crtc_funcs, NULL);
> > > > @@ -830,9 +838,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
> > > >                     return ret;
> > > >     }
> > > >
> > > > -   ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0],
> > > > -                           mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] :
> > > > -                           NULL, pipe);
> > > > +   ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, pipe);
> > > >     if (ret < 0)
> > > >             return ret;
> > > >
> > >
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 7b392d6c71cc..935652990afa 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -658,10 +658,18 @@  static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = {
 
 static int mtk_drm_crtc_init(struct drm_device *drm,
 			     struct mtk_drm_crtc *mtk_crtc,
-			     struct drm_plane *primary,
-			     struct drm_plane *cursor, unsigned int pipe)
+			     unsigned int pipe)
 {
-	int ret;
+	struct drm_plane *primary = NULL;
+	struct drm_plane *cursor = NULL;
+	int i, ret;
+
+	for (i = 0; i < mtk_crtc->layer_nr; i++) {
+		if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_PRIMARY)
+			primary = &mtk_crtc->planes[i];
+		else if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_CURSOR)
+			cursor = &mtk_crtc->planes[i];
+	}
 
 	ret = drm_crtc_init_with_planes(drm, &mtk_crtc->base, primary, cursor,
 					&mtk_crtc_funcs, NULL);
@@ -830,9 +838,7 @@  int mtk_drm_crtc_create(struct drm_device *drm_dev,
 			return ret;
 	}
 
-	ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0],
-				mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] :
-				NULL, pipe);
+	ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, pipe);
 	if (ret < 0)
 		return ret;