motu: the 4pre channel layout within packets is now believed to be correct. Thanks...
[ffado.git] / libffado / src / fireworks / efc / efc_cmds_monitor.cpp
blobcb750431d52963fd9a512a7a3ca0f08146410cd5
1 /*
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_cmd.h"
25 #include "efc_cmds_monitor.h"
27 #include "libutil/ByteSwap.h"
28 #include <iostream>
30 using namespace std;
32 namespace FireWorks {
34 const char *eMonitorCommandToString(const enum eMonitorCommand command) {
35 switch (command) {
36 case eMoC_Gain:
37 return "eMC_Gain";
38 case eMoC_Solo:
39 return "eMoC_Solo";
40 case eMoC_Mute:
41 return "eMoC_Mute";
42 case eMoC_Pan:
43 return "eMoC_Pan";
44 default:
45 return "invalid";
49 EfcGenericMonitorCmd::EfcGenericMonitorCmd(enum eCmdType type,
50 enum eMonitorCommand command)
51 : EfcCmd()
52 , m_input ( -1 )
53 , m_output ( -1 )
54 , m_value ( 0 )
55 , m_type ( type )
56 , m_command ( command )
58 m_category_id=EFC_CAT_MONITOR_MIX;
59 if (type == eCT_Get) {
60 switch (command) {
61 case eMoC_Gain:
62 m_command_id=EFC_CMD_MIXER_GET_GAIN;
63 break;
64 case eMoC_Solo:
65 m_command_id=EFC_CMD_MIXER_GET_SOLO;
66 break;
67 case eMoC_Mute:
68 m_command_id=EFC_CMD_MIXER_GET_MUTE;
69 break;
70 case eMoC_Pan:
71 m_command_id=EFC_CMD_MIXER_GET_PAN;
72 break;
73 default:
74 debugError("Invalid mixer get command: %d\n", command);
76 } else {
77 switch (command) {
78 case eMoC_Gain:
79 m_command_id=EFC_CMD_MIXER_SET_GAIN;
80 break;
81 case eMoC_Solo:
82 m_command_id=EFC_CMD_MIXER_SET_SOLO;
83 break;
84 case eMoC_Mute:
85 m_command_id=EFC_CMD_MIXER_SET_MUTE;
86 break;
87 case eMoC_Pan:
88 m_command_id=EFC_CMD_MIXER_SET_PAN;
89 break;
90 default:
91 debugError("Invalid mixer set command: %d\n", command);
96 bool
97 EfcGenericMonitorCmd::serialize( Util::Cmd::IOSSerialize& se )
99 bool result=true;
101 if (m_type == eCT_Get) {
102 // the length should be specified before
103 // the header is serialized
104 m_length=EFC_HEADER_LENGTH_QUADLETS+2;
106 result &= EfcCmd::serialize ( se );
108 result &= se.write(CondSwapToBus32(m_input), "Input" );
109 result &= se.write(CondSwapToBus32(m_output), "Output" );
111 } else {
112 // the length should be specified before
113 // the header is serialized
114 m_length=EFC_HEADER_LENGTH_QUADLETS+3;
116 result &= EfcCmd::serialize ( se );
118 result &= se.write(CondSwapToBus32(m_input), "Input" );
119 result &= se.write(CondSwapToBus32(m_output), "Output" );
120 result &= se.write(CondSwapToBus32(m_value), "Value" );
122 return result;
125 bool
126 EfcGenericMonitorCmd::deserialize( Util::Cmd::IISDeserialize& de )
128 bool result=true;
130 result &= EfcCmd::deserialize ( de );
132 if (m_type == eCT_Get) {
133 EFC_DESERIALIZE_AND_SWAP(de, (quadlet_t *)&m_input, result);
134 EFC_DESERIALIZE_AND_SWAP(de, (quadlet_t *)&m_output, result);
135 EFC_DESERIALIZE_AND_SWAP(de, &m_value, result);
138 if(!result) {
139 debugWarning("Deserialization failed\n");
142 return result;
145 void
146 EfcGenericMonitorCmd::showEfcCmd()
148 EfcCmd::showEfcCmd();
149 debugOutput(DEBUG_LEVEL_NORMAL, "EFC %s MONITOR %s:\n",
150 (m_type==eCT_Get?"GET":"SET"),
151 eMonitorCommandToString(m_command));
152 debugOutput(DEBUG_LEVEL_NORMAL, " Input : %d\n", m_input);
153 debugOutput(DEBUG_LEVEL_NORMAL, " Output : %d\n", m_output);
154 debugOutput(DEBUG_LEVEL_NORMAL, " Value : %u\n", m_value);
157 // --- The specific commands
161 } // namespace FireWorks