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

Revision 963, 9.0 kB (checked in by ppalmers, 16 years ago)

- add clock source control to all panels that don't have it yet
- fix saffire (LE) detection bug

Line 
1 #
2 # Copyright (C) 2005-2008 by Pieter Palmers
3 #
4 # This file is part of FFADO
5 # FFADO = Free Firewire (pro-)audio drivers for linux
6 #
7 # FFADO is based upon FreeBoB.
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 2 of the License, or
12 # (at your option) version 3 of the License.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 #
22
23 from qt import *
24 from mixer_saffireui import *
25
26 class SaffireMixer(SaffireMixerUI):
27     def __init__(self,parent = None,name = None,modal = 0,fl = 0):
28         SaffireMixerUI.__init__(self,parent,name,modal,fl)
29
30     def init(self):
31             print "Init Saffire mixer window"
32
33             self.VolumeControls={
34                     self.sldPC12Out12: ['/Mixer/PCMix', 0, 0],
35                     self.sldPC12Out34: ['/Mixer/PCMix', 0, 1],
36                     self.sldPC12Out56: ['/Mixer/PCMix', 0, 2],
37                     self.sldPC12Out78: ['/Mixer/PCMix', 0, 3],
38                     self.sldPC12Out910: ['/Mixer/PCMix', 0, 4],
39                     self.sldPC34Out12: ['/Mixer/PCMix', 1, 0],
40                     self.sldPC34Out34: ['/Mixer/PCMix', 1, 1],
41                     self.sldPC34Out56: ['/Mixer/PCMix', 1, 2],
42                     self.sldPC34Out78: ['/Mixer/PCMix', 1, 3],
43                     self.sldPC34Out910: ['/Mixer/PCMix', 1, 4],
44                     self.sldPC56Out12: ['/Mixer/PCMix', 2, 0],
45                     self.sldPC56Out34: ['/Mixer/PCMix', 2, 1],
46                     self.sldPC56Out56: ['/Mixer/PCMix', 2, 2],
47                     self.sldPC56Out78: ['/Mixer/PCMix', 2, 3],
48                     self.sldPC56Out910: ['/Mixer/PCMix', 2, 4],
49                     self.sldPC78Out12: ['/Mixer/PCMix', 3, 0],
50                     self.sldPC78Out34: ['/Mixer/PCMix', 3, 1],
51                     self.sldPC78Out56: ['/Mixer/PCMix', 3, 2],
52                     self.sldPC78Out78: ['/Mixer/PCMix', 3, 3],
53                     self.sldPC78Out910: ['/Mixer/PCMix', 3, 4],
54                     self.sldPC910Out12: ['/Mixer/PCMix', 4, 0],
55                     self.sldPC910Out34: ['/Mixer/PCMix', 4, 1],
56                     self.sldPC910Out56: ['/Mixer/PCMix', 4, 2],
57                     self.sldPC910Out78: ['/Mixer/PCMix', 4, 3],
58                     self.sldPC910Out910: ['/Mixer/PCMix', 4, 4],
59                     self.sldIN1Out1: ['/Mixer/InputMix', 0, 0],
60                     self.sldIN1Out3: ['/Mixer/InputMix', 0, 2],
61                     self.sldIN1Out5: ['/Mixer/InputMix', 0, 4],
62                     self.sldIN1Out7: ['/Mixer/InputMix', 0, 6],
63                     self.sldIN1Out9: ['/Mixer/InputMix', 0, 8],
64                     self.sldIN2Out2: ['/Mixer/InputMix', 1, 1],
65                     self.sldIN2Out4: ['/Mixer/InputMix', 1, 3],
66                     self.sldIN2Out6: ['/Mixer/InputMix', 1, 5],
67                     self.sldIN2Out8: ['/Mixer/InputMix', 1, 7],
68                     self.sldIN2Out10: ['/Mixer/InputMix', 1, 9],
69                     self.sldIN3Out1: ['/Mixer/InputMix', 2, 0],
70                     self.sldIN3Out3: ['/Mixer/InputMix', 2, 2],
71                     self.sldIN3Out5: ['/Mixer/InputMix', 2, 4],
72                     self.sldIN3Out7: ['/Mixer/InputMix', 2, 6],
73                     self.sldIN3Out9: ['/Mixer/InputMix', 2, 8],
74                     self.sldIN4Out2: ['/Mixer/InputMix', 3, 1],
75                     self.sldIN4Out4: ['/Mixer/InputMix', 3, 3],
76                     self.sldIN4Out6: ['/Mixer/InputMix', 3, 5],
77                     self.sldIN4Out8: ['/Mixer/InputMix', 3, 7],
78                     self.sldIN4Out10: ['/Mixer/InputMix', 3, 9],
79                     self.sldREV1Out1: ['/Mixer/InputMix', 4, 0],
80                     self.sldREV1Out3: ['/Mixer/InputMix', 4, 2],
81                     self.sldREV1Out5: ['/Mixer/InputMix', 4, 4],
82                     self.sldREV1Out7: ['/Mixer/InputMix', 4, 6],
83                     self.sldREV1Out9: ['/Mixer/InputMix', 4, 8],
84                     self.sldREV2Out2: ['/Mixer/InputMix', 5, 1],
85                     self.sldREV2Out4: ['/Mixer/InputMix', 5, 3],
86                     self.sldREV2Out6: ['/Mixer/InputMix', 5, 5],
87                     self.sldREV2Out8: ['/Mixer/InputMix', 5, 7],
88                     self.sldREV2Out10: ['/Mixer/InputMix', 5, 9],
89                     }
90
91
92             self.SelectorControls={
93                     self.chkSpdifSwitch:    ['/Mixer/SpdifSwitch'],
94                     self.chkOut12Mute:      ['/Mixer/Out12Mute'],
95                     self.chkOut12HwCtrl:    ['/Mixer/Out12HwCtrl'],
96                     self.chkOut12Dim:       ['/Mixer/Out12Dim'],
97                     self.chkOut34Mute:      ['/Mixer/Out34Mute'],
98                     self.chkOut34HwCtrl:    ['/Mixer/Out34HwCtrl'],
99                     self.chkOut56Mute:      ['/Mixer/Out56Mute'],
100                     self.chkOut56HwCtrl:    ['/Mixer/Out56HwCtrl'],
101                     self.chkOut78Mute:      ['/Mixer/Out78Mute'],
102                     self.chkOut78HwCtrl:    ['/Mixer/Out78HwCtrl'],
103                     self.chkOut910Mute:     ['/Mixer/Out910Mute'],
104                     }
105
106             self.VolumeControlsLowRes={
107                     self.sldOut12Level:      ['/Mixer/Out12Level'],
108                     self.sldOut34Level:      ['/Mixer/Out34Level'],
109                     self.sldOut56Level:      ['/Mixer/Out56Level'],
110                     self.sldOut78Level:      ['/Mixer/Out78Level'],
111                     }
112
113     def updateMatrixVolume(self,a0):
114         sender = self.sender()
115         vol = 0x7FFF-a0
116         print "set %s %d %d to %d" % (
117                     self.VolumeControls[sender][0],
118                     self.VolumeControls[sender][1],
119                     self.VolumeControls[sender][2],
120                     vol)
121         self.hw.setMatrixMixerValue(self.VolumeControls[sender][0],
122                                     self.VolumeControls[sender][1],
123                                     self.VolumeControls[sender][2],
124                                     vol)
125     def updateLowResVolume(self,a0):
126         sender = self.sender()
127         vol = a0
128         print "set %s to %d" % (
129                     self.VolumeControlsLowRes[sender][0],
130                     vol)
131         self.hw.setDiscrete(self.VolumeControlsLowRes[sender][0], vol)
132
133     def updateSelector(self,a0):
134         sender = self.sender()
135         if a0:
136             state = 1
137         else:
138             state = 0
139         print "set %s to %d" % (
140                     self.SelectorControls[sender][0],
141                     state)
142         self.hw.setDiscrete(self.SelectorControls[sender][0], state)
143
144     def updateClockSelection(self,a0):
145         #disable the combobox
146         self.comboClockSelect.setEnabled(False)
147         #change the clock source
148         self.clockselect.select(a0)
149         #refresh the clock source selection box
150         self.initClockSelector()
151         #make the box available again
152         self.comboClockSelect.setEnabled(True)
153
154     def initClockSelector(self):
155         self.comboClockSelect.clear()
156         nbsources = self.clockselect.count()
157         for idx in range(nbsources):
158             desc = self.clockselect.getEnumLabel(idx)
159             self.comboClockSelect.insertItem(desc)
160         active_idx = self.clockselect.selected();
161         if active_idx >= 0:
162             self.comboClockSelect.setCurrentItem(active_idx)
163
164     def initValues(self):
165         for ctrl, info in self.VolumeControls.iteritems():
166             vol = self.hw.getMatrixMixerValue(self.VolumeControls[ctrl][0],
167                                               self.VolumeControls[ctrl][1],
168                                               self.VolumeControls[ctrl][2])
169
170             print "%s volume is %d" % (ctrl.name() , 0x7FFF-vol)
171             ctrl.setValue(0x7FFF-vol)
172
173             # connect the UI element
174             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateMatrixVolume)
175
176         for ctrl, info in self.VolumeControlsLowRes.iteritems():
177             vol = self.hw.getDiscrete(self.VolumeControlsLowRes[ctrl][0])
178
179             print "%s volume is %d" % (ctrl.name() , vol)
180             ctrl.setValue(vol)
181
182             # connect the UI element
183             QObject.connect(ctrl,SIGNAL('valueChanged(int)'),self.updateLowResVolume)
184
185         for ctrl, info in self.SelectorControls.iteritems():
186             state = self.hw.getDiscrete(self.SelectorControls[ctrl][0])
187             print "%s state is %d" % (ctrl.name() , state)
188             if state:
189                 ctrl.setChecked(True)
190             else:
191                 ctrl.setChecked(False)
192
193             # connect the UI element
194             QObject.connect(ctrl,SIGNAL('stateChanged(int)'),self.updateSelector)
195
196         self.initClockSelector()
197         # connect the clock selector UI element
198         QObject.connect(self.comboClockSelect, SIGNAL('activated(int)'), self.updateClockSelection)
Note: See TracBrowser for help on using the browser.