Bug 42727

Summary: radeon KMS with CRT TV
Product: Drivers Reporter: Aur (aprovin)
Component: Video(DRI - non Intel)Assignee: drivers_video-dri
Status: NEW ---    
Severity: normal CC: alexdeucher, egorov_egor, szg00000
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.2 Subsystem:
Regression: No Bisected commit-id:
Attachments: dmesg
dmesg with drm.debug=5
xrandr --verbose
without kms
with kms
rv570.kms.s-video-turn_off
rv570.kms.s-video-turn_on
rv570.ums.s-video-turn_off
rv570.ums.s-video-turn_on
possible fix
vbios.rom
testing patch
dmesg
KMS-radeonreg-connected-activated
KMS-radeonreg-just-connected
KMS-xrandr1-notv
KMS-xrandr2-tv-connected
KMS-xrandr3-tv-activated
UMS-radeonreg-just-connected
UMS-xrandr1-notv
UMS-xrandr2-tv-connected
dmesg-patch-noX
dmesg-patch-withX
kms-radeonreg-noX
ums-radeonreg-noX
vbios.rom
working.regs

Description Aur 2012-02-04 12:06:14 UTC
Created attachment 72278 [details]
dmesg

Hi,

KMS with radeon driver doesn't work properly using the svideo output connected to a CRT TV.

See startup with and without KMS :
http://aprovin.linux62.org/others/forums/kms/startup_with_kms.mp4
http://aprovin.linux62.org/others/forums/kms/startup_without_kms.mp4

I tested with 3.2, 3.1, 2.6.39, 2.6.32 kernels. The bug is present.

Because of this bug, it's impossible to use a X session (color and resolution corrupted).

I built a custom kernel (3.2.2) with debug flags enabled for radeon driver. See the dmesg.

If you need others informations or I test a patch, I'll do it with pleasure.

Regards,

Aurélien PROVIN
Comment 1 Aur 2012-02-04 12:25:00 UTC
My video card is an 'ATI Technologies Inc RV516 [Radeon X1300/X1550 Series]'
Comment 2 Aur 2012-02-04 12:37:52 UTC
Created attachment 72279 [details]
dmesg with drm.debug=5
Comment 3 Michel Dänzer 2012-02-09 09:13:35 UTC
Looks like the radeon driver uses NTSC output by default, can the TV handle that?
Comment 4 Aur 2012-02-09 17:48:16 UTC
I don't know if this TV supports NTSC but it supports PAL and SECAM.

Is it possible to force driver to use PAL by a kernel option or by a patch ?
Comment 5 Alex Deucher 2012-02-09 18:29:24 UTC
xrandr --output S-video --set "tv standard" pal
use xrandr --verbose to double check the output and attribute name for your board.
Comment 6 Aur 2012-02-21 16:37:01 UTC
Created attachment 72458 [details]
xrandr --verbose

I tried to set pal with xrandr :

http://aprovin.linux62.org/others/forums/kms/startup_xrandr_pal.mp4

01m09s -> to pal
01m21s -> to ntsc
01m27s -> to pal

The display change when PAL is set but it's already unreadable and green ...
Comment 7 Egor Y. Egorov 2012-02-26 14:12:23 UTC
same problem on my system with
VGA compatible controller: ATI Technologies Inc RV570 [Radeon X1950 Pro] (rev 9a)
Comment 8 Aur 2012-02-26 17:41:11 UTC
I can confirm it's not a cable problem or a TV problem (Tested with Windows 7 on the same config : no problem)
Comment 9 Egor Y. Egorov 2012-02-27 02:13:36 UTC
Yes. With Windosw 7 and on linux without KMS all right.
Comment 10 Alex Deucher 2012-02-27 13:54:19 UTC
Please grab radeonreg (http://cgit.freedesktop.org/~airlied/radeontool/) and dump the display registers with KMS and without KMS (as root).

./radeonreg regs avivo > working.regs

and

./radeonreg regs avivo > broken.regs

And attach the outputs here.
Comment 11 Egor Y. Egorov 2012-02-27 14:26:05 UTC
Created attachment 72484 [details]
without kms
Comment 12 Egor Y. Egorov 2012-02-27 14:26:32 UTC
Created attachment 72485 [details]
with kms
Comment 13 Alex Deucher 2012-02-27 15:31:08 UTC
The only difference seems to be which crtc is driving the TV.  Can you try booting with only the DVI port connected, and then connecting the TV later once your desktop is up with both KMS and UMS?
Comment 14 Egor Y. Egorov 2012-02-28 02:10:54 UTC
Well, I'll do it in the evening when I'll be home. Simply plug the TV or turn on the output and adjust the resolution?
Comment 15 Egor Y. Egorov 2012-02-28 12:49:46 UTC
Created attachment 72491 [details]
rv570.kms.s-video-turn_off
Comment 16 Egor Y. Egorov 2012-02-28 12:50:06 UTC
Created attachment 72492 [details]
rv570.kms.s-video-turn_on
Comment 17 Egor Y. Egorov 2012-02-28 12:50:22 UTC
Created attachment 72493 [details]
rv570.ums.s-video-turn_off
Comment 18 Egor Y. Egorov 2012-02-28 12:50:45 UTC
Created attachment 72494 [details]
rv570.ums.s-video-turn_on
Comment 19 Alex Deucher 2012-02-28 15:50:12 UTC
Boot up without the TV attached to the video card, then when your desktop is up, use xrandr to turn on the TV connector and adjust the mode, etc.  Does it work any better or worse in either case (UMS or KMS)?  What exactly did you do to generate the files you attached?
Comment 20 Egor Y. Egorov 2012-02-28 16:29:33 UTC
> Boot up without the TV attached to the video card, then when your desktop is
up, use xrandr to turn on the TV connector and adjust the mode, etc.
Yes. I did exactly. 
I first boot the system with KMS. Plug the TV. Launched
# ./radeonreg regs avivo > rv570.kms.turn_off
Then set up S-video output in systemsetings (kde). Launched
# ./radeonreg regs avivo > rv570.kms.turn_on

In the same way rv570.ums.turn_off and rv570.ums.turn_on are created (UMS).
With UMS all good. With KMS screen TV is striped.
Comment 21 Alex Deucher 2012-02-29 21:04:00 UTC
Created attachment 72501 [details]
possible fix

Does this kernel patch help?
Comment 22 Egor Y. Egorov 2012-03-01 13:39:51 UTC
Unfortunately the patch did not help. Everything remains as before.
Comment 23 Alex Deucher 2012-03-01 14:40:44 UTC
Please attach a copy of your video bios.  

(as root)
(use lspci to get the bus id)
cd /sys/bus/pci/devices/<pci bus id>
echo 1 > rom
cat rom > /tmp/vbios.rom
echo 0 > rom
Comment 24 Egor Y. Egorov 2012-03-01 14:45:15 UTC
Created attachment 72505 [details]
vbios.rom
Comment 25 Alex Deucher 2012-03-01 15:04:05 UTC
What mode are you trying to use on the TV?  Can you attach the output of xrandr --verbose with KMS?
Comment 26 Alex Deucher 2012-03-01 15:53:11 UTC
Created attachment 72506 [details]
testing patch

Does this patch help?
Comment 27 Egor Y. Egorov 2012-03-01 16:13:21 UTC
No, did not help. :(


$ xrandr --verbose
Screen 0: minimum 320 x 200, current 2304 x 1024, maximum 8192 x 8192
DVI-0 connected 1280x1024+0+0 (0x54) normal (normal left inverted right x axis y axis) 337mm x 270mm
        Identifier: 0x51
        Timestamp:  264987
        Subpixel:   horizontal rgb
        Gamma:      1.0:1.0:1.0
        Brightness: 1.0
        Clones:     DVI-1
        CRTC:       0
        CRTCs:      0 1
        Transform:  1.000000 0.000000 0.000000
                    0.000000 1.000000 0.000000
                    0.000000 0.000000 1.000000
                   filter: 
        EDID:
                00ffffffffffff000469b4175b070000
                2f0f010380221b962ac5c8a3574a9c23
                12484cbfee0081800101010101010101
                010101010101302a009851002a403070
                1300510e1100001e000000fd003c4b1e
                410b000a202020202020000000fc0041
                53555320504d313754550a20000000ff
                0035414c373030313838330a2020006f
        load detection: 1 (0x00000001)  range:  (0,1)
        underscan vborder: 0 (0x00000000)       range:  (0,128)
        underscan hborder: 0 (0x00000000)       range:  (0,128)
        underscan:      off
                supported: off          on           auto        
        coherent: 1 (0x00000001)        range:  (0,1)
  1280x1024 (0x54)  108.0MHz +HSync +VSync *current +preferred
        h: width  1280 start 1328 end 1440 total 1688 skew    0 clock   64.0KHz
        v: height 1024 start 1025 end 1028 total 1066           clock   60.0Hz
  1024x768 (0x55)   78.8MHz +HSync +VSync
        h: width  1024 start 1040 end 1136 total 1312 skew    0 clock   60.1KHz                                                                                  
        v: height  768 start  769 end  772 total  800           clock   75.1Hz                                                                                   
  1024x768 (0x56)   75.0MHz -HSync -VSync                                                                                                                        
        h: width  1024 start 1048 end 1184 total 1328 skew    0 clock   56.5KHz                                                                                  
        v: height  768 start  771 end  777 total  806           clock   70.1Hz                                                                                   
  1024x768 (0x57)   65.0MHz -HSync -VSync                                                                                                                        
        h: width  1024 start 1048 end 1184 total 1344 skew    0 clock   48.4KHz                                                                                  
        v: height  768 start  771 end  777 total  806           clock   60.0Hz                                                                                   
  832x624 (0x58)   57.3MHz -HSync -VSync                                                                                                                         
        h: width   832 start  864 end  928 total 1152 skew    0 clock   49.7KHz                                                                                  
        v: height  624 start  625 end  628 total  667           clock   74.6Hz                                                                                   
  800x600 (0x59)   50.0MHz +HSync +VSync                                                                                                                         
        h: width   800 start  856 end  976 total 1040 skew    0 clock   48.1KHz                                                                                  
        v: height  600 start  637 end  643 total  666           clock   72.2Hz                                                                                   
  800x600 (0x5a)   49.5MHz +HSync +VSync                                                                                                                         
        h: width   800 start  816 end  896 total 1056 skew    0 clock   46.9KHz                                                                                  
        v: height  600 start  601 end  604 total  625           clock   75.0Hz                                                                                   
  800x600 (0x5b)   40.0MHz +HSync +VSync                                                                                                                         
        h: width   800 start  840 end  968 total 1056 skew    0 clock   37.9KHz                                                                                  
        v: height  600 start  601 end  605 total  628           clock   60.3Hz
  800x600 (0x5c)   36.0MHz +HSync +VSync
        h: width   800 start  824 end  896 total 1024 skew    0 clock   35.2KHz
        v: height  600 start  601 end  603 total  625           clock   56.2Hz
  640x480 (0x5d)   31.5MHz -HSync -VSync
        h: width   640 start  664 end  704 total  832 skew    0 clock   37.9KHz
        v: height  480 start  489 end  491 total  520           clock   72.8Hz
  640x480 (0x5e)   31.5MHz -HSync -VSync
        h: width   640 start  656 end  720 total  840 skew    0 clock   37.5KHz
        v: height  480 start  481 end  484 total  500           clock   75.0Hz
  640x480 (0x5f)   30.2MHz -HSync -VSync
        h: width   640 start  704 end  768 total  864 skew    0 clock   35.0KHz
        v: height  480 start  483 end  486 total  525           clock   66.7Hz
  640x480 (0x60)   25.2MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock   31.5KHz
        v: height  480 start  490 end  492 total  525           clock   60.0Hz
  720x400 (0x61)   28.3MHz -HSync +VSync
        h: width   720 start  738 end  846 total  900 skew    0 clock   31.5KHz
        v: height  400 start  412 end  414 total  449           clock   70.1Hz
S-video connected 1024x768+1280+0 (0x177) normal (normal left inverted right x axis y axis) 0mm x 0mm
        Identifier: 0x52
        Timestamp:  264987
        Subpixel:   no subpixels
        Gamma:      1.0:1.0:1.0
        Brightness: 1.0
        Clones:    
        CRTC:       1
        CRTCs:      0 1
        Transform:  1.000000 0.000000 0.000000
                    0.000000 1.000000 0.000000
                    0.000000 0.000000 1.000000
                   filter: 
        tv standard:    pal
                supported: ntsc         pal          pal-m        pal-60      
                           ntsc-j       scart-pal    pal-cn       secam       
        load detection: 1 (0x00000001)  range:  (0,1)
  1024x768 (0x177)   63.5MHz -HSync +VSync *current
        h: width  1024 start 1072 end 1176 total 1328 skew    0 clock   47.8KHz
        v: height  768 start  771 end  775 total  798           clock   59.9Hz
  800x600 (0x178)   38.2MHz -HSync +VSync
        h: width   800 start  832 end  912 total 1024 skew    0 clock   37.4KHz
        v: height  600 start  603 end  607 total  624           clock   59.9Hz
  848x480 (0x179)   31.5MHz -HSync +VSync
        h: width   848 start  872 end  952 total 1056 skew    0 clock   29.8KHz
        v: height  480 start  483 end  493 total  500           clock   59.7Hz
  720x480 (0x17a)   26.8MHz -HSync +VSync
        h: width   720 start  744 end  808 total  896 skew    0 clock   29.9KHz
        v: height  480 start  483 end  493 total  500           clock   59.7Hz
  640x480 (0x17b)   23.8MHz -HSync +VSync
        h: width   640 start  664 end  720 total  800 skew    0 clock   29.7KHz
        v: height  480 start  483 end  487 total  500           clock   59.4Hz
DVI-1 disconnected (normal left inverted right x axis y axis)
        Identifier: 0x53
        Timestamp:  264987
        Subpixel:   horizontal rgb
        Clones:     DVI-0
        CRTCs:      0 1
        Transform:  1.000000 0.000000 0.000000
                    0.000000 1.000000 0.000000
                    0.000000 0.000000 1.000000
                   filter: 
        load detection: 1 (0x00000001)  range:  (0,1)
        underscan vborder: 0 (0x00000000)       range:  (0,128)
        underscan hborder: 0 (0x00000000)       range:  (0,128)
        underscan:      off
                supported: off          on           auto        
        coherent: 1 (0x00000001)        range:  (0,1)
Comment 28 Alex Deucher 2012-03-01 16:17:59 UTC
Can you attach the dmesg output with that patch applied?
Comment 29 Alex Deucher 2012-03-01 16:26:05 UTC
For some reason the entire secondary display path is disabled (tv encoder, dac, crtc) with KMS on your system for some reason.  I can't reproduce it here unfortunately. Does the following help?  

./radeonreg regset 0x000004f4 0x80000062
./radeonreg regset 0x00005e00 0x00000001
./radeonreg regset 0x00006810 0x00000000
./radeonreg regset 0x00006830 0x00000000
./radeonreg regset 0x00006880 0x00010101
./radeonreg regset 0x00006884 0x00000000
./radeonreg regset 0x00007a00 0x00000001
Comment 30 Egor Y. Egorov 2012-03-02 13:34:22 UTC
Created attachment 72515 [details]
dmesg
Comment 31 Egor Y. Egorov 2012-03-02 13:35:40 UTC
I run

# ./radeonreg regset 0x000004f4 0x80000062
OLD: 0x000004f4 (04f4)  0x80000062 (-2147483550)
NEW: 0x000004f4 (04f4)  0x80000062 (-2147483550)
EGOROV radeontool # ./radeonreg regset 0x00005e00 0x00000001
OLD: 0x00005e00 (5e00)  0x00000001 (1)
NEW: 0x00005e00 (5e00)  0x00000001 (1)
EGOROV radeontool # ./radeonreg regset 0x00006810 0x00000000
OLD: 0x00006810 (6810)  0x00000000 (0)
NEW: 0x00006810 (6810)  0x00000000 (0)
EGOROV radeontool # ./radeonreg regset 0x00006830 0x00000000
OLD: 0x00006830 (6830)  0x00000000 (0)
NEW: 0x00006830 (6830)  0x00000000 (0)
EGOROV radeontool # ./radeonreg regset 0x00006880 0x00010101
OLD: 0x00006880 (6880)  0x00010101 (65793)
NEW: 0x00006880 (6880)  0x00010101 (65793)
EGOROV radeontool # ./radeonreg regset 0x00006884 0x00000000
OLD: 0x00006884 (6884)  0x00000000 (0)
NEW: 0x00006884 (6884)  0x00000000 (0)
EGOROV radeontool # ./radeonreg regset 0x00007a00 0x00000001
OLD: 0x00007a00 (7a00)  0x00000001 (1)
NEW: 0x00007a00 (7a00)  0x00000001 (1)
EGOROV radeontool # 

but everything remains as before
Comment 32 Aur 2012-03-03 10:03:13 UTC
I'm back. I'm sorry for the delay...

I started computer with only DVI connected with KMS enabled.
-> xrandr --verbose (KMS-xrandr1-notv)
I connected the S-video cable
-> xrandr --verbose (KMS-xrandr2-tv-connected)
-> ./radeonreg regs avivo (KMS-radeonreg-just-connected)
-> xrandr --output S-video --auto
-> xrandr --verbose (KMS-xrandr3-tv-activated)
-> ./radeonreg regs avivo (KMS-radeonreg-connected-activated)

I started computer with only DVI connected with KMS disabled.
-> xrandr --verbose (UMS-xrandr1-notv)
I connected the S-video cable
-> xrandr --verbose (UMS-xrandr2-tv-connected)
=> TV not detected
-> ./radeonreg regs avivo (UMS-radeonreg-just-connected)

I also add ./radeonreg regs avivo without X session :
kms-radeonreg-noX
ums-radeonreg-noX

There is no change with your patch :
- dmesg (dmesg-patch-noX)
- dmesg (dmesg-patch-withX)

I also attach vbios.rom
Comment 33 Aur 2012-03-03 10:04:12 UTC
Created attachment 72517 [details]
KMS-radeonreg-connected-activated
Comment 34 Aur 2012-03-03 10:04:49 UTC
Created attachment 72518 [details]
KMS-radeonreg-just-connected
Comment 35 Aur 2012-03-03 10:05:17 UTC
Created attachment 72519 [details]
KMS-xrandr1-notv
Comment 36 Aur 2012-03-03 10:05:37 UTC
Created attachment 72520 [details]
KMS-xrandr2-tv-connected
Comment 37 Aur 2012-03-03 10:06:36 UTC
Created attachment 72521 [details]
KMS-xrandr3-tv-activated
Comment 38 Aur 2012-03-03 10:07:01 UTC
Created attachment 72522 [details]
UMS-radeonreg-just-connected
Comment 39 Aur 2012-03-03 10:07:20 UTC
Created attachment 72524 [details]
UMS-xrandr1-notv
Comment 40 Aur 2012-03-03 10:07:37 UTC
Created attachment 72525 [details]
UMS-xrandr2-tv-connected
Comment 41 Aur 2012-03-03 10:08:14 UTC
Created attachment 72526 [details]
dmesg-patch-noX
Comment 42 Aur 2012-03-03 10:08:33 UTC
Created attachment 72527 [details]
dmesg-patch-withX
Comment 43 Aur 2012-03-03 10:09:39 UTC
Created attachment 72529 [details]
kms-radeonreg-noX
Comment 44 Aur 2012-03-03 10:10:02 UTC
Created attachment 72530 [details]
ums-radeonreg-noX
Comment 45 Aur 2012-03-03 10:10:19 UTC
Created attachment 72531 [details]
vbios.rom
Comment 46 Egor Y. Egorov 2012-04-01 04:52:22 UTC
Alex, where can I read the description of the registers for the rv570?
Comment 47 Alex Deucher 2012-04-01 13:03:20 UTC
See the documents linked from the bottom of this page:
http://wiki.x.org/wiki/RadeonFeature
See the M56 and rs690 pdfs.
Comment 48 Egor Y. Egorov 2012-04-01 15:29:06 UTC
Thanks.
Comment 49 Egor Y. Egorov 2012-05-29 04:34:05 UTC
Created attachment 73452 [details]
working.regs

Alex, I have news. Today I ran the system with the KMS enabled and then sent the computer into standby mode. After leaving the sleep mode on the TV image was fine. In the file contents of the registers. I hope this will help in solving the problem. Thank you.