Changeset 1735 for trunk

Show
Ignore:
Timestamp:
11/25/09 13:09:04 (14 years ago)
Author:
arnonym
Message:

Lots more controls. Should be ready for the gui now...

Files:

Legend:

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

    r1734 r1735  
    4444} 
    4545bool FocusriteEAP::Poti::setValue(int n) { 
    46     if ( n == m_value
     46    if (n == m_value
    4747        return true; 
     48    m_value = n; 
    4849    return m_eap->writeApplicationReg(m_offset, -n); 
    49     //return false; 
    50 
     50
     51 
    5152 
    5253FocusriteEAP::FocusriteEAP(Dice::Device& dev) : Dice::Device::EAP(dev) { 
     
    7273{ 
    7374    m_eap->readApplicationReg(m_offset, &m_state_tmp); 
    74     printf("%s: Active?%i\n", name.c_str(), m_state_tmp&m_activevalue); 
     75    printf("%s: %s\n", name.c_str(), (m_state_tmp&m_activevalue)?"true":"false"); 
    7576    debugOutput(DEBUG_LEVEL_VERBOSE, "Probably the initialization is the other way round.\n"); 
    7677    m_selected = (m_state_tmp&m_activevalue)?true:false; 
     
    9192 
    9293 
     94class VolumeControl : public Control::Discrete 
     95{ 
     96public: 
     97    VolumeControl(FocusriteEAP* eap, std::string name, size_t offset, int bitshift) 
     98        : Control::Discrete(eap, name) 
     99        , m_eap(eap) 
     100        , m_offset(offset) 
     101        , m_bitshift(bitshift) 
     102    { 
     103        quadlet_t tmp; 
     104        m_eap->readApplicationReg(m_offset, &tmp); 
     105        m_value = - ((tmp>>m_bitshift)&0xff); 
     106        printf("%s: %i -> %i\n", name.c_str(), tmp, m_value); 
     107    } 
     108 
     109    int getValue(int) { return getValue(); } 
     110    bool setValue(int, int n) { return setValue(n); } 
     111 
     112    int getMinimum() { return -255; } 
     113    int getMaximum() { return 0; } 
     114 
     115    int getValue() { return m_value; } 
     116    bool setValue(int n) { 
     117        if (n == m_value) 
     118            return true; 
     119        m_value = n; 
     120        return m_eap->writeApplicationReg(m_offset, (-n)<<m_bitshift); 
     121    } 
     122private: 
     123    FocusriteEAP* m_eap; 
     124    size_t m_offset; 
     125    int m_bitshift; 
     126    int m_value; 
     127}; 
     128 
    93129 
    94130FocusriteEAP::MonitorSection::MonitorSection(Dice::Focusrite::FocusriteEAP* eap, std::string name) 
     
    98134    , m_dimlevel(0) 
    99135{ 
    100     m_mute = new Switch(m_eap, "Mute", 0x0C, 1); 
    101     addElement(m_mute); 
    102     m_dim = new Switch(m_eap, "Dim", 0x10, 1); 
    103     addElement(m_dim); 
     136    Control::Container* grp_globalmute = new Control::Container(m_eap, "GlobalMute"); 
     137    addElement(grp_globalmute); 
     138    m_mute = new Switch(m_eap, "State", 0x0C, 1); 
     139    grp_globalmute->addElement(m_mute); 
     140 
     141    Control::Container* grp_globaldim = new Control::Container(m_eap, "GlobalDim"); 
     142    addElement(grp_globaldim); 
     143    m_dim = new Switch(m_eap, "State", 0x10, 1); 
     144    grp_globaldim->addElement(m_dim); 
     145    m_dimlevel = m_eap->getDimPoti("Level"); 
     146    grp_globaldim->addElement(m_dimlevel); 
     147 
     148    Control::Container* grp_mono = new Control::Container(m_eap, "Mono"); 
     149    addElement(grp_mono); 
     150 
     151    Control::Container* grp_globalvolume = new Control::Container(m_eap, "GlobalVolume"); 
     152    addElement(grp_globalvolume); 
     153    m_monitorlevel = m_eap->getMonitorPoti("Level"); 
     154    grp_globalvolume->addElement(m_monitorlevel); 
     155 
     156    Control::Container* grp_perchannel = new Control::Container(m_eap, "PerChannel"); 
     157    addElement(grp_perchannel); 
     158 
    104159    for (int i=0; i<10; ++i) { 
    105160        std::stringstream stream; 
    106         stream << "MuteAffectsCh" << i; 
     161        stream << "AffectsCh" << i; 
    107162        Switch* s = new Switch(m_eap, stream.str(), 0x3C, 1<<i); 
    108         addElement(s); 
    109         m_mute_affected.push_back(s); 
    110         stream.str(std::string()); 
    111         stream << "DimAffectsCh" << i; 
     163        grp_globalmute->addElement(s); 
     164        //m_mute_affected.push_back(s); 
    112165        s = new Switch(m_eap, stream.str(), 0x3C, 1<<(10+i)); 
    113         addElement(s); 
    114         m_dim_affected.push_back(s); 
     166        grp_globaldim->addElement(s); 
     167        //m_dim_affected.push_back(s); 
    115168    } 
    116169    for (int i=0; i<5; ++i) { 
    117170        std::stringstream stream; 
    118         stream << "Mono_" << i*2 << "_" << i*2+1; 
     171        stream << "Ch" << i*2 << "Ch" << i*2+1; 
    119172        Switch* s = new Switch(m_eap, stream.str(), 0x3C, 1<<(20+i)); 
    120         addElement(s); 
    121         m_mono.push_back(s); 
    122     } 
    123     m_monitorlevel = m_eap->getMonitorPoti("MonitorLevel"); 
    124     addElement(m_monitorlevel); 
    125     m_dimlevel = m_eap->getDimPoti("DimLevel"); 
    126     addElement(m_dimlevel); 
     173        grp_mono->addElement(s); 
     174        //m_mono.push_back(s); 
     175 
     176        stream.str(std::string()); 
     177        stream << "AffectsCh" << i*2; 
     178        s = new Switch(m_eap, stream.str(), 0x28+i*4, 1); 
     179        grp_globalvolume->addElement(s); 
     180        stream.str(std::string()); 
     181        stream << "AffectsCh" << i*2+1; 
     182        s = new Switch(m_eap, stream.str(), 0x28+i*4, 2); 
     183        grp_globalvolume->addElement(s); 
     184 
     185        stream.str(std::string()); 
     186        stream << "Mute" << i*2; 
     187        s = new Switch(m_eap, stream.str(), 0x28+i*4, 4); 
     188        grp_perchannel->addElement(s); 
     189        stream.str(std::string()); 
     190        stream << "Mute" << i*2+1; 
     191        s = new Switch(m_eap, stream.str(), 0x28+i*4, 8); 
     192        grp_perchannel->addElement(s); 
     193 
     194        stream.str(std::string()); 
     195        stream << "Volume" << i*2; 
     196        VolumeControl* vol = new VolumeControl(m_eap, stream.str(), 0x14+i*4, 0); 
     197        grp_perchannel->addElement(vol); 
     198        stream.str(std::string()); 
     199        stream << "Volume" << i*2+1; 
     200        vol = new VolumeControl(m_eap, stream.str(), 0x14+i*4, 8); 
     201        grp_perchannel->addElement(vol); 
     202    } 
    127203} 
    128204