Changeset 1726

Show
Ignore:
Timestamp:
11/22/09 13:42:57 (14 years ago)
Author:
arnonym
Message:

Access more switches of the pro24. Dim and Mute work, Mono-monitoring somehow doesn't (yet).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/dice/focusrite/saffire_pro24.cpp

    r1719 r1726  
    3030const int msgSet = 0x68; 
    3131 
     32SaffirePro24::Switch::Switch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue ) 
     33    : Control::Boolean(eap, name) 
     34    , m_eap(eap) 
     35    , m_selected(0) 
     36    , m_offset(offset) 
     37    , m_activevalue(activevalue) 
     38{ 
     39    m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp); 
     40    printf("%s: Active?%i\n", name.c_str(), m_state_tmp&m_activevalue); 
     41    debugOutput(DEBUG_LEVEL_VERBOSE, "Probably the initialization is the other way round.\n"); 
     42    m_selected = (m_state_tmp&m_activevalue)?true:false; 
     43} 
     44 
     45bool SaffirePro24::Switch::selected() { 
     46    return m_selected; 
     47} 
     48 
     49bool SaffirePro24::Switch::select(bool n) { 
     50    if ( n != m_selected ) { 
     51        m_selected = n; 
     52        m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp); 
     53        m_eap->writeReg(Dice::Device::EAP::eRT_Application, m_offset, m_state_tmp^m_activevalue); 
     54        int msg = 0; 
     55        if (m_offset<0x14) msg = 2; 
     56        if (m_offset<0x3C && m_offset>=0x14) msg = 1; 
     57        if (m_offset<0x40 && m_offset>=0x3C) msg = 3; 
     58        if (m_offset<0x60 && m_offset>=0x58) msg = 4; 
     59        debugOutput(DEBUG_LEVEL_VERBOSE, "Switch will write the msg %i.\n", msg); 
     60        m_eap->writeReg(Dice::Device::EAP::eRT_Application, msgSet, msg); 
     61    } 
     62    return true; 
     63} 
     64 
     65class SaffirePro24::LineInstSwitch : public Switch 
     66{ 
     67public: 
     68    LineInstSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue) 
     69        : Switch(eap, name, offset, activevalue) {} 
     70    std::string getBooleanLabel(bool n) { 
     71        if ( n ) return "Instrument"; 
     72        return "Line"; 
     73    } 
     74}; 
     75class SaffirePro24::LevelSwitch : public Switch 
     76{ 
     77public: 
     78    LevelSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue) 
     79        : Switch(eap, name, offset, activevalue) {} 
     80    std::string getBooleanLabel(bool n) { 
     81        if ( n ) return "High"; 
     82        return "Low"; 
     83    } 
     84}; 
     85 
    3286SaffirePro24::SaffirePro24( DeviceManager& d, 
    3387                            std::auto_ptr<ConfigRom>( configRom )) 
     
    4296SaffirePro24::~SaffirePro24() 
    4397{ 
     98    //debugOutput(DEBUG_LEVEL_VERBOSE, "Deleting the saffirePro24\n"); 
     99    /// I wonder whether we should really save only on clean exits or also each time a setting is 
     100    //  changed. Or should we provide a function (and thus gui-button) to save the state of the 
     101    //  device? 
     102    getEAP()->storeFlashConfig(); 
    44103    getEAP()->deleteElement(m_ch1); 
    45104    getEAP()->deleteElement(m_ch2); 
     
    51110    if (Dice::Device::discover()) { 
    52111        fb_quadlet_t* tmp = (fb_quadlet_t *)calloc(2, sizeof(fb_quadlet_t)); 
    53         getEAP()->readRegBlock(Dice::Device::EAP::eRT_Application, 0x58, tmp, 2*sizeof(fb_quadlet_t)); 
    54         hexDumpQuadlets(tmp, 2); 
     112        getEAP()->readRegBlock(Dice::Device::EAP::eRT_Application, 0x00, tmp, 1*sizeof(fb_quadlet_t)); 
     113        //hexDumpQuadlets(tmp, 2); // DEBUG 
     114        if (tmp[0] != 0x00010004 ) { 
     115            debugError("This is a Focusrite Saffire Pro24 but not the right firmware. Better stop here before something goes wrong.\n"); 
     116            debugError("This device has firmware 0x%x while we only know about version 0x%x.\n", tmp[0], 0x10004); 
     117            return false; 
     118        } 
     119        //getEAP()->readRegBlock(Dice::Device::EAP::eRT_Command, 0x00, tmp, 2*sizeof(fb_quadlet_t)); // DEBUG 
     120        //hexDumpQuadlets(tmp, 2); // DEBUG 
    55121 
    56         m_ch1 = new LineInstSwitch(getEAP(), "LineInstCh1", 0x58, 2); 
     122        m_ch1 = new LineInstSwitch(getEAP(), "Ch1LineInst", 0x58, 2); 
    57123        getEAP()->addElement(m_ch1); 
    58         m_ch2 = new LineInstSwitch(getEAP(), "LineInstCh2", 0x58, 2<<16); 
     124        m_ch2 = new LineInstSwitch(getEAP(), "Ch2LineInst", 0x58, 2<<16); 
    59125        getEAP()->addElement(m_ch2); 
    60         m_ch3 = new LevelSwitch(getEAP(), "LevelCh3", 0x5C, 1); 
     126        m_ch3 = new LevelSwitch(getEAP(), "Ch3Level", 0x5C, 1); 
    61127        getEAP()->addElement(m_ch3); 
    62         m_ch4 = new LevelSwitch(getEAP(), "LevelCh4", 0x5C, 1<<16); 
     128        m_ch4 = new LevelSwitch(getEAP(), "Ch4Level", 0x5C, 1<<16); 
    63129        getEAP()->addElement(m_ch4); 
     130 
     131        m_monitor = new MonitorSection(getEAP(), "Monitoring"); 
     132        getEAP()->addElement(m_monitor); 
    64133        return true; 
    65134    } 
     
    83152} 
    84153 
    85 SaffirePro24::LineInstSwitch::LineInstSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue ) 
    86     : Control::Enum(eap, name) 
     154 
     155SaffirePro24::MonitorSection::MonitorSection(Dice::Device::EAP* eap, std::string name) 
     156    : Control::Container(eap, name) 
    87157    , m_eap(eap) 
    88     , m_selected(0) 
    89     , m_offset(offset) 
    90     , m_activevalue(activevalue) 
    91158{ 
    92     m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp); 
    93     printf("%s: Active?%i\n", name.c_str(), m_state_tmp&m_activevalue); 
    94     m_selected = (m_state_tmp&m_activevalue)?1:0
    95 
    96  
    97 int SaffirePro24::LineInstSwitch::selected() { 
    98     return m_selected
    99 
    100  
    101 bool SaffirePro24::LineInstSwitch::select(int n) { 
    102     if ( n != m_selected ) { 
    103         m_selected = n
    104         m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp); 
    105         m_eap->writeReg(Dice::Device::EAP::eRT_Application, m_offset, m_state_tmp^m_activevalue); 
    106         m_eap->writeReg(Dice::Device::EAP::eRT_Application, msgSet, 4); 
     159    m_mute = new Switch(m_eap, "Mute", 0x0C, 1); 
     160    addElement(m_mute); 
     161    m_dim = new Switch(m_eap, "Dim", 0x10, 1)
     162    addElement(m_dim); 
     163    for (int i=0; i<10; ++i) { 
     164        std::stringstream stream; 
     165        stream << "MuteAffectsCh" << i
     166        Switch* s = new Switch(m_eap, stream.str(), 0x3C, 1<<i); 
     167        addElement(s); 
     168        m_mute_affected.push_back(s); 
     169        stream.str(std::string()); 
     170        stream << "DimAffectsCh" << i
     171        s = new Switch(m_eap, stream.str(), 0x3C, 1<<(10+i)); 
     172        addElement(s); 
     173        m_dim_affected.push_back(s); 
    107174    } 
    108     return true; 
    109 
    110 std::string SaffirePro24::LineInstSwitch::getEnumLabel(int n) { 
    111     if ( n == 1 ) { 
    112         return "Instrument"; 
    113     } 
    114     return "Line"; 
    115 
    116  
    117 SaffirePro24::LevelSwitch::LevelSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue) 
    118     : LineInstSwitch(eap, name, offset, activevalue) 
    119 
    120 
    121 std::string SaffirePro24::LevelSwitch::getEnumLabel(int n) { 
    122     switch (n) { 
    123         case 0: 
    124             return "Low"; 
    125         case 1: 
    126             return "High"; 
    127         default: 
    128             return ""; 
     175    for (int i=0; i<5; ++i) { 
     176        std::stringstream stream; 
     177        stream << "Mono_" << i*2 << "_" << i*2+1; 
     178        Switch* s = new Switch(m_eap, stream.str(), 0x3C, 1<<(20+i)); 
     179        addElement(s); 
     180        m_mono.push_back(s); 
    129181    } 
    130182} 
    131  
    132183 
    133184} 
  • trunk/libffado/src/dice/focusrite/saffire_pro24.h

    r1718 r1726  
    4747    std::string getNickName(); 
    4848 
    49     class LineInstSwitch : public Control::Enum 
     49    /** 
     50     * @brief A standard-switch for boolean. 
     51     * 
     52     * If you don't like True and False for the labels, subclass and return your own. 
     53    */ 
     54    class Switch : public Control::Boolean 
    5055    { 
    5156    protected: 
    5257        friend class Dice::Focusrite::SaffirePro24; 
    5358 
    54         LineInstSwitch(Dice::Device::EAP*, std::string name, size_t offset, int activevalue); 
     59        Switch(Dice::Device::EAP*, std::string name, size_t offset, int activevalue); 
    5560    public: 
    56         int count() { return 2; } 
    57  
    58         int selected(); 
    59         bool select(int); 
    60  
    61         std::string getEnumLabel(int); 
    62  
     61        bool selected(); 
     62        bool select(bool); 
    6363    private: 
    6464        Dice::Device::EAP* m_eap; 
    65         int m_selected; 
     65        bool m_selected; 
    6666        size_t m_offset; 
    6767        int m_activevalue; 
    6868        fb_quadlet_t m_state_tmp; 
    6969    }; 
    70     class LevelSwitch : public LineInstSwitch 
     70 
     71    class MonitorSection : public Control::Container 
    7172    { 
    7273    protected: 
    7374        friend class Dice::Focusrite::SaffirePro24; 
    7475 
    75         LevelSwitch(Dice::Device::EAP*, std::string name, size_t offset, int activevalue); 
    76     public: 
    77         std::string getEnumLabel(int); 
     76        MonitorSection(Dice::Device::EAP*, std::string name); 
     77    private: 
     78        Dice::Device::EAP* m_eap; 
     79        Switch *m_mute, *m_dim; 
     80        std::vector<Switch*> m_mute_affected; 
     81        std::vector<Switch*> m_dim_affected; 
     82        std::vector<Switch*> m_mono; 
    7883    }; 
    7984private: 
     85    class LineInstSwitch; 
    8086    LineInstSwitch *m_ch1, *m_ch2; 
     87    class LevelSwitch; 
    8188    LevelSwitch *m_ch3, *m_ch4; 
     89    MonitorSection *m_monitor; 
    8290}; 
    8391