如何让恢复脚本等待 ivtv 初始化

如何让恢复脚本等待 ivtv 初始化

我有一张带红外传感器的电视调谐卡。我编写了一个脚本来删除/启动 ivtv 内核模块并在挂起/恢复时关闭/重新启动 lirc 服务。

问题是 lirc 服务启动命令在 ivtv 找到并初始化硬件之前运行,因此失败。

有没有办法将 lirc 服务启动推迟到硬件初始化之后?

脚本文件为:

/etc/pm/sleep.d/30_ivtv

及其内容:

#!/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

恢复后系统日志的片段:

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
...

答案1

您可以在此处添加sleep

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

现在,您想要做一些真正聪明的事情,您可能想要使用 upstart。

相关内容