Changeset 2433

Show
Ignore:
Timestamp:
10/17/13 05:04:56 (10 years ago)
Author:
jwoithe
Message:

profile-2626: add master volume knob support. Add dbus controls for setting which analog output pairs are controlled by the master volume knob. Code templated from focusrite implementation. Patch from Jano Svitok.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/dice/maudio/profire_2626.cpp

    r2432 r2433  
    2828namespace Dice { 
    2929namespace Maudio { 
     30 
     31Profire2626::Profire2626EAP::Profire2626EAP(Dice::Device & dev)  
     32    : Dice::EAP(dev) 
     33{ 
     34} 
    3035 
    3136// 
     
    275280 
    276281/** 
     282 * Application space register read/write 
     283 */ 
     284bool Profire2626::Profire2626EAP::readApplicationReg(unsigned offset, quadlet_t* quadlet) 
     285{ 
     286    bool ret = readReg(Dice::EAP::eRT_Application, offset, quadlet); 
     287    return ret; 
     288} 
     289 
     290bool Profire2626::Profire2626EAP::writeApplicationReg(unsigned offset, quadlet_t quadlet) 
     291{ 
     292    bool ret = writeReg(Dice::EAP::eRT_Application, offset, quadlet); 
     293    if (!ret) { 
     294        debugWarning("Couldn't write %i to register %x!\n", quadlet, offset); 
     295        return false; 
     296    } 
     297    return ret; 
     298} 
     299 
     300/** 
     301 * Switch class 
     302 */ 
     303Profire2626::Profire2626EAP::Switch::Switch( 
     304        Profire2626::Profire2626EAP* eap, std::string name, 
     305        size_t offset, int activevalue) 
     306    : Control::Boolean(eap, name) 
     307    , m_eap(eap) 
     308    , m_name(name) 
     309    , m_offset(offset) 
     310    , m_activevalue(activevalue) 
     311{ 
     312    debugOutput( DEBUG_LEVEL_VERBOSE, "Create Switch %s)\n", m_name.c_str()); 
     313} 
     314 
     315bool Profire2626::Profire2626EAP::Switch::selected() 
     316{ 
     317    quadlet_t state_tmp; 
     318 
     319    m_eap->readApplicationReg(m_offset, &state_tmp); 
     320    bool is_selected = (state_tmp&m_activevalue)?true:false; 
     321    return is_selected; 
     322} 
     323 
     324bool Profire2626::Profire2626EAP::Switch::select(bool n) 
     325{ 
     326    quadlet_t state_tmp; 
     327    m_eap->readApplicationReg(m_offset, &state_tmp); 
     328    bool is_selected = (state_tmp&m_activevalue)?true:false; 
     329 
     330    // Switch the corresponding bit(s) 
     331    if ( n != is_selected ) { 
     332        m_eap->writeApplicationReg(m_offset, state_tmp^m_activevalue); 
     333        is_selected = n; 
     334    } 
     335    return is_selected; 
     336} 
     337 
     338/** 
     339 *  Profire2626 Settings section 
     340 */ 
     341Profire2626::Profire2626EAP::SettingsSection::SettingsSection( 
     342        Profire2626::Profire2626EAP* eap, std::string name) 
     343    : Control::Container(eap, name) 
     344    , m_eap(eap) 
     345{ 
     346    // Volume Knob 
     347    Control::Container* grp_volumeknob = new Control::Container(m_eap, "VolumeKnob"); 
     348    addElement(grp_volumeknob); 
     349 
     350    for (unsigned i=0; i<MAUDIO_PROFIRE2626_REGISTER_APP_VOLUME_KNOB_SIZE; ++i) { 
     351        std::stringstream stream; 
     352        stream << "Line" << i*2+1 << "Line" << i*2+2; 
     353        Profire2626EAP::Switch* outputPair = 
     354            new Profire2626EAP::Switch(m_eap, stream.str(), 
     355                                 MAUDIO_PROFIRE2626_REGISTER_APP_VOLUME_KNOB_OFFSET, 
     356                                 MAUDIO_PROFIRE2626_REGISTER_APP_VOLUME_KNOB_VALUE 
     357                                      <<(MAUDIO_PROFIRE2626_REGISTER_APP_VOLUME_KNOB_SHIFT+i)); 
     358        grp_volumeknob->addElement(outputPair); 
     359    } 
     360} 
     361 
     362/** 
    277363  Device 
    278364*/ 
     
    289375} 
    290376 
    291 bool Profire2626::discover()  
     377bool Profire2626::discover() 
    292378{ 
    293379    if (Dice::Device::discover()) { 
    294380        debugOutput(DEBUG_LEVEL_VERBOSE, "Discovering Dice::Maudio::Profire2626\n"); 
     381 
     382        Profire2626EAP* eap = dynamic_cast<Profire2626EAP*>(getEAP()); 
     383        Profire2626EAP::SettingsSection *settings = new Profire2626EAP::SettingsSection(eap, "Settings"); 
     384        eap->addElement(settings); 
     385 
    295386        return true; 
    296387    } 
  • trunk/libffado/src/dice/maudio/profire_2626.h

    r2254 r2433  
    3232#include "libieee1394/configrom.h" 
    3333 
     34// Global monitor registers (application space) 
     35#define MAUDIO_PROFIRE2626_REGISTER_APP_VOLUME_KNOB_OFFSET 0x00 
     36#define MAUDIO_PROFIRE2626_REGISTER_APP_VOLUME_KNOB_SIZE 4 
     37#define MAUDIO_PROFIRE2626_REGISTER_APP_VOLUME_KNOB_VALUE 1 
     38#define MAUDIO_PROFIRE2626_REGISTER_APP_VOLUME_KNOB_SHIFT 0 
     39 
    3440namespace Dice { 
    3541namespace Maudio { 
     
    4753    bool canChangeNickname() { return false; } 
    4854 
    49 private: 
    5055    class Profire2626EAP : public Dice::EAP 
    5156    { 
    5257    public: 
    53         Profire2626EAP(Dice::Device& dev) : Dice::EAP(dev) { 
    54 
     58        Profire2626EAP(Dice::Device& dev); 
    5559 
    5660        void setupSources_low(); 
     
    6468        void setupDefaultRouterConfig_high(); 
    6569 
     70        bool readApplicationReg(unsigned, quadlet_t*); 
     71        bool writeApplicationReg(unsigned, quadlet_t); 
     72 
     73       /** 
     74        * @brief A standard-switch for boolean. 
     75        * 
     76        * If you don't like True and False for the labels, subclass and return your own. 
     77        * \internal copy&paste from focusrite_eap.h 
     78        */ 
     79        class Switch : public Control::Boolean 
     80        { 
     81        public: 
     82            Switch(Profire2626EAP*, std::string, size_t, int); 
     83            bool selected(); 
     84            bool select(bool); 
     85        private: 
     86            Profire2626EAP* m_eap; 
     87            std::string m_name; 
     88            size_t m_offset; 
     89            int m_activevalue; 
     90        }; 
     91 
     92        class SettingsSection : public Control::Container 
     93        { 
     94        public: 
     95            SettingsSection(Profire2626EAP*, std::string); 
     96        private: 
     97            Profire2626EAP * m_eap; 
     98        }; 
    6699    }; 
     100 
     101private: 
    67102    Dice::EAP* createEAP(); 
    68103};