Changeset 323
- Timestamp:
- 11/12/06 09:11:57 (17 years ago)
- Files:
-
- trunk/libfreebob/ChangeLog (modified) (1 diff)
- trunk/libfreebob/src/libfreebobavc/avc_definitions.h (modified) (1 diff)
- trunk/libfreebob/src/libfreebobavc/avc_function_block.cpp (moved) (moved from trunk/libfreebob/src/libfreebobavc/avc_feature_function_block.cpp) (5 diffs)
- trunk/libfreebob/src/libfreebobavc/avc_function_block.h (moved) (moved from trunk/libfreebob/src/libfreebobavc/avc_feature_function_block.h) (6 diffs)
- trunk/libfreebob/src/Makefile.am (modified) (1 diff)
- trunk/libfreebob/tests/test-volume.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libfreebob/ChangeLog
r321 r323 1 2006-11-12 Daniel Wagner <wagi@newton.monom.org> 2 3 * basic function block AV/C commands added. 4 test program for setting the volume added. 5 1 6 2006-11-11 Daniel Wagner <wagi@newton.monom.org> 2 7 trunk/libfreebob/src/libfreebobavc/avc_definitions.h
r319 r323 70 70 typedef byte_t control_selector_t; 71 71 typedef byte_t control_data_length_t; 72 typedef byte_t input_fb_plug_number_t; 73 typedef byte_t input_audio_channel_number_t; 74 typedef byte_t output_audio_channel_number_t; 72 75 73 76 typedef quadlet_t company_id_t; trunk/libfreebob/src/libfreebobavc/avc_function_block.cpp
r320 r323 1 /* avc_f eature_function_block.cpp1 /* avc_function_block.cpp 2 2 * Copyright (C) 2006 by Daniel Wagner 3 3 * … … 19 19 */ 20 20 21 #include "avc_f eature_function_block.h"21 #include "avc_function_block.h" 22 22 #include "serialize.h" 23 23 #include "ieee1394service.h" 24 24 25 FeatureFunctionBlockVolume::FeatureFunctionBlockVolume() 26 : IBusData() 27 , m_selectorLength( 6 ) 28 , m_audioChannelNumber( 0 ) 29 , m_controlSelector( eFCS_Volume ) 25 26 ///////////////////////////////// 27 28 FunctionBlockFeatureVolume::FunctionBlockFeatureVolume() 29 : IBusData() 30 , m_controlSelector( FunctionBlockFeature::eCSE_Feature_Volume ) 30 31 , m_controlDataLength( 2 ) 31 32 , m_volume( 0 ) … … 33 34 } 34 35 35 FeatureFunctionBlockVolume::FeatureFunctionBlockVolume( const FeatureFunctionBlockVolume& rhs ) 36 : m_selectorLength( rhs.m_selectorLength ) 37 , m_audioChannelNumber( rhs.m_audioChannelNumber ) 38 , m_controlSelector( rhs.m_controlSelector ) 36 FunctionBlockFeatureVolume::FunctionBlockFeatureVolume( const FunctionBlockFeatureVolume& rhs ) 37 : m_controlSelector( rhs.m_controlSelector ) 39 38 , m_controlDataLength( rhs.m_controlDataLength ) 40 39 , m_volume( rhs.m_volume ) … … 42 41 } 43 42 44 F eatureFunctionBlockVolume::~FeatureFunctionBlockVolume()45 { 46 } 47 48 bool 49 F eatureFunctionBlockVolume::serialize( IOSSerialize& se )43 FunctionBlockFeatureVolume::~FunctionBlockFeatureVolume() 44 { 45 } 46 47 bool 48 FunctionBlockFeatureVolume::serialize( IOSSerialize& se ) 50 49 { 51 50 bool bStatus; 52 51 byte_t val; 53 bStatus = se.write( m_selectorLength, "FeatureFunctionBlockVolume selectorLength" ); 54 bStatus &= se.write( m_audioChannelNumber, "FeatureFunctionBlockVolume audioChannelNumber" ); 55 bStatus &= se.write( m_controlSelector, "FeatureFunctionBlockVolume controlSelector" ); 56 bStatus &= se.write( m_controlDataLength, "FeatureFunctionBlockVolume controlDataLength" ); 52 bStatus = se.write( m_controlSelector, "FunctionBlockFeatureVolume controlSelector" ); 53 bStatus &= se.write( m_controlDataLength, "FunctionBlockFeatureVolume controlDataLength" ); 57 54 val = (byte_t)(m_volume >> 8); 58 bStatus &= se.write( val, "F eatureFunctionBlockVolume volume high" );55 bStatus &= se.write( val, "FunctionBlockFeatureVolume volume high" ); 59 56 val = m_volume & 0xff; 60 bStatus &= se.write( val, "F eatureFunctionBlockVolume volume low" );61 62 return bStatus; 63 } 64 65 bool 66 F eatureFunctionBlockVolume::deserialize( IISDeserialize& de )57 bStatus &= se.write( val, "FunctionBlockFeatureVolume volume low" ); 58 59 return bStatus; 60 } 61 62 bool 63 FunctionBlockFeatureVolume::deserialize( IISDeserialize& de ) 67 64 { 68 65 bool bStatus; 69 66 byte_t val; 70 bStatus = de.read( &m_selectorLength );71 bStatus = de.read( &m_audioChannelNumber );72 67 bStatus = de.read( &m_controlSelector ); 73 bStatus = de.read( &m_controlDataLength );74 bStatus = de.read( &val );68 bStatus &= de.read( &m_controlDataLength ); 69 bStatus &= de.read( &val ); 75 70 m_volume = val << 8; 76 bStatus = de.read( &val );71 bStatus &= de.read( &val ); 77 72 m_volume |= val; 78 73 … … 80 75 } 81 76 82 FeatureFunctionBlockVolume* 83 FeatureFunctionBlockVolume::clone() const 84 { 85 return new FeatureFunctionBlockVolume( *this ); 86 } 87 88 ///////////////////////////////// 89 90 91 FeatureFunctionBlockCmd::FeatureFunctionBlockCmd( Ieee1394Service* ieee1394service ) 77 FunctionBlockFeatureVolume* 78 FunctionBlockFeatureVolume::clone() const 79 { 80 return new FunctionBlockFeatureVolume( *this ); 81 } 82 83 ///////////////////////////////// 84 85 FunctionBlockProcessingMixer::FunctionBlockProcessingMixer() 86 : IBusData() 87 , m_controlSelector( FunctionBlockProcessing::eCSE_Processing_Mixer ) 88 { 89 } 90 91 FunctionBlockProcessingMixer::FunctionBlockProcessingMixer( const FunctionBlockProcessingMixer& rhs ) 92 : m_controlSelector( rhs.m_controlSelector ) 93 { 94 } 95 96 FunctionBlockProcessingMixer::~FunctionBlockProcessingMixer() 97 { 98 } 99 100 bool 101 FunctionBlockProcessingMixer::serialize( IOSSerialize& se ) 102 { 103 bool bStatus; 104 bStatus = se.write( m_controlSelector, "FunctionBlockProcessingMixer controlSelector" ); 105 106 return bStatus; 107 } 108 109 bool 110 FunctionBlockProcessingMixer::deserialize( IISDeserialize& de ) 111 { 112 bool bStatus; 113 bStatus = de.read( &m_controlSelector ); 114 115 return bStatus; 116 } 117 118 FunctionBlockProcessingMixer* 119 FunctionBlockProcessingMixer::clone() const 120 { 121 return new FunctionBlockProcessingMixer( *this ); 122 } 123 124 125 ///////////////////////////////// 126 ///////////////////////////////// 127 128 FunctionBlockSelector::FunctionBlockSelector() 129 : IBusData() 130 , m_selectorLength( 0x02 ) 131 , m_inputFbPlugNumber( 0x00 ) 132 , m_controlSelector( eCSE_Selector_Selector ) 133 { 134 } 135 136 FunctionBlockSelector::FunctionBlockSelector( const FunctionBlockSelector& rhs ) 137 : IBusData() 138 , m_selectorLength( rhs.m_selectorLength ) 139 , m_inputFbPlugNumber( rhs.m_inputFbPlugNumber ) 140 , m_controlSelector( rhs.m_controlSelector ) 141 { 142 } 143 144 FunctionBlockSelector::~FunctionBlockSelector() 145 { 146 } 147 148 bool 149 FunctionBlockSelector::serialize( IOSSerialize& se ) 150 { 151 bool bStatus; 152 bStatus = se.write( m_selectorLength, "FunctionBlockSelector selectorLength" ); 153 bStatus &= se.write( m_inputFbPlugNumber, "FunctionBlockSelector inputFbPlugNumber" ); 154 bStatus &= se.write( m_controlSelector, "FunctionBlockSelector controlSelector" ); 155 156 return bStatus; 157 } 158 159 bool 160 FunctionBlockSelector::deserialize( IISDeserialize& de ) 161 { 162 bool bStatus; 163 bStatus = de.read( &m_selectorLength ); 164 bStatus &= de.read( &m_inputFbPlugNumber ); 165 bStatus &= de.read( &m_controlSelector ); 166 167 return bStatus; 168 } 169 170 FunctionBlockSelector* 171 FunctionBlockSelector::clone() const 172 { 173 return new FunctionBlockSelector( *this ); 174 } 175 176 ///////////////////////////////// 177 178 FunctionBlockFeature::FunctionBlockFeature() 179 : IBusData() 180 , m_selectorLength( 0x02 ) 181 , m_audioChannelNumber( 0x00 ) 182 , m_pVolume( 0 ) 183 { 184 } 185 186 FunctionBlockFeature::FunctionBlockFeature( const FunctionBlockFeature& rhs ) 187 : IBusData() 188 , m_selectorLength( rhs.m_selectorLength ) 189 , m_audioChannelNumber( rhs.m_audioChannelNumber ) 190 { 191 if ( rhs.m_pVolume ) { 192 m_pVolume = new FunctionBlockFeatureVolume( *rhs.m_pVolume ); 193 } 194 } 195 196 FunctionBlockFeature::~FunctionBlockFeature() 197 { 198 delete m_pVolume; 199 m_pVolume = 0; 200 } 201 202 bool 203 FunctionBlockFeature::serialize( IOSSerialize& se ) 204 { 205 bool bStatus; 206 bStatus = se.write( m_selectorLength, "FunctionBlockFeature selectorLength" ); 207 bStatus &= se.write( m_audioChannelNumber, "FunctionBlockFeature audioChannelNumber" ); 208 209 if ( m_pVolume ) { 210 bStatus &= m_pVolume->serialize( se ); 211 } else { 212 bStatus = false; 213 } 214 215 return bStatus; 216 } 217 218 bool 219 FunctionBlockFeature::deserialize( IISDeserialize& de ) 220 { 221 bool bStatus; 222 bStatus = de.read( &m_selectorLength ); 223 bStatus &= de.read( &m_audioChannelNumber ); 224 225 byte_t controlSelector; 226 bStatus &= de.peek( &controlSelector ); 227 switch( controlSelector ) { 228 case eCSE_Feature_Volume: 229 if ( !m_pVolume ) { 230 m_pVolume = new FunctionBlockFeatureVolume; 231 } 232 bStatus &= m_pVolume->deserialize( de ); 233 break; 234 case eCSE_Feature_Mute: 235 case eCSE_Feature_LRBalance: 236 case eCSE_Feature_FRBalance: 237 case eCSE_Feature_Bass: 238 case eCSE_Feature_Mid: 239 case eCSE_Feature_Treble: 240 case eCSE_Feature_GEQ: 241 case eCSE_Feature_AGC: 242 case eCSE_Feature_Delay: 243 case eCSE_Feature_BassBoost: 244 case eCSE_Feature_Loudness: 245 default: 246 bStatus = false; 247 } 248 249 return bStatus; 250 } 251 252 FunctionBlockFeature* 253 FunctionBlockFeature::clone() const 254 { 255 return new FunctionBlockFeature( *this ); 256 } 257 258 ///////////////////////////////// 259 260 FunctionBlockProcessing::FunctionBlockProcessing() 261 : IBusData() 262 , m_selectorLength( 0x04 ) 263 , m_fbInputPlugNumber( 0x00 ) 264 , m_inputAudioChannelNumber( 0x00 ) 265 , m_outputAudioChannelNumber( 0x00 ) 266 { 267 } 268 269 FunctionBlockProcessing::FunctionBlockProcessing( const FunctionBlockProcessing& rhs ) 270 : m_selectorLength( rhs.m_selectorLength ) 271 , m_fbInputPlugNumber( rhs.m_fbInputPlugNumber ) 272 , m_inputAudioChannelNumber( rhs.m_inputAudioChannelNumber ) 273 , m_outputAudioChannelNumber( rhs.m_outputAudioChannelNumber ) 274 { 275 } 276 277 FunctionBlockProcessing::~FunctionBlockProcessing() 278 { 279 delete m_pMixer; 280 m_pMixer = 0; 281 } 282 283 bool 284 FunctionBlockProcessing::serialize( IOSSerialize& se ) 285 { 286 bool bStatus; 287 bStatus = se.write( m_selectorLength, "FunctionBlockProcessing selectorLength" ); 288 bStatus &= se.write( m_fbInputPlugNumber, "FunctionBlockProcessing fbInputPlugNumber" ); 289 bStatus &= se.write( m_inputAudioChannelNumber, "FunctionBlockProcessing inputAudioChannelNumber" ); 290 bStatus &= se.write( m_outputAudioChannelNumber, "FunctionBlockProcessing outputAudioChannelNumber" ); 291 292 if ( m_pMixer ) { 293 bStatus &= m_pMixer->serialize( se ); 294 } else { 295 bStatus = false; 296 } 297 298 return bStatus; 299 } 300 301 bool 302 FunctionBlockProcessing::deserialize( IISDeserialize& de ) 303 { 304 bool bStatus; 305 bStatus = de.read( &m_selectorLength ); 306 bStatus &= de.read( &m_fbInputPlugNumber ); 307 bStatus &= de.read( &m_inputAudioChannelNumber ); 308 bStatus &= de.read( &m_outputAudioChannelNumber ); 309 310 byte_t controlSelector; 311 bStatus &= de.peek( &controlSelector ); 312 switch( controlSelector ) { 313 case eCSE_Processing_Mixer: 314 if ( !m_pMixer ) { 315 m_pMixer = new FunctionBlockProcessingMixer; 316 } 317 bStatus &= m_pMixer->deserialize( de ); 318 break; 319 case eCSE_Processing_Enable: 320 case eCSE_Processing_Mode: 321 default: 322 bStatus = false; 323 } 324 325 return bStatus; 326 } 327 328 FunctionBlockProcessing* 329 FunctionBlockProcessing::clone() const 330 { 331 return new FunctionBlockProcessing( *this ); 332 } 333 334 ///////////////////////////////// 335 336 FunctionBlockCodec::FunctionBlockCodec() 337 : IBusData() 338 { 339 } 340 341 FunctionBlockCodec::FunctionBlockCodec( const FunctionBlockCodec& rhs ) 342 : IBusData() 343 { 344 } 345 346 FunctionBlockCodec::~FunctionBlockCodec() 347 { 348 } 349 350 bool 351 FunctionBlockCodec::serialize( IOSSerialize& se ) 352 { 353 return false; 354 } 355 356 bool 357 FunctionBlockCodec::deserialize( IISDeserialize& de ) 358 { 359 return false; 360 } 361 362 FunctionBlockCodec* 363 FunctionBlockCodec::clone() const 364 { 365 return new FunctionBlockCodec( *this ); 366 } 367 368 ///////////////////////////////// 369 ///////////////////////////////// 370 371 FunctionBlockCmd::FunctionBlockCmd( Ieee1394Service* ieee1394service, 372 EFunctionBlockType eType, 373 function_block_id_t id, 374 EControlAttribute eCtrlAttrib ) 92 375 : AVCCommand( ieee1394service, AVC1394_FUNCTION_BLOCK_CMD ) 93 , m_functionBlockType( 0x81 ) // feature function block 94 , m_functionBlockId( 0xff ) 95 , m_controlAttribute( eCA_Current ) 376 , m_functionBlockType( eType ) 377 , m_functionBlockId( id ) 378 , m_controlAttribute( eCtrlAttrib ) 379 , m_pFBSelector( 0 ) 380 , m_pFBFeature( 0 ) 381 , m_pFBProcessing( 0 ) 382 , m_pFBCodec( 0 ) 96 383 { 97 384 setSubunitType( eST_Audio ); 98 } 99 100 FeatureFunctionBlockCmd::FeatureFunctionBlockCmd( const FeatureFunctionBlockCmd& rhs ) 385 386 switch( m_functionBlockType ) { 387 case eFBT_Selector: 388 m_pFBSelector = new FunctionBlockSelector; 389 break; 390 case eFBT_Feature: 391 m_pFBFeature = new FunctionBlockFeature; 392 break; 393 case eFBT_Processing: 394 m_pFBProcessing = new FunctionBlockProcessing; 395 break; 396 case eFBT_Codec: 397 m_pFBCodec = new FunctionBlockCodec; 398 break; 399 } 400 } 401 402 FunctionBlockCmd::FunctionBlockCmd( const FunctionBlockCmd& rhs ) 101 403 : AVCCommand( rhs ) 102 404 , m_functionBlockType( rhs.m_functionBlockType ) 103 405 , m_functionBlockId( rhs.m_functionBlockId ) 104 406 , m_controlAttribute( rhs.m_controlAttribute ) 105 , m_volumeControl( rhs.m_volumeControl ) 106 { 107 } 108 109 FeatureFunctionBlockCmd::~FeatureFunctionBlockCmd() 110 { 111 } 112 113 bool FeatureFunctionBlockCmd::serialize( IOSSerialize& se ) 114 { 115 bool bStatus; 116 bStatus = AVCCommand::serialize( se ); 117 bStatus &= se.write( m_functionBlockType, "FeatureFunctionBlockCmd functionBlockType" ); 118 bStatus &= se.write( m_functionBlockId, "FeatureFunctionBlockCmd functionBlockId" ); 119 bStatus &= se.write( m_controlAttribute, "FeatureFunctionBlockCmd controlAttribute" ); 120 bStatus &= m_volumeControl.serialize( se ); 121 122 return bStatus; 123 } 124 125 bool FeatureFunctionBlockCmd::deserialize( IISDeserialize& de ) 126 { 127 bool bStatus; 128 bStatus = AVCCommand::deserialize( de ); 407 , m_pFBSelector( new FunctionBlockSelector( *rhs.m_pFBSelector ) ) 408 , m_pFBFeature( new FunctionBlockFeature( *rhs.m_pFBFeature ) ) 409 , m_pFBProcessing( new FunctionBlockProcessing( *rhs.m_pFBProcessing ) ) 410 , m_pFBCodec( new FunctionBlockCodec( *rhs.m_pFBCodec ) ) 411 { 412 } 413 414 FunctionBlockCmd::~FunctionBlockCmd() 415 { 416 delete m_pFBSelector; 417 m_pFBSelector = 0; 418 delete m_pFBFeature; 419 m_pFBFeature = 0; 420 delete m_pFBProcessing; 421 m_pFBProcessing = 0; 422 delete m_pFBCodec; 423 m_pFBCodec = 0; 424 } 425 426 bool 427 FunctionBlockCmd::serialize( IOSSerialize& se ) 428 { 429 bool bStatus; 430 bStatus = AVCCommand::serialize( se ); 431 bStatus &= se.write( m_functionBlockType, "FunctionBlockCmd functionBlockType" ); 432 bStatus &= se.write( m_functionBlockId, "FunctionBlockCmd functionBlockId" ); 433 bStatus &= se.write( m_controlAttribute, "FunctionBlockCmd controlAttribute" ); 434 435 switch( m_functionBlockType ) { 436 case eFBT_Selector: 437 if ( m_pFBSelector ) { 438 bStatus &= m_pFBSelector->serialize( se ); 439 } else { 440 bStatus = false; 441 } 442 break; 443 case eFBT_Feature: 444 if ( m_pFBFeature ) { 445 bStatus &= m_pFBFeature->serialize( se ); 446 } else { 447 bStatus = false; 448 } 449 break; 450 case eFBT_Processing: 451 if ( m_pFBProcessing ) { 452 bStatus &= m_pFBProcessing->serialize( se ); 453 } else { 454 bStatus = false; 455 } 456 break; 457 case eFBT_Codec: 458 if ( m_pFBCodec ) { 459 bStatus &= m_pFBCodec->serialize( se ); 460 } else { 461 bStatus = false; 462 } 463 break; 464 default: 465 bStatus = false; 466 } 467 468 return bStatus; 469 } 470 471 bool 472 FunctionBlockCmd::deserialize( IISDeserialize& de ) 473 { 474 bool bStatus; 475 bStatus = AVCCommand::deserialize( de ); 129 476 130 477 bStatus &= de.read( &m_functionBlockType ); 131 478 bStatus &= de.read( &m_functionBlockId ); 132 479 bStatus &= de.read( &m_controlAttribute ); 133 bStatus &= m_volumeControl.deserialize( de ); 134 135 return bStatus; 136 } 137 138 FeatureFunctionBlockCmd* 139 FeatureFunctionBlockCmd::clone() const 140 { 141 FeatureFunctionBlockCmd* pFeatureFunctionBlockCmd 142 = new FeatureFunctionBlockCmd( *this ); 143 return pFeatureFunctionBlockCmd; 144 } 480 481 switch( m_functionBlockType ) { 482 case eFBT_Selector: 483 if ( !m_pFBSelector ) { 484 m_pFBSelector = new FunctionBlockSelector; 485 } 486 bStatus &= m_pFBSelector->deserialize( de ); 487 break; 488 case eFBT_Feature: 489 if ( !m_pFBFeature ) { 490 m_pFBFeature = new FunctionBlockFeature; 491 } 492 bStatus &= m_pFBFeature->deserialize( de ); 493 break; 494 case eFBT_Processing: 495 if ( !m_pFBProcessing ) { 496 m_pFBProcessing = new FunctionBlockProcessing; 497 } 498 bStatus &= m_pFBProcessing->deserialize( de ); 499 break; 500 case eFBT_Codec: 501 if ( !m_pFBCodec ) { 502 m_pFBCodec = new FunctionBlockCodec; 503 } 504 bStatus &= m_pFBCodec->deserialize( de ); 505 break; 506 default: 507 bStatus = false; 508 } 509 510 return bStatus; 511 } 512 513 FunctionBlockCmd* 514 FunctionBlockCmd::clone() const 515 { 516 return new FunctionBlockCmd( *this ); 517 } trunk/libfreebob/src/libfreebobavc/avc_function_block.h
r319 r323 1 /* avc_f eature_function_block.h1 /* avc_function_block.h 2 2 * Copyright (C) 2006 by Daniel Wagner 3 3 * … … 19 19 */ 20 20 21 #ifndef AVCF EATUREFUNCTIONBLOCK_H22 #define AVCF EATUREFUNCTIONBLOCK_H21 #ifndef AVCFUNCTIONBLOCK_H 22 #define AVCFUNCTIONBLOCK_H 23 23 24 24 #include "avc_extended_cmd_generic.h" … … 27 27 #include <libavc1394/avc1394.h> 28 28 29 30 enum EControlSelector { 31 eFCS_Mute = 0x01, 32 eFCS_Volume = 0x02, 33 eFCS_LRBalance = 0x03, 34 eFCS_FRBalance = 0x04, 35 eFCS_Bass = 0x05, 36 eFCS_Mid = 0x06, 37 eFCS_Treble = 0x07, 38 eFCS_GEQ = 0x08, 39 eFCS_AGC = 0x09, 40 eFCS_Delay = 0x0a, 41 eFCS_BassBoost = 0x0b, 42 eFCS_Loudness = 0x0c, 43 }; 44 45 class FeatureFunctionBlockVolume: public IBusData 46 { 47 public: 48 FeatureFunctionBlockVolume(); 49 FeatureFunctionBlockVolume( const FeatureFunctionBlockVolume& rhs ); 50 virtual ~FeatureFunctionBlockVolume(); 51 52 virtual bool serialize( IOSSerialize& se ); 53 virtual bool deserialize( IISDeserialize& de ); 54 virtual FeatureFunctionBlockVolume* clone() const; 55 56 57 selector_length_t m_selectorLength; 58 audio_channel_number_t m_audioChannelNumber; 29 class FunctionBlockFeatureVolume: public IBusData 30 { 31 public: 32 FunctionBlockFeatureVolume(); 33 FunctionBlockFeatureVolume( const FunctionBlockFeatureVolume& rhs ); 34 virtual ~FunctionBlockFeatureVolume(); 35 36 virtual bool serialize( IOSSerialize& se ); 37 virtual bool deserialize( IISDeserialize& de ); 38 virtual FunctionBlockFeatureVolume* clone() const; 39 59 40 control_selector_t m_controlSelector; 60 41 control_data_length_t m_controlDataLength; … … 64 45 /////////////////////////////////////////// 65 46 47 class FunctionBlockProcessingMixer: public IBusData 48 { 49 public: 50 FunctionBlockProcessingMixer(); 51 FunctionBlockProcessingMixer( const FunctionBlockProcessingMixer& rhs ); 52 virtual ~FunctionBlockProcessingMixer(); 53 54 virtual bool serialize( IOSSerialize& se ); 55 virtual bool deserialize( IISDeserialize& de ); 56 virtual FunctionBlockProcessingMixer* clone() const; 57 58 control_selector_t m_controlSelector; 59 }; 60 61 /////////////////////////////////////////// 62 /////////////////////////////////////////// 63 64 class FunctionBlockSelector: public IBusData 65 { 66 // untested 67 public: 68 // Control selector encoding 69 enum EControlSelectorEncoding { 70 eCSE_Selector_Selector = 0x01, 71 }; 72 73 FunctionBlockSelector(); 74 FunctionBlockSelector( const FunctionBlockSelector& rhs ); 75 virtual ~FunctionBlockSelector(); 76 77 virtual bool serialize( IOSSerialize& se ); 78 virtual bool deserialize( IISDeserialize& de ); 79 virtual FunctionBlockSelector* clone() const; 80 81 selector_length_t m_selectorLength; 82 input_fb_plug_number_t m_inputFbPlugNumber; 83 control_selector_t m_controlSelector; 84 }; 85 86 /////////////////////////////////////////// 87 88 class FunctionBlockFeature: public IBusData 89 { 90 // no complete implementation 91 public: 92 // Control selector encoding 93 enum EControlSelectorEncoding { 94 eCSE_Feature_Mute = 0x01, 95 eCSE_Feature_Volume = 0x02, 96 eCSE_Feature_LRBalance = 0x03, 97 eCSE_Feature_FRBalance = 0x04, 98 eCSE_Feature_Bass = 0x05, 99 eCSE_Feature_Mid = 0x06, 100 eCSE_Feature_Treble = 0x07, 101 eCSE_Feature_GEQ = 0x08, 102 eCSE_Feature_AGC = 0x09, 103 eCSE_Feature_Delay = 0x0a, 104 eCSE_Feature_BassBoost = 0x0b, 105 eCSE_Feature_Loudness = 0x0c, 106 }; 107 108 FunctionBlockFeature(); 109 FunctionBlockFeature( const FunctionBlockFeature& rhs ); 110 virtual ~FunctionBlockFeature(); 111 112 virtual bool serialize( IOSSerialize& se ); 113 virtual bool deserialize( IISDeserialize& de ); 114 virtual FunctionBlockFeature* clone() const; 115 116 selector_length_t m_selectorLength; 117 audio_channel_number_t m_audioChannelNumber; 118 119 FunctionBlockFeatureVolume* m_pVolume; 120 }; 121 122 /////////////////////////////////////////// 123 124 class FunctionBlockProcessing: public IBusData 125 { 126 // no complete implementation 127 public: 128 // Function block selector 129 enum EProcessingTypeEncoding { 130 ePTE_Mixer = 0x01, 131 ePTE_Generic = 0x02, 132 ePTE_UpDown = 0x03, 133 ePTE_DolbyProLogic = 0x04, 134 ePTE_3dStereoExtender = 0x05, 135 ePTE_Reverberation = 0x06, 136 ePTE_Chorus = 0x07, 137 ePTE_DynamicRangeCompression = 0x08, 138 }; 139 140 // Control selector encoding 141 enum EControlSelectorEncoding { 142 eCSE_Processing_Enable = 0x01, 143 eCSE_Processing_Mode = 0x02, 144 eCSE_Processing_Mixer = 0x03, 145 // lots of definition missing 146 }; 147 148 FunctionBlockProcessing(); 149 FunctionBlockProcessing( const FunctionBlockProcessing& rhs ); 150 virtual ~FunctionBlockProcessing(); 151 152 virtual bool serialize( IOSSerialize& se ); 153 virtual bool deserialize( IISDeserialize& de ); 154 virtual FunctionBlockProcessing* clone() const; 155 156 selector_length_t m_selectorLength; 157 input_fb_plug_number_t m_fbInputPlugNumber; 158 input_audio_channel_number_t m_inputAudioChannelNumber; 159 output_audio_channel_number_t m_outputAudioChannelNumber; 160 161 FunctionBlockProcessingMixer* m_pMixer; 162 }; 163 164 /////////////////////////////////////////// 165 166 class FunctionBlockCodec: public IBusData 167 { 168 // dummy implementation 169 public: 170 // CODEC type endcoding 171 enum ECodecTypeEncoding { 172 eCTE_Ac3Decoder = 0x01, 173 eCTE_MpegDecoder = 0x02, 174 eCTE_DtsDecoder = 0x03, 175 }; 176 177 FunctionBlockCodec(); 178 FunctionBlockCodec( const FunctionBlockCodec& rhs ); 179 virtual ~FunctionBlockCodec(); 180 181 virtual bool serialize( IOSSerialize& se ); 182 virtual bool deserialize( IISDeserialize& de ); 183 virtual FunctionBlockCodec* clone() const; 184 }; 185 186 /////////////////////////////////////////// 187 /////////////////////////////////////////// 188 66 189 #define AVC1394_FUNCTION_BLOCK_CMD 0xB8 67 190 68 // audio function block command only 69 class FeatureFunctionBlockCmd: public AVCCommand 70 { 71 public: 191 class FunctionBlockCmd: public AVCCommand 192 { 193 public: 194 enum EFunctionBlockType { 195 eFBT_Selector = 0x80, 196 eFBT_Feature = 0x81, 197 eFBT_Processing = 0x82, 198 eFBT_Codec = 0x83, 199 }; 200 72 201 enum EControlAttribute { 73 202 eCA_Resolution = 0x01, … … 78 207 eCA_Current = 0x10, 79 208 eCA_Move = 0x18, 80 eCA_Delta = 0x19 81 }; 82 83 FeatureFunctionBlockCmd( Ieee1394Service* ieee1394service ); 84 FeatureFunctionBlockCmd( const FeatureFunctionBlockCmd& rhs ); 85 virtual ~FeatureFunctionBlockCmd(); 86 87 virtual bool serialize( IOSSerialize& se ); 88 virtual bool deserialize( IISDeserialize& de ); 89 virtual FeatureFunctionBlockCmd* clone() const; 209 eCA_Delta = 0x19, 210 }; 211 212 FunctionBlockCmd( Ieee1394Service* ieee1394service, 213 EFunctionBlockType eType, 214 function_block_id_t id, 215 EControlAttribute eCtrlAttrib ); 216 FunctionBlockCmd( const FunctionBlockCmd& rhs ); 217 virtual ~FunctionBlockCmd(); 218 219 virtual bool serialize( IOSSerialize& se ); 220 virtual bool deserialize( IISDeserialize& de ); 221 virtual FunctionBlockCmd* clone() const; 90 222 91 223 virtual const char* getCmdName() const 92 { return "FeatureFunctionBlockCmd"; } 93 94 95 bool setFunctionBlockId( function_block_type_t functionBlockId ) 96 { m_functionBlockId = functionBlockId; return true; } 97 bool setControlAttribute( EControlAttribute eControlAttribute ) 98 { m_controlAttribute = eControlAttribute; return true; } 224 { return "FunctionBlockCmd"; } 99 225 100 226 function_block_type_t m_functionBlockType; … … 102 228 control_attribute_t m_controlAttribute; 103 229 104 FeatureFunctionBlockVolume m_volumeControl; 105 // all other selectors not implemented 230 FunctionBlockSelector* m_pFBSelector; 231 FunctionBlockFeature* m_pFBFeature; 232 FunctionBlockProcessing* m_pFBProcessing; 233 FunctionBlockCodec* m_pFBCodec; 106 234 }; 107 235 trunk/libfreebob/src/Makefile.am
r319 r323 62 62 libfreebobavc/avc_extended_stream_format.cpp \ 63 63 libfreebobavc/avc_extended_subunit_info.cpp \ 64 libfreebobavc/avc_f eature_function_block.cpp\65 libfreebobavc/avc_f eature_function_block.h\64 libfreebobavc/avc_function_block.cpp \ 65 libfreebobavc/avc_function_block.h \ 66 66 libfreebobavc/avc_generic.cpp \ 67 67 libfreebobavc/avc_plug_info.cpp \ trunk/libfreebob/tests/test-volume.cpp
r320 r323 1 1 /* test-volume.cpp 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 * Copyright (C) 2006 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with FreeBoB; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 18 * MA 02111-1307 USA. 19 */ 20 20 21 #include "libfreebobavc/avc_f eature_function_block.h"21 #include "libfreebobavc/avc_function_block.h" 22 22 #include "libfreebobavc/serialize.h" 23 23 #include "libfreebobavc/ieee1394service.h" 24 24 25 short int getMaxVolume(Ieee1394Service& ieee1394service, int node_id, int ffb_id) 25 const bool bVerbose = false; 26 27 short int 28 getVolume( Ieee1394Service& ieee1394service, int node_id, int ffb_id, 29 FunctionBlockCmd::EControlAttribute control_attrib ) 26 30 { 27 FeatureFunctionBlockCmd ffbCmd( &ieee1394service ); 28 ffbCmd.setNodeId( node_id ); 29 ffbCmd.setSubunitId( 0x00 ); 30 ffbCmd.setCommandType( AVCCommand::eCT_Status ); 31 ffbCmd.setFunctionBlockId( ffb_id ); 32 ffbCmd.setControlAttribute(FeatureFunctionBlockCmd::eCA_Maximum); 33 34 if ( !ffbCmd.fire() ) { 31 FunctionBlockCmd fbCmd( &ieee1394service, 32 FunctionBlockCmd::eFBT_Feature, 33 ffb_id, 34 control_attrib ); 35 fbCmd.setNodeId( node_id ); 36 fbCmd.setSubunitId( 0x00 ); 37 fbCmd.setCommandType( AVCCommand::eCT_Status ); 38 fbCmd.m_pFBFeature->m_pVolume = new FunctionBlockFeatureVolume; 39 40 fbCmd.setVerbose( bVerbose ); 41 ieee1394service.setVerbose( bVerbose ); 42 43 if ( !fbCmd.fire() ) { 35 44 printf( "cmd failed\n" ); 36 45 } 37 return ffbCmd.m_volumeControl.m_volume;38 }39 46 40 short int getMinVolume(Ieee1394Service& ieee1394service, int node_id, int ffb_id) 41 { 42 FeatureFunctionBlockCmd ffbCmd( &ieee1394service ); 43 ffbCmd.setNodeId( node_id ); 44 ffbCmd.setSubunitId( 0x00 ); 45 ffbCmd.setCommandType( AVCCommand::eCT_Status ); 46 ffbCmd.setFunctionBlockId( ffb_id ); 47 ffbCmd.setControlAttribute(FeatureFunctionBlockCmd::eCA_Minimum); 47 if ( bVerbose ) { 48 CoutSerializer se; 49 fbCmd.serialize( se ); 50 } 48 51 49 if ( !ffbCmd.fire() ) { 50 printf( "cmd failed\n" ); 51 } 52 return ffbCmd.m_volumeControl.m_volume; 53 } 54 55 short int getCurrentVolume(Ieee1394Service& ieee1394service, int node_id, int ffb_id) 56 { 57 FeatureFunctionBlockCmd ffbCmd( &ieee1394service ); 58 ffbCmd.setNodeId( node_id ); 59 ffbCmd.setSubunitId( 0x00 ); 60 ffbCmd.setCommandType( AVCCommand::eCT_Status ); 61 ffbCmd.setFunctionBlockId( ffb_id ); 62 63 if ( !ffbCmd.fire() ) { 64 printf( "cmd failed\n" ); 65 } 66 return ffbCmd.m_volumeControl.m_volume; 52 return fbCmd.m_pFBFeature->m_pVolume->m_volume; 67 53 } 68 54 69 55 bool 70 doApp(Ieee1394Service& ieee1394service, int node_id, int ffb_id, int vol )56 setVolume( Ieee1394Service& ieee1394service, int node_id, int ffb_id, int vol ) 71 57 { 72 short int maxVolume = getMaxVolume(ieee1394service, node_id, ffb_id); 73 short int minVolume = getMinVolume(ieee1394service, node_id, ffb_id); 58 FunctionBlockCmd fbCmd( &ieee1394service, 59 FunctionBlockCmd::eFBT_Feature, 60 ffb_id, 61 FunctionBlockCmd::eCA_Current ); 62 fbCmd.setNodeId( node_id ); 63 fbCmd.setSubunitId( 0x00 ); 64 fbCmd.setCommandType( AVCCommand::eCT_Control ); 65 fbCmd.m_pFBFeature->m_pVolume = new FunctionBlockFeatureVolume; 66 fbCmd.m_pFBFeature->m_pVolume->m_volume = vol; 74 67 75 printf("max volume value = %d\n", maxVolume);76 printf("min volume value = %d\n", minVolume);68 fbCmd.setVerbose( bVerbose ); 69 ieee1394service.setVerbose( bVerbose ); 77 70 78 short int volume = getCurrentVolume(ieee1394service, node_id, ffb_id); 79 printf("old volume value = %d\n", volume); 80 81 FeatureFunctionBlockCmd ffbCmd( &ieee1394service ); 82 ffbCmd.setNodeId( node_id ); 83 ffbCmd.setSubunitId( 0x00 ); 84 ffbCmd.setCommandType( AVCCommand::eCT_Control ); 85 ffbCmd.setFunctionBlockId( ffb_id ); 86 ffbCmd.m_volumeControl.m_volume = vol; 87 88 if ( !ffbCmd.fire() ) { 71 bool bStatus = fbCmd.fire(); 72 if ( !bStatus ) { 89 73 printf( "cmd failed\n" ); 90 74 } 91 75 92 volume = getCurrentVolume(ieee1394service, node_id, ffb_id); 93 printf("new volume value = %d\n", volume); 76 if ( bVerbose ) { 77 CoutSerializer se; 78 fbCmd.serialize( se ); 79 } 80 81 return bStatus; 82 } 83 84 bool 85 doApp( Ieee1394Service& ieee1394service, int node_id, int fb_id, int vol ) 86 { 87 short int maxVolume = getVolume( ieee1394service, node_id, fb_id, FunctionBlockCmd::eCA_Maximum ); 88 short int minVolume = getVolume( ieee1394service, node_id, fb_id, FunctionBlockCmd::eCA_Minimum ); 89 short int curVolume = getVolume( ieee1394service, node_id, fb_id, FunctionBlockCmd::eCA_Current ); 90 printf( "max volume value = %d\n", maxVolume ); 91 printf( "min volume value = %d\n", minVolume ); 92 printf( "old volume value = %d\n", curVolume); 93 94 setVolume( ieee1394service, node_id, fb_id, vol ); 95 96 curVolume = getVolume( ieee1394service, node_id, fb_id, FunctionBlockCmd::eCA_Current ); 97 printf( "new volume value = %d\n", curVolume ); 94 98 95 99 return true; … … 104 108 105 109 if (argc < 3) { 106 printf("usage: NODE_ID F FB_ID VOL\n");110 printf("usage: NODE_ID FB_ID VOL\n"); 107 111 exit(0); 108 112 } … … 111 115 char* tail; 112 116 int node_id = strtol( argv[1], &tail, 0 ); 113 int f fb_id= strtol( argv[2], &tail, 0 );117 int fb_id = strtol( argv[2], &tail, 0 ); 114 118 int vol = strtol( argv[3], &tail, 0 ); 115 119 116 120 if (errno) { 117 118 121 perror("argument parsing failed:"); 122 return -1; 119 123 } 120 124 Ieee1394Service ieee1394service; … … 124 128 } 125 129 126 doApp( ieee1394service, node_id, f fb_id, vol );130 doApp( ieee1394service, node_id, fb_id, vol ); 127 131 128 132 return 0;