diff mbox

[v4,1/2] drm: bridge: Add sii902x driver

Message ID 20160601180337.28e0917b@bbrezillon (mailing list archive)
State New, archived
Headers show

Commit Message

Boris BREZILLON June 1, 2016, 4:03 p.m. UTC
On Tue, 17 May 2016 08:47:11 +0200
Daniel Vetter <daniel@ffwll.ch> wrote:

> > +static struct drm_encoder *sii902x_best_encoder(struct drm_connector *connector)
> > +{
> > +	struct sii902x *sii902x = connector_to_sii902x(connector);
> > +
> > +	return sii902x->bridge.encoder;
> > +}  
> 
> drm_atomic_helper_best_encoder should do exactly this for you. If you feel
> board pimp the atomic helpers to call that one by default to even remove
> the vfunc assingment line ;-)

Just to be sure, is that what you had in mind?

--->8---
From d218b7ea16ca35452b3174c83a207ecd406e5c88 Mon Sep 17 00:00:00 2001
From: Boris Brezillon <boris.brezillon@free-electrons.com>
Date: Wed, 1 Jun 2016 17:57:18 +0200
Subject: [PATCH] drm: atomic: Handle funcs->best_encoder == NULL case

Fallback drm_atomic_helper_best_encoder() is funcs->best_encoder() is NULL
so that DRM drivers can leave this hook unassigned if they know they want
to use drm_atomic_helper_best_encoder().

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 drivers/gpu/drm/drm_atomic_helper.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Daniel Vetter June 1, 2016, 9:56 p.m. UTC | #1
On Wed, Jun 01, 2016 at 06:03:37PM +0200, Boris Brezillon wrote:
> On Tue, 17 May 2016 08:47:11 +0200
> Daniel Vetter <daniel@ffwll.ch> wrote:
> 
> > > +static struct drm_encoder *sii902x_best_encoder(struct drm_connector *connector)
> > > +{
> > > +	struct sii902x *sii902x = connector_to_sii902x(connector);
> > > +
> > > +	return sii902x->bridge.encoder;
> > > +}  
> > 
> > drm_atomic_helper_best_encoder should do exactly this for you. If you feel
> > board pimp the atomic helpers to call that one by default to even remove
> > the vfunc assingment line ;-)
> 
> Just to be sure, is that what you had in mind?

Exactly, I'll pick this one up for drm-misc. btw if you're even more
motivated, you can go through all drivers with a static mapping from
connector to encoder, and nuke those functions. Since if it's just a
static mapping, the only way to do it is like the helper does.

Thanks, Daniel
> 
> --->8---
> From d218b7ea16ca35452b3174c83a207ecd406e5c88 Mon Sep 17 00:00:00 2001
> From: Boris Brezillon <boris.brezillon@free-electrons.com>
> Date: Wed, 1 Jun 2016 17:57:18 +0200
> Subject: [PATCH] drm: atomic: Handle funcs->best_encoder == NULL case
> 
> Fallback drm_atomic_helper_best_encoder() is funcs->best_encoder() is NULL
> so that DRM drivers can leave this hook unassigned if they know they want
> to use drm_atomic_helper_best_encoder().
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index ddfa0d1..f6a3350 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -110,8 +110,10 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state,
>  
>  		if (funcs->atomic_best_encoder)
>  			new_encoder = funcs->atomic_best_encoder(connector, conn_state);
> -		else
> +		else if (funcs->best_encoder)
>  			new_encoder = funcs->best_encoder(connector);
> +		else
> +			new_encoder = drm_atomic_helper_best_encoder(connector);
>  
>  		if (new_encoder) {
>  			if (encoder_mask & (1 << drm_encoder_index(new_encoder))) {
> 
> 
>
Boris BREZILLON June 2, 2016, 7:40 a.m. UTC | #2
Hi Daniel,

On Wed, 1 Jun 2016 23:56:02 +0200
Daniel Vetter <daniel@ffwll.ch> wrote:

> On Wed, Jun 01, 2016 at 06:03:37PM +0200, Boris Brezillon wrote:
> > On Tue, 17 May 2016 08:47:11 +0200
> > Daniel Vetter <daniel@ffwll.ch> wrote:
> >   
> > > > +static struct drm_encoder *sii902x_best_encoder(struct drm_connector *connector)
> > > > +{
> > > > +	struct sii902x *sii902x = connector_to_sii902x(connector);
> > > > +
> > > > +	return sii902x->bridge.encoder;
> > > > +}    
> > > 
> > > drm_atomic_helper_best_encoder should do exactly this for you. If you feel
> > > board pimp the atomic helpers to call that one by default to even remove
> > > the vfunc assingment line ;-)  
> > 
> > Just to be sure, is that what you had in mind?  
> 
> Exactly, I'll pick this one up for drm-misc. btw if you're even more
> motivated, you can go through all drivers with a static mapping from
> connector to encoder, and nuke those functions. Since if it's just a
> static mapping, the only way to do it is like the helper does.
> 
> Thanks, Daniel
> >   
> > --->8---  
> > From d218b7ea16ca35452b3174c83a207ecd406e5c88 Mon Sep 17 00:00:00 2001
> > From: Boris Brezillon <boris.brezillon@free-electrons.com>
> > Date: Wed, 1 Jun 2016 17:57:18 +0200
> > Subject: [PATCH] drm: atomic: Handle funcs->best_encoder == NULL case
> > 
> > Fallback drm_atomic_helper_best_encoder() is funcs->best_encoder() is NULL

Oops, can you fix the commit message before applying?

"
Fallback *to* drm_atomic_helper_best_encoder() *if*
funcs->best_encoder() is NULL
"

Maybe I should resend the patch along with the other modifications you
asked for. This way it will in a dedicated thread, instead of being
hidden in an unrelated patch series.

Regards,

Boris


> > so that DRM drivers can leave this hook unassigned if they know they want
> > to use drm_atomic_helper_best_encoder().
> > 
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > ---
> >  drivers/gpu/drm/drm_atomic_helper.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> > index ddfa0d1..f6a3350 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -110,8 +110,10 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state,
> >  
> >  		if (funcs->atomic_best_encoder)
> >  			new_encoder = funcs->atomic_best_encoder(connector, conn_state);
> > -		else
> > +		else if (funcs->best_encoder)
> >  			new_encoder = funcs->best_encoder(connector);
> > +		else
> > +			new_encoder = drm_atomic_helper_best_encoder(connector);
> >  
> >  		if (new_encoder) {
> >  			if (encoder_mask & (1 << drm_encoder_index(new_encoder))) {
> > 
> > 
> >   
>
Boris BREZILLON June 2, 2016, 8:04 a.m. UTC | #3
On Wed, 1 Jun 2016 23:56:02 +0200
Daniel Vetter <daniel@ffwll.ch> wrote:

> On Wed, Jun 01, 2016 at 06:03:37PM +0200, Boris Brezillon wrote:
> > On Tue, 17 May 2016 08:47:11 +0200
> > Daniel Vetter <daniel@ffwll.ch> wrote:
> >   
> > > > +static struct drm_encoder *sii902x_best_encoder(struct drm_connector *connector)
> > > > +{
> > > > +	struct sii902x *sii902x = connector_to_sii902x(connector);
> > > > +
> > > > +	return sii902x->bridge.encoder;
> > > > +}    
> > > 
> > > drm_atomic_helper_best_encoder should do exactly this for you. If you feel
> > > board pimp the atomic helpers to call that one by default to even remove
> > > the vfunc assingment line ;-)  
> > 
> > Just to be sure, is that what you had in mind?  
> 
> Exactly, I'll pick this one up for drm-misc. btw if you're even more
> motivated, you can go through all drivers with a static mapping from
> connector to encoder, and nuke those functions. Since if it's just a
> static mapping, the only way to do it is like the helper does.
> 
> Thanks, Daniel
> >   
> > --->8---  
> > From d218b7ea16ca35452b3174c83a207ecd406e5c88 Mon Sep 17 00:00:00 2001
> > From: Boris Brezillon <boris.brezillon@free-electrons.com>
> > Date: Wed, 1 Jun 2016 17:57:18 +0200
> > Subject: [PATCH] drm: atomic: Handle funcs->best_encoder == NULL case
> > 
> > Fallback drm_atomic_helper_best_encoder() is funcs->best_encoder() is NULL
> > so that DRM drivers can leave this hook unassigned if they know they want
> > to use drm_atomic_helper_best_encoder().

Please don't apply the patch, it's buggy.

> > 
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > ---
> >  drivers/gpu/drm/drm_atomic_helper.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> > index ddfa0d1..f6a3350 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -110,8 +110,10 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state,
> >  
> >  		if (funcs->atomic_best_encoder)
> >  			new_encoder = funcs->atomic_best_encoder(connector, conn_state);
> > -		else
> > +		else if (funcs->best_encoder)
> >  			new_encoder = funcs->best_encoder(connector);
> > +		else
> > +			new_encoder = drm_atomic_helper_best_encoder(connector);
> >  
> >  		if (new_encoder) {
> >  			if (encoder_mask & (1 << drm_encoder_index(new_encoder))) {
> > 
> > 
> >   
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index ddfa0d1..f6a3350 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -110,8 +110,10 @@  static int handle_conflicting_encoders(struct drm_atomic_state *state,
 
 		if (funcs->atomic_best_encoder)
 			new_encoder = funcs->atomic_best_encoder(connector, conn_state);
-		else
+		else if (funcs->best_encoder)
 			new_encoder = funcs->best_encoder(connector);
+		else
+			new_encoder = drm_atomic_helper_best_encoder(connector);
 
 		if (new_encoder) {
 			if (encoder_mask & (1 << drm_encoder_index(new_encoder))) {