2 * Copyright (C) 2005-2008 by Daniel Wagner
3 * Copyright (C) 2005-2008 by Pieter Palmers
5 * This file is part of FFADO
6 * FFADO = Free Firewire (pro-)audio drivers for linux
8 * FFADO is based upon FreeBoB.
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 2 of the License, or
13 * (at your option) version 3 of the License.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "libavc/avc_function_block.h"
26 #include "libavc/avc_serialize.h"
27 #include "debugmodule/debugmodule.h"
29 #include "libieee1394/ieee1394service.h"
32 DECLARE_GLOBAL_DEBUG_MODULE
;
34 const bool bVerbose
= true;
37 doApp( Ieee1394Service
& ieee1394service
, int node_id
, int fb_id
)
39 FunctionBlockCmd
fbCmd( ieee1394service
,
40 FunctionBlockCmd::eFBT_Processing
,
42 FunctionBlockCmd::eCA_Current
);
43 fbCmd
.setNodeId( node_id
);
44 fbCmd
.setSubunitId( 0x00 );
45 fbCmd
.setCommandType( AVCCommand::eCT_Status
);
46 fbCmd
.m_pFBProcessing
->m_pEnhancedMixer
= new FunctionBlockProcessingEnhancedMixer
;
48 debugOutput(DEBUG_LEVEL_NORMAL
, "Requesting mixer programmable state...\n");
50 fbCmd
.m_pFBProcessing
->m_fbInputPlugNumber
= 0x00;
51 fbCmd
.m_pFBProcessing
->m_inputAudioChannelNumber
= 0xff;
52 fbCmd
.m_pFBProcessing
->m_outputAudioChannelNumber
= 0xff;
53 fbCmd
.m_pFBProcessing
->m_pEnhancedMixer
->m_statusSelector
54 = FunctionBlockProcessingEnhancedMixer::eSS_ProgramableState
;
56 fbCmd
.setVerbose( bVerbose
);
58 ieee1394service
.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE
);
61 if ( !fbCmd
.fire() ) {
62 debugError( "cmd failed\n" );
67 fbCmd
.serialize( se
);
70 debugOutput(DEBUG_LEVEL_NORMAL
, "Requesting mixer level state...\n");
72 fbCmd
.m_pFBProcessing
->m_fbInputPlugNumber
= 0x00;
73 fbCmd
.m_pFBProcessing
->m_inputAudioChannelNumber
= 0x00;
74 fbCmd
.m_pFBProcessing
->m_outputAudioChannelNumber
= 0x00;
75 fbCmd
.m_pFBProcessing
->m_pEnhancedMixer
->m_statusSelector
76 = FunctionBlockProcessingEnhancedMixer::eSS_Level
;
78 if ( !fbCmd
.fire() ) {
79 debugError( "cmd failed\n" );
84 fbCmd
.serialize( se
);
91 selectorGet( Ieee1394Service
& ieee1394service
, int node_id
, int fb_id
)
93 FunctionBlockCmd
fbCmd( ieee1394service
,
94 FunctionBlockCmd::eFBT_Selector
,
96 FunctionBlockCmd::eCA_Current
);
97 fbCmd
.setNodeId( node_id
);
98 fbCmd
.setSubunitId( 0x00 );
99 fbCmd
.setCommandType( AVCCommand::eCT_Status
);
100 fbCmd
.m_pFBSelector
->m_inputFbPlugNumber
=0;
102 debugOutput(DEBUG_LEVEL_NORMAL
, "Requesting selector state...\n");
104 fbCmd
.setVerbose( bVerbose
);
106 ieee1394service
.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE
);
109 if ( !fbCmd
.fire() ) {
110 debugError( "cmd failed\n" );
115 fbCmd
.serialize( se
);
122 selectorSet( Ieee1394Service
& ieee1394service
, int node_id
, int fb_id
, int val
)
124 FunctionBlockCmd
fbCmd( ieee1394service
,
125 FunctionBlockCmd::eFBT_Selector
,
127 FunctionBlockCmd::eCA_Current
);
128 fbCmd
.setNodeId( node_id
);
129 fbCmd
.setSubunitId( 0x00 );
130 fbCmd
.setCommandType( AVCCommand::eCT_Control
);
131 fbCmd
.m_pFBSelector
->m_inputFbPlugNumber
=val
;
133 debugOutput(DEBUG_LEVEL_NORMAL
, "Setting selector state to %d...\n", val
);
135 fbCmd
.setVerbose( bVerbose
);
137 ieee1394service
.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE
);
140 if ( !fbCmd
.fire() ) {
141 debugError( "cmd failed\n" );
146 fbCmd
.serialize( se
);
153 volumeGet( Ieee1394Service
& ieee1394service
, int node_id
, int fb_id
, int channel
)
155 FunctionBlockCmd
fbCmd( ieee1394service
,
156 FunctionBlockCmd::eFBT_Feature
,
158 FunctionBlockCmd::eCA_Current
);
159 fbCmd
.setNodeId( node_id
);
160 fbCmd
.setSubunitId( 0x00 );
161 fbCmd
.setCommandType( AVCCommand::eCT_Status
);
162 fbCmd
.m_pFBFeature
->m_audioChannelNumber
=channel
;
163 fbCmd
.m_pFBFeature
->m_controlSelector
=FunctionBlockFeature::eCSE_Feature_Volume
;
164 fbCmd
.m_pFBFeature
->m_pVolume
->m_volume
=0;
166 debugOutput(DEBUG_LEVEL_NORMAL
, "Requesting volume feature block state...\n");
168 fbCmd
.setVerbose( bVerbose
);
170 ieee1394service
.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE
);
173 if ( !fbCmd
.fire() ) {
174 debugError( "cmd failed\n" );
179 fbCmd
.serialize( se
);
186 volumeSet( Ieee1394Service
& ieee1394service
, int node_id
, int fb_id
, int channel
, int value
)
188 FunctionBlockCmd
fbCmd( ieee1394service
,
189 FunctionBlockCmd::eFBT_Feature
,
191 FunctionBlockCmd::eCA_Current
);
192 fbCmd
.setNodeId( node_id
);
193 fbCmd
.setSubunitId( 0x00 );
194 fbCmd
.setCommandType( AVCCommand::eCT_Control
);
195 fbCmd
.m_pFBFeature
->m_audioChannelNumber
=channel
;
196 fbCmd
.m_pFBFeature
->m_controlSelector
=FunctionBlockFeature::eCSE_Feature_Volume
;
197 fbCmd
.m_pFBFeature
->m_pVolume
->m_volume
=value
;
199 debugOutput(DEBUG_LEVEL_NORMAL
, "Setting volume feature block channel %d state to %d...\n", channel
, value
);
201 fbCmd
.setVerbose( bVerbose
);
203 ieee1394service
.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE
);
206 if ( !fbCmd
.fire() ) {
207 debugError( "cmd failed\n" );
212 fbCmd
.serialize( se
);
218 ///////////////////////////
220 //////////////////////////
222 main( int argc
, char **argv
)
226 debugError("usage: PORT NODE_ID CMD FB_ID [VAL1] [VAL2]\n");
232 int port
= strtol( argv
[1], &tail
, 0 );
233 int node_id
= strtol( argv
[2], &tail
, 0 );
234 int cmd
= strtol( argv
[3], &tail
, 0 );
235 int fb_id
= strtol( argv
[4], &tail
, 0 );
241 value1
= strtol(argv
[5], &tail
, 0 );
244 value2
= strtol(argv
[6], &tail
, 0 );
247 debugError("argument parsing failed: %s\n", strerror(errno
));
250 Ieee1394Service ieee1394service
;
251 if ( !ieee1394service
.initialize( port
) ) {
252 debugError( "could not set port on ieee1394service\n" );
258 doApp( ieee1394service
, node_id
, fb_id
);
261 selectorGet( ieee1394service
, node_id
, fb_id
);
264 selectorSet( ieee1394service
, node_id
, fb_id
, value1
);
267 volumeGet( ieee1394service
, node_id
, fb_id
, value1
);
270 volumeSet( ieee1394service
, node_id
, fb_id
, value1
, value2
);