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

Revision 1763, 8.8 kB (checked in by ppalmers, 8 years ago)

Merged revisions 1536,1541,1544-1546,1549,1554-1562,1571,1579-1581,1618,1632,1634-1635,1661,1677-1679,1703-1704,1715,1720-1723,1743-1745,1755 via svnmerge from
svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0

Also fix remaining format string warnings.

Line 
1 /*
2  * Copyright (C) 2005-2008 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 2 of the License, or
12  * (at your option) version 3 of the License.
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_cmds_hardware.h"
25
26 #include "libutil/ByteSwap.h"
27 #include <iostream>
28
29 using namespace std;
30
31 namespace FireWorks {
32
33 EfcHardwareInfoCmd::EfcHardwareInfoCmd()
34 : EfcCmd(EFC_CAT_HARDWARE_INFO, EFC_CMD_HW_HWINFO_GET_CAPS)
35 , m_nb_out_groups( 0 )
36 , m_nb_in_groups( 0 )
37 {}
38
39 bool
40 EfcHardwareInfoCmd::serialize( Util::Cmd::IOSSerialize& se )
41 {
42     bool result=true;
43    
44     // the length should be specified before
45     // the header is serialized
46     m_length=EFC_HEADER_LENGTH_QUADLETS;
47    
48     result &= EfcCmd::serialize ( se );
49     return result;
50 }
51
52 bool
53 EfcHardwareInfoCmd::deserialize( Util::Cmd::IISDeserialize& de )
54 {
55     bool result=true;
56     uint32_t tmp;
57    
58     result &= EfcCmd::deserialize ( de );
59    
60     // the serialization is different from the deserialization
61     EFC_DESERIALIZE_AND_SWAP(de, &m_flags, result);
62    
63     EFC_DESERIALIZE_AND_SWAP(de, &tmp, result);
64     m_guid=tmp;
65     m_guid <<= 32;
66    
67     EFC_DESERIALIZE_AND_SWAP(de, &tmp, result);
68     m_guid |= tmp;
69    
70     EFC_DESERIALIZE_AND_SWAP(de, &m_type, result);
71     EFC_DESERIALIZE_AND_SWAP(de, &m_version, result);
72
73     int i=0;
74     byte_t *vname=(byte_t *)m_vendor_name;
75     for (i=0; i<HWINFO_NAME_SIZE_BYTES; i++) {
76         result &= de.read(vname++);
77     }
78     byte_t *mname=(byte_t *)m_model_name;
79     for (i=0; i<HWINFO_NAME_SIZE_BYTES; i++) {
80         result &= de.read(mname++);
81     }
82    
83     EFC_DESERIALIZE_AND_SWAP(de, &m_supported_clocks, result);
84     EFC_DESERIALIZE_AND_SWAP(de, &m_nb_1394_playback_channels, result);
85     EFC_DESERIALIZE_AND_SWAP(de, &m_nb_1394_record_channels, result);
86     EFC_DESERIALIZE_AND_SWAP(de, &m_nb_phys_audio_out, result);
87     EFC_DESERIALIZE_AND_SWAP(de, &m_nb_phys_audio_in, result);
88    
89     EFC_DESERIALIZE_AND_SWAP(de, &m_nb_out_groups, result);
90     for (i=0; i<HWINFO_MAX_CAPS_GROUPS; i++) {
91         result &= de.read(&(out_groups[i].type));
92         result &= de.read(&(out_groups[i].count));
93     }
94    
95     EFC_DESERIALIZE_AND_SWAP(de, &m_nb_in_groups, result);
96     for (i=0; i<HWINFO_MAX_CAPS_GROUPS; i++) {
97         result &= de.read(&(in_groups[i].type));
98         result &= de.read(&(in_groups[i].count));
99     }
100    
101     EFC_DESERIALIZE_AND_SWAP(de, &m_nb_midi_out, result);
102     EFC_DESERIALIZE_AND_SWAP(de, &m_nb_midi_in, result);
103     EFC_DESERIALIZE_AND_SWAP(de, &m_max_sample_rate, result);
104     EFC_DESERIALIZE_AND_SWAP(de, &m_min_sample_rate, result);
105     EFC_DESERIALIZE_AND_SWAP(de, &m_dsp_version, result);
106     EFC_DESERIALIZE_AND_SWAP(de, &m_arm_version, result);
107    
108     EFC_DESERIALIZE_AND_SWAP(de, &num_mix_play_chan, result);
109     EFC_DESERIALIZE_AND_SWAP(de, &num_mix_rec_chan, result);
110    
111     if (m_header.version >= 1) {
112         EFC_DESERIALIZE_AND_SWAP(de, &m_fpga_version, result);
113         EFC_DESERIALIZE_AND_SWAP(de, &m_nb_1394_play_chan_2x, result);
114         EFC_DESERIALIZE_AND_SWAP(de, &m_nb_1394_rec_chan_2x, result);
115         EFC_DESERIALIZE_AND_SWAP(de, &m_nb_1394_play_chan_4x, result);
116         EFC_DESERIALIZE_AND_SWAP(de, &m_nb_1394_rec_chan_4x, result);
117     }
118    
119     return result;
120 }
121
122 void
123 EfcHardwareInfoCmd::showEfcCmd()
124 {
125     EfcCmd::showEfcCmd();
126    
127     debugOutput(DEBUG_LEVEL_NORMAL, "EFC HW CAPS info:\n");
128     debugOutput(DEBUG_LEVEL_NORMAL, " Flags   : 0x%08X\n", m_flags);
129     debugOutput(DEBUG_LEVEL_NORMAL, " GUID    : %016"PRIX64"\n", m_guid);
130     debugOutput(DEBUG_LEVEL_NORMAL, " HwType  : 0x%08X\n", m_type);
131     debugOutput(DEBUG_LEVEL_NORMAL, " Version : %u\n", m_version);
132     debugOutput(DEBUG_LEVEL_NORMAL, " Vendor  : %s\n", m_vendor_name);
133     debugOutput(DEBUG_LEVEL_NORMAL, " Model   : %s\n", m_model_name);
134    
135     debugOutput(DEBUG_LEVEL_NORMAL, " Supported Clocks   : 0x%08X\n", m_supported_clocks);
136     debugOutput(DEBUG_LEVEL_NORMAL, " # 1394 Playback    : %d\n", m_nb_1394_playback_channels);
137     debugOutput(DEBUG_LEVEL_NORMAL, " # 1394 Record      : %d\n", m_nb_1394_record_channels);
138     debugOutput(DEBUG_LEVEL_NORMAL, " # Physical out     : %d\n", m_nb_phys_audio_out);
139     debugOutput(DEBUG_LEVEL_NORMAL, " # Physical in      : %d\n", m_nb_phys_audio_in);
140    
141     unsigned int i=0;
142     debugOutput(DEBUG_LEVEL_NORMAL, " # Output Groups    : %d\n", m_nb_out_groups);
143     for (i=0;i<m_nb_out_groups;i++) {
144         debugOutput(DEBUG_LEVEL_NORMAL, "     Group %d: Type 0x%02X, count %d\n",
145                                         i, out_groups[i].type, out_groups[i].count);
146     }
147     debugOutput(DEBUG_LEVEL_NORMAL, " # Input Groups     : %d\n", m_nb_in_groups);
148     for (i=0;i<m_nb_in_groups;i++) {
149         debugOutput(DEBUG_LEVEL_NORMAL, "     Group %d: Type 0x%02X, count %d\n",
150                                         i, in_groups[i].type, in_groups[i].count);
151     }
152     debugOutput(DEBUG_LEVEL_NORMAL, " # Midi out         : %d\n", m_nb_midi_out);
153     debugOutput(DEBUG_LEVEL_NORMAL, " # Midi in          : %d\n", m_nb_midi_in);
154     debugOutput(DEBUG_LEVEL_NORMAL, " Max Sample Rate    : %d\n", m_max_sample_rate);
155     debugOutput(DEBUG_LEVEL_NORMAL, " Min Sample Rate    : %d\n", m_min_sample_rate);
156     debugOutput(DEBUG_LEVEL_NORMAL, " DSP version        : 0x%08X\n", m_dsp_version);
157     debugOutput(DEBUG_LEVEL_NORMAL, " ARM version        : 0x%08X\n", m_arm_version);
158     debugOutput(DEBUG_LEVEL_NORMAL, " # Mix play chann.  : %d\n", num_mix_play_chan);
159     debugOutput(DEBUG_LEVEL_NORMAL, " # Mix rec chann.   : %d\n", num_mix_rec_chan);
160
161     if (m_header.version >= 1) {
162         debugOutput(DEBUG_LEVEL_NORMAL, " FPGA version         : 0x%08X\n", m_fpga_version);
163         debugOutput(DEBUG_LEVEL_NORMAL, " # 1394 Playback (x2) : %d\n", m_nb_1394_play_chan_2x);
164         debugOutput(DEBUG_LEVEL_NORMAL, " # 1394 Record   (x2) : %d\n", m_nb_1394_rec_chan_2x);
165         debugOutput(DEBUG_LEVEL_NORMAL, " # 1394 Playback (x4) : %d\n", m_nb_1394_play_chan_4x);
166         debugOutput(DEBUG_LEVEL_NORMAL, " # 1394 Record   (x4) : %d\n", m_nb_1394_rec_chan_4x);
167     }
168 }
169
170 // --- polled info command
171 EfcPolledValuesCmd::EfcPolledValuesCmd()
172 : EfcCmd(EFC_CAT_HARDWARE_INFO, EFC_CMD_HW_GET_POLLED)
173 , m_nb_output_meters ( 0 )
174 , m_nb_input_meters ( 0 )
175 {}
176
177 bool
178 EfcPolledValuesCmd::serialize( Util::Cmd::IOSSerialize& se )
179 {
180     bool result=true;
181    
182     // the length should be specified before
183     // the header is serialized
184     m_length=EFC_HEADER_LENGTH_QUADLETS;
185    
186     result &= EfcCmd::serialize ( se );
187     return result;
188 }
189
190 bool
191 EfcPolledValuesCmd::deserialize( Util::Cmd::IISDeserialize& de )
192 {
193     bool result=true;
194    
195     result &= EfcCmd::deserialize ( de );
196    
197     // the serialization is different from the deserialization
198     EFC_DESERIALIZE_AND_SWAP(de, &m_status, result);
199    
200     EFC_DESERIALIZE_AND_SWAP(de, &m_detect_spdif, result);
201     EFC_DESERIALIZE_AND_SWAP(de, &m_detect_adat, result);
202     EFC_DESERIALIZE_AND_SWAP(de, &m_reserved3, result);
203     EFC_DESERIALIZE_AND_SWAP(de, &m_reserved4, result);
204
205     EFC_DESERIALIZE_AND_SWAP(de, &m_nb_output_meters, result);
206     EFC_DESERIALIZE_AND_SWAP(de, &m_nb_input_meters, result);
207     EFC_DESERIALIZE_AND_SWAP(de, &m_reserved5, result);
208     EFC_DESERIALIZE_AND_SWAP(de, &m_reserved6, result);
209
210     int i=0;
211     int nb_meters=m_nb_output_meters+m_nb_input_meters;
212    
213     assert(nb_meters<POLLED_MAX_NB_METERS);
214     for (i=0; i<nb_meters; i++) {
215         EFC_DESERIALIZE_AND_SWAP(de, (uint32_t *)&m_meters[i], result);
216     }
217    
218     return result;
219 }
220
221 void
222 EfcPolledValuesCmd::showEfcCmd()
223 {
224     EfcCmd::showEfcCmd();
225    
226     debugOutput(DEBUG_LEVEL_NORMAL, "EFC POLLED info:\n");
227     debugOutput(DEBUG_LEVEL_NORMAL, " Status          : 0x%08X\n", m_status);
228     debugOutput(DEBUG_LEVEL_NORMAL, " Detect SPDIF    : 0x%08X\n", m_detect_spdif);
229     debugOutput(DEBUG_LEVEL_NORMAL, " Detect ADAT     : 0x%08X\n", m_detect_adat);
230    
231     unsigned int i=0;
232     debugOutput(DEBUG_LEVEL_NORMAL, " # Output Meters : %d\n", m_nb_output_meters);
233     for (i=0;i<m_nb_output_meters;i++) {
234         debugOutput(DEBUG_LEVEL_NORMAL, "     Meter %d: %d\n", i, m_meters[i]);
235     }
236    
237     debugOutput(DEBUG_LEVEL_NORMAL, " # Input Meters  : %d\n", m_nb_input_meters);
238     for (;i<m_nb_output_meters+m_nb_input_meters;i++) {
239         debugOutput(DEBUG_LEVEL_NORMAL, "     Meter %d: %d\n", i, m_meters[i]);
240     }
241 }
242
243
244 } // namespace FireWorks
Note: See TracBrowser for help on using the browser.