2 * Copyright (C) 2005-2008 by Pieter Palmers
4 * This file is part of FFADO
5 * FFADO = Free Firewire (pro-)audio drivers for linux
7 * FFADO is based upon FreeBoB
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 2 of the License, or
12 * (at your option) version 3 of the License.
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.
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/>.
24 #ifndef FIREWORKS_EFC_CMD_H
25 #define FIREWORKS_EFC_CMD_H
27 #include "debugmodule/debugmodule.h"
29 #include "libutil/cmd_serialize.h"
31 #define EFC_CAT_INVALID 0xFFFFFFFF
32 #define EFC_CMD_INVALID 0xFFFFFFFF
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
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
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
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
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
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
97 #define EFC_HEADER_LENGTH_QUADLETS ((sizeof(uint32_t) + sizeof(struct EfcCmd::efc_header))/4)
99 // util macro to do deserialization and byteswap
100 #define EFC_DESERIALIZE_AND_SWAP(__de__, __value__, __result__) \
101 { __result__ &= __de__.read(__value__); \
102 *(__value__)=CondSwapFromBus32(*(__value__)); } \
105 // specifiers for the flags field
106 #define EFC_CMD_HW_DYNADDR_SUPPORTED 0
107 #define EFC_CMD_HW_MIRRORING_SUPPORTED 1
108 #define EFC_CMD_HW_OPTICAL_INTERFACE_SUPPORTED 2
109 #define EFC_CMD_HW_SPDIF_AESEBUXLR_SUPPORTED 3
110 #define EFC_CMD_HW_HAS_DSP 4
111 #define EFC_CMD_HW_HAS_FPGA 5
112 #define EFC_CMD_HW_HAS_PHANTOM 6
113 #define EFC_CMD_HW_HAS_PLAYBACK_ROUTING 7
115 #define EFC_CMD_HW_CHECK_FLAG(__val__,__flag__) \
116 (((__val__) & (1<<(__flag__))) != 0)
117 #define EFC_CMD_HW_TO_FLAG(__val__) \
121 #define EFC_CMD_HW_CLOCK_INTERNAL 0
122 #define EFC_CMD_HW_CLOCK_SYTMATCH 1
123 #define EFC_CMD_HW_CLOCK_WORDCLOCK 2
124 #define EFC_CMD_HW_CLOCK_SPDIF 3
125 #define EFC_CMD_HW_CLOCK_ADAT_1 4
126 #define EFC_CMD_HW_CLOCK_ADAT_2 5
127 #define EFC_CMD_HW_CLOCK_COUNT 6
129 #define EFC_CMD_HW_CLOCK_UNSPECIFIED 0xFFFFFFFF
132 #define EFC_CMD_HW_MIDI_IN_1 8
133 #define EFC_CMD_HW_MIDI_OUT_1 9
134 #define EFC_CMD_HW_MIDI_IN_2 10
135 #define EFC_CMD_HW_MIDI_OUT_2 11
138 #define EFC_CMD_HW_CHANNEL_TYPE_ANALOG 0
139 #define EFC_CMD_HW_CHANNEL_TYPE_SPDIF 1
140 #define EFC_CMD_HW_CHANNEL_TYPE_ADAT 2
141 #define EFC_CMD_HW_CHANNEL_TYPE_SPDIF_OR_ADAT 3
142 #define EFC_CMD_HW_CHANNEL_TYPE_ANALOG_MIRRORING 4
143 #define EFC_CMD_HW_CHANNEL_TYPE_HEADPHONES 5
144 #define EFC_CMD_HW_CHANNEL_TYPE_I2S 6
146 namespace FireWorks
{
149 eMT_PhysicalOutputMix
,
150 eMT_PhysicalInputMix
,
166 enum eIOConfigRegister
{
168 eCR_DigitalInterface
,
173 const char *eMixerTargetToString(const enum eMixerTarget target
);
174 const char *eMixerCommandToString(const enum eMixerCommand command
);
175 const char *eIOConfigRegisterToString(const enum eIOConfigRegister reg
);
180 enum EfcReturnValue
{
185 eERV_BadQuadCount
= 4,
186 eERV_Unsupported
= 5,
187 eERV_1394Timeout
= 6,
191 eERV_BadChannel
= 10,
196 eERV_BadParameter
= 15,
197 eERV_Incomplete
= 0x80000000L
,
198 eERV_Unspecified
= 0xFFFFFFFFL
,
210 protected: // this HAS to be overloaded
211 EfcCmd(uint32_t cat
, uint32_t cmd
);
217 virtual bool serialize( Util::Cmd::IOSSerialize
& se
);
218 virtual bool deserialize( Util::Cmd::IISDeserialize
& de
);
220 virtual const char* getCmdName() const = 0;
222 virtual void showEfcCmd();
223 virtual void setVerboseLevel(int l
);
225 uint32_t m_length
; // in quadlets, including length field and header.
226 struct efc_header m_header
;
229 uint32_t m_category_id
;
230 uint32_t m_command_id
;
233 static uint32_t m_seqnum
;
235 DECLARE_DEBUG_MODULE
;
238 } // namespace FireWorks
240 #endif // FIREWORKS_EFC_CMD_H