1 |
/* |
---|
2 |
* Copyright (C) 2005-2007 by by Daniel Wagner |
---|
3 |
* Copyright (C) 2005-2007 by by Pieter Palmers |
---|
4 |
* |
---|
5 |
* This file is part of FFADO |
---|
6 |
* FFADO = Free Firewire (pro-)audio drivers for linux |
---|
7 |
* |
---|
8 |
* FFADO is based upon FreeBoB. |
---|
9 |
* |
---|
10 |
* FFADO 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) any later version. |
---|
14 |
* FFADO 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. |
---|
18 |
* |
---|
19 |
* You should have received a copy of the GNU General Public License |
---|
20 |
* along with FFADO; if not, write to the Free Software |
---|
21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
22 |
* MA 02111-1307 USA. |
---|
23 |
*/ |
---|
24 |
|
---|
25 |
#include "libavc/avc_function_block.h" |
---|
26 |
#include "libavc/avc_serialize.h" |
---|
27 |
#include "debugmodule/debugmodule.h" |
---|
28 |
|
---|
29 |
#include "libieee1394/ieee1394service.h" |
---|
30 |
#include <string.h> |
---|
31 |
|
---|
32 |
DECLARE_GLOBAL_DEBUG_MODULE; |
---|
33 |
|
---|
34 |
const bool bVerbose = true; |
---|
35 |
|
---|
36 |
bool |
---|
37 |
doApp( Ieee1394Service& ieee1394service, int node_id, int fb_id ) |
---|
38 |
{ |
---|
39 |
FunctionBlockCmd fbCmd( ieee1394service, |
---|
40 |
FunctionBlockCmd::eFBT_Processing, |
---|
41 |
fb_id, |
---|
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; |
---|
47 |
|
---|
48 |
debugOutput(DEBUG_LEVEL_NORMAL, "Requesting mixer programmable state...\n"); |
---|
49 |
|
---|
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; |
---|
55 |
|
---|
56 |
fbCmd.setVerbose( bVerbose ); |
---|
57 |
if (bVerbose) { |
---|
58 |
ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE ); |
---|
59 |
} |
---|
60 |
|
---|
61 |
if ( !fbCmd.fire() ) { |
---|
62 |
debugError( "cmd failed\n" ); |
---|
63 |
} |
---|
64 |
|
---|
65 |
if ( bVerbose ) { |
---|
66 |
CoutSerializer se; |
---|
67 |
fbCmd.serialize( se ); |
---|
68 |
} |
---|
69 |
|
---|
70 |
debugOutput(DEBUG_LEVEL_NORMAL, "Requesting mixer level state...\n"); |
---|
71 |
|
---|
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; |
---|
77 |
|
---|
78 |
if ( !fbCmd.fire() ) { |
---|
79 |
debugError( "cmd failed\n" ); |
---|
80 |
} |
---|
81 |
|
---|
82 |
if ( bVerbose ) { |
---|
83 |
CoutSerializer se; |
---|
84 |
fbCmd.serialize( se ); |
---|
85 |
} |
---|
86 |
|
---|
87 |
return true; |
---|
88 |
} |
---|
89 |
|
---|
90 |
bool |
---|
91 |
doApp2( Ieee1394Service& ieee1394service, int node_id, int fb_id ) |
---|
92 |
{ |
---|
93 |
FunctionBlockCmd fbCmd( ieee1394service, |
---|
94 |
FunctionBlockCmd::eFBT_Selector, |
---|
95 |
fb_id, |
---|
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; |
---|
101 |
|
---|
102 |
debugOutput(DEBUG_LEVEL_NORMAL, "Requesting selector state...\n"); |
---|
103 |
|
---|
104 |
fbCmd.setVerbose( bVerbose ); |
---|
105 |
if (bVerbose) { |
---|
106 |
ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE ); |
---|
107 |
} |
---|
108 |
|
---|
109 |
if ( !fbCmd.fire() ) { |
---|
110 |
debugError( "cmd failed\n" ); |
---|
111 |
} |
---|
112 |
|
---|
113 |
if ( bVerbose ) { |
---|
114 |
CoutSerializer se; |
---|
115 |
fbCmd.serialize( se ); |
---|
116 |
} |
---|
117 |
|
---|
118 |
return true; |
---|
119 |
} |
---|
120 |
|
---|
121 |
bool |
---|
122 |
doApp3( Ieee1394Service& ieee1394service, int node_id, int fb_id , int val ) |
---|
123 |
{ |
---|
124 |
FunctionBlockCmd fbCmd( ieee1394service, |
---|
125 |
FunctionBlockCmd::eFBT_Selector, |
---|
126 |
fb_id, |
---|
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; |
---|
132 |
|
---|
133 |
debugOutput(DEBUG_LEVEL_NORMAL, "Setting selector state to %d...\n", val); |
---|
134 |
|
---|
135 |
fbCmd.setVerbose( bVerbose ); |
---|
136 |
if (bVerbose) { |
---|
137 |
ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE ); |
---|
138 |
} |
---|
139 |
|
---|
140 |
if ( !fbCmd.fire() ) { |
---|
141 |
debugError( "cmd failed\n" ); |
---|
142 |
} |
---|
143 |
|
---|
144 |
if ( bVerbose ) { |
---|
145 |
CoutSerializer se; |
---|
146 |
fbCmd.serialize( se ); |
---|
147 |
} |
---|
148 |
|
---|
149 |
return true; |
---|
150 |
} |
---|
151 |
|
---|
152 |
/////////////////////////// |
---|
153 |
// main |
---|
154 |
////////////////////////// |
---|
155 |
int |
---|
156 |
main( int argc, char **argv ) |
---|
157 |
{ |
---|
158 |
|
---|
159 |
if (argc < 3) { |
---|
160 |
debugError("usage: PORT NODE_ID FB_ID\n"); |
---|
161 |
exit(0); |
---|
162 |
} |
---|
163 |
|
---|
164 |
int errno = 0; |
---|
165 |
char* tail; |
---|
166 |
int port = strtol( argv[1], &tail, 0 ); |
---|
167 |
int node_id = strtol( argv[2], &tail, 0 ); |
---|
168 |
int fb_id = strtol( argv[3], &tail, 0 ); |
---|
169 |
|
---|
170 |
if (errno) { |
---|
171 |
debugError("argument parsing failed: %s", strerror(errno)); |
---|
172 |
return -1; |
---|
173 |
} |
---|
174 |
Ieee1394Service ieee1394service; |
---|
175 |
if ( !ieee1394service.initialize( port ) ) { |
---|
176 |
debugError( "could not set port on ieee1394service\n" ); |
---|
177 |
return -1; |
---|
178 |
} |
---|
179 |
|
---|
180 |
doApp( ieee1394service, node_id, fb_id ); |
---|
181 |
doApp2( ieee1394service, node_id, fb_id ); |
---|
182 |
doApp3( ieee1394service, node_id, fb_id , 0 ); |
---|
183 |
sleep(1); |
---|
184 |
doApp3( ieee1394service, node_id, fb_id , 1 ); |
---|
185 |
sleep(1); |
---|
186 |
doApp3( ieee1394service, node_id, fb_id , 0 ); |
---|
187 |
|
---|
188 |
return 0; |
---|
189 |
} |
---|