Changeset 2433
- Timestamp:
- 10/17/13 05:04:56 (10 years ago)
- Files:
-
- trunk/libffado/src/dice/maudio/profire_2626.cpp (modified) (3 diffs)
- trunk/libffado/src/dice/maudio/profire_2626.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/dice/maudio/profire_2626.cpp
r2432 r2433 28 28 namespace Dice { 29 29 namespace Maudio { 30 31 Profire2626::Profire2626EAP::Profire2626EAP(Dice::Device & dev) 32 : Dice::EAP(dev) 33 { 34 } 30 35 31 36 // … … 275 280 276 281 /** 282 * Application space register read/write 283 */ 284 bool Profire2626::Profire2626EAP::readApplicationReg(unsigned offset, quadlet_t* quadlet) 285 { 286 bool ret = readReg(Dice::EAP::eRT_Application, offset, quadlet); 287 return ret; 288 } 289 290 bool 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 */ 303 Profire2626::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 315 bool 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 324 bool 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 */ 341 Profire2626::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 /** 277 363 Device 278 364 */ … … 289 375 } 290 376 291 bool Profire2626::discover() 377 bool Profire2626::discover() 292 378 { 293 379 if (Dice::Device::discover()) { 294 380 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 295 386 return true; 296 387 } trunk/libffado/src/dice/maudio/profire_2626.h
r2254 r2433 32 32 #include "libieee1394/configrom.h" 33 33 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 34 40 namespace Dice { 35 41 namespace Maudio { … … 47 53 bool canChangeNickname() { return false; } 48 54 49 private:50 55 class Profire2626EAP : public Dice::EAP 51 56 { 52 57 public: 53 Profire2626EAP(Dice::Device& dev) : Dice::EAP(dev) { 54 } 58 Profire2626EAP(Dice::Device& dev); 55 59 56 60 void setupSources_low(); … … 64 68 void setupDefaultRouterConfig_high(); 65 69 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 }; 66 99 }; 100 101 private: 67 102 Dice::EAP* createEAP(); 68 103 };