diff mbox

drm: bridge/dw_hdmi: Filter modes > 165MHz for DVI

Message ID 1434582847-713-1-git-send-email-dianders@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Doug Anderson June 17, 2015, 11:14 p.m. UTC
If you plug in a DVI monitor to your HDMI port, you need to filter out
clocks > 165MHz.  That's because 165MHz is the maximum clock rate that
we can run single-link DVI at.

If you want to run high resolutions to DVI, you'd need some type of an
active adapter that pretended that it was HDMI, interpreted the
signal, and produced a new dual link DVI signal at a lower clock rate.

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
Note: this patch was tested against a 3.14 kernel with backports.  It
was only compile tested against linuxnext, but the code is
sufficiently similar that I'm convinced it will work there.

 drivers/gpu/drm/bridge/dw_hdmi.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Doug Anderson June 18, 2015, 2:52 a.m. UTC | #1
Russell,

On Wed, Jun 17, 2015 at 4:30 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Wed, Jun 17, 2015 at 04:14:07PM -0700, Doug Anderson wrote:
>> If you plug in a DVI monitor to your HDMI port, you need to filter out
>> clocks > 165MHz.  That's because 165MHz is the maximum clock rate that
>> we can run single-link DVI at.
>>
>> If you want to run high resolutions to DVI, you'd need some type of an
>> active adapter that pretended that it was HDMI, interpreted the
>> signal, and produced a new dual link DVI signal at a lower clock rate.
>>
>> Signed-off-by: Doug Anderson <dianders@chromium.org>
>> ---
>> Note: this patch was tested against a 3.14 kernel with backports.  It
>> was only compile tested against linuxnext, but the code is
>> sufficiently similar that I'm convinced it will work there.
>
> Really?  I have to wonder what your testing was...
>
>         hdmi->vic = drm_match_cea_mode(mode);
>
>         if (!hdmi->vic) {
>                 dev_dbg(hdmi->dev, "Non-CEA mode used in HDMI\n");
>                 hdmi->hdmi_data.video_mode.mdvi = true;
>         } else {
>                 dev_dbg(hdmi->dev, "CEA mode used vic=%d\n", hdmi->vic);
>                 hdmi->hdmi_data.video_mode.mdvi = false;
>         }
>
> mdvi indicates whether the _currently set mode_ is a CEA mode or not (imho,
> it's mis-named).  It doesn't indicate whether we have a HDMI display device
> or a DVI display device connected, which seems to be what you want to use
> it for below.
>
> To sort that, what you need to do is detect a HDMI display device using
> drm_detect_hdmi_monitor() on the EDID received from the device before
> parsing the modes, and save that value in a dw_hdmi struct member, and
> I'd suggest that it's a top-level struct member, not buried in 'hdmi_data'
> or 'video_mode'.

OK, so clearly my patch won't work against mainline.  I guess it's a
good thing that I pointed out that it was only tested locally (would
have been better to test against mainline, but I don't think that's so
easy since there are several unlanded patches in mainline for
Rockchip).

As pointed out by others at <http://crosreview.com/278255>, locally
our kernel has a slightly older version of
<https://lkml.org/lkml/2015/2/28/291>, which would change mdvi to be
as needed.

...so I guess my change is blocked on someone reviewing/landing that
series.  If that series is rejected (or is changed sufficiently so
that mdvi no longer is set via drm_detect_hdmi_monitor() then my patch
will need to be re-spun.

-Doug
Russell King - ARM Linux June 18, 2015, 8:53 a.m. UTC | #2
On Wed, Jun 17, 2015 at 07:52:14PM -0700, Doug Anderson wrote:
> Russell,
> 
> On Wed, Jun 17, 2015 at 4:30 PM, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
> > On Wed, Jun 17, 2015 at 04:14:07PM -0700, Doug Anderson wrote:
> >> If you plug in a DVI monitor to your HDMI port, you need to filter out
> >> clocks > 165MHz.  That's because 165MHz is the maximum clock rate that
> >> we can run single-link DVI at.
> >>
> >> If you want to run high resolutions to DVI, you'd need some type of an
> >> active adapter that pretended that it was HDMI, interpreted the
> >> signal, and produced a new dual link DVI signal at a lower clock rate.
> >>
> >> Signed-off-by: Doug Anderson <dianders@chromium.org>
> >> ---
> >> Note: this patch was tested against a 3.14 kernel with backports.  It
> >> was only compile tested against linuxnext, but the code is
> >> sufficiently similar that I'm convinced it will work there.
> >
> > Really?  I have to wonder what your testing was...
> >
> >         hdmi->vic = drm_match_cea_mode(mode);
> >
> >         if (!hdmi->vic) {
> >                 dev_dbg(hdmi->dev, "Non-CEA mode used in HDMI\n");
> >                 hdmi->hdmi_data.video_mode.mdvi = true;
> >         } else {
> >                 dev_dbg(hdmi->dev, "CEA mode used vic=%d\n", hdmi->vic);
> >                 hdmi->hdmi_data.video_mode.mdvi = false;
> >         }
> >
> > mdvi indicates whether the _currently set mode_ is a CEA mode or not (imho,
> > it's mis-named).  It doesn't indicate whether we have a HDMI display device
> > or a DVI display device connected, which seems to be what you want to use
> > it for below.
> >
> > To sort that, what you need to do is detect a HDMI display device using
> > drm_detect_hdmi_monitor() on the EDID received from the device before
> > parsing the modes, and save that value in a dw_hdmi struct member, and
> > I'd suggest that it's a top-level struct member, not buried in 'hdmi_data'
> > or 'video_mode'.
> 
> OK, so clearly my patch won't work against mainline.  I guess it's a
> good thing that I pointed out that it was only tested locally (would
> have been better to test against mainline, but I don't think that's so
> easy since there are several unlanded patches in mainline for
> Rockchip).

As far as I'm aware, Freescale's original BSP version was the same, as is
their later BSPs, and Jon's maintained 3.14-stable kernel.

> As pointed out by others at <http://crosreview.com/278255>, locally
> our kernel has a slightly older version of
> <https://lkml.org/lkml/2015/2/28/291>, which would change mdvi to be
> as needed.

Please don't post unreliable lkml.org URLs, please use some other archive
site.  I can't access this URL at the moment.

> ...so I guess my change is blocked on someone reviewing/landing that
> series.  If that series is rejected (or is changed sufficiently so
> that mdvi no longer is set via drm_detect_hdmi_monitor() then my patch
> will need to be re-spun.

That's not what I said.  I said mdvi is set according to whether the mode
being set is a CEA mode or not.  We need something set according to
the return value of drm_detect_hdmi_monitor(), which will tell us if the
connected sink is a HDMI device or a DVI device (based upon the EDID.)

A thought occurs to me this morning though: what happens if you connect
a DVI monitor to an AV receiver which is then connected to this device.
Does the resulting EDID contain the HDMI vendor ID?  If it does, it
means that drm_detect_hdmi_monitor() will return true, indicating that
the connected device is HDMI, and we will still allow modes greater than
165MHz.

That's probably a scenario that should be checked at some point... and
it would throw a question mark over whether this is the correct approach
to limit the video modes.
Doug Anderson June 18, 2015, 3:26 p.m. UTC | #3
Russell,

On Thu, Jun 18, 2015 at 1:53 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
>> OK, so clearly my patch won't work against mainline.  I guess it's a
>> good thing that I pointed out that it was only tested locally (would
>> have been better to test against mainline, but I don't think that's so
>> easy since there are several unlanded patches in mainline for
>> Rockchip).
>
> As far as I'm aware, Freescale's original BSP version was the same, as is
> their later BSPs, and Jon's maintained 3.14-stable kernel.

Was "the same"?  You mean was untested, or was 3.14?  It is probably
not the same "3.14 with backports" that I'm testing on, which includes
backports + things from the mailing list that haven't landed yet, as
many of the unlanded patches are things that make Rockchip HDMI work
more correctly.  Perhaps I should have called my tree "3.14 with
backports + unlanded patches" or "the chromeos 3.14 tree" to make it
clearer.

In general I haven't been posting patches that I've made to HDMI since
it appears that our tree has significant differences from mainline.
In this case the function I was touching looked identical to mainline
so I figured posting a patch seemed reasonable.


>> As pointed out by others at <http://crosreview.com/278255>, locally
>> our kernel has a slightly older version of
>> <https://lkml.org/lkml/2015/2/28/291>, which would change mdvi to be
>> as needed.
>
> Please don't post unreliable lkml.org URLs, please use some other archive
> site.  I can't access this URL at the moment.

Perhaps you can try <https://patchwork.kernel.org/patch/5906771/>


>> ...so I guess my change is blocked on someone reviewing/landing that
>> series.  If that series is rejected (or is changed sufficiently so
>> that mdvi no longer is set via drm_detect_hdmi_monitor() then my patch
>> will need to be re-spun.
>
> That's not what I said.  I said mdvi is set according to whether the mode
> being set is a CEA mode or not.

Perhaps now that you can access the patch with the patchwork link you
can re-read my email.  If/when that patch lands then mdvi _will_ be
set as per drm_detect_hdmi_monitor().


> A thought occurs to me this morning though: what happens if you connect
> a DVI monitor to an AV receiver which is then connected to this device.
> Does the resulting EDID contain the HDMI vendor ID?  If it does, it
> means that drm_detect_hdmi_monitor() will return true, indicating that
> the connected device is HDMI, and we will still allow modes greater than
> 165MHz.

I am nowhere near an HDMI expert.  If you have a better suggestion
then I'm more than happy for you to post it and drop my patch.  In my
non-expert opinion, it would seem awfully strange for an AV receiver
to modify the EDID though unless it was actively interpreting the
signal and generating a whole new signal on the other end.  In any
case, perhaps you can find such a device and that will give insight to
how we should deal with it.  Until such a device is found, it seems
fruitless to speculate.

Personally, I was pointed at "drivers/gpu/drm/i915/intel_hdmi.c".  If
you look there you will find a similar bit of code.


To summarize: I am not planning to spin my patch.  I am hopeful that
folks could review Yakir's series.  Would it help if he re-sent it
with different people in the "To" line?

Maybe when Yakir spins his series next he can include my patch?


-Doug
Russell King - ARM Linux June 18, 2015, 3:55 p.m. UTC | #4
On Thu, Jun 18, 2015 at 08:26:39AM -0700, Doug Anderson wrote:
> Russell,
> 
> On Thu, Jun 18, 2015 at 1:53 AM, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
> >> OK, so clearly my patch won't work against mainline.  I guess it's a
> >> good thing that I pointed out that it was only tested locally (would
> >> have been better to test against mainline, but I don't think that's so
> >> easy since there are several unlanded patches in mainline for
> >> Rockchip).
> >
> > As far as I'm aware, Freescale's original BSP version was the same, as is
> > their later BSPs, and Jon's maintained 3.14-stable kernel.
> 
> Was "the same"?  You mean was untested, or was 3.14?

I'm saying that the mdvi thing behaves the same in all the kernel sources
I've seen of this driver, and I'm unaware of anything that changes it -
and I've been looking at Jon's 3.14-stable kernels as well as Freescale's
git repository.

> >> As pointed out by others at <http://crosreview.com/278255>, locally
> >> our kernel has a slightly older version of
> >> <https://lkml.org/lkml/2015/2/28/291>, which would change mdvi to be
> >> as needed.
> >
> > Please don't post unreliable lkml.org URLs, please use some other archive
> > site.  I can't access this URL at the moment.
> 
> Perhaps you can try <https://patchwork.kernel.org/patch/5906771/>

Something like that needs to be done, but let's get rid of the mdvi
thing in struct hdmi_vmode - it doesn't belong there, it isn't part
of the currently set video mode, but becomes a property of the
connected sink.

I'd also prefer it to be called "is_dvi_sink", especially as its
function is changing from "is it a CEA mode" to "is the attached
device a DVI sink".

Even better would be to call it "is_hdmi_sink" to maintain positive
logic with single-negation where required, rather than double-
negation in places.

> >> ...so I guess my change is blocked on someone reviewing/landing that
> >> series.  If that series is rejected (or is changed sufficiently so
> >> that mdvi no longer is set via drm_detect_hdmi_monitor() then my patch
> >> will need to be re-spun.
> >
> > That's not what I said.  I said mdvi is set according to whether the mode
> > being set is a CEA mode or not.
> 
> Perhaps now that you can access the patch with the patchwork link you
> can re-read my email.  If/when that patch lands then mdvi _will_ be
> set as per drm_detect_hdmi_monitor().

Well, I object to that patch (see above.)

> I am nowhere near an HDMI expert.  If you have a better suggestion
> then I'm more than happy for you to post it and drop my patch.  In my
> non-expert opinion, it would seem awfully strange for an AV receiver
> to modify the EDID though unless it was actively interpreting the
> signal and generating a whole new signal on the other end.  In any
> case, perhaps you can find such a device and that will give insight to
> how we should deal with it.  Until such a device is found, it seems
> fruitless to speculate.

Neither am I, but I have had the ability to do some testing with AV
receivers in the path of a HDMI device, and I've seen how they behave.
(I made copious notes on this, which I intend to publish when I have
a round tuit.)  Unfortunately, I have no DVI devices to test with,
and DVI devices are a dying breed - most monitors today come with
HDMI sockets instead.

> Personally, I was pointed at "drivers/gpu/drm/i915/intel_hdmi.c".  If
> you look there you will find a similar bit of code.

Yea, I've also been using that for inspiration too, but I put personal
testing above what's in someone elses driver. :)

> To summarize: I am not planning to spin my patch.  I am hopeful that
> folks could review Yakir's series.  Would it help if he re-sent it
> with different people in the "To" line?

That's a shame... I'm not inclined to Ack it as-is - and I'd also like
to see Yakir's patch reworked as I mentioned above.
Doug Anderson June 18, 2015, 4:10 p.m. UTC | #5
Russell,

On Thu, Jun 18, 2015 at 8:55 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
>> Perhaps you can try <https://patchwork.kernel.org/patch/5906771/>
>
> Something like that needs to be done, but let's get rid of the mdvi
> thing in struct hdmi_vmode - it doesn't belong there, it isn't part
> of the currently set video mode, but becomes a property of the
> connected sink.
>
> I'd also prefer it to be called "is_dvi_sink", especially as its
> function is changing from "is it a CEA mode" to "is the attached
> device a DVI sink".
>
> Even better would be to call it "is_hdmi_sink" to maintain positive
> logic with single-negation where required, rather than double-
> negation in places.

Yakir: sounds like you now have some feedback on your patch now.
Perhaps you can spin it with Russell's feedback?

When you send it next, please make sure you include Russell in the
"To" line.  Based at looking at who committed things to dw_hdmi in the
past, I've been sending my patches "To":
    Philipp Zabel
    Russell King
    Thierry Reding

...so perhaps that would be good for you to do, too?

>> I am nowhere near an HDMI expert.  If you have a better suggestion
>> then I'm more than happy for you to post it and drop my patch.  In my
>> non-expert opinion, it would seem awfully strange for an AV receiver
>> to modify the EDID though unless it was actively interpreting the
>> signal and generating a whole new signal on the other end.  In any
>> case, perhaps you can find such a device and that will give insight to
>> how we should deal with it.  Until such a device is found, it seems
>> fruitless to speculate.
>
> Neither am I, but I have had the ability to do some testing with AV
> receivers in the path of a HDMI device, and I've seen how they behave.
> (I made copious notes on this, which I intend to publish when I have
> a round tuit.)  Unfortunately, I have no DVI devices to test with,
> and DVI devices are a dying breed - most monitors today come with
> HDMI sockets instead.

Ah, OK.  Have you seen any that specifically confuse the DVI vs. HDMI bits?

I still have copious DVI devices around, personally.  I could have
sworn that supporting "older hardware" was actually pretty important
in Linux.  ...and I can still buy plenty of DVI devices out there.


> That's a shame... I'm not inclined to Ack it as-is - and I'd also like
> to see Yakir's patch reworked as I mentioned above.

Perhaps when Yakir spins his series he can include a patch like mine
in it.  It doesn't make sense for me to re-spin it until his is
resolved.

-Doug
Yakir Yang June 19, 2015, 1:31 a.m. UTC | #6
Doug & Russell,

? 2015/6/19 0:10, Doug Anderson ??:
> Russell,
>
> On Thu, Jun 18, 2015 at 8:55 AM, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
>>> Perhaps you can try <https://patchwork.kernel.org/patch/5906771/>
>> Something like that needs to be done, but let's get rid of the mdvi
>> thing in struct hdmi_vmode - it doesn't belong there, it isn't part
>> of the currently set video mode, but becomes a property of the
>> connected sink.
>>
>> I'd also prefer it to be called "is_dvi_sink", especially as its
>> function is changing from "is it a CEA mode" to "is the attached
>> device a DVI sink".
>>
>> Even better would be to call it "is_hdmi_sink" to maintain positive
>> logic with single-negation where required, rather than double-
>> negation in places.
> Yakir: sounds like you now have some feedback on your patch now.
> Perhaps you can spin it with Russell's feedback?
>
> When you send it next, please make sure you include Russell in the
> "To" line.  Based at looking at who committed things to dw_hdmi in the
> past, I've been sending my patches "To":
>      Philipp Zabel
>      Russell King
>      Thierry Reding
>
> ...so perhaps that would be good for you to do, too?

Okay,  thanks for your remind.

>>> I am nowhere near an HDMI expert.  If you have a better suggestion
>>> then I'm more than happy for you to post it and drop my patch.  In my
>>> non-expert opinion, it would seem awfully strange for an AV receiver
>>> to modify the EDID though unless it was actively interpreting the
>>> signal and generating a whole new signal on the other end.  In any
>>> case, perhaps you can find such a device and that will give insight to
>>> how we should deal with it.  Until such a device is found, it seems
>>> fruitless to speculate.
>> Neither am I, but I have had the ability to do some testing with AV
>> receivers in the path of a HDMI device, and I've seen how they behave.
>> (I made copious notes on this, which I intend to publish when I have
>> a round tuit.)  Unfortunately, I have no DVI devices to test with,
>> and DVI devices are a dying breed - most monitors today come with
>> HDMI sockets instead.
> Ah, OK.  Have you seen any that specifically confuse the DVI vs. HDMI bits?
>
> I still have copious DVI devices around, personally.  I could have
> sworn that supporting "older hardware" was actually pretty important
> in Linux.  ...and I can still buy plenty of DVI devices out there.
>
>
>> That's a shame... I'm not inclined to Ack it as-is - and I'd also like
>> to see Yakir's patch reworked as I mentioned above.
> Perhaps when Yakir spins his series he can include a patch like mine
> in it.  It doesn't make sense for me to re-spin it until his is
> resolved.
I will rebase on russell series and re-send my patch today.

- Yakir
> -Doug
>
>
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 816d104..48b8532 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -1421,8 +1421,12 @@  dw_hdmi_connector_mode_valid(struct drm_connector *connector,
 {
 	struct dw_hdmi *hdmi = container_of(connector,
 					   struct dw_hdmi, connector);
+	struct hdmi_vmode *vmode = &hdmi->hdmi_data.video_mode;
 	enum drm_mode_status mode_status = MODE_OK;
 
+	if (mode->clock > 165000 && vmode->mdvi)
+		return MODE_BAD;
+
 	if (hdmi->plat_data->mode_valid)
 		mode_status = hdmi->plat_data->mode_valid(connector, mode);