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_hardware_ctrl.h"
27 #include "libutil/ByteSwap.h"
35 EfcGetClockCmd::EfcGetClockCmd()
36 : EfcCmd(EFC_CAT_HARDWARE_CONTROL
, EFC_CMD_HWCTRL_GET_CLOCK
)
37 , m_clock ( EFC_CMD_HW_CLOCK_UNSPECIFIED
)
38 , m_samplerate ( EFC_CMD_HW_CLOCK_UNSPECIFIED
)
44 EfcGetClockCmd::serialize( Util::Cmd::IOSSerialize
& se
)
48 // the length should be specified before
49 // the header is serialized
50 m_length
=EFC_HEADER_LENGTH_QUADLETS
;
52 result
&= EfcCmd::serialize ( se
);
58 EfcGetClockCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
62 result
&= EfcCmd::deserialize ( de
);
64 EFC_DESERIALIZE_AND_SWAP(de
, &m_clock
, result
);
65 EFC_DESERIALIZE_AND_SWAP(de
, &m_samplerate
, result
);
66 EFC_DESERIALIZE_AND_SWAP(de
, &m_index
, result
);
72 EfcGetClockCmd::showEfcCmd()
75 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC Get Clock:\n");
76 debugOutput(DEBUG_LEVEL_NORMAL
, " Clock : %u\n", m_clock
);
77 debugOutput(DEBUG_LEVEL_NORMAL
, " Samplerate : %u\n", m_samplerate
);
78 debugOutput(DEBUG_LEVEL_NORMAL
, " Index : %u\n", m_index
);
82 EfcSetClockCmd::EfcSetClockCmd()
83 : EfcCmd(EFC_CAT_HARDWARE_CONTROL
, EFC_CMD_HWCTRL_SET_CLOCK
)
84 , m_clock ( EFC_CMD_HW_CLOCK_UNSPECIFIED
)
85 , m_samplerate ( EFC_CMD_HW_CLOCK_UNSPECIFIED
)
91 EfcSetClockCmd::serialize( Util::Cmd::IOSSerialize
& se
)
95 // the length should be specified before
96 // the header is serialized
97 m_length
=EFC_HEADER_LENGTH_QUADLETS
+3;
99 result
&= EfcCmd::serialize ( se
);
101 result
&= se
.write(CondSwapToBus32(m_clock
), "Clock" );
102 result
&= se
.write(CondSwapToBus32(m_samplerate
), "Samplerate" );
103 result
&= se
.write(CondSwapToBus32(m_index
), "Index" );
109 EfcSetClockCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
113 result
&= EfcCmd::deserialize ( de
);
115 EFC_DESERIALIZE_AND_SWAP(de
, &m_clock
, result
);
116 EFC_DESERIALIZE_AND_SWAP(de
, &m_samplerate
, result
);
117 EFC_DESERIALIZE_AND_SWAP(de
, &m_index
, result
);
120 * With firmware version 5.8, after setting, approximately 100ms needs to
121 * get it effective. If getting command is executed during this period,
122 * previous value is returned. This is a simple hack for this issue.
130 EfcSetClockCmd::showEfcCmd()
132 EfcCmd::showEfcCmd();
133 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC Set Clock:\n");
134 debugOutput(DEBUG_LEVEL_NORMAL
, " Clock : %u\n", m_clock
);
135 debugOutput(DEBUG_LEVEL_NORMAL
, " Samplerate : %u\n", m_samplerate
);
136 debugOutput(DEBUG_LEVEL_NORMAL
, " Index : %u\n", m_index
);
140 EfcPhyReconnectCmd::EfcPhyReconnectCmd()
141 : EfcCmd(EFC_CAT_HARDWARE_CONTROL
, EFC_CMD_HWCTRL_RECONNECT_PHY
)
146 EfcPhyReconnectCmd::serialize( Util::Cmd::IOSSerialize
& se
)
150 // the length should be specified before
151 // the header is serialized
152 m_length
=EFC_HEADER_LENGTH_QUADLETS
;
154 result
&= EfcCmd::serialize ( se
);
160 EfcPhyReconnectCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
164 result
&= EfcCmd::deserialize ( de
);
170 EfcPhyReconnectCmd::showEfcCmd()
172 EfcCmd::showEfcCmd();
173 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC Phy Reconnect\n");
177 EfcGetFlagsCmd::EfcGetFlagsCmd()
178 : EfcCmd(EFC_CAT_HARDWARE_CONTROL
, EFC_CMD_HWCTRL_GET_FLAGS
)
184 EfcGetFlagsCmd::serialize( Util::Cmd::IOSSerialize
& se
)
188 // the length should be specified before
189 // the header is serialized
190 m_length
=EFC_HEADER_LENGTH_QUADLETS
;
192 result
&= EfcCmd::serialize ( se
);
198 EfcGetFlagsCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
202 result
&= EfcCmd::deserialize ( de
);
204 EFC_DESERIALIZE_AND_SWAP(de
, &m_flags
, result
);
210 EfcGetFlagsCmd::showEfcCmd()
212 EfcCmd::showEfcCmd();
213 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC Get Flags:\n");
214 debugOutput(DEBUG_LEVEL_NORMAL
, " Flags : %08X\n", m_flags
);
218 EfcChangeFlagsCmd::EfcChangeFlagsCmd()
219 : EfcCmd(EFC_CAT_HARDWARE_CONTROL
, EFC_CMD_HWCTRL_CHANGE_FLAGS
)
226 EfcChangeFlagsCmd::serialize( Util::Cmd::IOSSerialize
& se
)
230 // the length should be specified before
231 // the header is serialized
232 m_length
=EFC_HEADER_LENGTH_QUADLETS
+2;
234 result
&= EfcCmd::serialize ( se
);
236 result
&= se
.write(CondSwapToBus32(m_setmask
), "SetMask" );
237 result
&= se
.write(CondSwapToBus32(m_clearmask
), "ClearMask" );
243 EfcChangeFlagsCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
246 result
&= EfcCmd::deserialize ( de
);
251 EfcChangeFlagsCmd::showEfcCmd()
253 EfcCmd::showEfcCmd();
254 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC Change flags:\n");
255 debugOutput(DEBUG_LEVEL_NORMAL
, " Set mask : %08X\n", m_setmask
);
256 debugOutput(DEBUG_LEVEL_NORMAL
, " Clear mask : %08X\n", m_clearmask
);
261 EfcIdentifyCmd::EfcIdentifyCmd()
262 : EfcCmd(EFC_CAT_HARDWARE_CONTROL
, EFC_CMD_HWCTRL_IDENTIFY
)
267 EfcIdentifyCmd::serialize( Util::Cmd::IOSSerialize
& se
)
271 // the length should be specified before
272 // the header is serialized
273 m_length
=EFC_HEADER_LENGTH_QUADLETS
;
275 result
&= EfcCmd::serialize ( se
);
281 EfcIdentifyCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
285 result
&= EfcCmd::deserialize ( de
);
291 EfcIdentifyCmd::showEfcCmd()
293 EfcCmd::showEfcCmd();
294 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC Identify\n");
297 } // namespace FireWorks