root/trunk/libffado/src/bebob/terratec/terratec_device.cpp

Revision 1543, 4.0 kB (checked in by ppalmers, 13 years ago)

- Clean up class names
- Change probe code for all devices (except MOTU) to use the config file based approach

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
26 namespace BeBoB {
27 namespace Terratec {
28
29 Phase88Device::Phase88Device(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ))
30     : BeBoB::Device( d, configRom)
31 {
32     debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Terratec::Phase88Device (NodeID %d)\n",
33                  getConfigRom().getNodeId() );
34     updateClockSources();
35 }
36
37 Phase88Device::~Phase88Device()
38 {
39 }
40
41 void
42 Phase88Device::showDevice()
43 {
44     debugOutput(DEBUG_LEVEL_NORMAL, "This is a BeBoB::Terratec::Phase88Device\n");
45     BeBoB::Device::showDevice();
46 }
47 /*                'externalsync': ['/Mixer/Selector_8', self.comboExtSync],
48                 'syncsource':   ['/Mixer/Selector_9', self.comboSyncSource], */
49 void
50 Phase88Device::updateClockSources() {
51     m_internal_clocksource.type = FFADODevice::eCT_Internal;
52     m_internal_clocksource.valid = true;
53     m_internal_clocksource.locked = true;
54     m_internal_clocksource.id = 0;
55     m_internal_clocksource.slipping = false;
56     m_internal_clocksource.description = "Internal";
57
58     m_spdif_clocksource.type = FFADODevice::eCT_SPDIF;
59     m_spdif_clocksource.valid = true;
60     m_spdif_clocksource.locked = false;
61     m_spdif_clocksource.id = 1;
62     m_spdif_clocksource.slipping = false;
63     m_spdif_clocksource.description = "S/PDIF";
64
65     m_wordclock_clocksource.type = FFADODevice::eCT_WordClock;
66     m_wordclock_clocksource.valid = true;
67     m_wordclock_clocksource.locked = false;
68     m_wordclock_clocksource.id = 2;
69     m_wordclock_clocksource.slipping = false;
70     m_wordclock_clocksource.description = "WordClock";
71 }
72
73 FFADODevice::ClockSource
74 Phase88Device::getActiveClockSource() {
75     int fb_extsync_value = getSelectorFBValue(8);
76     int fb_syncsource_value = getSelectorFBValue(9);
77
78     debugOutput(DEBUG_LEVEL_VERBOSE,
79                 "Selectors: 0x%02X 0x%02X\n",
80                 fb_extsync_value, fb_syncsource_value);
81
82
83     if(fb_syncsource_value == 0) {
84         return m_internal_clocksource;
85     } else {
86         if(fb_extsync_value == 0) {
87             return m_spdif_clocksource;
88         } else {
89             return m_wordclock_clocksource;
90         }
91     }
92 }
93
94 bool
95 Phase88Device::setActiveClockSource(ClockSource s) {
96     if(s.id == m_internal_clocksource.id) {
97         return setSelectorFBValue(9, 0);
98     }
99     if(s.id == m_spdif_clocksource.id) {
100         bool retval = true;
101         retval &= setSelectorFBValue(8, 0);
102         retval &= setSelectorFBValue(9, 1);
103         return retval;
104     }
105     if(s.id == m_wordclock_clocksource.id) {
106         bool retval = true;
107         retval &= setSelectorFBValue(8, 1);
108         retval &= setSelectorFBValue(9, 1);
109         return retval;
110     }
111     return false;
112 }
113
114 FFADODevice::ClockSourceVector
115 Phase88Device::getSupportedClockSources() {
116     FFADODevice::ClockSourceVector r;
117     r.push_back(m_internal_clocksource);
118     r.push_back(m_spdif_clocksource);
119     r.push_back(m_wordclock_clocksource);
120     return r;
121 }
122
123 uint16_t
124 Phase88Device::getConfigurationIdSyncMode()
125 {
126     uint8_t fb_extsync_value = getSelectorFBValue(8);
127     uint8_t fb_syncsource_value = getSelectorFBValue(9);
128     return (fb_extsync_value & 0x01) | ((fb_syncsource_value << 1) & 0x01);
129 }
130
131 } // namespace Terratec
132 } // namespace BeBoB
Note: See TracBrowser for help on using the browser.