From 951431ba42a422cf059666d8000f7d3f5fd8449a Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Thu, 2 Apr 2009 14:10:02 -0500
Subject: LinHES-config: more stuff to fix hauppauge. Still not complete
 because rmmod pvr-150 likes to cause an oops

---
 abs/core-testing/LinHES-config/PKGBUILD        |  2 +-
 abs/core-testing/LinHES-config/ir_config.sh    | 63 ++++++++++++++++++++------
 abs/core-testing/LinHES-config/systemconfig.sh | 54 +++++++++++-----------
 3 files changed, 77 insertions(+), 42 deletions(-)

diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD
index f61f2da..1d15a84 100644
--- a/abs/core-testing/LinHES-config/PKGBUILD
+++ b/abs/core-testing/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=1.0
-pkgrel=357
+pkgrel=362
 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev )
 pkgdesc="Install and configure your system"
 depends=(bc libstatgrab  mysql-python expect curl dnsutils parted sg3_utils nmbscan system-templates )
diff --git a/abs/core-testing/LinHES-config/ir_config.sh b/abs/core-testing/LinHES-config/ir_config.sh
index d059ddb..f4c99b9 100644
--- a/abs/core-testing/LinHES-config/ir_config.sh
+++ b/abs/core-testing/LinHES-config/ir_config.sh
@@ -11,6 +11,19 @@ function include_lirc () {
 
 }
 
+function unload_all_lirc () {
+    sv stop lircd
+    killall -9 lircd
+    modprobe -r $(lsmod |grep ^lirc |awk '{print $1}')
+}
+
+function udev_trigger () {
+    udevadm settle
+    udevadm trigger
+    udevadm settle
+    udevadm trigger
+}
+
 
 
 function setup_ir_remote {
@@ -26,6 +39,11 @@ function setup_ir_remote {
             #make backup copy
             mv ${BASE}/etc/lircd.conf ${BASE}/etc/lircd.conf.`date +%Y-%m-%d-%H-%M`
             mv ${BASE}/etc/lircrc ${BASE}/etc/lircrc.`date +%Y-%m-%d-%H-%M`
+            if [ $HostBlasterType = pvr150 ]
+            then
+                Remotetype=hauppauge-blaster
+            fi
+
             cd $TEMPLATES/remotes/$Remotetype
             for i in lircd*
             do
@@ -54,8 +72,8 @@ function setup_ir_remote {
             then
                 ln -s /etc/lircrc /home/mythtv/.lircrc 2> /dev/null
             fi
-            echo "Sending hup to lircd"
-            sv hup lircd
+#             echo "Sending hup to lircd"
+#             sv hup lircd
             ;;
     esac
 
@@ -93,6 +111,8 @@ function setup_lcd () {
                 ;;
         xno_lcd) echo "disabling lcd"
                 sv down lcdd
+                #sometimes it doesn't want to die
+                killall -9 LCDd
                 load-modules-mythvantage.sh  UNLOAD LCD
                 sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage
                 daemon_remove="lcdd $daemon_remove"
@@ -141,15 +161,18 @@ function setup_lcd () {
 }
 
 function setup_blaster_proto () {
-    for i in `seq $Hostnumblaster`
-    do
-        TEMP=HostTransmitproto_$i
-        eval proto=\$${TEMP}
-        if [ -f $TEMPLATES/transmit/${proto}/lircd.conf ]
-        then
-            include_lirc  ${BASE}/etc/lircd.conf $TEMPLATES/transmit/${proto}/lircd.conf
-        fi
-    done
+    if [ ! $HostBlasterType = pvr150 -a ! $HostBlasterType = None ]
+    then
+        for i in `seq $Hostnumblaster`
+        do
+            TEMP=HostTransmitproto_$i
+            eval proto=\$${TEMP}
+            if [ -f $TEMPLATES/transmit/${proto}/lircd.conf ]
+            then
+                include_lirc  ${BASE}/etc/lircd.conf $TEMPLATES/transmit/${proto}/lircd.conf
+            fi
+        done
+    fi
     #--------------------------------REVISIT THIS------------------------
         #sed -e "s/^REMOTE_NAME=.*$/REMOTE_NAME=${Blastertype} /" $TEMPLATES/change_chan.sh > #${BASE}/usr/bin/change_chan.sh
         #chmod 755 ${BASE}/usr/bin/change_chan.sh
@@ -162,15 +185,20 @@ function setup_blaster_transmiter () {
     if [ ! x$HostBlasterType = xReceiver ]
     then
         case $HostBlasterType in
+            None) echo "no blaster"
+                  sed -i -e '/.*#blaster/d' ${BASE}/etc/modules.mythvantage
+                  ;;
             Serial) echo "setup serial lirc blaster"
                     sed -i -e '/.*#blaster/d' ${BASE}/etc/modules.mythvantage
                     echo "lirc_serial   #blaster" >> ${BASE}/etc/modules.mythvantage
                     load-modules-mythvantage.sh
                     ;;
-            Hauppauge) echo "setup hauppauge blaster (lirc_i2c)"
+            pvr150) echo "setup hauppauge blaster (lirc_pvr150)"
                     sed -i -e '/.*#blaster/d' ${BASE}/etc/modules.mythvantage
-                    echo "lirc_i2c   #blaster" >> ${BASE}/etc/modules.mythvantage
-                    cp_and_log $TEMPLATES/modules/lirc_i2c.conf ${BASE}/etc/modprobe.d/lirc_i2c.conf
+                    sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+                    echo "lirc_pvr150   #blaster" >> ${BASE}/etc/modules.mythvantage
+                    echo "lirc_pvr150   #lirc" >> ${BASE}/etc/modules.mythvantage
+                    #cp_and_log $TEMPLATES/modules/lirc_i2c.conf ${BASE}/etc/modprobe.d/lirc_i2c.conf
                     rmmod lirc_i2c 2>/dev/null
                     load-modules-mythvantage.sh
                     ;;
@@ -186,8 +214,15 @@ function setupir () {
    then
         setup_ir_remote
         setup_ir_receiver
+        unload_all_lirc
         setup_blaster_proto
         setup_blaster_transmiter
+        RESTART_FE="true"
+        load-modules-mythvantage.sh
+        udev_trigger
+        sleep 1
+        sv start lircd
+
     fi
     setup_lcd
 }
\ No newline at end of file
diff --git a/abs/core-testing/LinHES-config/systemconfig.sh b/abs/core-testing/LinHES-config/systemconfig.sh
index 72c5287..6b7f26d 100755
--- a/abs/core-testing/LinHES-config/systemconfig.sh
+++ b/abs/core-testing/LinHES-config/systemconfig.sh
@@ -185,33 +185,33 @@ fi
 }
 
 
-function setupreceiver {
-case $ReceiverType in
-    tinker) echo "do nothing"
-            ;;
-    Serial) echo "setup serial lirc"
-            sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
-            echo "lirc_serial   #lirc" >> ${BASE}/etc/modules.mythvantage
-            load-modules-mythvantage.sh
-            ;;
-    Usb-imon) echo "setup receiver-usb-imon"
-            sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
-            echo "lirc_imon     #lirc" >> ${BASE}/etc/modules.mythvantage
-            load-modules-mythvantage.sh
-            ;;
-Hauppauge) echo "setup hauppauge reciever (lirc_i2c)"
-            sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
-            echo "lirc_i2c   #lirc" >> ${BASE}/etc/modules.mythvantage
-            cp_and_log $TEMPLATES/modules/lirc_i2c.conf ${BASE}/etc/modprobe.d/lirc_i2c.conf
-            rmmod lirc_i2c 2>/dev/null
-            load-modules-mythvantage.sh
-            ;;
-        *)   sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
-            ;;
-    esac
-
-
-}
+# function setupreceiver {
+# case $ReceiverType in
+#     tinker) echo "do nothing"
+#             ;;
+#     Serial) echo "setup serial lirc"
+#             sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+#             echo "lirc_serial   #lirc" >> ${BASE}/etc/modules.mythvantage
+#             load-modules-mythvantage.sh
+#             ;;
+#     Usb-imon) echo "setup receiver-usb-imon"
+#             sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+#             echo "lirc_imon     #lirc" >> ${BASE}/etc/modules.mythvantage
+#             load-modules-mythvantage.sh
+#             ;;
+# Hauppauge) echo "setup hauppauge reciever (lirc_i2c)"
+#             sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+#             echo "lirc_i2c   #lirc" >> ${BASE}/etc/modules.mythvantage
+#             cp_and_log $TEMPLATES/modules/lirc_i2c.conf ${BASE}/etc/modprobe.d/lirc_i2c.conf
+#             rmmod lirc_i2c 2>/dev/null
+#             load-modules-mythvantage.sh
+#             ;;
+#         *)   sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage
+#             ;;
+#     esac
+#
+#
+# }
 
 
 function setupevrouter {
-- 
cgit v0.12

