[mythtv-users] PVR-350 IR Control & IR Blaster (long answer)

IvanK. chepati at yahoo.com
Thu May 13 13:27:44 EDT 2004


Will,

I'm running three instances of lirc on my system -- one controlling the 
pvr350's receiver and two controlling simple ir transmitters that control my 
external boxes (Time Warner in NYC, Scientific Atlanta 2000, and a Pioneer 
something).

Here's what I did (thanks to someone on the list, whose name I regrettably 
forgot, for the info on compiling custom lirc)

Downloaded lirc cvs (from a few months ago, but anything recent should work)

Copied the lirc directory three times, one called lirc-hauppauge, one called 
lirc-trans1, and the last called lirc-trans2.

Went into lirc-hauppauge and ran ./setup.sh.
Selected 1 Driver configuration -> TV Card -> Hauppauge TV card (new I2C layer 
required)
Selected 4 Save configuration and exit.

created a script configure-hauppauge.sh with this:

#!/bin/bash

./configure \
--prefix=/usr \
--libexecdir=/usr/sbin \
--localstatedir=/var \
--with-moduledir=/lib/modules/2.4.24/misc_hauppauge \
--with-x \
--with-syslog \
--with-driver=hauppauge \
--with-major=61 \
--with-port=none \
--with-irq=none \
"$@"

Ran ./configure-hauppauge.sh and then did make, make install
Went into /lib/modules/2.4.24/misc_hauppauge and renamed lirc_dev.o to 
lirc_dev_hauppauge.o (not sure if this is really necessary, but the lirc 
instances I will compile later for the two transmitters also have lirc_dev.o 
modules and I want to differentiate between them).

My two transmitters are hooked up to a PCI serial port card that has the 
following (as reported by lspci -v):

00:0b.0 Serial controller: NetMos Technology 222N-2 I/O Card (2S+1P) (rev 01) 
(prog-if 02 [16550])
        Subsystem: LSI Logic / Symbios Logic: Unknown device 0012
        Flags: medium devsel, IRQ 12
        I/O ports at 9000 [size=8]  # This is /dev/ttyS2, aka lirc-trans1
        I/O ports at 9400 [size=8]  # This is /dev/ttyS3, aka lirc-trans2
        I/O ports at 9800 [size=8]
        I/O ports at 9c00 [size=8]
        I/O ports at a000 [size=8]
        I/O ports at a400 [size=16]

I repeated the same procedure I did for lirc-hauppauge, for each of 
lirc-trans1 and lirc-trans2, except that configure-trans1.sh looks like this:

#!/bin/bash

./configure \
--prefix=/usr/local/lirc_trans1 \
--localstatedir=/usr/local/lirc_trans1/var \
--with-devdir=/usr/local/lirc_trans1/dev \
--with-moduledir=/lib/modules/2.4.24/misc_trans1 \
--with-transmitter \
--with-x \
--with-syslog \
--with-driver=serial \
--with-major=62 \
--with-port=0x9000 \
--with-irq=12 \
--program-suffix=_trans1 \
"$@"


and configure-trans2.sh looks like this:

#!/bin/bash

./configure \
--prefix=/usr/local/lirc_trans2 \
--localstatedir=/usr/local/lirc_trans2/var \
--with-devdir=/usr/local/lirc_trans2/dev \
--with-moduledir=/lib/modules/2.4.24/misc_trans2 \
--with-transmitter \
--with-x \
--with-syslog \
--with-driver=serial \
--with-major=63 \
--with-port=0x9400 \
--with-irq=12 \
--program-suffix=_trans2 \
"$@"

Make sure to replace --with-port= and --with-irq= with the IO port and irq 
that correspond to the serial ports.  Same applies to --with-major=.  
However, the major number is something you can decide, just make sure you use 
that number consistently throughout all the scripts.

Don't forget to go to /lib/modules/2.4.24/misc_trans1 and move lirc_dev.o to 
lirc_dev_trans1.o and lirc_serial.o to lirc_serial-1.o

and go to  /lib/modules/2.4.24/misc_trans2 and move move lirc_dev.o to 
lirc_dev_trans2.o and lirc_serial.o to lirc_serial-2.o

Of course change 2.4.24 to your kernel's version.

Don't forget to do depmod -a `uname -r`

Now go to /usr/local/lirc_trans1 and do:
mkdir dev && mknod dev/lirc c 62 0

then go to /usr/local/lirc_trans2 and do:
mkdir dev && mknod dev/lirc c 63 0

It's important to use the same major numbers (62 for trans1 and 63 for trans2) 
that you specified in ./configure-trans1.sh and ./configure-trans2.sh, 
respectively.

When you're done with that, you still need to start lirc when you boot your 
computer.  Since you renamed your lirc_dev.o for the hauppauge receiver, you 
also need to change /etc/modules.conf

Here's what mine looks like:
# This is for WinTV PVR-350 IVTV
alias char-major-81     videodev
alias char-major-81-0   ivtv
alias char-major-81-1   ivtv
#alias char-major-81-1  bttv
options ivtv ivtv_debug=1
options tuner type=2
options saa7127 enable_output=1 output_select=0
options msp3400 once=1 simple=-1
add below ivtv msp3400 saa7115 saa7127 tuner
#add above ivtv lirc_dev_hauppauge lirc_i2c ivtv-fb
add above ivtv ivtv-fb

Note, that I have disabled automatic loading of the pvr-350 lirc module since 
I want to do it in a separate init script.

But before I get to the lirc init script, I have to say that I had to write 
another init script to initialize and prepare the com ports before I ran lirc 
on them.  My com port script is called comm_port and looks like this:

#!/bin/bash
# Begin $rc_base/init.d/comm_port

# Based on sysklogd script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org

source /etc/sysconfig/rc
source $rc_functions

case "$1" in
        start)
                echo "Setting up /dev/ttyS0..."
                /bin/setserial /dev/ttyS0 uart none

                echo "Setting up /dev/ttyS2..."
                /bin/setserial /dev/ttyS2 port 0x9000 uart none irq 12 
baud_base 115200
                evaluate_retval

                echo "Setting up /dev/ttyS3..."
                /bin/setserial /dev/ttyS3 port 0x9400 uart none irq 12 
baud_base 115200
                evaluate_retval
                ;;

        *)
                echo "Usage: $0 {start}"
                exit 1
                ;;
esac

# End $rc_base/init.d/comm_port

Note, my email program may break the setserial line into two lines, but you 
make sure it's on a single line.

Then I have another init script, called lircd that looks like this:

#!/bin/bash
# Begin $rc_base/init.d/lircd

# Based on sysklogd script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org

source /etc/sysconfig/rc
source $rc_functions

case "$1" in
        start)
                echo "Starting Transmitter 1 LIRC..."
                /sbin/insmod lirc_dev_trans1
                /sbin/insmod lirc_serial-1
                loadproc /usr/local/lirc_trans1/sbin/lircd_trans1
                evaluate_retval

                echo "Starting Transmitter 2 LIRC..."
                /sbin/insmod lirc_dev_trans2
                /sbin/insmod lirc_serial-2
                loadproc /usr/local/lirc_trans2/sbin/lircd_trans2
                evaluate_retval

                echo "Starting Receiver LIRC..."
                /sbin/insmod lirc_dev_hauppauge
                /sbin/insmod lirc_i2c
                loadproc lircd
                evaluate_retval

                echo "Starting Reboot Monitor..."
                /usr/bin/irexec -d /etc/irexec.conf
                evaluate_retval
                ;;

        stop)
                echo "Stopping Transmitter 1 LIRC..."
                killproc lircd_trans1

                echo "Stopping Transmitter 2 LIRC..."
                killproc lircd_trans2

                echo "Stopping Receiver LIRC..."
                killproc lircd

                echo "Stopping Reboot Monitor..."
                killproc irexec
                ;;

        restart)
                $0 stop
                sleep 1
                $0 start
                ;;

        status)
                statusproc lircd
                statusproc lircd_trans1
                statusproc lircd_trans1
                statusproc irexec
                ;;

        *)
                echo "Usage: $0 {start|stop|restart|status}"
                exit 1
                ;;
esac

# End $rc_base/init.d/lircd


Now, a word of warning, I'm using Linux From Scratch (LFS) and the scripts I 
wrote use a few LFS init functions -- loadproc, killproc, statusproc, and 
evaluate_retval, which if you're using anything other than LFS will not be 
found.  You'll have to adapt to your distribution.  In RedHat (Fedora) I 
think loadproc would be called startproc.

Anyhow, when I boot, I make sure that comm_port will be run first, then lircd, 
and lastly my mythbackend script, which I'm not posting, since that wasn't in 
your question.

It looks complicated, but the idea is simple, custom-build a few (2 or three 
or as many as you want) lirc instances that you run simultaneously and that 
control devices with non-standard lirc device major numbers (61 is default, 
and I'm using 62 for ttyS2 and 63 for ttyS3).  Just make sure you don't use a 
major number that is assigned or reserved for another device.

Good luck and let me know if you have questions.

IvanK.


On Thursday 13 May 2004 12:24 pm, Will Cardenas wrote:
> I hope this isn't considered too far OT...
>
> Anyone using the PVR-350 IR recv AND using an IR blaster
> to control a cable box?  Unless I'm completely missing something
> LIRC seems to be only able to control one device.  Is this the
> case?
>
> My ultimate goal with Myth is to use the PVR-350 IR recv and
> control two cable boxes using two (isolated) IR blasters.
>
> Anyone have this setup?  Are there other configurations that
> would get me the same functionality?
>
> Thanks.
>
> Will Cardenas


More information about the mythtv-users mailing list