Show
Ignore:
Timestamp:
04/09/07 04:25:12 (17 years ago)
Author:
ppalmers
Message:

- test-mixer volume control works (tested on phase88 only)
- volume control is exposed to the outside

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/tests/test-mixer.cpp

    r447 r455  
    8989 
    9090bool 
    91 doApp2( Ieee1394Service& ieee1394service, int node_id, int fb_id ) 
     91selectorGet( Ieee1394Service& ieee1394service, int node_id, int fb_id ) 
    9292{ 
    9393    FunctionBlockCmd fbCmd( ieee1394service, 
     
    120120 
    121121bool 
    122 doApp3( Ieee1394Service& ieee1394service, int node_id, int fb_id , int val ) 
     122selectorSet( Ieee1394Service& ieee1394service, int node_id, int fb_id , int val ) 
    123123{ 
    124124    FunctionBlockCmd fbCmd( ieee1394service, 
     
    132132 
    133133    debugOutput(DEBUG_LEVEL_NORMAL, "Setting selector state to %d...\n", val); 
     134 
     135    fbCmd.setVerbose( bVerbose ); 
     136    if (bVerbose) { 
     137        ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE ); 
     138    } 
     139     
     140    if ( !fbCmd.fire() ) { 
     141        debugError( "cmd failed\n" ); 
     142    } 
     143 
     144    if ( bVerbose ) { 
     145        CoutSerializer se; 
     146        fbCmd.serialize( se ); 
     147    } 
     148 
     149    return true; 
     150} 
     151 
     152bool 
     153volumeGet( Ieee1394Service& ieee1394service, int node_id, int fb_id, int channel ) 
     154{ 
     155    FunctionBlockCmd fbCmd( ieee1394service, 
     156                            FunctionBlockCmd::eFBT_Feature, 
     157                            fb_id, 
     158                            FunctionBlockCmd::eCA_Current ); 
     159    fbCmd.setNodeId( node_id ); 
     160    fbCmd.setSubunitId( 0x00 ); 
     161    fbCmd.setCommandType( AVCCommand::eCT_Status ); 
     162    fbCmd.m_pFBFeature->m_audioChannelNumber=channel; 
     163    fbCmd.m_pFBFeature->m_controlSelector=FunctionBlockFeature::eCSE_Feature_Volume; 
     164    fbCmd.m_pFBFeature->m_pVolume->m_volume=0; 
     165 
     166    debugOutput(DEBUG_LEVEL_NORMAL, "Requesting volume feature block state...\n"); 
     167 
     168    fbCmd.setVerbose( bVerbose ); 
     169    if (bVerbose) { 
     170        ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE ); 
     171    } 
     172     
     173    if ( !fbCmd.fire() ) { 
     174        debugError( "cmd failed\n" ); 
     175    } 
     176 
     177    if ( bVerbose ) { 
     178        CoutSerializer se; 
     179        fbCmd.serialize( se ); 
     180    } 
     181 
     182    return true; 
     183} 
     184 
     185bool 
     186volumeSet( Ieee1394Service& ieee1394service, int node_id, int fb_id, int channel, int value ) 
     187{ 
     188    FunctionBlockCmd fbCmd( ieee1394service, 
     189                            FunctionBlockCmd::eFBT_Feature, 
     190                            fb_id, 
     191                            FunctionBlockCmd::eCA_Current ); 
     192    fbCmd.setNodeId( node_id ); 
     193    fbCmd.setSubunitId( 0x00 ); 
     194    fbCmd.setCommandType( AVCCommand::eCT_Control ); 
     195    fbCmd.m_pFBFeature->m_audioChannelNumber=channel; 
     196    fbCmd.m_pFBFeature->m_controlSelector=FunctionBlockFeature::eCSE_Feature_Volume; 
     197    fbCmd.m_pFBFeature->m_pVolume->m_volume=value; 
     198 
     199    debugOutput(DEBUG_LEVEL_NORMAL, "Setting volume feature block channel %d state to %d...\n", channel, value); 
    134200 
    135201    fbCmd.setVerbose( bVerbose ); 
     
    157223{ 
    158224 
    159     if (argc < 3) { 
    160         debugError("usage: PORT NODE_ID FB_ID\n"); 
     225    if (argc < 4) { 
     226        debugError("usage: PORT NODE_ID CMD FB_ID [VAL1] [VAL2]\n"); 
    161227        exit(0); 
    162228    } 
     
    166232    int port = strtol( argv[1], &tail, 0 ); 
    167233    int node_id = strtol( argv[2], &tail, 0 ); 
    168     int fb_id   = strtol( argv[3], &tail, 0 ); 
    169  
     234    int cmd = strtol( argv[3], &tail, 0 ); 
     235    int fb_id   = strtol( argv[4], &tail, 0 ); 
     236     
     237    int value1=-1; 
     238    int value2=-1; 
     239     
     240    if (argc>=6) 
     241        value1 = strtol(argv[5], &tail, 0 ); 
     242         
     243    if (argc>=7) 
     244        value2 = strtol(argv[6], &tail, 0 ); 
     245     
    170246    if (errno) { 
    171247        debugError("argument parsing failed: %s", strerror(errno)); 
     
    178254    } 
    179255 
    180     doApp( ieee1394service, node_id, fb_id ); 
    181     doApp2( ieee1394service, node_id, fb_id ); 
    182      doApp3( ieee1394service, node_id, fb_id , 0 ); 
    183      sleep(1); 
    184      doApp3( ieee1394service, node_id, fb_id , 1 ); 
    185      sleep(1); 
    186      doApp3( ieee1394service, node_id, fb_id , 0 ); 
     256    switch(cmd) { 
     257    case 0: 
     258        doApp( ieee1394service, node_id, fb_id ); 
     259        break; 
     260    case 1: 
     261        selectorGet( ieee1394service, node_id, fb_id ); 
     262        break; 
     263    case 2: 
     264        selectorSet( ieee1394service, node_id, fb_id , value1 ); 
     265        break; 
     266    case 3: 
     267        volumeGet( ieee1394service, node_id, fb_id, value1); 
     268        break; 
     269    case 4: 
     270        volumeSet( ieee1394service, node_id, fb_id, value1, value2); 
     271        break; 
     272    } 
    187273 
    188274    return 0;