Categories
How-To's

Upgrading LIRC to ir-core and imon

While the title may sound a tad cryptic, that matched my first impression about the new infrared remote subsystem used in Ubuntu 10.10 and kernel 2.6.36+ based distributions. In Linux 2.6.36, a new sub-system is introduced for remote controls. This subsystem is a partial replacement for lirc as it features complete IR drivers for numerous devices.

In reality, the glass is only half full as some IR receivers (and transmitters) deal with raw data. Writing universal drivers for such devices can be bothersome or even impossible, for example when dealing with universal receivers. As such, LIRC is not completely written off as it can be used to do userspace IR processing as it used to. The exact details are unknown to me as I have an SoundGraph iMon receiver (device ID 0038 – LCD), which does not deliver raw sensory input but rather complete scancodes.

When I upgraded from Ubuntu 10.04 running lirc 0.8.6 to Ubuntu 10.10 and lirc 0.8.7, the entire IR subsystem died on me. To my surprise, while the remote was dead, the LCD screen was working fine. Further inspection showed that the ‘lirc_imon’ driver was not loaded at all.

With the move to the new input layer driver for supported IR devices in the kernel, the new ‘imon’ driver (version 0.8 at the time of writing) no longer provides a ‘lirc0’ device. As such, lircd will fail when attempting to claim it and loading ‘lirc_imon’ (provided you still have it) will not work as the device is already claimed by the ‘imon’ driver.

The fastest way to get up and running again is as follows. The ‘imon’ receiver will now be a HID input device. I got the impression it would send keystrokes to a graphical application but I didn’t get that working. Instead, we will use ‘lircd’ again using a special driver called ‘devinput’. This driver reads the key strokes from the input layer device and converts them into LIRC events. All your LIRC capable programs will then use LIRC like they used to – we only need to use the new button names.

To find the iMon receiver in the list of input devices, lets create a udev rule to symlink to the device. This way we will not have to rely on obscure device names like ‘input1’. Make sure the device name matches whatever hardware you have. I inserted this rule in a file called /etc/udev/rules.d/99-imon.rules:

KERNEL=="event*", SYSFS{name}=="iMON Remote (15c2:0038)", NAME="input/%k", SYMLINK="input/imon_remote", MODE="0666"

Lets begin by stopping lirc if you still have it running. Next, reconfigure LIRC to use the devinput driver – when it asks which device you have, DOT NOT SELECT THE SOUNDGRAPH IMON but ‘Linux input layer (/dev/input/eventX)’. In the next screen select ‘None’ as you probably do not use a transmitter.

/etc/init.d/lirc stop
sudo dpkg-reconfigure lirc
> Linux input layer (/dev/input/eventX)
> None
/etc/init.d/lirc start

In case you are not using Ubuntu Linux, I will explain the key parts of the LIRC configuration. The /etc/lirc/lircd.conf file now has this part in it:

#Configuration for the Linux input layer (/dev/input/eventX) remote:
include "/usr/share/lirc/remotes/devinput/lircd.conf.devinput"

The lirc.conf.devinput file is a standard (generated) file with key codes as provided with LIRC. There is no need to manually set up a file with button scan codes as the new ir-core kernel subsystem will generate standard codes.

The file called /etc/lirc/hardware.conf has something like this in it:

REMOTE="Linux input layer (/dev/input/eventX)"
REMOTE_MODULES=""
REMOTE_DRIVER="devinput"
REMOTE_DEVICE="/dev/input/imon_remote"
REMOTE_LIRCD_CONF="devinput/lircd.conf.devinput"
REMOTE_LIRCD_ARGS=""

All that remains is to use the new buttons in your LIRC capable program. For example, this is a part of my configuration of XBMC (Lircmap.xml) for use with the SoundGraph iMon receiver:

1
2
3
4
5
6
7
8
9
10
11
<lircmap>
  <remote device="devinput">
    <hash>KEY_EJECTCD</hash>
    <play>KEY_PLAY</play>
    <pause>KEY_PAUSE</pause>
    <stop>KEY_STOP</stop>
    <forward>KEY_FASTFORWARD</forward>
    <reverse>KEY_REWIND</reverse>
    <skipplus>KEY_NEXT</skipplus>
    <skipminus>KEY_PREVIOUS</skipminus>
    <record>KEY_RECORD</record>...
Categories
Linux / Gentoo Linux

Networking for KVM with CentOS 5.5

I’ve found numerous tutorials to set up KVM with CentOS 5.5. Some refer to the Red Hat guides, which are useless in my opinion if you are not using KVM in a large server park, others come up with scripts to set up networking.

I kept searching and trying configurations until I finally found one that works. Note that among problems you might encounter is the one that plagued me for months: CentOS is attempting to bring up the virtual device for LAN access on the host before bringing up the physical interface, this fails and prevents all networking and dependencies from starting properly.

To set up the bridge devices for KVM and the host (something which is done only once to ‘wire’ your virtual network instide the bridge) look here. Most of the guide is still relevant even if they refer to the Red Hat documentation (which is about Red Hats cloud virtualisation platform and not a single server running KVM).

Use a configuration like this for proper KVM networking under CentOS, Red Hat and probably even Fedora.

1. Edit /etc/sysconfig/network-scripts/ifcfg-eth0 to contain something like this:

1
2
3
4
5
6
7
# /etc/sysconfig/network-scripts/ifcfg-eth0 - the physical NIC which will not be used directly
DEVICE=eth0
TYPE=Ethernet
HWADDR=00:23:B3:16:3F:00
ONBOOT=yes
BRIDGE=br0
NM_CONTROLLED=no

The “NM_CONTROLLED” bit seems to originate from Fedora 12/13, CentOS might ignore it altogether so you could leave it out.

2. Edit /etc/sysconfig/network-scripts/ifcfg-br0 to restore network access for your host machine:

1
2
3
4
5
6
# /etc/sysconfig/network-scripts/ifcfg-br0 - Bridged network access for host
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
NM_CONTROLLED=no

The crucial parts in this configuration is that eth0 is started on boot and is assigned a bridge device: ‘br0’. The ‘br0’ device is marked as a bridge device which completes the dependencies between them. So make sure if you deviate from the examples you leave the types and ‘bridge=br0’ in tact.

Categories
Linux / Gentoo Linux

Determining the UUID of a partition

From Wikipedia:

A Universally Unique Identifier (UUID) is an identifier standard used in software construction, standardized by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE).

The intent of UUIDs is to enable distributed systems to uniquely identify information without significant central coordination. Thus, anyone can create a UUID and use it to identify something with reasonable confidence that the identifier will never be unintentionally used by anyone for anything else. Information labeled with UUIDs can therefore be later combined into a single database without needing to resolve name conflicts.

Since CentOS (and Ubuntu and others) use the UUID of partitions to mount or perform other operations on them, I needed to find the UUID of my storage partition. The downside to using UUIDs is obvious: I know the device name (/dev/sdb1) but I have no clue what the UUID of the partition is.

The upside is that if I move the drives around, so my /dev/sdb1 becomes /dev/sda1 for example, everything will still work because the identifiers remained unchanged.

Enough talking, I found 3 ways of finding the UUID of a drive on Linux. Note that this is not all of them though, just enough for me.

Option 1: Use /dev

Since the UUID to device mapping needs to be done somewhere for the kernel and system tools, why not use that ourselves?
ls -l /dev/disk/by-uuid

Option 2: Use udev

The vol_id program pulls the information from udev and presents it all in a fairly readable form. For some reason, my Ubuntu 10.10 does not have it anymore but possibly others still do.
vol_id /dev/sdb1

Option 3: Use blkid

The option I tend to use it to use the program called blkid. Which as sole purpose (as its name suggests) is to show the block device ID of a block device *gasp*.
blkid /dev/sdb1

Categories
General blog entries

Converting sequential algorithms to parallel algorithms

Like I mentioned before, I started my thesis for my Computer Science degree. And without getting into too much detail at this point, one of the problems we are trying to tackle is the conversion from sequential programs to parallel programs.

The target architecture is not really of importance although we are stuffing it in a multi-core chip which is programmed into a Virtex 6 FPGA.

The thing that strikes me as odd is that an insane amount of work is being put into creating new applications for multi-core environments using tool-kits and various paradigms like tasks, task graphs, Khan Networks – whatever.

After years of development, the mainstream development tools come with tools to help the programmer to design multi-core programs without having to specify each and every thread and communication channels – a drawback which prevents most programmers to easily write parallel programs.

But most software these days is based on monolithic code meant to be running on a single core. Slowly parts are rewritten to exploit the surplus cores modern computers have but even then, most software scales poorly to more cores.

Since most ‘fixes’ involve a complete rewrite, this shift to actually write multi-threaded programs instead of having a hand full of manually designed partitions within a program to appear to be multi-core is finally beginning.

In a way, my research area is barely explored as I attempt to rewrite a decoder application to be converted from a single core program to something which can run on at least 8 cores… Hows that for multi-threading…

Categories
How-To's

New phonon-vlc backend for KDE 4

According to the devs of Amarok, the new VLC based backend for Phonon delivers better sound quality than the Xine backend. Something like this just begs to be explored of course and the instructions below are based on the generic ones but specifically for Gentoo. Please note that the backend is alpha: it is incomplete and changes daily.

Install VLC 1.1 pre by installing the live version (note that VLC 1.1 is about to be released any time now so this might be available by the time you read this). Note that I had to disable the Gentoo patches in the vlc-9999 ebuild as they prevent VLC from compiling.

ACCEPT_KEYWORDS=** emerge =vlc-9999

Note to self: add the keywords to the /etc/portage/package.keywords file. 😉

Next, fetch the Phonon-VLC backend from GIT. Note that is should become ‘stable’ soonish (it said somewhere it should be moving to kdereview in the near future) so it should be safe to assume it sort of works.

cyberwizzard@cyberxps ~ $ mkdir kde
cyberwizzard@cyberxps ~ $ cd kde
cyberwizzard@cyberxps ~/kde $ mkdir src
cyberwizzard@cyberxps ~/kde $ cd src
cyberwizzard@cyberxps ~/kde/src $ git clone git://gitorious.org/phonon/phonon-vlc.git

Initialized empty Git repository in /home/cyberwizzard/kde/src/phonon-vlc/.git/
remote: Counting objects: 483, done.
remote: Compressing objects: 100% (400/400), done.
remote: Total 483 (delta 330), reused 116 (delta 66)
Receiving objects: 100% (483/483), 102.22 KiB, done.
Resolving deltas: 100% (330/330), done.

cyberwizzard@cyberxps ~/kde/src $ cd phonon-vlc/
cyberwizzard@cyberxps ~/kde/src/phonon-vlc $ cmake -DCMAKE_BUILD_TYPE=debugfull -DCMAKE_INSTALL_PREFIX=/usr $HOME/kde/src/phonon-vlc/

...configure here...

cyberwizzard@cyberxps ~/kde/src/phonon-vlc $ make

...wait a bit more...

cyberwizzard@cyberxps ~/kde/src/phonon-vlc $ su -c "make install"
Password:

[100%] Built target phonon_vlc
Install the project...
-- Install configuration: "debugfull"
-- Installing: /usr/lib/kde4/plugins/phonon_backend/phonon_vlc.so
-- Set runtime path of "/usr/lib/kde4/plugins/phonon_backend/phonon_vlc.so" to "/usr/lib:/usr/lib64/qt4"
-- Installing: /usr/share/kde4/services/phononbackends/vlc.desktop

cyberwizzard@cyberxps ~/kde/src/phonon-vlc $ su -c "kbuildsycoca4 --noincremental"
...password and lot of output here...

And thats it! Just fire up Amarok -> Settings -> Configure Amarok -> Playback -> Configure Phonon (or go through System Settings in KDE) and select the VLC backend (currently shows up as version 0.2).

Categories
How-To's

Multi-monitor with KDE 4 and XRandR

One of the annoyances I’ve had with *nix so far was the apparent lack of multi-monitor control from the GUI. I’ve have experience with TwinView using xorg.conf, which worked fine but was quite a hassle to set up.

A side effect of this is the fact that once set up, I never touched the configuration again. For a computer with 2 screens hooked up permanently, this is fine. For a laptop which is dragged along and connected to beamers, TVs and monitors – not so much.

The good news is that I run a modern linux distro which led me to believe that the multi-monitor stuff should be enabled by default. However, I am not using Kubuntu (which would probably auto-enable all new toys for me) but rather I am using Gentoo. So it took some digging to figure out what is going on these days and how to use it. On a side note: you could use nvidia-settings instead after plugging something in but I’d rather use the automatic method.

First a word of warning: the binary NVidia drivers do not support RandR 1.2. I have the 195.xx drivers installed and NVidia expressed back in 2007 that RandR 1.2 support was a ‘priority’ feature. One that apparently needed more than 3 years to be released. This means that using the binary ‘nvidia’ driver will give you RandR 1.1 which does not support the on-the-fly hotplug for displays. Instead you are forced to use TwinView, define meta-modes for every possible configuration and switch to those using ‘xrandr’ (or use the nvidia-settings tool each time).

Since this sort of defies having RandR 1.2 support altogether in Xorg, I decided to ditch the binary nvidia driver in favor of ‘nouveau’: the open-source replacement for ‘nv’ with decent 2D acceleration support (although I couldn’t resist and enabled the highly experimental Gallium3D support as well).

To start off: trim down your Xorg configuration to a minimum, note that a recent Xorg is needed (I have 7.4 at the time of writing). This is needed to enable the auto-detection of many things or rather: manually specifying properties will override auto-detected settings and cripple Xorg’s ability to handle everything on its own. As an example, I have included my own xorg.conf below.

Section "ServerLayout"
  Identifier "Default Layout"
  Screen 0 "Screen0"
EndSection

Section "ServerFlags"
  Option "AutoAddDevices" "true"
  Option "AutoEnableDevices" "true"
EndSection

Section "Device"
  Identifier "nVidia_8600M_GS_nouveau"
  Driver "nouveau"
  Boardname "GeForce 8600M GS"
EndSection

Section "Screen"
  Identifier "Screen 0"
  Device "nVidia_8600M_GS_nouveau"
  Monitor "Monitor 0"
  SubSection "Display"
    Modes "1680x1050"
  EndSubSection
EndSection

Section "Monitor"
  Identifier "Monitor 0"
  VendorName "Primary Monitor"
  Option "DPMS"
EndSection

Section "Extensions"
  Option "Composite" "Enable"
EndSection

The ‘ServerFlags’ section is pretty simple: use every auto-detection known in Xorg to hotplug devices. This means both monitors and input devices like mouses and keyboards.

Next up are the 2 sections for my NVidia display card. Since I am using ‘nouveau’ instead of ‘nvidia’, make sure you are not loading ‘glx’ somewhere (if you were using ‘nvidia’ in the past like me, you most likely have that somewhere).

The last 2 sections are fairly simple as well but note that I do specify the native resolution of my LCD screen as the preferred resolution.

Thats it! Restart your X server and run xrandr so see the result. I plugged a VGA monitor in my notebook and this is the result:

cyberwizzard@cyberxps ~ $ xrandr
Screen 0: minimum 320 x 200, current 2960 x 1050, maximum 8192 x 8192
LVDS-1 connected 1680x1050+0+0 (normal left inverted right x axis y axis) 331mm x 207mm
1680x1050      60.0*+   60.0
1400x1050      60.0
1280x1024      59.9
1280x960       59.9
1152x864       60.0
1024x768       59.9
800x600        59.9
640x480        59.4
720x400        59.6
640x400        60.0
640x350        59.8
HDMI-1 disconnected (normal left inverted right x axis y axis)
VGA-1 connected 1280x1024+1680+0 (normal left inverted right x axis y axis) 312mm x 234mm
1680x1050      74.9 +   60.0
1280x1024      85.0*+   75.0     60.0
1792x1344      60.0
1920x1200      59.9
1600x1200      75.0     70.0     65.0     60.0
1400x1050      85.0     74.9     60.0
1440x900       84.8     75.0     59.9
1280x960       85.0     60.0
1360x768       60.0
1280x800       84.9     74.9     59.8
1152x864       75.0
1280x768       84.8     74.9     59.9
1024x768      100.0     85.0     75.1     75.0     70.1     60.0     43.5     43.5
832x624        74.6
800x600        85.1     72.2     75.0     60.3     56.2
848x480        60.0
640x480        85.0     75.0     72.8     72.8     66.7     60.0     59.9
720x400        85.0     87.8     70.1
640x400        85.1
640x350        85.1
Categories
Linux / Gentoo Linux

Change SVN repository location

For some reason, repositories can be moved around. If you are using a working copy to develop a program or web-application or whatever, the move usually only implies a ‘check-out’ and you are set.

However, sometimes the repository is part of a production environment. To be precise, the production version is prepped in a special branch and then deployed using Subversion. Upgrading a website to a newer version only requires a ‘svn up’ and if you automate the database upgrades as well, web management becomes a breeze.

You might imagine that moving the repository in such an environment is less than desirable: each site or application which is part of that repository becomes un-upgradable and checking out everything by hand and setting it all up (plus the verification that every part is still functional) becomes a time consuming task.

However, the SVN information is all stored in plain text files. The following snippet switches the repository from http://svn.mydomain.com/svn to svn://svn.someotherdomain.com. This means you can quickly switch protocol, host names or even the location within a certain host. Simply copy-paste the code below into a file in the directory holding one or more projects for that repository, change the URLs (do not forget to escape by replacing ‘/’ with ‘\/’) and run the script.

#!/bin/bash
DIRS=`find . -name ".svn"`
for dir in ${DIRS}
do
  echo "Processing $dir"
  FILES=`find $dir`
  for file in ${FILES}
  do
    if [ -f ${file} ]; then
      echo "Fixing '${file}'..."
      sed 's/http:\/\/svn.mydomain.com/svn:\/\/svn.someotherdomain.com/g' "${file}" > "${file}.tmp"
      mv "${file}.tmp" "${file}"
    fi
  done
done
Categories
General blog entries

Radio silence

Visitors dwindling to my site, I decided it was time to write something again after 3 months. Its not that I stopped working with computers but rather that my attention moved from working with computers to studying Computer Science. Something that is hard to combine if you are making a dash to the finish line.

In other words: I am finishing my last courses in the coming days and will begin on my thesis. I haven’t decided yet if I will post things from my thesis yet (as extra content). Not so much because of the extra time but also because not everything is interesting and some information is classified – making other things inexplicable or incomplete if I were to post it online.

On to more important things: KDE 4.4 is about to hit the virtual shelves! Besides more polishing and some other features, it finally comes with a full blogging client (as part of the base system).

“What”, you say, “they fixed KBlogger?” Heck no, KBlogger is still dead as a door nail and as buggy as it has been forever. It seems that someone got the bright idea to actually replace KBlogger altogether with Bilbo – the tool I talked about before. One of the major issues Bilbo had, was that fact that nobody knew it. Personally, I think this comes from the name: Bilbo – as it is also the name from one of Tolkiens books. If you now think “Lord of the Rings”, you should be ashamed: Bilbo is part of the story *before* LOTR, he just happens to be alive in the epic story afterwards…

But I digress.

The fact remains that finding the program (even if you know that it exists) becomes hard because all search engines will refer you to hits about the wrong topic. Also, as you might imagine, some folks (*cough*copyright holders*cough*) might have issues with the naming. So it was renamed from Bilbo to Blogilo a while back and as such can now be part of the whole KDE experience. Hurray!

Next time I will probably explain about a project (formal model checker, based on the Promela language) I have been working on and the surprisingly bad hash functions I found on the internet…

Categories
Linux / Gentoo Linux

Fixing Vmware mouse flicker

After upgrading a VM from Ubuntu 9.04 to Xubuntu 9.10 I noticed that the mouse cursor works fine in a certain region (say 640×480) but outside that region, it flickers between the actual mouse position and the edge of the region.

After reinstalling X a few times and upgrading the VMware tools I found the solution: it is a bug in the newer GTK versions. Since I amd running Gentoo (unstable aka bleeding edge) I am one of the lucky owners of this new bug.

The solution seems to be to instruct VMWare Player or Workstation (I use 6.5.x) to use its bundled GTK instead of the system one:

echo "VMWARE_USE_SHIPPED_GTK=yes" >> /etc/vmware/bootstrap
Categories
General blog entries

VoIP providers

In my quest for VoIP support in the Netherlands I found a lot of providers. Most of them seem to be catering the consumer needs rather than the prosumer or even business needs. Most providers fall under one of 3 categories: consumer (“free” landline calls but usually not unlimited call time resulting in paid minutes after a certain time), prosumer (better defined call rates, subscriptions, professional level support) and corporate (meant for large businesses, lots of trunks, hosted PBX and so on).

Note that I omit the service providers that only provide services for their own customers. For example, Tele2 has a business oriented VoIP division but also provides VoIP telephony to their DSL customers.

Known ISPs with a VoIP service for their customers: KPN, Tele2, XS4all, @Home (Ziggo).

Note: the listing above is incomplete and based upon results I found in my search online.

Consumer

VoIP Goedkoop

This is a handy site containing links to multiple “free” VoIP providers. These are fine for consumer usage, normally are not suited for business usage (free equals no quality guarantee, no subscriptions) and usually do not come with DID services.

http://voipgoedkoop.nl/

VoIPBuster

As one of the more wide known service providers, VoIPBuster advertises with free calls. The “free” here is relative as not all destinations are actually free and for example land line calling in the Netherlands is “free” for a minute (they call that a “Superdeal”, a choice of words which is not reflected by their meaning), after which an unspecified fee is charged. Also, every 120 days, a user needs to reactivate their account by paying 10 Euros, which is converted into 10 Euros credit. Also, mobile numbers cost 25 cpm, which is twice as much as every other VoIP provider I found, not a bargain at all…

www.voipbuster.com

Prosumer

VoipQ

VoipQ supports subscriptions, clear call rates and supports DID services as well.

www.voipq.nl

SpeakUp

SpeakUp also provides subscriptions, DIDs and clear calling rates. The also offer hosted PBX or just trunk services.

www.speakup.nl

Voys Telecom

Supports VoIP subscriptions from one to multiple lines and everything that comes with it. Does not seem to be the cheapest provider but they seem to have a good reputation.

www.voys.nl

Corporate

KPN

KPN is the leading Dutch telecom company for decades. Slowly they start to move from POTS solutions to VoIP, for example for their DSL and fibre customers. For the corporate markt they only aim for the big players, as only the start fee is 2000 Euros at the time of writing and subscriptions are expressed in 3 digit monthly fees for the smallest packages. Great for huge corporations and call centers, but useless for everyone else.

http://zakelijk.kpn.com/business/voip.htm