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/>.
25 #include "efc_cmds_ioconfig.h"
27 #include "libutil/ByteSwap.h"
35 EfcGenericIOConfigCmd::EfcGenericIOConfigCmd(enum eIOConfigRegister r
)
40 m_category_id
= EFC_CAT_IO_CONFIG
;
46 EfcGenericIOConfigCmd::serialize( Util::Cmd::IOSSerialize
& se
)
50 if (m_type
== eCT_Get
) {
51 // the length should be specified before
52 // the header is serialized
53 m_length
=EFC_HEADER_LENGTH_QUADLETS
;
55 result
&= EfcCmd::serialize ( se
);
58 // the length should be specified before
59 // the header is serialized
60 m_length
=EFC_HEADER_LENGTH_QUADLETS
+1;
62 result
&= EfcCmd::serialize ( se
);
64 result
&= se
.write(CondSwapToBus32(m_value
), "Value" );
70 EfcGenericIOConfigCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
74 result
&= EfcCmd::deserialize ( de
);
76 if (m_type
== eCT_Get
) {
77 EFC_DESERIALIZE_AND_SWAP(de
, &m_value
, result
);
84 EfcGenericIOConfigCmd::setType( enum eCmdType type
)
87 if (m_type
== eCT_Get
) {
90 m_command_id
=EFC_CMD_IO_CONFIG_GET_MIRROR
;
92 case eCR_DigitalInterface
:
93 m_command_id
=EFC_CMD_IO_CONFIG_GET_DIGITAL_MODE
;
96 m_command_id
=EFC_CMD_IO_CONFIG_GET_PHANTOM
;
99 debugError("Invalid IOConfig get command: %d\n", m_reg
);
105 m_command_id
=EFC_CMD_IO_CONFIG_SET_MIRROR
;
107 case eCR_DigitalInterface
:
108 m_command_id
=EFC_CMD_IO_CONFIG_SET_DIGITAL_MODE
;
111 m_command_id
=EFC_CMD_IO_CONFIG_SET_PHANTOM
;
114 debugError("Invalid IOConfig set command: %d\n", m_reg
);
121 EfcGenericIOConfigCmd::setRegister( enum eIOConfigRegister r
)
124 if (m_type
== eCT_Get
) {
127 m_command_id
=EFC_CMD_IO_CONFIG_GET_MIRROR
;
129 case eCR_DigitalInterface
:
130 m_command_id
=EFC_CMD_IO_CONFIG_GET_DIGITAL_MODE
;
133 m_command_id
=EFC_CMD_IO_CONFIG_GET_PHANTOM
;
136 debugError("Invalid IOConfig get command: %d\n", m_reg
);
142 m_command_id
=EFC_CMD_IO_CONFIG_SET_MIRROR
;
144 case eCR_DigitalInterface
:
145 m_command_id
=EFC_CMD_IO_CONFIG_SET_DIGITAL_MODE
;
148 m_command_id
=EFC_CMD_IO_CONFIG_SET_PHANTOM
;
151 debugError("Invalid IOConfig set command: %d\n", m_reg
);
159 EfcGenericIOConfigCmd::showEfcCmd()
161 EfcCmd::showEfcCmd();
162 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC IOCONFIG %s %s:\n",
163 (m_type
==eCT_Get
?"GET":"SET"),
164 eIOConfigRegisterToString(m_reg
));
165 debugOutput(DEBUG_LEVEL_NORMAL
, " Value : %u\n", m_value
);
168 // --- The specific commands
170 EfcIsocMapIOConfigCmd::EfcIsocMapIOConfigCmd(void)
174 , m_num_playmap_entries (0)
176 , m_num_recmap_entries (0)
179 m_category_id
= EFC_CAT_IO_CONFIG
;
182 memset(m_playmap
, EFC_MAX_ISOC_MAP_ENTRIES
, 0);
183 memset(m_recmap
, EFC_MAX_ISOC_MAP_ENTRIES
, 0);
186 EfcIsocMapIOConfigCmd::serialize( Util::Cmd::IOSSerialize
& se
)
191 assert((m_num_playmap_entries
<= EFC_MAX_ISOC_MAP_ENTRIES
)
192 || (m_num_recmap_entries
<= EFC_MAX_ISOC_MAP_ENTRIES
));
194 if (m_type
== eCT_Get
) {
195 // the length should be specified before
196 // the header is serialized
197 m_length
=EFC_HEADER_LENGTH_QUADLETS
;
199 result
&= EfcCmd::serialize ( se
);
201 // the length should be specified before
202 // the header is serialized
203 m_length
= EFC_HEADER_LENGTH_QUADLETS
+ sizeof(IsoChannelMap
);
205 result
&= EfcCmd::serialize ( se
);
207 result
&= se
.write(CondSwapToBus32(m_samplerate
), "Samplerate" );
208 result
&= se
.write(CondSwapToBus32(m_flags
), "Flags" );
210 result
&= se
.write(CondSwapToBus32(m_num_playmap_entries
), "Num. of Entries for Play Map" );
211 result
&= se
.write(CondSwapToBus32(m_num_phys_out
), "Num. of Phys. Out" );
212 for (i
= 0; i
< EFC_MAX_ISOC_MAP_ENTRIES
; i
++)
213 result
&= se
.write(CondSwapToBus32(m_playmap
[i
]), "Play Map Entry" );
215 result
&= se
.write(CondSwapToBus32(m_num_recmap_entries
), "Num. of Entries for Rec Map" );
216 result
&= se
.write(CondSwapToBus32(m_num_phys_in
), "Num. of Phys. In" );
217 for (i
= 0; i
< EFC_MAX_ISOC_MAP_ENTRIES
; i
++)
218 result
&= se
.write(CondSwapToBus32(m_recmap
[i
]), "Rec Map Entry" );
225 EfcIsocMapIOConfigCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
230 result
&= EfcCmd::deserialize ( de
);
232 if (m_type
== eCT_Get
) {
233 EFC_DESERIALIZE_AND_SWAP(de
, &m_samplerate
, result
);
234 EFC_DESERIALIZE_AND_SWAP(de
, &m_flags
, result
);
236 EFC_DESERIALIZE_AND_SWAP(de
, &m_num_playmap_entries
, result
);
237 EFC_DESERIALIZE_AND_SWAP(de
, &m_num_phys_out
, result
);
238 for (i
= 0; i
< EFC_MAX_ISOC_MAP_ENTRIES
; i
++)
239 EFC_DESERIALIZE_AND_SWAP(de
, &m_playmap
[i
], result
);
241 EFC_DESERIALIZE_AND_SWAP(de
, &m_num_recmap_entries
, result
);
242 EFC_DESERIALIZE_AND_SWAP(de
, &m_num_phys_in
, result
);
243 for (i
= 0; i
< EFC_MAX_ISOC_MAP_ENTRIES
; i
++)
244 EFC_DESERIALIZE_AND_SWAP(de
, &m_recmap
[i
], result
);
251 EfcIsocMapIOConfigCmd::setType( enum eCmdType type
)
254 if (m_type
== eCT_Get
)
255 m_command_id
= EFC_CMD_IO_CONFIG_GET_ISOC_MAP
;
257 m_command_id
= EFC_CMD_IO_CONFIG_SET_ISOC_MAP
;
262 EfcIsocMapIOConfigCmd::showEfcCmd()
266 EfcCmd::showEfcCmd();
267 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC IOCONFIG %s %s:\n",
268 (m_type
==eCT_Get
?"GET":"SET"),
269 eIOConfigRegisterToString(m_reg
));
270 debugOutput(DEBUG_LEVEL_NORMAL
, " Samplerate : %u\n", m_samplerate
);
271 debugOutput(DEBUG_LEVEL_NORMAL
, " Flags : %u\n", m_flags
);
272 debugOutput(DEBUG_LEVEL_NORMAL
, " Playback:");
273 debugOutput(DEBUG_LEVEL_NORMAL
, " Num. of Entries : %u\n", m_num_playmap_entries
);
274 debugOutput(DEBUG_LEVEL_NORMAL
, " Num. of Phys. Out: %u\n", m_num_phys_out
);
275 for (i
= 0; i
< EFC_MAX_ISOC_MAP_ENTRIES
; i
++)
276 debugOutput(DEBUG_LEVEL_NORMAL
, " Entriy %02d : %u\n", i
, m_playmap
[i
]);
277 debugOutput(DEBUG_LEVEL_NORMAL
, " Record:");
278 debugOutput(DEBUG_LEVEL_NORMAL
, " Num. of Entries : %u\n", m_num_recmap_entries
);
279 debugOutput(DEBUG_LEVEL_NORMAL
, " Num. of Phys. In : %u\n", m_num_phys_in
);
280 for (i
= 0; i
< EFC_MAX_ISOC_MAP_ENTRIES
; i
++)
281 debugOutput(DEBUG_LEVEL_NORMAL
, " Entriy %02d : %u\n", i
, m_recmap
[i
]);
285 } // namespace FireWorks