short int getVolume( Ieee1394Service& ieee1394service, int node_id, int ffb_id, FunctionBlockCmd::EControlAttribute control_attrib ) { FunctionBlockCmd fbCmd( ieee1394service, FunctionBlockCmd::eFBT_Feature, ffb_id, control_attrib ); fbCmd.setNodeId( node_id ); fbCmd.setSubunitId( 0x00 ); fbCmd.setCommandType( AVCCommand::eCT_Status ); fbCmd.m_pFBFeature->m_audioChannelNumber = 0; fbCmd.m_pFBFeature->m_controlSelector=FunctionBlockFeature::eCSE_Feature_Volume; fbCmd.m_pFBFeature->m_pVolume->m_volume = 0; fbCmd.setVerbose( bVerbose ); if (bVerbose) { ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERBOSE ); } if ( !fbCmd.fire() ) { printf( "cmd failed\n" ); } if ( bVerbose ) { CoutSerializer se; fbCmd.serialize( se ); } return fbCmd.m_pFBFeature->m_pVolume->m_volume; }
bool setVolume( Ieee1394Service& ieee1394service, int node_id, int ffb_id, int vol ) { FunctionBlockCmd fbCmd( ieee1394service, FunctionBlockCmd::eFBT_Feature, ffb_id, FunctionBlockCmd::eCA_Current ); fbCmd.setNodeId( node_id ); fbCmd.setSubunitId( 0x00 ); fbCmd.setCommandType( AVCCommand::eCT_Control ); fbCmd.m_pFBFeature->m_audioChannelNumber = 0; fbCmd.m_pFBFeature->m_controlSelector=FunctionBlockFeature::eCSE_Feature_Volume; fbCmd.m_pFBFeature->m_pVolume->m_volume = vol; fbCmd.setVerbose( bVerbose ); if (bVerbose) { ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERBOSE ); } bool bStatus = fbCmd.fire(); if ( !bStatus ) { printf( "cmd failed\n" ); } if ( bVerbose ) { CoutSerializer se; fbCmd.serialize( se ); } return bStatus; }
void printDeviceList() { Ieee1394Service service; // switch off all messages since they mess up the list service.setVerboseLevel(0); if ( !service.initialize( args->port ) ) { cerr << "Could not initialize IEEE 1394 service" << endl; exit(-1); } cout << "Node id GUID Vendor - Model" << endl; for (int i = 0; i < service.getNodeCount(); i++) { ConfigRom crom(service, i); if (!crom.initialize()) break; cout << i << " " << " 0x" << crom.getGuidString() << " '" << crom.getVendorName() << "' - '" << crom.getModelName() << "'" << endl; } }
int main( int argc, char** argv ) { printf("-----------------------------------------------\n"); printf("BridgeCo BeBoB platform firmware downloader\n"); printf("Part of the FFADO project -- www.ffado.org\n"); printf("Version: %s\n", PACKAGE_VERSION); printf("(C) 2008, Daniel Wagner, Pieter Palmers\n"); printf("This program comes with ABSOLUTELY NO WARRANTY.\n"); printf("-----------------------------------------------\n\n"); // arg parsing argp_parse (argp, argc, argv, 0, 0, args); if (args->nargs < 2) { printDeviceList(); exit(0); } errno = 0; char* tail; int node_id = -1; fb_octlet_t guid = strtoll(args->args[0], &tail, 0); if (errno) { perror("argument parsing failed:"); return -1; } if(args->magic != MAGIC_THAT_SAYS_I_KNOW_WHAT_IM_DOING) { printf("Magic number not correct. Please specify the correct magic using the '-m' option.\n"); printf("Manipulating firmware can cause your device to magically stop working (a.k.a. 'bricking').\n"); printf("Specifying the magic number indicates that you accept the risks involved\n"); printf("with using this tool. The magic number can be found in the source code.\n\n"); return -1; } else { printf("YOU HAVE SPECIFIED THE CORRECT MAGIC NUMBER.\n"); printf("HENCE YOU ACCEPT THE RISKS INVOLVED.\n"); } Ieee1394Service service; if ( !service.initialize( args->port ) ) { cerr << "Could not initialize IEEE 1394 service" << endl; return -1; } service.setVerboseLevel( args->verbose ); for (int i = 0; i < service.getNodeCount(); i++) { ConfigRom configRom(service, i); configRom.initialize(); if (configRom.getGuid() == guid) node_id = configRom.getNodeId(); } if (node_id < 0) { cerr << "Could not find device with matching GUID" << endl; return -1; } service.setVerboseLevel( args->verbose ); BeBoB::BootloaderManager blMgr( service, node_id ); if ( args->force == 1 ) { blMgr.setForceOperations( true ); } blMgr.getConfigRom()->printConfigRom(); blMgr.printInfoRegisters(); if ( strcmp( args->args[1], "setguid" ) == 0 ) { if (!args->args[2] ) { cerr << "guid argument is missing" << endl; return -1; } char* tail; fb_octlet_t guid = strtoll(args->args[2], &tail, 0 ); if ( !blMgr.programGUID( guid ) ) { cerr << "Failed to set GUID" << endl; return -1; } else { cout << "new GUID programmed" << endl; } } else if ( strcmp( args->args[1], "firmware" ) == 0 ) { if (!args->args[2] ) { cerr << "FILE argument is missing" << endl; return -1; } std::string str( args->args[2] ); blMgr.setStartBootloader( args->no_bootloader_restart != 1 ); if ( !blMgr.downloadFirmware( str ) ) { cerr << "Failed to download firmware" << endl; return -1; } else { cout << "Firmware download was successful" << endl; cout << "Please reboot the device by removing the power and firewire connections." << endl; } } else if ( strcmp( args->args[1], "cne" ) == 0 ) { if (!args->args[2] ) { cerr << "FILE argument is missing" << endl; return -1; } std::string str( args->args[2] ); if ( !blMgr.downloadCnE( str ) ) { cerr << "Failed to download CnE" << endl; return -1; } else { cout << "CnE download was successful" << endl; cout << "Please reboot the device by removing the power and firewire connections." << endl; } } else if ( strcmp( args->args[1], "display" ) == 0 ) { // nothing to do } else if ( strcmp( args->args[1], "bcd" ) == 0 ) { if ( !args->args[2] ) { cerr << "FILE arguments is missing" << endl; return -1; } BeBoB::BCD* bcd = new BeBoB::BCD::BCD( args->args[2] ); if ( !bcd ) { cerr << "Could no open file " << args->args[2] << endl; return -1; } if ( !bcd->parse() ) { cerr << "Could not parse file " << args->args[2] << endl; return -1; } bcd->displayInfo(); delete bcd; } else { cout << "Unknown operation" << endl; } return 0; }