I'm a noob when it comes to using systemd. I'm running Ubuntu 15.04 with the Hauppauge 2250 TV tuner. Unfortunately, the driver/module for the 2250, "saa7164", is not compatible with suspend/resume so live TV will not work after resuming. So I'm using the following file to stop/resume tvheadend and saa7164:
sudo gedit /lib/systemd/system-sleep/50_tvheadend
Which contains the following scipt:
#!/bin/sh
case "$1" in
pre/*)
echo "Entering sleep..." > /tmp/sleep.log
echo "Entering sleep"
cat /proc/acpi/wakeup >> /tmp/sleep.log
service tvheadend stop
sleep 1
modprobe -r tveeprom
modprobe -r dvb_core
modprobe -r v4l2_common
modprobe -r videodev
modprobe -r saa7164
sleep 3
echo "After modprobe..." >> /tmp/sleep.log
cat /proc/acpi/wakeup >> /tmp/sleep.log
;;
post/*)
echo "Awaking from sleep..." >> /tmp/sleep.log
echo "Waking up"
modprobe saa7164
modprobe videodev
modprobe v4l2_common
modprobe dvb_core
modprobe tveeprom
sleep 3
echo "After modprobe..." >> /tmp/sleep.log
service tvheadend start
sleep 1
\cat /proc/acpi/wakeup >> /tmp/sleep.log
;;
esac
For good measure, I made the file executable by everyone:
sudo chmod 755 /lib/systemd/system-sleep/50_tvheadend
But this didn't work. So I ran the commands to start and stop tvheadend in terminal, which worked. But when I tried to stop the saa7164 driver in terminal using "modprobe -r saa7164", it errored. So I followed these instructions on how to unload a kernel module which is in use, but my script attempted to unload all the modules listed in "lsmod | grep saa7164" and failed. So I attempted to run the commands in terminal, as follows:
htpc@htpc-desktop:~$ sudo modprobe -r saa7164
modprobe: FATAL: Module saa7164 is in use
htpc@htpc-desktop:~$ lsmod | grep saa7164
saa7164 131072 -1
tveeprom 24576 1 saa7164
dvb_core 126976 1 saa7164
v4l2_common 16384 1 saa7164
videodev 159744 2 saa7164,v4l2_common
htpc@htpc-desktop:~$ sudo modprobe -r tveeprom
modprobe: FATAL: Module tveeprom is in use.
htpc@htpc-desktop:~$ lsmod | grep tveeprom
tveeprom 24576 1 saa7164
How do I unload the saa7164 driver/module?
I've just written up my solution here http://ubuntuforums.org/showthread.php?t=2298165
I think it will work for you. :)
– Wayne McDougall Feb 28 '16 at 15:23and see if it succeeds or not. Then see what you need to end first.
I don't think you need to remove the other modules - it's only saa7164 that doesn't handle suspend.
– Wayne McDougall Feb 28 '16 at 15:35