Changeset 323

Show
Ignore:
Timestamp:
11/12/06 09:11:57 (17 years ago)
Author:
wagi
Message:

2006-11-12 Daniel Wagner <wagi@newton.monom.org>

  • basic function block AV/C commands added.
    test program for setting the volume added.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libfreebob/ChangeLog

    r321 r323  
     12006-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 
    162006-11-11  Daniel Wagner  <wagi@newton.monom.org> 
    27 
  • trunk/libfreebob/src/libfreebobavc/avc_definitions.h

    r319 r323  
    7070typedef byte_t control_selector_t; 
    7171typedef byte_t control_data_length_t; 
     72typedef byte_t input_fb_plug_number_t; 
     73typedef byte_t input_audio_channel_number_t; 
     74typedef byte_t output_audio_channel_number_t; 
    7275 
    7376typedef quadlet_t company_id_t; 
  • trunk/libfreebob/src/libfreebobavc/avc_function_block.cpp

    r320 r323  
    1 /* avc_feature_function_block.cpp 
     1/* avc_function_block.cpp 
    22 * Copyright (C) 2006 by Daniel Wagner 
    33 * 
     
    1919 */ 
    2020 
    21 #include "avc_feature_function_block.h" 
     21#include "avc_function_block.h" 
    2222#include "serialize.h" 
    2323#include "ieee1394service.h" 
    2424 
    25 FeatureFunctionBlockVolume::FeatureFunctionBlockVolume() 
    26     : IBusData() 
    27     , m_selectorLength( 6 ) 
    28     , m_audioChannelNumber( 0 ) 
    29     , m_controlSelector( eFCS_Volume ) 
     25 
     26///////////////////////////////// 
     27 
     28FunctionBlockFeatureVolume::FunctionBlockFeatureVolume() 
     29    : IBusData() 
     30    , m_controlSelector( FunctionBlockFeature::eCSE_Feature_Volume ) 
    3031    , m_controlDataLength( 2 ) 
    3132    , m_volume( 0 ) 
     
    3334} 
    3435 
    35 FeatureFunctionBlockVolume::FeatureFunctionBlockVolume( const FeatureFunctionBlockVolume& rhs ) 
    36     : m_selectorLength( rhs.m_selectorLength ) 
    37     , m_audioChannelNumber( rhs.m_audioChannelNumber ) 
    38     , m_controlSelector( rhs.m_controlSelector ) 
     36FunctionBlockFeatureVolume::FunctionBlockFeatureVolume( const FunctionBlockFeatureVolume& rhs ) 
     37    : m_controlSelector( rhs.m_controlSelector ) 
    3938    , m_controlDataLength( rhs.m_controlDataLength ) 
    4039    , m_volume( rhs.m_volume ) 
     
    4241} 
    4342 
    44 FeatureFunctionBlockVolume::~FeatureFunctionBlockVolume() 
    45 { 
    46 } 
    47  
    48 bool 
    49 FeatureFunctionBlockVolume::serialize( IOSSerialize& se ) 
     43FunctionBlockFeatureVolume::~FunctionBlockFeatureVolume() 
     44{ 
     45} 
     46 
     47bool 
     48FunctionBlockFeatureVolume::serialize( IOSSerialize& se ) 
    5049{ 
    5150    bool bStatus; 
    5251    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" ); 
    5754    val = (byte_t)(m_volume >> 8); 
    58     bStatus &= se.write( val,                  "FeatureFunctionBlockVolume volume high" ); 
     55    bStatus &= se.write( val,                  "FunctionBlockFeatureVolume volume high" ); 
    5956    val = m_volume & 0xff; 
    60     bStatus &= se.write( val,                  "FeatureFunctionBlockVolume volume low" ); 
    61  
    62     return bStatus; 
    63 } 
    64  
    65 bool 
    66 FeatureFunctionBlockVolume::deserialize( IISDeserialize& de ) 
     57    bStatus &= se.write( val,                  "FunctionBlockFeatureVolume volume low" ); 
     58 
     59    return bStatus; 
     60} 
     61 
     62bool 
     63FunctionBlockFeatureVolume::deserialize( IISDeserialize& de ) 
    6764{ 
    6865    bool bStatus; 
    6966    byte_t val; 
    70     bStatus = de.read( &m_selectorLength ); 
    71     bStatus = de.read( &m_audioChannelNumber ); 
    7267    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 ); 
    7570    m_volume = val << 8; 
    76     bStatus = de.read( &val ); 
     71    bStatus &= de.read( &val ); 
    7772    m_volume |= val; 
    7873 
     
    8075} 
    8176 
    82 FeatureFunctionBlockVolume* 
    83 FeatureFunctionBlockVolume::clone() const 
    84 
    85     return new FeatureFunctionBlockVolume( *this ); 
    86 
    87  
    88 ///////////////////////////////// 
    89  
    90  
    91 FeatureFunctionBlockCmd::FeatureFunctionBlockCmd( Ieee1394Service* ieee1394service ) 
     77FunctionBlockFeatureVolume* 
     78FunctionBlockFeatureVolume::clone() const 
     79
     80    return new FunctionBlockFeatureVolume( *this ); 
     81
     82 
     83///////////////////////////////// 
     84 
     85FunctionBlockProcessingMixer::FunctionBlockProcessingMixer() 
     86    : IBusData() 
     87    , m_controlSelector( FunctionBlockProcessing::eCSE_Processing_Mixer ) 
     88
     89
     90 
     91FunctionBlockProcessingMixer::FunctionBlockProcessingMixer( const FunctionBlockProcessingMixer& rhs ) 
     92    : m_controlSelector( rhs.m_controlSelector ) 
     93
     94
     95 
     96FunctionBlockProcessingMixer::~FunctionBlockProcessingMixer() 
     97
     98
     99 
     100bool 
     101FunctionBlockProcessingMixer::serialize( IOSSerialize& se ) 
     102
     103    bool bStatus; 
     104    bStatus = se.write( m_controlSelector,    "FunctionBlockProcessingMixer controlSelector" ); 
     105 
     106    return bStatus; 
     107
     108 
     109bool 
     110FunctionBlockProcessingMixer::deserialize( IISDeserialize& de ) 
     111
     112    bool bStatus; 
     113    bStatus = de.read( &m_controlSelector ); 
     114 
     115    return bStatus; 
     116
     117 
     118FunctionBlockProcessingMixer* 
     119FunctionBlockProcessingMixer::clone() const 
     120
     121    return new FunctionBlockProcessingMixer( *this ); 
     122
     123 
     124 
     125///////////////////////////////// 
     126///////////////////////////////// 
     127 
     128FunctionBlockSelector::FunctionBlockSelector() 
     129    : IBusData() 
     130    , m_selectorLength( 0x02 ) 
     131    , m_inputFbPlugNumber( 0x00 ) 
     132    , m_controlSelector( eCSE_Selector_Selector ) 
     133
     134
     135 
     136FunctionBlockSelector::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 
     144FunctionBlockSelector::~FunctionBlockSelector() 
     145
     146
     147 
     148bool 
     149FunctionBlockSelector::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 
     159bool 
     160FunctionBlockSelector::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 
     170FunctionBlockSelector* 
     171FunctionBlockSelector::clone() const 
     172
     173    return new FunctionBlockSelector( *this ); 
     174
     175 
     176///////////////////////////////// 
     177 
     178FunctionBlockFeature::FunctionBlockFeature() 
     179    : IBusData() 
     180    , m_selectorLength( 0x02 ) 
     181    , m_audioChannelNumber( 0x00 ) 
     182    , m_pVolume( 0 ) 
     183
     184
     185 
     186FunctionBlockFeature::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 
     196FunctionBlockFeature::~FunctionBlockFeature() 
     197
     198    delete m_pVolume; 
     199    m_pVolume = 0; 
     200
     201 
     202bool 
     203FunctionBlockFeature::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 
     218bool 
     219FunctionBlockFeature::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 
     252FunctionBlockFeature* 
     253FunctionBlockFeature::clone() const 
     254
     255    return new FunctionBlockFeature( *this ); 
     256
     257 
     258///////////////////////////////// 
     259 
     260FunctionBlockProcessing::FunctionBlockProcessing() 
     261    : IBusData() 
     262    , m_selectorLength( 0x04 ) 
     263    , m_fbInputPlugNumber( 0x00 ) 
     264    , m_inputAudioChannelNumber( 0x00 ) 
     265    , m_outputAudioChannelNumber( 0x00 ) 
     266
     267
     268 
     269FunctionBlockProcessing::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 
     277FunctionBlockProcessing::~FunctionBlockProcessing() 
     278
     279    delete m_pMixer; 
     280    m_pMixer = 0; 
     281
     282 
     283bool 
     284FunctionBlockProcessing::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 
     301bool 
     302FunctionBlockProcessing::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 
     328FunctionBlockProcessing* 
     329FunctionBlockProcessing::clone() const 
     330
     331    return new FunctionBlockProcessing( *this ); 
     332
     333 
     334///////////////////////////////// 
     335 
     336FunctionBlockCodec::FunctionBlockCodec() 
     337    : IBusData() 
     338
     339
     340 
     341FunctionBlockCodec::FunctionBlockCodec( const FunctionBlockCodec& rhs ) 
     342    : IBusData() 
     343
     344
     345 
     346FunctionBlockCodec::~FunctionBlockCodec() 
     347
     348
     349 
     350bool 
     351FunctionBlockCodec::serialize( IOSSerialize& se ) 
     352
     353    return false; 
     354
     355 
     356bool 
     357FunctionBlockCodec::deserialize( IISDeserialize& de ) 
     358
     359    return false; 
     360
     361 
     362FunctionBlockCodec* 
     363FunctionBlockCodec::clone() const 
     364
     365    return new FunctionBlockCodec( *this ); 
     366
     367 
     368///////////////////////////////// 
     369///////////////////////////////// 
     370 
     371FunctionBlockCmd::FunctionBlockCmd( Ieee1394Service* ieee1394service, 
     372                                    EFunctionBlockType eType, 
     373                                    function_block_id_t id, 
     374                                    EControlAttribute eCtrlAttrib ) 
    92375    : 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 ) 
    96383{ 
    97384    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 
     402FunctionBlockCmd::FunctionBlockCmd( const FunctionBlockCmd& rhs ) 
    101403    : AVCCommand( rhs ) 
    102404    , m_functionBlockType( rhs.m_functionBlockType ) 
    103405    , m_functionBlockId( rhs.m_functionBlockId ) 
    104406    , 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 
     414FunctionBlockCmd::~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 
     426bool 
     427FunctionBlockCmd::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 
     471bool 
     472FunctionBlockCmd::deserialize( IISDeserialize& de ) 
     473
     474    bool bStatus; 
     475    bStatus  = AVCCommand::deserialize( de ); 
    129476 
    130477    bStatus &= de.read( &m_functionBlockType ); 
    131478    bStatus &= de.read( &m_functionBlockId ); 
    132479    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 
     513FunctionBlockCmd* 
     514FunctionBlockCmd::clone() const 
     515
     516    return new FunctionBlockCmd( *this ); 
     517
  • trunk/libfreebob/src/libfreebobavc/avc_function_block.h

    r319 r323  
    1 /* avc_feature_function_block.h 
     1/* avc_function_block.h 
    22 * Copyright (C) 2006 by Daniel Wagner 
    33 * 
     
    1919 */ 
    2020 
    21 #ifndef AVCFEATUREFUNCTIONBLOCK_H 
    22 #define AVCFEATUREFUNCTIONBLOCK_H 
     21#ifndef AVCFUNCTIONBLOCK_H 
     22#define AVCFUNCTIONBLOCK_H 
    2323 
    2424#include "avc_extended_cmd_generic.h" 
     
    2727#include <libavc1394/avc1394.h> 
    2828 
    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; 
     29class FunctionBlockFeatureVolume: public IBusData 
     30
     31public: 
     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 
    5940    control_selector_t     m_controlSelector; 
    6041    control_data_length_t  m_controlDataLength; 
     
    6445/////////////////////////////////////////// 
    6546 
     47class FunctionBlockProcessingMixer: public IBusData 
     48{ 
     49public: 
     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 
     64class FunctionBlockSelector: public IBusData 
     65{ 
     66// untested 
     67public: 
     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 
     88class FunctionBlockFeature: public IBusData 
     89{ 
     90// no complete implementation 
     91public: 
     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 
     124class FunctionBlockProcessing: public IBusData 
     125{ 
     126// no complete implementation 
     127public: 
     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 
     166class FunctionBlockCodec: public IBusData 
     167{ 
     168// dummy implementation 
     169public: 
     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 
    66189#define AVC1394_FUNCTION_BLOCK_CMD 0xB8 
    67190 
    68 // audio function block command only 
    69 class FeatureFunctionBlockCmd: public AVCCommand 
    70 
    71 public: 
     191class FunctionBlockCmd: public AVCCommand 
     192
     193public: 
     194    enum EFunctionBlockType { 
     195        eFBT_Selector   = 0x80, 
     196        eFBT_Feature    = 0x81, 
     197        eFBT_Processing = 0x82, 
     198        eFBT_Codec      = 0x83, 
     199    }; 
     200 
    72201    enum EControlAttribute { 
    73202        eCA_Resolution = 0x01, 
     
    78207        eCA_Current    = 0x10, 
    79208        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; 
    90222 
    91223    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"; } 
    99225 
    100226    function_block_type_t m_functionBlockType; 
     
    102228    control_attribute_t   m_controlAttribute; 
    103229 
    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; 
    106234}; 
    107235 
  • trunk/libfreebob/src/Makefile.am

    r319 r323  
    6262        libfreebobavc/avc_extended_stream_format.cpp    \ 
    6363        libfreebobavc/avc_extended_subunit_info.cpp     \ 
    64         libfreebobavc/avc_feature_function_block.cpp  \ 
    65         libfreebobavc/avc_feature_function_block.h    \ 
     64        libfreebobavc/avc_function_block.cpp          \ 
     65        libfreebobavc/avc_function_block.h            \ 
    6666        libfreebobavc/avc_generic.cpp                   \ 
    6767        libfreebobavc/avc_plug_info.cpp                 \ 
  • trunk/libfreebob/tests/test-volume.cpp

    r320 r323  
    11/* test-volume.cpp 
    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  */ 
     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*/ 
    2020 
    21 #include "libfreebobavc/avc_feature_function_block.h" 
     21#include "libfreebobavc/avc_function_block.h" 
    2222#include "libfreebobavc/serialize.h" 
    2323#include "libfreebobavc/ieee1394service.h" 
    2424 
    25 short int getMaxVolume(Ieee1394Service& ieee1394service, int node_id, int ffb_id) 
     25const bool bVerbose = false; 
     26 
     27short int 
     28getVolume( Ieee1394Service& ieee1394service, int node_id, int ffb_id, 
     29           FunctionBlockCmd::EControlAttribute control_attrib ) 
    2630{ 
    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() ) { 
    3544        printf( "cmd failed\n" ); 
    3645    } 
    37     return ffbCmd.m_volumeControl.m_volume; 
    38 } 
    3946 
    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    } 
    4851 
    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; 
    6753} 
    6854 
    6955bool 
    70 doApp(Ieee1394Service& ieee1394service, int node_id, int ffb_id, int vol ) 
     56setVolume( Ieee1394Service& ieee1394service, int node_id, int ffb_id, int vol ) 
    7157{ 
    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; 
    7467 
    75     printf("max volume value = %d\n", maxVolume); 
    76     printf("min volume value = %d\n", minVolume); 
     68    fbCmd.setVerbose( bVerbose ); 
     69    ieee1394service.setVerbose( bVerbose ); 
    7770 
    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 ) { 
    8973        printf( "cmd failed\n" ); 
    9074    } 
    9175 
    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 
     84bool 
     85doApp( 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 ); 
    9498 
    9599    return true; 
     
    104108 
    105109    if (argc < 3) { 
    106         printf("usage: NODE_ID FFB_ID VOL\n"); 
     110        printf("usage: NODE_ID FB_ID VOL\n"); 
    107111        exit(0); 
    108112    } 
     
    111115    char* tail; 
    112116    int node_id = strtol( argv[1], &tail, 0 ); 
    113     int ffb_id  = strtol( argv[2], &tail, 0 ); 
     117    int fb_id   = strtol( argv[2], &tail, 0 ); 
    114118    int vol     = strtol( argv[3], &tail, 0 ); 
    115119 
    116120    if (errno) { 
    117        perror("argument parsing failed:"); 
    118        return -1; 
     121        perror("argument parsing failed:"); 
     122        return -1; 
    119123    } 
    120124    Ieee1394Service ieee1394service; 
     
    124128    } 
    125129 
    126     doApp( ieee1394service, node_id, ffb_id, vol ); 
     130    doApp( ieee1394service, node_id, fb_id, vol ); 
    127131 
    128132    return 0;