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

Revision 644, 3.6 kB (checked in by ppalmers, 15 years ago)

- Adapt the phase 88 mixer control application to the new DBUS control interface

Line 
1 #!/usr/bin/python
2 #
3
4 from qt import *
5 from mixer_phase88ui import *
6 import sys
7
8 SupportedDevices=[
9     [(0x000aac, 0x00000003),'Phase88Control'],
10     ]
11
12 class ControlInterface:
13     def __init__(self, servername, basepath):
14         self.basepath=basepath
15         self.servername=servername
16         self.bus=dbus.SessionBus()
17            
18     def setContignuous(self, subpath, v):
19         path = self.basepath + subpath
20         dev = self.bus.get_object(self.servername, path)
21         dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Continuous')
22         dev_cont.setValue(v)
23            
24     def getContignuous(self, subpath):
25         path = self.basepath + subpath
26         dev = self.bus.get_object(self.servername, path)
27         dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Continuous')
28         return dev_cont.getValue()       
29    
30     def setDiscrete(self, subpath, v):
31         path = self.basepath + subpath
32         dev = self.bus.get_object(self.servername, path)
33         dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Discrete')
34         dev_cont.setValue(v)
35            
36     def getDiscrete(self, subpath):
37         path = self.basepath + subpath
38         dev = self.bus.get_object(self.servername, path)
39         dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Discrete')
40         return dev_cont.getValue()       
41
42 class DeviceManagerInterface:
43     def __init__(self, servername, basepath):
44         self.basepath=basepath + '/DeviceManager'
45         self.servername=servername
46         self.bus=dbus.SessionBus()
47         self.dev = self.bus.get_object(self.servername, self.basepath)
48         self.iface = dbus.Interface(self.dev, dbus_interface='org.ffado.Control.Element.Container')
49            
50     def getNbDevices(self):
51         return self.iface.getNbElements()
52     def getDeviceName(self, idx):
53         return self.iface.getElementName(idx) 
54
55 class ConfigRomInterface:
56     def __init__(self, servername, devicepath):
57         self.basepath=devicepath + '/ConfigRom'
58         self.servername=servername
59         self.bus=dbus.SessionBus()
60         self.dev = self.bus.get_object(self.servername, self.basepath)
61         self.iface = dbus.Interface(self.dev, dbus_interface='org.ffado.Control.Element.ConfigRomX')
62     def getGUID(self):
63         return self.iface.getGUID()
64     def getVendorName(self):
65         return self.iface.getVendorName()
66     def getModelName(self):
67         return self.iface.getModelName()
68     def getVendorId(self):
69         return self.iface.getVendorId()
70     def getModelId(self):
71         return self.iface.getModelId()
72    
73
74 if __name__ == "__main__":
75    
76     server='org.ffado.Control'
77     basepath='/org/ffado/Control'
78    
79     app = QApplication(sys.argv)
80    
81     devmgr=DeviceManagerInterface(server, basepath)
82     nbDevices=devmgr.getNbDevices()
83    
84     for idx in range(nbDevices):
85         path=devmgr.getDeviceName(idx)
86         print "Found device %d: %s" % (idx, path)
87        
88         cfgrom=ConfigRomInterface(server, basepath+'/DeviceManager/'+path)
89         vendorId=cfgrom.getVendorId()
90         modelId=cfgrom.getModelId()
91        
92         print "Found (%X, %X) %s %s" % (vendorId, modelId, cfgrom.getVendorName() , cfgrom.getModelName())
93        
94         thisdev=(vendorId, modelId);
95        
96         for dev in SupportedDevices:
97             if dev[0]==thisdev:
98                 print dev[1]
99                 exec('f='+dev[1]+'()')
100                 f.hw=ControlInterface(server, basepath+'/DeviceManager/'+path)
101                 f.initValues()
102                 f.show()
103    
104     app.setMainWidget(f)
105     app.exec_loop()
Note: See TracBrowser for help on using the browser.