1 |
/* |
---|
2 |
* Copyright (C) 2005-2008 by Pieter Palmers |
---|
3 |
* Copyright (C) 2008-2009 by Jonathan Woithe |
---|
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 |
#include "rme/rme_avdevice.h" |
---|
25 |
#include "rme/fireface_settings_ctrls.h" |
---|
26 |
|
---|
27 |
namespace Rme { |
---|
28 |
|
---|
29 |
#define RME_CTRL_PHANTOM_SW 0x00 |
---|
30 |
#define RME_CTRL_SPDIF_INPUT_MODE 0x01 |
---|
31 |
#define RME_CTRL_SPDIF_OUTPUT_OPTIONS 0x02 |
---|
32 |
#define RME_CTRL_CLOCK_MODE 0x03 |
---|
33 |
#define RME_CTRL_SYNC_REF 0x04 |
---|
34 |
#define RME_CTRL_DEV_OPTIONS 0x05 |
---|
35 |
#define RME_CTRL_LIMIT_BANDWIDTH 0x06 |
---|
36 |
#define RME_CTRL_INPUT_LEVEL 0x07 |
---|
37 |
#define RME_CTRL_OUTPUT_LEVEL 0x08 |
---|
38 |
#define RME_CTRL_INSTRUMENT_OPTIONS 0x09 |
---|
39 |
#define RME_CTRL_WCLK_SINGLE_SPEED 0x0a |
---|
40 |
#define RME_CTRL_PHONES_LEVEL 0x0b |
---|
41 |
#define RME_CTRL_INPUT0_OPTIONS 0x0c |
---|
42 |
#define RME_CTRL_INPUT1_OPTIONS 0x0d |
---|
43 |
#define RME_CTRL_INPUT2_OPTIONS 0x0e |
---|
44 |
|
---|
45 |
RmeSettingsCtrl::RmeSettingsCtrl(Device &parent, unsigned int type, |
---|
46 |
unsigned int info) |
---|
47 |
: Control::Discrete(&parent) |
---|
48 |
, m_parent(parent) |
---|
49 |
, m_type(type) |
---|
50 |
, m_value(0) |
---|
51 |
, m_info(info) |
---|
52 |
{ |
---|
53 |
} |
---|
54 |
|
---|
55 |
RmeSettingsCtrl::RmeSettingsCtrl(Device &parent, unsigned int type, |
---|
56 |
unsigned int info, |
---|
57 |
std::string name, std::string label, std::string descr) |
---|
58 |
: Control::Discrete(&parent) |
---|
59 |
, m_parent(parent) |
---|
60 |
, m_type(type) |
---|
61 |
, m_value(0) |
---|
62 |
, m_info(info) |
---|
63 |
{ |
---|
64 |
setName(name); |
---|
65 |
setLabel(label); |
---|
66 |
setDescription(descr); |
---|
67 |
} |
---|
68 |
|
---|
69 |
bool |
---|
70 |
RmeSettingsCtrl::setValue(int v) { |
---|
71 |
|
---|
72 |
signed int i; |
---|
73 |
signed int err = 0; |
---|
74 |
|
---|
75 |
switch (m_type) { |
---|
76 |
case RME_CTRL_PHANTOM_SW: |
---|
77 |
// Lowest 16 bits are phantom status bits (max 16 channels). |
---|
78 |
// High 16 bits are "write enable" bits for the correspoding |
---|
79 |
// channel represented in the low 16 bits. This way changes can |
---|
80 |
// be made to one channel without needing to first read the |
---|
81 |
// existing value. |
---|
82 |
// |
---|
83 |
// At present there are at most 4 phantom-capable channels. |
---|
84 |
// Flag attempts to write to the bits corresponding to channels |
---|
85 |
// beyond this. |
---|
86 |
if (v & 0xfff00000) { |
---|
87 |
debugOutput(DEBUG_LEVEL_WARNING, "Ignored out-of-range phantom set request: mask=0x%04x, value=0x%04x\n", |
---|
88 |
(v >> 16) & 0xfff0, v && 0xfff0); |
---|
89 |
} |
---|
90 |
|
---|
91 |
for (i=0; i<4; i++) { |
---|
92 |
if (v & (0x00010000 << i)) { |
---|
93 |
unsigned int on = (v & (0x00000001 << i)) != 0; |
---|
94 |
err = m_parent.setPhantom(i, on); |
---|
95 |
if (!err && on) { |
---|
96 |
m_value |= (0x01 << i); |
---|
97 |
} else { |
---|
98 |
m_value &= ~(0x01 << i); |
---|
99 |
} |
---|
100 |
} |
---|
101 |
} |
---|
102 |
break; |
---|
103 |
} |
---|
104 |
|
---|
105 |
return err==0?true:false; |
---|
106 |
} |
---|
107 |
|
---|
108 |
int |
---|
109 |
RmeSettingsCtrl::getValue() { |
---|
110 |
|
---|
111 |
switch (m_type) { |
---|
112 |
case RME_CTRL_PHANTOM_SW: |
---|
113 |
return m_value; |
---|
114 |
break; |
---|
115 |
} |
---|
116 |
return 0; |
---|
117 |
} |
---|
118 |
|
---|
119 |
} |
---|