Rainbow Scenery
Valid HTML 4.01 Transitional

CompuLab Fit-PC3
Software Setup (Iris)

Jim Carter, 2014-02-18

Contents

Migrating from Aurora

As much as possible, I tried to copy the working configurations from Aurora onto Iris. Here is a laundry list of software subsystems that had to be dealt with.

Users' home directories

Specifically the watchtv user. [Done.] Plus the /home/video directory with saved media files. These were copied in bulk using rsync, and for the final cutover they were synced again, which went very quickly because there were few changes since the bulk copy.

X-Windows configuration

Issues here:

Sound Issues:

Infrared Remote Control

Infrared does not work out of the box. See my writeup on setting up the remote control.

MySQL Database for MythTV

Server is running. But that's just the beginning.

MythTV startup and housekeeping scripts

Available but not enabled, pending MythTV setup.

Cronj

For putting the machine to sleep. Works, with either suspend style (mem or disk).

Suspending to RAM or Disc

First testing with no DVB (TV capture) devices. You do not need s2ram --force; this chipset is listed in the quirks database. With rtcwake -v -m mem -s 10 it suspended to RAM and resumed 20 times with no errors, and the display was functional afterward. Suspending is nearly instant and waking takes about 2 seconds. Suspending to disc with a similar command, it succeeded 5 times with no errors and a functional display. It takes about 30 seconds to wake, and 8 seconds from executing the command to power off.

Now what happens with the DVB device? Testing with the Hauppauge HTC-950q, but the HTC-1950 behaves similarly on Aurora and likely will be similar on Iris. If you execute s2ram it goes through the whole procedure, then stays shut down for about 130 usec and wakes up again. Hiss, boo! DVB is functional afterward. On Aurora it's necessary to unload 14 modules in a specific order, and reload them in a different order (not the reverse of unloading), to get it to suspend to RAM, and even then the DVB locks up too frequently. I'm going to use suspend to disc, at least for now.

If you execute s2disk -r /dev/sda2 (not unloading any modules) it suspends, taking about 8 seconds, and it takes about 40 secs to wake. Likely the HTC-950q takes about 10 secs extra due to uploading firmware, which is ridiculously slow and has to be re-done every time you open the device. The DVB is functional afterward. This is the mode I'm going to use, despite the extra time versus RAM to sleep and wake. You need to specify the resume (swap) device with -r because it seems unable to find it by itself.

The suspend style, module unload list, etc. are configured in /etc/sysconfig/suspend which is read by /usr/diklo/sbin/susp2ram which is called by /usr/diklo/sbin/cronj.sleep . Mythbackend is supposed to call ~watchtv/bin/waketime2 %H %M to set the wakeup time (by depositing an at job at that time), and waketime2 -s to actually go to sleep (by writing a CronWake request to doze). Cronj handles the details by calling cronj.sleep.

DVB Tester

It is surprisingly hard to determine whether the DVB (TV capture device) is functional. Here are the steps I went through:

Webserver features:

backup.pln files.

Copied, except I missed /usr/share and hence backed up a zillion bytes of crap. Fixed.

Graphics Processor Struggles

Which graphics driver am I going to use? This is a comparison of radeon vs. fglrx. Note: fglrx was not actually tested on the fit-PC3 Pro; results (such as they are) come from the Zotac Zbox with Radeon HD 6310. The radeonhd driver was excluded because it does not support the HD 6320 GPU. It is also deprecated. Lines with a pair of percentages show the CPU utilization on each of 2 cores (100% - idle fraction).

  radeon fglrx
Political Status Open Source Proprietary
Supports AMD HD 6320 Yes Yes
KMS (Kernel Mode Setting) Required Forbidden
2D Graphics Perfect Perfect
glxgears 3% + 4% Perfect
mesademo fire 25% + 10% Perfect 157 fps
Play Theora (CPU utilization on each core) 45% + 38% 25% + 25%
Play MPEG-2 64% + 58% 12% + 12%
Play MPEG-4 55% + 45% 6% + 6%
HDMI audio Works Works
Suspend to RAM 20x OK N.T.
Suspend to disc 5x OK N.T.

Notes for MPEG-2 and MPEG-4 playback:

With this chipset the open source Radeon driver is functional for video playback, although I think it is not using hardware rendering, or is not using very much hardware acceleration, compared to fglrx on the less powerful Zbox. But compiling and installing the ATI proprietary module fglrx is always traumatic and messy. I'm going to stick with the Radeon driver. MythTV has a VDPAU interface and it may do better than these tests.

Sound Issues

ALSA sound is the most frustrating of all Linux subsystems due to arcane configuration and fungoid evolution of the design. Here's what I did t get ALSA sound under control.

First, on this system there are three sound devices.

The normal default audio device of hw:0,0 exists only rarely. Numerically based card assignments are subject to change without notice. This situation of course is unacceptable for daily use. The goal at this point is to specify the three sound devices using keys that are unique and immutable. Here is what I did to bring some sanity to the sound configuration.

If your sound devices are each served by different modules, the easiest way to nail them down is to specify the index parameter of each relevant driver; this parameter determines the card number(s). Following forum postings I tried (unsuccessfully) the following method. Look in /etc/modprobe.d . Files therein have the form: number hyphen basename .conf, e.g. 50-radeon_audio.conf . In this file I put:

options snd_hda_intel index=0,1 
options snd_usb_audio index=2
(Use e.g. modinfo snd_hda_intel to determine which drivers have the index parameter.) These settings were obeyed, and if each driver served only one device this fix would have been sufficient, but I have multiple devices on the Intel driver, so I had to use a different solution. It is possible to specify a model parameter on the Intel driver, but I could not get it to cue on the IDs.

Next, let's look at /proc/asound/cards .

 0 [Generic        ]: HDA-Intel - HD-Audio Generic
                      HD-Audio Generic at 0xfeb44000 irq 44
 1 [SB             ]: HDA-Intel - HDA ATI SB
                      HDA ATI SB at 0xfeb40000 irq 16
 2 [Device         ]: USB-Audio - USB Sound Device
                      C-Media INC. USB Sound Device at usb-0000:06:00.0-2.4, full speed
The integers are the card numbers, determined by the drivers' index parameters, or the order in which their respective driver modules are loaded (if the index is unspecified), which occurs in parallel threads and so is not deterministic. The third column, e.g. USB Sound Device, comes from the idProduct attribute on USB, and I can't find it for PCI. The last whitespace separated word of this attribute gives the value for the id attribute, which appears in the second column of /proc/asound/cards . These values are kind of lame and could easily be non-unique.

If your ID values are not satisfactory, use this solution to set the ID attributes to something consistent and unique, by a udev rule. Do this for each sound device. Pick a device inode associated with each sound device: /dev/snd/controlC2 (substitute each card number) always exists. Now do:

udevadm info --attribute-walk --name=/dev/snd/controlC2
Find its ancestor that has the id attribute, which you're going to change. The output will say something like ATTRS{id}=="Device". Now look for one grand-ancestor with unique attributes, like the vendor and product. Finally you will assign ATTR{id} (singular) (one = for assignment, 2 for comparison). Here are my rules, in /etc/udev/rules.d/26-soundJ.rules .
ATTR{id}=="*" ATTRS{vendor}=="0x1002" ATTRS{device}=="0x4383" ATTR{id}="Azalia"
ATTR{id}=="*" ATTRS{vendor}=="0x1002" ATTRS{device}=="0x1314" ATTR{id}="AMD_HDMI"
ATTR{id}=="*" ATTRS{idVendor}=="0d8c" ATTRS{idProduct}=="0103" ATTR{id}="TurtleBeach"

Explanation:

If you have multiple devices with the same vendor and product codes, you need to find another unique attribute to cue on. Some devices have a serial number. I believe the KERNEL uniquely identifies the port or slot that the device is plugged into, so it will be satisfactory as long as you do not move the device, which can be a problem with USB.

To make this rule effective, remove all the sound driver modules like this:

lsmod | grep ^snd_
modprobe -r -v snd_usb_audio # (pick an unused driver)
modprobe -r -v snd_hda_intel
etc. etc.; repeat from the lsmod step until all are gone.

Then reload the keystone drivers. Instead you might simplify your life by rebooting, just like on Windows. Check your work by inspecting /proc/asound/cards and make sure your ID values are now shown in the second column.

Now that you have useful ID values, you can use them like this. For the user who is going to play the sound, change to its home directory (the value of the HOME environment variable when the sound program executes). For MythTV I have a special user called watchtv. ALSA is configured from these files:

Edit $HOME/.asoundrc . Here is what I use for MythTV. The name ati_hdmi is arbitrary, but avoid sleeping dragons and don't try to replace a system-defined PCM.
pcm.ati_hdmi {
        type    hw
        card    AMD_HDMI
        device  3
}
ctl.ati_hdmi {
        type    hw
        card    AMD_HDMI
}
# The ! is important; without it, ALSA lib gets an error.
pcm.!default    pcm.ati_hdmi

You need to define both the pcm and ctl devices (mixer). While the card is normally specified as an integer, you can give the ID attribute as appearing in /proc/asound/cards . With this default override, the sound generating program will send output over HDMI no matter how the module order is randomized at boot time.

Configuring MythTV

This is what I did to set up MythTV 0.27 from an empty database on Iris-3 (the fit-PC3 Pro). See the initial installation instructions on the MythTV wiki. Skip to post-install tasks.

Various Prerequisites

The database engine should be running, and security setup steps should be done. You need to have done these additional steps.

The installation page (see link above) has the exact command lines to do the database items. You will need to give the password of the root database user, which you set during the security setup.

Running MythTV Programs over SSH

It's a pain to crouch on the carpet in front of the TV and use the keyboard and mouse. Instead, on a desktop machine get a SSH connection to Iris. Authenticate as the MythTV user (for me, watchtv). Then run these commands for the respective setup steps.

mythtv-setup -geometry 640x480-0+3 -O ThemePainter=qt
mythfrontend -w -geometry 640x480-0+3 -O ThemePainter=qt

You can make the window larger if you want. Despite the geometry specification the window will migrate to the upper left corner of the screen. The resulting window is borderless, and the mouse cursor is erratically visible (but usable) when inside; MythTV is designed to be controlled by the keyboard. Don't try to perform video because it's a total slug with no 3D acceleration.

Initial Setup

Run mythtv-setup using the command line above. It creates the file ~/.mythtv/ It wants you to pick your language; en_US is preselected and you can just hit Save. It fails to connect to the database (duh) and asks where it is. You can take all the defaults, i.e. database on localhost, except the user and the password, which likely you will want to customize. Then hit Next.

Finally, settings can vary among hosts and so the frontend's hostname is used to differentiate them. You could use a different identifier, but I didn't. Since my frontend, backend and database engine run on the same host, it's meaningless to wake up the database server, but in a more complex situation this may be useful. Hit Finish.

It started mythtv-setup, but hit a SQL error, referring to a table that did not exist. It went back to the first step, language selection. I killed it. Probably I didn't have to; if I had just gone through the whole process again, it would have picked up.

I started mythtv-setup again. This time it wanted to upgrade the database schema (from 1307 to 1317). Having done this, it was able to start the setup GUI.

MythTV Setup: General

MythTV Setup: Capture Cards

Presently the Hauppauge HTV-950q is connected to Iris. Later I will move over and configure the HTV-1950. On the Capture Cards page, hit New Capture Card. (Not with the mouse; you have to use arrow keys to scroll to it, then press return.) Give it about 10 secs because it has to upload firmware, which is slow.

The program auto-discovers the card(s) and presents them in the first drop-down list. Ours is a DVB-T tuner card, which was auto selected. However, instead of /dev/dvb/adapter0/frontend0 I want to use a symlink that is specific to that card, when there are several. So how do I edit the device name? Click in the DVB Device box. Delete any one letter. This will go very slowly, be very patient. Once you have a nonexistent device specified, you can click and drag to delete all text after /dev/. Now type in the symlink pathname followed by frontend0. In my case: /dev/htv-950q/frontend0. When you type the final 0 there will be a 10 second delay while it opens the device, uploading the firmware for the Nth time.

The defaults will probably be satisfactory for the two timeouts. Now hit Recording Options (another delay, this time for at least 3 minutes). I turned on Open DVB card on demand, so when the machine goes to sleep the backend will not have the card open, which would probably mess it up totally. I also turned off Active EIT Scan, because the card would be used continually, with obvious consequences when putting the machine to sleep. The other items I left at the defaults.

Hit Finish on the two screens in progress. Press Esc to exit from the Capture Cards section.

MythTV Setup: Recording Profiles

I actually did not change anything for the recording profiles.

MythTV Setup: Video Sources

This refers to how and where you are going to get program listing data. Hit New Video Source.

MythTV Setup: Input Connections

Select each of your capture cards in turn. On the resulting page, fill in these items:

In the past I have always done the channel scan, but it takes time and usually misses some of the more obscure channels. I tried Fetch from Listings, but it did not seem to import any channels. You're warned that it takes a long time but it's only about 5 secs. Reverting to Scan: you get the Scan Configuration page.

MythTV Setup: Channel Editor

You don't need to edit channels unless you messed something up.

MythTV Setup: Storage Directories

MythTV doesn't know where you want your video content stored, so you have to tell it. Select the Default group. I didn't mess with separate storage groups for the various categories. On the page that opens, hit Add New Directory. Type the toplevel directory pathname. For me, /video is a symlink to my big disc partition. You could have several directories. Content categories are stored in subdirectories, e.g. /video/tv. Hit Esc on 2 pages to return to the main menu.

MythTV Setup: System Events

You can cause a program to be executed when certain events happen. I've heard of people using this effectively, but I don't have any such programs to run.

MythTV Setup: Finishing Up

At the main menu, hit Esc to escape. It reminds you to download your program guide data. To do this, execute (as the watchtv user) mythfilldatabase. For my channel lineup it took about 2 minutes. Ignore the error that it could not connect to the master backend, which is not yet running.

Mythfrontend Setup

Start the backend and give it a minute to start up. Now start mythfrontend using the command line given earlier. Select the Setup toplevel menu choice. To use the Setup Wizard effectively you need to be executing on the actual TV, so skip that and come back to it later.

Mythfrontend Setup: General

It has a lot of pages. Here is what I set.

Mythfrontend Setup: Appearance

These are the pages for controlling how the display looks:

Mythfrontend Setup: Theme Chooser

We have used the Media Center theme and will continue to do so. It may look dumb, but none of the other themes really attract me either, to make the investment in user training to use a new theme. Pick a theme that matches your display's aspect ration, 16x9 or 4x3. Hit Esc to return to the main menu.

Mythfrontend Setup: Audio

To set up the rest of the items effectively, you need to exit from your remote session and start up the physical console (TV). Crouch on the carpet with your keyboard; some of them need typing file paths.

Audio Output Device: I'm not sure where it's getting its list of ALSA PCMs, but it does the equivalent of aplay -L and the Radeon HDMI PCM that I configured is not in the list. Nonetheless, I tried ALSA:hdmi:CARD=HDMI,DEV=0 and it played the test sound (white noise) on each of the TV's speakers. With DEV=3, which is the expected device from hardware settings, there is no sound.

When on the test page I turned on Use Highest Quality Mode, the sounds had a lot more high frequency energy, but only played on the left speaker, so I turned this off again.

On the next page, leave Use Internal Volume Controls turned on. This lets MythTV control the volume.

Mythfrontend Setup: Video

This has several pages:

Mythfrontend Setup: Video Settings

This is for video files rather than TV programs recorded by MythTV. The first section is also called Videos Settings.

With this setup, MythTV is operating well, as well as it did on Aurora. MythWeb is also doing its job, including streaming delivery of programs to a player (totem) using GStreamer-1.0. The remaining issues are:

Rainbow Scenery