2 * Copyright (C) 2005-2008 by Pieter Palmers
4 * This file is part of FFADO
5 * FFADO = Free Firewire (pro-)audio drivers for linux
7 * FFADO is based upon FreeBoB
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.
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.
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/>.
24 #include "efc_cmds_hardware.h"
26 #include "libutil/ByteSwap.h"
33 EfcHardwareInfoCmd::EfcHardwareInfoCmd()
34 : EfcCmd(EFC_CAT_HARDWARE_INFO
, EFC_CMD_HW_HWINFO_GET_CAPS
)
35 , m_nb_out_groups( 0 )
40 EfcHardwareInfoCmd::serialize( Util::Cmd::IOSSerialize
& se
)
44 // the length should be specified before
45 // the header is serialized
46 m_length
=EFC_HEADER_LENGTH_QUADLETS
;
48 result
&= EfcCmd::serialize ( se
);
53 EfcHardwareInfoCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
58 result
&= EfcCmd::deserialize ( de
);
60 // the serialization is different from the deserialization
61 EFC_DESERIALIZE_AND_SWAP(de
, &m_flags
, result
);
63 EFC_DESERIALIZE_AND_SWAP(de
, &tmp
, result
);
67 EFC_DESERIALIZE_AND_SWAP(de
, &tmp
, result
);
70 EFC_DESERIALIZE_AND_SWAP(de
, &m_type
, result
);
71 EFC_DESERIALIZE_AND_SWAP(de
, &m_version
, result
);
74 byte_t
*vname
=(byte_t
*)m_vendor_name
;
75 for (i
=0; i
<HWINFO_NAME_SIZE_BYTES
; i
++) {
76 result
&= de
.read(vname
++);
78 byte_t
*mname
=(byte_t
*)m_model_name
;
79 for (i
=0; i
<HWINFO_NAME_SIZE_BYTES
; i
++) {
80 result
&= de
.read(mname
++);
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
);
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
));
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
));
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
);
108 EFC_DESERIALIZE_AND_SWAP(de
, &num_mix_play_chan
, result
);
109 EFC_DESERIALIZE_AND_SWAP(de
, &num_mix_rec_chan
, result
);
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
);
123 EfcHardwareInfoCmd::showEfcCmd()
125 EfcCmd::showEfcCmd();
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
);
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
);
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
);
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
);
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
);
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
);
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 )
178 EfcPolledValuesCmd::serialize( Util::Cmd::IOSSerialize
& se
)
182 // the length should be specified before
183 // the header is serialized
184 m_length
=EFC_HEADER_LENGTH_QUADLETS
;
186 result
&= EfcCmd::serialize ( se
);
191 EfcPolledValuesCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
196 if (!EfcCmd::deserialize(de
))
199 // the serialization is different from the deserialization
201 EFC_DESERIALIZE_AND_SWAP(de
, &m_status
, result
);
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
);
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
);
216 nb_meters
= m_nb_output_meters
+ m_nb_input_meters
;
217 if (nb_meters
> POLLED_MAX_NB_METERS
) {
218 m_nb_output_meters
= 0;
219 m_nb_input_meters
= 0;
224 for (i
= 0; i
< nb_meters
; i
++)
225 EFC_DESERIALIZE_AND_SWAP(de
, (uint32_t *)&m_meters
[i
], result
);
231 EfcPolledValuesCmd::showEfcCmd()
235 EfcCmd::showEfcCmd();
237 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC POLLED info:\n");
238 debugOutput(DEBUG_LEVEL_NORMAL
, " Status : 0x%08X\n", m_status
);
239 debugOutput(DEBUG_LEVEL_NORMAL
, " Detect SPDIF : 0x%08X\n", m_detect_spdif
);
240 debugOutput(DEBUG_LEVEL_NORMAL
, " Detect ADAT : 0x%08X\n", m_detect_adat
);
242 /* prevent buffer over run */
243 if (m_nb_output_meters
+ m_nb_input_meters
> POLLED_MAX_NB_METERS
)
246 if (m_nb_output_meters
> 0) {
247 debugOutput(DEBUG_LEVEL_NORMAL
, " # Output Meters : %d\n", m_nb_output_meters
);
248 for (i
= 0; i
< m_nb_output_meters
; i
++)
249 debugOutput(DEBUG_LEVEL_NORMAL
, " Meter %d: %d\n", i
, m_meters
[i
]);
252 if (m_nb_input_meters
> 0) {
253 debugOutput(DEBUG_LEVEL_NORMAL
, " # Input Meters : %d\n", m_nb_input_meters
);
254 for (; i
< m_nb_output_meters
+ m_nb_input_meters
; i
++)
255 debugOutput(DEBUG_LEVEL_NORMAL
, " Meter %d: %d\n", i
, m_meters
[i
]);
260 } // namespace FireWorks