1 |
/* |
---|
2 |
* Copyright (C) 2013 by Takashi Sakamoto |
---|
3 |
* Copyright (C) 2005-2008 by Pieter Palmers |
---|
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 "yamaha_avdevice.h" |
---|
26 |
#include "yamaha_cmd.h" |
---|
27 |
|
---|
28 |
namespace BeBoB { |
---|
29 |
namespace Yamaha { |
---|
30 |
|
---|
31 |
GoDevice::GoDevice(DeviceManager& d, ffado_smartptr<ConfigRom>( configRom )) |
---|
32 |
: BeBoB::Device( d, configRom) |
---|
33 |
{ |
---|
34 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::Yamaha::GoDevice (NodeID %d)\n", |
---|
35 |
getConfigRom().getNodeId() ); |
---|
36 |
updateClockSources(); |
---|
37 |
} |
---|
38 |
|
---|
39 |
GoDevice::~GoDevice() |
---|
40 |
{ |
---|
41 |
} |
---|
42 |
|
---|
43 |
void |
---|
44 |
GoDevice::showDevice() |
---|
45 |
{ |
---|
46 |
debugOutput(DEBUG_LEVEL_NORMAL, "This is a BeBoB::Yamaha::GoDevice\n"); |
---|
47 |
BeBoB::Device::showDevice(); |
---|
48 |
} |
---|
49 |
|
---|
50 |
bool |
---|
51 |
GoDevice::updateClockSources() |
---|
52 |
{ |
---|
53 |
int err; |
---|
54 |
|
---|
55 |
m_internal_clocksource.type = FFADODevice::eCT_Internal; |
---|
56 |
m_internal_clocksource.valid = true; |
---|
57 |
m_internal_clocksource.active = false; |
---|
58 |
m_internal_clocksource.locked = true; |
---|
59 |
m_internal_clocksource.id = 0; |
---|
60 |
m_internal_clocksource.slipping = false; |
---|
61 |
m_internal_clocksource.description = "Internal"; |
---|
62 |
|
---|
63 |
m_spdif_clocksource.type = FFADODevice::eCT_SPDIF; |
---|
64 |
m_spdif_clocksource.valid = true; |
---|
65 |
m_spdif_clocksource.active = false; |
---|
66 |
m_spdif_clocksource.locked = false; |
---|
67 |
m_spdif_clocksource.id = 1; |
---|
68 |
m_spdif_clocksource.slipping = false; |
---|
69 |
m_spdif_clocksource.description = "S/PDIF"; |
---|
70 |
|
---|
71 |
/* detect digital input */ |
---|
72 |
YamahaDigInDetectCmd cmd ( get1394Service() ); |
---|
73 |
cmd.setCommandType( AVC::AVCCommand::eCT_Status ); |
---|
74 |
cmd.setNodeId( getConfigRom().getNodeId() ); |
---|
75 |
cmd.setVerbose( getDebugLevel() ); |
---|
76 |
if ( !cmd.fire() ) { |
---|
77 |
debugError( "YamahaDigInDetectCmd failed\n" ); |
---|
78 |
return false; |
---|
79 |
} else if (cmd.m_digin == 0) { |
---|
80 |
m_spdif_clocksource.locked = true; |
---|
81 |
} |
---|
82 |
|
---|
83 |
/* get current clock source */ |
---|
84 |
err = getSelectorFBValue(4); |
---|
85 |
if (err < 0) |
---|
86 |
return err; |
---|
87 |
else if (err > 0) { |
---|
88 |
m_active_clocksource = &m_spdif_clocksource; |
---|
89 |
m_spdif_clocksource.active = true; |
---|
90 |
} else { |
---|
91 |
m_active_clocksource = &m_internal_clocksource; |
---|
92 |
m_internal_clocksource.active = true; |
---|
93 |
} |
---|
94 |
|
---|
95 |
return true; |
---|
96 |
} |
---|
97 |
|
---|
98 |
FFADODevice::ClockSource |
---|
99 |
GoDevice::getActiveClockSource() |
---|
100 |
{ |
---|
101 |
if (!updateClockSources()) { |
---|
102 |
ClockSource s; |
---|
103 |
s.type = eCT_Invalid; |
---|
104 |
return s; |
---|
105 |
} |
---|
106 |
return *m_active_clocksource; |
---|
107 |
} |
---|
108 |
|
---|
109 |
bool |
---|
110 |
GoDevice::setActiveClockSource(ClockSource s) |
---|
111 |
{ |
---|
112 |
if (!updateClockSources()) |
---|
113 |
return false; |
---|
114 |
|
---|
115 |
if ((s.id > 0) || (!m_spdif_clocksource.locked)) |
---|
116 |
return false; |
---|
117 |
return setSelectorFBValue(4, s.id); |
---|
118 |
} |
---|
119 |
|
---|
120 |
FFADODevice::ClockSourceVector |
---|
121 |
GoDevice::getSupportedClockSources() { |
---|
122 |
FFADODevice::ClockSourceVector r; |
---|
123 |
r.push_back(m_internal_clocksource); |
---|
124 |
r.push_back(m_spdif_clocksource); |
---|
125 |
return r; |
---|
126 |
} |
---|
127 |
} // namespace Yamaha |
---|
128 |
} // namespace BeBoB |
---|