root/branches/libffado-2.0/src/bebob/terratec/terratec_device.cpp

Revision 1558, 4.2 kB (checked in by ppalmers, 15 years ago)

add firmware check for Terratec Phase88 (click/pop issue)

Line 
1 /*
2  * Copyright (C) 2005-2008 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) version 3 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #include "terratec_device.h"
25 #include "src/bebob/bebob_dl_mgr.h"
26 #include "src/bebob/bebob_dl_bcd.h"
27
28 namespace BeBoB {
29 namespace Terratec {
30
31 Phase88Device::Phase88Device(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ))
32     : BeBoB::AvDevice( d, configRom)
33 {
34     debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Terratec::Phase88Device (NodeID %d)\n",
35                  getConfigRom().getNodeId() );
36     updateClockSources();
37 }
38
39 Phase88Device::~Phase88Device()
40 {
41 }
42
43 void
44 Phase88Device::showDevice()
45 {
46     debugOutput(DEBUG_LEVEL_NORMAL, "This is a BeBoB::Terratec::Phase88Device\n");
47     BeBoB::AvDevice::showDevice();
48 }
49
50 bool
51 Phase88Device::discover()
52 {
53     BeBoB::BootloaderManager blMgr( get1394Service(), getNodeId() );
54     blMgr.printInfoRegisters();
55     if (blMgr.getSoftwareVersion() < 0x01120d1f) {
56         debugError("The firmware of this Phase88 device is too old. Please update the firmware.\n");
57         return false;
58     }
59     return BeBoB::AvDevice::discover();
60 }
61
62 void
63 Phase88Device::updateClockSources() {
64     m_internal_clocksource.type = FFADODevice::eCT_Internal;
65     m_internal_clocksource.valid = true;
66     m_internal_clocksource.locked = true;
67     m_internal_clocksource.id = 0;
68     m_internal_clocksource.slipping = false;
69     m_internal_clocksource.description = "Internal";
70
71     m_spdif_clocksource.type = FFADODevice::eCT_SPDIF;
72     m_spdif_clocksource.valid = true;
73     m_spdif_clocksource.locked = false;
74     m_spdif_clocksource.id = 1;
75     m_spdif_clocksource.slipping = false;
76     m_spdif_clocksource.description = "S/PDIF";
77
78     m_wordclock_clocksource.type = FFADODevice::eCT_WordClock;
79     m_wordclock_clocksource.valid = true;
80     m_wordclock_clocksource.locked = false;
81     m_wordclock_clocksource.id = 2;
82     m_wordclock_clocksource.slipping = false;
83     m_wordclock_clocksource.description = "WordClock";
84 }
85
86 FFADODevice::ClockSource
87 Phase88Device::getActiveClockSource() {
88     int fb_extsync_value = getSelectorFBValue(8);
89     int fb_syncsource_value = getSelectorFBValue(9);
90
91     debugOutput(DEBUG_LEVEL_VERBOSE,
92                 "Selectors: 0x%02X 0x%02X\n",
93                 fb_extsync_value, fb_syncsource_value);
94
95
96     if(fb_syncsource_value == 0) {
97         return m_internal_clocksource;
98     } else {
99         if(fb_extsync_value == 0) {
100             return m_spdif_clocksource;
101         } else {
102             return m_wordclock_clocksource;
103         }
104     }
105 }
106
107 bool
108 Phase88Device::setActiveClockSource(ClockSource s) {
109     if(s.id == m_internal_clocksource.id) {
110         return setSelectorFBValue(9, 0);
111     }
112     if(s.id == m_spdif_clocksource.id) {
113         bool retval = true;
114         retval &= setSelectorFBValue(8, 0);
115         retval &= setSelectorFBValue(9, 1);
116         return retval;
117     }
118     if(s.id == m_wordclock_clocksource.id) {
119         bool retval = true;
120         retval &= setSelectorFBValue(8, 1);
121         retval &= setSelectorFBValue(9, 1);
122         return retval;
123     }
124     return false;
125 }
126
127 FFADODevice::ClockSourceVector
128 Phase88Device::getSupportedClockSources() {
129     FFADODevice::ClockSourceVector r;
130     r.push_back(m_internal_clocksource);
131     r.push_back(m_spdif_clocksource);
132     r.push_back(m_wordclock_clocksource);
133     return r;
134 }
135
136 uint16_t
137 Phase88Device::getConfigurationIdSyncMode()
138 {
139     uint8_t fb_extsync_value = getSelectorFBValue(8);
140     uint8_t fb_syncsource_value = getSelectorFBValue(9);
141     return (fb_extsync_value & 0x01) | ((fb_syncsource_value << 1) & 0x01);
142 }
143
144 } // namespace Terratec
145 } // namespace BeBoB
Note: See TracBrowser for help on using the browser.