Changeset 1336 for trunk/libffado/src/fireworks/fireworks_control.cpp
- Timestamp:
- 09/23/08 03:42:04 (16 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/fireworks/fireworks_control.cpp
r1158 r1336 28 28 #include "efc/efc_cmds_mixer.h" 29 29 #include "efc/efc_cmds_monitor.h" 30 #include "efc/efc_cmds_hardware_ctrl.h" 30 31 31 32 #include <string> … … 40 41 : Control::MatrixMixer(&p, "MonitorControl") 41 42 , m_control(c) 42 , m_Parent (p)43 , m_ParentDevice(p) 43 44 { 44 45 } … … 47 48 : Control::MatrixMixer(&p, n) 48 49 , m_control(c) 49 , m_Parent (p)50 , m_ParentDevice(p) 50 51 { 51 52 } … … 86 87 bool did_command=false; 87 88 88 if(row >= (int)m_Parent .getHwInfo().m_nb_phys_audio_in) {89 if(row >= (int)m_ParentDevice.getHwInfo().m_nb_phys_audio_in) { 89 90 debugError("specified row (%u) larger than number of rows (%d)\n", 90 row, m_Parent .getHwInfo().m_nb_phys_audio_in);91 row, m_ParentDevice.getHwInfo().m_nb_phys_audio_in); 91 92 return 0.0; 92 93 } 93 if(col >= (int)m_Parent .getHwInfo().m_nb_phys_audio_out) {94 if(col >= (int)m_ParentDevice.getHwInfo().m_nb_phys_audio_out) { 94 95 debugError("specified col (%u) larger than number of cols (%d)\n", 95 col, m_Parent .getHwInfo().m_nb_phys_audio_out);96 col, m_ParentDevice.getHwInfo().m_nb_phys_audio_out); 96 97 return 0.0; 97 98 } 98 99 100 // not a switch since we create variables 99 101 if(m_control==eMC_Gain) { 100 102 EfcSetMonitorGainCmd setCmd; 101 setCmd.m_input=row; 102 setCmd.m_output=col; 103 setCmd.m_value=(uint32_t)val; 104 if (!m_Parent.doEfcOverAVC(setCmd)) 105 { 106 debugFatal("Cmd failed\n"); 107 } 108 retval=setCmd.m_value; 109 did_command=true; 103 setCmd.m_input = row; 104 setCmd.m_output = col; 105 setCmd.m_value = (uint32_t)val; 106 if (!m_ParentDevice.doEfcOverAVC(setCmd)) 107 { 108 debugError("Cmd failed\n"); 109 } 110 // update the session block 111 m_ParentDevice.m_session.h.monitorgains[row][col] = setCmd.m_value; 112 retval = setCmd.m_value; 113 did_command = true; 110 114 } 111 115 if(m_control==eMC_Pan) { 112 116 EfcSetMonitorPanCmd setCmd; 113 setCmd.m_input=row; 114 setCmd.m_output=col; 115 setCmd.m_value=(uint32_t)val; 116 if (!m_Parent.doEfcOverAVC(setCmd)) 117 { 118 debugFatal("Cmd failed\n"); 119 } 120 retval=setCmd.m_value; 121 did_command=true; 117 setCmd.m_input = row; 118 setCmd.m_output = col; 119 setCmd.m_value = (uint32_t)val; 120 if (!m_ParentDevice.doEfcOverAVC(setCmd)) 121 { 122 debugError("Cmd failed\n"); 123 } 124 // update the session block 125 m_ParentDevice.m_session.s.monitorpans[row][col] = setCmd.m_value; 126 retval = setCmd.m_value; 127 did_command = true; 122 128 } 123 129 if(m_control==eMC_Mute) { 124 130 EfcSetMonitorMuteCmd setCmd; 125 setCmd.m_input=row; 126 setCmd.m_output=col; 127 setCmd.m_value=(uint32_t)val; 128 if (!m_Parent.doEfcOverAVC(setCmd)) 129 { 130 debugFatal("Cmd failed\n"); 131 } 132 retval=setCmd.m_value; 133 did_command=true; 131 setCmd.m_input = row; 132 setCmd.m_output = col; 133 setCmd.m_value = (uint32_t)val; 134 if (!m_ParentDevice.doEfcOverAVC(setCmd)) 135 { 136 debugError("Cmd failed\n"); 137 } 138 // update the session block 139 if(setCmd.m_value) { 140 m_ParentDevice.m_session.s.monitorflags[row][col] |= ECHO_SESSION_MUTE_BIT; 141 } else { 142 m_ParentDevice.m_session.s.monitorflags[row][col] &= ~ECHO_SESSION_MUTE_BIT; 143 } 144 retval = setCmd.m_value; 145 did_command = true; 134 146 } 135 147 if(m_control==eMC_Solo) { 136 148 EfcSetMonitorSoloCmd setCmd; 137 setCmd.m_input=row; 138 setCmd.m_output=col; 139 setCmd.m_value=(uint32_t)val; 140 if (!m_Parent.doEfcOverAVC(setCmd)) 141 { 142 debugFatal("Cmd failed\n"); 143 } 144 retval=setCmd.m_value; 145 did_command=true; 149 setCmd.m_input = row; 150 setCmd.m_output = col; 151 setCmd.m_value = (uint32_t)val; 152 if (!m_ParentDevice.doEfcOverAVC(setCmd)) 153 { 154 debugError("Cmd failed\n"); 155 } 156 // update the session block 157 if(setCmd.m_value) { 158 m_ParentDevice.m_session.s.monitorflags[row][col] |= ECHO_SESSION_SOLO_BIT; 159 } else { 160 m_ParentDevice.m_session.s.monitorflags[row][col] &= ~ECHO_SESSION_SOLO_BIT; 161 } 162 retval = setCmd.m_value; 163 did_command = true; 146 164 } 147 165 … … 160 178 bool did_command=false; 161 179 162 if(row >= (int)m_Parent .getHwInfo().m_nb_phys_audio_in) {180 if(row >= (int)m_ParentDevice.getHwInfo().m_nb_phys_audio_in) { 163 181 debugError("specified row (%u) larger than number of rows (%d)\n", 164 row, m_Parent .getHwInfo().m_nb_phys_audio_in);182 row, m_ParentDevice.getHwInfo().m_nb_phys_audio_in); 165 183 return 0.0; 166 184 } 167 if(col >= (int)m_Parent .getHwInfo().m_nb_phys_audio_out) {185 if(col >= (int)m_ParentDevice.getHwInfo().m_nb_phys_audio_out) { 168 186 debugError("specified col (%u) larger than number of cols (%d)\n", 169 col, m_Parent .getHwInfo().m_nb_phys_audio_out);187 col, m_ParentDevice.getHwInfo().m_nb_phys_audio_out); 170 188 return 0.0; 171 189 } … … 175 193 getCmd.m_input=row; 176 194 getCmd.m_output=col; 177 if (!m_Parent .doEfcOverAVC(getCmd))178 { 179 debug Fatal("Cmd failed\n");195 if (!m_ParentDevice.doEfcOverAVC(getCmd)) 196 { 197 debugError("Cmd failed\n"); 180 198 } 181 199 retval=getCmd.m_value; … … 186 204 getCmd.m_input=row; 187 205 getCmd.m_output=col; 188 if (!m_Parent .doEfcOverAVC(getCmd))189 { 190 debug Fatal("Cmd failed\n");206 if (!m_ParentDevice.doEfcOverAVC(getCmd)) 207 { 208 debugError("Cmd failed\n"); 191 209 } 192 210 retval=getCmd.m_value; … … 197 215 getCmd.m_input=row; 198 216 getCmd.m_output=col; 199 if (!m_Parent .doEfcOverAVC(getCmd))200 { 201 debug Fatal("Cmd failed\n");217 if (!m_ParentDevice.doEfcOverAVC(getCmd)) 218 { 219 debugError("Cmd failed\n"); 202 220 } 203 221 retval=getCmd.m_value; … … 208 226 getCmd.m_input=row; 209 227 getCmd.m_output=col; 210 if (!m_Parent .doEfcOverAVC(getCmd))211 { 212 debug Fatal("Cmd failed\n");228 if (!m_ParentDevice.doEfcOverAVC(getCmd)) 229 { 230 debugError("Cmd failed\n"); 213 231 } 214 232 retval=getCmd.m_value; … … 227 245 int MonitorControl::getRowCount( ) 228 246 { 229 return m_Parent .getHwInfo().m_nb_phys_audio_in;247 return m_ParentDevice.getHwInfo().m_nb_phys_audio_in; 230 248 } 231 249 232 250 int MonitorControl::getColCount( ) 233 251 { 234 return m_Parent .getHwInfo().m_nb_phys_audio_out;252 return m_ParentDevice.getHwInfo().m_nb_phys_audio_out; 235 253 } 236 254 … … 243 261 : Control::Continuous(&p, "SimpleControl") 244 262 , m_Slave(new EfcGenericMixerCmd(t, c, channel)) 245 , m_Parent (p)263 , m_ParentDevice(p) 246 264 { 247 265 } … … 254 272 : Control::Continuous(&p, n) 255 273 , m_Slave(new EfcGenericMixerCmd(t, c, channel)) 256 , m_Parent (p)274 , m_ParentDevice(p) 257 275 { 258 276 } … … 273 291 if(m_Slave) { 274 292 m_Slave->setType(eCT_Set); 275 m_Slave->m_value =(uint32_t)val;276 if (!m_Parent .doEfcOverAVC(*m_Slave))277 { 278 debug Fatal("Cmd failed\n");293 m_Slave->m_value = (uint32_t)val; 294 if (!m_ParentDevice.doEfcOverAVC(*m_Slave)) 295 { 296 debugError("Cmd failed\n"); 279 297 return 0.0; 298 } 299 300 // update the session block 301 switch(m_Slave->getTarget()) { 302 case eMT_PlaybackMix: 303 switch(m_Slave->getCommand()) { 304 case eMC_Gain: 305 m_ParentDevice.m_session.h.playbackgains[m_Slave->m_channel] = m_Slave->m_value; 306 break; 307 default: // nothing 308 break; 309 } 310 break; 311 case eMT_PhysicalOutputMix: 312 switch(m_Slave->getCommand()) { 313 case eMC_Gain: 314 m_ParentDevice.m_session.h.outputgains[m_Slave->m_channel] = m_Slave->m_value; 315 break; 316 default: // nothing 317 break; 318 } 319 break; 320 default: // nothing 321 break; 280 322 } 281 323 debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for channel %d to %lf = %lf\n", … … 292 334 if(m_Slave) { 293 335 m_Slave->setType(eCT_Get); 294 if (!m_Parent .doEfcOverAVC(*m_Slave))295 { 296 debug Fatal("Cmd failed\n");336 if (!m_ParentDevice.doEfcOverAVC(*m_Slave)) 337 { 338 debugError("Cmd failed\n"); 297 339 return 0.0; 298 340 } … … 315 357 , m_bit(bit) 316 358 , m_Slave(new EfcGenericMixerCmd(t, c, channel)) 317 , m_Parent (p)359 , m_ParentDevice(p) 318 360 { 319 361 } … … 327 369 , m_bit(bit) 328 370 , m_Slave(new EfcGenericMixerCmd(t, c, channel)) 329 , m_Parent (p)371 , m_ParentDevice(p) 330 372 { 331 373 } … … 361 403 m_Slave->setType(eCT_Set); 362 404 m_Slave->m_value=reg; 363 if (!m_Parent .doEfcOverAVC(*m_Slave))364 { 365 debug Fatal("Cmd failed\n");405 if (!m_ParentDevice.doEfcOverAVC(*m_Slave)) 406 { 407 debugError("Cmd failed\n"); 366 408 return 0; 367 409 } 410 411 // update the session block 412 switch(m_Slave->getTarget()) { 413 case eMT_PlaybackMix: 414 switch(m_Slave->getCommand()) { 415 case eMC_Mute: 416 m_ParentDevice.m_session.s.playbacks[m_Slave->m_channel].mute = m_Slave->m_value; 417 break; 418 case eMC_Solo: 419 m_ParentDevice.m_session.s.playbacks[m_Slave->m_channel].solo = m_Slave->m_value; 420 break; 421 default: // nothing 422 break; 423 } 424 break; 425 case eMT_PhysicalOutputMix: 426 switch(m_Slave->getCommand()) { 427 case eMC_Mute: 428 m_ParentDevice.m_session.s.outputs[m_Slave->m_channel].mute = m_Slave->m_value; 429 break; 430 case eMC_Nominal: 431 m_ParentDevice.m_session.s.outputs[m_Slave->m_channel].shift = m_Slave->m_value; 432 break; 433 default: // nothing 434 break; 435 } 436 break; 437 case eMT_PhysicalInputMix: 438 switch(m_Slave->getCommand()) { 439 //case eMC_Pad: 440 // m_ParentDevice.m_session.s.inputs[m_Slave->m_channel].pad = m_Slave->m_value; 441 // break; 442 case eMC_Nominal: 443 m_ParentDevice.m_session.s.inputs[m_Slave->m_channel].shift = m_Slave->m_value; 444 break; 445 default: // nothing 446 break; 447 } 448 break; 449 default: // nothing 450 break; 451 } 452 368 453 debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for channel %d to %ld (reg: 0x%08X => 0x%08X)\n", 369 454 m_Slave->m_channel, val, old_reg, reg); … … 378 463 { 379 464 if(m_Slave) { 465 // workaround for the failing get nominal command for input channels 466 // get it from the session block 467 if ((m_Slave->getTarget() == eMT_PhysicalInputMix) 468 && (m_Slave->getCommand() == eMC_Nominal)) { 469 int val = m_ParentDevice.m_session.s.inputs[m_Slave->m_channel].shift; 470 debugOutput(DEBUG_LEVEL_VERBOSE, "input pad workaround: %08X\n", val); 471 return val; 472 } 380 473 m_Slave->setType(eCT_Get); 381 if (!m_Parent .doEfcOverAVC(*m_Slave))382 { 383 debug Fatal("Cmd failed\n");474 if (!m_ParentDevice.doEfcOverAVC(*m_Slave)) 475 { 476 debugError("Cmd failed\n"); 384 477 return 0; 385 478 } … … 394 487 } 395 488 489 // --- control element for flags 490 491 SpdifModeControl::SpdifModeControl(FireWorks::Device& parent) 492 : Control::Discrete(&parent, "SpdifModeControl") 493 , m_ParentDevice(parent) 494 { 495 } 496 497 SpdifModeControl::SpdifModeControl(FireWorks::Device& parent, 498 std::string n) 499 : Control::Discrete(&parent, n) 500 , m_ParentDevice(parent) 501 { 502 } 503 504 SpdifModeControl::~SpdifModeControl() 505 { 506 } 507 508 void SpdifModeControl::show() 509 { 510 debugOutput(DEBUG_LEVEL_NORMAL, "SpdifModeControl\n"); 511 } 512 513 bool SpdifModeControl::setValue( const int val ) 514 { 515 EfcChangeFlagsCmd setCmd; 516 if(val) { 517 setCmd.m_setmask = FIREWORKS_EFC_FLAG_SPDIF_PRO; 518 } else { 519 setCmd.m_clearmask = FIREWORKS_EFC_FLAG_SPDIF_PRO; 520 } 521 debugOutput(DEBUG_LEVEL_VERBOSE, "setValue val: %d setmask: %08X, clear: %08X\n", 522 val, setCmd.m_setmask, setCmd.m_clearmask); 523 if (!m_ParentDevice.doEfcOverAVC(setCmd)) 524 { 525 debugError("Cmd failed\n"); 526 return false; 527 } 528 return true; 529 } 530 531 int SpdifModeControl::getValue( ) 532 { 533 EfcGetFlagsCmd getCmd; 534 if (!m_ParentDevice.doEfcOverAVC(getCmd)) 535 { 536 debugError("Cmd failed\n"); 537 return 0; 538 } 539 debugOutput(DEBUG_LEVEL_VERBOSE, "got flags: %08X\n", 540 getCmd.m_flags); 541 if(getCmd.m_flags & FIREWORKS_EFC_FLAG_SPDIF_PRO) return 1; 542 else return 0; 543 } 544 396 545 // --- io config controls 397 546 … … 400 549 : Control::Discrete(&parent, "IOConfigControl") 401 550 , m_Slave(new EfcGenericIOConfigCmd(r)) 402 , m_Parent (parent)551 , m_ParentDevice(parent) 403 552 { 404 553 } … … 409 558 : Control::Discrete(&parent, n) 410 559 , m_Slave(new EfcGenericIOConfigCmd(r)) 411 , m_Parent (parent)560 , m_ParentDevice(parent) 412 561 { 413 562 } … … 429 578 m_Slave->setType(eCT_Set); 430 579 m_Slave->m_value=val; 431 if (!m_Parent .doEfcOverAVC(*m_Slave))432 { 433 debug Fatal("Cmd failed\n");580 if (!m_ParentDevice.doEfcOverAVC(*m_Slave)) 581 { 582 debugError("Cmd failed\n"); 434 583 return 0; 435 584 } … … 446 595 if(m_Slave) { 447 596 m_Slave->setType(eCT_Get); 448 if (!m_Parent .doEfcOverAVC(*m_Slave))449 { 450 debug Fatal("Cmd failed\n");597 if (!m_ParentDevice.doEfcOverAVC(*m_Slave)) 598 { 599 debugError("Cmd failed\n"); 451 600 return 0; 452 601 } … … 460 609 } 461 610 462 611 // control to get hardware information 612 HwInfoControl::HwInfoControl(FireWorks::Device& p, 613 enum eHwInfoField f) 614 : Control::Discrete(&p, "HwInfoControl") 615 , m_ParentDevice(p) 616 , m_Field(f) 617 { 618 } 619 620 HwInfoControl::HwInfoControl(FireWorks::Device& p, 621 enum eHwInfoField f, 622 std::string n) 623 : Control::Discrete(&p, n) 624 , m_ParentDevice(p) 625 , m_Field(f) 626 { 627 } 628 629 HwInfoControl::~HwInfoControl() 630 { 631 } 632 633 int HwInfoControl::getValue() 634 { 635 switch (m_Field) { 636 case eHIF_PhysicalAudioOutCount: 637 return m_ParentDevice.getHwInfo().m_nb_phys_audio_out; 638 case eHIF_PhysicalAudioInCount: 639 return m_ParentDevice.getHwInfo().m_nb_phys_audio_in; 640 case eHIF_1394PlaybackCount: 641 return m_ParentDevice.getHwInfo().m_nb_1394_playback_channels; 642 case eHIF_1394RecordCount: 643 return m_ParentDevice.getHwInfo().m_nb_1394_record_channels; 644 case eHIF_GroupOutCount: 645 return m_ParentDevice.getHwInfo().m_nb_out_groups; 646 case eHIF_GroupInCount: 647 return m_ParentDevice.getHwInfo().m_nb_in_groups; 648 case eHIF_PhantomPower: 649 return m_ParentDevice.getHwInfo().hasSoftwarePhantom(); 650 default: 651 debugError("Bogus field\n"); 652 return 0; 653 } 654 } 655 656 void HwInfoControl::show() 657 { 658 debugOutput(DEBUG_LEVEL_NORMAL, "HwInfoControl\n"); 659 } 660 661 662 // control to save settings 663 MultiControl::MultiControl(FireWorks::Device& p, enum eType t) 664 : Control::Discrete(&p, "MultiControl") 665 , m_ParentDevice(p) 666 , m_Type(t) 667 { 668 } 669 670 MultiControl::MultiControl(FireWorks::Device& p, 671 enum eType t, std::string n) 672 : Control::Discrete(&p, n) 673 , m_ParentDevice(p) 674 , m_Type(t) 675 { 676 } 677 678 MultiControl::~MultiControl() 679 { 680 } 681 682 bool MultiControl::setValue(const int v) 683 { 684 switch(m_Type) { 685 case eT_SaveSession: 686 debugOutput(DEBUG_LEVEL_VERBOSE, "saving session\n"); 687 return m_ParentDevice.saveSession(); 688 case eT_Identify: 689 debugOutput(DEBUG_LEVEL_VERBOSE, "indentify device\n"); 690 { 691 EfcIdentifyCmd cmd; 692 if (!m_ParentDevice.doEfcOverAVC(cmd)) 693 { 694 debugError("Cmd failed\n"); 695 return false; 696 } 697 } 698 return true; 699 default: 700 debugError("Bad type\n"); 701 return false; 702 } 703 } 704 705 void MultiControl::show() 706 { 707 debugOutput(DEBUG_LEVEL_NORMAL, "MultiControl\n"); 708 switch(m_Type) { 709 case eT_SaveSession: 710 debugOutput(DEBUG_LEVEL_NORMAL, "Type: SaveSession\n"); 711 break; 712 case eT_Identify: 713 debugOutput(DEBUG_LEVEL_NORMAL, "Type: Identify\n"); 714 break; 715 default: 716 debugError("Bad type\n"); 717 } 718 } 463 719 464 720 } // FireWorks