root/trunk/libffado/src/dice/focusrite/saffire_pro24.cpp

Revision 1718, 4.1 kB (checked in by arnonym, 14 years ago)

Switching line/inst on channels 1+2 and low/high in channels 3+4 works now with the dbus-interface. Mixer is coming soon.

Gotta ask back whether I am allowed to add the full description of the application-space here for all to see.

Line 
1 /*
2  * Copyright (C) 2009 by Pieter Palmers
3  * Copyright (C) 2009 by Arnold Krille
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 2 of the License, or
13  * (at your option) version 3 of the License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #include "saffire_pro24.h"
26
27 namespace Dice {
28 namespace Focusrite {
29
30 const int msgSet = 0x68;
31
32 SaffirePro24::SaffirePro24( DeviceManager& d,
33                                         std::auto_ptr<ConfigRom>( configRom ))
34     : Dice::Device(d , configRom)
35     , m_ch1(NULL)
36     , m_ch2(NULL)
37 {
38     debugOutput(DEBUG_LEVEL_VERBOSE, "Created Dice::Focusrite::SaffirePro24 (NodeID %d)\n",
39                 getConfigRom().getNodeId());
40 }
41
42 SaffirePro24::~SaffirePro24()
43 {
44     m_eap->deleteElement(m_ch1);
45     m_eap->deleteElement(m_ch2);
46     if (m_ch1) delete m_ch1;
47     if (m_ch2) delete m_ch2;
48 }
49 bool SaffirePro24::discover() {
50     if (Dice::Device::discover()) {
51         fb_quadlet_t* tmp = (fb_quadlet_t *)calloc(2, sizeof(fb_quadlet_t));
52         m_eap->readRegBlock(Dice::Device::EAP::eRT_Application, 0x58, tmp, 2*sizeof(fb_quadlet_t));
53         hexDumpQuadlets(tmp, 2);
54
55         m_ch1 = new LineInstSwitch(getEAP(), "LineInstCh1", 0x58, 2);
56         getEAP()->addElement(m_ch1);
57         m_ch2 = new LineInstSwitch(getEAP(), "LineInstCh2", 0x58, 2<<16);
58         getEAP()->addElement(m_ch2);
59         m_ch3 = new LevelSwitch(getEAP(), "LevelCh3", 0x5C, 1);
60         getEAP()->addElement(m_ch3);
61         m_ch4 = new LevelSwitch(getEAP(), "LevelCh4", 0x5C, 1<<16);
62         getEAP()->addElement(m_ch4);
63         return true;
64     }
65     return false;
66 }
67 void SaffirePro24::showDevice()
68 {
69     debugOutput(DEBUG_LEVEL_VERBOSE, "This is a Dice::Focusrite::SaffirePro24\n");
70     Dice::Device::showDevice();
71 }
72 bool SaffirePro24::setNickName( std::string name ) {
73     return m_eap->writeRegBlock( Dice::Device::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name.c_str(), name.size() );
74 }
75 std::string SaffirePro24::getNickName() {
76     char name[16];
77     m_eap->readRegBlock( Dice::Device::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name, 16 );
78     return std::string( name );
79 }
80
81
82 SaffirePro24::LineInstSwitch::LineInstSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue )
83     : Control::Enum(eap, name)
84     , m_eap(eap)
85     , m_selected(0)
86     , m_offset(offset)
87     , m_activevalue(activevalue)
88 {
89     m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp);
90     printf("%s: Active?%i\n", name.c_str(), m_state_tmp&m_activevalue);
91     m_selected = (m_state_tmp&m_activevalue)?1:0;
92 }
93 int SaffirePro24::LineInstSwitch::selected() {
94     return m_selected;
95 }
96 bool SaffirePro24::LineInstSwitch::select(int n) {
97     if ( n != m_selected ) {
98         m_selected = n;
99         m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp);
100         m_eap->writeReg(Dice::Device::EAP::eRT_Application, m_offset, m_state_tmp^m_activevalue);
101         m_eap->writeReg(Dice::Device::EAP::eRT_Application, msgSet, 4);
102     }
103     return true;
104 }
105 std::string SaffirePro24::LineInstSwitch::getEnumLabel(int n) {
106     if ( n == 1 ) {
107         return "Instrument";
108     }
109     return "Line";
110 }
111
112 SaffirePro24::LevelSwitch::LevelSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue)
113     : LineInstSwitch(eap, name, offset, activevalue)
114 {
115 }
116 std::string SaffirePro24::LevelSwitch::getEnumLabel(int n) {
117     switch (n) {
118         case 0:
119             return "Low";
120         case 1:
121             return "High";
122         default:
123             return "";
124     }
125 }
126
127
128 }
129 }
130
131 // vim: et
Note: See TracBrowser for help on using the browser.