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

Revision 665, 7.0 kB (checked in by ppalmers, 15 years ago)

Implement support for Phantom power on the fireworks devices

Line 
1 /*
2  * Copyright (C) 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 library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
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_HARDWARE_CONTROL category
57 #define EFC_CMD_HWCTRL_SET_CLOCK        0
58 #define EFC_CMD_HWCTRL_GET_CLOCK        1
59 #define EFC_CMD_HWCTRL_BSX_HANDSHAKE    2
60 #define EFC_CMD_HWCTRL_CHANGE_FLAGS     3
61 #define EFC_CMD_HWCTRL_GET_FLAGS        4
62 #define EFC_CMD_HWCTRL_IDENTIFY         5
63 #define EFC_CMD_HWCTRL_RECONNECT_PHY    6
64
65 // Commands for the EFC_CAT_*_MIX categories
66 #define EFC_CMD_MIXER_SET_GAIN        0
67 #define EFC_CMD_MIXER_GET_GAIN        1
68 #define EFC_CMD_MIXER_SET_MUTE        2
69 #define EFC_CMD_MIXER_GET_MUTE        3
70 #define EFC_CMD_MIXER_SET_SOLO        4
71 #define EFC_CMD_MIXER_GET_SOLO        5
72 #define EFC_CMD_MIXER_SET_PAN         6
73 #define EFC_CMD_MIXER_GET_PAN         7
74 #define EFC_CMD_MIXER_SET_NOMINAL     8
75 #define EFC_CMD_MIXER_GET_NOMINAL     9
76
77 // Commands for the EFC_CAT_IO_CONFIG category
78 #define EFC_CMD_IO_CONFIG_SET_MIRROR        0
79 #define EFC_CMD_IO_CONFIG_GET_MIRROR        1
80 #define EFC_CMD_IO_CONFIG_SET_DIGITAL_MODE  2
81 #define EFC_CMD_IO_CONFIG_GET_DIGITAL_MODE  3
82 #define EFC_CMD_IO_CONFIG_SET_PHANTOM       4
83 #define EFC_CMD_IO_CONFIG_GET_PHANTOM       5
84 #define EFC_CMD_IO_CONFIG_SET_ISOC_MAP      6
85 #define EFC_CMD_IO_CONFIG_GET_ISOC_MAP      7
86
87
88 // size of the header
89 #define EFC_HEADER_LENGTH_QUADLETS      ((sizeof(uint32_t) + sizeof(struct EfcCmd::efc_header))/4)
90
91 // util macro to do deserialization and byteswap
92 #define EFC_DESERIALIZE_AND_SWAP(__de__, __value__, __result__) \
93     { __result__ &= __de__.read(__value__); \
94       *(__value__)=ntohl(*(__value__)); } \
95
96
97 // specifiers for the flags field
98 #define EFC_CMD_HW_DYNADDR_SUPPORTED                1
99 #define EFC_CMD_HW_MIRRORING_SUPPORTED              2
100 #define EFC_CMD_HW_SPDIF_COAX_SUPPORTED             3
101 #define EFC_CMD_HW_SPDIF_AESEBUXLR_SUPPORTED        4
102 #define EFC_CMD_HW_HAS_DSP                          5
103 #define EFC_CMD_HW_HAS_FPGA                         6
104 #define EFC_CMD_HW_HAS_PHANTOM                      7
105
106 #define EFC_CMD_HW_CHECK_FLAG(__val__,__flag__) \
107     (((__val__) & (1<<(__flag__))) != 0)
108 #define EFC_CMD_HW_TO_FLAG(__val__) \
109     (1<<(__val__))
110
111 // Clock sources
112 #define EFC_CMD_HW_CLOCK_INTERNAL                   0
113 #define EFC_CMD_HW_CLOCK_SYTMATCH                   1
114 #define EFC_CMD_HW_CLOCK_WORDCLOCK                  2
115 #define EFC_CMD_HW_CLOCK_SPDIF                      3
116 #define EFC_CMD_HW_CLOCK_ADAT_1                     4
117 #define EFC_CMD_HW_CLOCK_ADAT_2                     5
118 #define EFC_CMD_HW_CLOCK_COUNT                      6
119
120 #define EFC_CMD_HW_CLOCK_UNSPECIFIED       0xFFFFFFFF
121
122 // MIDI flags
123 #define EFC_CMD_HW_MIDI_IN_1                        8
124 #define EFC_CMD_HW_MIDI_OUT_1                       9
125 #define EFC_CMD_HW_MIDI_IN_2                       10
126 #define EFC_CMD_HW_MIDI_OUT_2                      11
127
128 // Channel types
129 #define EFC_CMD_HW_CHANNEL_TYPE_ANALOG              0
130 #define EFC_CMD_HW_CHANNEL_TYPE_SPDIF               1
131 #define EFC_CMD_HW_CHANNEL_TYPE_ADAT                2
132 #define EFC_CMD_HW_CHANNEL_TYPE_SPDIF_OR_ADAT       3
133 #define EFC_CMD_HW_CHANNEL_TYPE_ANALOG_MIRRORING    4
134 #define EFC_CMD_HW_CHANNEL_TYPE_HEADPHONES          5
135 #define EFC_CMD_HW_CHANNEL_TYPE_I2S                 6
136
137 namespace FireWorks {
138
139 enum eMixerTarget {
140     eMT_PhysicalOutputMix,
141     eMT_PhysicalInputMix,
142     eMT_PlaybackMix,
143     eMT_RecordMix,
144 };
145 enum eMixerCommand {
146     eMC_Gain,
147     eMC_Solo,
148     eMC_Mute,
149     eMC_Pan,
150     eMC_Nominal,
151 };
152 enum eCmdType {
153     eCT_Get,
154     eCT_Set,
155 };
156
157 enum eIOConfigRegister {
158     eCR_Mirror,
159     eCR_DigitalMode,
160     eCR_Phantom,
161 };
162
163 const char *eMixerTargetToString(const enum eMixerTarget target);
164 const char *eMixerCommandToString(const enum eMixerCommand command);
165 const char *eIOConfigRegisterToString(const enum eIOConfigRegister reg);
166
167 class EfcCmd
168 {
169 public:
170     enum EfcReturnValue {
171         eERV_Ok             = 0,
172         eERV_Bad            = 1,
173         eERV_BadCommand     = 2,
174         eERV_CommErr        = 3,
175         eERV_BadQuadCount   = 4,
176         eERV_Unsupported    = 5,
177         eERV_1394Timeout    = 6,
178         eERV_DspTimeout     = 7,
179         eERV_BadRate        = 8,
180         eERV_BadClock       = 9,
181         eERV_BadChannel     = 10,
182         eERV_BadPan         = 11,
183         eERV_FlashBusy      = 12,
184         eERV_BadMirror      = 13,
185         eERV_BadLed         = 14,
186         eERV_BadParameter   = 15,
187         eERV_Incomplete     = 0x80000000L,
188         eERV_Unspecified    = 0xFFFFFFFFL,
189     };
190
191     typedef struct efc_header
192     {
193         uint32_t    version;
194         uint32_t    seqnum;
195         uint32_t    category;
196         uint32_t    command;
197         uint32_t    retval;
198     };
199
200 protected: // this HAS to be overloaded
201     EfcCmd(uint32_t cat, uint32_t cmd);
202     EfcCmd();
203
204 public:
205     virtual ~EfcCmd();
206    
207     virtual bool serialize( Util::IOSSerialize& se );
208     virtual bool deserialize( Util::IISDeserialize& de );
209
210     virtual const char* getCmdName() const = 0;
211
212     virtual void showEfcCmd();
213
214     uint32_t            m_length; // in quadlets, including length field and header.
215     struct efc_header   m_header;
216
217 protected:
218     uint32_t            m_category_id;
219     uint32_t            m_command_id;
220
221 public:
222     static uint32_t     m_seqnum;
223 protected:
224     DECLARE_DEBUG_MODULE;
225 };
226
227 } // namespace FireWorks
228
229 #endif // FIREWORKS_EFC_CMD_H
Note: See TracBrowser for help on using the browser.