Bug 25913 - Intermittent surious TV-out detection on GM45
Summary: Intermittent surious TV-out detection on GM45
Status: CLOSED FIXED
Alias: None
Product: DRI
Classification: Unclassified
Component: DRM/Intel (show other bugs)
Version: XOrg git
Hardware: Other All
: medium normal
Assignee: ykzhao
QA Contact:
URL:
Whiteboard:
Keywords:
: 27169 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-01-06 07:08 UTC by Peter Clifton
Modified: 2017-07-24 23:08 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
dmidecode output, Dell Latitude E5400 (13.51 KB, text/plain)
2010-02-08 01:49 UTC, Santi
no flags Details
vbios.dump, Dell Latitude E5400 (64.00 KB, text/plain)
2010-02-08 01:53 UTC, Santi
no flags Details
Video BIOS dump, HP 6730b (64.00 KB, application/octet-stream)
2010-02-08 02:02 UTC, Peter Clifton
no flags Details
dmidecode output for HP 6730b (6.60 KB, application/octet-stream)
2010-02-08 02:03 UTC, Peter Clifton
no flags Details
try the patch that uses the bios mechanism to detect TV (2.18 KB, patch)
2010-03-26 02:42 UTC, ykzhao
no flags Details | Splinter Review
the updated patch that Clear the TV sense state bits on cantiga to make TV detection reliable (1.68 KB, patch)
2010-04-06 17:43 UTC, ykzhao
no flags Details | Splinter Review

Description Peter Clifton 2010-01-06 07:08:35 UTC
Chip: 00:02.0 0300: 8086:2a42 (rev 07)
Laptop: HP 6730b (which has an S-Video output)

Symptom:

Running xrandr repeatedly sometimes shows spurious TV modes detected:

> ---------------------------
> TV1 disconnected (normal left inverted right x axis y axis)
> ---------------------------
> TV1 connected 1360x768+1680+0 (normal left inverted right x axis y
> axis) 0mm x 0mm
>    1360x768       59.8* 
>    1152x864       60.0  
>    1024x768       60.0  
>    800x600        60.3  
>    640x480        59.9  
> ---------------------------
> TV1 connected 848x480+1680+0 (normal left inverted right x axis y
> axis) 0mm x 0mm
>    848x480        30.0*+
>    640x480        30.0 +
>    1024x768       30.0  
>    800x600        30.0  
> ---------------------------
> TV1 disconnected (normal left inverted right x axis y axis)
>   848x480 (0x12d)   14.5MHz
>         h: width   848 start  849 end  912 total  944 skew    0
> clock   15.4KHz v: height  480 start  481 end  512 total
> 513           clock   30.0Hz ---------------------------

This causes various effects, including occasional low-res at the GDM screen, wide virtual desktop - where the cursor goes onto the falsely detected TV-out.

Because the detections are spurious, and each probe can give a positive or negative result, this also hightlighted a bug in libdrm / the kernel ioctl interface it uses which means when the mode list changes _during_ a probe, it can cause a crash in the Xorg 2D driver.
Comment 1 Peter Clifton 2010-01-06 07:09:39 UTC
This patch seems to have some effect. (Although it could just be in one
of its "working" moods at the moment. It was flaky just before I
rebooted, and hasn't mis-detected since I applied this patch:

diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index 1d5b9b7..ee92335 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -1391,8 +1391,8 @@ intel_tv_detect_type (struct drm_crtc *crtc, struct intel_
        tv_dac &= ~DAC_A_MASK;
        tv_dac &= ~DAC_B_MASK;
        tv_dac &= ~DAC_C_MASK;
-       tv_dac |= (TVDAC_STATE_CHG_EN |
-                  TVDAC_A_SENSE_CTL |
+       tv_dac &= ~TVDAC_STATE_CHG_EN;
+       tv_dac |= (TVDAC_A_SENSE_CTL |
                   TVDAC_B_SENSE_CTL |
                   TVDAC_C_SENSE_CTL |
                   DAC_CTL_OVERRIDE |

(We aren't using the DAC state change logic for polling based load
detection, so I figured I might try turning it off).

I'm running: "watch -n 0.5 xrandr" as a trigger for the bug. With the
stock driver I get display glitches, and spurious TV-detection now and
again. With the patch applied, I'm not getting that (at the moment!)


I had this hunk applied too, from Zhenyu Wang:

@@ -1840,8 +1840,6 @@ intel_tv_init(struct drm_device *dev)
        drm_connector_attach_property(connector,
                                   dev->mode_config.tv_bottom_margin_property,
                                   tv_priv->margin[TV_MARGIN_BOTTOM]);
-
-       dev_priv->hotplug_supported_mask |= TV_HOTPLUG_INT_STATUS;
 out:
        drm_sysfs_connector_add(connector);
 }

Although on its own, it didn't have any effect. (I've not tried the
former without the latter).
Comment 2 Jesse Barnes 2010-02-05 15:06:11 UTC
Did this patch ever get incorporated?  Zhenyu?
Comment 3 Santi 2010-02-07 16:28:15 UTC
Hello,

  I just wanted to say that the patch in comment#2 solves my bug:

Summary: 	Misdetection of the TV output
http://bugzilla.kernel.org/show_bug.cgi?id=14792

Thanks,
Santi
Comment 4 Wang Zhenyu 2010-02-07 17:17:47 UTC
I don't know much about current TV detect status. 

Yakui, do you have anything like that in your mind?
Comment 5 Peter Clifton 2010-02-07 21:05:42 UTC
One caveat witih this patch.. is that I _have not_ verified that TV-out detection works with it!

I don't have a TV to test on, nor anything which will accept an S-Video connection. Hmm... actually, I might be able to dig out a projector which does.. but I would need to go buy a cable I think!
Comment 6 ykzhao 2010-02-08 00:34:18 UTC
(In reply to comment #5)
> One caveat witih this patch.. is that I _have not_ verified that TV-out
> detection works with it!

It seems that the TV detection logic is disabled completely in the patch. In such case the TV can't be detected.

will you please confirm whether there exists the TV connector plug on your laptop?

Please also attach the output of vbios.dump and dmidecode on your box?

The vbios.dump can be obtained by using the following command:
   1. echo 1 > /sys/devices/pci0000:00/0000:00:02.0/rom
   2. cat /sys/devices/pci0000:00/0000:00:02.0/rom >vbios.dump
   3. echo 0 > /sys/devices/pci0000:00/0000:00:02.0/rom

Thanks.
> 
> I don't have a TV to test on, nor anything which will accept an S-Video
> connection. Hmm... actually, I might be able to dig out a projector which
> does.. but I would need to go buy a cable I think!
> 

Comment 7 ykzhao 2010-02-08 00:34:58 UTC
(In reply to comment #3)
> Hello,
> 
>   I just wanted to say that the patch in comment#2 solves my bug:
> 
> Summary:        Misdetection of the TV output
> http://bugzilla.kernel.org/show_bug.cgi?id=14792
> 
> Thanks,
> Santi
> 

Hi, Santi
    Will you please attach the output of dmidecode, vbios.dump on your box?

thanks.

Comment 8 Peter Clifton 2010-02-08 01:46:46 UTC
I have an S-Video connector on my HP nc6730b.

Do you want the log files from me as well?


Regarding disabling the detect logic - I wasn't sure from the wording of the PRM - it seems a little ambiguous. My intent was is that it disables the state-change interrupt generation logic, not the polling based load detect method.

You'd need to refer to a hardware state-machine or functional diagram to really know what the effect of unsetting TVDAC_STATE_CHG_EN is.

My thought was that it disables the edge triggered logic in the chip, but not the level triggered stuff handled by polling. Of course.. I'm just guessing, as I have no reference materials.
Comment 9 Santi 2010-02-08 01:49:07 UTC
Created attachment 33146 [details]
dmidecode output, Dell Latitude E5400
Comment 10 Santi 2010-02-08 01:53:02 UTC
Created attachment 33147 [details]
vbios.dump, Dell Latitude E5400

Hi,

  here you have the output you requested, I don't have the cable to connect a TV in the TV output, but it is in my shopping list.

Thanks,
Santi
Comment 11 Peter Clifton 2010-02-08 02:02:30 UTC
Created attachment 33148 [details]
Video BIOS dump, HP 6730b
Comment 12 Peter Clifton 2010-02-08 02:03:16 UTC
Created attachment 33149 [details]
dmidecode output for HP 6730b
Comment 13 ykzhao 2010-03-26 02:42:52 UTC
Created attachment 34472 [details] [review]
try the patch that uses the bios mechanism to detect TV

Does anyone have an opportunity to try the attached patch and see whether the TV is still misdetected?

thanks.
Comment 14 Felix 2010-04-06 08:37:06 UTC
Hi,
I had the same issue on my HP 6530b with Intel 4500MHD graphics card. Using the patch from https://bugzilla.kernel.org/show_bug.cgi?id=14792#c22 worked great for me. Tested with 2.6.33.2 vanilla kernel on Arch Linux x86_64. Beside removing the misdetection issue TV out works if a TV is plugged in. Thanks for that!
Comment 15 ykzhao 2010-04-06 17:43:22 UTC
Created attachment 34740 [details] [review]
the updated patch that Clear the TV sense state bits on cantiga to make TV detection reliable

Hi, Flex
    Thanks for the testing. It is good news that the misdetection issue is fixed.
    
    Can you try the updated patch and see whether it works for you?

Thanks.
Comment 16 Felix 2010-04-08 13:19:50 UTC
Hi,

I tested the patch and it works good. Tested with TV connected on boot, TV connect after boot and TV disconnected. Again vanilla kernel 2.6.33.2.

One little resolution "problem" was noticed. If "video=1440x900@60" is not appended to kernel line and TV is connected, the console framebuffer does not fit the laptop display (too small). Having the appendix my console fits the whole screen and TV dimension is adapted accordingly.

I did not check this with the last patch since I always had "video=1440x900@60" as default option to my kernel line.
Comment 17 ykzhao 2010-04-08 17:17:52 UTC
(In reply to comment #16)
> Hi,
> 
> I tested the patch and it works good. Tested with TV connected on boot, TV
> connect after boot and TV disconnected. Again vanilla kernel 2.6.33.2.

Thanks for your testing. Appreciate your efforts.

> 
> One little resolution "problem" was noticed. If "video=1440x900@60" is not
> appended to kernel line and TV is connected, the console framebuffer does not
> fit the laptop display (too small). Having the appendix my console fits the
> whole screen and TV dimension is adapted accordingly.

When the TV is connected, it will select the common mode for LVDS and TV if there is no boot option of "video=1440x900@60". After the boot option of "video=1440x900@60" is added, the 1440x900 is used as the common mode for TV/LVDS. In such case it can fit the laptop display very well.

Thanks again.

> 
> I did not check this with the last patch since I always had "video=1440x900@60"
> as default option to my kernel line.
Comment 18 ykzhao 2010-04-11 01:06:26 UTC
Now the following commit is already shipped and this bug will be marked as resolved. 

commit fb8b5a39b6310379d7b54c0c7113703a8eaf4a57
Author: Zhao Yakui <yakui.zhao@intel.com>
Date:   Wed Apr 7 17:11:19 2010 +0800
 
    drm/i915: Configure the TV sense state correctly on GM45 to make TV detection reliable

Thanks.
Comment 19 Daniel Vetter 2012-03-25 13:52:12 UTC
Patch actually got reverted.
Comment 20 Daniel Vetter 2012-03-27 07:04:11 UTC
*** Bug 27169 has been marked as a duplicate of this bug. ***
Comment 21 Daniel Vetter 2012-03-27 07:05:13 UTC
Patch is on track to get merged into 3.5, already included in drm-intel-next-queued as

commit e7e58eb5c0d1d7d1a42fcb2b5a247d28ec08b47e
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Sun Mar 25 19:47:43 2012 +0200

    drm/i915: mark pwrite/pread slowpaths with unlikely
Comment 22 Daniel Vetter 2012-03-27 07:08:41 UTC
Meh, pasted wrong patch, this one is the right one:

commit d42c9e2c24f7e7897405b85816bdf4ac924881c0                                                                                      
Author: Daniel Vetter <daniel.vetter@ffwll.ch>                                                                                       
Date:   Sun Mar 25 22:56:14 2012 +0200                                                                                               
                                                                                                                                     
    drm/i915: reinstate GM45 TV detection fix


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.