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

Revision 676, 4.7 kB (checked in by ppalmers, 16 years ago)

- Add direct address space control mechanism
- Add extra device control id's

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 library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License version 2.1, as published by the Free Software Foundation;
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22  * MA 02110-1301 USA
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( Ieee1394Service& ieee1394Service,
139               std::auto_ptr<ConfigRom>( configRom ));
140     virtual ~FocusriteDevice() {};
141
142     virtual void showDevice();
143     virtual void setVerboseLevel(int l);
144
145 public:
146     bool setSpecificValue(uint32_t id, uint32_t v);
147     bool getSpecificValue(uint32_t id, uint32_t *v);
148
149 protected:
150     int convertDefToSr( uint32_t def );
151     uint32_t convertSrToDef( int sr );
152
153 private:
154     bool setSpecificValueAvc(uint32_t id, uint32_t v);
155     bool getSpecificValueAvc(uint32_t id, uint32_t *v);
156
157     bool setSpecificValueARM(uint32_t id, uint32_t v);
158     bool getSpecificValueARM(uint32_t id, uint32_t *v);
159 };
160
161 } // namespace Focusrite
162 } // namespace BeBoB
163
164 #endif
Note: See TracBrowser for help on using the browser.