Saturday, May 01, 2010

mythtv on both TV and 720p projector with nouveau

I just finished installing my mythtv (mythbuntu) box to lucid. The upgrade went well enough, although X wasn't working well afterwards. No problem, since I really wanted to switch from the proprietary nvidia drivers to the nouveau drivers anyway.


I have both a (SD)TV and an HD projector connected to my nvidia FX 5200, the former via S-Video, and the latter via an hdmi cable plugged into a DVI-to-hdmi adapter. With the "nv" or "nvidia" drivers, xrandr only sees the projector if both are plugged in, although it sees the TV if the projector is unplugged. So, I've been restarting X when I want to use the projector, which is a pain. With the nouveau drivers in lucid, though, xrandr now shows all three connections at boot time:



grant@mythbuntu:~$ xrandr -q
Screen 0: minimum 320 x 200, current 720 x 480, maximum 4096 x 4096
VGA-1 disconnected (normal left inverted right x axis y axis)
TV-1 connected 720x480+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
720x480 59.9*+
1024x768 59.9
800x600 59.9
720x576 59.9
640x480 59.9
400x300 119.9
320x240 119.9
320x200 119.9
DVI-D-1 connected (normal left inverted right x axis y axis)
1280x720 60.0 + 60.0 50.0
1280x1024 60.0
1024x768 60.0
800x600 60.3
720x576 50.0
720x480 59.9
640x480 60.0

Awesome!



Unfortunately, the TV output was showing up in black and white. Oops. Looking at the output from xrandr --verbose, I realized that nouveau was assuming the TV out should be PAL instead of NTSC-M. After a great deal of searching, I completely failed to find any document that would tell me how to fix that problem for nouveau, since I couldn't find the magic incantation for xrandr that actually worked, and the old standby of Option "TVStandard" "NTSC-M" in xorg.conf just lead to (WW) NOUVEAU(0): Option "TVStandard" is not used showing up in Xorg.0.log. Sigh.



When all else fails, ask on IRC. So I asked about it in #nouveau on freenode. It turns out that what I needed was to have nouveau.tv_norm=NTSC-M in the kernel boot line, because it's the kernel that does the detection. Oh. Works, though. (Incidentally, the list of settable parameters may be found from modinfo nouveau.)


Now my TV is in color, and xrandr may be used to set which output device I want to use with no plugging/unplugging involved. There's a bit of a catch, though, since the aspect ratios and screen sizes are different between the two displays. If I have mythfrontend filling the screen on the TV, then cloning that display on the HD projector leaves a bit of unused real estate. I don't really want to use both screens at the same time, though, so I wrote a couple simple scripts and connected them to "Switch to TV" and "Switch to Projector" buttons that I added to the mythtv main menu:




grant@mythbuntu:~$ cat bin/tv.sh
#!/bin/bash

export DISPLAY=:0
xrandr --output DVI-D-1 --off
killall mythfrontend.real
xrandr --output TV-1 --auto
nohup mythfrontend &

along with



grant@mythbuntu:~$ cat bin/projector.sh
#!/bin/bash

export DISPLAY=:0
xrandr --output TV-1 --off
killall mythfrontend.real
xrandr --output DVI-D-1 --auto
nohup mythfrontend &


Now I just have to get two minor bugs worked out. The first is the fact that putting the GRUB_CMDLINE_LINUX="nouveau.tv_norm=NTSC-M kernel line in /etc/grub.d/40_custom and running update-grub doesn't seem to actually append that string to the kernel boot line. That's annoying, but fixing it in /etc/default/grub does work, and I'll just have to remember to update that when grub is updated. The other bug is that now mythfrontend crashes when I put a DVD in the drive. A mythtv box makes for a great upscaling DVD player, or at least it would if QT wouldn't segfault. All in all, not too bad a set of problems.

Label Cloud