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

Revision 2803, 9.5 kB (checked in by jwoithe, 3 years ago)

Cosmetic: capitalise "L" in "Linux".

"Linux" is a proper noun so it should start with a capital letter. These
changes are almost all within comments.

This patch was originally proposed by pander on the ffado-devel mailing
list. It has been expanded to cover all similar cases to maintain
consistency throughout the source tree.

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     int i, nb_meters;
194     bool result;
195    
196     if (!EfcCmd::deserialize(de))
197         return false;
198    
199     // the serialization is different from the deserialization
200     result = true;
201     EFC_DESERIALIZE_AND_SWAP(de, &m_status, result);
202    
203     EFC_DESERIALIZE_AND_SWAP(de, &m_detect_spdif, result);
204     EFC_DESERIALIZE_AND_SWAP(de, &m_detect_adat, result);
205     EFC_DESERIALIZE_AND_SWAP(de, &m_reserved3, result);
206     EFC_DESERIALIZE_AND_SWAP(de, &m_reserved4, result);
207
208     EFC_DESERIALIZE_AND_SWAP(de, &m_nb_output_meters, result);
209     EFC_DESERIALIZE_AND_SWAP(de, &m_nb_input_meters, result);
210     EFC_DESERIALIZE_AND_SWAP(de, &m_reserved5, result);
211     EFC_DESERIALIZE_AND_SWAP(de, &m_reserved6, result);
212
213     if (!result)
214         return result;
215
216     /*
217      * NOTE:
218      * Firmware version 5.0 or later for AudioFire12 returns invalid values to
219      * contents of response against this command. Currently apply a workaround
220      * to compensate the value because this value is not re-used again.
221      */
222     nb_meters = m_nb_output_meters + m_nb_input_meters;
223     if (nb_meters > POLLED_MAX_NB_METERS) {
224         m_nb_output_meters = 0;
225         m_nb_input_meters = 0;
226         nb_meters = 0;
227     }
228
229     for (i = 0; i < nb_meters; i++)
230         EFC_DESERIALIZE_AND_SWAP(de, (uint32_t *)&m_meters[i], result);
231    
232     return result;
233 }
234
235 void
236 EfcPolledValuesCmd::showEfcCmd()
237 {
238     unsigned int i;
239
240     EfcCmd::showEfcCmd();
241    
242     debugOutput(DEBUG_LEVEL_NORMAL, "EFC POLLED info:\n");
243     debugOutput(DEBUG_LEVEL_NORMAL, " Status          : 0x%08X\n", m_status);
244     debugOutput(DEBUG_LEVEL_NORMAL, " Detect SPDIF    : 0x%08X\n", m_detect_spdif);
245     debugOutput(DEBUG_LEVEL_NORMAL, " Detect ADAT     : 0x%08X\n", m_detect_adat);
246    
247     /* prevent buffer over run */
248     if (m_nb_output_meters + m_nb_input_meters > POLLED_MAX_NB_METERS)
249         return;
250
251     if (m_nb_output_meters > 0) {
252         debugOutput(DEBUG_LEVEL_NORMAL, " # Output Meters : %d\n", m_nb_output_meters);
253         for (i = 0; i < m_nb_output_meters; i++)
254             debugOutput(DEBUG_LEVEL_NORMAL, "     Meter %d: %d\n", i, m_meters[i]);
255     }   
256
257     if (m_nb_input_meters > 0) {
258         debugOutput(DEBUG_LEVEL_NORMAL, " # Input Meters  : %d\n", m_nb_input_meters);
259         for (; i < m_nb_output_meters + m_nb_input_meters; i++)
260             debugOutput(DEBUG_LEVEL_NORMAL, "     Meter %d: %d\n", i, m_meters[i]);
261     }
262 }
263
264
265 } // namespace FireWorks
Note: See TracBrowser for help on using the browser.