summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xabs/core/LinHES-config/PKGBUILD7
-rw-r--r--[-rwxr-xr-x]abs/core/LinHES-config/autocard.py737
-rwxr-xr-xabs/core/LinHES-config/udev_link.sh33
3 files changed, 508 insertions, 269 deletions
diff --git a/abs/core/LinHES-config/PKGBUILD b/abs/core/LinHES-config/PKGBUILD
index bd6b387..7c64fe2 100755
--- a/abs/core/LinHES-config/PKGBUILD
+++ b/abs/core/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
pkgname=LinHES-config
pkgver=2.3
-pkgrel=202
+pkgrel=204
conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev LinHes-config )
pkgdesc="Install and configure your system"
depends=('bc' 'libstatgrab' 'mysql-python' 'expect' 'curl' 'dnsutils' 'parted'
@@ -29,6 +29,7 @@ source=(mv_install.py 09_mythvantge_runit_grub
build_diskless.sh
networkconfig.sh
autocard.py
+ udev_link.sh
restore_km_db_chroot.sh
README
mv_advanced.py
@@ -85,6 +86,7 @@ build() {
install -m 0755 build_diskless.sh $MVDIR/bin/build_diskless.sh
install -m 0755 timezip.py $MVDIR/bin/timezip.py
install -m 0755 autocard.py $MVDIR/bin/autocard.py
+ install -m 0755 udev_link.sh $MVDIR/bin/udev_link.sh
install -m 0755 mv_config.py $MVDIR/bin/mv_config.py
install -m 0755 mv_install.py $MVDIR/bin/mv_install.py
install -m 0755 mv_advanced.py $MVDIR/bin/
@@ -148,7 +150,8 @@ md5sums=('26e20dba8d1bea96a07131ef945fd2f7'
'ab2aa42c2947148c2b1cac0ade6d1d55'
'd429b59d3cfb37b0624c6a4a71a7c2c0'
'f6a935c35123fdc7c259c01cbc794a64'
- '9151c74fcaf18ec4cf5e757cfdbc7017'
+ '656625c8fee50f5b1d8d29eaa80c5982'
+ 'd3490e93f313bbbcbc6c3693c56b9c17'
'3d1e4a119f38cff0498bf8a67e94e4b3'
'71fd2d0d448fc2fcd15415a1beed7109'
'c0549457750c4f8e8038d904a0f3012a'
diff --git a/abs/core/LinHES-config/autocard.py b/abs/core/LinHES-config/autocard.py
index f8bb173..eda2286 100755..100644
--- a/abs/core/LinHES-config/autocard.py
+++ b/abs/core/LinHES-config/autocard.py
@@ -5,298 +5,499 @@ import MySQLdb
import sys
import getopt
import socket
-import os
+import os , re
import time
import string
import glob
from string import letters
from string import digits
-def INSERTNULL_SOURCE(name,xmltvgrabber,userid,freqtable,lineupid,password,useeit):
- cursor = db.cursor()
- cursor.execute("INSERT INTO videosource(name,xmltvgrabber,userid,freqtable,lineupid,password,useeit) VALUES(%s,%s,%s,%s,%s,%s,%s);",(name,xmltvgrabber,userid,freqtable,lineupid,password,useeit))
-
-def INSERTCARD_INTOMYTH(Device,Driver,Cardvendor):
- global currenthostname
- print Device
- print Driver,
- print Cardvendor
- cursor = db.cursor()
- insert = "false"
- if Driver == "ivtv" :
- cardtype="MPEG"
- defaultinput="Tuner 1"
- insert="true"
- if Cardvendor == "pcHDTV HD3000 HDTV":
- insert="false"
- cardtype ="whocares"
-
- #print insert
- if insert == "true" :
- cursor.execute("INSERT INTO capturecard (videodevice,cardtype,defaultinput,hostname) VALUES(%s,%s,%s,%s);",(Device,cardtype,defaultinput,currenthostname))
-
-def INSERTHDR_INTOMYTH(deviceid,tuner_number):
- cardtype='HDHOMERUN'
- defaultinput='MPEG2TS'
- global currenthostname
- print deviceid
- print cardtype
- print defaultinput
- print tuner_number
- cursor = db.cursor()
- #print insert
- cursor.execute("INSERT INTO capturecard (videodevice,cardtype,defaultinput,dbox2_port ,hostname) VALUES(%s,%s,%s,%s,%s);",(deviceid,cardtype,defaultinput,tuner_number,currenthostname))
-
-def INSERTAUTOCARD():
- global cardlist
- global currenthostname
- # create a cursor
- cursor = db.cursor()
-
-
- for i in range( 1 , len(cardlist)):
- insert = "false"
-# print cardlist[i]
- Device=cardlist[i][0]
- Driver=cardlist[i][1]
- Cardvendor=cardlist[i][2]
- Businfo=cardlist[i][3]
- if Driver == "ivtv" :
- insert="true"
- devicestatus="unused"
- if Cardvendor == "pcHDTV HD3000 HDTV":
- insert="false"
- cardtype ="whocares"
- if Driver == "hdr":
- insert="true"
- devicestatus="unused"
-
- if insert == "true" :
- cursor.execute("delete from autocard where uniqid=%s;",(Businfo))
- if Driver=="hdr":
- Cardvendor="HDHOMERUN Tuner 1"
- cursor.execute("INSERT INTO autocard (dev,driver,description,uniqid,devicestatus,hostname) VALUES(%s,%s,%s,%s,%s,%s);",(Device,Driver,Cardvendor,Businfo,devicestatus,currenthostname))
- Cardvendor="HDHOMERUN Tuner 2"
- cursor.execute("INSERT INTO autocard (dev,driver,description,uniqid,devicestatus,hostname) VALUES(%s,%s,%s,%s,%s,%s);",(Device,Driver,Cardvendor,Businfo,devicestatus,currenthostname))
- else:
- cursor.execute("INSERT INTO autocard (dev,driver,description,uniqid,devicestatus,hostname) VALUES(%s,%s,%s,%s,%s,%s);",(Device,Driver,Cardvendor,Businfo,devicestatus,currenthostname))
-
-
-
-def PRINTINFO():
- global cardlist
-
- for list in cardlist:
- if list != "_placeholder_":
- print list
- #print "-------------"
-
-def GATHER_HDR():
- global cardlist
+class v4l_tuners():
+ def __init__(self, device):
+ self.device = device
+ self.full_attribs = self.find_full_attribs()
+ self.full_udev_attribs = self.find_full_udev_attribs()
+ self.description = self.find_description()
+ self.udev_props = self.parse_full_udev()
+ self.tuner_hash = self.find_tuner_hash()
+ self.udev_rule = self.create_udev_rule()
+
+ def find_full_attribs(self):
+ cmd = 'v4l2-ctl -D -d' + self.device
+ return os.popen(cmd).readlines()
+
+ def find_full_udev_attribs(self):
+ cmd = 'udevadm info -a -p $(udevadm info -q path -n %s)' %self.device
+ return os.popen(cmd).readlines()
+
+ def find_description(self):
+ for line in self.full_attribs:
+ #print line
+ pos = string.find(line,"Driver name")
+ if pos >=0:
+ splitline= line.split(':')
+ Driver=splitline[1].strip()
+ pos = string.find(line,"Card type")
+ if pos >=0:
+ splitline= line.split(':')
+ Cardtype=splitline[1].strip()
+
+ pos = string.find(line,"Bus info")
+ if pos >=0:
+ splitline= line.split(':',1)
+ Businfo=splitline[1].strip()
+ return Cardtype
+
+ def parse_full_udev(self):
+ udev_props = []
+ #ATTRS{serial}=="00A2023E"\n',
+ #SUBSYSTEMS=="usb"\n',
+ #SUBSYSTEM=="video4linux"\n',
+ #KERNELS=="0000:08:08.0"\n',
+ #DRIVERS=="hdpvr"\n'
+ #DRIVERS=="ivtv"\n',
+ #ATTR{index}=="0"
+ match = ['SUBSYSTEM',
+ 'SUBSYSTEMS',
+ 'DRIVERS',
+ 'KERNELS',
+ 'ATTRS{serial}',
+ 'ATTR{name}',
+ 'ATTR{index}'
+ ]
+
+ for item in match:
+ regex = re.compile('%s.*$' %item)
+ for line in self.full_udev_attribs:
+ m = regex.search(line.strip())
+ if m:
+ #print line
+ udev_props.append(line.strip())
+ break
+
+ #throw out kernels for usb subsystems.
+ if 'SUBSYSTEMS=="usb"' in udev_props:
+ #print "found usb"
+ new_udev_props=[]
+ for index, item in enumerate(udev_props):
+ #print item,index
+ if item.startswith("DRIVERS=="):
+ continue
+ elif item.startswith("KERNELS=="):
+ continue
+ else:
+ new_udev_props.append(item)
+ udev_props = new_udev_props
+
+
+ return udev_props
+
+ def is_hdpvr(self):
+ if self.description == "Hauppauge HD PVR":
+ return True
+ return False
+
+ def find_tuner_hash(self):
+ #tuner hash will be driven by card_type pci id and index
+ i=''
+ k=''
+ tuner_hash=''
+ card_type = self.get_card_type()
+ if card_type == "v4l_hdpvr":
+ for index, item in enumerate(self.udev_props):
+ if item.startswith("ATTRS{serial}=="):
+ hex_serial=item.split("==")[1].strip('''"''')
+ serial = int(hex_serial, 16)
+ tuner_hash="hdpvr_%s" %serial
+
+ else:
+ for index, item in enumerate(self.udev_props):
+ if item.startswith("KERNELS=="):
+ k=item.split("==")[1].strip('''"''')
+ k=k.replace(":", "_")
+ k=k.replace("0", "")
+ k=k.replace(".", "")
+
+ if item.startswith("ATTR{index}=="):
+ i=item.split("==")[1].strip('''"''')
+
+ tuner_hash="%s%s%s" %(card_type,k,i)
+
+ return tuner_hash
+
+ def escapeSpecialCharacters ( self, text, characters ):
+ for character in characters:
+ text = text.replace( character, '\\' + character )
+ return text
+
+ def create_udev_rule(self):
+ #DRIVERS=="ivtv", ATTR{name}=="ivtv? encoder MPG", KERNELS=="0000:08:09.0" SYMLINK+="myth/aivtv2"
+ line = ','.join(self.udev_props)
+ line += ' SYMLINK+="vstatic/%s"' %(self.get_tuner_hash())
+ return self.escapeSpecialCharacters(line,'[]')
+
+ def get_dev_node(self):
+ return self.device
+
+ def get_full_attribs(self):
+ return self.full_attribs
+
+ def get_full_udev_attribs(self):
+ return self.full_udev_attribs
+
+ def get_card_type(self):
+ if self.is_hdpvr() == True :
+ rc = "v4l_hdpvr"
+ else:
+ rc = "v4l"
+ return rc
+
+ def get_description(self):
+ return self.description
+
+ def get_udev_probs(self):
+ return self.udev_props
+
+ def get_tuner_hash(self):
+ return self.tuner_hash
+
+ def get_udev_rule(self):
+ return self.udev_rule
+
+#-----
+
+class hdhr_tuners():
+ def __init__(self, device):
+ self.device = device
+ self.description = self.find_description()
+
+ def find_description(self):
+ command = '/usr/bin/hdhomerun_config %s get /sys/model' %self.device
+ results=os.popen(command,'r')
+ return results.readline().strip()
+
+ def get_dev_node(self):
+ return self.device
+
+ def get_card_type(self):
+ return "hdhr"
+
+ def get_description(self):
+ return self.description
+
+ def get_udev_rule(self):
+ return
+#----------
+
+class dvb_tuners():
+ def __init__(self, device):
+ self.device = device
+ self.dvb_number = self.find_dvb_number()
+ self.description = self.find_description()
+ self.full_udev_attribs = self.find_full_udev_attribs()
+ self.udev_props = self.parse_full_udev()
+ self.tuner_hash = self.find_tuner_hash()
+ self.udev_rule = self.create_udev_rule()
+
+
+ def find_description(self):
+ command = '/usr/bin/dvb-fe-tool -g -a %s' %self.dvb_number
+ results=os.popen(command,'r')
+ line = results.readline().strip()
+ d = line.split('''(''')
+ return d[0]
+
+ def find_full_udev_attribs(self):
+ cmd = 'udevadm info -a -p $(udevadm info -q path -n %s)' %self.device
+ return os.popen(cmd).readlines()
+
+ def find_dvb_number(self):
+ #/dev/dvb/adapter2/frontend0
+ d=self.device.split("/")[3]
+ dvb_number=d.partition("adapter")[2]
+ return dvb_number
+
+ def parse_full_udev(self):
+ udev_props = ['KERNEL=="dvb?.frontend?"']
+ #ATTRS{serial}=="00A2023E"\n',
+ #SUBSYSTEMS=="usb"\n',
+ #SUBSYSTEM=="video4linux"\n',
+ #KERNELS=="0000:08:08.0"\n',
+ #DRIVERS=="hdpvr"\n'
+ #DRIVERS=="ivtv"\n',
+ #ATTR{index}=="0"
+ #KERNEL=="dvb1.frontend0"
+
+ match = ['SUBSYSTEM',
+ 'SUBSYSTEMS',
+ 'DRIVERS',
+ 'KERNELS',
+ 'ATTRS{serial}',
+ 'ATTR{name}',
+ 'ATTR{index}'
+ ]
+
+ for item in match:
+ regex = re.compile('%s.*$' %item)
+ for line in self.full_udev_attribs:
+ m = regex.search(line.strip())
+ if m:
+ #print line
+ udev_props.append(line.strip())
+ break
+
+ #throw out kernels for usb subsystems.
+ if 'SUBSYSTEMS=="usb"' in udev_props:
+ #print "found usb"
+ new_udev_props=[]
+ for index, item in enumerate(udev_props):
+ #print item,index
+ if item.startswith("DRIVERS=="):
+ continue
+ elif item.startswith("KERNELS=="):
+ continue
+ else:
+ new_udev_props.append(item)
+ udev_props = new_udev_props
+
+
+ return udev_props
+
+
+ def find_tuner_hash(self):
+ #tuner hash will be driven by card_type pci id and index
+ i=''
+ k=''
+ tuner_hash=''
+ card_type = self.get_card_type()
+ if card_type == "v4l_hdpvr":
+ for index, item in enumerate(self.udev_props):
+ if item.startswith("ATTRS{serial}=="):
+ hex_serial=item.split("==")[1].strip('''"''')
+ serial = int(hex_serial, 16)
+ tuner_hash="hdpvr_%s" %serial
+
+ else:
+ for index, item in enumerate(self.udev_props):
+ if item.startswith("KERNELS=="):
+ k=item.split("==")[1].strip('''"''')
+ k=k.replace(":", "_")
+ k=k.replace("0", "")
+ k=k.replace(".", "")
+
+ if item.startswith("ATTR{index}=="):
+ i=item.split("==")[1].strip('''"''')
+
+ tuner_hash="%s%s%s" %(card_type,k,i)
+
+ return tuner_hash
+
+ def escapeSpecialCharacters ( self, text, characters ):
+ for character in characters:
+ text = text.replace( character, '\\' + character )
+ return text
+
+ def create_udev_rule(self):
+ #ACTION=="add",KERNEL=="dvb?.frontend?",SUBSYSTEM=="dvb",SUBSYSTEMS=="pci",DRIVERS=="saa7164",KERNELS=="0000:05:00.0",RUN+="/tmp/udev_link.sh dvb_5 $env{DEVNAME}"
+ line = ','.join(self.udev_props)
+ line += ' RUN+="/usr/MythVantage/bin/udev_link.sh %s $env{DEVNAME} "' %(self.get_tuner_hash())
+ return self.escapeSpecialCharacters(line,'[]')
+
+ def get_dev_node(self):
+ return self.device
+
+ def get_card_type(self):
+ return "dvb"
+
+ def get_description(self):
+ return self.description
+
+ def get_full_udev_attribs(self):
+ return self.full_udev_attribs
+
+ def get_tuner_hash(self):
+ return self.tuner_hash
+
+ def get_udev_rule(self):
+ return self.udev_rule
+#------------
+
+
+
+def gather_hdhr(tuner_list):
command="/usr/bin/hdhomerun_config --discover"
results=os.popen(command,'r')
- line=results.readline()
- if line.strip().split()[0] == "no":
- print "HDHOMERUN not detected"
- else:
- print line
- hdrdevice=line.strip().split()[2]
- print hdrdevice
- Driver="hdr"
- Device=hdrdevice
- Cardtype="HDHOMERUN"
- Businfo=hdrdevice
- cardprops = [Device,Driver , Cardtype , Businfo]
- cardlist.append(cardprops)
-
-
-def GATHER_v4l_CARDS():
- global cardlist
- cardlist=["_placeholder_"]
- # print "Looking for v4l cards"
+ lines=results.readlines()
+ try:
+ if lines[0].strip().split()[0] == "no":
+ print "HDHOMERUN not detected"
+ else:
+ for line in lines:
+ hdrdevice=line.strip().split()[2]
+ tuner_list.append(hdhr_tuners(hdrdevice))
+ except:
+ print "Error finding HDHOMERUN"
+ return tuner_list
+
+def gather_v4l(tuner_list):
try:
- filelist = os.listdir('/dev/v4l/')
+ filelist = os.listdir('/dev/v4l/by-path/')
except OSError:
- filelist=" "
+ pass
#fakelist=['/dev/v4l/video3', 'ivtv', 'WinTV PVR 500 (unit #2)', '0000:04:09.0']
#cardlist.append(fakelist)
try:
- filelist = glob.glob("/dev/v4l/video?")
- Driver=""
- Cardtype=""
- Businfo=""
- numcards = 0
- for Device in filelist:
- #print card
- numcards = numcards+1
- cmd = 'v4l2-ctl -D -d' + Device
- for line in os.popen(cmd).readlines():
- #print line
- pos = string.find(line,"Driver name")
- if pos >=0:
- splitline= line.split(':')
- Driver=splitline[1].strip()
- pos = string.find(line,"Card type")
- if pos >=0:
- splitline= line.split(':')
- Cardtype=splitline[1].strip()
-
- pos = string.find(line,"Bus info")
- if pos >=0:
- splitline= line.split(':',1)
- Businfo=splitline[1].strip()
-
- #print Device,Driver , Cardtype , Businfo,numcards
- cardprops = [Device,Driver , Cardtype , Businfo]
- cardlist.append(cardprops)
+ p = re.compile('^/dev/video?\d$')
+ filelist = glob.glob("/dev/v4l/by-path/*video*")
+ for device in filelist:
+ Device=os.path.realpath(device)
+ if not p.search(Device):
+ continue
+ #print "real device node"
+ #print Device
+ tuner_list.append(v4l_tuners(Device))
except IOError:
- print "no v4l cards found"
- sys.exit(2)
-
-
-def WRITEUDEV_IVTV():
- global insertmyth
- cursor = db.cursor()
- #add ivtv,cid lookup loop through until empty.
- cursor.execute("select distinct(uniqid) from autocard where driver='ivtv' and devicestatus='will-add'")
- cidrows = cursor.fetchall()
- for row in cidrows:
- cid=row[0]
- cursor.execute("select dev,driver,description,devicestatus,hostname from autocard where uniqid=%s limit 1;",(cid))
- result = cursor.fetchone()
- description=result[2]
- driver='DRIVERS==\"ivtv\"'
- ATTRNAME='ATTR{name}=="ivtv? encoder MPG"'
- KERNELS='KERNELS==\"'
- KERNELS+=cid
- KERNELS+="\""
- #filter out non digit or chars
- keep=letters.join(digits)
- description=filter(lambda c: c in keep, description)
- devnode="ivtv/"
- #devnode+=description + "_"
- udevcid=cid.partition(":")
- devnode+=udevcid[2]
- devnode+="_video"
- UDEV_RULE=driver +', '+ATTRNAME+', '+ KERNELS +', ' + 'NAME=\"' + devnode + '"'
- print "Here is the udev rule"
- print UDEV_RULE
- filename='/etc/udev/rules.d/11-ivtv-'+cid+'.rules'
- file = open(filename,'w')
- file.write(UDEV_RULE)
- if ( insertmyth == "true"):
- devnode="/dev/"+devnode
- INSERTCARD_INTOMYTH(devnode,"ivtv",description)
- cursor.execute("update autocard set devicestatus='done' where uniqid=%s;",(cid))
-#now insert HDR
- cursor.execute("select distinct(uniqid),description from autocard where driver='hdr' and devicestatus='will-add'")
- cidrows = cursor.fetchall()
- for row in cidrows:
- if ( insertmyth == "true"):
- deviceid=row[0]
- #cardtype="HDHOMRUN"
- #defaultinput="MPEG2TS"
- dbox2_port=row[1]
- tuner_number=dbox2_port.rpartition(' ')[2]
- INSERTHDR_INTOMYTH(deviceid,tuner_number)
- cursor.execute("update autocard set devicestatus='done' where uniqid=%s and description=%s;",(deviceid,dbox2_port))
-
-
-
-def CLEARAUTOCARD():
- cursor = db.cursor()
- cursor.execute("delete from autocard")
-
-def RELOADUDEV():
- print "relaoding udev rules"
- os.system('udevcontrol reload_rules')
- os.system('rmmod ivtv')
- os.system('udevtrigger')
-
-
-def usage():
- print " -h help"
- print " -g gather and print out the found cards"
- print " -w write out the udev rules"
- print " -i insert cards into myth that are marked will-add(only used with -w)"
- print " -r reload udev rules"
- print " -c clear the autocard db"
-
-def main(argv):
- global db
- global cardlist
- global currenthostname
- currenthostname=""
- writeudev="false"
- global insertmyth
- insertmyth ="false"
-
- db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg")
- try:
- cursor = db.cursor()
- cursor.execute("describe autocard;")
- except MySQLdb.Error, e:
- cursor.execute("create table autocard(dev varchar(50),driver varchar(50),description varchar(50),uniqid varchar(50), devicestatus varchar(50),hostname varchar(50));")
- print "table created"
-
- if ( currenthostname == "" ):
- currenthostname = socket.gethostname()
+ print "no v4l cards found"
+ return tuner_list
+def gather_dvb(tuner_list):
try:
- opts, args = getopt.getopt(argv, "hgwircd", ["help", "gathercards", "writeudev" ,"insert" , "reloadudev" , "clearautocard"] )
- except getopt.GetoptError:
- sys.exit(2)
- for opt, arg in opts:
- if opt in ("-h", "--help"):
- usage()
- sys.exit()
- elif opt in ( "-g" , "--gathercards"):
- GATHER_v4l_CARDS()
- GATHER_HDR()
- INSERTAUTOCARD()
- PRINTINFO()
- elif opt in ("-w", "--writeudev"):
- writeudev="true"
- elif opt in ("-i", "--insert"):
- insertmyth="true"
- elif opt in ( "-r" , "--reloadudev"):
- RELOADUDEV()
- elif opt in ( "-c" , "--clearautocard"):
- CLEARAUTOCARD()
- elif opt in ( "-d" ):
- INSERTCARD_INTOMYTH("file:/myth/video/TripThe1939.mpeg","ivtv","Dummy tuner")
- INSERTNULL_SOURCE("dummy","/bin/true","","default","NULL","NULL","0")
-
- if ( writeudev == "true"):
- WRITEUDEV_IVTV()
-
-
-
-
+ filelist = os.listdir('/dev/dvb/')
+ except OSError:
+ pass
+ try:
+ for d in filelist:
+ if os.path.islink("/dev/dvb/"+d):
+ continue
+ Device=os.path.realpath("/dev/dvb/"+d+"/frontend0")
+ tuner_list.append(dvb_tuners(Device))
+ except:
+ print "no dvb cards found"
+ return tuner_list
+
+
+
+def gather_tuners():
+ tuner_list = []
+ tuner_list = gather_hdhr(tuner_list)
+ tuner_list = gather_v4l(tuner_list)
+ tuner_list = gather_dvb(tuner_list)
+ #tuner_list = gather_ceton(tuner_list)
+
+ #for i in tuner_list:
+ #if i.get_card_type() == "hdhr":
+ #pass
+ #print "hdhr : %s " %(i.get_dev_node())
+ #print "\t" , i.get_description()
+
+
+ #elif i.get_card_type() == "v4l":
+ #pass
+
+ #print "V4L : %s " %(i.get_dev_node())
+ #print "\t" , i.get_description()
+ ##print "\t" , i.get_udev_probs()
+ #print "\t" , i.get_tuner_hash()
+ ##print "\t" , i.get_udev_rule()
+ ##print "\t" , i.get_full_udev_attribs()
+
+
+ #elif i.get_card_type() == "v4l_hdpvr":
+ #pass
+ #print "hdpvr : %s " %(i.get_dev_node())
+ #print "\t" , i.get_description()
+ ##print "\t" , i.get_udev_probs()
+ #print "\t" , i.get_tuner_hash()
+ ##print "\t" , i.get_udev_rule()
+ ##print "\t" , i.get_full_udev_attribs()
+
+ #elif i.get_card_type() == "dvb":
+ #pass
+ #print "dvb : %s " %(i.get_dev_node())
+ #print "\t" , i.get_description()
+ #print "\t" , i.get_tuner_hash()
+ ##print "\t" , i.get_full_udev_attribs()
+ ##for y in i.get_full_udev_attribs():
+ ## print y
+ ##print "\t" , i.get_udev_rule()
+
+ #elif i.get_card_type() == "ceton":
+ #print "ceton : %s " %(i.get_dev_node())
+ #else:
+ #print i
+ return tuner_list
+
+
+def write_udev_file(rule_list):
+ udevfile = '/etc/udev/rules.d/99-mv-persistent-video.rules'
+ try:
+ f = open(udevfile, 'w')
+ line = "#Do not edit this file, it is auto generated by autocard.py \n\n"
+ f.write(line)
+ for rule in rule_list:
+ if rule:
+ line = "%s \n" %(rule)
+ f.write(line)
+ f.close()
+ except:
+ print "Error creating %s" %udevfile
+
+def write_udev_map(tuner_list):
+ udevfile = '/etc/udev/mv-persistent-video.description'
+ try:
+ f = open(udevfile, 'w')
+ line = "#Do not edit this file, it is auto generated by autocard.py \n"
+ f.write(line)
+ line = "#This file is used to generate the static tuner card web page\n"
+ f.write(line)
+ for i in tuner_list:
+ if i.get_card_type() == "hdhr":
+ pass
+ line="hdhr:%s:%s" %(i.get_description(),i.get_dev_node())
+ f.write(line)
+ f.write("\n")
+ elif i.get_card_type() == "v4l":
+ pass
+ line="V4L:%s:/dev/vstatic/%s " %(i.get_description(),i.get_tuner_hash())
+ f.write(line)
+ f.write("\n")
+ elif i.get_card_type() == "v4l_hdpvr":
+ pass
+ line="hdpvr:%s:/dev/vstatic/%s " %(i.get_description(),i.get_tuner_hash())
+ f.write(line)
+ f.write("\n")
+ elif i.get_card_type() == "dvb":
+ line="dvb:%s:/dev/dvb/adapter_static_%s " %(i.get_description(),i.get_tuner_hash())
+ f.write(line)
+ f.write("\n")
+ elif i.get_card_type() == "ceton":
+ line="ceton:%s:/dev/vstatic/%s " %(i.get_description(),i.get_tuner_hash())
+ f.write(line)
+ f.write("\n")
+ else:
+ print i
+ line = i
+ f.write(line)
+ f.write("\n")
+ except:
+ print "Error creating %s" %udevfile
+ f.close()
-if __name__ == "__main__":
- main(sys.argv[1:])
+def main(argv):
+ tuner_list = gather_tuners()
+ rule_list = []
+ for i in tuner_list:
+ rule_list.append(i.get_udev_rule())
-#mysql> create table autocard(dev varchar(50),driver varchar(50),description varchar(50),uniqid varchar(50), devicestatus varchar(50),hostname varchar(50));
-#Query OK, 0 rows affected (0.14 sec)
+ write_udev_file(rule_list)
+ write_udev_map(tuner_list)
-#mysql> describe autocard;
-#+--------------+-------------+------+-----+---------+-------+
-#| Field | Type | Null | Key | Default | Extra |
-#+--------------+-------------+------+-----+---------+-------+
-#| dev | varchar(50) | YES | | NULL | |
-#| driver | varchar(50) | YES | | NULL | |
-#| description | varchar(50) | YES | | NULL | |
-#| uniqid | varchar(50) | YES | | NULL | |
-#| devicestatus | varchar(50) | YES | | NULL | |
-#| hostname | varchar(50) | YES | | NULL | |
-#+--------------+-------------+------+-----+---------+-------+
@@ -304,4 +505,6 @@ if __name__ == "__main__":
+if __name__ == "__main__":
+ main(sys.argv[1:])
diff --git a/abs/core/LinHES-config/udev_link.sh b/abs/core/LinHES-config/udev_link.sh
new file mode 100755
index 0000000..ec8bdcf
--- /dev/null
+++ b/abs/core/LinHES-config/udev_link.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+my_base=$1
+dev_name=$2
+#DEVNAME=/dev/dvb/adapter2/frontend0
+#DVB_ADAPTER_NUM=2
+
+lndir=`dirname $dev_name`
+#for clink in `ls -d /dev/vstatic/dvb*`
+for clink in `ls -d /dev/dvb/adapter_*`
+do
+ if [ `readlink $clink` == $lndir ]
+ then
+ echo "link is already present $clink"
+ exit 0
+ fi
+
+done
+mkdir -p /dev/vstatic
+for i in 1 2 3 4
+do
+
+ #mydir="/dev/vstatic/${my_base}_$i"
+ mydir="/dev/dvb/adapter_static_${my_base}_$i"
+ if [ ! -e $mydir ]
+ then
+ ln -s $lndir $mydir
+ exit 0
+ else
+ echo "dvb dir already exists "
+ fi
+done
+exit 0
+