Changeset 455
- Timestamp:
- 04/09/07 04:25:12 (16 years ago)
- Files:
-
- trunk/libffado/src/bebob/bebob_functionblock.h (modified) (1 diff)
- trunk/libffado/src/bebob/GenericMixer.cpp (modified) (2 diffs)
- trunk/libffado/src/bebob/GenericMixer.h (modified) (1 diff)
- trunk/libffado/src/libavc/avc_function_block.cpp (modified) (10 diffs)
- trunk/libffado/src/libavc/avc_function_block.h (modified) (2 diffs)
- trunk/libffado/tests/test-mixer.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bebob/bebob_functionblock.h
r451 r455 138 138 139 139 virtual const char* getName(); 140 141 // FIXME: this is not pretty! 142 enum EControlSelectorEncoding { 143 eCSE_Feature_Unknown = 0x00, 144 eCSE_Feature_Mute = 0x01, 145 eCSE_Feature_Volume = 0x02, 146 eCSE_Feature_LRBalance = 0x03, 147 eCSE_Feature_FRBalance = 0x04, 148 eCSE_Feature_Bass = 0x05, 149 eCSE_Feature_Mid = 0x06, 150 eCSE_Feature_Treble = 0x07, 151 eCSE_Feature_GEQ = 0x08, 152 eCSE_Feature_AGC = 0x09, 153 eCSE_Feature_Delay = 0x0a, 154 eCSE_Feature_BassBoost = 0x0b, 155 eCSE_Feature_Loudness = 0x0c, 156 }; 140 157 141 158 protected: trunk/libffado/src/bebob/GenericMixer.cpp
r451 r455 94 94 return OscResponse(OscResponse::eError); 95 95 } 96 if(! (m->getArgument(3).isInt64() || m->getArgument(3).isFloat())) {96 if(!m->getArgument(3).isNumeric()) { 97 97 debugWarning("set selector: Wrong argument type\n"); 98 98 return OscResponse(OscResponse::eError); 99 99 } 100 101 int value=m->getArgument(3).getInt(); 102 103 if (m->getArgument(3).isFloat()) { 104 value=(int)(m->getArgument(3).getFloat()); 105 } 100 int value=m->getArgument(3).toInt(); 106 101 107 102 return mixerSetSelectorValue(id, value); 108 103 } 109 104 105 if (type == "volume") { 106 if ( !(nbArgs==7)) { 107 debugWarning("set volume: Wrong nb of arguments\n"); 108 return OscResponse(OscResponse::eError); 109 } 110 if(!m->getArgument(3).isNumeric()) { 111 debugWarning("set volume: Wrong argument (3) type\n"); 112 return OscResponse(OscResponse::eError); 113 } 114 if(!m->getArgument(4).isNumeric()) { 115 debugWarning("set volume: Wrong argument (4) type\n"); 116 return OscResponse(OscResponse::eError); 117 } 118 119 int channel=m->getArgument(3).toInt(); 120 int volume=m->getArgument(4).toInt(); 121 122 return mixerSetFeatureVolumeValue(id, channel, volume); 123 } 124 110 125 return OscResponse(OscResponse::eError); 111 126 } … … 230 245 } 231 246 247 OscResponse 248 GenericMixer::mixerSetFeatureVolumeValue(int fb_id, int channel, 249 int volume) { 250 OscMessage m; 251 252 debugOutput(DEBUG_LEVEL_NORMAL,"Set feature volume %d channel %d to %d...\n", 253 fb_id, channel, volume); 254 255 FunctionBlockCmd fbCmd( m_p1394Service, 256 FunctionBlockCmd::eFBT_Feature, 257 fb_id, 258 FunctionBlockCmd::eCA_Current ); 259 fbCmd.setNodeId( m_device.getNodeId() ); 260 fbCmd.setSubunitId( 0x00 ); 261 fbCmd.setCommandType( AVCCommand::eCT_Control ); 262 fbCmd.m_pFBFeature->m_audioChannelNumber=channel; 263 fbCmd.m_pFBFeature->m_controlSelector=FunctionBlockFeature::eCSE_Feature_Volume; 264 fbCmd.m_pFBFeature->m_pVolume->m_volume=volume; 265 266 if ( !fbCmd.fire() ) { 267 debugError( "cmd failed\n" ); 268 } 269 270 if (fbCmd.getResponse() != AVCCommand::eR_Accepted) { 271 return OscResponse(OscResponse::eError); 272 } 273 274 return OscResponse(m); 275 } 276 277 OscResponse 278 GenericMixer::mixerGetFeatureVolumeValue(int fb_id, int channel) { 279 OscMessage m; 280 281 debugOutput(DEBUG_LEVEL_NORMAL,"Get feature volume %d channel %d...\n", 282 fb_id, channel); 283 284 FunctionBlockCmd fbCmd( m_p1394Service, 285 FunctionBlockCmd::eFBT_Feature, 286 fb_id, 287 FunctionBlockCmd::eCA_Current ); 288 fbCmd.setNodeId( m_device.getNodeId() ); 289 fbCmd.setSubunitId( 0x00 ); 290 fbCmd.setCommandType( AVCCommand::eCT_Status ); 291 fbCmd.m_pFBFeature->m_audioChannelNumber=channel; 292 fbCmd.m_pFBFeature->m_controlSelector=FunctionBlockFeature::eCSE_Feature_Volume; 293 fbCmd.m_pFBFeature->m_pVolume->m_volume=0; 294 295 if ( !fbCmd.fire() ) { 296 debugError( "cmd failed\n" ); 297 } 298 299 if (fbCmd.getResponse() != AVCCommand::eR_Accepted) { 300 return OscResponse(OscResponse::eError); 301 } 302 303 m.addArgument((int32_t)(fbCmd.m_pFBFeature->m_pVolume->m_volume)); 304 305 return OscResponse(m); 306 } 232 307 233 308 } // end of namespace BeBoB trunk/libffado/src/bebob/GenericMixer.h
r451 r455 51 51 OSC::OscResponse mixerGetSelectorValue(int id); 52 52 OSC::OscResponse mixerSetSelectorValue(int id, int value); 53 54 OSC::OscResponse mixerSetFeatureVolumeValue(int id, int channel, int volume); 55 OSC::OscResponse mixerGetFeatureVolumeValue(int fb_id, int channel); 56 53 57 protected: 54 58 Ieee1394Service &m_p1394Service; trunk/libffado/src/libavc/avc_function_block.cpp
r445 r455 1 1 /* 2 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 * Copyright (C) 2005-2007 by Pieter Palmers 3 4 * 4 5 * This file is part of FFADO … … 30 31 FunctionBlockFeatureVolume::FunctionBlockFeatureVolume() 31 32 : IBusData() 32 , m_controlSelector( FunctionBlockFeature::eCSE_Feature_Volume )33 33 , m_controlDataLength( 2 ) 34 34 , m_volume( 0 ) … … 37 37 38 38 FunctionBlockFeatureVolume::FunctionBlockFeatureVolume( const FunctionBlockFeatureVolume& rhs ) 39 : m_controlSelector( rhs.m_controlSelector ) 40 , m_controlDataLength( rhs.m_controlDataLength ) 39 : m_controlDataLength( rhs.m_controlDataLength ) 41 40 , m_volume( rhs.m_volume ) 42 41 { … … 52 51 bool bStatus; 53 52 byte_t val; 54 bStatus = se.write( m_controlSelector, "FunctionBlockFeatureVolume controlSelector" ); 55 bStatus &= se.write( m_controlDataLength, "FunctionBlockFeatureVolume controlDataLength" ); 53 bStatus = se.write( m_controlDataLength, "FunctionBlockFeatureVolume controlDataLength" ); 56 54 val = (byte_t)(m_volume >> 8); 57 55 bStatus &= se.write( val, "FunctionBlockFeatureVolume volume high" ); … … 67 65 bool bStatus; 68 66 byte_t val; 69 bStatus = de.read( &m_controlSelector ); 70 bStatus &= de.read( &m_controlDataLength ); 67 bStatus = de.read( &m_controlDataLength ); 71 68 bStatus &= de.read( &val ); 72 69 m_volume = val << 8; … … 327 324 , m_selectorLength( 0x02 ) 328 325 , m_audioChannelNumber( 0x00 ) 329 , m_pVolume( 0 ) 326 , m_controlSelector( eCSE_Feature_Unknown ) 327 , m_pVolume( new FunctionBlockFeatureVolume ) 330 328 { 331 329 } … … 335 333 , m_selectorLength( rhs.m_selectorLength ) 336 334 , m_audioChannelNumber( rhs.m_audioChannelNumber ) 335 , m_controlSelector( rhs.m_controlSelector ) 337 336 { 338 337 if ( rhs.m_pVolume ) { … … 344 343 { 345 344 delete m_pVolume; 346 m_pVolume = 0;345 m_pVolume = NULL; 347 346 } 348 347 … … 353 352 bStatus = se.write( m_selectorLength, "FunctionBlockFeature selectorLength" ); 354 353 bStatus &= se.write( m_audioChannelNumber, "FunctionBlockFeature audioChannelNumber" ); 355 356 if ( m_pVolume ) { 354 bStatus &= se.write( m_controlSelector, "FunctionBlockFeature controlSelector" ); 355 356 if ( m_controlSelector == eCSE_Feature_Volume ) { 357 357 bStatus &= m_pVolume->serialize( se ); 358 358 } else { … … 369 369 bStatus = de.read( &m_selectorLength ); 370 370 bStatus &= de.read( &m_audioChannelNumber ); 371 372 byte_t controlSelector; 373 bStatus &= de.peek( &controlSelector ); 374 switch( controlSelector ) { 371 bStatus &= de.read( &m_controlSelector ); 372 373 switch( m_controlSelector ) { 375 374 case eCSE_Feature_Volume: 376 if ( !m_pVolume ) {377 m_pVolume = new FunctionBlockFeatureVolume;378 }379 375 bStatus &= m_pVolume->deserialize( de ); 380 376 break; trunk/libffado/src/libavc/avc_function_block.h
r445 r455 43 43 virtual FunctionBlockFeatureVolume* clone() const; 44 44 45 control_selector_t m_controlSelector;46 45 control_data_length_t m_controlDataLength; 47 46 u_int16_t m_volume; … … 147 146 virtual FunctionBlockFeature* clone() const; 148 147 149 selector_length_t m_selectorLength; 150 audio_channel_number_t m_audioChannelNumber; 148 selector_length_t m_selectorLength; 149 audio_channel_number_t m_audioChannelNumber; 150 control_selector_t m_controlSelector; 151 151 152 152 FunctionBlockFeatureVolume* m_pVolume; trunk/libffado/tests/test-mixer.cpp
r447 r455 89 89 90 90 bool 91 doApp2( Ieee1394Service& ieee1394service, int node_id, int fb_id )91 selectorGet( Ieee1394Service& ieee1394service, int node_id, int fb_id ) 92 92 { 93 93 FunctionBlockCmd fbCmd( ieee1394service, … … 120 120 121 121 bool 122 doApp3( Ieee1394Service& ieee1394service, int node_id, int fb_id , int val )122 selectorSet( Ieee1394Service& ieee1394service, int node_id, int fb_id , int val ) 123 123 { 124 124 FunctionBlockCmd fbCmd( ieee1394service, … … 132 132 133 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 bool 153 volumeGet( Ieee1394Service& ieee1394service, int node_id, int fb_id, int channel ) 154 { 155 FunctionBlockCmd fbCmd( ieee1394service, 156 FunctionBlockCmd::eFBT_Feature, 157 fb_id, 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; 165 166 debugOutput(DEBUG_LEVEL_NORMAL, "Requesting volume feature block state...\n"); 167 168 fbCmd.setVerbose( bVerbose ); 169 if (bVerbose) { 170 ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE ); 171 } 172 173 if ( !fbCmd.fire() ) { 174 debugError( "cmd failed\n" ); 175 } 176 177 if ( bVerbose ) { 178 CoutSerializer se; 179 fbCmd.serialize( se ); 180 } 181 182 return true; 183 } 184 185 bool 186 volumeSet( Ieee1394Service& ieee1394service, int node_id, int fb_id, int channel, int value ) 187 { 188 FunctionBlockCmd fbCmd( ieee1394service, 189 FunctionBlockCmd::eFBT_Feature, 190 fb_id, 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; 198 199 debugOutput(DEBUG_LEVEL_NORMAL, "Setting volume feature block channel %d state to %d...\n", channel, value); 134 200 135 201 fbCmd.setVerbose( bVerbose ); … … 157 223 { 158 224 159 if (argc < 3) {160 debugError("usage: PORT NODE_ID FB_ID\n");225 if (argc < 4) { 226 debugError("usage: PORT NODE_ID CMD FB_ID [VAL1] [VAL2]\n"); 161 227 exit(0); 162 228 } … … 166 232 int port = strtol( argv[1], &tail, 0 ); 167 233 int node_id = strtol( argv[2], &tail, 0 ); 168 int fb_id = strtol( argv[3], &tail, 0 ); 169 234 int cmd = strtol( argv[3], &tail, 0 ); 235 int fb_id = strtol( argv[4], &tail, 0 ); 236 237 int value1=-1; 238 int value2=-1; 239 240 if (argc>=6) 241 value1 = strtol(argv[5], &tail, 0 ); 242 243 if (argc>=7) 244 value2 = strtol(argv[6], &tail, 0 ); 245 170 246 if (errno) { 171 247 debugError("argument parsing failed: %s", strerror(errno)); … … 178 254 } 179 255 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 ); 256 switch(cmd) { 257 case 0: 258 doApp( ieee1394service, node_id, fb_id ); 259 break; 260 case 1: 261 selectorGet( ieee1394service, node_id, fb_id ); 262 break; 263 case 2: 264 selectorSet( ieee1394service, node_id, fb_id , value1 ); 265 break; 266 case 3: 267 volumeGet( ieee1394service, node_id, fb_id, value1); 268 break; 269 case 4: 270 volumeSet( ieee1394service, node_id, fb_id, value1, value2); 271 break; 272 } 187 273 188 274 return 0;