Changeset 1730
- Timestamp:
- 11/23/09 13:55:36 (13 years ago)
- Files:
-
- trunk/libffado/src/dice/focusrite/focusrite_eap.cpp (copied) (copied from trunk/libffado/src/dice/focusrite/saffire_pro24.cpp) (4 diffs)
- trunk/libffado/src/dice/focusrite/focusrite_eap.h (copied) (copied from trunk/libffado/src/dice/focusrite/saffire_pro24.h) (5 diffs)
- trunk/libffado/src/dice/focusrite/saffire_pro24.cpp (modified) (5 diffs)
- trunk/libffado/src/dice/focusrite/saffire_pro24.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/dice/focusrite/focusrite_eap.cpp
r1726 r1730 23 23 */ 24 24 25 #include " saffire_pro24.h"25 #include "focusrite_eap.h" 26 26 27 27 namespace Dice { … … 30 30 const int msgSet = 0x68; 31 31 32 SaffirePro24::Switch::Switch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue ) 32 FocusriteEAP::FocusriteEAP(Dice::Device& dev) : Dice::Device::EAP(dev) { 33 } 34 35 bool FocusriteEAP::readApplicationReg(unsigned offset, quadlet_t* quadlet) { 36 return readReg(eRT_Application, offset, quadlet); 37 } 38 bool FocusriteEAP::writeApplicationReg(unsigned offset, quadlet_t quadlet) { 39 bool ret = writeReg(eRT_Application, offset, quadlet); 40 if (!ret) return false; 41 return writeReg(eRT_Application, msgSet, commandToFix(offset)); 42 } 43 44 45 FocusriteEAP::Switch::Switch(Dice::Focusrite::FocusriteEAP* eap, std::string name, size_t offset, int activevalue ) 33 46 : Control::Boolean(eap, name) 34 47 , m_eap(eap) … … 37 50 , m_activevalue(activevalue) 38 51 { 39 m_eap->read Reg(Dice::Device::EAP::eRT_Application,m_offset, &m_state_tmp);52 m_eap->readApplicationReg(m_offset, &m_state_tmp); 40 53 printf("%s: Active?%i\n", name.c_str(), m_state_tmp&m_activevalue); 41 54 debugOutput(DEBUG_LEVEL_VERBOSE, "Probably the initialization is the other way round.\n"); … … 43 56 } 44 57 45 bool SaffirePro24::Switch::selected() {58 bool FocusriteEAP::Switch::selected() { 46 59 return m_selected; 47 60 } 48 61 49 bool SaffirePro24::Switch::select(bool n) {62 bool FocusriteEAP::Switch::select(bool n) { 50 63 if ( n != m_selected ) { 51 64 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); 65 m_eap->readApplicationReg(m_offset, &m_state_tmp); 66 m_eap->writeApplicationReg(m_offset, m_state_tmp^m_activevalue); 61 67 } 62 68 return true; 63 69 } 64 70 65 class SaffirePro24::LineInstSwitch : public Switch66 {67 public: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 };75 class SaffirePro24::LevelSwitch : public Switch76 {77 public: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 86 SaffirePro24::SaffirePro24( DeviceManager& d,87 std::auto_ptr<ConfigRom>( configRom ))88 : Dice::Device(d , configRom)89 , m_ch1(NULL)90 , m_ch2(NULL)91 {92 debugOutput(DEBUG_LEVEL_VERBOSE, "Created Dice::Focusrite::SaffirePro24 (NodeID %d)\n",93 getConfigRom().getNodeId());94 }95 96 SaffirePro24::~SaffirePro24()97 {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 is100 // changed. Or should we provide a function (and thus gui-button) to save the state of the101 // device?102 getEAP()->storeFlashConfig();103 getEAP()->deleteElement(m_ch1);104 getEAP()->deleteElement(m_ch2);105 if (m_ch1) delete m_ch1;106 if (m_ch2) delete m_ch2;107 }108 109 bool SaffirePro24::discover() {110 if (Dice::Device::discover()) {111 fb_quadlet_t* tmp = (fb_quadlet_t *)calloc(2, sizeof(fb_quadlet_t));112 getEAP()->readRegBlock(Dice::Device::EAP::eRT_Application, 0x00, tmp, 1*sizeof(fb_quadlet_t));113 //hexDumpQuadlets(tmp, 2); // DEBUG114 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)); // DEBUG120 //hexDumpQuadlets(tmp, 2); // DEBUG121 122 m_ch1 = new LineInstSwitch(getEAP(), "Ch1LineInst", 0x58, 2);123 getEAP()->addElement(m_ch1);124 m_ch2 = new LineInstSwitch(getEAP(), "Ch2LineInst", 0x58, 2<<16);125 getEAP()->addElement(m_ch2);126 m_ch3 = new LevelSwitch(getEAP(), "Ch3Level", 0x5C, 1);127 getEAP()->addElement(m_ch3);128 m_ch4 = new LevelSwitch(getEAP(), "Ch4Level", 0x5C, 1<<16);129 getEAP()->addElement(m_ch4);130 131 m_monitor = new MonitorSection(getEAP(), "Monitoring");132 getEAP()->addElement(m_monitor);133 return true;134 }135 return false;136 }137 138 void SaffirePro24::showDevice()139 {140 debugOutput(DEBUG_LEVEL_VERBOSE, "This is a Dice::Focusrite::SaffirePro24\n");141 Dice::Device::showDevice();142 }143 144 bool SaffirePro24::setNickName( std::string name ) {145 return getEAP()->writeRegBlock( Dice::Device::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name.c_str(), name.size() );146 }147 148 std::string SaffirePro24::getNickName() {149 char name[16];150 getEAP()->readRegBlock( Dice::Device::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name, 16 );151 return std::string( name );152 }153 71 154 72 155 SaffirePro24::MonitorSection::MonitorSection(Dice::Device::EAP* eap, std::string name)73 FocusriteEAP::MonitorSection::MonitorSection(Dice::Focusrite::FocusriteEAP* eap, std::string name) 156 74 : Control::Container(eap, name) 157 75 , m_eap(eap) trunk/libffado/src/dice/focusrite/focusrite_eap.h
r1726 r1730 23 23 */ 24 24 25 #ifndef DICE_FOCUSRITE_ SAFFIRE_PRO24_H26 #define DICE_FOCUSRITE_ SAFFIRE_PRO24_H25 #ifndef DICE_FOCUSRITE_FOCUSRITE_EAP_H 26 #define DICE_FOCUSRITE_FOCUSRITE_EAP_H 27 27 28 28 #include "dice/dice_avdevice.h" … … 33 33 namespace Focusrite { 34 34 35 class SaffirePro24 : public Dice::Device { 35 class FocusriteEAP : public Dice::Device::EAP 36 { 36 37 public: 37 SaffirePro24( DeviceManager& d,38 std::auto_ptr<ConfigRom>( configRom ));39 ~SaffirePro24();40 41 bool discover();42 43 void showDevice();44 45 bool canChangeNickname() { return true; }46 bool setNickName( std::string name );47 std::string getNickName();48 49 38 /** 50 39 * @brief A standard-switch for boolean. … … 54 43 class Switch : public Control::Boolean 55 44 { 56 p rotected:57 friend class Dice::Focusrite::SaffirePro24;45 public: 46 Switch(Dice::Focusrite::FocusriteEAP*, std::string name, size_t offset, int activevalue); 58 47 59 Switch(Dice::Device::EAP*, std::string name, size_t offset, int activevalue);60 public:61 48 bool selected(); 62 49 bool select(bool); 50 63 51 private: 64 Dice:: Device::EAP* m_eap;52 Dice::Focusrite::FocusriteEAP* m_eap; 65 53 bool m_selected; 66 54 size_t m_offset; … … 71 59 class MonitorSection : public Control::Container 72 60 { 73 p rotected:74 friend class Dice::Focusrite::SaffirePro24;61 public: 62 MonitorSection(Dice::Focusrite::FocusriteEAP*, std::string name); 75 63 76 MonitorSection(Dice::Device::EAP*, std::string name);77 64 private: 78 Dice:: Device::EAP* m_eap;65 Dice::Focusrite::FocusriteEAP* m_eap; 79 66 Switch *m_mute, *m_dim; 80 67 std::vector<Switch*> m_mute_affected; … … 82 69 std::vector<Switch*> m_mono; 83 70 }; 84 private: 85 class LineInstSwitch; 86 LineInstSwitch *m_ch1, *m_ch2; 87 class LevelSwitch; 88 LevelSwitch *m_ch3, *m_ch4; 89 MonitorSection *m_monitor; 71 72 73 public: 74 FocusriteEAP(Dice::Device&); 75 76 bool readApplicationReg(unsigned offset, quadlet_t*); 77 bool writeApplicationReg(unsigned offset, quadlet_t); 78 79 protected: 80 virtual int commandToFix(unsigned offset) =0; 90 81 }; 91 82 trunk/libffado/src/dice/focusrite/saffire_pro24.cpp
r1726 r1730 24 24 25 25 #include "saffire_pro24.h" 26 #include "focusrite_eap.h" 26 27 27 28 namespace Dice { 28 29 namespace Focusrite { 29 30 30 const int msgSet = 0x68; 31 32 SaffirePro24::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; 31 int SaffirePro24::SaffirePro24EAP::commandToFix(unsigned offset) { 32 if (offset<0x14) return 2; 33 if (offset<0x3C && offset>=0x14) return 1; 34 if (offset<0x40 && offset>=0x3C) return 3; 35 if (offset<0x60 && offset>=0x58) return 4; 36 return 0; 43 37 } 44 38 45 bool SaffirePro24::Switch::selected() {46 return m_selected;47 }48 39 49 bool 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 65 class SaffirePro24::LineInstSwitch : public Switch 40 class SaffirePro24::LineInstSwitch : public Dice::Focusrite::FocusriteEAP::Switch 66 41 { 67 42 public: 68 LineInstSwitch(Dice:: Device::EAP* eap, std::string name, size_t offset, int activevalue)69 : Switch(eap, name, offset, activevalue) {}43 LineInstSwitch(Dice::Focusrite::FocusriteEAP* eap, std::string name, size_t offset, int activevalue) 44 : Dice::Focusrite::FocusriteEAP::Switch(eap, name, offset, activevalue) {} 70 45 std::string getBooleanLabel(bool n) { 71 46 if ( n ) return "Instrument"; … … 73 48 } 74 49 }; 75 class SaffirePro24::LevelSwitch : public Switch50 class SaffirePro24::LevelSwitch : public Dice::Focusrite::FocusriteEAP::Switch 76 51 { 77 52 public: 78 LevelSwitch(Dice:: Device::EAP* eap, std::string name, size_t offset, int activevalue)79 : Switch(eap, name, offset, activevalue) {}53 LevelSwitch(Dice::Focusrite::FocusriteEAP* eap, std::string name, size_t offset, int activevalue) 54 : Dice::Focusrite::FocusriteEAP::Switch(eap, name, offset, activevalue) {} 80 55 std::string getBooleanLabel(bool n) { 81 56 if ( n ) return "High"; … … 120 95 //hexDumpQuadlets(tmp, 2); // DEBUG 121 96 122 m_ch1 = new LineInstSwitch(getEAP(), "Ch1LineInst", 0x58, 2); 97 FocusriteEAP* eap = dynamic_cast<FocusriteEAP*>(getEAP()); 98 m_ch1 = new LineInstSwitch(eap, "Ch1LineInst", 0x58, 2); 123 99 getEAP()->addElement(m_ch1); 124 m_ch2 = new LineInstSwitch( getEAP(), "Ch2LineInst", 0x58, 2<<16);100 m_ch2 = new LineInstSwitch(eap, "Ch2LineInst", 0x58, 2<<16); 125 101 getEAP()->addElement(m_ch2); 126 m_ch3 = new LevelSwitch( getEAP(), "Ch3Level", 0x5C, 1);102 m_ch3 = new LevelSwitch(eap, "Ch3Level", 0x5C, 1); 127 103 getEAP()->addElement(m_ch3); 128 m_ch4 = new LevelSwitch( getEAP(), "Ch4Level", 0x5C, 1<<16);104 m_ch4 = new LevelSwitch(eap, "Ch4Level", 0x5C, 1<<16); 129 105 getEAP()->addElement(m_ch4); 130 106 131 m_monitor = new MonitorSection(getEAP(), "Monitoring");107 m_monitor = new FocusriteEAP::MonitorSection(eap, "Monitoring"); 132 108 getEAP()->addElement(m_monitor); 133 109 return true; … … 140 116 debugOutput(DEBUG_LEVEL_VERBOSE, "This is a Dice::Focusrite::SaffirePro24\n"); 141 117 Dice::Device::showDevice(); 118 } 119 Dice::Device::EAP* SaffirePro24::createEAP() { 120 return new SaffirePro24EAP(*this); 142 121 } 143 122 … … 152 131 } 153 132 154 155 SaffirePro24::MonitorSection::MonitorSection(Dice::Device::EAP* eap, std::string name)156 : Control::Container(eap, name)157 , m_eap(eap)158 {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);174 }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);181 }182 }183 184 133 } 185 134 } trunk/libffado/src/dice/focusrite/saffire_pro24.h
r1726 r1730 30 30 #include "libieee1394/configrom.h" 31 31 32 #include "focusrite_eap.h" 33 32 34 namespace Dice { 33 35 namespace Focusrite { … … 47 49 std::string getNickName(); 48 50 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 51 private: 52 53 class SaffirePro24EAP : public FocusriteEAP 55 54 { 56 protected: 57 friend class Dice::Focusrite::SaffirePro24; 55 public: 56 SaffirePro24EAP(Dice::Device& dev) : FocusriteEAP(dev) { 57 } 58 58 59 Switch(Dice::Device::EAP*, std::string name, size_t offset, int activevalue); 60 public: 61 bool selected(); 62 bool select(bool); 63 private: 64 Dice::Device::EAP* m_eap; 65 bool m_selected; 66 size_t m_offset; 67 int m_activevalue; 68 fb_quadlet_t m_state_tmp; 59 int commandToFix(unsigned offset); 69 60 }; 61 Dice::Device::EAP* createEAP(); 70 62 71 class MonitorSection : public Control::Container72 {73 protected:74 friend class Dice::Focusrite::SaffirePro24;75 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;83 };84 private:85 63 class LineInstSwitch; 86 64 LineInstSwitch *m_ch1, *m_ch2; 87 65 class LevelSwitch; 88 66 LevelSwitch *m_ch3, *m_ch4; 89 MonitorSection *m_monitor;67 Dice::Focusrite::FocusriteEAP::MonitorSection *m_monitor; 90 68 }; 91 69