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

Revision 965, 5.0 kB (checked in by ppalmers, 15 years ago)

add generic register read for focusrite devices

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