root/branches/libffado-2.0/src/bebob/focusrite/focusrite_generic.h

Revision 1261, 5.7 kB (checked in by ppalmers, 16 years ago)

ensure proper behavior of the hardware control checkbox of the saffire on un-mute (fixes #135)

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 #define FR_PARAM_SPACE_START 0x000100000000LL
35
36 namespace BeBoB {
37 namespace Focusrite {
38
39 class FocusriteDevice;
40
41 class BinaryControl
42     : public Control::Discrete
43 {
44 public:
45     BinaryControl(FocusriteDevice& parent, int id, int bit);
46     BinaryControl(FocusriteDevice& parent, int id, int bit,
47                   std::string name, std::string label, std::string descr);
48
49     virtual bool setValue(int v);
50     virtual int getValue();
51     virtual bool setValue(int idx, int v)
52         {return setValue(v);};
53     virtual int getValue(int idx)
54         {return getValue();};
55
56     virtual int getMinimum() {return 0;};
57     virtual int getMaximum() {return 1;};
58
59 private:
60     FocusriteDevice&        m_Parent;
61     unsigned int            m_cmd_id;
62     unsigned int            m_cmd_bit;
63 };
64
65 class VolumeControl
66     : public Control::Discrete
67 {
68 public:
69     VolumeControl(FocusriteDevice& parent, int id);
70     VolumeControl(FocusriteDevice& parent, int id,
71                   std::string name, std::string label, std::string descr);
72
73     virtual bool setValue(int v);
74     virtual int getValue();
75     virtual bool setValue(int idx, int v)
76         {return setValue(v);};
77     virtual int getValue(int idx)
78         {return getValue();};
79
80     virtual int getMinimum() {return 0;};
81     virtual int getMaximum() {return 0x07FFF;};
82
83 private:
84     FocusriteDevice&        m_Parent;
85     unsigned int            m_cmd_id;
86 };
87
88 class RegisterControl
89     : public Control::Register
90 {
91 public:
92     RegisterControl(FocusriteDevice& parent);
93     RegisterControl(FocusriteDevice& parent,
94                     std::string name, std::string label, std::string descr);
95
96     virtual bool setValue(uint64_t addr, uint64_t value);
97     virtual uint64_t getValue(uint64_t addr);
98
99 private:
100     FocusriteDevice&        m_Parent;
101 };
102
103 class VolumeControlLowRes
104     : public Control::Discrete
105 {
106 public:
107     VolumeControlLowRes(FocusriteDevice& parent, int id, int shift);
108     VolumeControlLowRes(FocusriteDevice& parent, int id, int shift,
109                   std::string name, std::string label, std::string descr);
110    
111     virtual bool setValue(int v);
112     virtual int getValue();
113     virtual bool setValue(int idx, int v)
114         {return setValue(v);};
115     virtual int getValue(int idx)
116         {return getValue();};
117
118     virtual int getMinimum() {return 0;};
119     virtual int getMaximum() {return 0x0FF;};
120 private:
121     FocusriteDevice&        m_Parent;
122     unsigned int            m_cmd_id;
123     unsigned int            m_bit_shift;
124 };
125
126 class FocusriteMatrixMixer : public Control::MatrixMixer
127 {
128 public:
129     FocusriteMatrixMixer(FocusriteDevice& parent);
130     FocusriteMatrixMixer(FocusriteDevice& parent, std::string n);
131     virtual ~FocusriteMatrixMixer() {};
132
133     virtual void show();
134
135     virtual std::string getRowName( const int );
136     virtual std::string getColName( const int );
137     virtual int canWrite( const int, const int );
138     virtual double setValue( const int, const int, const double );
139     virtual double getValue( const int, const int );
140     virtual int getRowCount( );
141     virtual int getColCount( );
142
143 protected:
144     struct sSignalInfo {
145         std::string name;
146         std::string label;
147         std::string description;
148     };
149     struct sCellInfo {
150         int row;
151         int col;
152         // indicates whether a cell can be valid, this
153         // doesn't mean that it is writable. Just that it can be.
154         bool valid;
155         // the address to use when manipulating this cell
156         int address;
157     };
158    
159     virtual void init() = 0;
160     virtual void addSignalInfo(std::vector<struct sSignalInfo> &target,
161                        std::string name, std::string label, std::string descr);
162     virtual void setCellInfo(int row, int col, int addr, bool valid);
163
164     std::vector<struct sSignalInfo> m_RowInfo;
165     std::vector<struct sSignalInfo> m_ColInfo;
166     std::vector< std::vector<struct sCellInfo> > m_CellInfo;
167    
168     FocusriteDevice&        m_Parent;
169 };
170
171 class FocusriteDevice : public BeBoB::AvDevice {
172 public:
173     FocusriteDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ));
174     virtual ~FocusriteDevice() {};
175
176     virtual void showDevice();
177     virtual void setVerboseLevel(int l);
178
179 public:
180     bool setSpecificValue(uint32_t id, uint32_t v);
181     bool getSpecificValue(uint32_t id, uint32_t *v);
182
183 protected:
184     int convertDefToSr( uint32_t def );
185     uint32_t convertSrToDef( int sr );
186
187 private:
188     bool setSpecificValueAvc(uint32_t id, uint32_t v);
189     bool getSpecificValueAvc(uint32_t id, uint32_t *v);
190
191     bool setSpecificValueARM(uint32_t id, uint32_t v);
192     bool getSpecificValueARM(uint32_t id, uint32_t *v);
193 };
194
195 } // namespace Focusrite
196 } // namespace BeBoB
197
198 #endif
Note: See TracBrowser for help on using the browser.