Re: [RFC PATCH 1/2] drm: bridge: anx7688: Add anx7688 bridge driver support.

2016-06-23 Thread Philipp Zabel
Am Donnerstag, den 23.06.2016, 12:08 +0800 schrieb Nicolas Boichat:
[...]
> >> >> I think it'd be a bit weird to have the DDC bus phandle on the DP
> >> >> connector, as we're not reading the EDID on the DP side of the bridge,
> >> >> but on the HDMI side (and the bridge can do all sort of things to the
> >> >> EDID: At the very least, I think it caches it).
> >>>
> >> > On the board, do the DDC lines join directly from the SoC pins to the
> >> > DP connector, or does it go via the ANX7688 chip?
> >>
> >> The DDC/I2C lines go to the ANX7688 chip. (DP has AUX channel instead)
> >
> > The anx7688 should get the i2c-ddc-bus property then, and the driver
> > should use it to implement get_modes (or its bridge API equivalent, once
> > it exists).
> 
> Ok, I can do that (I tried it). It's a lot a duplication from the
> existing connector in mtk-hdmi, but I understand there may not be a
> better way currently.

Is there a thread where moving connectors back out of the bridge drivers
was discussed?

> However, the problem I'm facing is how to implement "detect" in the
> connector function. I'm still getting the interrupts from the MTK cec
> module (so the detect function gets called), but then I don't see a
> good way to read the HPD status (ANX7688 does not have a register for
> that: it passes the HPD signal downstream).
> 
> mtk_hdmi implements detect this way:
> return mtk_cec_hpd_high(hdmi->cec_dev) ?
>connector_status_connected : connector_status_disconnected;
> 
> But of course I can't call this function from the ANX7688 bridge driver...

If the bridge API is extended to get a .detect equivalent, the ANX7688
could just not implement it or return -ENOTSUPP to indicate HPD
passthrough and the mtk_hdmi connector could fall back to current
behaviour.

> >> > Even with the current bindings (referred from the link below), the
> >> > hdmi connector has the DDC node. Shouldn't it be the same in the DP
> >> > case too? The DP connector, like before, is still manged by the HDMI
> >> > driver, the only difference being the name and that it's two hops away
> >> > in the DT bindings.
> >> >
> >> > https://patchwork.kernel.org/patch/9137089/
> >>
> >> True, the bindings say so, but the current code actually looks for
> >> ddc-i2c-bus property in whatever is connected on the endpoint (be it a
> >> bridge or a connector).
> >
> > The HDMI driver only handles this itself because there are no separate
> > connector drivers (or helpers) to do this. Ideally the HDMI driver
> > shouldn't have to parse the connector DT node.
> >
> >> And again, a bit odd as DP connector does not have true I2C lines...
> >>
> >> Phillip? Any opinion?
> >
> > Make the HDMI driver leave the bridges' DT node alone and let the bridge
> > handle DDC, if that's where it is connected physically.
> 
> Again, a bit odd... AFAICT, all other bridge drivers, and encoders,
> read EDID from a bus that is downstream of it. If we handle DDC in the
> ANX driver, it'll have to read the EDID upstream (on the HDMI side),
> as there is no way to read the EDID on the DP side on this chip.

Well, the chip is a bit odd in that it seems to be intended to be
transparent to the software with the EDID and HPD passthrough, but then
still needs to have a driver.

regards
Philipp



Re: [RFC PATCH 1/2] drm: bridge: anx7688: Add anx7688 bridge driver support.

2016-06-22 Thread Nicolas Boichat
Hi Philipp,

On Wed, Jun 22, 2016 at 4:51 PM, Philipp Zabel  wrote:
> Hi Nicolas,
>
> Am Mittwoch, den 22.06.2016, 14:32 +0800 schrieb Nicolas Boichat:
>> >> Actually, experimenting a bit more with the code, I realized that the
>> >> connector is always attached to the encoder, not the bridge, so the 2
>> >> layouts above are actually identical (from the userspace point of
>> >> view). Except that the connector name should be HDMI in one case, and
>> >> DP in the other. But I think that's mostly a cosmetic difference?
>> >
>> >
>> > Yeah, probably. I don't know what exactly the userspace does with
>> > the connector type, but it would be nice to represent it as a DP
>> > connector in case it makes any decisions based on it.
>>
>> AFAICT does not matter... And, in any case, USB-C to HDMI adapters are
>> far more common (so we'd do HDMI->(DP over USB-C)->HDMI), so there
>> is a high change that advertising as DP would be wrong (and
>> advertising as HDMI would be correct by chance...).
>
> If anything it should be represented as an USB-C connector, whatever
> USB-C(DP)->HDMI->VGA adapter chain is connected externally shouldn't
> matter.

Indeed, looks like we could just create a new connector type.

>> >>> One way I can think of fixing this is to make make the MTK hdmi
>> >>> encoder driver a bit smarter by observing the DT connections. If
>> >>> it's output port is connected to just a hdmi-connector, then
>> >>> things should be as before. If the output is connected to the DP
>> >>> bridge, then it should create a DP connector. The connector ops
>> >>> for the DP connector can still be the same as that of the HDMI
>> >>> connector before, but the phandle to the DDC bus would be in the
>> >>> DP device node in this case.
>> >>
>> >>
>> >> I think it'd be a bit weird to have the DDC bus phandle on the DP
>> >> connector, as we're not reading the EDID on the DP side of the bridge,
>> >> but on the HDMI side (and the bridge can do all sort of things to the
>> >> EDID: At the very least, I think it caches it).
>>>
>> > On the board, do the DDC lines join directly from the SoC pins to the
>> > DP connector, or does it go via the ANX7688 chip?
>>
>> The DDC/I2C lines go to the ANX7688 chip. (DP has AUX channel instead)
>
> The anx7688 should get the i2c-ddc-bus property then, and the driver
> should use it to implement get_modes (or its bridge API equivalent, once
> it exists).

Ok, I can do that (I tried it). It's a lot a duplication from the
existing connector in mtk-hdmi, but I understand there may not be a
better way currently.

However, the problem I'm facing is how to implement "detect" in the
connector function. I'm still getting the interrupts from the MTK cec
module (so the detect function gets called), but then I don't see a
good way to read the HPD status (ANX7688 does not have a register for
that: it passes the HPD signal downstream).

mtk_hdmi implements detect this way:
return mtk_cec_hpd_high(hdmi->cec_dev) ?
   connector_status_connected : connector_status_disconnected;

But of course I can't call this function from the ANX7688 bridge driver...

>> > Even with the current bindings (referred from the link below), the
>> > hdmi connector has the DDC node. Shouldn't it be the same in the DP
>> > case too? The DP connector, like before, is still manged by the HDMI
>> > driver, the only difference being the name and that it's two hops away
>> > in the DT bindings.
>> >
>> > https://patchwork.kernel.org/patch/9137089/
>>
>> True, the bindings say so, but the current code actually looks for
>> ddc-i2c-bus property in whatever is connected on the endpoint (be it a
>> bridge or a connector).
>
> The HDMI driver only handles this itself because there are no separate
> connector drivers (or helpers) to do this. Ideally the HDMI driver
> shouldn't have to parse the connector DT node.
>
>> And again, a bit odd as DP connector does not have true I2C lines...
>>
>> Phillip? Any opinion?
>
> Make the HDMI driver leave the bridges' DT node alone and let the bridge
> handle DDC, if that's where it is connected physically.

Again, a bit odd... AFAICT, all other bridge drivers, and encoders,
read EDID from a bus that is downstream of it. If we handle DDC in the
ANX driver, it'll have to read the EDID upstream (on the HDMI side),
as there is no way to read the EDID on the DP side on this chip.

> regards
> Philipp
>

Thanks!

Best,


Re: [RFC PATCH 1/2] drm: bridge: anx7688: Add anx7688 bridge driver support.

2016-06-22 Thread Philipp Zabel
Hi Nicolas,

Am Mittwoch, den 22.06.2016, 14:32 +0800 schrieb Nicolas Boichat:
> >> Actually, experimenting a bit more with the code, I realized that the
> >> connector is always attached to the encoder, not the bridge, so the 2
> >> layouts above are actually identical (from the userspace point of
> >> view). Except that the connector name should be HDMI in one case, and
> >> DP in the other. But I think that's mostly a cosmetic difference?
> >
> >
> > Yeah, probably. I don't know what exactly the userspace does with
> > the connector type, but it would be nice to represent it as a DP
> > connector in case it makes any decisions based on it.
> 
> AFAICT does not matter... And, in any case, USB-C to HDMI adapters are
> far more common (so we'd do HDMI->(DP over USB-C)->HDMI), so there
> is a high change that advertising as DP would be wrong (and
> advertising as HDMI would be correct by chance...).

If anything it should be represented as an USB-C connector, whatever
USB-C(DP)->HDMI->VGA adapter chain is connected externally shouldn't
matter.

> >>> One way I can think of fixing this is to make make the MTK hdmi
> >>> encoder driver a bit smarter by observing the DT connections. If
> >>> it's output port is connected to just a hdmi-connector, then
> >>> things should be as before. If the output is connected to the DP
> >>> bridge, then it should create a DP connector. The connector ops
> >>> for the DP connector can still be the same as that of the HDMI
> >>> connector before, but the phandle to the DDC bus would be in the
> >>> DP device node in this case.
> >>
> >>
> >> I think it'd be a bit weird to have the DDC bus phandle on the DP
> >> connector, as we're not reading the EDID on the DP side of the bridge,
> >> but on the HDMI side (and the bridge can do all sort of things to the
> >> EDID: At the very least, I think it caches it).
>>
> > On the board, do the DDC lines join directly from the SoC pins to the
> > DP connector, or does it go via the ANX7688 chip?
> 
> The DDC/I2C lines go to the ANX7688 chip. (DP has AUX channel instead)

The anx7688 should get the i2c-ddc-bus property then, and the driver
should use it to implement get_modes (or its bridge API equivalent, once
it exists).

> > Even with the current bindings (referred from the link below), the
> > hdmi connector has the DDC node. Shouldn't it be the same in the DP
> > case too? The DP connector, like before, is still manged by the HDMI
> > driver, the only difference being the name and that it's two hops away
> > in the DT bindings.
> >
> > https://patchwork.kernel.org/patch/9137089/
> 
> True, the bindings say so, but the current code actually looks for
> ddc-i2c-bus property in whatever is connected on the endpoint (be it a
> bridge or a connector).

The HDMI driver only handles this itself because there are no separate
connector drivers (or helpers) to do this. Ideally the HDMI driver
shouldn't have to parse the connector DT node.

> And again, a bit odd as DP connector does not have true I2C lines...
> 
> Phillip? Any opinion?

Make the HDMI driver leave the bridges' DT node alone and let the bridge
handle DDC, if that's where it is connected physically.

regards
Philipp



Re: [RFC PATCH 1/2] drm: bridge: anx7688: Add anx7688 bridge driver support.

2016-06-21 Thread Nicolas Boichat
+Philipp

On Wed, Jun 22, 2016 at 11:54 AM, Archit Taneja  wrote:
>
>
> On 6/22/2016 8:14 AM, Nicolas Boichat wrote:
>>
>> Hi Archit,
>>
>> Thanks for your reply.
>>
>> On Tue, Jun 21, 2016 at 11:39 PM, Archit Taneja 
>> wrote:
>>>
>>> Hi,
>>>
>>> On 6/20/2016 12:44 PM, Nicolas Boichat wrote:


 ANX7688 is a HDMI to DP converter (as well as USB-C port controller),
 that has an internal microcontroller.

 The only reason a Linux kernel driver is necessary is to reject
 resolutions that require more bandwidth than what is available on
 the DP side. DP bandwidth and lane count are reported by the bridge
 via 2 registers on I2C.
>>>
>>>
>>>
>>> How does the chip know when to enable/disable itself? Does it shutoff
>>> itself if there isn't anything on the HDMI link?
>>
>>
>> Not 100% sure of the internals (there is a closed source firmware in
>> the chip), but I believe the HDMI/DP part of the chip is switched on
>> whenever there is a DP over USB-C connector plugged in.
>>

 Signed-off-by: Nicolas Boichat 
 ---

 Hi,

 I tested this driver using the Mediatek HDMI controller (MT8173)
 upstream
 of the ANX bridge chip (Phillip sent a PULL request on June 13:
 git://git.pengutronix.de/git/pza/linux.git tags/mediatek-drm-2016-06-13
 ).

 I have 2 concerns, that I'm not sure how to address within the kernel
 DRM
 framework:
1. All other bridge drivers also have a connector attached to it.
 However, in
   this case, we cannot read the monitor EDID directly, so I'm not
 sure
 what
   I could put in a "get_modes" function. Instead, ANX7688 provides a
 I2C
   passthru/repeater, so the EDID is read on the Mediatek HDMI
 controller side.

   That leads to a somewhat strange layout, where we have:
   - MTK HDMI bridge/encoder
 - MTK connector (HDMI)
 - ANX7688 bridge
   - No connector
>>>
>>>
>>>
>>>
>>> You should ideally have one DP connector at the end of the chain:
>>>
>>>  - MTK HDMI bridge/encoder
>>>  - ANX7688 bridge
>>> - Connector (DP)
>>>
>>> In the dt-bindings for this board, hdmi's output port shouldn't be
>>> connected to a hdmi connector, but the input port of the ANX7688
>>> DP bridge. The output port of the bridge should be the one that
>>> connects to the DP connector.
>>
>>
>> Yes that's what I do (in the device tree).
>>
>> Actually, experimenting a bit more with the code, I realized that the
>> connector is always attached to the encoder, not the bridge, so the 2
>> layouts above are actually identical (from the userspace point of
>> view). Except that the connector name should be HDMI in one case, and
>> DP in the other. But I think that's mostly a cosmetic difference?
>
>
> Yeah, probably. I don't know what exactly the userspace does with
> the connector type, but it would be nice to represent it as a DP
> connector in case it makes any decisions based on it.

AFAICT does not matter... And, in any case, USB-C to HDMI adapters are
far more common (so we'd do HDMI->(DP over USB-C)->HDMI), so there
is a high change that advertising as DP would be wrong (and
advertising as HDMI would be correct by chance...).

>>
>>> One way I can think of fixing this is to make make the MTK hdmi
>>> encoder driver a bit smarter by observing the DT connections. If
>>> it's output port is connected to just a hdmi-connector, then
>>> things should be as before. If the output is connected to the DP
>>> bridge, then it should create a DP connector. The connector ops
>>> for the DP connector can still be the same as that of the HDMI
>>> connector before, but the phandle to the DDC bus would be in the
>>> DP device node in this case.
>>
>>
>> I think it'd be a bit weird to have the DDC bus phandle on the DP
>> connector, as we're not reading the EDID on the DP side of the bridge,
>> but on the HDMI side (and the bridge can do all sort of things to the
>> EDID: At the very least, I think it caches it).
>
>
> On the board, do the DDC lines join directly from the SoC pins to the
> DP connector, or does it go via the ANX7688 chip?

The DDC/I2C lines go to the ANX7688 chip. (DP has AUX channel instead)

> Even with the current bindings (referred from the link below), the
> hdmi connector has the DDC node. Shouldn't it be the same in the DP
> case too? The DP connector, like before, is still manged by the HDMI
> driver, the only difference being the name and that it's two hops away
> in the DT bindings.
>
> https://patchwork.kernel.org/patch/9137089/

True, the bindings say so, but the current code actually looks for
ddc-i2c-bus property in whatever is connected on the endpoint (be it a
bridge or a connector).

And again, a bit odd as DP connector does not have true I2C lines...

Phillip? Any opinion?

>>
>>> This way, you can get around having the correct layout.
>>>
>>> Ideally, a bridge dr

Re: [RFC PATCH 1/2] drm: bridge: anx7688: Add anx7688 bridge driver support.

2016-06-21 Thread Archit Taneja



On 6/22/2016 8:14 AM, Nicolas Boichat wrote:

Hi Archit,

Thanks for your reply.

On Tue, Jun 21, 2016 at 11:39 PM, Archit Taneja  wrote:

Hi,

On 6/20/2016 12:44 PM, Nicolas Boichat wrote:


ANX7688 is a HDMI to DP converter (as well as USB-C port controller),
that has an internal microcontroller.

The only reason a Linux kernel driver is necessary is to reject
resolutions that require more bandwidth than what is available on
the DP side. DP bandwidth and lane count are reported by the bridge
via 2 registers on I2C.



How does the chip know when to enable/disable itself? Does it shutoff
itself if there isn't anything on the HDMI link?


Not 100% sure of the internals (there is a closed source firmware in
the chip), but I believe the HDMI/DP part of the chip is switched on
whenever there is a DP over USB-C connector plugged in.



Signed-off-by: Nicolas Boichat 
---

Hi,

I tested this driver using the Mediatek HDMI controller (MT8173) upstream
of the ANX bridge chip (Phillip sent a PULL request on June 13:
git://git.pengutronix.de/git/pza/linux.git tags/mediatek-drm-2016-06-13
).

I have 2 concerns, that I'm not sure how to address within the kernel DRM
framework:
   1. All other bridge drivers also have a connector attached to it.
However, in
  this case, we cannot read the monitor EDID directly, so I'm not sure
what
  I could put in a "get_modes" function. Instead, ANX7688 provides a
I2C
  passthru/repeater, so the EDID is read on the Mediatek HDMI
controller side.

  That leads to a somewhat strange layout, where we have:
  - MTK HDMI bridge/encoder
- MTK connector (HDMI)
- ANX7688 bridge
  - No connector




You should ideally have one DP connector at the end of the chain:

 - MTK HDMI bridge/encoder
 - ANX7688 bridge
- Connector (DP)

In the dt-bindings for this board, hdmi's output port shouldn't be
connected to a hdmi connector, but the input port of the ANX7688
DP bridge. The output port of the bridge should be the one that
connects to the DP connector.


Yes that's what I do (in the device tree).

Actually, experimenting a bit more with the code, I realized that the
connector is always attached to the encoder, not the bridge, so the 2
layouts above are actually identical (from the userspace point of
view). Except that the connector name should be HDMI in one case, and
DP in the other. But I think that's mostly a cosmetic difference?


Yeah, probably. I don't know what exactly the userspace does with
the connector type, but it would be nice to represent it as a DP
connector in case it makes any decisions based on it.




One way I can think of fixing this is to make make the MTK hdmi
encoder driver a bit smarter by observing the DT connections. If
it's output port is connected to just a hdmi-connector, then
things should be as before. If the output is connected to the DP
bridge, then it should create a DP connector. The connector ops
for the DP connector can still be the same as that of the HDMI
connector before, but the phandle to the DDC bus would be in the
DP device node in this case.


I think it'd be a bit weird to have the DDC bus phandle on the DP
connector, as we're not reading the EDID on the DP side of the bridge,
but on the HDMI side (and the bridge can do all sort of things to the
EDID: At the very least, I think it caches it).


On the board, do the DDC lines join directly from the SoC pins to the
DP connector, or does it go via the ANX7688 chip?

Even with the current bindings (referred from the link below), the
hdmi connector has the DDC node. Shouldn't it be the same in the DP
case too? The DP connector, like before, is still manged by the HDMI
driver, the only difference being the name and that it's two hops away
in the DT bindings.

https://patchwork.kernel.org/patch/9137089/




This way, you can get around having the correct layout.

Ideally, a bridge driver shouldn't be the one that creates a
connector. It may contain some of the connector functionality, but
the connector creation should be managed by the kms driver.
Almost all bridge drivers creating a connector in their .attach
callbacks since they own some of the connector functionality (like
reading EDID). That's something we're trying to fix by providing
some more bridge api that kms drivers can use.

Since this bridge driver doesn't have any connector functionality
anyway, you should be okay.


Great, thanks for clarifying.



  Resolution filtering works fine though, thanks to mode_fixup callback
on the
  bridge. It also helps that Mediatek HDMI bridge calls mode_fixup from
its
  connector mode_valid callback, so that invalid modes are not even
presented
  to userspace.

   2. In the bandwidth computation, I hard-code 8-bit per channel (bpc).
bpc does
  not seem to be included in the mode setting itself. We could possibly
iterate
  over connectors on the DRM device, but then, IIUC,
connector->display_info.bpc

Re: [RFC PATCH 1/2] drm: bridge: anx7688: Add anx7688 bridge driver support.

2016-06-21 Thread Nicolas Boichat
Hi Archit,

Thanks for your reply.

On Tue, Jun 21, 2016 at 11:39 PM, Archit Taneja  wrote:
> Hi,
>
> On 6/20/2016 12:44 PM, Nicolas Boichat wrote:
>>
>> ANX7688 is a HDMI to DP converter (as well as USB-C port controller),
>> that has an internal microcontroller.
>>
>> The only reason a Linux kernel driver is necessary is to reject
>> resolutions that require more bandwidth than what is available on
>> the DP side. DP bandwidth and lane count are reported by the bridge
>> via 2 registers on I2C.
>
>
> How does the chip know when to enable/disable itself? Does it shutoff
> itself if there isn't anything on the HDMI link?

Not 100% sure of the internals (there is a closed source firmware in
the chip), but I believe the HDMI/DP part of the chip is switched on
whenever there is a DP over USB-C connector plugged in.

>>
>> Signed-off-by: Nicolas Boichat 
>> ---
>>
>> Hi,
>>
>> I tested this driver using the Mediatek HDMI controller (MT8173) upstream
>> of the ANX bridge chip (Phillip sent a PULL request on June 13:
>> git://git.pengutronix.de/git/pza/linux.git tags/mediatek-drm-2016-06-13
>> ).
>>
>> I have 2 concerns, that I'm not sure how to address within the kernel DRM
>> framework:
>>   1. All other bridge drivers also have a connector attached to it.
>> However, in
>>  this case, we cannot read the monitor EDID directly, so I'm not sure
>> what
>>  I could put in a "get_modes" function. Instead, ANX7688 provides a
>> I2C
>>  passthru/repeater, so the EDID is read on the Mediatek HDMI
>> controller side.
>>
>>  That leads to a somewhat strange layout, where we have:
>>  - MTK HDMI bridge/encoder
>>- MTK connector (HDMI)
>>- ANX7688 bridge
>>  - No connector
>
>
>
> You should ideally have one DP connector at the end of the chain:
>
> - MTK HDMI bridge/encoder
> - ANX7688 bridge
>- Connector (DP)
>
> In the dt-bindings for this board, hdmi's output port shouldn't be
> connected to a hdmi connector, but the input port of the ANX7688
> DP bridge. The output port of the bridge should be the one that
> connects to the DP connector.

Yes that's what I do (in the device tree).

Actually, experimenting a bit more with the code, I realized that the
connector is always attached to the encoder, not the bridge, so the 2
layouts above are actually identical (from the userspace point of
view). Except that the connector name should be HDMI in one case, and
DP in the other. But I think that's mostly a cosmetic difference?

> One way I can think of fixing this is to make make the MTK hdmi
> encoder driver a bit smarter by observing the DT connections. If
> it's output port is connected to just a hdmi-connector, then
> things should be as before. If the output is connected to the DP
> bridge, then it should create a DP connector. The connector ops
> for the DP connector can still be the same as that of the HDMI
> connector before, but the phandle to the DDC bus would be in the
> DP device node in this case.

I think it'd be a bit weird to have the DDC bus phandle on the DP
connector, as we're not reading the EDID on the DP side of the bridge,
but on the HDMI side (and the bridge can do all sort of things to the
EDID: At the very least, I think it caches it).

> This way, you can get around having the correct layout.
>
> Ideally, a bridge driver shouldn't be the one that creates a
> connector. It may contain some of the connector functionality, but
> the connector creation should be managed by the kms driver.
> Almost all bridge drivers creating a connector in their .attach
> callbacks since they own some of the connector functionality (like
> reading EDID). That's something we're trying to fix by providing
> some more bridge api that kms drivers can use.
>
> Since this bridge driver doesn't have any connector functionality
> anyway, you should be okay.

Great, thanks for clarifying.

>>
>>  Resolution filtering works fine though, thanks to mode_fixup callback
>> on the
>>  bridge. It also helps that Mediatek HDMI bridge calls mode_fixup from
>> its
>>  connector mode_valid callback, so that invalid modes are not even
>> presented
>>  to userspace.
>>
>>   2. In the bandwidth computation, I hard-code 8-bit per channel (bpc).
>> bpc does
>>  not seem to be included in the mode setting itself. We could possibly
>> iterate
>>  over connectors on the DRM device, but then, IIUC,
>> connector->display_info.bpc
>>  indicates the _maximum_ bpc supported by the monitor.
>
>
> I'm not clear about this either. Some drivers set a bus format
> on the connector via drm_display_info_set_bus_formats in their
> get_modes connector op, and then retrieve it later.

Ah, interesting... Seems like we'd need a big switch/case to convert
from bus_format to bpp, though.

>>
>> Any pointers? Thanks!
>>
>> Best,
>>
>> Nicolas
>>
>>   drivers/gpu/drm/bridge/Kconfig|   9 ++
>>   drivers/gpu/drm/bridge/Makefile   |   1 +
>>   d

Re: [RFC PATCH 1/2] drm: bridge: anx7688: Add anx7688 bridge driver support.

2016-06-21 Thread Archit Taneja

Hi,

On 6/20/2016 12:44 PM, Nicolas Boichat wrote:

ANX7688 is a HDMI to DP converter (as well as USB-C port controller),
that has an internal microcontroller.

The only reason a Linux kernel driver is necessary is to reject
resolutions that require more bandwidth than what is available on
the DP side. DP bandwidth and lane count are reported by the bridge
via 2 registers on I2C.


How does the chip know when to enable/disable itself? Does it shutoff
itself if there isn't anything on the HDMI link?



Signed-off-by: Nicolas Boichat 
---

Hi,

I tested this driver using the Mediatek HDMI controller (MT8173) upstream
of the ANX bridge chip (Phillip sent a PULL request on June 13:
git://git.pengutronix.de/git/pza/linux.git tags/mediatek-drm-2016-06-13
).

I have 2 concerns, that I'm not sure how to address within the kernel DRM
framework:
  1. All other bridge drivers also have a connector attached to it. However, in
 this case, we cannot read the monitor EDID directly, so I'm not sure what
 I could put in a "get_modes" function. Instead, ANX7688 provides a I2C
 passthru/repeater, so the EDID is read on the Mediatek HDMI controller 
side.

 That leads to a somewhat strange layout, where we have:
 - MTK HDMI bridge/encoder
   - MTK connector (HDMI)
   - ANX7688 bridge
 - No connector



You should ideally have one DP connector at the end of the chain:

- MTK HDMI bridge/encoder
- ANX7688 bridge
   - Connector (DP)

In the dt-bindings for this board, hdmi's output port shouldn't be
connected to a hdmi connector, but the input port of the ANX7688
DP bridge. The output port of the bridge should be the one that
connects to the DP connector.

One way I can think of fixing this is to make make the MTK hdmi
encoder driver a bit smarter by observing the DT connections. If
it's output port is connected to just a hdmi-connector, then
things should be as before. If the output is connected to the DP
bridge, then it should create a DP connector. The connector ops
for the DP connector can still be the same as that of the HDMI
connector before, but the phandle to the DDC bus would be in the
DP device node in this case.

This way, you can get around having the correct layout.

Ideally, a bridge driver shouldn't be the one that creates a
connector. It may contain some of the connector functionality, but
the connector creation should be managed by the kms driver.
Almost all bridge drivers creating a connector in their .attach
callbacks since they own some of the connector functionality (like
reading EDID). That's something we're trying to fix by providing
some more bridge api that kms drivers can use.

Since this bridge driver doesn't have any connector functionality
anyway, you should be okay.



 Resolution filtering works fine though, thanks to mode_fixup callback on 
the
 bridge. It also helps that Mediatek HDMI bridge calls mode_fixup from its
 connector mode_valid callback, so that invalid modes are not even presented
 to userspace.

  2. In the bandwidth computation, I hard-code 8-bit per channel (bpc). bpc does
 not seem to be included in the mode setting itself. We could possibly 
iterate
 over connectors on the DRM device, but then, IIUC, 
connector->display_info.bpc
 indicates the _maximum_ bpc supported by the monitor.


I'm not clear about this either. Some drivers set a bus format
on the connector via drm_display_info_set_bus_formats in their
get_modes connector op, and then retrieve it later.



Any pointers? Thanks!

Best,

Nicolas

  drivers/gpu/drm/bridge/Kconfig|   9 ++
  drivers/gpu/drm/bridge/Makefile   |   1 +
  drivers/gpu/drm/bridge/analogix-anx7688.c | 227 ++
  3 files changed, 237 insertions(+)
  create mode 100644 drivers/gpu/drm/bridge/analogix-anx7688.c

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 8f7423f..0c1eb41 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -7,6 +7,15 @@ config DRM_BRIDGE
  menu "Display Interface Bridges"
depends on DRM && DRM_BRIDGE

+config DRM_ANALOGIX_ANX7688
+   tristate "Analogix ANX7688 bridge"
+   depends on DRM
+   select DRM_KMS_HELPER
+   ---help---
+ ANX7688 is a transmitter to support DisplayPort over USB-C for
+ smartphone and tablets.
+ This driver only supports the HDMI to DP component of the chip.
+
  config DRM_ANALOGIX_ANX78XX
tristate "Analogix ANX78XX bridge"
select DRM_KMS_HELPER
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index 96b13b3..d744c6c 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -1,5 +1,6 @@
  ccflags-y := -Iinclude/drm

+obj-$(CONFIG_DRM_ANALOGIX_ANX7688) += analogix-anx7688.o
  obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
  obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o
  obj-$(CONFIG_D