root/trunk/libffado/support/mixer/mixer.py

Revision 662, 4.7 kB (checked in by ppalmers, 16 years ago)

- introduce mixer control for the original saffire

Line 
1 #!/usr/bin/python
2 #
3
4 from qt import *
5 from mixer_phase88 import *
6 from mixer_phase24 import *
7 from mixer_saffirepro import *
8 from mixer_saffire import *
9 import sys
10 import dbus
11
12 SupportedDevices=[
13     [(0x000aac, 0x00000003),'Phase88Control'],
14     [(0x000aac, 0x00000004),'PhaseX24Control'],
15     [(0x000aac, 0x00000007),'PhaseX24Control'],
16     [(0x00130e, 0x00000003),'SaffireProMixer'],
17     [(0x00130e, 0x00000006),'SaffireProMixer'],
18     [(0x00130e, 0x00000000),'SaffireMixer'],
19     ]
20
21 class ControlInterface:
22     def __init__(self, servername, basepath):
23         self.basepath=basepath
24         self.servername=servername
25         self.bus=dbus.SessionBus()
26            
27     def setContignuous(self, subpath, v):
28         path = self.basepath + subpath
29         dev = self.bus.get_object(self.servername, path)
30         dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Continuous')
31         dev_cont.setValue(v)
32            
33     def getContignuous(self, subpath):
34         path = self.basepath + subpath
35         dev = self.bus.get_object(self.servername, path)
36         dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Continuous')
37         return dev_cont.getValue()       
38    
39     def setDiscrete(self, subpath, v):
40         path = self.basepath + subpath
41         dev = self.bus.get_object(self.servername, path)
42         dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Discrete')
43         dev_cont.setValue(v)
44            
45     def getDiscrete(self, subpath):
46         path = self.basepath + subpath
47         dev = self.bus.get_object(self.servername, path)
48         dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Discrete')
49         return dev_cont.getValue()
50
51     def setMatrixMixerValue(self, subpath, row, col, v):
52         path = self.basepath + subpath
53         dev = self.bus.get_object(self.servername, path)
54         dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.MatrixMixer')
55         dev_cont.setValue(row, col, v)
56
57     def getMatrixMixerValue(self, subpath, row, col):
58         path = self.basepath + subpath
59         dev = self.bus.get_object(self.servername, path)
60         dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.MatrixMixer')
61         return dev_cont.getValue(row, col)
62
63 class DeviceManagerInterface:
64     def __init__(self, servername, basepath):
65         self.basepath=basepath + '/DeviceManager'
66         self.servername=servername
67         self.bus=dbus.SessionBus()
68         self.dev = self.bus.get_object(self.servername, self.basepath)
69         self.iface = dbus.Interface(self.dev, dbus_interface='org.ffado.Control.Element.Container')
70            
71     def getNbDevices(self):
72         return self.iface.getNbElements()
73     def getDeviceName(self, idx):
74         return self.iface.getElementName(idx) 
75
76 class ConfigRomInterface:
77     def __init__(self, servername, devicepath):
78         self.basepath=devicepath + '/ConfigRom'
79         self.servername=servername
80         self.bus=dbus.SessionBus()
81         self.dev = self.bus.get_object(self.servername, self.basepath)
82         self.iface = dbus.Interface(self.dev, dbus_interface='org.ffado.Control.Element.ConfigRomX')
83     def getGUID(self):
84         return self.iface.getGUID()
85     def getVendorName(self):
86         return self.iface.getVendorName()
87     def getModelName(self):
88         return self.iface.getModelName()
89     def getVendorId(self):
90         return self.iface.getVendorId()
91     def getModelId(self):
92         return self.iface.getModelId()
93    
94
95 if __name__ == "__main__":
96    
97     server='org.ffado.Control'
98     basepath='/org/ffado/Control'
99    
100     app = QApplication(sys.argv)
101    
102     devmgr=DeviceManagerInterface(server, basepath)
103     nbDevices=devmgr.getNbDevices()
104    
105     forms=[];
106     for idx in range(nbDevices):
107         path=devmgr.getDeviceName(idx)
108         print "Found device %d: %s" % (idx, path)
109        
110         cfgrom=ConfigRomInterface(server, basepath+'/DeviceManager/'+path)
111         vendorId=cfgrom.getVendorId()
112         modelId=cfgrom.getModelId()
113        
114         print "Found (%X, %X) %s %s" % (vendorId, modelId, cfgrom.getVendorName() , cfgrom.getModelName())
115        
116         thisdev=(vendorId, modelId);
117        
118         for dev in SupportedDevices:
119             if dev[0]==thisdev:
120                 print dev[1]
121                 exec('forms.append('+dev[1]+'())')
122                 forms[idx].hw=ControlInterface(server, basepath+'/DeviceManager/'+path)
123                 forms[idx].initValues()
124                 forms[idx].show()
125                 app.setMainWidget(forms[idx])
126
127     if forms:
128         QObject.connect(app,SIGNAL("lastWindowClosed()"),app,SLOT("quit()"))
129
130         app.exec_loop()
131     else:
132         print "No supported device found..."
Note: See TracBrowser for help on using the browser.