Show
Ignore:
Timestamp:
11/18/09 12:53:43 (14 years ago)
Author:
arnonym
Message:

Switching line/inst on channels 1+2 and low/high in channels 3+4 works now with the dbus-interface. Mixer is coming soon.

Gotta ask back whether I am allowed to add the full description of the application-space here for all to see.

Files:

Legend:

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

    r1712 r1718  
    2828namespace Focusrite { 
    2929 
     30const int msgSet = 0x68; 
     31 
    3032SaffirePro24::SaffirePro24( DeviceManager& d, 
    3133                                        std::auto_ptr<ConfigRom>( configRom )) 
    32     : Dice::Device( d , configRom) 
     34    : Dice::Device(d , configRom) 
     35    , m_ch1(NULL) 
     36    , m_ch2(NULL) 
    3337{ 
    34     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Dice::Focusrite::SaffirePro24 (NodeID %d)\n", 
    35                 getConfigRom().getNodeId() ); 
     38    debugOutput(DEBUG_LEVEL_VERBOSE, "Created Dice::Focusrite::SaffirePro24 (NodeID %d)\n", 
     39                getConfigRom().getNodeId()); 
    3640} 
    3741 
    3842SaffirePro24::~SaffirePro24() 
    3943{ 
     44    m_eap->deleteElement(m_ch1); 
     45    m_eap->deleteElement(m_ch2); 
     46    if (m_ch1) delete m_ch1; 
     47    if (m_ch2) delete m_ch2; 
    4048} 
     49bool SaffirePro24::discover() { 
     50    if (Dice::Device::discover()) { 
     51        fb_quadlet_t* tmp = (fb_quadlet_t *)calloc(2, sizeof(fb_quadlet_t)); 
     52        m_eap->readRegBlock(Dice::Device::EAP::eRT_Application, 0x58, tmp, 2*sizeof(fb_quadlet_t)); 
     53        hexDumpQuadlets(tmp, 2); 
    4154 
    42 void 
    43 SaffirePro24::showDevice() 
     55        m_ch1 = new LineInstSwitch(getEAP(), "LineInstCh1", 0x58, 2); 
     56        getEAP()->addElement(m_ch1); 
     57        m_ch2 = new LineInstSwitch(getEAP(), "LineInstCh2", 0x58, 2<<16); 
     58        getEAP()->addElement(m_ch2); 
     59        m_ch3 = new LevelSwitch(getEAP(), "LevelCh3", 0x5C, 1); 
     60        getEAP()->addElement(m_ch3); 
     61        m_ch4 = new LevelSwitch(getEAP(), "LevelCh4", 0x5C, 1<<16); 
     62        getEAP()->addElement(m_ch4); 
     63        return true; 
     64    } 
     65    return false; 
     66
     67void SaffirePro24::showDevice() 
    4468{ 
    4569    debugOutput(DEBUG_LEVEL_VERBOSE, "This is a Dice::Focusrite::SaffirePro24\n"); 
    4670    Dice::Device::showDevice(); 
    4771} 
     72bool SaffirePro24::setNickName( std::string name ) { 
     73    return m_eap->writeRegBlock( Dice::Device::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name.c_str(), name.size() ); 
     74} 
     75std::string SaffirePro24::getNickName() { 
     76    char name[16]; 
     77    m_eap->readRegBlock( Dice::Device::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name, 16 ); 
     78    return std::string( name ); 
     79} 
     80 
     81 
     82SaffirePro24::LineInstSwitch::LineInstSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue ) 
     83    : Control::Enum(eap, name) 
     84    , m_eap(eap) 
     85    , m_selected(0) 
     86    , m_offset(offset) 
     87    , m_activevalue(activevalue) 
     88{ 
     89    m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp); 
     90    printf("%s: Active?%i\n", name.c_str(), m_state_tmp&m_activevalue); 
     91    m_selected = (m_state_tmp&m_activevalue)?1:0; 
     92} 
     93int SaffirePro24::LineInstSwitch::selected() { 
     94    return m_selected; 
     95} 
     96bool SaffirePro24::LineInstSwitch::select(int n) { 
     97    if ( n != m_selected ) { 
     98        m_selected = n; 
     99        m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp); 
     100        m_eap->writeReg(Dice::Device::EAP::eRT_Application, m_offset, m_state_tmp^m_activevalue); 
     101        m_eap->writeReg(Dice::Device::EAP::eRT_Application, msgSet, 4); 
     102    } 
     103    return true; 
     104} 
     105std::string SaffirePro24::LineInstSwitch::getEnumLabel(int n) { 
     106    if ( n == 1 ) { 
     107        return "Instrument"; 
     108    } 
     109    return "Line"; 
     110} 
     111 
     112SaffirePro24::LevelSwitch::LevelSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue) 
     113    : LineInstSwitch(eap, name, offset, activevalue) 
     114{ 
     115} 
     116std::string SaffirePro24::LevelSwitch::getEnumLabel(int n) { 
     117    switch (n) { 
     118        case 0: 
     119            return "Low"; 
     120        case 1: 
     121            return "High"; 
     122        default: 
     123            return ""; 
     124    } 
     125} 
     126 
    48127 
    49128} 
    50129} 
     130 
     131// vim: et 
  • trunk/libffado/src/dice/focusrite/saffire_pro24.h

    r1712 r1718  
    3737    SaffirePro24( DeviceManager& d, 
    3838                  std::auto_ptr<ConfigRom>( configRom )); 
    39     virtual ~SaffirePro24(); 
     39    ~SaffirePro24(); 
    4040 
    41     virtual void showDevice(); 
     41    bool discover(); 
    4242 
     43    void showDevice(); 
     44 
     45    bool canChangeNickname() { return true; } 
     46    bool setNickName( std::string name ); 
     47    std::string getNickName(); 
     48 
     49    class LineInstSwitch : public Control::Enum 
     50    { 
     51    protected: 
     52        friend class Dice::Focusrite::SaffirePro24; 
     53 
     54        LineInstSwitch(Dice::Device::EAP*, std::string name, size_t offset, int activevalue); 
     55    public: 
     56        int count() { return 2; } 
     57 
     58        int selected(); 
     59        bool select(int); 
     60 
     61        std::string getEnumLabel(int); 
     62 
     63    private: 
     64        Dice::Device::EAP* m_eap; 
     65        int m_selected; 
     66        size_t m_offset; 
     67        int m_activevalue; 
     68        fb_quadlet_t m_state_tmp; 
     69    }; 
     70    class LevelSwitch : public LineInstSwitch 
     71    { 
     72    protected: 
     73        friend class Dice::Focusrite::SaffirePro24; 
     74 
     75        LevelSwitch(Dice::Device::EAP*, std::string name, size_t offset, int activevalue); 
     76    public: 
     77        std::string getEnumLabel(int); 
     78    }; 
    4379private: 
     80    LineInstSwitch *m_ch1, *m_ch2; 
     81    LevelSwitch *m_ch3, *m_ch4; 
    4482}; 
    4583 
     
    4886 
    4987#endif 
     88// vim: et