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

Revision 1719, 4.1 kB (checked in by ppalmers, 14 years ago)

fix some compilation issues with the PRO24 code

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     getEAP()->deleteElement(m_ch1);
45     getEAP()->deleteElement(m_ch2);
46     if (m_ch1) delete m_ch1;
47     if (m_ch2) delete m_ch2;
48 }
49
50 bool SaffirePro24::discover() {
51     if (Dice::Device::discover()) {
52         fb_quadlet_t* tmp = (fb_quadlet_t *)calloc(2, sizeof(fb_quadlet_t));
53         getEAP()->readRegBlock(Dice::Device::EAP::eRT_Application, 0x58, tmp, 2*sizeof(fb_quadlet_t));
54         hexDumpQuadlets(tmp, 2);
55
56         m_ch1 = new LineInstSwitch(getEAP(), "LineInstCh1", 0x58, 2);
57         getEAP()->addElement(m_ch1);
58         m_ch2 = new LineInstSwitch(getEAP(), "LineInstCh2", 0x58, 2<<16);
59         getEAP()->addElement(m_ch2);
60         m_ch3 = new LevelSwitch(getEAP(), "LevelCh3", 0x5C, 1);
61         getEAP()->addElement(m_ch3);
62         m_ch4 = new LevelSwitch(getEAP(), "LevelCh4", 0x5C, 1<<16);
63         getEAP()->addElement(m_ch4);
64         return true;
65     }
66     return false;
67 }
68
69 void SaffirePro24::showDevice()
70 {
71     debugOutput(DEBUG_LEVEL_VERBOSE, "This is a Dice::Focusrite::SaffirePro24\n");
72     Dice::Device::showDevice();
73 }
74
75 bool SaffirePro24::setNickName( std::string name ) {
76     return getEAP()->writeRegBlock( Dice::Device::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name.c_str(), name.size() );
77 }
78
79 std::string SaffirePro24::getNickName() {
80     char name[16];
81     getEAP()->readRegBlock( Dice::Device::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name, 16 );
82     return std::string( name );
83 }
84
85 SaffirePro24::LineInstSwitch::LineInstSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue )
86     : Control::Enum(eap, name)
87     , m_eap(eap)
88     , m_selected(0)
89     , m_offset(offset)
90     , m_activevalue(activevalue)
91 {
92     m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp);
93     printf("%s: Active?%i\n", name.c_str(), m_state_tmp&m_activevalue);
94     m_selected = (m_state_tmp&m_activevalue)?1:0;
95 }
96
97 int SaffirePro24::LineInstSwitch::selected() {
98     return m_selected;
99 }
100
101 bool SaffirePro24::LineInstSwitch::select(int n) {
102     if ( n != m_selected ) {
103         m_selected = n;
104         m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp);
105         m_eap->writeReg(Dice::Device::EAP::eRT_Application, m_offset, m_state_tmp^m_activevalue);
106         m_eap->writeReg(Dice::Device::EAP::eRT_Application, msgSet, 4);
107     }
108     return true;
109 }
110 std::string SaffirePro24::LineInstSwitch::getEnumLabel(int n) {
111     if ( n == 1 ) {
112         return "Instrument";
113     }
114     return "Line";
115 }
116
117 SaffirePro24::LevelSwitch::LevelSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue)
118     : LineInstSwitch(eap, name, offset, activevalue)
119 {
120 }
121 std::string SaffirePro24::LevelSwitch::getEnumLabel(int n) {
122     switch (n) {
123         case 0:
124             return "Low";
125         case 1:
126             return "High";
127         default:
128             return "";
129     }
130 }
131
132
133 }
134 }
135
136 // vim: et
Note: See TracBrowser for help on using the browser.