User Tools

Site Tools


unix:debian

Rob's Personal Debian Etch Notes

I keep some reminders to myself here about how I configured Debian on my system to overcome certain hardware issues.

Scroll-Wheel Emulation on my Marble Mouse

It took some doing to get my 4-button, no-scroll-wheel, trackball to work the way I wanted: Holding one button causes movements of the ball to be interpreted as scrolling, and the other 3 to behave as ordinary button on a 3-button mouse.

Scroll-Wheel Emulation on a Logitech Marble Mouse

Tearing on the HDMI screen

My Panasonic TV has a refresh rate of 59.97Hz (1080p) while my LCD monitor is at 60.0Hz. Combining the two screens via Xinerama or TwinView will cause the system to ignore one of the screen Vsync. It would appear that no matter what I tried, I couldn't cause it to ignore the LCD's, it ignored the only one I really cared about.

Solution? Use two X screens (one per monitor).

256 Colour mode for VIM under SCREEN

Unlike some of my colleagues at work, I believe that syntax highlighting and colour in general makes applications more usable and enhances productivity. Furthermore, I think that more colours is better than fewer1).

So I set about working out how to enable 256-colour mode in my terminal (gnome-terminal / PuTTY), terminal manager (GNU screen), and editor (Vim).

Configuring Linux for 256 colour-mode

EPSON Stylus SX400 All-in-one as a scanner

Ubuntu 9.04 detected and supported printing on this USB printer without issue, but scanning was tricker. EPSON support pointed me at http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do which installs a SANE backend that gets all standard scanner apps working.

Also see Scanning for OCR and one-touch archiving of snail-mail.

DVI-to-HDMI Display wouldn't go high-res

I couldn't get my 42“ Toshiba flat panel display (a 1080i TV) to work at native resolutions, the best I got from auto-detection was 768×512@75Hz. The fix?

  1. Make a backup of your /etc/X11/xorg.conf as shown in the previous examples
  2. Open /etc/X11/xorg.conf as shown in the previous examples
  3. Add the following line to your existing “Screen” section:
Option "UseEdidFreqs" "false"

Video playback would lock up X11

/var/log/Xorg.0.log showed that it was the nVidia driver causing problems.

mplayer with verbose output over an SSH session showed it was [xv] that was causing the problem. So I disabled extmod in /etc/X11/xorg.conf and the crashes have stopped. The GUI doesn't look quite the same though, for instance windows cannot have transparency anymore.

Alternatively, just don't use any programs that use [xv], use OpenGL output instead (both VLC and mplayer support this). However, this is quite tricky to do in practice, because you find programs that use [xv] by accidentally locking up your GUI

You can disable [xv] within exmod by adding an “extmod” subsection to your xorg.conf:

Section "Module"
        Load    "bitmap"
        Load    "ddc"
        SubSection "extmod"
                Option "omit XVideo-MotionCompensation"
                Option "omit XVideo"
        EndSubSection
        Load    "freetype"
        Load    "glx"
EndSection

DVD Playback with menus

The mplayer package which comes with Ubuntu 7.10 doesn't seem to support dvdnav: playback. My attempts to compile mplayer from source with dvdnav support have failed, despite having libdvdnav4 and libdvdnav-dev installed correctly and using the mplayer1.0-rc2-with-dvdnav patch. It would appear that the “ogle” package is an alternative media player which supports DVD menus and most special features of DVDs. However it does not have an option to deinterlace the output, and mandates that xv is used to output the video. I am also unable to truly fullscreen it under Ubuntu 7.10's compiz-fusion installation (I get my deskopt menu bars at the top and bottom). Under metacity it doesn't appear to output anything sane, although there is sound. For now I'm sticking to using “mplayer dvd:” to watch DVDs, and just blinding working my way through all the titles on a disc until I get the ones I want. It's a nuisance, but it's not as annoying as interlacing artefacts.

Disabling Screen Blanking

Despite disabling the screen saver, and supposedly telling mplayer to disable the screen saver during playback, my screen kept turning off when I was watching DivX. The solution?

~/.xinitrc

setterm -blank 0 -powersave off -powerdown 0
xset s off

Sweex LC100060 802.11g WiFi USB Dongle

Actually, I've installed rt2x00 now (it's actually called that - the x is part of the name) because rt2570 didn't seem to support WPA-PSK encryption properly… Although I may have just been stupid. The steps are identical, but with rt2570 replaced with rt2x00

Once I worked out what to do, doing it was easy. It was all the mistakes along the way that made it hard.

# m-a == module-assistant
m-a prepare
m-a get rt2570 # This is the USB chipset in many dongle, see http://ralink.rapla.net/
m-a build rt2570

This will show some progress, and then quit to a shell with a line something like this:

Done with /usr/src/rt2570-modules-2.6.18-4-686_1.1.0+cvs20060620-3+2.6.18.dfsg.1-12etch2_i386.deb .

This is important, this is where I was missing the point. All this m-a stuff is just to create a package, you still have to install the package it makes for it to work!

dpkg -i rt2570-modules-2.6.18-4-686_1.1.0+cvs20060620-3+2.6.18.dfsg.1-12etch2_i386.deb

Then removing and reinserting the dongle did the trick!

# dmesg
usb 7-3: USB disconnect, address 9
usb 7-3: new high speed USB device using ehci_hcd and address 10
usb 7-3: configuration #1 chosen from 1 choice
idVendor = 0x148f, idProduct = 0x2570
usbcore: registered new driver rt2570
RT25usb  Driver version 1.0.0

This created a couple of new devices, wlan0 and wmaster0. After making sure the wireless-tools package was installed I had to fiddle with my network interface config until it worked:

/etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth1
auto eth1
iface eth1 inet static
#iface eth1 inet dhcp
address 10.0.0.1
netmask 255.0.0.0
gateway 10.0.0.1


allow-hotplug wlan0
auto wlan0
iface wlan0 inet static
        address 192.168.1.34
        netmask 255.255.255.0
        gateway 192.168.1.1
        wpa-driver wext
        wpa-ssid 24
        wpa-key_mgmt WPA-PSK
        wpa-proto WPA
        wpa-pairwise TKIP
        wpa-psk "very_secret_passphrase"

All I need to do to activate Wifi (and wpa_supplicant etc) is “ifup wlan0”.

Update: I decided to abandon WiFi and bought myself some Homeplugs instead. They worked flawlessly and didn't require any kind of tinkering, a rarity with technology.

SmartD

Explicitly added my harddrives to /etc/smartd.conf:

/dev/sda -a -d sat
/dev/sdb -a -d sat
/dev/sdc -a -d sat
/dev/sdd -a -d sat
/dev/sde -a -d sat
/dev/sdf -a -d sat

RAID

I was trying to setup Linux software-RAID when I discovered one of my new drives was failing! While this was a good test to see how my SATA controller deals with such things2), it was at an inopportune time because I was still building the array, so there was no redundancy in the system yet. On the other hand, I didn't lose any data.

So, in an effort to educate myself and others about all this stuff, I'm going to put up some pretty verbose logs.

First my setup:

CPU Intel Core 2 Duo (1.83GHz)
OS GNU/Linux Debian Etch
Motherboard Abit AB9 Pro
Disk Controller Intel ICH8R component of an Intel 965 Chipset
Disk Type All SATA 3.0 Gbit/s
Disk Model 6x SAMSUNG HD321KJ (“Spinpoint T166”)

I have installed Linux on the first disk (“/dev/sda”) and intended to use the other 5 for in a RAID array (“/dev/sd[b-f]”).

Automatic assembly not happening after an upgrade

After a routine upgrade and a reboot I noticed my RAID had not been mounted… and then realised this was because my RAID device was not assembled: cat /proc/mdstat showed that there were not disks in my current RAID setup. The disks were all present and accounted for though:

meermanr@ikari.robmeerman.co.uk:~
$ sudo mdadm --examine /dev/sd[d-f]
...
/dev/sdf:
          Magic : a92b4efc
        Version : 00.90.00
           UUID : c834fba5:79aa0f9e:bf606b92:b5e8404c
  Creation Time : Thu Jul 19 11:51:47 2007
     Raid Level : raid5
  Used Dev Size : 312571136 (298.09 GiB 320.07 GB)
     Array Size : 937713408 (894.27 GiB 960.22 GB)
   Raid Devices : 4
  Total Devices : 5
Preferred Minor : 0

    Update Time : Sun Aug 17 19:57:10 2008
          State : clean
 Active Devices : 4
Working Devices : 5
 Failed Devices : 0
  Spare Devices : 1
       Checksum : 23d76c3 - correct
         Events : 8544

         Layout : left-symmetric
     Chunk Size : 64K

      Number   Major   Minor   RaidDevice State
this     4       8       80        4      spare   /dev/sdf

   0     0       8       16        0      active sync   /dev/sdb
   1     1       8       32        1      active sync   /dev/sdc
   2     2       8       48        2      active sync   /dev/sdd
   3     3       8       64        3      active sync   /dev/sde
   4     4       8       80        4      spare   /dev/sdf

And I could manually assemble and run the array trivially:

meermanr@ikari.robmeerman.co.uk:~
$ sudo mdadm --assemble --scan

meermanr@ikari.robmeerman.co.uk:~
$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
md0 : active raid5 sdb[0] sdd[2] sdc[1]
      937713408 blocks level 5, 64k chunk, algorithm 2 [4/3] [UUU_]
      
unused devices: <none>

So why doesn't it do this automatically during boot (and before auto-mounting everything in /etc/mtab)?

Short answer: because my RAID-members do not live within partitions.

Because I use the entire disk as a RAID-member, rather than a partition within the disk, udev does not probe the disk for its filesystem type. This in turn means that automatic RAID array assembly is never triggered.

The all-import environment variable ID_FS_TYPE, was absent. The sysfs data on my RAID-member disks looked like this:

meermanr@ikari.robmeerman.co.uk:~
$ sudo udevadm info --query=all --name /dev/sdb
P: /devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sdb
N: sdb
S: disk/by-id/scsi-1ATA_SAMSUNG_HD321KJ_S0MQJ1MP400749
S: disk/by-id/ata-SAMSUNG_HD321KJ_S0MQJ1MP400749
S: disk/by-path/pci-0000:00:1f.2-scsi-1:0:0:0
S: block/8:16
E: ID_VENDOR=ATA
E: ID_MODEL=SAMSUNG_HD321KJ
E: ID_REVISION=CP10
E: ID_SERIAL=1ATA_SAMSUNG_HD321KJ_S0MQJ1MP400749
E: ID_SERIAL_SHORT=ATA_SAMSUNG_HD321KJ_S0MQJ1MP400749
E: ID_TYPE=disk
E: ID_BUS=scsi
E: ID_ATA_COMPAT=SAMSUNG_HD321KJ_S0MQJ1MP400749
E: ID_PATH=pci-0000:00:1f.2-scsi-1:0:0:0

Rather than like this:

meermanr@ikari.robmeerman.co.uk:~
$ sudo udevadm info --query=all --name /dev/sdb
P: /devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sdb
N: sdb
S: disk/by-id/scsi-1ATA_SAMSUNG_HD321KJ_S0MQJ1MP400749
S: disk/by-id/ata-SAMSUNG_HD321KJ_S0MQJ1MP400749
S: disk/by-path/pci-0000:00:1f.2-scsi-1:0:0:0
S: block/8:16
E: ID_VENDOR=ATA
E: ID_MODEL=SAMSUNG_HD321KJ
E: ID_REVISION=CP10
E: ID_SERIAL=1ATA_SAMSUNG_HD321KJ_S0MQJ1MP400749
E: ID_SERIAL_SHORT=ATA_SAMSUNG_HD321KJ_S0MQJ1MP400749
E: ID_TYPE=disk
E: ID_BUS=scsi
E: ID_ATA_COMPAT=SAMSUNG_HD321KJ_S0MQJ1MP400749
E: ID_PATH=pci-0000:00:1f.2-scsi-1:0:0:0
E: ID_FS_USAGE=raid
E: ID_FS_TYPE=linux_raid_member
E: ID_FS_VERSION=0.90.0
E: ID_FS_UUID=c834fba5:79aa0f9e:bf606b92:b5e8404c
E: ID_FS_UUID_ENC=c834fba5:79aa0f9e:bf606b92:b5e8404c
E: ID_FS_LABEL=
E: ID_FS_LABEL_ENC=
E: ID_FS_LABEL_SAFE=

The solution I used to arrive at the correct output, above, was to add a new rule to /etc/udev/rules.d/85-mdadm.rules which is triggered before the usual one:

SUBSYSTEM=="block", ACTION=="add|change", ENV{ID_TYPE}=="disk", IMPORT{program}="vol_id --export      $tempnode"

For completeness here is my complete and working rules file:

# This file causes block devices with Linux RAID (mdadm) signatures to
# automatically cause mdadm to be run.
# See udev(8) for syntax
 
SUBSYSTEM=="block", ACTION=="add|change", ENV{ID_TYPE}=="disk", IMPORT{program}="vol_id --export $tempnode"
SUBSYSTEM=="block", ACTION=="add|change", ENV{ID_FS_TYPE}=="linux_raid*", RUN+="watershed /sbin/mdadm --assemble --scan --no-degraded"

Logs

Should remove / update this section, it's all working now

See S.M.A.R.T. for details on how to interpret the raw attributes.

Disk Description Idle Temperature (C) * Notes
RAIDlogs: SDA 30 Non-RAID, has Linux on it
RAIDlogs: SDB 30 RAID
RAIDlogs: SDC 31 RAID
RAIDlogs: SDD 32 RAID
RAIDlogs: SDE 37 RAID failing
RAIDlogs: SDF 38 RAID refuses to complete a selftest, though no error reported as yet

Mplayer and codecs

I was probably just being stupid, but it seemed to me that mplayer wouldn't play MP3 sound.

I added the following repository to my apt config and “upgraded” mplayer from that:

/etc/apt/sources.list

# Win32 (non-free) codecs for mplayer etc
deb http://www.debian-multimedia.org etch main

I also injected the following into my mplayer configuration:

~/.mplayer/config

# (These settings intended for use under Compiz)
# Specify default video driver (see -vo help for a list).
vo=gl:yuv=2:lscale=2:cscale=2
dr=1    # Enable direct rendering (for codecs that support it)
noslices=1 # Draw entire frames at once
 
fs=1
 
ao=pulse
 
# Use system-managed fonts
fontconfig=1
 
slang=en        # Preferred subtitle language: English
alang=ja,en     # Preferred audio languages: Japanese, then English
 
autosync=30     # The default (0) means that video framerate is dictated by audio
                # rate, which doesn't seem to work well when using "-ao
                # alsa:device=spdif"

Playing DVDs

Ubuntu doesn't come with libdvdcss as a package, so you need to install it manually like so:

sudo /usr/share/doc/libdvdread3/install-css.sh

(Taken from https://help.ubuntu.com/community/RestrictedFormats/PlayingDVDs)

General unreliability of GUI

I have stability issues which I've yet to track down.

Update: Stability issues were due to a BIOS bug, which was provoked by the GUI it would seem.

Desktop Effects

I used the following guide: How to: Enable compiz-fusion in Ubuntu Fiesty

Removing the ubuntu-desktop and desktop-effects packages (as outlined in the guide) caused broken packages for me - I recommend running your favourite package manager after performing that step to fix anything that's wrong before installing any of the new compiz packages.

And here is a snapshot of my config, exported from the CompizConfig Settings Manager: robm_compiz_pref.profile

Audio

No sound when using my custom kernel. Had to reinstall using the instructions from here:

cd /usr/src
sudo module-assistant update
sudo module-assistant prepare
sudo module-assistant auto-install alsa
sudo shutdown -r now

But that spewed out a lot of errors about cannot find Makefile_32 or compile assembly stuff. This was because my custom-headers were missing these extra Makefile for some reason.

A post in the Debian forum here had the solution:

cd /usr/src/linux-headers-2.6.24-custom1/arch/x86
ln /usr/src/linux-headers-2.6.24-1-common/arch/x86/Makefile_32 Makefile_32
ln /usr/src/linux-headers-2.6.24-1-common/arch/x86/Makefile_32.cpu Makefile_32.cpu
 
cd /usr/src/linux-headers-2.6.24-custom1/include
rm asm
ln -s asm-x86 asm

Followed by a retry of the original instructions and all worked!

Mix all audio sources (PulseAudio)

Using the instructions here I was able to get Flash and others to use PulseAudio and therefore share the sound-card properly. No more Flash stealing all audio until I kill Firefox!

Audio over S/PDIF (aka IEC958, "Optical", "TOS Link")

Followed HDA-Intel guide at https://help.ubuntu.com/community/HdaIntelSoundHowto, and it worked.

Make sure digital-out is enabled!

Most guides tell you to use alsamixer to enable IEC958. If you have PulseAudio setup you may only get controls for that, and nothing hardware specific.

alsamixer
┌──────────────────[AlsaMixer v1.0.17 (Press Escape to quit)]──────────────────┐
│ Card: PulseAudio                                                             │
│ Chip: PulseAudio                                                             │
│ View: [Playback] Capture  All                                                │
│ Item: Master                                                                 │
│                                                                              │
│                                     ┌──┐                                     │
│                                     │▒▒│                                     │
│                                     │▒▒│                                     │
│                                     │▒▒│                                     │
│                                     │▒▒│                                     │
│                                     │▒▒│                                     │
│                                     │▒▒│                                     │
│                                     │▒▒│                                     │
│                                     │▒▒│                                     │
│                                     │▒▒│                                     │
│                                     │▒▒│                                     │
│                                     │▒▒│                                     │
│                                     ├──┤                                     │
│                                     │OO│                                     │
│                                     └──┘                                     │
│                                   100<>100                                   │
│                                  < Master >                                  │
└──────────────────────────────────────────────────────────────────────────────┘

In my case I simply had to specify which card I wanted to control:

alsamixer -c 0
┌──────────────────[AlsaMixer v1.0.17 (Press Escape to quit)]──────────────────┐
│ Card: HDA Intel                                                              │
│ Chip: Realtek ALC882                                                         │
│ View: [Playback] Capture  All                                                │
│ Item: IEC958 Default PCM                                                     │
│                                                                              │
│    ┌──┐     ┌──┐      ┌──┐     ┌──┐     ┌──┐      ┌──┐                       │
│    │  │     │  │      │▒▒│     │▒▒│     │▒▒│      │  │                       │
│    │  │     │  │      │▒▒│     │▒▒│     │▒▒│      │  │                       │
<    │  │     │  │      │▒▒│     │▒▒│     │▒▒│      │  │                       │
<    │  │     │  │      │▒▒│     │▒▒│     │▒▒│      │▒▒│                       │
<    │  │     │  │      │▒▒│     │▒▒│     │▒▒│      │▒▒│                       │
<    │  │     │  │      │▒▒│     │▒▒│     │▒▒│      │▒▒│                       │
<    │  │     │  │      │▒▒│     │▒▒│     │▒▒│      │▒▒│                       │
<    │  │     │  │      │▒▒│     │▒▒│     │▒▒│      │▒▒│                       │
│    │  │     │  │      │▒▒│     │▒▒│     │▒▒│      │▒▒│                       │
│    │  │     │  │      │▒▒│     │▒▒│     │▒▒│      │▒▒│                       │
│    │  │     │  │      │▒▒│     │▒▒│     │▒▒│      │▒▒│                       │
│    ├──┤     ├──┤      ├──┤     ├──┤     ├──┤      └──┘     ┌──┐     ┌──┐     │
│    │MM│     │MM│      │OO│     │OO│     │MM│               │OO│     │OO│     │
│    └──┘     └──┘      └──┘     └──┘     └──┘               └──┘     └──┘     │
│      0      0<>0    100<>100 100<>100 100<>100   67<>67                      │
│    LFE      Side      Line      CD      Mic     Mic Boos  IEC958 <IEC958 D>  │
└──────────────────────────────────────────────────────────────────────────────┘

Both IEC958 settings should be green “00”, which mean enabled. There is no volume to speak of, so there's no vertical bar to play with. It's just enabled or disabled, where “muted” (“MM”) means disabled. Press m to toggle muted state.

Getting the System Mixer out over optical too

This one had me stumped for a while. PulseAudio appeared to be working fine - the pavumeter GUI app showed there was plenty of noise in the system; but only on the “front:0” output, which was the headphone jack on the front of my PC; no sound on the digital output!

pavumeter screenshot

So I started the command-line tool pacmd and checked which sinks were available:

meermanr@ikari.robmeerman.co.uk:~
$ pacmd
Welcome to PulseAudio! Use "help" for usage information.
>>> list-sinks 
1 sink(s) available.
  * index: 0
        name: <alsa_output.pci_8086_284b_sound_card_0_alsa_playback_0>
        driver: <modules/module-alsa-sink.c>
        flags: HW_VOLUME_CTRL LATENCY HARDWARE 
        state: RUNNING
        volume: <0: 100% 1: 100%>
        mute: <0>
        latency: <80884 usec>
        monitor source: <0>
        sample spec: <s16le 2ch 44100Hz>
        channel map: <front-left,front-right>
        used by: <1>
        linked by: <1>
        module: <0>
        description: <ALSA PCM on front:0 (ALC882 Analog) via DMA>

Ah, it's the headphone port at the front alright - says so in the description! How do I add a sink for the S/PDIF port? First by checking how this sink was loaded, and trying variations there-of.

>>> list-modules
18 module(s) loaded.
    index: 0
        name: <module-alsa-sink>
        argument: <device_id=0 sink_name=alsa_output.pci_8086_284b_sound_card_0_alsa_playback_0>
        used: -1
        auto unload: no
    index: 1
[... etc ...]

Note that the arguments to the ALSA-sink module refer to the device by ID, and not by it's ALSA name. I found out you can use the names, and therefore say “Load the ALSA-sink module, and connect it to the IEC958 ALSA-device”, thus:

>>> load-module module-alsa-sink device=iec958 sink_name=ALSA

Check it loaded properly, and find what it's description is:

>>> list-sinks
2 sink(s) available.
  * index: 0
        name: <alsa_output.pci_8086_284b_sound_card_0_alsa_playback_0>
        driver: <modules/module-alsa-sink.c>
        flags: HW_VOLUME_CTRL LATENCY HARDWARE 
        state: RUNNING
        volume: <0: 100% 1: 100%>
        mute: <0>
        latency: <80181 usec>
        monitor source: <0>
        sample spec: <s16le 2ch 44100Hz>
        channel map: <front-left,front-right>
        used by: <1>
        linked by: <1>
        module: <0>
        description: <ALSA PCM on front:0 (ALC882 Analog) via DMA>
    index: 1
        name: <ALSA>
        driver: <modules/module-alsa-sink.c>
        flags: LATENCY HARDWARE 
        state: SUSPENDED
        volume: <0: 100% 1: 100%>
        mute: <0>
        latency: <0 usec>
        monitor source: <5>
        sample spec: <s16le 2ch 44100Hz>
        channel map: <front-left,front-right>
        used by: <0>
        linked by: <0>
        module: <19>
        description: <ALSA PCM on iec958 (ALC882 Digital) via DMA>

It's the digital out! Now to test it.

mplayer * -ao pulse

This came out on the headphones only, but that's because the default is still the “front:0” sink. You can move the stream to our new sink without touching the default:

>>> list-sink-inputs
1 sink input(s) available.
    index: 9
        name: <audio stream>
        driver: <pulsecore/protocol-native.c>
        flags: 
        state: RUNNING
        sink: <0> 'alsa_output.pci_8086_284b_sound_card_0_alsa_playback_0'
        volume: <0: 100% 1: 100%>
        mute: <0>
        latency: <500000 usec>
        sample spec: <s16le 2ch 44100Hz>
        channel map: <front-left,front-right>
        resample method: speex-float-1
        module: <4>
        client: <16> 'MPlayer'

>>> move-sink-input 9 1

Which tells me my mplayer test-case is stream 9, and I know from earlier output that my newly-loaded sink-module is index 1. We therefore say move sink-input number 9 to play through sink number 1.

Bingo! Sound through the digital out plays on my amp immediately!

Footnote

I found that my sound didn't work until I ran iecset and put my SPDIF-out port into audio mode:

iecset professional off audio on copyright off original off

DTS / Dolby Digital and mplayer

I use the following when I want mplayer to spit it's audio track straight over the optical link (for decoding by my amp):

mplayer -ao alsa:device=spdif -ac hwac3 <filename>

Notes:

  • This tramples on anything else that might be using IEC958 (S/PDIF) by others means, such as the system mixer. If you're using PulseAudio to do your mixing one of two things happens:
    1. Nothing, because PulseAudio is writing to the IEC958 port already, blocking mplayer
    2. mplayer gets perfect sound, but anything trying to create noise via PulseAudio will hang because mplayer is blocking access. Kill mplayer and un-stick your app (i.e. skip to next track etc)

To mitigate these problems I have a little shell script which will only use this trick for videos which will benefit (i.e. if the video is plain-old-stereo, send it through the system mixer!):

#!/bin/bash -x
for file in "$@"; do
    codec=$(mplayer "$file" -vo null -ao null -frames 0 -identify 2>/dev/null |    grep ID_AUDIO_CODEC= | cut -d = -f 2)
    case $codec in
        "a52")
            mplayer "$file" -ac hwac3 -ao alsa:noblock:device=spdif
            ;;
 
        "dts")
            mplayer "$file" -ac hwdts -ao alsa:noblock:device=spdif
            ;;
 
        *)
            mplayer "$file"
            ;;
    esac
done

Mplayer configuration file: mplayer.conf

Amarok + PulseAudio + Ubuntu 9.10 (Karmic Koala)

The amarok package (v2:2.2.0-0ubuntu2) forgets to install its MP3 decoding engine! Fix it with:

sudo apt-get install libxine1-ffmpeg3)

Webcam

I got a webcamera from Malaysia which appears to be one of those no-name Chinese models. The box claims it is a PCCamera, the drivers install a program written by BIGDOG and the lsusb command in Linux tell me it is a “Z-Star Microelectronics Corp. ZC0301 WebCam”. I think I'll go with the USB descriptor.

This is supported by the linux drivers developed at http://mxhaard.free.fr/index.html. This is an Ubuntu package called gspca-source. Once the package is installed you create and insert the kernel-module like so:

(Taken from /usr/share/doc/gspca-source)
m-a prepare
m-a a-i gspca

Using lsmod you can see that it has been inserted:

$ lsmod | grep gspca
gspca                 608336  0 
videodev               29312  2 zc0301,gspca
usbcore               138632  10 zc0301,gspca,usblp,xpad,usb_storage,usbhid,libusual,ehci_hcd,uhci_hcd

To test the webcam I used camorama (a package).

Update 2009-02-14

Another kernel upgrade and another problem. Upgraded to 2.6.27-11-generic for x86.

This time apps just fail with errors like “Unable to capture image”.

Apparently this is because 2.6.27 includes gspca in the kernel, but doesn't include libv4l1.so.

The workaround is simple, prefix your command with an LD_PRELOAD, e.g.:

LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so camorama

Update 2007-07-28

After a kernel upgrade the webcam stopped working. I saw this in the kernel log:

$ dmesg
...
/build/buildd/linux-ubuntu-modules-2.6.24-2.6.24/debian/build/build-generic/media/gspcav1/gspca_core.c: init isoc: usb_submit_urb(0) ret -28
...

Trying to rebuild with the modula-assistant command failed due to this error:

scripts/Makefile.build:46: *** CFLAGS was changed in "/usr/src/modules/gspca/Makefile". Fix it to use EXTRA_CFLAGS. Stop.

even patching the Makefile didn't help, you get:

/usr/src/modules/gspca/gspca_core.c:2567: error: unknown field ‘hardware’ specified in initialiser

So I downloaded the latest gspca-source tarball and compiled it myself:

$ wget http://mxhaard.free.fr/spca50x/Download/gspcav1-20071224.tar.gz
$ tar zxvf gspcav1-20071224.tar.gz
$ cd gspcav1-20071224
$ make

I tested this via manual insertion:

$ sudo modprobe videodev # Needed by gspca
$ sudo modprobe zc0301 # Driver for my particular camera
$ sudo insmod gspca.ko

Inserted without error, but then repeats this dmesg error:

/home/meermanr/Desktop/gspca/gspcav1-20071224/gspca_core.c: [gspca_set_isoc_ep:945] ISO EndPoint found 0x81 AlternateSet 7
/home/meermanr/Desktop/gspca/gspcav1-20071224/gspca_core.c: init isoc: usb_submit_urb(0) ret -28

some forum threads suggest that this error may mean there is a bandwidth problem on the USB hub in use - it was plugged into a hub on my desk, rather than directly into the PC.

Yup, moving it to a new USB port fixed it. Wonder if there was anything wrong with the module to begin with?!

Useful references

1)
“less” is a comparative term reserved for continuous measurements, and not applicable when used to describe a discrete number of entities as we have here. Thank you Colin for hammering this into me over the years…
2)
as it turns out, it deals gracefully with read errors
unix/debian.txt · Last modified: 2009/12/11 00:36 by robm