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

Revision 629, 8.7 kB (checked in by ppalmers, 15 years ago)

- Base infrastructure for the Echo EFC commands
- Some first command implementations

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