Changeset 1697 for trunk

Show
Ignore:
Timestamp:
10/19/09 05:37:15 (14 years ago)
Author:
jwoithe
Message:

RME:
* implement stub functions for more device initialisation processes
* continued work towards convincing the interface to start streaming

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/rme/fireface_def.h

    r1696 r1697  
    3232#define _FIREFACE_DEF 
    3333 
     34/* The maximum number of channels supported by each device */ 
     35#define RME_FF400_MAX_CHANNELS  18 
     36#define RME_FF800_MAX_CHANNELS  28 
     37 
    3438/* Boundaries between the speed multipliers */ 
    3539#define MIN_SPEED               30000 
     
    8387#define RME_FF_STATUS_REG0           0x801c0000    // Read only 
    8488#define RME_FF_STATUS_REG1           0x801c0004    // Read only 
    85  
    86 #define RME_FF_TCO_READ_REG          0x801f0000 
    87 #define RME_FF_TCO_WRITE_REG         0x810f0020 
     89#define RME_FF_STATUS_REG2           0x801c0008 
     90#define RME_FF_STATUS_REG3           0x801c001c 
     91#define RME_FF_OUTPUT_REC_MASK       0x801c0080    // Write only 
     92 
     93#define RME_FF_MIXER_RAM             0x80080000 
     94 
     95#define RME_FF_TCO_READ_REG          0x801f0000    // FF800 only 
     96#define RME_FF_TCO_WRITE_REG         0x810f0020    // FF800 only 
    8897 
    8998#define RME_FF400_GAIN_REG           0x801c0180 
    9099 
    91100#define RME_FF400_MIDI_HIGH_ADDR     0x801003f4 
     101 
     102/* Types of controls in the matrix mixer */ 
     103#define RME_FF_MM_INPUT              0x0000 
     104#define RME_FF_MM_PLAYBACK           0x0001 
     105#define RME_FF_MM_OUTPUT             0x0002 
    92106 
    93107/* Addresses of various blocks in memory-mapped flash */ 
  • trunk/libffado/src/rme/fireface_hw.cpp

    r1696 r1697  
    2424/* This file implements miscellaneous lower-level hardware functions for the Fireface */ 
    2525 
     26#include <math.h> 
     27 
    2628#include "libieee1394/configrom.h" 
    2729#include "libieee1394/ieee1394service.h" 
     
    5860{ 
    5961    signed int ret = 0; 
     62    signed int src, dest; 
     63    signed int n_channels = (m_rme_model==RME_MODEL_FIREFACE400)? 
     64                   RME_FF400_MAX_CHANNELS:RME_FF800_MAX_CHANNELS; 
    6065 
    6166    // Initialises the device's settings structure to a known state and then 
     
    7984        settings->limit_bandwidth = FF_SWPARAM_BWLIMIT_SEND_ALL_CHANNELS; 
    8085 
    81         // Set amplifier gains 
     86        // A default sampling rate.  An explicit DDS frequency is not enabled 
     87        // by default. 
     88        dev_config->software_freq = 44100; 
     89        dev_config->dds_freq = 0; 
     90 
     91        // TODO: set input amplifier gains to a value other than 0? 
     92 
     93        // TODO: store and set matrix mixer values 
     94        // TODO: store and manipulate channel mute/rec flags 
     95 
     96        // Configure the hardware to match the current software status.  
     97        // This is only done if the settings valid flag is 0; if it is 1 it 
     98        // indicates that something has already set the device up to match 
     99        // the software settings so there's no need to do it again. 
     100 
     101        if (set_hardware_params(settings) != 0) 
     102            ret = -1; 
     103 
     104        if (ret==0 && m_rme_model==RME_MODEL_FIREFACE400) { 
     105            unsigned int node_id = getConfigRom().getNodeId(); 
     106            unsigned int midi_hi_addr; 
     107            // For now we'll fix this since that's what's done under other 
     108            // systems. 
     109            midi_hi_addr = 0x01; 
     110            if (writeRegister(RME_FF400_MIDI_HIGH_ADDR, (node_id<<16) | midi_hi_addr) != 0) 
     111                ret = -1; 
     112        } 
     113 
     114        if (ret==0) { 
     115            signed freq = dev_config->software_freq; 
     116            if (dev_config->dds_freq > 0) 
     117                freq = dev_config->dds_freq; 
     118            if (set_hardware_dds_freq(freq) != 0) 
     119                ret = -1; 
     120        } 
     121 
    82122        if (m_rme_model == RME_MODEL_FIREFACE400) { 
    83123            signed int i; 
    84             for (i=0; i<FF400_AMPGAIN_NUM; i++) { 
     124            for (i=FF400_AMPGAIN_MIC1; i<=FF400_AMPGAIN_INPUT4; i++) { 
    85125                set_hardware_ampgain(i, settings->amp_gains[i]); 
    86126            } 
    87127        } 
    88128 
     129        // Matrix mixer settings 
     130        for (dest=0; dest<n_channels; dest++) { 
     131            for (src=0; src<n_channels; src++) { 
     132                set_hardware_mixergain(RME_FF_MM_INPUT, src, dest, 0); 
     133            } 
     134            for (src=0; src<n_channels; src++) { 
     135                set_hardware_mixergain(RME_FF_MM_PLAYBACK, src, dest, 0); 
     136            } 
     137        } 
     138        for (src=0; src<n_channels; src++) { 
     139            set_hardware_mixergain(RME_FF_MM_OUTPUT, src, 0, 0); 
     140        } 
     141 
     142        set_hardware_output_rec(0); 
     143 
    89144        dev_config->settings_valid = 1; 
    90145    } 
    91146 
    92     // A default sampling rate.  An explicit DDS frequency is not enabled 
    93     // by default. 
    94     dev_config->software_freq = 44100; 
    95     dev_config->dds_freq = 0; 
    96  
    97     if (set_hardware_params(settings) != 0) 
    98         ret = -1; 
    99147 
    100148    // Also configure the TCO (Time Code Option) settings for those devices 
     
    106154        } 
    107155        dev_config->tco_settings_valid = 1; 
    108     } 
    109  
    110     if (ret==0 && m_rme_model==RME_MODEL_FIREFACE400) { 
    111         unsigned int node_id = getConfigRom().getNodeId(); 
    112         unsigned int midi_hi_addr; 
    113         // For now we'll fix this since that's what's done under other 
    114         // systems. 
    115         midi_hi_addr = 0x01; 
    116         if (writeRegister(RME_FF400_MIDI_HIGH_ADDR, (node_id<<16) | midi_hi_addr) != 0) 
    117             ret = -1; 
    118     } 
    119  
    120     if (ret==0) { 
    121         signed freq = dev_config->software_freq; 
    122         if (dev_config->dds_freq > 0) 
    123             freq = dev_config->dds_freq; 
    124         if (set_hardware_dds_freq(freq) != 0) 
    125             ret = -1; 
    126156    } 
    127157 
     
    730760            dev_config->is_streaming = 1; 
    731761        } 
     762 
     763        set_hardware_channel_mute(0); 
     764 
    732765    } else 
    733766        ret = -1; 
     
    758791            dev_config->is_streaming = 0; 
    759792        } 
     793 
     794        set_hardware_channel_mute(1); 
     795 
    760796    } else 
    761797        ret = -1; 
     
    767803signed int 
    768804Device::set_hardware_ampgain(unsigned int index, signed int val) { 
     805// "index" indicates the hardware amplifier gain to set.  Values of 0-3 
     806// correspond to input amplifier gains.  Values from 4 on relate to output 
     807// volume. 
     808// 
    769809// "val" is in dB except for inputs 3/4 where it's in units of 0.5 dB. This 
    770810// function is responsible for converting to/from the scale used by the 
    771811// device. 
     812// 
     813// Only the FF400 has the hardware gain register which is controlled by this 
     814// function. 
    772815    quadlet_t regval = 0; 
    773816    signed int devval = 0; 
     817    if (val > 120) 
     818      val = 120; 
     819    if (val < -120) 
     820      val = -120; 
    774821    if (index <= FF400_AMPGAIN_MIC2) { 
    775822        if (val >= 10) 
     
    790837} 
    791838 
    792 
     839signed int 
     840Device::set_hardware_mixergain(unsigned int ctype, unsigned int src_channel,  
     841  unsigned int dest_channel, signed int val) { 
     842// Set the value of a matrix mixer control.  ctype is one of the RME_FF_MM_* 
     843// defines: 
     844//   RME_FF_MM_INPUT: source is a physical input 
     845//   RME_FF_MM_PLAYBACK: source is playback from PC 
     846//   RME_FF_MM_OUTPUT: source is the physical output whose gain is to be  
     847//     changed, destination is ignored 
     848// Val is the integer value sent to the device.  The amount of gain (in dB) 
     849// applied can be calculated using 
     850//   dB = 20.log10(val/32768) 
     851// The maximum value of val is 0x10000, corresponding to +6dB of gain. 
     852// The minimum is 0x00000 corresponding to mute. 
     853 
     854    unsigned int n_channels; 
     855    signed int ram_output_block_size; 
     856    unsigned int ram_addr; 
     857 
     858    n_channels = (m_rme_model==RME_MODEL_FIREFACE400)? 
     859        RME_FF400_MAX_CHANNELS:RME_FF800_MAX_CHANNELS; 
     860    if (src_channel>n_channels || dest_channel>n_channels) 
     861        return -1; 
     862    if (val<0 || val>0x10000) 
     863        return -1; 
     864 
     865    if (m_rme_model == RME_MODEL_FIREFACE400) { 
     866        ram_output_block_size = 0x48; 
     867    } else { 
     868        ram_output_block_size = 0x80; 
     869    } 
     870 
     871    ram_addr = RME_FF_MIXER_RAM; 
     872    switch (ctype) { 
     873        case RME_FF_MM_INPUT: 
     874        case RME_FF_MM_PLAYBACK: 
     875            ram_addr += (dest_channel*2*ram_output_block_size) + 4*src_channel; 
     876            if (ctype == RME_FF_MM_PLAYBACK) 
     877                 ram_addr += ram_output_block_size; 
     878            break; 
     879        case RME_FF_MM_OUTPUT: 
     880            ram_addr += 0x0f80 + 4*src_channel; 
     881            break; 
     882    } 
     883    writeRegister(ram_addr, val); 
     884 
     885    // If setting the output volume and the device is the FF400, keep 
     886    // the separate gain register in sync. 
     887    if (ctype==RME_FF_MM_OUTPUT && m_rme_model==RME_MODEL_FIREFACE400) { 
     888        signed int dB; 
     889        if (val==0) 
     890            dB = -90; 
     891        else 
     892            dB = roundl(20.0*log10(val/32768.0)); 
     893        set_hardware_ampgain(FF400_AMPGAIN_OUTPUT1+src_channel, dB); 
     894    } 
     895 
     896    return 0; 
     897
     898 
     899signed int 
     900Device::set_hardware_channel_mute(signed int mute) { 
     901// Explicitly mute (mute!=0) or unmute (mute=0) all channels. 
     902// TODO: fill the details in to allow individual channels to be muted as  
     903// required. 
     904    quadlet_t buf[28]; 
     905    signed int i; 
     906 
     907    for (i=0; i<28; i++) 
     908        buf[i] = (mute!=0); 
     909 
     910    // Write 28 quadlets even for FF400 
     911    return writeBlock(RME_FF_CHANNEL_MUTE_MASK, buf, 28); 
     912
     913 
     914signed int 
     915Device::set_hardware_output_rec(signed int rec) { 
     916// Explicitly record (mute!=1) outputs, or not. 
     917// TODO: fill the details in to allow individual outputs to be recorded as  
     918// required. 
     919    quadlet_t buf[28]; 
     920    signed int i; 
     921 
     922    for (i=0; i<28; i++) 
     923        buf[i] = (rec!=0); 
     924 
     925    // Write 28 quadlets even for FF400 
     926    return writeBlock(RME_FF_OUTPUT_REC_MASK, buf, 28); 
     927
     928 
     929
  • trunk/libffado/src/rme/rme_avdevice.cpp

    r1690 r1697  
    767767        debugError("Error doing RME write to register 0x%06x\n",reg); 
    768768    } 
     769 
     770printf("writeRegister: %016llx = %08x\n", reg, data); 
    769771    return (err==0)?0:-1; 
    770772} 
     
    788790          n_quads, reg); 
    789791    } 
     792 
     793printf("writeBlock: %016llx, size=%d (%d)\n", reg, n_quads, n_quads*4); 
    790794    return (err==0)?0:-1; 
    791795} 
  • trunk/libffado/src/rme/rme_avdevice.h

    r1684 r1697  
    177177 
    178178    signed int set_hardware_ampgain(unsigned int index, signed int val); 
     179    signed int set_hardware_mixergain(unsigned int ctype,  
     180        unsigned int src_channel, unsigned int dest_channel, signed int val); 
     181 
     182    signed int set_hardware_channel_mute(signed int mute); 
     183    signed int set_hardware_output_rec(signed int rec); 
    179184 
    180185    Control::Container *m_MixerContainer;