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

Revision 750, 4.6 kB (checked in by ppalmers, 15 years ago)

Code refactoring. Tries to simplify things and tries to put all code where it belongs.

Line 
1 /*
2  * Copyright (C) 2005-2007 by Daniel Wagner
3  * Copyright (C) 2005-2007 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 3 of the License, or
13  * (at your option) any later version.
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 VolumeControlLowRes
75     : public Control::Discrete
76 {
77 public:
78     VolumeControlLowRes(FocusriteDevice& parent, int id, int shift);
79     VolumeControlLowRes(FocusriteDevice& parent, int id, int shift,
80                   std::string name, std::string label, std::string descr);
81    
82     virtual bool setValue(int v);
83     virtual int getValue();
84    
85 private:
86     FocusriteDevice&        m_Parent;
87     unsigned int            m_cmd_id;
88     unsigned int            m_bit_shift;
89 };
90
91 class FocusriteMatrixMixer : public Control::MatrixMixer
92 {
93 public:
94     FocusriteMatrixMixer(FocusriteDevice& parent);
95     FocusriteMatrixMixer(FocusriteDevice& parent, std::string n);
96     virtual ~FocusriteMatrixMixer() {};
97
98     virtual void show();
99
100     virtual std::string getRowName( const int );
101     virtual std::string getColName( const int );
102     virtual int canWrite( const int, const int );
103     virtual double setValue( const int, const int, const double );
104     virtual double getValue( const int, const int );
105     virtual int getRowCount( );
106     virtual int getColCount( );
107
108 protected:
109     struct sSignalInfo {
110         std::string name;
111         std::string label;
112         std::string description;
113     };
114     struct sCellInfo {
115         int row;
116         int col;
117         // indicates whether a cell can be valid, this
118         // doesn't mean that it is writable. Just that it can be.
119         bool valid;
120         // the address to use when manipulating this cell
121         int address;
122     };
123    
124     virtual void init() = 0;
125     virtual void addSignalInfo(std::vector<struct sSignalInfo> &target,
126                        std::string name, std::string label, std::string descr);
127     virtual void setCellInfo(int row, int col, int addr, bool valid);
128
129     std::vector<struct sSignalInfo> m_RowInfo;
130     std::vector<struct sSignalInfo> m_ColInfo;
131     std::vector< std::vector<struct sCellInfo> > m_CellInfo;
132    
133     FocusriteDevice&        m_Parent;
134 };
135
136 class FocusriteDevice : public BeBoB::AvDevice {
137 public:
138     FocusriteDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ));
139     virtual ~FocusriteDevice() {};
140
141     virtual void showDevice();
142     virtual void setVerboseLevel(int l);
143
144 public:
145     bool setSpecificValue(uint32_t id, uint32_t v);
146     bool getSpecificValue(uint32_t id, uint32_t *v);
147
148 protected:
149     int convertDefToSr( uint32_t def );
150     uint32_t convertSrToDef( int sr );
151
152 private:
153     bool setSpecificValueAvc(uint32_t id, uint32_t v);
154     bool getSpecificValueAvc(uint32_t id, uint32_t *v);
155
156     bool setSpecificValueARM(uint32_t id, uint32_t v);
157     bool getSpecificValueARM(uint32_t id, uint32_t *v);
158 };
159
160 } // namespace Focusrite
161 } // namespace BeBoB
162
163 #endif
Note: See TracBrowser for help on using the browser.