Changeset 439

Show
Ignore:
Timestamp:
03/13/07 15:17:03 (17 years ago)
Author:
pieterpalmers
Message:

- some work on the AVC mixer & control stuff

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/streaming-rework/src/bebob/bebob_avplug.cpp

    r438 r439  
    19611961        AvPlug* plug = *it; 
    19621962        if ( plug->getFunctionBlockType() != 0xff ) { 
     1963            std::ostringstream strstrm; 
     1964            switch(plug->getFunctionBlockType()) { 
     1965                case 0x80: 
     1966                    strstrm << "Selector FB"; 
     1967                    break; 
     1968                case 0x81: 
     1969                    strstrm << "Feature FB"; 
     1970                    break; 
     1971                case 0x82: 
     1972                    strstrm << "Processing FB"; 
     1973                    break; 
     1974                case 0x83: 
     1975                    strstrm << "CODEC FB"; 
     1976                    break; 
     1977                default: 
     1978                    strstrm << plug->getFunctionBlockType(); 
     1979            } 
     1980 
    19631981            if ( plug->getPlugDirection() == AvPlug::eAPD_Input ) { 
    1964                 debugOutputShort( DEBUG_LEVEL_NORMAL, "\t\"(%d) %s\" -> \"(0x%02x,%d)\"\n", 
     1982                debugOutputShort( DEBUG_LEVEL_NORMAL, "\t\"(%d) %s\" -> \"(%s, ID %d)\"\n", 
    19651983                        plug->getGlobalId(), 
    19661984                        plug->getName(), 
    1967                         plug->getFunctionBlockType(), 
     1985                        strstrm.str().c_str(), 
    19681986                        plug->getFunctionBlockId() ); 
    19691987            } else { 
    1970                 debugOutputShort( DEBUG_LEVEL_NORMAL, "\t\"(0x%02x,%d)\" -> \t\"(%d) %s\"\n", 
    1971                         plug->getFunctionBlockType(), 
     1988                debugOutputShort( DEBUG_LEVEL_NORMAL, "\t\"(%s, ID %d)\" -> \t\"(%d) %s\"\n", 
     1989                        strstrm.str().c_str(), 
    19721990                        plug->getFunctionBlockId(), 
    19731991                        plug->getGlobalId(), 
  • branches/streaming-rework/src/bebob/bebob_avplug.h

    r438 r439  
    9696 
    9797    int getGlobalId() const 
    98        { return m_globalId; } 
     98        { return m_globalId; } 
    9999    plug_id_t getPlugId() const 
    100        { return m_id; } 
     100        { return m_id; } 
    101101    AVCCommand::ESubunitType getSubunitType() const 
    102        { return m_subunitType; } 
     102        { return m_subunitType; } 
    103103    subunit_id_t getSubunitId() const 
    104        { return m_subunitId; } 
     104        { return m_subunitId; } 
    105105    const char* getName() const 
    106        { return m_name.c_str(); } 
     106        { return m_name.c_str(); } 
    107107    EAvPlugDirection getPlugDirection() const 
    108        { return m_direction; } 
     108        { return m_direction; } 
    109109    sampling_frequency_t getSamplingFrequency() const 
    110        { return m_samplingFrequency; } 
     110        { return m_samplingFrequency; } 
    111111    int getSampleRate() const; // 22050, 24000, 32000, ... 
    112112    int getNrOfChannels() const; 
     
    118118        { return m_addressType; } 
    119119    EAvPlugType getPlugType() const 
    120        { return m_infoPlugType; } 
     120        { return m_infoPlugType; } 
    121121 
    122122    function_block_type_t getFunctionBlockType() const 
    123        { return m_functionBlockType; } 
     123        { return m_functionBlockType; } 
    124124    function_block_id_t getFunctionBlockId() const 
    125125        { return m_functionBlockId; } 
  • branches/streaming-rework/src/debugmodule/debugmodule.cpp

    r406 r439  
    5454DebugModule::~DebugModule() 
    5555{ 
    56     if ( m_level >= eDL_VeryVerbose ) { 
    57         cout << "Unregistering " 
    58              << this->getName() 
    59              << " at DebugModuleManager" 
    60              << endl; 
    61     } 
     56//     if ( m_level >= eDL_VeryVerbose ) { 
     57//         cout << "Unregistering " 
     58//              << this->getName() 
     59//              << " at DebugModuleManager" 
     60//              << endl; 
     61//     } 
    6262    if ( !DebugModuleManager::instance()->unregisterModule( *this ) ) { 
    6363        cerr << "Could not unregister DebugModule at DebugModuleManager" 
  • branches/streaming-rework/src/libavc/avc_definitions.h

    r438 r439  
    7171typedef byte_t control_selector_t; 
    7272typedef byte_t control_data_length_t; 
     73typedef uint16_t control_data_ext_length_t; 
     74typedef uint16_t mixer_level_t; 
     75typedef byte_t mixer_programmable_state_t; 
    7376typedef byte_t input_fb_plug_number_t; 
    7477typedef byte_t input_audio_channel_number_t; 
  • branches/streaming-rework/src/libavc/avc_function_block.cpp

    r413 r439  
    144144FunctionBlockProcessingEnhancedMixer::serialize( IOSSerialize& se ) 
    145145{ 
    146     bool bStatus; 
     146    int todo,done; 
     147    bool bStatus; 
     148    byte_t data_length_hi, data_length_lo; 
     149     
    147150    bStatus  = se.write( m_controlSelector, "FunctionBlockProcessingEnhancedMixer controlSelector" ); 
    148151    bStatus &= se.write( m_statusSelector,  "FunctionBlockProcessingEnhancedMixer statusSelector" ); 
    149  
     152     
     153    switch (m_statusSelector) { 
     154        case eSS_ProgramableState: 
     155            m_controlDataLength=m_LevelData.size(); 
     156            data_length_hi=(m_controlDataLength >> 8); 
     157            data_length_lo=(m_controlDataLength & 0xFF); 
     158            bStatus &= se.write( data_length_hi,  "FunctionBlockProcessingEnhancedMixer controlDataLengthHi" ); 
     159            bStatus &= se.write( data_length_lo,  "FunctionBlockProcessingEnhancedMixer controlDataLengthLo" ); 
     160 
     161            for (int i=0;i<m_controlDataLength/8;i++) { 
     162                byte_t value=0; 
     163                 
     164                for (int j=0;j<8;j++) { 
     165                    control_data_ext_length_t bit_value=m_ProgramableStateData.at(i*8+j); 
     166                    value |= bit_value << (7-j); 
     167                } 
     168                 
     169                bStatus &= se.write( value,  "FunctionBlockProcessingEnhancedMixer data" ); 
     170            } 
     171             
     172            todo=m_controlDataLength%8; 
     173            done=m_controlDataLength-todo; 
     174            if (todo) { 
     175                byte_t value=0; 
     176                for (int j=0;j<todo;j++) { 
     177                    control_data_ext_length_t bit_value=m_ProgramableStateData.at(done*8+j); 
     178                    value |= bit_value << (7-j); 
     179                } 
     180                bStatus &= se.write( value,  "FunctionBlockProcessingEnhancedMixer data" ); 
     181            } 
     182            break; 
     183        case eSS_Level: 
     184            m_controlDataLength=m_LevelData.size()/2; 
     185            data_length_hi=(m_controlDataLength >> 8); 
     186            data_length_lo=(m_controlDataLength & 0xFF); 
     187            bStatus &= se.write( data_length_hi,  "FunctionBlockProcessingEnhancedMixer controlDataLengthHi" ); 
     188            bStatus &= se.write( data_length_lo,  "FunctionBlockProcessingEnhancedMixer controlDataLengthLo" ); 
     189 
     190            for (int i=0;i<m_controlDataLength/2;i++) { 
     191                mixer_level_t value=m_LevelData.at(i); 
     192                byte_t value_hi=value >> 8; 
     193                byte_t value_lo=value & 0xFF; 
     194                 
     195                bStatus &= se.write( value_hi,  "FunctionBlockProcessingEnhancedMixer data" ); 
     196                bStatus &= se.write( value_lo,  "FunctionBlockProcessingEnhancedMixer data" ); 
     197            } 
     198            break; 
     199    } 
    150200    return bStatus; 
    151201} 
     
    154204FunctionBlockProcessingEnhancedMixer::deserialize( IISDeserialize& de ) 
    155205{ 
    156     bool bStatus; 
     206    int todo; 
     207    bool bStatus=true; 
    157208    bStatus  = de.read( &m_controlSelector ); 
     209 
     210    // NOTE: the returned value is currently bogus, so overwrite it 
     211    m_controlSelector=FunctionBlockProcessing::eCSE_Processing_EnhancedMixer; 
     212 
    158213    bStatus &= de.read( &m_statusSelector ); 
     214 
     215    byte_t data_length_hi; 
     216    byte_t data_length_lo; 
     217    bStatus &= de.read( &data_length_hi ); 
     218    bStatus &= de.read( &data_length_lo ); 
     219 
     220    m_controlDataLength = (data_length_hi << 8) + data_length_lo; 
     221    switch (m_statusSelector) { 
     222        case eSS_ProgramableState: 
     223            m_ProgramableStateData.clear(); 
     224            for (int i=0;i<m_controlDataLength/8;i++) { 
     225                byte_t value; 
     226                bStatus &= de.read( &value); 
     227 
     228                for (int j=7;j>=0;j--) { 
     229                    byte_t bit_value; 
     230                    bit_value=(((1<<j) & value) ? 1 : 0); 
     231                    m_ProgramableStateData.push_back(bit_value); 
     232                } 
     233            } 
     234 
     235            todo=m_controlDataLength%8; 
     236            if (todo) { 
     237                byte_t value; 
     238                bStatus &= de.read( &value); 
     239 
     240                for (int j=7;j>7-todo;j--) { 
     241                    byte_t bit_value; 
     242                    bit_value=(((1<<j) & value) ? 1 : 0); 
     243                    m_ProgramableStateData.push_back(bit_value); 
     244                } 
     245            } 
     246            break; 
     247        case eSS_Level: 
     248            m_LevelData.clear(); 
     249            for (int i=0;i<m_controlDataLength/2;i++) { 
     250                byte_t mixer_value_hi=0, mixer_value_lo=0; 
     251                bStatus &= de.read( &mixer_value_hi); 
     252                bStatus &= de.read( &mixer_value_lo); 
     253                mixer_level_t value = (mixer_value_hi << 8) + mixer_value_lo; 
     254                m_LevelData.push_back(value); 
     255            } 
     256            break; 
     257    } 
    159258 
    160259    return bStatus; 
     
    358457FunctionBlockProcessing::deserialize( IISDeserialize& de ) 
    359458{ 
     459    // NOTE: apparently the fbCmd of the STATUS type, 
     460    // with EnhancedMixer controlSelector returns with this 
     461    // controlSelector type changed to Mixer, making it 
     462    // impossible to choose the correct response handler 
     463    // based upon the response only. 
     464     
     465    // HACK: we assume that it is the same as the sent one 
     466    // we also look at our data structure to figure out what we sent 
     467    byte_t controlSelector=eCSE_Processing_Unknown; 
     468    if(m_pMixer) { 
     469        controlSelector=eCSE_Processing_Mixer; 
     470    } else if(m_pEnhancedMixer) { 
     471        controlSelector=eCSE_Processing_EnhancedMixer; 
     472    } 
     473     
    360474    bool bStatus; 
    361475    bStatus  = de.read( &m_selectorLength ); 
     
    364478    bStatus &= de.read( &m_outputAudioChannelNumber ); 
    365479 
    366     byte_t controlSelector; 
    367     bStatus &= de.peek( &controlSelector ); 
     480    byte_t controlSelector_response; 
     481    bStatus &= de.peek( &controlSelector_response ); 
     482/*    debugOutput(DEBUG_LEVEL_VERBOSE,"ctrlsel: orig = %02X, resp = %02X\n", 
     483        controlSelector, controlSelector_response);*/ 
     484     
    368485    switch( controlSelector ) { 
    369486    case eCSE_Processing_Mixer: 
     
    385502    } 
    386503 
     504    byte_t tmp; 
     505    if (de.peek(&tmp)) { 
     506        debugOutput(DEBUG_LEVEL_VERBOSE,"Unprocessed bytes:\n"); 
     507        while (de.read(&tmp)) { 
     508            debugOutput(DEBUG_LEVEL_VERBOSE," %02X\n",tmp); 
     509        } 
     510    } 
     511 
    387512    return bStatus; 
    388513} 
  • branches/streaming-rework/src/libavc/avc_function_block.h

    r379 r439  
    2626 
    2727#include <libavc1394/avc1394.h> 
     28#include <vector> 
     29using namespace std; 
    2830 
    2931class FunctionBlockFeatureVolume: public IBusData 
     
    7880    virtual FunctionBlockProcessingEnhancedMixer* clone() const; 
    7981 
    80     control_selector_t m_controlSelector; 
    81     status_selector_t  m_statusSelector; 
     82    control_selector_t        m_controlSelector; 
     83    status_selector_t         m_statusSelector; 
     84    control_data_ext_length_t m_controlDataLength; 
     85    vector<mixer_programmable_state_t> m_ProgramableStateData; 
     86    vector<mixer_level_t>              m_LevelData; 
    8287}; 
    8388 
  • branches/streaming-rework/src/libavc/avc_generic.cpp

    r413 r439  
    3030 
    3131IMPL_DEBUG_MODULE( AVCCommand, AVCCommand, DEBUG_LEVEL_NORMAL ); 
     32IMPL_DEBUG_MODULE( IBusData, IBusData, DEBUG_LEVEL_VERBOSE ); 
    3233 
    3334int AVCCommand::m_time = 0; 
  • branches/streaming-rework/src/libavc/avc_generic.h

    r375 r439  
    4545 
    4646    virtual IBusData* clone() const = 0; 
     47     
     48protected: 
     49    DECLARE_DEBUG_MODULE; 
    4750}; 
    4851 
  • branches/streaming-rework/src/libavc/avc_serialize.cpp

    r365 r439  
    2626#include <netinet/in.h> 
    2727 
     28IMPL_DEBUG_MODULE( CoutSerializer, CoutSerializer, DEBUG_LEVEL_NORMAL ); 
     29 
    2830bool 
    2931CoutSerializer::write( byte_t d, const char* name ) 
    3032{ 
    31     printf( "  %3d:\t0x%02x\t%s\n", m_cnt, d, name ); 
     33    debugOutput( DEBUG_LEVEL_NORMAL, "  %3d:\t0x%02x\t%s\n", m_cnt, d, name ); 
    3234    m_cnt += sizeof( byte_t ); 
    3335 
     
    3840CoutSerializer::write( quadlet_t d, const char* name ) 
    3941{ 
    40     printf( "  %3d:\t0x%08x\t%s\n", m_cnt, d, name ); 
     42    debugOutput( DEBUG_LEVEL_NORMAL, "  %3d:\t0x%08x\t%s\n", m_cnt, d, name ); 
    4143    m_cnt += sizeof( quadlet_t ); 
    4244    return true; 
  • branches/streaming-rework/src/libavc/avc_serialize.h

    r365 r439  
    2121#ifndef Serialize_h 
    2222#define Serialize_h 
     23 
     24#include "debugmodule/debugmodule.h" 
    2325 
    2426#include <libraw1394/raw1394.h> // byte_t and quadlet_t declaration 
     
    6264private: 
    6365    unsigned int m_cnt; 
     66    DECLARE_DEBUG_MODULE; 
    6467 
    6568}; 
  • branches/streaming-rework/src/libieee1394/ieee1394service.cpp

    r436 r439  
    287287    } 
    288288 
    289     #ifdef DEBUG 
    290     debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "  pre avc1394_transaction_block2\n" ); 
    291     printBuffer( DEBUG_LEVEL_VERY_VERBOSE, len, buf ); 
    292     #endif 
    293  
    294289    fb_quadlet_t* result = 
    295290        avc1394_transaction_block2( m_handle, 
     
    299294                                    resp_len, 
    300295                                    10 ); 
    301  
    302     #ifdef DEBUG 
    303     debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "  post avc1394_transaction_block2\n" ); 
    304     printBuffer( DEBUG_LEVEL_VERY_VERBOSE, *resp_len, result ); 
    305     #endif 
    306296 
    307297    for ( unsigned int i = 0; i < *resp_len; ++i ) { 
  • branches/streaming-rework/tests/test-mixer.cpp

    r437 r439  
    2121#include "libavc/avc_function_block.h" 
    2222#include "libavc/avc_serialize.h" 
     23#include "debugmodule/debugmodule.h" 
    2324 
    2425#include "libieee1394/ieee1394service.h" 
     26#include <string.h> 
     27 
     28DECLARE_GLOBAL_DEBUG_MODULE; 
    2529 
    2630const bool bVerbose = true; 
     
    3842    fbCmd.m_pFBProcessing->m_pEnhancedMixer = new FunctionBlockProcessingEnhancedMixer; 
    3943 
    40     fbCmd.m_pFBProcessing->m_fbInputPlugNumber = 0x01; 
     44    debugOutput(DEBUG_LEVEL_NORMAL, "Requesting mixer programmable state...\n"); 
     45 
     46    fbCmd.m_pFBProcessing->m_fbInputPlugNumber = 0x00; 
    4147    fbCmd.m_pFBProcessing->m_inputAudioChannelNumber  = 0xff; 
    4248    fbCmd.m_pFBProcessing->m_outputAudioChannelNumber = 0xff; 
    4349    fbCmd.m_pFBProcessing->m_pEnhancedMixer->m_statusSelector 
    4450        = FunctionBlockProcessingEnhancedMixer::eSS_ProgramableState; 
    45 //     fbCmd.m_pFBProcessing->m_pEnhancedMixer->m_statusSelector 
    46 //         = FunctionBlockProcessingEnhancedMixer::eSS_Level; 
    4751 
    4852    fbCmd.setVerbose( bVerbose ); 
     
    5256     
    5357    if ( !fbCmd.fire() ) { 
    54         printf( "cmd failed\n" ); 
     58        debugError( "cmd failed\n" ); 
     59    } 
     60 
     61    if ( bVerbose ) { 
     62        CoutSerializer se; 
     63        fbCmd.serialize( se ); 
     64    } 
     65     
     66    debugOutput(DEBUG_LEVEL_NORMAL, "Requesting mixer level state...\n"); 
     67     
     68    fbCmd.m_pFBProcessing->m_fbInputPlugNumber = 0x00; 
     69    fbCmd.m_pFBProcessing->m_inputAudioChannelNumber  = 0x00; 
     70    fbCmd.m_pFBProcessing->m_outputAudioChannelNumber = 0x00; 
     71    fbCmd.m_pFBProcessing->m_pEnhancedMixer->m_statusSelector 
     72        = FunctionBlockProcessingEnhancedMixer::eSS_Level; 
     73     
     74    if ( !fbCmd.fire() ) { 
     75        debugError( "cmd failed\n" ); 
     76    } 
     77 
     78    if ( bVerbose ) { 
     79        CoutSerializer se; 
     80        fbCmd.serialize( se ); 
     81    } 
     82 
     83    return true; 
     84
     85 
     86bool 
     87doApp2( Ieee1394Service& ieee1394service, int node_id, int fb_id ) 
     88
     89    FunctionBlockCmd fbCmd( ieee1394service, 
     90                            FunctionBlockCmd::eFBT_Selector, 
     91                            fb_id, 
     92                            FunctionBlockCmd::eCA_Current ); 
     93    fbCmd.setNodeId( node_id ); 
     94    fbCmd.setSubunitId( 0x00 ); 
     95    fbCmd.setCommandType( AVCCommand::eCT_Status ); 
     96    fbCmd.m_pFBSelector->m_inputFbPlugNumber=0; 
     97 
     98    debugOutput(DEBUG_LEVEL_NORMAL, "Requesting selector state...\n"); 
     99 
     100    fbCmd.setVerbose( bVerbose ); 
     101    if (bVerbose) { 
     102        ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE ); 
     103    } 
     104     
     105    if ( !fbCmd.fire() ) { 
     106        debugError( "cmd failed\n" ); 
     107    } 
     108 
     109    if ( bVerbose ) { 
     110        CoutSerializer se; 
     111        fbCmd.serialize( se ); 
     112    } 
     113 
     114    return true; 
     115
     116 
     117bool 
     118doApp3( Ieee1394Service& ieee1394service, int node_id, int fb_id , int val ) 
     119
     120    FunctionBlockCmd fbCmd( ieee1394service, 
     121                            FunctionBlockCmd::eFBT_Selector, 
     122                            fb_id, 
     123                            FunctionBlockCmd::eCA_Current ); 
     124    fbCmd.setNodeId( node_id ); 
     125    fbCmd.setSubunitId( 0x00 ); 
     126    fbCmd.setCommandType( AVCCommand::eCT_Control ); 
     127    fbCmd.m_pFBSelector->m_inputFbPlugNumber=val; 
     128 
     129    debugOutput(DEBUG_LEVEL_NORMAL, "Setting selector state to %d...\n", val); 
     130 
     131    fbCmd.setVerbose( bVerbose ); 
     132    if (bVerbose) { 
     133        ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE ); 
     134    } 
     135     
     136    if ( !fbCmd.fire() ) { 
     137        debugError( "cmd failed\n" ); 
    55138    } 
    56139 
     
    71154 
    72155    if (argc < 3) { 
    73         printf("usage: PORT NODE_ID FB_ID\n"); 
     156        debugError("usage: PORT NODE_ID FB_ID\n"); 
    74157        exit(0); 
    75158    } 
     
    82165 
    83166    if (errno) { 
    84         perror("argument parsing failed:"); 
     167        debugError("argument parsing failed: %s", strerror(errno)); 
    85168        return -1; 
    86169    } 
    87170    Ieee1394Service ieee1394service; 
    88171    if ( !ieee1394service.initialize( port ) ) { 
    89         fprintf( stderr, "could not set port on ieee1394service\n" ); 
     172        debugError( "could not set port on ieee1394service\n" ); 
    90173        return -1; 
    91174    } 
    92175 
    93176    doApp( ieee1394service, node_id, fb_id ); 
     177    doApp2( ieee1394service, node_id, fb_id ); 
     178//     doApp3( ieee1394service, node_id, fb_id , 0 ); 
     179//     sleep(1); 
     180//     doApp3( ieee1394service, node_id, fb_id , 1 ); 
     181//     sleep(1); 
     182//     doApp3( ieee1394service, node_id, fb_id , 0 ); 
    94183 
    95184    return 0;