root/trunk/libffado/src/fireworks/efc/efc_cmds_hardware_ctrl.cpp

Revision 639, 4.0 kB (checked in by ppalmers, 13 years ago)

- Introduce a generic infrastructure for FFADODevices to present the clock sources they support and their state
- Implement this infrastructure for BeBoB devices
- Implement this infrastructure for ECHO 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 #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::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::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::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::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::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::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
Note: See TracBrowser for help on using the browser.