Infrared receiver/transmitter support


From SamyGO
Revision as of 13:42, 25 September 2011 by Marcelru (talk | contribs)
Jump to: navigation, search

A few years ago I bought a B-series Samsung TV (UE40B7020). Apart from a very good display, it also has a very poor sound quality. What do you expect from a <30mm thick housing, with the speakers facing backwards. To counter this not-so-good feature, I hooked the TV up to a home theatre system, incorporating a BluRay player (HT-BD8200, also from Samsung. It has a sleek design that nicely matches my TV). Both devices need to be switched on through an IR-remote control. Once running, when the TV is switched off again, the BluRay player shuts down automatically, together with the TV, at least when the TV's software is properly configured.

Hmmm .. I want them to switch on with a single button-push as well. Since both devices only respond to IR signals when switched off, there are two possible options to tackle this problem.

  1. Buy a multi-platform, multi-protocol remote. Logitech has some, with list prices ranging from $70,- to $350,-.
    Pro: One shiny remote for a multitude of devices.
    Con: Yet another remote floating around in your living room. Price may be an issue. It's just dull and boring.
  2. Buy a small USB infrared receiver/transmitter, teach the TV how to control it, and let your TV do the switching on of the home theatre.
    Pro: Cheap (I bought one for $40,- from iguanaworks). One remote for a multitude of devices. You can still use your original remote. Yet another way to be tinkering with your TV.
    Con: Nothing!

For the SamyGO community, the second is of course the only real option.

Here's how it's done:

What you need

Before we go any futher, this wiki describes the use of the iguanaworks USB IR receiver/transmitter. For any other type and/or brand, parts of this wiki may be helpful, but it is by no means a complete guide, then.

Required hardware:

  1. USB-IR transmitter/receiver. You can order it from IguanaWorks.
    USB transmitter/receiver from iguanaworks
  2. USB A-male A-female cable, at least 0.5m in length. Without it your transmitter will be tucked away behind your TV, probably without being able to send/receive IR signals.
  3. B-series Samsung TV, with telnet access and a free USB-port. Automated startup follows through an edit of the SamyGO.sh script. The actions described in this wiki may work for other models as well, but haven't been tested.

Required software:

  1. Iguanaworks driver code
  2. libpopt source
  3. libusb-0.1 [1] or, alternatively, use the libusb source provided by Samsung. It is deeply hidden in 10_UE46B8000.zip, available from Samsung. I did the last.
  4. libusb-1.0 [2]
  5. LIRC [3]
  6. Cross-compilation toolchain for your TV, including at least the kernel headers. See SamyGO wiki for details.

What you do

Preparation of the software

In this example, the source code packages were installed side by side, in the same top-level directory:

libusb
popt-1.16
iguanaIR-1.0.1  
libusb-1.0.8  
lirc-0.9.0

Build of libpopt.so

  • Unpack the source code for libpopt.
  • cd to the popt source dir, run the configure script, define the host type for cross-compilation (mine is arm-SamyGO-linux-gnueabi):
./configure --host=arm-SamyGO-linux-gnueabi
  • run make
  • after successful completion, libpopt.so.0.0.0 resides in .libs/ in the source tree.

Build of libusb-0.1

  • Unpack the source code for libusb-0.1
  • For Samsung's libusb, edit the Makefile, to enable cross-compilation. Set the -I option to point to the right header subdir.The relevant lines should look like this:
CC = arm-SamyGO-linux-gnueabi-gcc
INC = -I./Inc
  • run make
  • After successful completion, libusb.so resides in the top-level build directory.

Build of libusb-1.0

  • Unpack the source code for libusb-1.0
  • run configure, set host and installation prefix. In my machine this is /usr/local/arm-SamyGO-linux-gnueabi, YMMV:
./configure --host=arm-SamyGO-linux-gnueabi --prefix=/usr/local/arm-SamyGO-linux-gnueabi
  • run make
  • run make install. This step is needed because otherwise the build of igdaemon fails miserably.
  • after completion, the library and links reside in $prefix/lib, headers in $prefix/include/libusb-1.0

Build of igdaemon

  • Unpack the iguanaIR source package
  • Locate the file iguanaIR.h
  • Change the line reading
#define IGSOCK_NAME "/dev/iguanaIR/"

to

#define IGSOCK_NAME "/dtv/dev/iguanaIR/"
  • Configure the igdaemon build. Because some dependencies for libusb-1.0 for ARM are normally not installed on an x86-64 or x86 linux system, I set up a script for the configuration of igdaemon and libiguanaIR. Normally, I try and avoid the installation of ARM executables and libraries as much as I can, so I don't have libpopt and libusb installed. The only exception is libusb-1.0. It had to be installed to prevent interference with the native libusb (x86-64).This is the script:
BUILD_ROOT=`pwd`

# exports for headers and libraries.

export CPPFLAGS="-I/usr/local/arm-SamyGO-linux-gnueabi/include -I$BUILD_ROOT/../libusb/Inc -I../popt-1.16"
export LDFLAGS="-L/usr/local/arm-SamyGO-linux-gnueabi/lib -L$BUILD_ROOT/../libusb -L../popt-1.16/.libs" 

# exports for rpl_malloc() and rpl_realloc() macros

export ac_cv_func_malloc_0_nonnull=yes
export ac_cv_func_realloc_0_nonnull=yes
./configure --host arm-SamyGO-linux-gnueabi --disable-python
  • run make
  • After completion, the required binaries reside in the top-level build directory.
  • to be able to build LIRC, create the following link in the top-level build directory:
ln -s libiguanaIR.so.0 libiguanaIR.so

Build of LIRC with Iguanaworks support

  • Unpack the LIRC source package
  • LIRC redefines some datatypes, which during the build leads to errors.
  • Locate the file include/linux/types.h in the kernel source tree and comment out the lines described below (I know, not a very elegant way of getting things to work, but after two days of searching I got fed up and decided to do it the blunt way. This edit holds at least for kernel 2.6.18):
[marcelr@laptop46 linux]$ diff types.h.orig types.h 
21,22c21,22
< typedef __kernel_fd_set		fd_set;
< typedef __kernel_dev_t		dev_t;
---
> /*typedef __kernel_fd_set		fd_set;*/
> /*typedef __kernel_dev_t		dev_t;*/
24,25c24,25
< typedef __kernel_mode_t		mode_t;
< typedef __kernel_nlink_t	nlink_t;
---
> /*typedef __kernel_mode_t		mode_t;*/
> /*typedef __kernel_nlink_t	nlink_t;*/
51,52c51,52
< typedef __kernel_uid_t		uid_t;
< typedef __kernel_gid_t		gid_t;
---
> /*typedef __kernel_uid_t		uid_t;*/
> /*typedef __kernel_gid_t		gid_t;*/
140c140
< typedef unsigned long blkcnt_t;
---
> /*typedef unsigned long blkcnt_t;*/
  • Configure LIRC. Like for igdaemon, quite some options need to be set, so again a script is easier:
#! /bin/sh

export CPPFLAGS="-I/home/marcelr/build/iguanaworks/iguanaIR-1.0.1"
export LDFLAGS="-L/home/marcelr/build/iguanaworks/iguanaIR-1.0.1 -liguanaIR"

./configure --with-kerneldir=/home/marcelr/build/ue40b7020/toolchain/build/src/linux --host=arm-SamyGO-linux-gnueabi \
            --with-driver=iguanaIR --with-transmitter
  • You may encounter this error:
checking for Linux kernel sources... make: arm_v6_vfp_le-gcc: Command not found
/tmp/LIRCMF.tFf5zE:1404: *** mixed implicit and normal rules.  Stop.
make: arm_v6_vfp_le-gcc: Command not found
/tmp/LIRCMF.tFf5zE:1404: *** mixed implicit and normal rules.  Stop.
./configure: line 15357: test: -eq: unary operator expected

This you can ignore, because there will be no kernel module for this particular device.

  • run make.
  • after successful completion, the required binaries reside in the daemons/ directory.

Installation of the software on the TV

To make things work the following binaries need to be transferred to the TV (I put them in /mtd_rwarea/iguanaworks/)

# pwd
/mtd_rwarea/iguanaworks
# ls -R
.:
bin  etc  lib 

./bin:
SamyGO-IR-ctrl.sh  igdaemon           irsend             lircd
igclient           irrecord           irw                lircmd

./etc:
lirc

./etc/lirc:
Samsung_AH59-02195C.conf

./lib:
libiguanaIR.so           libpopt.so               libusb-1.0.so.0
libiguanaIR.so.0         libpopt.so.0             libusb-1.0.so.0.0.0
liblirc_client.so        libpopt.so.0.0.0         libusb.so
liblirc_client.so.0.2.1  libusb-1.0.so            libusbpre1.so

You don't really need everything in bin/, some binaries are there just for testing purposes. As soon as that's done, they will be removed. The switching on of my TV is handled by bin/SamyGO-IR-ctrl.sh. etc/lirc/Samsung_AH59-02195C.conf holds the commands for my HT remote.

To be continued ...


marcelr