Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a TV tuner card with an infrared sensor. I have made a script to remove/start ivtv kernel module and shutdown/restart lirc service on suspend/resume.

The problem is that the lirc service start command runs before ivtv has found and initialized the hardware, so it fails.

Is there a way to defer the lirc service start until after the hardware has been initialized?

The script file is:

/etc/pm/sleep.d/30_ivtv

and its contents:

#!/bin/sh
#
# Hauppauge PVR250 TV-card and TBS6680 DVB-card are dead after resume, fix it

. /usr/lib/pm-utils/functions

case "$1" in
    hibernate|suspend)
        # VLC prevents sleep
        killall vlc
        # LIRC...
        service lirc stop
        # Disable ivtv to prevent Hauppauge from being dead on resume
        rmmod ivtv
        # Disable TBS6680 dvb card to prevent it from being dead on resume
        rmmod saa716x_tbs_dvb

;;

    thaw|resume)
        modprobe saa716x_tbs_dvb
        modprobe ivtv

        # Here we need to wait until IR sensor device initialization is done!

        service lirc start
;;

    *)
;;
esac

exit

Snippet from syslog after resume:

lircd-0.9.0[13717]: lircd(devinput) ready, using /var/run/lirc/lircd
lircd-0.9.0[13717]: accepted new client on /var/run/lirc/lircd
lircd-0.9.0[13717]: initializing '/dev/input/event'
lircd-0.9.0[13717]: unable to open '/dev/input/event'
lircd-0.9.0[13717]: Failed to initialize hardware
kernel: [34425.580877] init: Handling lirc-device-added event
...
kernel: [34426.032906] ivtv: Start initialization, version 1.4.3
...
kernel: [34426.093966] ivtv0: Autodetected Hauppauge WinTV PVR-250
...
kernel: [34426.273807] init: Handling i2c-device-added event
kernel: [34426.274758] Registered IR keymap rc-hauppauge
kernel: [34426.274801] input: i2c IR (Hauppauge) as /devices/virtual/rc/rc13/input71
kernel: [34426.274854] rc13: i2c IR (Hauppauge) as /devices/virtual/rc/rc13
kernel: [34426.274856] ir-kbd-i2c: i2c IR (Hauppauge) detected at i2c-2/2-0018/ir0 [ivtv i2c driver #0]
kernel: [34426.275080] init: Handling i2c-device-added event
kernel: [34426.275135] init: Handling rc-device-added event
...
share|improve this question

1 Answer 1

You can add a sleep here:

thaw|resume)
    modprobe saa716x_tbs_dvb
    modprobe ivtv

    # Here we need to wait until IR sensor device initialization is done!
    sleep 20
    service lirc start

Now, you want to do something really smart, you may want to use upstart.

share|improve this answer
    
Thanks, I'll look into upstart, sounds like what I need! I wanted to avoid putting a sleep there, since it's ugly and not solid-state. –  Per Nov 17 '13 at 11:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.