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/>.
25 #include "efc_cmds_mixer.h"
27 #include "libutil/ByteSwap.h"
34 EfcGenericMixerCmd::EfcGenericMixerCmd(enum eMixerTarget target
,
35 enum eMixerCommand command
)
48 EfcGenericMixerCmd::EfcGenericMixerCmd(enum eMixerTarget target
,
49 enum eMixerCommand command
,
52 , m_channel ( channel
)
64 EfcGenericMixerCmd::serialize( Util::Cmd::IOSSerialize
& se
)
68 if (m_type
== eCT_Get
) {
69 // the length should be specified before
70 // the header is serialized
71 m_length
=EFC_HEADER_LENGTH_QUADLETS
+1;
73 result
&= EfcCmd::serialize ( se
);
75 result
&= se
.write(CondSwapToBus32(m_channel
), "Channel" );
78 // the length should be specified before
79 // the header is serialized
80 m_length
=EFC_HEADER_LENGTH_QUADLETS
+2;
82 result
&= EfcCmd::serialize ( se
);
84 result
&= se
.write(CondSwapToBus32(m_channel
), "Channel" );
85 result
&= se
.write(CondSwapToBus32(m_value
), "Value" );
89 debugWarning("Serialization failed\n");
96 EfcGenericMixerCmd::deserialize( Util::Cmd::IISDeserialize
& de
)
100 result
&= EfcCmd::deserialize ( de
);
102 if (m_type
== eCT_Get
) {
103 EFC_DESERIALIZE_AND_SWAP(de
, (quadlet_t
*)&m_channel
, result
);
104 EFC_DESERIALIZE_AND_SWAP(de
, &m_value
, result
);
108 debugWarning("Deserialization failed\n");
115 EfcGenericMixerCmd::setType( enum eCmdType type
)
118 if (type
== eCT_Get
) {
121 m_command_id
=EFC_CMD_MIXER_GET_GAIN
;
124 m_command_id
=EFC_CMD_MIXER_GET_SOLO
;
127 m_command_id
=EFC_CMD_MIXER_GET_MUTE
;
130 m_command_id
=EFC_CMD_MIXER_GET_PAN
;
133 m_command_id
=EFC_CMD_MIXER_GET_NOMINAL
;
136 debugError("Invalid mixer get command: %d\n", m_command
);
142 m_command_id
=EFC_CMD_MIXER_SET_GAIN
;
145 m_command_id
=EFC_CMD_MIXER_SET_SOLO
;
148 m_command_id
=EFC_CMD_MIXER_SET_MUTE
;
151 m_command_id
=EFC_CMD_MIXER_SET_PAN
;
154 m_command_id
=EFC_CMD_MIXER_SET_NOMINAL
;
157 debugError("Invalid mixer set command: %d\n", m_command
);
165 EfcGenericMixerCmd::setTarget( enum eMixerTarget target
)
169 case eMT_PhysicalOutputMix
:
170 m_category_id
=EFC_CAT_PHYSICAL_OUTPUT_MIX
;
172 case eMT_PhysicalInputMix
:
173 m_category_id
=EFC_CAT_PHYSICAL_INPUT_MIX
;
175 case eMT_PlaybackMix
:
176 m_category_id
=EFC_CAT_PLAYBACK_MIX
;
179 m_category_id
=EFC_CAT_RECORD_MIX
;
182 debugError("Invalid mixer target: %d\n", target
);
189 EfcGenericMixerCmd::setCommand( enum eMixerCommand command
)
192 if (m_type
== eCT_Get
) {
195 m_command_id
=EFC_CMD_MIXER_GET_GAIN
;
198 m_command_id
=EFC_CMD_MIXER_GET_SOLO
;
201 m_command_id
=EFC_CMD_MIXER_GET_MUTE
;
204 m_command_id
=EFC_CMD_MIXER_GET_PAN
;
207 m_command_id
=EFC_CMD_MIXER_GET_NOMINAL
;
210 debugError("Invalid mixer get command: %d\n", command
);
216 m_command_id
=EFC_CMD_MIXER_SET_GAIN
;
219 m_command_id
=EFC_CMD_MIXER_SET_SOLO
;
222 m_command_id
=EFC_CMD_MIXER_SET_MUTE
;
225 m_command_id
=EFC_CMD_MIXER_SET_PAN
;
228 m_command_id
=EFC_CMD_MIXER_SET_NOMINAL
;
231 debugError("Invalid mixer set command: %d\n", command
);
240 EfcGenericMixerCmd::showEfcCmd()
242 EfcCmd::showEfcCmd();
243 debugOutput(DEBUG_LEVEL_NORMAL
, "EFC %s %s %s:\n",
244 (m_type
==eCT_Get
?"GET":"SET"),
245 eMixerTargetToString(m_target
),
246 eMixerCommandToString(m_command
));
247 debugOutput(DEBUG_LEVEL_NORMAL
, " Channel : %d\n", m_channel
);
248 debugOutput(DEBUG_LEVEL_NORMAL
, " Value : %u\n", m_value
);
251 // --- The specific commands
255 } // namespace FireWorks