root/trunk/libffado/src/bebob/focusrite/focusrite_generic.h

Revision 1742, 7.4 kB (checked in by arnonym, 14 years ago)

Extend the interface of the MatrixMixer?:

  • Have booleans indicating if names and/or connections are supported. These functions are pure virtual.
  • Allow names and connections to be read and written, the default implementations of these (not anymore pure) virtual functions do nothing and return false or nothing.
Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
3  * Copyright (C) 2005-2008 by Pieter Palmers
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 2 of the License, or
13  * (at your option) version 3 of the License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #ifndef BEBOB_FOCUSRITE_GENERIC_DEVICE_H
26 #define BEBOB_FOCUSRITE_GENERIC_DEVICE_H
27
28 #include "debugmodule/debugmodule.h"
29 #include "bebob/bebob_avdevice.h"
30
31 #include "libcontrol/BasicElements.h"
32 #include "libcontrol/MatrixMixer.h"
33
34 #include "libutil/SystemTimeSource.h"
35
36 #define FR_PARAM_SPACE_START 0x000100000000LL
37
38 namespace BeBoB {
39 namespace Focusrite {
40
41 class FocusriteDevice;
42
43 class BinaryControl
44     : public Control::Discrete
45 {
46 public:
47     BinaryControl(FocusriteDevice& parent, int id, int bit);
48     BinaryControl(FocusriteDevice& parent, int id, int bit,
49                   std::string name, std::string label, std::string descr);
50
51     virtual bool setValue(int v);
52     virtual int getValue();
53     virtual bool setValue(int idx, int v)
54         {return setValue(v);};
55     virtual int getValue(int idx)
56         {return getValue();};
57
58     virtual int getMinimum() {return 0;};
59     virtual int getMaximum() {return 1;};
60
61 private:
62     FocusriteDevice&        m_Parent;
63     unsigned int            m_cmd_id;
64     unsigned int            m_cmd_bit;
65 };
66
67 class VolumeControl
68     : public Control::Discrete
69 {
70 public:
71     VolumeControl(FocusriteDevice& parent, int id);
72     VolumeControl(FocusriteDevice& parent, int id,
73                   std::string name, std::string label, std::string descr);
74
75     virtual bool setValue(int v);
76     virtual int getValue();
77     virtual bool setValue(int idx, int v)
78         {return setValue(v);};
79     virtual int getValue(int idx)
80         {return getValue();};
81
82     virtual int getMinimum() {return 0;};
83     virtual int getMaximum() {return 0x07FFF;};
84
85 private:
86     FocusriteDevice&        m_Parent;
87     unsigned int            m_cmd_id;
88 };
89
90 class MeteringControl
91     : public Control::Discrete
92 {
93 public:
94     MeteringControl(FocusriteDevice& parent, int id);
95     MeteringControl(FocusriteDevice& parent, int id,
96                   std::string name, std::string label, std::string descr);
97    
98     virtual bool setValue(int v) {return false;};
99     virtual int getValue();
100     virtual bool setValue(int idx, int v)
101         {return setValue(v);};
102     virtual int getValue(int idx)
103         {return getValue();};
104
105     virtual int getMinimum() {return 0;};
106     virtual int getMaximum() {return 0x07FFF;};
107 private:
108     FocusriteDevice&        m_Parent;
109     unsigned int            m_cmd_id;
110 };
111
112 class RegisterControl
113     : public Control::Register
114 {
115 public:
116     RegisterControl(FocusriteDevice& parent);
117     RegisterControl(FocusriteDevice& parent,
118                     std::string name, std::string label, std::string descr);
119
120     virtual bool setValue(uint64_t addr, uint64_t value);
121     virtual uint64_t getValue(uint64_t addr);
122
123 private:
124     FocusriteDevice&        m_Parent;
125 };
126
127 class VolumeControlLowRes
128     : public Control::Discrete
129 {
130 public:
131     VolumeControlLowRes(FocusriteDevice& parent, int id, int shift);
132     VolumeControlLowRes(FocusriteDevice& parent, int id, int shift,
133                   std::string name, std::string label, std::string descr);
134    
135     virtual bool setValue(int v);
136     virtual int getValue();
137     virtual bool setValue(int idx, int v)
138         {return setValue(v);};
139     virtual int getValue(int idx)
140         {return getValue();};
141
142     virtual int getMinimum() {return 0;};
143     virtual int getMaximum() {return 0x0FF;};
144 private:
145     FocusriteDevice&        m_Parent;
146     unsigned int            m_cmd_id;
147     unsigned int            m_bit_shift;
148 };
149
150 class DialPositionControl
151     : public Control::Discrete
152 {
153 public:
154     DialPositionControl(FocusriteDevice& parent, int id, int shift);
155     DialPositionControl(FocusriteDevice& parent, int id, int shift,
156                         std::string name, std::string label, std::string descr);
157    
158     virtual bool setValue(int v) {return false;};
159     virtual int getValue();
160     virtual bool setValue(int idx, int v)
161         {return setValue(v);};
162     virtual int getValue(int idx)
163         {return getValue();};
164
165     virtual int getMinimum() {return 0;};
166     virtual int getMaximum() {return 0x07FFF;};
167 private:
168     FocusriteDevice&        m_Parent;
169     unsigned int            m_cmd_id;
170     int                     m_shift;
171 };
172
173 class FocusriteMatrixMixer : public Control::MatrixMixer
174 {
175 public:
176     FocusriteMatrixMixer(FocusriteDevice& parent);
177     FocusriteMatrixMixer(FocusriteDevice& parent, std::string n);
178     virtual ~FocusriteMatrixMixer() {};
179
180     virtual void show();
181
182     virtual int getRowCount( );
183     virtual int getColCount( );
184
185     virtual int canWrite( const int, const int );
186     virtual double setValue( const int, const int, const double );
187     virtual double getValue( const int, const int );
188
189     // full map updates are unsupported
190     virtual bool getCoefficientMap(int &) {return false;};
191     virtual bool storeCoefficientMap(int &) {return false;};
192
193     bool hasNames() const { return true; }
194     virtual std::string getRowName( const int );
195     virtual std::string getColName( const int );
196
197     bool canConnect() const { return false; }
198
199 protected:
200     struct sSignalInfo {
201         std::string name;
202         std::string label;
203         std::string description;
204     };
205     struct sCellInfo {
206         int row;
207         int col;
208         // indicates whether a cell can be valid, this
209         // doesn't mean that it is writable. Just that it can be.
210         bool valid;
211         // the address to use when manipulating this cell
212         int address;
213     };
214    
215     virtual void init() = 0;
216     virtual void addSignalInfo(std::vector<struct sSignalInfo> &target,
217                        std::string name, std::string label, std::string descr);
218     virtual void setCellInfo(int row, int col, int addr, bool valid);
219
220     std::vector<struct sSignalInfo> m_RowInfo;
221     std::vector<struct sSignalInfo> m_ColInfo;
222     std::vector< std::vector<struct sCellInfo> > m_CellInfo;
223    
224     FocusriteDevice&        m_Parent;
225 };
226
227 class FocusriteDevice : public BeBoB::Device {
228 public:
229     FocusriteDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ));
230     virtual ~FocusriteDevice() {};
231
232     virtual void showDevice();
233     virtual void setVerboseLevel(int l);
234
235 public:
236     bool setSpecificValue(uint32_t id, uint32_t v);
237     bool getSpecificValue(uint32_t id, uint32_t *v);
238
239 protected:
240     int convertDefToSr( uint32_t def );
241     uint32_t convertSrToDef( int sr );
242
243 private:
244     bool setSpecificValueAvc(uint32_t id, uint32_t v);
245     bool getSpecificValueAvc(uint32_t id, uint32_t *v);
246
247     bool setSpecificValueARM(uint32_t id, uint32_t v);
248     bool getSpecificValueARM(uint32_t id, uint32_t *v);
249
250 protected:
251     ffado_microsecs_t m_cmd_time_interval;
252     ffado_microsecs_t m_earliest_next_cmd_time;
253 };
254
255 } // namespace Focusrite
256 } // namespace BeBoB
257
258 #endif
Note: See TracBrowser for help on using the browser.