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 |
#include "efc_cmd.h" |
---|
25 |
#include "efc_cmds_hardware_ctrl.h" |
---|
26 |
|
---|
27 |
#include <netinet/in.h> |
---|
28 |
#include <iostream> |
---|
29 |
|
---|
30 |
using namespace std; |
---|
31 |
|
---|
32 |
namespace FireWorks { |
---|
33 |
|
---|
34 |
EfcGetClockCmd::EfcGetClockCmd() |
---|
35 |
: EfcCmd(EFC_CAT_HARDWARE_CONTROL, EFC_CMD_HWCTRL_GET_CLOCK) |
---|
36 |
, m_clock ( EFC_CMD_HW_CLOCK_UNSPECIFIED ) |
---|
37 |
, m_samplerate ( EFC_CMD_HW_CLOCK_UNSPECIFIED ) |
---|
38 |
, m_index ( 0 ) |
---|
39 |
{ |
---|
40 |
} |
---|
41 |
|
---|
42 |
bool |
---|
43 |
EfcGetClockCmd::serialize( Util::Cmd::IOSSerialize& se ) |
---|
44 |
{ |
---|
45 |
bool result=true; |
---|
46 |
|
---|
47 |
// the length should be specified before |
---|
48 |
// the header is serialized |
---|
49 |
m_length=EFC_HEADER_LENGTH_QUADLETS; |
---|
50 |
|
---|
51 |
result &= EfcCmd::serialize ( se ); |
---|
52 |
|
---|
53 |
return result; |
---|
54 |
} |
---|
55 |
|
---|
56 |
bool |
---|
57 |
EfcGetClockCmd::deserialize( Util::Cmd::IISDeserialize& de ) |
---|
58 |
{ |
---|
59 |
bool result=true; |
---|
60 |
|
---|
61 |
result &= EfcCmd::deserialize ( de ); |
---|
62 |
|
---|
63 |
EFC_DESERIALIZE_AND_SWAP(de, &m_clock, result); |
---|
64 |
EFC_DESERIALIZE_AND_SWAP(de, &m_samplerate, result); |
---|
65 |
EFC_DESERIALIZE_AND_SWAP(de, &m_index, result); |
---|
66 |
|
---|
67 |
return result; |
---|
68 |
} |
---|
69 |
|
---|
70 |
void |
---|
71 |
EfcGetClockCmd::showEfcCmd() |
---|
72 |
{ |
---|
73 |
EfcCmd::showEfcCmd(); |
---|
74 |
debugOutput(DEBUG_LEVEL_NORMAL, "EFC Get Clock:\n"); |
---|
75 |
debugOutput(DEBUG_LEVEL_NORMAL, " Clock : %lu\n", m_clock); |
---|
76 |
debugOutput(DEBUG_LEVEL_NORMAL, " Samplerate : %lu\n", m_samplerate); |
---|
77 |
debugOutput(DEBUG_LEVEL_NORMAL, " Index : %lu\n", m_index); |
---|
78 |
} |
---|
79 |
|
---|
80 |
// ---- |
---|
81 |
EfcSetClockCmd::EfcSetClockCmd() |
---|
82 |
: EfcCmd(EFC_CAT_HARDWARE_CONTROL, EFC_CMD_HWCTRL_SET_CLOCK) |
---|
83 |
, m_clock ( EFC_CMD_HW_CLOCK_UNSPECIFIED ) |
---|
84 |
, m_samplerate ( EFC_CMD_HW_CLOCK_UNSPECIFIED ) |
---|
85 |
, m_index ( 0 ) |
---|
86 |
{ |
---|
87 |
} |
---|
88 |
|
---|
89 |
bool |
---|
90 |
EfcSetClockCmd::serialize( Util::Cmd::IOSSerialize& se ) |
---|
91 |
{ |
---|
92 |
bool result=true; |
---|
93 |
|
---|
94 |
// the length should be specified before |
---|
95 |
// the header is serialized |
---|
96 |
m_length=EFC_HEADER_LENGTH_QUADLETS+3; |
---|
97 |
|
---|
98 |
result &= EfcCmd::serialize ( se ); |
---|
99 |
|
---|
100 |
result &= se.write(htonl(m_clock), "Clock" ); |
---|
101 |
result &= se.write(htonl(m_samplerate), "Samplerate" ); |
---|
102 |
result &= se.write(htonl(m_index), "Index" ); |
---|
103 |
|
---|
104 |
return result; |
---|
105 |
} |
---|
106 |
|
---|
107 |
bool |
---|
108 |
EfcSetClockCmd::deserialize( Util::Cmd::IISDeserialize& de ) |
---|
109 |
{ |
---|
110 |
bool result=true; |
---|
111 |
|
---|
112 |
result &= EfcCmd::deserialize ( de ); |
---|
113 |
|
---|
114 |
EFC_DESERIALIZE_AND_SWAP(de, &m_clock, result); |
---|
115 |
EFC_DESERIALIZE_AND_SWAP(de, &m_samplerate, result); |
---|
116 |
EFC_DESERIALIZE_AND_SWAP(de, &m_index, result); |
---|
117 |
|
---|
118 |
return result; |
---|
119 |
} |
---|
120 |
|
---|
121 |
void |
---|
122 |
EfcSetClockCmd::showEfcCmd() |
---|
123 |
{ |
---|
124 |
EfcCmd::showEfcCmd(); |
---|
125 |
debugOutput(DEBUG_LEVEL_NORMAL, "EFC Set Clock:\n"); |
---|
126 |
debugOutput(DEBUG_LEVEL_NORMAL, " Clock : %lu\n", m_clock); |
---|
127 |
debugOutput(DEBUG_LEVEL_NORMAL, " Samplerate : %lu\n", m_samplerate); |
---|
128 |
debugOutput(DEBUG_LEVEL_NORMAL, " Index : %lu\n", m_index); |
---|
129 |
} |
---|
130 |
|
---|
131 |
// ---- |
---|
132 |
EfcPhyReconnectCmd::EfcPhyReconnectCmd() |
---|
133 |
: EfcCmd(EFC_CAT_HARDWARE_CONTROL, EFC_CMD_HWCTRL_RECONNECT_PHY) |
---|
134 |
{ |
---|
135 |
} |
---|
136 |
|
---|
137 |
bool |
---|
138 |
EfcPhyReconnectCmd::serialize( Util::Cmd::IOSSerialize& se ) |
---|
139 |
{ |
---|
140 |
bool result=true; |
---|
141 |
|
---|
142 |
// the length should be specified before |
---|
143 |
// the header is serialized |
---|
144 |
m_length=EFC_HEADER_LENGTH_QUADLETS; |
---|
145 |
|
---|
146 |
result &= EfcCmd::serialize ( se ); |
---|
147 |
|
---|
148 |
return result; |
---|
149 |
} |
---|
150 |
|
---|
151 |
bool |
---|
152 |
EfcPhyReconnectCmd::deserialize( Util::Cmd::IISDeserialize& de ) |
---|
153 |
{ |
---|
154 |
bool result=true; |
---|
155 |
|
---|
156 |
result &= EfcCmd::deserialize ( de ); |
---|
157 |
|
---|
158 |
return result; |
---|
159 |
} |
---|
160 |
|
---|
161 |
void |
---|
162 |
EfcPhyReconnectCmd::showEfcCmd() |
---|
163 |
{ |
---|
164 |
EfcCmd::showEfcCmd(); |
---|
165 |
debugOutput(DEBUG_LEVEL_NORMAL, "EFC Phy Reconnect\n"); |
---|
166 |
} |
---|
167 |
|
---|
168 |
} // namespace FireWorks |
---|