Changeset 1338

Show
Ignore:
Timestamp:
09/23/08 14:43:50 (12 years ago)
Author:
wagi
Message:

- Add AV/C command for LRBalance feature function block
- Expose for each found feature function block one level feature

function mixer element and one left right balance feature
function mixer element.

- Add 'Volume' or 'LRBalance' as dbus

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0-with-panning/src/bebob/bebob_avdevice.cpp

    r1321 r1338  
    256256 
    257257//     if ( getDebugLevel() >= DEBUG_LEVEL_NORMAL ) { 
    258 //         Util::CoutSerializer se; 
     258//         Util::Cmd::CoutSerializer se; 
    259259//         fbCmd.serialize( se ); 
    260260//     } 
     
    286286     
    287287//     if ( getDebugLevel() >= DEBUG_LEVEL_NORMAL ) { 
    288 //         Util::CoutSerializer se; 
     288//         Util::Cmd::CoutSerializer se; 
    289289//         fbCmd.serialize( se ); 
    290290//     } 
     
    309309    fbCmd.m_pFBFeature->m_audioChannelNumber = channel; 
    310310    fbCmd.m_pFBFeature->m_controlSelector = FunctionBlockFeature::eCSE_Feature_Volume; 
     311    AVC::FunctionBlockFeatureVolume vl; 
     312    fbCmd.m_pFBFeature->m_pVolume = vl.clone(); 
    311313    fbCmd.m_pFBFeature->m_pVolume->m_volume = v; 
    312314    fbCmd.setVerboseLevel( getDebugLevel() ); 
     
    318320 
    319321//     if ( getDebugLevel() >= DEBUG_LEVEL_NORMAL ) { 
    320 //         Util::CoutSerializer se; 
     322//         Util::Cmd::CoutSerializer se; 
    321323//         fbCmd.serialize( se ); 
    322324//     } 
     
    341343    fbCmd.m_pFBFeature->m_audioChannelNumber = channel; 
    342344    fbCmd.m_pFBFeature->m_controlSelector = FunctionBlockFeature::eCSE_Feature_Volume; 
     345    AVC::FunctionBlockFeatureVolume vl; 
     346    fbCmd.m_pFBFeature->m_pVolume = vl.clone(); 
    343347    fbCmd.m_pFBFeature->m_pVolume->m_volume = 0; 
    344348    fbCmd.setVerboseLevel( getDebugLevel() ); 
     
    350354     
    351355//     if ( getDebugLevel() >= DEBUG_LEVEL_NORMAL ) { 
    352 //         Util::CoutSerializer se; 
     356//         Util::Cmd::CoutSerializer se; 
    353357//         fbCmd.serialize( se ); 
    354358//     } 
     
    379383{ 
    380384    return getFeatureFBVolumeValue(id, channel, AVC::FunctionBlockCmd::eCA_Current);    
     385} 
     386 
     387bool 
     388AvDevice::setFeatureFBLRBalanceCurrent(int id, int channel, int v) { 
     389 
     390    FunctionBlockCmd fbCmd( get1394Service(), 
     391                            FunctionBlockCmd::eFBT_Feature, 
     392                            id, 
     393                            FunctionBlockCmd::eCA_Current ); 
     394    fbCmd.setNodeId( getNodeId() ); 
     395    fbCmd.setSubunitId( 0x00 ); 
     396    fbCmd.setCommandType( AVCCommand::eCT_Control ); 
     397    fbCmd.m_pFBFeature->m_audioChannelNumber = channel; 
     398    fbCmd.m_pFBFeature->m_controlSelector = FunctionBlockFeature::eCSE_Feature_LRBalance; 
     399    AVC::FunctionBlockFeatureLRBalance bl; 
     400    fbCmd.m_pFBFeature->m_pLRBalance = bl.clone(); 
     401    fbCmd.m_pFBFeature->m_pLRBalance->m_lrBalance = v; 
     402    fbCmd.setVerboseLevel( getDebugLevel() ); 
     403 
     404    if ( !fbCmd.fire() ) { 
     405        debugError( "cmd failed\n" ); 
     406        return false; 
     407    } 
     408 
     409//     if ( getDebugLevel() >= DEBUG_LEVEL_NORMAL ) { 
     410//         Util::Cmd::CoutSerializer se; 
     411//         fbCmd.serialize( se ); 
     412//     } 
     413     
     414    if((fbCmd.getResponse() != AVCCommand::eR_Accepted)) { 
     415        debugWarning("fbCmd.getResponse() != AVCCommand::eR_Accepted\n"); 
     416    } 
     417 
     418    return (fbCmd.getResponse() == AVCCommand::eR_Accepted); 
     419} 
     420 
     421int 
     422AvDevice::getFeatureFBLRBalanceValue(int id, int channel, FunctionBlockCmd::EControlAttribute controlAttribute)  
     423{ 
     424    FunctionBlockCmd fbCmd( get1394Service(), 
     425                            FunctionBlockCmd::eFBT_Feature, 
     426                            id, 
     427                            controlAttribute); 
     428    fbCmd.setNodeId( getNodeId() ); 
     429    fbCmd.setSubunitId( 0x00 ); 
     430    fbCmd.setCommandType( AVCCommand::eCT_Status ); 
     431    fbCmd.m_pFBFeature->m_audioChannelNumber = channel; 
     432    fbCmd.m_pFBFeature->m_controlSelector = FunctionBlockFeature::eCSE_Feature_LRBalance; 
     433    AVC::FunctionBlockFeatureLRBalance bl; 
     434    fbCmd.m_pFBFeature->m_pLRBalance = bl.clone(); 
     435    fbCmd.m_pFBFeature->m_pLRBalance->m_lrBalance = 0; 
     436    fbCmd.setVerboseLevel( getDebugLevel() ); 
     437 
     438    if ( !fbCmd.fire() ) { 
     439        debugError( "cmd failed\n" ); 
     440        return 0; 
     441    } 
     442     
     443//     if ( getDebugLevel() >= DEBUG_LEVEL_NORMAL ) { 
     444//         Util::Cmd::CoutSerializer se; 
     445//         fbCmd.serialize( se ); 
     446//     } 
     447 
     448    if((fbCmd.getResponse() != AVCCommand::eR_Implemented)) { 
     449        debugWarning("fbCmd.getResponse() != AVCCommand::eR_Implemented\n"); 
     450    } 
     451     
     452    int16_t balance=(int16_t)(fbCmd.m_pFBFeature->m_pLRBalance->m_lrBalance); 
     453 
     454    return balance; 
     455} 
     456 
     457int  
     458AvDevice::getFeatureFBLRBalanceMinimum(int id, int channel) 
     459{ 
     460    return getFeatureFBLRBalanceValue(id, channel, AVC::FunctionBlockCmd::eCA_Minimum); 
     461} 
     462 
     463int  
     464AvDevice::getFeatureFBLRBalanceMaximum(int id, int channel) 
     465{ 
     466    return getFeatureFBLRBalanceValue(id, channel, AVC::FunctionBlockCmd::eCA_Maximum); 
     467} 
     468 
     469int  
     470AvDevice::getFeatureFBLRBalanceCurrent(int id, int channel) 
     471{ 
     472    return getFeatureFBLRBalanceValue(id, channel, AVC::FunctionBlockCmd::eCA_Current);    
    381473} 
    382474 
  • branches/libffado-2.0-with-panning/src/bebob/bebob_avdevice.h

    r1321 r1338  
    8585    virtual int getSelectorFBValue(int id); 
    8686    virtual bool setSelectorFBValue(int id, int v); 
     87 
    8788    virtual int getFeatureFBVolumeMinimum(int id, int channel); 
    8889    virtual int getFeatureFBVolumeMaximum(int id, int channel); 
    8990    virtual int getFeatureFBVolumeCurrent(int id, int channel); 
    9091    virtual bool setFeatureFBVolumeCurrent(int id, int channel, int v); 
     92 
     93    virtual int getFeatureFBLRBalanceMinimum(int id, int channel); 
     94    virtual int getFeatureFBLRBalanceMaximum(int id, int channel); 
     95    virtual int getFeatureFBLRBalanceCurrent(int id, int channel); 
     96    virtual bool setFeatureFBLRBalanceCurrent(int id, int channel, int v); 
    9197 
    9298    virtual void showDevice(); 
     
    99105 
    100106    virtual int getFeatureFBVolumeValue(int id, int channel, AVC::FunctionBlockCmd::EControlAttribute controlAttribute); 
     107    virtual int getFeatureFBLRBalanceValue(int id, int channel, AVC::FunctionBlockCmd::EControlAttribute controlAttribute); 
    101108 
    102109public: 
  • branches/libffado-2.0-with-panning/src/bebob/bebob_mixer.cpp

    r1321 r1338  
    108108} 
    109109 
    110 bool 
    111 Mixer::addElementForFunctionBlock(FunctionBlock& b) { 
    112     bool retval=true; 
    113      
    114     std::ostringstream ostrm; 
    115     ostrm << b.getName() << "_" << (int)(b.getId()); 
    116      
    117     debugOutput(DEBUG_LEVEL_NORMAL,"Adding element for functionblock %s...\n", 
    118         ostrm.str().c_str()); 
    119  
    120     Control::Element *e=NULL; 
    121      
    122     if (dynamic_cast<FunctionBlockSelector *>(&b) != NULL) { 
    123         FunctionBlockSelector *bf=dynamic_cast<FunctionBlockSelector *>(&b); 
    124         debugOutput( DEBUG_LEVEL_VERBOSE, "FB is a SelectorFunctionBlock\n"); 
    125         e=new MixerFBSelector(*this, *bf); 
    126         if (e) { 
    127             e->setVerboseLevel(getDebugLevel()); 
    128             retval &= Control::Container::addElement(e); 
    129         } else { 
    130             debugError("Control element creation failed\n"); 
    131             retval &= false; 
    132         } 
    133     } 
    134     if (dynamic_cast<FunctionBlockFeature *>(&b) != NULL) { 
    135         FunctionBlockFeature *bf=dynamic_cast<FunctionBlockFeature *>(&b); 
    136         debugOutput( DEBUG_LEVEL_VERBOSE, "FB is a FeatureFunctionBlock\n"); 
    137         e=new MixerFBFeature(*this, *bf); 
    138         if (e) { 
    139             e->setVerboseLevel(getDebugLevel()); 
    140             retval &= Control::Container::addElement(e); 
    141         } else { 
    142             debugError("Control element creation failed\n"); 
    143             retval &= false; 
    144         } 
    145     } 
    146  
    147     if (dynamic_cast<FunctionBlockEnhancedMixer *>(&b) != NULL) { 
    148         FunctionBlockEnhancedMixer *bf=dynamic_cast<FunctionBlockEnhancedMixer *>(&b); 
    149         debugOutput( DEBUG_LEVEL_VERBOSE, "FB is a FunctionBlockEnhancedMixer\n"); 
    150         e=new EnhancedMixerFBFeature(*this, *bf); 
    151         if (e) { 
    152             e->setVerboseLevel(getDebugLevel()); 
    153             retval &= Control::Container::addElement(e); 
    154         } else { 
    155             debugError("Control element creation failed\n"); 
    156             retval &= false; 
    157         } 
    158     } 
    159      
     110template<typename FBType, typename MixerType>  
     111bool 
     112Mixer::addElementForFunctionBlock(FBType& b) 
     113
     114    Control::Element *e = new MixerType(*this, b); 
    160115    if (!e) { 
    161         debugError("No control element created\n"); 
     116        debugError("Control element creation failed\n"); 
    162117        return false; 
    163118    } 
    164119 
    165     return retval; 
     120    e->setVerboseLevel(getDebugLevel()); 
     121    return Control::Container::addElement(e); 
    166122} 
    167123 
     
    169125Mixer::addElementForAllFunctionBlocks() { 
    170126    debugOutput(DEBUG_LEVEL_NORMAL,"Adding elements for functionblocks...\n"); 
     127 
     128    bool retval = true; 
    171129 
    172130    BeBoB::SubunitAudio *asu = 
     
    183141          ++it ) 
    184142    { 
    185         if (!addElementForFunctionBlock(*(*it))) { 
     143        FunctionBlock *pfb = *it; 
     144        FunctionBlockSelector *ps; 
     145        FunctionBlockFeature *pf; 
     146        FunctionBlockEnhancedMixer *pm; 
     147 
     148        if ((ps = dynamic_cast<FunctionBlockSelector *>(pfb))) { 
     149            debugOutput( DEBUG_LEVEL_VERBOSE, "FB is a SelectorFunctionBlock\n"); 
     150            retval = addElementForFunctionBlock<FunctionBlockSelector, MixerFBSelector>(*ps); 
     151        } else if ((pf = dynamic_cast<FunctionBlockFeature *>(pfb))) { 
     152            // We might should check if really both feature function 
     153            // blocks exists and only then announce them. The FA-101, 
     154            // FA-66 and the Ref BCO Audio5 do have both. 
     155            debugOutput( DEBUG_LEVEL_VERBOSE, "FB is a FeatureFunctionBlock\n"); 
     156            retval  = addElementForFunctionBlock<FunctionBlockFeature, MixerFBFeatureVolume>(*pf); 
     157            retval &= addElementForFunctionBlock<FunctionBlockFeature, MixerFBFeatureLRBalance>(*pf); 
     158        } else if ((pm = dynamic_cast<FunctionBlockEnhancedMixer *>(pfb))) { 
     159            // All BeBoB devices lock the mixer feature function 
     160            // block. The AV/C model for this mixer is just to 
     161            // complex and the BridgeCo guys decided to use the above 
     162            // function feature blocks (level and balance) to achive 
     163            // the same. 
     164            debugOutput( DEBUG_LEVEL_VERBOSE, "FB is a FunctionBlockEnhancedMixer\n"); 
     165            retval = addElementForFunctionBlock<FunctionBlockEnhancedMixer, EnhancedMixerFBFeature>(*pm); 
     166        } 
     167 
     168        if (!retval) { 
    186169            std::ostringstream ostrm; 
    187170            ostrm << (*it)->getName() << " " << (int)((*it)->getId()); 
     
    191174        }; 
    192175    } 
    193     return true
     176    return retval
    194177} 
    195178 
    196179// --- element implementation classes 
    197180 
    198 MixerFBFeature::MixerFBFeature(Mixer& parent, FunctionBlockFeature& s) 
     181MixerFBFeatureVolume::MixerFBFeatureVolume(Mixer& parent, FunctionBlockFeature& s) 
    199182: Control::Continuous(&parent) 
    200183, m_Parent(parent)  
     
    202185{ 
    203186    std::ostringstream ostrm; 
    204     ostrm << s.getName() << "_" << (int)(s.getId()); 
     187    ostrm << s.getName() << "_Volume_" << (int)(s.getId()); 
    205188     
    206189    Control::Continuous::setName(ostrm.str()); 
    207190     
    208191    ostrm.str(""); 
    209     ostrm << "Label for " << s.getName() << " " << (int)(s.getId()); 
     192    ostrm << "Label for " << s.getName() << "_Volume " << (int)(s.getId()); 
    210193    setLabel(ostrm.str()); 
    211194     
    212195    ostrm.str(""); 
    213     ostrm << "Description for " << s.getName() << " " << (int)(s.getId()); 
     196    ostrm << "Description for " << s.getName() << "_Volume " << (int)(s.getId()); 
    214197    setDescription(ostrm.str()); 
    215198} 
    216199 
    217 bool 
    218 MixerFBFeature::setValue(double v) 
     200MixerFBFeatureVolume::~MixerFBFeatureVolume() 
     201
     202
     203 
     204bool 
     205MixerFBFeatureVolume::setValue(double v) 
    219206{ 
    220207    return setValue(0, v); 
     
    222209 
    223210bool 
    224 MixerFBFeature::setValue(int idx, double v) 
     211MixerFBFeatureVolume::setValue(int idx, double v) 
    225212{ 
    226213    int volume=(int)v; 
     
    231218 
    232219double 
    233 MixerFBFeature::getValue() 
     220MixerFBFeatureVolume::getValue() 
    234221{ 
    235222    return getValue(0); 
     
    237224 
    238225double 
    239 MixerFBFeature::getValue(int idx) 
     226MixerFBFeatureVolume::getValue(int idx) 
    240227{ 
    241228    debugOutput(DEBUG_LEVEL_NORMAL,"Get feature volume %d...\n", 
     
    246233 
    247234double 
    248 MixerFBFeature::getMinimum() 
     235MixerFBFeatureVolume::getMinimum() 
    249236{ 
    250237    debugOutput(DEBUG_LEVEL_NORMAL,"Get feature minimum volume %d...\n", 
     
    255242 
    256243double 
    257 MixerFBFeature::getMaximum() 
     244MixerFBFeatureVolume::getMaximum() 
    258245{ 
    259246    debugOutput(DEBUG_LEVEL_NORMAL,"Get feature maximum volume %d...\n", 
     
    261248 
    262249    return m_Parent.getParent().getFeatureFBVolumeMaximum(m_Slave.getId(), 0); 
     250} 
     251 
     252// --- element implementation classes 
     253 
     254MixerFBFeatureLRBalance::MixerFBFeatureLRBalance(Mixer& parent, FunctionBlockFeature& s) 
     255: Control::Continuous(&parent) 
     256, m_Parent(parent)  
     257, m_Slave(s) 
     258{ 
     259    std::ostringstream ostrm; 
     260    ostrm << s.getName() << "_LRBalance_" << (int)(s.getId()); 
     261     
     262    Control::Continuous::setName(ostrm.str()); 
     263     
     264    ostrm.str(""); 
     265    ostrm << "Label for " << s.getName() << "_LRBalance " << (int)(s.getId()); 
     266    setLabel(ostrm.str()); 
     267     
     268    ostrm.str(""); 
     269    ostrm << "Description for " << s.getName() << "_LRBalance " << (int)(s.getId()); 
     270    setDescription(ostrm.str()); 
     271} 
     272 
     273MixerFBFeatureLRBalance::~MixerFBFeatureLRBalance() 
     274{ 
     275} 
     276 
     277bool 
     278MixerFBFeatureLRBalance::setValue(double v) 
     279{ 
     280    return setValue(0, v); 
     281} 
     282 
     283bool 
     284MixerFBFeatureLRBalance::setValue(int idx, double v) 
     285{ 
     286    int volume=(int)v; 
     287    debugOutput(DEBUG_LEVEL_NORMAL,"Set feature balance %d to %d...\n", 
     288        m_Slave.getId(), volume); 
     289    return m_Parent.getParent().setFeatureFBLRBalanceCurrent(m_Slave.getId(), idx, volume); 
     290} 
     291 
     292double 
     293MixerFBFeatureLRBalance::getValue() 
     294{ 
     295    return getValue(0); 
     296} 
     297 
     298double 
     299MixerFBFeatureLRBalance::getValue(int idx) 
     300{ 
     301    debugOutput(DEBUG_LEVEL_NORMAL,"Get feature balance %d...\n", 
     302        m_Slave.getId()); 
     303 
     304    return m_Parent.getParent().getFeatureFBLRBalanceCurrent(m_Slave.getId(), idx); 
     305} 
     306 
     307double 
     308MixerFBFeatureLRBalance::getMinimum() 
     309{ 
     310    debugOutput(DEBUG_LEVEL_NORMAL,"Get feature balance volume %d...\n", 
     311        m_Slave.getId()); 
     312 
     313    return m_Parent.getParent().getFeatureFBLRBalanceMinimum(m_Slave.getId(), 0); 
     314} 
     315 
     316double 
     317MixerFBFeatureLRBalance::getMaximum() 
     318{ 
     319    debugOutput(DEBUG_LEVEL_NORMAL,"Get feature maximum balance %d...\n", 
     320        m_Slave.getId()); 
     321 
     322    return m_Parent.getParent().getFeatureFBLRBalanceMaximum(m_Slave.getId(), 0); 
    263323} 
    264324 
     
    284344} 
    285345 
     346EnhancedMixerFBFeature::~EnhancedMixerFBFeature() 
     347{ 
     348} 
     349 
    286350bool 
    287351EnhancedMixerFBFeature::setValue(double v) 
     
    323387} 
    324388 
     389MixerFBSelector::~MixerFBSelector() 
     390{ 
     391} 
     392 
    325393bool 
    326394MixerFBSelector::setValue(int v) 
  • branches/libffado-2.0-with-panning/src/bebob/bebob_mixer.h

    r1321 r1338  
    5151        { return false; }; 
    5252 
    53     bool addElementForFunctionBlock(FunctionBlock& b); 
     53    template<typename FBType, typename MixerType> bool addElementForFunctionBlock(FBType& b); 
    5454    bool addElementForAllFunctionBlocks(); 
    5555 
     
    6969}; 
    7070 
    71 class MixerFBFeature 
     71class MixerFBFeatureVolume 
    7272    : public Control::Continuous 
    7373{ 
    7474public: 
    75     MixerFBFeature(Mixer& parent, FunctionBlockFeature&); 
     75    MixerFBFeatureVolume(Mixer& parent, FunctionBlockFeature&); 
     76    virtual ~MixerFBFeatureVolume(); 
     77 
     78    virtual bool setValue(double v); 
     79    virtual double getValue(); 
     80    virtual bool setValue(int idx, double v); 
     81    virtual double getValue(int idx); 
     82    virtual double getMinimum(); 
     83    virtual double getMaximum(); 
     84 
     85private: 
     86    Mixer&                  m_Parent; 
     87    FunctionBlockFeature&   m_Slave; 
     88}; 
     89 
     90class MixerFBFeatureLRBalance 
     91    : public Control::Continuous 
     92
     93public: 
     94    MixerFBFeatureLRBalance(Mixer& parent, FunctionBlockFeature&); 
     95    virtual ~MixerFBFeatureLRBalance(); 
    7696 
    7797    virtual bool setValue(double v); 
     
    92112public: 
    93113    EnhancedMixerFBFeature(Mixer& parent, FunctionBlockEnhancedMixer&); 
     114    virtual ~EnhancedMixerFBFeature(); 
    94115 
    95116    virtual bool setValue(double v); 
     
    113134public: 
    114135    MixerFBSelector(Mixer& parent, FunctionBlockSelector&); 
     136    virtual ~MixerFBSelector(); 
    115137 
    116138    virtual bool setValue(int v); 
  • branches/libffado-2.0-with-panning/src/libavc/audiosubunit/avc_function_block.cpp

    r864 r1338  
    8686///////////////////////////////// 
    8787 
     88FunctionBlockFeatureLRBalance::FunctionBlockFeatureLRBalance() 
     89    : IBusData() 
     90    , m_controlDataLength( 2 ) 
     91    , m_lrBalance( 0 ) 
     92{ 
     93} 
     94 
     95FunctionBlockFeatureLRBalance::FunctionBlockFeatureLRBalance( const FunctionBlockFeatureLRBalance& rhs ) 
     96    : m_controlDataLength( rhs.m_controlDataLength ) 
     97    , m_lrBalance( rhs.m_lrBalance ) 
     98{ 
     99} 
     100 
     101FunctionBlockFeatureLRBalance::~FunctionBlockFeatureLRBalance() 
     102{ 
     103} 
     104 
     105bool 
     106FunctionBlockFeatureLRBalance::serialize( Util::Cmd::IOSSerialize& se ) 
     107{ 
     108    bool bStatus; 
     109    byte_t val; 
     110    bStatus = se.write( m_controlDataLength,  "FunctionBlockFeatureLRBalance controlDataLength" ); 
     111    val = (byte_t)(m_lrBalance >> 8); 
     112    bStatus &= se.write( val,                 "FunctionBlockFeatureLRBalance LR Balance high" ); 
     113    val = m_lrBalance & 0xff; 
     114    bStatus &= se.write( val,                 "FunctionBlockFeatureLRBalance LR Balance low" ); 
     115 
     116    return bStatus; 
     117} 
     118 
     119bool 
     120FunctionBlockFeatureLRBalance::deserialize( Util::Cmd::IISDeserialize& de ) 
     121{ 
     122    bool bStatus; 
     123    byte_t val; 
     124    bStatus = de.read( &m_controlDataLength ); 
     125    bStatus &= de.read( &val ); 
     126    m_lrBalance = val << 8; 
     127    bStatus &= de.read( &val ); 
     128    m_lrBalance |= val; 
     129 
     130    return bStatus; 
     131} 
     132 
     133FunctionBlockFeatureLRBalance* 
     134FunctionBlockFeatureLRBalance::clone() const 
     135{ 
     136    return new FunctionBlockFeatureLRBalance( *this ); 
     137} 
     138 
     139///////////////////////////////// 
     140 
    88141FunctionBlockProcessingMixer::FunctionBlockProcessingMixer() 
    89142    : IBusData() 
     
    210263{ 
    211264    int todo; 
    212     bool bStatus=true
     265    bool bStatus
    213266    bStatus  = de.read( &m_controlSelector ); 
    214267 
     
    219272 
    220273    // same here 
    221     //m_statusSelector = eSS_Level;  
    222     m_statusSelector = eSS_ProgramableState;  
     274    m_statusSelector = eSS_Level;  
     275    //m_statusSelector = eSS_ProgramableState;  
    223276 
    224277    byte_t data_length_hi; 
     
    228281 
    229282    m_controlDataLength = (data_length_hi << 8) + data_length_lo; 
     283    printf("m_controlDataLength = %d\n", m_controlDataLength); 
    230284    switch (m_statusSelector) { 
    231285        case eSS_ProgramableState: 
     
    256310        case eSS_Level: 
    257311            m_LevelData.clear(); 
    258             for (int i=0;i<m_controlDataLength/2;i++) { 
    259                 byte_t mixer_value_hi=0, mixer_value_lo=0; 
     312            for (int i = 0; i < m_controlDataLength/2; i++) { 
     313                byte_t mixer_value_hi = 0; 
     314                byte_t mixer_value_lo = 0; 
    260315                bStatus &= de.read( &mixer_value_hi); 
    261316                bStatus &= de.read( &mixer_value_lo); 
     317 
    262318                mixer_level_t value = (mixer_value_hi << 8) + mixer_value_lo; 
     319 
     320                printf("value = %x\n", value); 
    263321                m_LevelData.push_back(value); 
    264322            } 
     
    334392    , m_audioChannelNumber( 0x00 ) 
    335393    , m_controlSelector( eCSE_Feature_Unknown ) 
    336     , m_pVolume( new FunctionBlockFeatureVolume ) 
     394    , m_pVolume( 0 ) 
     395    , m_pLRBalance( 0 ) 
    337396{ 
    338397} 
     
    346405    if ( rhs.m_pVolume ) { 
    347406        m_pVolume = new FunctionBlockFeatureVolume( *rhs.m_pVolume ); 
     407    } else if ( rhs.m_pLRBalance ) { 
     408        m_pLRBalance = new FunctionBlockFeatureLRBalance( *rhs.m_pLRBalance ); 
    348409    } 
    349410} 
     
    352413{ 
    353414    delete m_pVolume; 
    354     m_pVolume = NULL; 
     415    m_pVolume = 0; 
     416    delete m_pLRBalance; 
     417    m_pLRBalance = 0; 
    355418} 
    356419 
     
    363426    bStatus &= se.write( m_controlSelector,    "FunctionBlockFeature controlSelector" ); 
    364427 
    365     if ( m_controlSelector == eCSE_Feature_Volume ) { 
     428    switch( m_controlSelector ) { 
     429    case eCSE_Feature_Volume: 
    366430        bStatus &= m_pVolume->serialize( se ); 
    367     } else { 
     431        break; 
     432    case eCSE_Feature_LRBalance: 
     433        bStatus &= m_pLRBalance->serialize( se ); 
     434        break; 
     435    case eCSE_Feature_Mute: 
     436    case eCSE_Feature_FRBalance: 
     437    case eCSE_Feature_Bass: 
     438    case eCSE_Feature_Mid: 
     439    case eCSE_Feature_Treble: 
     440    case eCSE_Feature_GEQ: 
     441    case eCSE_Feature_AGC: 
     442    case eCSE_Feature_Delay: 
     443    case eCSE_Feature_BassBoost: 
     444    case eCSE_Feature_Loudness: 
     445    default: 
    368446        bStatus = false; 
    369447    } 
     
    384462        bStatus &= m_pVolume->deserialize( de ); 
    385463        break; 
     464    case eCSE_Feature_LRBalance: 
     465        bStatus &= m_pLRBalance->deserialize( de ); 
     466        break; 
    386467    case eCSE_Feature_Mute: 
    387     case eCSE_Feature_LRBalance: 
    388468    case eCSE_Feature_FRBalance: 
    389469    case eCSE_Feature_Bass: 
  • branches/libffado-2.0-with-panning/src/libavc/audiosubunit/avc_function_block.h

    r864 r1338  
    4848    control_data_length_t  m_controlDataLength; 
    4949    u_int16_t              m_volume; 
     50}; 
     51 
     52/////////////////////////////////////////// 
     53 
     54class FunctionBlockFeatureLRBalance: public IBusData 
     55{ 
     56public: 
     57    FunctionBlockFeatureLRBalance(); 
     58    FunctionBlockFeatureLRBalance( const FunctionBlockFeatureLRBalance& rhs ); 
     59    virtual ~FunctionBlockFeatureLRBalance(); 
     60 
     61    virtual bool serialize( Util::Cmd::IOSSerialize& se ); 
     62    virtual bool deserialize( Util::Cmd::IISDeserialize& de ); 
     63    virtual FunctionBlockFeatureLRBalance* clone() const; 
     64 
     65    control_data_length_t  m_controlDataLength; 
     66    u_int16_t              m_lrBalance; 
    5067}; 
    5168 
     
    159176 
    160177    FunctionBlockFeatureVolume*     m_pVolume; 
     178    FunctionBlockFeatureLRBalance*  m_pLRBalance; 
    161179}; 
    162180