diff mbox

[2/4] drm/i2c: tda998x: Remove obsolete drm_connector_register() call

Message ID e988513ba2c8cf280f956c9d8e2494682855a248.1476825466.git.jsarha@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jyri Sarha Oct. 18, 2016, 9:33 p.m. UTC
Remove obsolete drm_connector_register() call from tda998x_bind(). All
connectors are registered when drm_dev_register() is called by the
master drm_device driver.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 6 ------
 1 file changed, 6 deletions(-)

Comments

Laurent Pinchart Oct. 19, 2016, 7:54 a.m. UTC | #1
Hi Jyri,

Thank you for the patch.

On Wednesday 19 Oct 2016 00:33:54 Jyri Sarha wrote:
> Remove obsolete drm_connector_register() call from tda998x_bind(). All
> connectors are registered when drm_dev_register() is called by the
> master drm_device driver.
> 
> Signed-off-by: Jyri Sarha <jsarha@ti.com>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

By the way, any chance you would plan porting the driver to drm_bridge ? :-)

> ---
>  drivers/gpu/drm/i2c/tda998x_drv.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c
> b/drivers/gpu/drm/i2c/tda998x_drv.c index 9798d40..265f854 100644
> --- a/drivers/gpu/drm/i2c/tda998x_drv.c
> +++ b/drivers/gpu/drm/i2c/tda998x_drv.c
> @@ -1656,16 +1656,10 @@ static int tda998x_bind(struct device *dev, struct
> device *master, void *data) if (ret)
>  		goto err_connector;
> 
> -	ret = drm_connector_register(&priv->connector);
> -	if (ret)
> -		goto err_sysfs;
> -
>  	drm_mode_connector_attach_encoder(&priv->connector, &priv->encoder);
> 
>  	return 0;
> 
> -err_sysfs:
> -	drm_connector_cleanup(&priv->connector);
>  err_connector:
>  	drm_encoder_cleanup(&priv->encoder);
>  err_encoder:
Russell King (Oracle) Oct. 19, 2016, 8:16 a.m. UTC | #2
On Wed, Oct 19, 2016 at 10:54:06AM +0300, Laurent Pinchart wrote:
> Hi Jyri,
> 
> Thank you for the patch.
> 
> On Wednesday 19 Oct 2016 00:33:54 Jyri Sarha wrote:
> > Remove obsolete drm_connector_register() call from tda998x_bind(). All
> > connectors are registered when drm_dev_register() is called by the
> > master drm_device driver.
> > 
> > Signed-off-by: Jyri Sarha <jsarha@ti.com>
> 
> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> By the way, any chance you would plan porting the driver to drm_bridge ? :-)

What's the point?
Laurent Pinchart Oct. 19, 2016, 8:52 a.m. UTC | #3
Hi Russell,

On Wednesday 19 Oct 2016 09:16:30 Russell King - ARM Linux wrote:
> On Wed, Oct 19, 2016 at 10:54:06AM +0300, Laurent Pinchart wrote:
> > On Wednesday 19 Oct 2016 00:33:54 Jyri Sarha wrote:
> >> Remove obsolete drm_connector_register() call from tda998x_bind(). All
> >> connectors are registered when drm_dev_register() is called by the
> >> master drm_device driver.
> >> 
> >> Signed-off-by: Jyri Sarha <jsarha@ti.com>
> > 
> > Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > 
> > By the way, any chance you would plan porting the driver to drm_bridge ?
> > :-)
>
> What's the point?

Avoiding code duplication. We currently have three APIs to handle external 
encoders (drm encoder slave, drm bridge and the component-based method used by 
tda998x only), which requires display drivers that want to support multiple 
external encoders to use up to three APIs.
Russell King (Oracle) Oct. 19, 2016, 9:11 a.m. UTC | #4
On Wed, Oct 19, 2016 at 11:52:15AM +0300, Laurent Pinchart wrote:
> Hi Russell,
> 
> On Wednesday 19 Oct 2016 09:16:30 Russell King - ARM Linux wrote:
> > On Wed, Oct 19, 2016 at 10:54:06AM +0300, Laurent Pinchart wrote:
> > > On Wednesday 19 Oct 2016 00:33:54 Jyri Sarha wrote:
> > >> Remove obsolete drm_connector_register() call from tda998x_bind(). All
> > >> connectors are registered when drm_dev_register() is called by the
> > >> master drm_device driver.
> > >> 
> > >> Signed-off-by: Jyri Sarha <jsarha@ti.com>
> > > 
> > > Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > 
> > > By the way, any chance you would plan porting the driver to drm_bridge ?
> > > :-)
> >
> > What's the point?
> 
> Avoiding code duplication. We currently have three APIs to handle external 
> encoders (drm encoder slave, drm bridge and the component-based method used by 
> tda998x only), which requires display drivers that want to support multiple 
> external encoders to use up to three APIs.

tda998x doesn't use the encoder slave anymore.  You somehow list component-
based as a third alternative - it isn't, that's the native DRM non-bridge
method.

In any case, I don't agree with converting it to a DRM bridge - that will
mean that we have to split the driver into two pieces, the bridge part
handling the mode set specifics, and a connector/encoder part which
handles the detection/edid stuff.

We might as well keep the whole thing as the classical connector/encoder
rather than introducing this additional layer of complexity.
Laurent Pinchart Oct. 19, 2016, 9:19 a.m. UTC | #5
Hi Russell,

On Wednesday 19 Oct 2016 10:11:22 Russell King - ARM Linux wrote:
> On Wed, Oct 19, 2016 at 11:52:15AM +0300, Laurent Pinchart wrote:
> > On Wednesday 19 Oct 2016 09:16:30 Russell King - ARM Linux wrote:
> >> On Wed, Oct 19, 2016 at 10:54:06AM +0300, Laurent Pinchart wrote:
> >>> On Wednesday 19 Oct 2016 00:33:54 Jyri Sarha wrote:
> >>>> Remove obsolete drm_connector_register() call from tda998x_bind().
> >>>> All connectors are registered when drm_dev_register() is called by the
> >>>> master drm_device driver.
> >>>> 
> >>>> Signed-off-by: Jyri Sarha <jsarha@ti.com>
> >>> 
> >>> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>> 
> >>> By the way, any chance you would plan porting the driver to drm_bridge
> >>> ? :-)
> >>
> >> What's the point?
> > 
> > Avoiding code duplication. We currently have three APIs to handle external
> > encoders (drm encoder slave, drm bridge and the component-based method
> > used by tda998x only), which requires display drivers that want to
> > support multiple external encoders to use up to three APIs.
> 
> tda998x doesn't use the encoder slave anymore.  You somehow list component-
> based as a third alternative - it isn't, that's the native DRM non-bridge
> method.

The order in my list was random, component-based instantiation of external 
encoders is one method, not specifically the third one :-)

> In any case, I don't agree with converting it to a DRM bridge - that will
> mean that we have to split the driver into two pieces, the bridge part
> handling the mode set specifics, and a connector/encoder part which
> handles the detection/edid stuff.
> 
> We might as well keep the whole thing as the classical connector/encoder
> rather than introducing this additional layer of complexity.

We have different ways to instantiate external HDMI encoders, and that's not 
good. I believe everybody agrees that drm encoder slave has to go, so that's 
already one problem solved (or rather solvable, it still requires someone to 
do the work). We will then be left with two different methods, drm bridge and 
non-bridge component-based instantiation. We need to somehow merge the two, 
and I'm open to discussions on how the end result should look like.
Russell King (Oracle) Oct. 19, 2016, 9:35 a.m. UTC | #6
On Wed, Oct 19, 2016 at 12:19:30PM +0300, Laurent Pinchart wrote:
> Hi Russell,
> 
> On Wednesday 19 Oct 2016 10:11:22 Russell King - ARM Linux wrote:
> > In any case, I don't agree with converting it to a DRM bridge - that will
> > mean that we have to split the driver into two pieces, the bridge part
> > handling the mode set specifics, and a connector/encoder part which
> > handles the detection/edid stuff.
> > 
> > We might as well keep the whole thing as the classical connector/encoder
> > rather than introducing this additional layer of complexity.
> 
> We have different ways to instantiate external HDMI encoders, and that's not 
> good. I believe everybody agrees that drm encoder slave has to go, so that's 
> already one problem solved (or rather solvable, it still requires someone to 
> do the work). We will then be left with two different methods, drm bridge and 
> non-bridge component-based instantiation. We need to somehow merge the two, 
> and I'm open to discussions on how the end result should look like.

I think you're idea really doesn't work - and I think your idea that
component-based is somehow separate from other methods is wrong.

Look at iMX for example - even converting all the code that could be
a bridge to be a bridge will not get rid of its use of the component
instantiation, because you still have other components that need to
come from elsewhere.  The same is true of armada as well.

Moreover, as I've already said, converting tda998x to a DRM bridge
will not get rid of the encoder/connector part, because it _is_ a
connector in the DRM sense - it provides the detection and EDID
reading.

So, what would we achieve by splitting the driver into a DRM bridge
and DRM encoder/connector?

We would still need the component helper to manage the binding of
the connector part, which would also then have to register a DRM
bridge in addition to a DRM encoder and providing the DRM connector
as we can't have two device drivers bound to the same i2c device.
What we get is more complexity in the driver.

We can see this with what happened to the DW-HDMI driver - that still
needs the component helper, and it provides a DRM bridge, DRM encoder
and DRM connector parts.  The only reason it made sense to split the
DW-HDMI driver was due to the differences between the Rockchip and
Freescale implementations.  Such differences do not exist for TDA998x.
So even here, your idea that "DRM bridge" vs "non-DRM bridge component
based" doesn't work - we have "DRM bridge component based" because of
the problem that I'm illustrating here.

So, again, I ask: what's the point of needlessly splitting the code
between an encoder/connector and a bridge?

You seem to be forcing the DRM bridge model onto drivers with no
regard for its appropriateness for those drivers.  If it pushes
more complexity into drivers, the model is wrong.
Brian Starkey Oct. 19, 2016, 9:46 a.m. UTC | #7
Hi Jyri,

I believe this will break mali-dp and hdlcd, unless something changed
while I wasn't looking. Please see this previous thread where I did
the same thing and then had to have it reverted: [1]

Before removing this, we need to refactor (at least) mali-dp and hdlcd
to move drm_dev_register() to the end of their ->bind() callback.

That could be done without moving drm_dev_unregister() to the start
of ->unbind() if you really want to nuke the drm_connector_register()
call, but to maintain symmetry (and introduce correctness) I was
putting it off until I had a chance to remove drm_vblank_cleanup()
from drm_dev_unregister() (because [2]).

Thanks,
Brian

[1] https://lists.freedesktop.org/archives/dri-devel/2016-September/119038.html
[2] https://lists.freedesktop.org/archives/dri-devel/2016-September/119268.html

On Wed, Oct 19, 2016 at 12:33:54AM +0300, Jyri Sarha wrote:
>Remove obsolete drm_connector_register() call from tda998x_bind(). All
>connectors are registered when drm_dev_register() is called by the
>master drm_device driver.
>
>Signed-off-by: Jyri Sarha <jsarha@ti.com>
>---
> drivers/gpu/drm/i2c/tda998x_drv.c | 6 ------
> 1 file changed, 6 deletions(-)
>
>diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
>index 9798d40..265f854 100644
>--- a/drivers/gpu/drm/i2c/tda998x_drv.c
>+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
>@@ -1656,16 +1656,10 @@ static int tda998x_bind(struct device *dev, struct device *master, void *data)
> 	if (ret)
> 		goto err_connector;
>
>-	ret = drm_connector_register(&priv->connector);
>-	if (ret)
>-		goto err_sysfs;
>-
> 	drm_mode_connector_attach_encoder(&priv->connector, &priv->encoder);
>
> 	return 0;
>
>-err_sysfs:
>-	drm_connector_cleanup(&priv->connector);
> err_connector:
> 	drm_encoder_cleanup(&priv->encoder);
> err_encoder:
>-- 
>1.9.1
>
>_______________________________________________
>dri-devel mailing list
>dri-devel@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/dri-devel
Laurent Pinchart Oct. 20, 2016, 8:20 a.m. UTC | #8
Hi Russell,

On Wednesday 19 Oct 2016 10:35:21 Russell King - ARM Linux wrote:
> On Wed, Oct 19, 2016 at 12:19:30PM +0300, Laurent Pinchart wrote:
> > On Wednesday 19 Oct 2016 10:11:22 Russell King - ARM Linux wrote:
> >> In any case, I don't agree with converting it to a DRM bridge - that
> >> will mean that we have to split the driver into two pieces, the bridge
> >> part handling the mode set specifics, and a connector/encoder part which
> >> handles the detection/edid stuff.
> >> 
> >> We might as well keep the whole thing as the classical connector/encoder
> >> rather than introducing this additional layer of complexity.
> > 
> > We have different ways to instantiate external HDMI encoders, and that's
> > not good. I believe everybody agrees that drm encoder slave has to go, so
> > that's already one problem solved (or rather solvable, it still requires
> > someone to do the work). We will then be left with two different methods,
> > drm bridge and non-bridge component-based instantiation. We need to
> > somehow merge the two, and I'm open to discussions on how the end result
> > should look like.
>
> I think you're idea really doesn't work - and I think your idea that
> component-based is somehow separate from other methods is wrong.
> 
> Look at iMX for example - even converting all the code that could be
> a bridge to be a bridge will not get rid of its use of the component
> instantiation, because you still have other components that need to
> come from elsewhere.  The same is true of armada as well.

Don't get me wrong, I'm certainly not against the component framework itself. 
A way to bind multiple independent devices together is needed. We have a 
similar framework in V4L2 called v4l2-async, and I'd like to see it moved to 
the component framework at some point to unify code. Some changes to the 
component framework might be needed to support needs of V4L2 that are 
currently not applicable to DRM/KMS, but there's nothing major there.

> Moreover, as I've already said, converting tda998x to a DRM bridge
> will not get rid of the encoder/connector part, because it _is_ a
> connector in the DRM sense - it provides the detection and EDID
> reading.
> 
> So, what would we achieve by splitting the driver into a DRM bridge
> and DRM encoder/connector?

Please note that DRM bridge doesn't split the DRM connector out of the bridge, 
bridges instantiate drm_connector objects. In that sense they don't differ 
much from the model implemented by the tda998x driver.

I however believe that connectors should be split out DRM bridge drivers, for 
the simple reason that bridges can be chained. The output of a bridge isn't 
guaranteed to be a connector but can be another bridge. We managed not to have 
to deal with that in a generic way so far in mainline, but we'll run into the 
problem one of these days, and a solution will be needed. There's no rush 
right now, and this is unrelated to converting tda998x to DRM bridge.

> We would still need the component helper to manage the binding of
> the connector part, which would also then have to register a DRM
> bridge in addition to a DRM encoder and providing the DRM connector
> as we can't have two device drivers bound to the same i2c device.
> What we get is more complexity in the driver.

DRM bridges indeed don't create encoders. That task is left to the display 
driver. The reason is the same as above: bridges can be chained (including 
with an internal encoder that is not modelled as a bridge, and that's a case 
we have today), while the KMS model exposes a single encoder to userspace. 
Exposing DRM encoder objects as part of the KMS UABI was probably a mistake. 
Better solutions would have been to expose no encoder at all or all encoders 
in the chain. We are however stuck with this model as we can't break the UABI. 
For that reason a DRM encoder object doesn't represent an encoder but a chain 
of encoders. As a DRM bridge models a single encoder, the DRM encoder object 
must be created at a higher level, in the display driver.

> We can see this with what happened to the DW-HDMI driver - that still
> needs the component helper, and it provides a DRM bridge, DRM encoder
> and DRM connector parts.

To be precise, the DW-HDMI driver core doesn't create a DRM encoder, it's the 
glue layers implemented as part of the Rockchip and iMX display drivers that 
do. Nonetheless, that's a mistake, the encoder should be created by the 
display drivers.

> The only reason it made sense to split the DW-HDMI driver was due to the
> differences between the Rockchip and Freescale implementations.  Such
> differences do not exist for TDA998x. So even here, your idea that "DRM
> bridge" vs "non-DRM bridge component based" doesn't work - we have "DRM
> bridge component based" because of the problem that I'm illustrating here.
> 
> So, again, I ask: what's the point of needlessly splitting the code
> between an encoder/connector and a bridge?

We need to standardize on one model. I don't care much about how the end 
result is named, as long as it fulfils the task at hand. For the reasons 
explained above, it should not create a DRM encoder or DRM connector. A step 
by step approach is obviously needed to get there, one option being moving all 
external encoders to DRM bridge as a first step without instantiating the DRM 
encoder in the bridge driver, and then moving connector instantiation out as a 
second step.

The current situation is a huge mess, we simply can't pretend to ignore the 
problem.

> You seem to be forcing the DRM bridge model onto drivers with no
> regard for its appropriateness for those drivers.  If it pushes
> more complexity into drivers, the model is wrong.

I expect several (many? most?) display drivers to handle bridges, encoders and 
connectors in the same way, so we should obviously share common code in the 
form of helper functions to keep display drivers simple.
Archit Taneja Oct. 20, 2016, 9:08 a.m. UTC | #9
On 10/20/2016 01:50 PM, Laurent Pinchart wrote:
> Hi Russell,
>
> On Wednesday 19 Oct 2016 10:35:21 Russell King - ARM Linux wrote:
>> On Wed, Oct 19, 2016 at 12:19:30PM +0300, Laurent Pinchart wrote:
>>> On Wednesday 19 Oct 2016 10:11:22 Russell King - ARM Linux wrote:
>>>> In any case, I don't agree with converting it to a DRM bridge - that
>>>> will mean that we have to split the driver into two pieces, the bridge
>>>> part handling the mode set specifics, and a connector/encoder part which
>>>> handles the detection/edid stuff.
>>>>
>>>> We might as well keep the whole thing as the classical connector/encoder
>>>> rather than introducing this additional layer of complexity.
>>>
>>> We have different ways to instantiate external HDMI encoders, and that's
>>> not good. I believe everybody agrees that drm encoder slave has to go, so
>>> that's already one problem solved (or rather solvable, it still requires
>>> someone to do the work). We will then be left with two different methods,
>>> drm bridge and non-bridge component-based instantiation. We need to
>>> somehow merge the two, and I'm open to discussions on how the end result
>>> should look like.
>>
>> I think you're idea really doesn't work - and I think your idea that
>> component-based is somehow separate from other methods is wrong.
>>
>> Look at iMX for example - even converting all the code that could be
>> a bridge to be a bridge will not get rid of its use of the component
>> instantiation, because you still have other components that need to
>> come from elsewhere.  The same is true of armada as well.
>
> Don't get me wrong, I'm certainly not against the component framework itself.
> A way to bind multiple independent devices together is needed. We have a
> similar framework in V4L2 called v4l2-async, and I'd like to see it moved to
> the component framework at some point to unify code. Some changes to the
> component framework might be needed to support needs of V4L2 that are
> currently not applicable to DRM/KMS, but there's nothing major there.
>
>> Moreover, as I've already said, converting tda998x to a DRM bridge
>> will not get rid of the encoder/connector part, because it _is_ a
>> connector in the DRM sense - it provides the detection and EDID
>> reading.
>>
>> So, what would we achieve by splitting the driver into a DRM bridge
>> and DRM encoder/connector?
>
> Please note that DRM bridge doesn't split the DRM connector out of the bridge,
> bridges instantiate drm_connector objects. In that sense they don't differ
> much from the model implemented by the tda998x driver.
>
> I however believe that connectors should be split out DRM bridge drivers, for
> the simple reason that bridges can be chained. The output of a bridge isn't
> guaranteed to be a connector but can be another bridge. We managed not to have
> to deal with that in a generic way so far in mainline, but we'll run into the
> problem one of these days, and a solution will be needed. There's no rush
> right now, and this is unrelated to converting tda998x to DRM bridge.
>
>> We would still need the component helper to manage the binding of
>> the connector part, which would also then have to register a DRM
>> bridge in addition to a DRM encoder and providing the DRM connector
>> as we can't have two device drivers bound to the same i2c device.
>> What we get is more complexity in the driver.
>
> DRM bridges indeed don't create encoders. That task is left to the display
> driver. The reason is the same as above: bridges can be chained (including
> with an internal encoder that is not modelled as a bridge, and that's a case
> we have today), while the KMS model exposes a single encoder to userspace.
> Exposing DRM encoder objects as part of the KMS UABI was probably a mistake.
> Better solutions would have been to expose no encoder at all or all encoders
> in the chain. We are however stuck with this model as we can't break the UABI.
> For that reason a DRM encoder object doesn't represent an encoder but a chain
> of encoders. As a DRM bridge models a single encoder, the DRM encoder object
> must be created at a higher level, in the display driver.

One more thing is that the TDA998x in its current form won't work
with KMS drivers that create their own drm_encoder objects to represent
their hardware's mipi DPI/RGB interfaces. For such drivers, we would
want the TDA998x to tie itself to the existing encoder created by the
KMS driver, rather than creating its own.

Thanks,
Archit

>
>> We can see this with what happened to the DW-HDMI driver - that still
>> needs the component helper, and it provides a DRM bridge, DRM encoder
>> and DRM connector parts.
>
> To be precise, the DW-HDMI driver core doesn't create a DRM encoder, it's the
> glue layers implemented as part of the Rockchip and iMX display drivers that
> do. Nonetheless, that's a mistake, the encoder should be created by the
> display drivers.
>
>> The only reason it made sense to split the DW-HDMI driver was due to the
>> differences between the Rockchip and Freescale implementations.  Such
>> differences do not exist for TDA998x. So even here, your idea that "DRM
>> bridge" vs "non-DRM bridge component based" doesn't work - we have "DRM
>> bridge component based" because of the problem that I'm illustrating here.
>>
>> So, again, I ask: what's the point of needlessly splitting the code
>> between an encoder/connector and a bridge?
>
> We need to standardize on one model. I don't care much about how the end
> result is named, as long as it fulfils the task at hand. For the reasons
> explained above, it should not create a DRM encoder or DRM connector. A step
> by step approach is obviously needed to get there, one option being moving all
> external encoders to DRM bridge as a first step without instantiating the DRM
> encoder in the bridge driver, and then moving connector instantiation out as a
> second step.
>
> The current situation is a huge mess, we simply can't pretend to ignore the
> problem.
>
>> You seem to be forcing the DRM bridge model onto drivers with no
>> regard for its appropriateness for those drivers.  If it pushes
>> more complexity into drivers, the model is wrong.
>
> I expect several (many? most?) display drivers to handle bridges, encoders and
> connectors in the same way, so we should obviously share common code in the
> form of helper functions to keep display drivers simple.
>
Russell King (Oracle) Oct. 20, 2016, 9:11 a.m. UTC | #10
On Thu, Oct 20, 2016 at 11:20:05AM +0300, Laurent Pinchart wrote:
> Hi Russell,
> 
> On Wednesday 19 Oct 2016 10:35:21 Russell King - ARM Linux wrote:
> > Moreover, as I've already said, converting tda998x to a DRM bridge
> > will not get rid of the encoder/connector part, because it _is_ a
> > connector in the DRM sense - it provides the detection and EDID
> > reading.
> > 
> > So, what would we achieve by splitting the driver into a DRM bridge
> > and DRM encoder/connector?
> 
> Please note that DRM bridge doesn't split the DRM connector out of the bridge, 
> bridges instantiate drm_connector objects. In that sense they don't differ 
> much from the model implemented by the tda998x driver.

So, we what you're saying is that we from a component based DRM encoder
plus DRM connector to a component based DRM bridge plus DRM connector
and some nebulous DRM encoder provider.

How does the DRM encoder get associated with the DRM connector?  DRM
requires the presence of at least one DRM encoder for each DRM connector,
and the DRM connector needs to provide a .best_encoder method to pick
the appropriate DRM encoder.

If (as you said elsewhere in your message) that the display driver is
responsible for providing the DRM encoder in your view, how does a
bridge DRM connector get to that DRM encoder, and how does it know
which DRM encoder to pick?

> I however believe that connectors should be split out DRM bridge drivers, for 
> the simple reason that bridges can be chained. The output of a bridge isn't 
> guaranteed to be a connector but can be another bridge.

You've not said how that could be achieved with TDA998x, so I'm still
opposed to the idea.  Remember, you're the one asking for this, you
must have a view on how to achieve it if you want it to happen.

> > We can see this with what happened to the DW-HDMI driver - that still
> > needs the component helper, and it provides a DRM bridge, DRM encoder
> > and DRM connector parts.
> 
> To be precise, the DW-HDMI driver core doesn't create a DRM encoder, it's the 
> glue layers implemented as part of the Rockchip and iMX display drivers that 
> do. Nonetheless, that's a mistake, the encoder should be created by the 
> display drivers.

If we're being precise, the "glue layer" creates the DRM encoder, but
the bridge code is responsible for binding itself to the DRM encoder,
and binding the DRM encoder to its associated DRM connector.

Let's assume it's a mistake.  Please illustrate how you would solve
this mistake.

> > The only reason it made sense to split the DW-HDMI driver was due to the
> > differences between the Rockchip and Freescale implementations.  Such
> > differences do not exist for TDA998x. So even here, your idea that "DRM
> > bridge" vs "non-DRM bridge component based" doesn't work - we have "DRM
> > bridge component based" because of the problem that I'm illustrating here.
> > 
> > So, again, I ask: what's the point of needlessly splitting the code
> > between an encoder/connector and a bridge?
> 
> We need to standardize on one model. I don't care much about how the end 
> result is named, as long as it fulfils the task at hand.

I don't care about the name either, that's not what I'm asking here.

All I seem to be getting is some hand-waving "we want one model" and
"the current situation is a huge mess" (which is not a sentiment I agree
with) but with no technical response about how to achieve it.  Please do
the technical response bits and stop hand-waving.
Russell King (Oracle) Oct. 20, 2016, 9:15 a.m. UTC | #11
On Thu, Oct 20, 2016 at 02:38:25PM +0530, Archit Taneja wrote:
> 
> 
> On 10/20/2016 01:50 PM, Laurent Pinchart wrote:
> >Hi Russell,
> >
> >On Wednesday 19 Oct 2016 10:35:21 Russell King - ARM Linux wrote:
> >>On Wed, Oct 19, 2016 at 12:19:30PM +0300, Laurent Pinchart wrote:
> >>>On Wednesday 19 Oct 2016 10:11:22 Russell King - ARM Linux wrote:
> >>>>In any case, I don't agree with converting it to a DRM bridge - that
> >>>>will mean that we have to split the driver into two pieces, the bridge
> >>>>part handling the mode set specifics, and a connector/encoder part which
> >>>>handles the detection/edid stuff.
> >>>>
> >>>>We might as well keep the whole thing as the classical connector/encoder
> >>>>rather than introducing this additional layer of complexity.
> >>>
> >>>We have different ways to instantiate external HDMI encoders, and that's
> >>>not good. I believe everybody agrees that drm encoder slave has to go, so
> >>>that's already one problem solved (or rather solvable, it still requires
> >>>someone to do the work). We will then be left with two different methods,
> >>>drm bridge and non-bridge component-based instantiation. We need to
> >>>somehow merge the two, and I'm open to discussions on how the end result
> >>>should look like.
> >>
> >>I think you're idea really doesn't work - and I think your idea that
> >>component-based is somehow separate from other methods is wrong.
> >>
> >>Look at iMX for example - even converting all the code that could be
> >>a bridge to be a bridge will not get rid of its use of the component
> >>instantiation, because you still have other components that need to
> >>come from elsewhere.  The same is true of armada as well.
> >
> >Don't get me wrong, I'm certainly not against the component framework itself.
> >A way to bind multiple independent devices together is needed. We have a
> >similar framework in V4L2 called v4l2-async, and I'd like to see it moved to
> >the component framework at some point to unify code. Some changes to the
> >component framework might be needed to support needs of V4L2 that are
> >currently not applicable to DRM/KMS, but there's nothing major there.
> >
> >>Moreover, as I've already said, converting tda998x to a DRM bridge
> >>will not get rid of the encoder/connector part, because it _is_ a
> >>connector in the DRM sense - it provides the detection and EDID
> >>reading.
> >>
> >>So, what would we achieve by splitting the driver into a DRM bridge
> >>and DRM encoder/connector?
> >
> >Please note that DRM bridge doesn't split the DRM connector out of the bridge,
> >bridges instantiate drm_connector objects. In that sense they don't differ
> >much from the model implemented by the tda998x driver.
> >
> >I however believe that connectors should be split out DRM bridge drivers, for
> >the simple reason that bridges can be chained. The output of a bridge isn't
> >guaranteed to be a connector but can be another bridge. We managed not to have
> >to deal with that in a generic way so far in mainline, but we'll run into the
> >problem one of these days, and a solution will be needed. There's no rush
> >right now, and this is unrelated to converting tda998x to DRM bridge.
> >
> >>We would still need the component helper to manage the binding of
> >>the connector part, which would also then have to register a DRM
> >>bridge in addition to a DRM encoder and providing the DRM connector
> >>as we can't have two device drivers bound to the same i2c device.
> >>What we get is more complexity in the driver.
> >
> >DRM bridges indeed don't create encoders. That task is left to the display
> >driver. The reason is the same as above: bridges can be chained (including
> >with an internal encoder that is not modelled as a bridge, and that's a case
> >we have today), while the KMS model exposes a single encoder to userspace.
> >Exposing DRM encoder objects as part of the KMS UABI was probably a mistake.
> >Better solutions would have been to expose no encoder at all or all encoders
> >in the chain. We are however stuck with this model as we can't break the UABI.
> >For that reason a DRM encoder object doesn't represent an encoder but a chain
> >of encoders. As a DRM bridge models a single encoder, the DRM encoder object
> >must be created at a higher level, in the display driver.
> 
> One more thing is that the TDA998x in its current form won't work
> with KMS drivers that create their own drm_encoder objects to represent
> their hardware's mipi DPI/RGB interfaces. For such drivers, we would
> want the TDA998x to tie itself to the existing encoder created by the
> KMS driver, rather than creating its own.

Please show _technically_ how this would work.  I want to see code or
pseudo-code illustrating how a "foreign" DRM encoder could be used with
either dw-hdmi or tda998x, because right now I can't see any way that
could work.
Russell King (Oracle) Oct. 22, 2016, 1:40 p.m. UTC | #12
On Wed, Oct 19, 2016 at 10:46:48AM +0100, Brian Starkey wrote:
> Hi Jyri,
> 
> I believe this will break mali-dp and hdlcd, unless something changed
> while I wasn't looking. Please see this previous thread where I did
> the same thing and then had to have it reverted: [1]
> 
> Before removing this, we need to refactor (at least) mali-dp and hdlcd
> to move drm_dev_register() to the end of their ->bind() callback.
> 
> That could be done without moving drm_dev_unregister() to the start
> of ->unbind() if you really want to nuke the drm_connector_register()
> call, but to maintain symmetry (and introduce correctness) I was
> putting it off until I had a chance to remove drm_vblank_cleanup()
> from drm_dev_unregister() (because [2]).

So what is the status of this - when is it going to happen?  Without
this happening, I can't de-midlayer armada-drm, and I can't apply
these TDA998x patches.

As armada-drm stands at the moment, it can cope with the TDA998x
driver having the drm_connector_register(), or with it eliminated.
When armada-drm is de-midlayered without changing TDA998x, the
drm_connector_register() call in TDA998x produces a warning:

WARNING: CPU: 0 PID: 13 at lib/kobject.c:244 kobject_add_internal+0xfc/0x2d8
kobject_add_internal failed for card0-HDMI-A-1 (error: -2 parent: card0)

I suspect that you will end up with the same problem when you move
the drm_dev_register() call after component_bind_all() - and I think
the answer is... you shouldn't have de-midlayered until TDA998x had
been updated to cope with de-midlayering, iow having had the
drm_connector_register() call removed.

Given that, I don't think we can avoid breaking mali-dp and hdlcd,
except by combining the change into a single patch, changing all three
drivers simultaneously (and any other driver which uses TDA998x which
has also been de-midlayered.)

So, what I would like to see is a single patch against Linus' 4.8.0
commit fixing mali-dp, hdlcd and any other driver, together with
removing drm_connector_register() from TDA998x.  This is so the patch
can be shared between all interested parties without forcing everyone
to 4.9-rc1.  Looking at the diff between 4.8 and 4.9-rc1 for
drivers/gpu/drm/arm, that shouldn't result in any merge conflicts -
and if you want to follow on from that with 4.9-rc1 development, you
can always merge 4.9-rc1 on top of that commit.

I'm happy to take such a patch and publish it via my git tree as part
of the TDA998x development if that helps - but either way we need it
shared between all parties.
Brian Starkey Oct. 24, 2016, 2:23 p.m. UTC | #13
Hi Russell,

On Sat, Oct 22, 2016 at 02:40:22PM +0100, Russell King - ARM Linux wrote:
>On Wed, Oct 19, 2016 at 10:46:48AM +0100, Brian Starkey wrote:
>> Hi Jyri,
>>
>> I believe this will break mali-dp and hdlcd, unless something changed
>> while I wasn't looking. Please see this previous thread where I did
>> the same thing and then had to have it reverted: [1]
>>
>> Before removing this, we need to refactor (at least) mali-dp and hdlcd
>> to move drm_dev_register() to the end of their ->bind() callback.
>>
>> That could be done without moving drm_dev_unregister() to the start
>> of ->unbind() if you really want to nuke the drm_connector_register()
>> call, but to maintain symmetry (and introduce correctness) I was
>> putting it off until I had a chance to remove drm_vblank_cleanup()
>> from drm_dev_unregister() (because [2]).
>
>So what is the status of this - when is it going to happen?  Without
>this happening, I can't de-midlayer armada-drm, and I can't apply
>these TDA998x patches.
>
>As armada-drm stands at the moment, it can cope with the TDA998x
>driver having the drm_connector_register(), or with it eliminated.
>When armada-drm is de-midlayered without changing TDA998x, the
>drm_connector_register() call in TDA998x produces a warning:
>
>WARNING: CPU: 0 PID: 13 at lib/kobject.c:244 kobject_add_internal+0xfc/0x2d8
>kobject_add_internal failed for card0-HDMI-A-1 (error: -2 parent: card0)
>
>I suspect that you will end up with the same problem when you move
>the drm_dev_register() call after component_bind_all() - and I think
>the answer is... you shouldn't have de-midlayered until TDA998x had
>been updated to cope with de-midlayering, iow having had the
>drm_connector_register() call removed.
>

Well technically neither hdlcd or mali-dp ever had a midlayer, but yes
it would have been nice to have never introduced this problem in the
first place, I agree.

>Given that, I don't think we can avoid breaking mali-dp and hdlcd,
>except by combining the change into a single patch, changing all three
>drivers simultaneously (and any other driver which uses TDA998x which
>has also been de-midlayered.)
>

There is a way - we can explicitly register the connectors in hdlcd
and mali-dp (drm_connector_register_all used to be exposed for that
job, afaik to work around the kind of issue we face here).

But, that would introduce some extra churn, so probably a single patch
for all three works just fine.

I couldn't spot any other drivers I think will be affected. tilcdc
isn't de-midlayered.

>So, what I would like to see is a single patch against Linus' 4.8.0
>commit fixing mali-dp, hdlcd and any other driver, together with
>removing drm_connector_register() from TDA998x.  This is so the patch
>can be shared between all interested parties without forcing everyone
>to 4.9-rc1.  Looking at the diff between 4.8 and 4.9-rc1 for
>drivers/gpu/drm/arm, that shouldn't result in any merge conflicts -
>and if you want to follow on from that with 4.9-rc1 development, you
>can always merge 4.9-rc1 on top of that commit.
>
>I'm happy to take such a patch and publish it via my git tree as part
>of the TDA998x development if that helps - but either way we need it
>shared between all parties.

OK, I will follow up to this email with that patch. I note that it
will conflict with the series you sent out yesterday (23rd October).

Hopefully that's an agreeable solution for you, and everyone else.

Thanks,
-Brian

>
>-- 
>RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
>FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
>according to speedtest.net.
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
index 9798d40..265f854 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -1656,16 +1656,10 @@  static int tda998x_bind(struct device *dev, struct device *master, void *data)
 	if (ret)
 		goto err_connector;
 
-	ret = drm_connector_register(&priv->connector);
-	if (ret)
-		goto err_sysfs;
-
 	drm_mode_connector_attach_encoder(&priv->connector, &priv->encoder);
 
 	return 0;
 
-err_sysfs:
-	drm_connector_cleanup(&priv->connector);
 err_connector:
 	drm_encoder_cleanup(&priv->encoder);
 err_encoder: