root/trunk/libffado/src/fireworks/efc/efc_cmd.h

Revision 742, 7.3 kB (checked in by ppalmers, 13 years ago)

- Remove some obsolete support files and dirs

- Clean up the license statements in the source files. Everything is

GPL version 3 now.

- Add license and copyright notices to scons scripts

- Clean up some other text files

Line 
1 /*
2  * Copyright (C) 2005-2007 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program 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
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #ifndef FIREWORKS_EFC_CMD_H
25 #define FIREWORKS_EFC_CMD_H
26
27 #include "debugmodule/debugmodule.h"
28
29 #include "libutil/cmd_serialize.h"
30
31 #define EFC_CAT_INVALID                 0xFFFFFFFF
32 #define EFC_CMD_INVALID                 0xFFFFFFFF
33
34 // Categories
35 #define EFC_CAT_HARDWARE_INFO           0
36 #define EFC_CAT_FLASH                   1
37 #define EFC_CAT_TRANSPORT               2
38 #define EFC_CAT_HARDWARE_CONTROL        3
39 #define EFC_CAT_PHYSICAL_OUTPUT_MIX     4
40 #define EFC_CAT_PHYSICAL_INPUT_MIX      5
41 #define EFC_CAT_PLAYBACK_MIX            6
42 #define EFC_CAT_RECORD_MIX              7
43 #define EFC_CAT_MONITOR_MIX             8
44 #define EFC_CAT_IO_CONFIG               9
45 #define EFC_CAT_COUNT                   10
46
47 // Commands for the EFC_CAT_HARDWARE_INFO category
48 #define EFC_CMD_HW_HWINFO_GET_CAPS      0
49 #define EFC_CMD_HW_GET_POLLED           1
50 #define EFC_CMD_HW_SET_EFR_ADDRESS      2
51 #define EFC_CMD_HW_READ_SESSION_BLOCK   3
52 #define EFC_CMD_HW_GET_DEBUG_INFO       4
53 #define EFC_CMD_HW_SET_DEBUG_TRACKING   5
54 #define EFC_CMD_HW_COUNT                6
55
56 // Commands for the EFC_CAT_FLASH category
57 #define EFC_CMD_FLASH_ERASE             0
58 #define EFC_CMD_FLASH_READ              1
59 #define EFC_CMD_FLASH_WRITE             2
60 #define EFC_CMD_FLASH_GET_STATUS        3
61 #define EFC_CMD_FLASH_GET_SESSION_BASE  4
62 #define EFC_CMD_FLASH_LOCK              5
63
64 // Commands for the EFC_CAT_HARDWARE_CONTROL category
65 #define EFC_CMD_HWCTRL_SET_CLOCK        0
66 #define EFC_CMD_HWCTRL_GET_CLOCK        1
67 #define EFC_CMD_HWCTRL_BSX_HANDSHAKE    2
68 #define EFC_CMD_HWCTRL_CHANGE_FLAGS     3
69 #define EFC_CMD_HWCTRL_GET_FLAGS        4
70 #define EFC_CMD_HWCTRL_IDENTIFY         5
71 #define EFC_CMD_HWCTRL_RECONNECT_PHY    6
72
73 // Commands for the EFC_CAT_*_MIX categories
74 #define EFC_CMD_MIXER_SET_GAIN        0
75 #define EFC_CMD_MIXER_GET_GAIN        1
76 #define EFC_CMD_MIXER_SET_MUTE        2
77 #define EFC_CMD_MIXER_GET_MUTE        3
78 #define EFC_CMD_MIXER_SET_SOLO        4
79 #define EFC_CMD_MIXER_GET_SOLO        5
80 #define EFC_CMD_MIXER_SET_PAN         6
81 #define EFC_CMD_MIXER_GET_PAN         7
82 #define EFC_CMD_MIXER_SET_NOMINAL     8
83 #define EFC_CMD_MIXER_GET_NOMINAL     9
84
85 // Commands for the EFC_CAT_IO_CONFIG category
86 #define EFC_CMD_IO_CONFIG_SET_MIRROR        0
87 #define EFC_CMD_IO_CONFIG_GET_MIRROR        1
88 #define EFC_CMD_IO_CONFIG_SET_DIGITAL_MODE  2
89 #define EFC_CMD_IO_CONFIG_GET_DIGITAL_MODE  3
90 #define EFC_CMD_IO_CONFIG_SET_PHANTOM       4
91 #define EFC_CMD_IO_CONFIG_GET_PHANTOM       5
92 #define EFC_CMD_IO_CONFIG_SET_ISOC_MAP      6
93 #define EFC_CMD_IO_CONFIG_GET_ISOC_MAP      7
94
95
96 // size of the header
97 #define EFC_HEADER_LENGTH_QUADLETS      ((sizeof(uint32_t) + sizeof(struct EfcCmd::efc_header))/4)
98
99 // util macro to do deserialization and byteswap
100 #define EFC_DESERIALIZE_AND_SWAP(__de__, __value__, __result__) \
101     { __result__ &= __de__.read(__value__); \
102       *(__value__)=ntohl(*(__value__)); } \
103
104
105 // specifiers for the flags field
106 #define EFC_CMD_HW_DYNADDR_SUPPORTED                1
107 #define EFC_CMD_HW_MIRRORING_SUPPORTED              2
108 #define EFC_CMD_HW_SPDIF_COAX_SUPPORTED             3
109 #define EFC_CMD_HW_SPDIF_AESEBUXLR_SUPPORTED        4
110 #define EFC_CMD_HW_HAS_DSP                          5
111 #define EFC_CMD_HW_HAS_FPGA                         6
112 #define EFC_CMD_HW_HAS_PHANTOM                      7
113
114 #define EFC_CMD_HW_CHECK_FLAG(__val__,__flag__) \
115     (((__val__) & (1<<(__flag__))) != 0)
116 #define EFC_CMD_HW_TO_FLAG(__val__) \
117     (1<<(__val__))
118
119 // Clock sources
120 #define EFC_CMD_HW_CLOCK_INTERNAL                   0
121 #define EFC_CMD_HW_CLOCK_SYTMATCH                   1
122 #define EFC_CMD_HW_CLOCK_WORDCLOCK                  2
123 #define EFC_CMD_HW_CLOCK_SPDIF                      3
124 #define EFC_CMD_HW_CLOCK_ADAT_1                     4
125 #define EFC_CMD_HW_CLOCK_ADAT_2                     5
126 #define EFC_CMD_HW_CLOCK_COUNT                      6
127
128 #define EFC_CMD_HW_CLOCK_UNSPECIFIED       0xFFFFFFFF
129
130 // MIDI flags
131 #define EFC_CMD_HW_MIDI_IN_1                        8
132 #define EFC_CMD_HW_MIDI_OUT_1                       9
133 #define EFC_CMD_HW_MIDI_IN_2                       10
134 #define EFC_CMD_HW_MIDI_OUT_2                      11
135
136 // Channel types
137 #define EFC_CMD_HW_CHANNEL_TYPE_ANALOG              0
138 #define EFC_CMD_HW_CHANNEL_TYPE_SPDIF               1
139 #define EFC_CMD_HW_CHANNEL_TYPE_ADAT                2
140 #define EFC_CMD_HW_CHANNEL_TYPE_SPDIF_OR_ADAT       3
141 #define EFC_CMD_HW_CHANNEL_TYPE_ANALOG_MIRRORING    4
142 #define EFC_CMD_HW_CHANNEL_TYPE_HEADPHONES          5
143 #define EFC_CMD_HW_CHANNEL_TYPE_I2S                 6
144
145 namespace FireWorks {
146
147 enum eMixerTarget {
148     eMT_PhysicalOutputMix,
149     eMT_PhysicalInputMix,
150     eMT_PlaybackMix,
151     eMT_RecordMix,
152 };
153 enum eMixerCommand {
154     eMC_Gain,
155     eMC_Solo,
156     eMC_Mute,
157     eMC_Pan,
158     eMC_Nominal,
159 };
160 enum eCmdType {
161     eCT_Get,
162     eCT_Set,
163 };
164
165 enum eIOConfigRegister {
166     eCR_Mirror,
167     eCR_DigitalMode,
168     eCR_Phantom,
169 };
170
171 const char *eMixerTargetToString(const enum eMixerTarget target);
172 const char *eMixerCommandToString(const enum eMixerCommand command);
173 const char *eIOConfigRegisterToString(const enum eIOConfigRegister reg);
174
175 class EfcCmd
176 {
177 public:
178     enum EfcReturnValue {
179         eERV_Ok             = 0,
180         eERV_Bad            = 1,
181         eERV_BadCommand     = 2,
182         eERV_CommErr        = 3,
183         eERV_BadQuadCount   = 4,
184         eERV_Unsupported    = 5,
185         eERV_1394Timeout    = 6,
186         eERV_DspTimeout     = 7,
187         eERV_BadRate        = 8,
188         eERV_BadClock       = 9,
189         eERV_BadChannel     = 10,
190         eERV_BadPan         = 11,
191         eERV_FlashBusy      = 12,
192         eERV_BadMirror      = 13,
193         eERV_BadLed         = 14,
194         eERV_BadParameter   = 15,
195         eERV_Incomplete     = 0x80000000L,
196         eERV_Unspecified    = 0xFFFFFFFFL,
197     };
198
199     typedef struct efc_header
200     {
201         uint32_t    version;
202         uint32_t    seqnum;
203         uint32_t    category;
204         uint32_t    command;
205         uint32_t    retval;
206     };
207
208 protected: // this HAS to be overloaded
209     EfcCmd(uint32_t cat, uint32_t cmd);
210     EfcCmd();
211
212 public:
213     virtual ~EfcCmd();
214    
215     virtual bool serialize( Util::IOSSerialize& se );
216     virtual bool deserialize( Util::IISDeserialize& de );
217
218     virtual const char* getCmdName() const = 0;
219
220     virtual void showEfcCmd();
221     virtual void setVerboseLevel(int l);
222
223     uint32_t            m_length; // in quadlets, including length field and header.
224     struct efc_header   m_header;
225
226 protected:
227     uint32_t            m_category_id;
228     uint32_t            m_command_id;
229
230 public:
231     static uint32_t     m_seqnum;
232 protected:
233     DECLARE_DEBUG_MODULE;
234 };
235
236 } // namespace FireWorks
237
238 #endif // FIREWORKS_EFC_CMD_H
Note: See TracBrowser for help on using the browser.