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

Revision 1630, 7.3 kB (checked in by ppalmers, 12 years ago)

add base level support for the DICE EAP based mixers (incomplete)

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 std::string getRowName( const int );
183     virtual std::string getColName( const int );
184     virtual int canWrite( const int, const int );
185     virtual double setValue( const int, const int, const double );
186     virtual double getValue( const int, const int );
187     virtual int getRowCount( );
188     virtual int getColCount( );
189
190     // full map updates are unsupported
191     virtual bool getCoefficientMap(int &) {return false;};
192     virtual bool storeCoefficientMap(int &) {return false;};
193
194 protected:
195     struct sSignalInfo {
196         std::string name;
197         std::string label;
198         std::string description;
199     };
200     struct sCellInfo {
201         int row;
202         int col;
203         // indicates whether a cell can be valid, this
204         // doesn't mean that it is writable. Just that it can be.
205         bool valid;
206         // the address to use when manipulating this cell
207         int address;
208     };
209    
210     virtual void init() = 0;
211     virtual void addSignalInfo(std::vector<struct sSignalInfo> &target,
212                        std::string name, std::string label, std::string descr);
213     virtual void setCellInfo(int row, int col, int addr, bool valid);
214
215     std::vector<struct sSignalInfo> m_RowInfo;
216     std::vector<struct sSignalInfo> m_ColInfo;
217     std::vector< std::vector<struct sCellInfo> > m_CellInfo;
218    
219     FocusriteDevice&        m_Parent;
220 };
221
222 class FocusriteDevice : public BeBoB::Device {
223 public:
224     FocusriteDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ));
225     virtual ~FocusriteDevice() {};
226
227     virtual void showDevice();
228     virtual void setVerboseLevel(int l);
229
230 public:
231     bool setSpecificValue(uint32_t id, uint32_t v);
232     bool getSpecificValue(uint32_t id, uint32_t *v);
233
234 protected:
235     int convertDefToSr( uint32_t def );
236     uint32_t convertSrToDef( int sr );
237
238 private:
239     bool setSpecificValueAvc(uint32_t id, uint32_t v);
240     bool getSpecificValueAvc(uint32_t id, uint32_t *v);
241
242     bool setSpecificValueARM(uint32_t id, uint32_t v);
243     bool getSpecificValueARM(uint32_t id, uint32_t *v);
244
245 protected:
246     ffado_microsecs_t m_cmd_time_interval;
247     ffado_microsecs_t m_earliest_next_cmd_time;
248 };
249
250 } // namespace Focusrite
251 } // namespace BeBoB
252
253 #endif
Note: See TracBrowser for help on using the browser.