Formerly we ran MythTV on a Dell Dimension E510 named Iris. It survived
for four years despite various mishaps including a blown power supply, but
finally a power surge got its motherboard. Therefore we migrated MythTV
to a Dell Inspiron 400 HD
Zino called Aurora. This is documentation
for what it took to get MythTV running on the Zino. Also I planned to
document procedures and settings on Iris, but in the struggle to get it
working and to overcome various hardware failures, this goal got forgotten.
Now I'm getting the basic setup into a web page.
|Model||Inspiron 400 HD |
|Processor||AMD Athlon 6850e |
Neo, dual core 1.8GHz
|Memory||2 x 1Gb, 2Gb total, Dual channel SODIMM DDR2, 800 MHz|
|Chipset||AMD K8 IMC (no ECC)|
|Graphics||ATI Radeon HD 3200 (onboard) (RS780 GPU)|
|Video RAM||256Mb stolen from main memory|
|Audio (analog)||ATI SBx00 |
|Audio (HDMI)||ATI RS780 |
|Hard disc||250Gb, Western Digital WD2500 AAJS-75M0A0|
|Optical disc||DVD+/-RW 8x, TSSTcorp model TS-L633C|
|Wired 802.3 Ethernet||Broadcom BCM57780 Gigabit NIC (tg3 driver)|
|About the Zino||Review by Jimc|
|Dimensions||50 inch / 127 cm; 1280x768 pixels so it says|
|Technology||LCD rear projection|
|Inputs||HDMI, VGA, ATSC, NTSC, QAM-64, component etc.|
|Dimensions||40 inch / 102 cm; 1920x1080 pixels|
|Technology||LCD flat panel, cold cathode lamp|
|Inputs||HDMI, VGA, ATSC, NTSC, QAM-64, component etc.|
|Signal Source||ATSC over the air|
|Locale||USA, Los Angeles|
The actual LCD pixel dimensions of the KDF-E50A10 are hard to determine, but it must be in the general range of 1280x768px, which is the largest mode reported by the EDID for VGA, and for HDMI the EDID reports 1280x720. A mode of 1920x540 (interlaced) is also reported on HDMI, but the Radeon RS780 does not support interlaced modes.
While the HDMI interconnect works fine (image and audio) on the KDL-40EX500, the KDF-E50A10 refuses to perform the HDMI audio no matter what settings I try. Therefore I'm using the VGA connection and the corresponding 3.5mm stereo jack.
TV Settings: On the KDF-E50A10 we're using input 7, PC/VGA. The only non-default setting (under Screen) is Wide Mode = Full #1. Full #2 looks identical with a video mode of 16:10 aspect ratio, but with 4:3 it would stretch X anamorphically (i.e. circles become wide ellipses). Both of these have a margin of about 1cm top and bottom, and 4cm at the sides. Zoom expands to fill the entire physical LCD panel, but the optical alignment makes it overscan, losing about 2cm on each edge.
If you have overscan it is possible to set up MythTV to scale the content to fit in the visible screen; however, this locks MythTV to that screen geometry, which makes trouble when you switch to a different display. The symptom is that on a bigger display the MythTV content occupies only the upper left corner of the screen (possibly with a narrow unoccupied border), while on a smaller display you can only see the upper left quadrant of the content. Change the screen offsets and size back to 0 when switching over to a different display.
The rest of my house machines have OpenSuSE 11.2, but the ATI Radeon HD 3200 (RS780 GPU) is rather new, and neither the radeonhd nor radeon X drivers were performing satisfactorily: no acceleration, or if it would use acceleration it would cause a kernel panic when suspending to RAM. Therefore I did a quick upgrade to version 11.3 with very positive results. Version 11.4 is promised on about 2011-03-12 and I plan to upgrade all hosts soon thereafter.
The upgrade went surprisingly smoothly, not trashing or invalidating my special packages and setup including MythTV and multimedia players.
Tidbit: In /var/lib/mysql/ I find a lot of files with names similar to mysql-bin.999999 . This blog by Vivek Gite dated 2008-12-16 tells what's happening: It's a journal of modifications to the database. You can use it for recovering transactions done after a dump was taken, or for sending transaction results to slave servers, If you don't need the journal, edit /etc/my.cnf like this: Comment out "log_bin", "expire_logs_days", "max_binlog_size". Otherwise, periodically execute the command
PURGE BINARY LOGS BEFORE 'ccyy-mm-dd hh:mm:ss' mysql -u root -p passwd -e "PURGE BINARY..."
I added this to the backup section of /etc/init.d/mysql. MySQL documentation is here.
These unusual features had to be dealt with on Aurora:
On my machine, MythTV and related features run as a special user called watchtv. Its home directory was restored unchanged from the most recent backup.
I'm using a special version of cron called cronj, which can put the machine to sleep and wake at the appropriate time. On a Myth box you don't want cronj (or other such programs) deciding when the machine is idle: tell it to believe only mythbackend.
MythTV imitates a TV, not an industrial or financial workstation computer. Thus it's necessary to get the watchtv user logged in without typing on keyboards. Specifically, I need to specify a particular user, watchtv, whose loginID will be pre-filled in the display manager greeter's login box, and it has to get on without a password.
Finding a useable display manager has been a problem. Formerly I used gdm (Gnome display manager) because it had the needed features, but in SuSE 11.1 gdm got a major rewrite which broke stuff. I don't want to use kdm because this will be the only use of KDE on the machine and I don't want to drag in all the infrastructure. I tried wdm (Wingz display manager) but I had some problems with stability. It turns out that old, obsolete xdm can be made to do the job.
/usr/lib/X11/xdm/libXdmGreet.so is the greeter for xdm. I've hacked it to pre-fill one user (watchtv) in the loginID field. It needs libXaw8.so.8 which is included in xorg-x11-libs 7.4 but not in 7.5. Since I'm lazy I tried to avoid locating the source for the new version and propagating hacks forward. I found that libXdmGreet doesn't actually use the new features in version 8: it's sufficient to symlink it to libXaw7.so.7 and then the code compiled for SuSE 11.2 worked in the 11.3 context.
To let this user on without a password I've also made modifications to my PAM configuration file /etc/pam.d/xdm.
In /etc/X11/xdm I've modified xdm-config and Xresources for the
MythTV greeter role. A script
Bootbox uses xmessage to present
a menu of session types and another one for shutdown and rebooting,
which gdm, kdm and wdm have as part of the native GUI.
These scripts are found in ~watchtv/bin; they must be checked for proper operation.
waketime2 is the script which Mythbackend calls to coordinate with cronj to make the machine sleep and wake. With appropriate arguments it either sets the wake time or signals cronj to suspend the machine to RAM.
preshutdown is run by mythbackend to check if it's OK to shut down the machine. It returns false (1) if any of these are true:
MythTV-start is mentioned in /usr/share/xsessions/mythtv.J.desktop ; its startup steps include:
bright-display forces DPMS on (i.e. the display's lamp). This is for when you log in; the script is cued from a button press on the remote control (see below).
These scripts have been moved elsewhere: mythsqldump (moved to /etc/init.d/mysql), susp2ram and waketime (using the versions from cronj).
These scripts are for setup or debugging: hdhomerun-scan, killfill, start-xephyr, viewdump.
For the ATI Radeon 3200 HD graphics unit, the credible drivers are radeon from xorg-x11-driver-video 7.5 or radeonhd from xorg-x11-driver-video-radeonhd-1.3.0_20100325_f6c9991-1.13.i586 . Current policy is that radeon is the one which receives most development attention, while radeonhd will be maintained as long as it is useful. Much of the 3D acceleration from radeonhd has been merged into radeon.
With the radeonhd driver from xorg-x11-driver-video-radeonhd-1.3.0_20100216_79a0ab2 and xorg-x11 version 7.4, it is necessary to specify on the kernel command line hpet=disable. I'm pretty sure this is required for radeonhd version 1.3.0 and xorg-x11 7.5 also. It is not necessary for the regular radeon driver in xorg-x11 either 7.4 or 7.5. Unfortunately, without the HPET (High Precision Event Timer) the substitute (presumably the Time Stamp Counter) drifts ridiculously, about 2.5 secs per 900 secs, and NTP can't handle this big of an error.
Therefore we're using the radeon driver and
disabling the HPET. (See below about the HPET.)
However, starting between kernel 2.6.31 and 2.6.34, kernel mode setting
(KMS) came in, and there is some conflict between KMS and the radeon driver,
so you need
nomodeset on the kernel command line.
As for /etc/X11/xorg.conf, these are the special features:
Input devices are hotplugged through HAL, which means that they use the evdev driver. There are no explicit InputDevice sections for the keyboard and mouse.
There is one InputDevice section with an identifier, a
void driver, and nothing else. The ServerLayout includes
this one section in the CoreKeyboard and CorePointer roles. This
allows the X-server to start up with no actual input devices.
There are two explicit Monitor sections, which (after fiddling) have
ended up identical except for the ModelName text. They rely on the
EDID of their respective connections (non-identical) for VertRefresh,
HorizSync, PixelClock and mode lines. I believe I could actually omit
them entirely, except for two items. Option "PreferredMode" is
important; without it, 640x480 is picked. You need to specify a mode
here that is actually in the EDID, even if it won't be used; the
server will pick the closest feasible mode. It's also important to lie
about the display dimensions. In the xdm greeter the font size is
given in points, not pixels, and X-Windows scales the font to actually
be that many points high, which is way too small for the big TV screen.
I can either have a special /etc/X11/xdm/Xresources with a bigger
xlogin*greetFace than Serif-14, or I can have a
size. Also, while it's very rare to print on a Myth box, in other
situations it's important to lie to make the display appear to have a
resolution of 96 dots per English inch, or else popular web browsers
put out distorted pages. The resulting Monitor section (minus
commented-out frequency ranges) looks like this:
Section "Monitor" Identifier "Monitor" VendorName "SNY" ModelName "SONY Grand Wega KDF-E50A10 HDMI Input" #DisplaySize 1094 613 mm (16:9), visible screen excluding overscan. #This lie makes it seem like 96dpi DisplaySize 339 203 Option "PreferredMode" "1280x768" EndSection
In the Device section, the monitor sections are tied to the device's outputs through Monitor options; it's OK to list all the outputs plus irrelevant names. Options Audio and DRI are on by default and therefore are omitted. The xorg.conf man page recommends including the PCI bus ID, but since I have only one card and since I copy sections between machines, I haven't done that. In the Screen section, MythTV needs good quality color, so I haven't bothered with 8 and 16 bit visuals. It's convenient to use the same file on both TVs, so I have listed both feasible screen sizes in the Modes statement.
Section "Device" Identifier "Device" VendorName "ATI" BoardName "ATI Radeon HD 3200 (RS780 engine)" Driver "radeon" Screen 0 # These names are used by radeonhd Option "Monitor-DVI-D_1" "Monitor" Option "Monitor-VGA_1" "Monitor" # These names are used by radeon Option "Monitor-HDMI-0" "Monitor" Option "Monitor-VGA-0" "Monitor" EndSection Section "Screen" Identifier "Screen" Device "Device" Monitor "Monitor" DefaultDepth 24 SubSection "Display" Depth 24 Modes "1920x1080" "1280x768" Virtual 3840 1200 EndSubSection EndSection
The ServerLayout section is needed to hook up the null InputDevices. Also the X-server is supposed to be able to pick the Screen and Device sections by itself, but somehow it ignored mine when ServerLayout was absent. So this is what I use. The result is that the two outputs (HDMI and VGA) transmit the same image, which is what I want. Option "Clone" "on" is the default and was not needed explicitly. In principle I could make and manage separate screens or combine them with Xinerama, but that's overkill in this application.
Section "ServerLayout" Identifier "Layout[all]" InputDevice "Null" "CoreKeyboard" InputDevice "Null" "CorePointer" # (auto added) InputDevice "Keyboard" "SendCoreEvents" # (auto added) InputDevice "Mouse" "SendCoreEvents" Screen 0 "Screen" Absolute 0 0 EndSection
See this MythTV wiki page about ACPI wakeup.
You will need a script that mythbackend
can call to set the wake time. (See below for MythTV configuration to
supply its name.) There are three
standard ways to set the wake timer:
Dell's smbios-wakeup-ctl from package smbios-utils-python. However, the Zino has a nonstandard System Management BIOS (probably because it has an AMD chipset) and none of the Dell smbios utilities will touch it.
/usr/sbin/rtcwake from package util-linux is effective. Mythbackend
wants to make separate calls to set the wake time and to shut down
the machine, so you need the option
-m no to not actually
put the machine to sleep. The program wants either
-s secs, where the -t time is the value (in seconds since
the UNIX epoch) that will be in the realtime clock when you want
to wake, and -s gives how many seconds in the future you want to wake.
The latter is probably the better one to use because it is independent
of which timezone (UTC or localtime) you have in the realtime clock,
and possible incorrect settings.
0into this file to clear the timer; the Zino will wake unreliably if this is not done. The absolute time is a decimal integer (ending with newline) giving the value that will be in the realtime clock when you want to wake, typically seconds since the UNIX epoch in whatever timezone. The relative time is a decimal integer prefixed with
+and ending in newline, which is the number of seconds in the future that you want to wake.
However, gotcha! The High Precision Event Timer (HPET) is the best
clocksource on an Intel-type (x86 or x86_64) chipset, but on some motherboards
including the Zino there is a bad interaction between it and the realtime
clock and the wakeup timer; if the HPET is enabled (by Linux) the machine
will not wake. If you have this problem, you need to put
on the kernel command line. First find your Grub boot menu file:
In menu.lst or grub.conf, find the stanza you normally boot from, usually
the first one, and the
kernel command within that. Append
hpet=disable. Reboot; you're now minus the HPET. (Check if your
Network Time Protocol (NTP) daemon is happy; if not, see the fix below.)
Mythbackend needs a separate script that shuts down the machine. I need to do these steps:
Flip to virtual terminal 1. Use
fgcosole to find out
which VT you're on, and in the likely case that it's not 1, do
chvt 1 to flip. When s2ram or s2disk exits you will need
to flip back.
Some services should be stopped during the nap and restarted on waking. You will want to restart the ntp service because an unexpected multi-hour delay could confuse it, and also you will want to sync with the outside time server after a long nap. The LIRC daemon has to be shut down so the LIRC modules can be unloaded.
You need to unload modules with defective power management. The LIRC modules (lirc_mceusb lirc_dev on my machine) are the ones that gave trouble on my system.
Finally you need to put the machine to sleep while negotiating
the minefield of graphics initialization. The Zino with the
Radeon driver needs
s2ram --force --vbe_post; s2disk
had trouble to recognize the resume device by itself (I think it
doesn't like discs identified by label) and it needed
the -r switch:
s2disk -r /dev/sda5.
NTP is not good at handling a clocksource which runs a lot slower or faster than real time. It can handle a rate difference of no more than 500 PPM (5e-4). I have never seen a HPET anywhere near this inaccurate -- but on the Zino you need to disable the HPET, and the fallback clocksource, the ACPI Power Management Timer (acpi_pm), is rather bad: 2.83e-3 on one Zino and 2.4e-3 on another, way beyond what NTP can deal with. ntpd could show one of three behaviors:
It dies after 10 to 15 minutes when it realizes that it can't sync with the time server. Hack your startup script or parameter file to provide the -g switch to ntpd, which will make it keep trying forever.
If you have a local clock configured on IPv4 address 127.127.1.0 (look in /etc/ntp.conf), ntpd will ignore the correct time server and fixate on the inaccurate local clock. The difference between real time and your clock will increase without limit by two or three minutes per day, which plays hob with TV recording schedules.
If you don't have the local clock, ntpd will lose sync
every 10 to 15 minutes and will reset the clock by several seconds.
If you're going to comment it out, put a # before both the
server command and the neighboring
Here is the procedure to deal with a slow clocksource. However, I wonder if acpi_pm is going to have a gross temperature dependence which when summer comes may go beyond NTP's sync range.
ntpq -p to check the health of ntpd. This is what it
will look like after these fixups have been done. Normally you would have
several time servers; I've simplified by showing just one.
remote refid st t when poll reach delay offset jitter ============================================================================== *jacinth.cft.ca. 126.96.36.199 6 u 464 512 377 3.509 -3.081 0.191
The key items here are the offset and jitter, both in milliseconds. If your offset is over 1000 (1 second) and varies erratically (as ntpd resets the time) or increases without limit, you have an excessively inaccurate clocksource. A positive offset means the clock is slow; negative means fast.
Make sure you have the programs /sbin/adjtimex and /sbin/hwclock (both from package util-linux).
Make sure you have /etc/adjtime ; if not, do
hwclock --systohc --utc (or --localtime if needed to dual boot
Windows); this will create that file, which adjtimex wants to read.
Stop the ntp service:
/etc/init.d/ntp stop (or the equivalent on
Ubuntu or Debian). You shouldn't mess with time variables when ntpd is
also struggling with them.
For reference, use
adjtimex -p to print out the current values
of the kernel time variables; make a note of them to compare with your
adjtimex -a. It runs for about 80 seconds, showing the
frequency variables every 10 seconds. And it
installs the values that it has computed.
Remove ntpd's bogus drift file. Look for its name in /etc/ntp.conf, the
driftfile parameter. On a SuSE system it is in
/var/lib/ntp/drift/localhost. This makes ntpd start from the beginning to
determine the clock rate according to the new kernel time variables.
After an hour or so it will save the correct drift rate again.
Now restart ntp:
/etc/init.d/ntp start. ntpd will sync right
away with the time server.
OpenSuSE automatically syncs the clock on startup, but if your distro's init script doesn't do that you really need to make it happen, but beware that if ntpd is running already, sntp will not be able to set the clock. Here is the sntp command line you need. You can fancy this up considerably including checking if ntpd is running and shutting it down as appropriate.
sntp -P no -r $NTP_MASTER(Options:
-P nomeans fix the clock no matter how wrong it is.
-rmeans always set the time stepwise.)
You need to set the
tick value at every reboot. The
frequency variable is not so important because ntpd initializes this
itself from the drift file. In the SuSE 11.3 distro the /etc/init.d/ntp
script has a command option
ntptimeset which pre-syncs the clock.
It should be executed also as part of the start procedure (make sure it's
not commented out; it was on my system). In the ntptimeset section before
it actually syncs the time I added this command (filling in the values
provided by adjtimex -a).
adjtimex --tick 10025 --frequency 3132687
Basically I copied the working LIRC setup from Iris. But LIRC is complicated and I have not properly documented how I have it set up, so I will make up that deficiency now.
I have a Philips eHome remote control (and IR receiver for USB)
which was bought with Microsoft Windows Media Center Edition. It uses
the lirc_mceusb module which depends on lirc_dev which presumably
depends on usbhid (which is hardwired in SuSE's
These driver(s) do not like to suspend to RAM; LIRC doesn't work afterward (doesn't yield any IR pulse data). Unload the modules first, and reload when waking. You will need to stop and start the LIRC daemon so /dev/lirc0 will not be in use when you unload.
lircd is the daemon that reads pulse info from /dev/lirc0 and translates it to button names. It is configured in /etc/lirc/lircd.conf which is copied from /usr/share/lirc/remotes/mceusb/lircd.conf.mceusb (no hacks needed).
I have an additional script called /etc/init.d/lircx.J which starts two daemons: irexec executes programs upon button presses, and irxevent translates button presses to X-Windows keycodes. The configuration file is /etc/lircx.J.conf; it actually works for both daemons.
The POWER button will make the machine shut down (except this seems to not be working and I'm not sure why; the keypress is recognized). The ENTER key runs the program to wake up DPMS (turns on the display's lamp) and also emits a Return keysym, which is what you need to log in, assuming that the loginID is filled in by one's hacked libXdmGreet.so. However, the Return keysym is not delivered. Either the greeter has grabbed the keyboard or my specification is wrong of what window to send it to.
There is a complication: when the watchtv user logs off the X-server is reset, kicking off irexec and irxevent. So a shepherd process restarts them for the next user.
To map button names to Myth keyboard commands you need to create ~watchtv/.lircrc which is copied from /usr/share/doc/packages/mythtv-doc/contrib/configfiles/lircrc.native.example.mceusb2 Hacks required:
For Android: Mythmote. You get a complete remote control. My only complaint is that "fast forward" skips ahead by a fixed delta, not continuously.
I am using MythTV 0.22. The current version is 0.24, but there is enough going on that I wanted to avoid upgrading Myth. This turned out to be feasible. I have these sub-packages: backend, base-themes, common, docs, frontend, setup, mythweb.
Basically I copied the working configuration from Iris backups. This did not result in a working configuration on Aurora.
The backend and frontend both think the master server is still on
Iris, and while there is a configuration for Iris, there is none for Aurora.
My strategy here is to edit (a copy of) the database backup changing the
aurora wherever occurring, and also the IPv4
address. Then reload the database. Note, many rows in the settings table
have a hostname of NULL which means they apply to every host.
In addition the name of the master server occurs in these files which have to be edited: ~watchtv/.mythtv/mysql.txt , ~watchtv/.mythtv/kconfig.xml .
The tuner card on Iris of course could not migrate to Aurora, and
it only does NTSC anyway, so we abandoned it. It is necessary to delete
this capture card. Stop the backend, run mythtv-setup, navigate to capture
cards, arrow keys down to the unwanted card, and press
d to delete it.
As noted previously, the MythTV frontend had been set to place content
in the subset of the screen that was actually visible. This made trouble when
I tried MythTV on different TV displays. Once I cleared the screen size and
offsets to 0, it auto-adapted to the actual screen size. Path to setup page:
Frontend - Setup - Setup - Appearance - Page 2: GUI width, height, XY offset.
Generally you will also want to turn on
Use GUI size for TV playback
(though it doesn't matter if the GUI is at full screen),
Hide mouse cursor
in MythTV, and probably
Use fixed window size.
It is necessary to review the audio device choice. On Iris I had it adjusting and muting the PCM channel, but neither is effective on Aurora. It needs to work on the master. This will be found (in the frontend menus) under Setup - Setup - General - page 4:
With these modifications, I now have a working MythTV on the Zino.
The ENTER key on the remote control is supposed to send an Enter keysym to the greeter, but the keysym doesn't arrive. Perhaps the issue is that the greeter grabs the keyboard and display, isolating itself from evil outside influences while handling passwords.
When you log in, remote control (infrared) commands are not delivered for about 30 seconds, even though mythfrontend opens the lircd socket right away.