Changeset 619
- Timestamp:
- 09/05/07 13:51:06 (17 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bebob/focusrite/focusrite_cmd.h
r618 r619 31 31 #include <libavc1394/avc1394.h> 32 32 33 #define FOCUSRITE_CMD_ID_SAMPLERATE 84 34 #define FOCUSRITE_CMD_ID_PHANTOM14 98 35 #define FOCUSRITE_CMD_ID_PHANTOM58 99 33 #define FOCUSRITE_CMD_ID_SAMPLERATE 84 34 35 #define FOCUSRITE_CMD_ID_PHANTOM14 98 36 #define FOCUSRITE_CMD_ID_PHANTOM58 99 37 #define FOCUSRITE_CMD_ID_INSERT1 100 38 #define FOCUSRITE_CMD_ID_INSERT2 101 39 #define FOCUSRITE_CMD_ID_AC3_PASSTHROUGH 103 40 #define FOCUSRITE_CMD_ID_MIDI_TRU 104 36 41 37 42 #define FOCUSRITE_CMD_SAMPLERATE_44K1 1 … … 41 46 #define FOCUSRITE_CMD_SAMPLERATE_176K4 5 42 47 #define FOCUSRITE_CMD_SAMPLERATE_192K 6 48 49 #define FOCUSRITE_CMD_ID_PC1_TO_OUT1 52 50 #define FOCUSRITE_CMD_ID_PC2_TO_OUT2 54 51 #define FOCUSRITE_CMD_ID_MIX1_TO_OUT1 53 52 #define FOCUSRITE_CMD_ID_MIX2_TO_OUT2 55 53 54 #define FOCUSRITE_CMD_ID_PC1_TO_OUT3 56 55 #define FOCUSRITE_CMD_ID_PC2_TO_OUT4 59 56 #define FOCUSRITE_CMD_ID_PC3_TO_OUT3 57 57 #define FOCUSRITE_CMD_ID_PC4_TO_OUT4 60 58 #define FOCUSRITE_CMD_ID_MIX1_TO_OUT3 58 59 #define FOCUSRITE_CMD_ID_MIX2_TO_OUT4 61 60 61 #define FOCUSRITE_CMD_ID_PC1_TO_OUT5 62 62 #define FOCUSRITE_CMD_ID_PC2_TO_OUT6 65 63 #define FOCUSRITE_CMD_ID_PC5_TO_OUT5 63 64 #define FOCUSRITE_CMD_ID_PC6_TO_OUT6 66 65 #define FOCUSRITE_CMD_ID_MIX1_TO_OUT5 64 66 #define FOCUSRITE_CMD_ID_MIX2_TO_OUT6 67 67 68 #define FOCUSRITE_CMD_ID_PC1_TO_OUT7 68 69 #define FOCUSRITE_CMD_ID_PC2_TO_OUT8 71 70 #define FOCUSRITE_CMD_ID_PC7_TO_OUT7 69 71 #define FOCUSRITE_CMD_ID_PC8_TO_OUT8 72 72 #define FOCUSRITE_CMD_ID_MIX1_TO_OUT7 70 73 #define FOCUSRITE_CMD_ID_MIX2_TO_OUT8 73 74 75 #define FOCUSRITE_CMD_ID_PC1_TO_OUT9 74 76 #define FOCUSRITE_CMD_ID_PC2_TO_OUT10 77 77 #define FOCUSRITE_CMD_ID_PC9_TO_OUT9 75 78 #define FOCUSRITE_CMD_ID_PC10_TO_OUT10 78 79 #define FOCUSRITE_CMD_ID_MIX1_TO_OUT9 76 80 #define FOCUSRITE_CMD_ID_MIX2_TO_OUT10 79 43 81 44 82 namespace BeBoB { trunk/libffado/src/bebob/focusrite/focusrite_device.cpp
r585 r619 36 36 37 37 // create control objects for the saffire pro 38 m_Phantom1 = new PhantomPowerControl(*this, FOCUSRITE_CMD_ID_PHANTOM14); 38 m_Phantom1 = new BinaryControl(*this, FOCUSRITE_CMD_ID_PHANTOM14, 39 "Phantom_1to4", "Phantom 1-4", "Switch Phantom Power on channels 1-4"); 39 40 if (m_Phantom1) addElement(m_Phantom1); 40 41 41 m_Phantom2 = new PhantomPowerControl(*this, FOCUSRITE_CMD_ID_PHANTOM58); 42 m_Phantom2 = new BinaryControl(*this, FOCUSRITE_CMD_ID_PHANTOM58, 43 "Phantom_5to8", "Phantom 5-8", "Switch Phantom Power on channels 5-8"); 42 44 if (m_Phantom2) addElement(m_Phantom2); 43 45 46 m_Insert1 = new BinaryControl(*this, FOCUSRITE_CMD_ID_INSERT1, 47 "Insert1", "Insert 1", "Switch Insert on Channel 1"); 48 if (m_Insert1) addElement(m_Insert1); 49 50 m_Insert2 = new BinaryControl(*this, FOCUSRITE_CMD_ID_INSERT2, 51 "Insert2", "Insert 2", "Switch Insert on Channel 2"); 52 if (m_Insert2) addElement(m_Insert2); 53 54 m_AC3pass = new BinaryControl(*this, FOCUSRITE_CMD_ID_AC3_PASSTHROUGH, 55 "AC3pass", "AC3 Passtrough", "Enable AC3 Passthrough"); 56 if (m_AC3pass) addElement(m_AC3pass); 57 58 m_MidiTru = new BinaryControl(*this, FOCUSRITE_CMD_ID_MIDI_TRU, 59 "MidiTru", "Midi Tru", "Enable Midi Tru"); 60 if (m_MidiTru) addElement(m_MidiTru); 61 62 // output mix controls 63 // OUT12 64 m_Output12[0] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC1_TO_OUT1, 65 "PC1_OUT1", "PC1_OUT1", "Volume from PC Channel 1 to Output Channel 1"); 66 if (m_Output12[0]) addElement(m_Output12[0]); 67 m_Output12[1] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC2_TO_OUT2, 68 "PC2_OUT2", "PC2_OUT2", "Volume from PC Channel 2 to Output Channel 2"); 69 if (m_Output12[1]) addElement(m_Output12[1]); 70 m_Output12[2] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX1_TO_OUT1, 71 "MIX_OUT1", "MIX_OUT1", "Volume from Input Mix Left to Output Channel 1"); 72 if (m_Output12[2]) addElement(m_Output12[2]); 73 m_Output12[3] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX2_TO_OUT2, 74 "MIX_OUT2", "MIX_OUT2", "Volume from Input Mix Right to Output Channel 2"); 75 if (m_Output12[3]) addElement(m_Output12[3]); 76 77 // OUT34 78 m_Output34[0] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC1_TO_OUT3, 79 "PC1_OUT3", "PC1_OUT3", "Volume from PC Channel 1 to Output Channel 3"); 80 if (m_Output34[0]) addElement(m_Output34[0]); 81 m_Output34[1] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC2_TO_OUT4, 82 "PC2_OUT4", "PC2_OUT4", "Volume from PC Channel 2 to Output Channel 4"); 83 if (m_Output34[1]) addElement(m_Output34[1]); 84 m_Output34[2] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC3_TO_OUT3, 85 "PC3_OUT3", "PC3_OUT3", "Volume from PC Channel 3 to Output Channel 3"); 86 if (m_Output34[2]) addElement(m_Output34[2]); 87 m_Output34[3] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC4_TO_OUT4, 88 "PC4_OUT4", "PC4_OUT4", "Volume from PC Channel 4 to Output Channel 4"); 89 if (m_Output34[3]) addElement(m_Output34[3]); 90 m_Output34[4] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX1_TO_OUT3, 91 "MIX_OUT3", "MIX_OUT3", "Volume from Input Mix Left to Output Channel 3"); 92 if (m_Output34[4]) addElement(m_Output34[4]); 93 m_Output34[5] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX2_TO_OUT4, 94 "MIX_OUT4", "MIX_OUT4", "Volume from Input Mix Right to Output Channel 4"); 95 if (m_Output34[5]) addElement(m_Output34[5]); 96 97 // OUT56 98 m_Output56[0] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC1_TO_OUT5, 99 "PC1_OUT5", "PC1_OUT5", "Volume from PC Channel 1 to Output Channel 5"); 100 if (m_Output56[0]) addElement(m_Output56[0]); 101 m_Output56[1] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC2_TO_OUT6, 102 "PC2_OUT6", "PC2_OUT6", "Volume from PC Channel 2 to Output Channel 6"); 103 if (m_Output56[1]) addElement(m_Output56[1]); 104 m_Output56[2] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC5_TO_OUT5, 105 "PC5_OUT5", "PC5_OUT5", "Volume from PC Channel 5 to Output Channel 5"); 106 if (m_Output56[2]) addElement(m_Output56[2]); 107 m_Output56[3] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC6_TO_OUT6, 108 "PC6_OUT6", "PC6_OUT6", "Volume from PC Channel 6 to Output Channel 6"); 109 if (m_Output56[3]) addElement(m_Output56[3]); 110 m_Output56[4] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX1_TO_OUT5, 111 "MIX_OUT5", "MIX_OUT5", "Volume from Input Mix Left to Output Channel 5"); 112 if (m_Output56[4]) addElement(m_Output56[4]); 113 m_Output56[5] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX2_TO_OUT6, 114 "MIX_OUT6", "MIX_OUT6", "Volume from Input Mix Right to Output Channel 6"); 115 if (m_Output56[5]) addElement(m_Output56[5]); 116 117 // OUT78 118 m_Output78[0] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC1_TO_OUT7, 119 "PC1_OUT7", "PC1_OUT7", "Volume from PC Channel 1 to Output Channel 7"); 120 if (m_Output78[0]) addElement(m_Output78[0]); 121 m_Output78[1] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC2_TO_OUT8, 122 "PC2_OUT8", "PC2_OUT8", "Volume from PC Channel 2 to Output Channel 8"); 123 if (m_Output78[1]) addElement(m_Output78[1]); 124 m_Output78[2] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC7_TO_OUT7, 125 "PC7_OUT7", "PC7_OUT7", "Volume from PC Channel 7 to Output Channel 7"); 126 if (m_Output78[2]) addElement(m_Output78[2]); 127 m_Output78[3] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC8_TO_OUT8, 128 "PC8_OUT8", "PC8_OUT8", "Volume from PC Channel 8 to Output Channel 8"); 129 if (m_Output78[3]) addElement(m_Output78[3]); 130 m_Output78[4] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX1_TO_OUT7, 131 "MIX_OUT7", "MIX_OUT7", "Volume from Input Mix Left to Output Channel 7"); 132 if (m_Output78[4]) addElement(m_Output78[4]); 133 m_Output78[5] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX2_TO_OUT8, 134 "MIX_OUT8", "MIX_OUT8", "Volume from Input Mix Right to Output Channel 8"); 135 if (m_Output78[5]) addElement(m_Output78[5]); 136 137 // OUT910 138 m_Output910[0] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC1_TO_OUT9, 139 "PC1_OUT9", "PC1_OUT9", "Volume from PC Channel 1 to Output Channel 9"); 140 if (m_Output910[0]) addElement(m_Output910[0]); 141 m_Output910[1] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC2_TO_OUT10, 142 "PC2_OUT10", "PC2_OUT10", "Volume from PC Channel 2 to Output Channel 10"); 143 if (m_Output910[1]) addElement(m_Output910[1]); 144 m_Output910[2] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC9_TO_OUT9, 145 "PC9_OUT9", "PC9_OUT9", "Volume from PC Channel 9 to Output Channel 9"); 146 if (m_Output910[2]) addElement(m_Output910[2]); 147 m_Output910[3] = new VolumeControl(*this, FOCUSRITE_CMD_ID_PC10_TO_OUT10, 148 "PC10_OUT10", "PC10_OUT10", "Volume from PC Channel 10 to Output Channel 10"); 149 if (m_Output910[3]) addElement(m_Output910[3]); 150 m_Output910[4] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX1_TO_OUT9, 151 "MIX_OUT9", "MIX_OUT9", "Volume from Input Mix Left to Output Channel 9"); 152 if (m_Output910[4]) addElement(m_Output910[4]); 153 m_Output910[5] = new VolumeControl(*this, FOCUSRITE_CMD_ID_MIX2_TO_OUT10, 154 "MIX_OUT10", "MIX_OUT10", "Volume from Input Mix Right to Output Channel 10"); 155 if (m_Output910[5]) addElement(m_Output910[5]); 156 44 157 } 45 158 … … 52 165 deleteElement(m_Phantom2); 53 166 if (m_Phantom2) delete m_Phantom2; 167 168 deleteElement(m_Insert1); 169 if (m_Insert1) delete m_Insert1; 170 171 deleteElement(m_Insert2); 172 if (m_Insert2) delete m_Insert2; 173 174 deleteElement(m_AC3pass); 175 if (m_AC3pass) delete m_AC3pass; 176 177 deleteElement(m_MidiTru); 178 if (m_MidiTru) delete m_MidiTru; 179 180 int i=0; 181 for (i=0;i<4;i++) { 182 deleteElement(m_Output12[i]); 183 if (m_Output12[i]) delete m_Output12[i]; 184 } 185 for (i=0;i<6;i++) { 186 deleteElement(m_Output34[i]); 187 if (m_Output34[i]) delete m_Output34[i]; 188 } 189 for (i=0;i<6;i++) { 190 deleteElement(m_Output56[i]); 191 if (m_Output56[i]) delete m_Output56[i]; 192 } 193 for (i=0;i<6;i++) { 194 deleteElement(m_Output78[i]); 195 if (m_Output78[i]) delete m_Output78[i]; 196 } 197 for (i=0;i<6;i++) { 198 deleteElement(m_Output910[i]); 199 if (m_Output910[i]) delete m_Output910[i]; 200 } 54 201 } 55 202 … … 72 219 } 73 220 74 int 75 SaffireProDevice::getSamplingFrequency( ) { 221 bool 222 SaffireProDevice::setSpecificValue(uint32_t id, uint32_t v) 223 { 224 225 FocusriteVendorDependentCmd cmd( get1394Service() ); 226 cmd.setCommandType( AVC::AVCCommand::eCT_Control ); 227 cmd.setNodeId( getConfigRom().getNodeId() ); 228 cmd.setSubunitType( AVC::eST_Unit ); 229 cmd.setSubunitId( 0xff ); 230 231 cmd.setVerbose( getDebugLevel() ); 232 // cmd.setVerbose( DEBUG_LEVEL_VERY_VERBOSE ); 233 234 cmd.m_id=id; 235 cmd.m_value=v; 236 237 if ( !cmd.fire() ) { 238 debugError( "FocusriteVendorDependentCmd info command failed\n" ); 239 return false; 240 } 241 242 uint32_t verify; 243 if ( !getSpecificValue(id, &verify) ) { 244 debugError( "getSpecificValue command failed\n" ); 245 return false; 246 } 247 248 // check wether the command was successful. 249 return verify==v; 250 } 251 252 bool 253 SaffireProDevice::getSpecificValue(uint32_t id, uint32_t *v) 254 { 255 76 256 FocusriteVendorDependentCmd cmd( get1394Service() ); 77 257 cmd.setCommandType( AVC::AVCCommand::eCT_Status ); 78 258 cmd.setNodeId( getConfigRom().getNodeId() ); 259 cmd.setSubunitType( AVC::eST_Unit ); 260 cmd.setSubunitId( 0xff ); 261 79 262 cmd.setVerbose( getDebugLevel() ); 80 cmd.setVerbose( DEBUG_LEVEL_VERY_VERBOSE ); 81 cmd.m_id=FOCUSRITE_CMD_ID_SAMPLERATE; 82 263 // cmd.setVerbose( DEBUG_LEVEL_VERY_VERBOSE ); 264 265 cmd.m_id=id; 266 83 267 if ( !cmd.fire() ) { 84 268 debugError( "FocusriteVendorDependentCmd info command failed\n" ); 269 return false; 270 } 271 272 *v=cmd.m_value; 273 274 return true; 275 } 276 277 int 278 SaffireProDevice::getSamplingFrequency( ) { 279 uint32_t sr; 280 281 if ( !getSpecificValue(FOCUSRITE_CMD_ID_SAMPLERATE, &sr ) ) { 282 debugError( "getSpecificValue failed\n" ); 85 283 return 0; 86 284 } 87 285 88 286 debugOutput( DEBUG_LEVEL_NORMAL, 89 "getSampleRate: %d\n", cmd.m_value);90 91 switch( cmd.m_value) {287 "getSampleRate: %d\n", sr ); 288 289 switch(sr) { 92 290 case FOCUSRITE_CMD_SAMPLERATE_44K1: return 44100; 93 291 case FOCUSRITE_CMD_SAMPLERATE_48K: return 48000; … … 118 316 } else { 119 317 120 FocusriteVendorDependentCmd cmd( get1394Service() ); 121 cmd.setCommandType( AVC::AVCCommand::eCT_Status ); 122 cmd.setNodeId( getConfigRom().getNodeId() ); 123 cmd.setVerbose( getDebugLevel() ); 124 cmd.setVerbose( DEBUG_LEVEL_VERY_VERBOSE ); 125 cmd.m_id=FOCUSRITE_CMD_ID_SAMPLERATE; 126 318 uint32_t value; 127 319 switch(s) { 128 case 44100: cmd.m_value=FOCUSRITE_CMD_SAMPLERATE_44K1;break;129 case 48000: cmd.m_value=FOCUSRITE_CMD_SAMPLERATE_48K;break;130 case 88200: cmd.m_value=FOCUSRITE_CMD_SAMPLERATE_88K2;break;131 case 96000: cmd.m_value=FOCUSRITE_CMD_SAMPLERATE_96K;break;132 case 176400: cmd.m_value=FOCUSRITE_CMD_SAMPLERATE_176K4;break;133 case 192000: cmd.m_value=FOCUSRITE_CMD_SAMPLERATE_192K;break;320 case 44100: value=FOCUSRITE_CMD_SAMPLERATE_44K1;break; 321 case 48000: value=FOCUSRITE_CMD_SAMPLERATE_48K;break; 322 case 88200: value=FOCUSRITE_CMD_SAMPLERATE_88K2;break; 323 case 96000: value=FOCUSRITE_CMD_SAMPLERATE_96K;break; 324 case 176400: value=FOCUSRITE_CMD_SAMPLERATE_176K4;break; 325 case 192000: value=FOCUSRITE_CMD_SAMPLERATE_192K;break; 134 326 default: 135 debugWarning("Unsupported samplerate: %d\n", s);327 debugWarning("Unsupported samplerate: %d\n", s); 136 328 return false; 137 329 } 138 330 139 331 140 if ( ! cmd.fire() ) {141 debugError( " FocusriteVendorDependentCmd info commandfailed\n" );332 if ( !setSpecificValue(FOCUSRITE_CMD_ID_SAMPLERATE, value) ) { 333 debugError( "setSpecificValue failed\n" ); 142 334 return false; 143 335 } … … 152 344 } 153 345 154 155 346 // --- element implementation classes 156 347 157 PhantomPowerControl::PhantomPowerControl(SaffireProDevice& parent, int channel)348 BinaryControl::BinaryControl(SaffireProDevice& parent, int id) 158 349 : Control::Discrete() 159 350 , m_Parent(parent) 160 , m_channel ( channel ) 161 { 162 std::ostringstream ostrm; 163 ostrm << "PhantomPower_"; 164 if(channel==FOCUSRITE_CMD_ID_PHANTOM14) ostrm << "1to4"; 165 if(channel==FOCUSRITE_CMD_ID_PHANTOM58) ostrm << "5to8"; 166 Control::Discrete::setName(ostrm.str()); 167 168 ostrm.str(""); 169 ostrm << "Phantom "; 170 if(channel==FOCUSRITE_CMD_ID_PHANTOM14) ostrm << "1-4"; 171 if(channel==FOCUSRITE_CMD_ID_PHANTOM58) ostrm << "5-8"; 172 setLabel(ostrm.str()); 173 174 ostrm.str(""); 175 ostrm << "Turn on/off Phantom Power on channels "; 176 if(channel==FOCUSRITE_CMD_ID_PHANTOM14) ostrm << "1 to 4"; 177 if(channel==FOCUSRITE_CMD_ID_PHANTOM58) ostrm << "5 to 8"; 178 setDescription(ostrm.str()); 351 , m_cmd_id ( id ) 352 {} 353 BinaryControl::BinaryControl(SaffireProDevice& parent, int id, 354 std::string name, std::string label, std::string descr) 355 : Control::Discrete() 356 , m_Parent(parent) 357 , m_cmd_id ( id ) 358 { 359 setName(name); 360 setLabel(label); 361 setDescription(descr); 179 362 } 180 363 181 364 bool 182 PhantomPowerControl::setValue(int v) 183 { 184 if (v != 0 && v != 1) return false; 185 186 FocusriteVendorDependentCmd cmd( m_Parent.get1394Service() ); 187 cmd.setCommandType( AVC::AVCCommand::eCT_Control ); 188 cmd.setNodeId( m_Parent.getConfigRom().getNodeId() ); 189 cmd.setVerbose( getDebugLevel() ); 190 cmd.m_id=m_channel; 191 cmd.m_value=v; 192 193 if ( !cmd.fire() ) { 194 debugError( "FocusriteVendorDependentCmd info command failed\n" ); 195 // shouldn't this be an error situation? 365 BinaryControl::setValue(int v) 366 { 367 uint32_t val=0; 368 if (v) val=1; 369 370 if ( !m_Parent.setSpecificValue(m_cmd_id, val) ) { 371 debugError( "setSpecificValue failed\n" ); 196 372 return false; 197 } 198 return true; 373 } else return true; 199 374 } 200 375 201 376 int 202 PhantomPowerControl::getValue() 203 { 204 FocusriteVendorDependentCmd cmd( m_Parent.get1394Service() ); 205 cmd.setCommandType( AVC::AVCCommand::eCT_Status ); 206 cmd.setNodeId( m_Parent.getConfigRom().getNodeId() ); 207 cmd.setVerbose( getDebugLevel() ); 208 cmd.m_id=m_channel; 209 cmd.m_value=0; 210 211 if ( !cmd.fire() ) { 212 debugError( "FocusriteVendorDependentCmd info command failed\n" ); 213 // shouldn't this be an error situation? 377 BinaryControl::getValue() 378 { 379 uint32_t val=0; 380 381 if ( !m_Parent.getSpecificValue(m_cmd_id, &val) ) { 382 debugError( "getSpecificValue failed\n" ); 214 383 return 0; 215 } 216 217 return cmd.m_value; 218 } 219 384 } else return val; 385 } 386 387 // --- element implementation classes 388 389 VolumeControl::VolumeControl(SaffireProDevice& parent, int id) 390 : Control::Discrete() 391 , m_Parent(parent) 392 , m_cmd_id ( id ) 393 {} 394 VolumeControl::VolumeControl(SaffireProDevice& parent, int id, 395 std::string name, std::string label, std::string descr) 396 : Control::Discrete() 397 , m_Parent(parent) 398 , m_cmd_id ( id ) 399 { 400 setName(name); 401 setLabel(label); 402 setDescription(descr); 403 } 404 405 406 bool 407 VolumeControl::setValue(int v) 408 { 409 if (v>0x07FFF) v=0x07FFF; 410 else if (v<0) v=0; 411 412 if ( !m_Parent.setSpecificValue(m_cmd_id, v) ) { 413 debugError( "setSpecificValue failed\n" ); 414 return false; 415 } else return true; 416 } 417 418 int 419 VolumeControl::getValue() 420 { 421 uint32_t val=0; 422 423 if ( !m_Parent.getSpecificValue(m_cmd_id, &val) ) { 424 debugError( "getSpecificValue failed\n" ); 425 return 0; 426 } else return val; 427 } 220 428 221 429 } // Focusrite trunk/libffado/src/bebob/focusrite/focusrite_device.h
r585 r619 36 36 class SaffireProDevice; 37 37 38 class PhantomPowerControl38 class BinaryControl 39 39 : public Control::Discrete 40 40 { 41 41 public: 42 PhantomPowerControl(SaffireProDevice& parent, int channel); 42 BinaryControl(SaffireProDevice& parent, int id); 43 BinaryControl(SaffireProDevice& parent, int id, 44 std::string name, std::string label, std::string descr); 43 45 44 46 virtual bool setValue(int v); … … 47 49 private: 48 50 SaffireProDevice& m_Parent; 49 unsigned int m_channel; 51 unsigned int m_cmd_id; 52 }; 53 54 class VolumeControl 55 : public Control::Discrete 56 { 57 public: 58 VolumeControl(SaffireProDevice& parent, int id); 59 VolumeControl(SaffireProDevice& parent, int id, 60 std::string name, std::string label, std::string descr); 61 62 virtual bool setValue(int v); 63 virtual int getValue(); 64 65 private: 66 SaffireProDevice& m_Parent; 67 unsigned int m_cmd_id; 50 68 }; 51 69 … … 63 81 virtual int getSamplingFrequency( ); 64 82 83 public: 84 bool setSpecificValue(uint32_t id, uint32_t v); 85 bool getSpecificValue(uint32_t id, uint32_t *v); 86 65 87 private: 66 PhantomPowerControl * m_Phantom1; 67 PhantomPowerControl * m_Phantom2; 88 BinaryControl * m_Phantom1; 89 BinaryControl * m_Phantom2; 90 91 BinaryControl * m_Insert1; 92 BinaryControl * m_Insert2; 93 BinaryControl * m_AC3pass; 94 BinaryControl * m_MidiTru; 95 96 VolumeControl * m_Output12[4]; 97 VolumeControl * m_Output34[6]; 98 VolumeControl * m_Output56[6]; 99 VolumeControl * m_Output78[6]; 100 VolumeControl * m_Output910[6]; 101 68 102 }; 69 103