Changeset 1591

Show
Ignore:
Timestamp:
07/03/09 04:23:20 (14 years ago)
Author:
jwoithe
Message:

RME: implement writing to device settings flash block
RME: correctly initialise the entire settings structure to zero

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/rme/fireface_flash.cpp

    r1590 r1591  
    249249 
    250250    if (settings != NULL) { 
    251         memset(settings, 0, sizeof(settings)); 
     251        memset(settings, 0, sizeof(*settings)); 
    252252        // Copy hardware details to the software settings structure as 
    253253        // appropriate. 
     
    320320    // Write the given device settings to the device's configuration flash. 
    321321 
    322     // FIXME: fairly obviously the detail needs to be filled in here. 
    323     return 0; 
    324 
    325  
    326 
     322    FF_device_flash_settings_t hw_settings; 
     323    signed int i, err = 0; 
     324 
     325    if (settings == NULL) { 
     326        debugOutput(DEBUG_LEVEL_WARNING, "NULL settings parameter\n"); 
     327        return -1; 
     328    } 
     329 
     330    memset(&hw_settings, 0, sizeof(hw_settings)); 
     331 
     332    // Copy software settings to the hardware structure as appropriate. 
     333    for (i=0; i<4; i++) 
     334        hw_settings.mic_phantom[i] = settings->mic_phantom[i]; 
     335    hw_settings.spdif_input_mode = settings->spdif_input_mode; 
     336    hw_settings.spdif_output_emphasis = settings->spdif_output_emphasis; 
     337    hw_settings.spdif_output_pro = settings->spdif_output_pro; 
     338    hw_settings.spdif_output_nonaudio = settings->spdif_output_nonaudio; 
     339    hw_settings.spdif_output_mode = settings->spdif_output_mode; 
     340    hw_settings.clock_mode = settings->clock_mode; 
     341    hw_settings.sync_ref = settings->sync_ref; 
     342    hw_settings.tms = settings->tms; 
     343    hw_settings.limit_bandwidth = settings->limit_bandwidth; 
     344    hw_settings.stop_on_dropout = settings->stop_on_dropout; 
     345    hw_settings.input_level = settings->input_level; 
     346    hw_settings.output_level = settings->output_level; 
     347    hw_settings.filter = settings->filter; 
     348    hw_settings.fuzz = settings->fuzz; 
     349    if (m_rme_model==RME_MODEL_FIREFACE800 && settings->limiter_disable==1 &&  
     350            settings->input_opt[0]==FF_SWPARAM_FF800_INPUT_OPT_FRONT) 
     351        hw_settings.p12db_an[0] = 1; 
     352    else 
     353        hw_settings.p12db_an[0] = 0; 
     354    hw_settings.sample_rate = settings->sample_rate; 
     355    hw_settings.word_clock_single_speed = settings->word_clock_single_speed; 
     356 
     357    // The FF800 has front/rear selectors for the "instrument" input  
     358    // (aka channel 1) and the two "mic" channels (aka channels 7 and 8). 
     359    // The FF400 does not.  The FF400 borrows the mic0 selector field  
     360    // in the flash configuration structure to use for the "phones" 
     361    // level which the FF800 doesn't have. 
     362    // The offset of 1 here is to maintain consistency with the values 
     363    // used in the flash by other operating systems.  See related section of 
     364    // read_device_flash_settings(). 
     365    if (m_rme_model == RME_MODEL_FIREFACE400) 
     366        hw_settings.mic_plug_select[0] = settings->phones_level - 1; 
     367    else { 
     368        hw_settings.instrument_plug_select = settings->input_opt[0] - 1; 
     369        hw_settings.mic_plug_select[0] = settings->input_opt[1] - 1; 
     370        hw_settings.mic_plug_select[1] = settings->input_opt[2] - 1; 
     371    } 
     372 
     373    // The configuration flash block must be erased before we can write to it 
     374    err = erase_flash(RME_FF_FLASH_ERASE_SETTINGS) != 0; 
     375    if (err != 0) 
     376        debugOutput(DEBUG_LEVEL_WARNING, "Error erasing settings flash block: %d\n", i); 
     377    else { 
     378        err = write_flash(m_rme_model==RME_MODEL_FIREFACE800? 
     379                  RME_FF800_FLASH_SETTINGS_ADDR:RME_FF400_FLASH_SETTINGS_ADDR, 
     380                  (quadlet_t *)&hw_settings, sizeof(hw_settings)/sizeof(uint32_t)); 
     381 
     382        if (err != 0) 
     383            debugOutput(DEBUG_LEVEL_WARNING, "Error writing device flash settings: %d\n", i); 
     384    } 
     385 
     386    return err!=0?-1:0; 
     387
     388 
     389