1

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?

guttermonk
  • 1,004
  • 14
  • 29

2 Answers2

0

You can try to unload the driver by stopping the service that is using it, or by disabling the use of the driver in the system settings. To do this, try running the following commands:

sudo rmmod saa7164
sudo rmmod tveeprom

If the above command fails, try using the force option:

sudo rmmod -f saa7164
sudo rmmod -f tveeprom

f the above command also fails, you can try to blacklist the driver from being loaded at boot time. You can do this by adding the following lines to /etc/modprobe.d/blacklist.conf:

blacklist saa7164
blacklist tveeprom

Save and close the file, then restart your system. The driver should not load at boot time, and you should be able to unload it.

Liel Dahan
  • 11
  • 2
0

I think you also need to stop any program that is using the module, before you remove it. You aren't running MythTV by any chance?

  • Your definitely right. Read the last part of my post. I'm stuck in a catch 22. I can't unload saa7164 because it's in use by tveeprom and several other programs, and when I try to unload tveeprom it says that it's in use by saa7164. I've heard that this technique doesn't work well with this card because it has two tuners. I wish I could just get a dual-tuner graphics card with Linux drivers that supports suspend. – guttermonk Feb 28 '16 at 15:08
  • You didn't actually say you were running mythtv in your post :-)

    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:23
  • Oh sorry, I'm not running MythTV. I am running tvheadend and kodi. – guttermonk Feb 28 '16 at 15:25
  • Ok, same principle should apply. You need to end either tvheadend or kodi (or both) before you can remove the module. You should be able to test that at the command line: sudo rmmod saa7164

    and 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