root/trunk/libffado/src/rme/fireface_settings_ctrls.cpp

Revision 1606, 4.1 kB (checked in by jwoithe, 14 years ago)

RME: phantom switches in mixer GUI now control the respective Fireface hardware. Tested only on FF400 to date.
RME: add some more TCO glue.

Line 
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 RmeSettingsCtrl::RmeSettingsCtrl(Device &parent, unsigned int type,
30     unsigned int info)
31 : Control::Discrete(&parent)
32 , m_parent(parent)
33 , m_type(type)
34 , m_value(0)
35 , m_info(info)
36 {
37 }
38
39 RmeSettingsCtrl::RmeSettingsCtrl(Device &parent, unsigned int type,
40     unsigned int info,
41     std::string name, std::string label, std::string descr)
42 : Control::Discrete(&parent)
43 , m_parent(parent)
44 , m_type(type)
45 , m_value(0)
46 , m_info(info)
47 {
48     setName(name);
49     setLabel(label);
50     setDescription(descr);
51 }
52
53 bool
54 RmeSettingsCtrl::setValue(int v) {
55
56 signed int i;
57 signed int err = 0;
58
59     switch (m_type) {
60         case RME_CTRL_NONE:
61             debugOutput(DEBUG_LEVEL_ERROR, "control has no type set\n");
62             err = 1;
63             break;
64         case RME_CTRL_PHANTOM_SW:
65             // Lowest 16 bits are phantom status bits (max 16 channels).
66             // High 16 bits are "write enable" bits for the correspoding
67             // channel represented in the low 16 bits.  This way changes can
68             // be made to one channel without needing to first read the
69             // existing value.
70             //
71             // At present there are at most 4 phantom-capable channels.
72             // Flag attempts to write to the bits corresponding to channels
73             // beyond this.
74             if (v & 0xfff00000) {
75                 debugOutput(DEBUG_LEVEL_WARNING, "Ignored out-of-range phantom set request: mask=0x%04x, value=0x%04x\n",
76                   (v >> 16) & 0xfff0, v && 0xfff0);
77             }
78
79             for (i=0; i<4; i++) {
80                 if (v & (0x00010000 << i)) {
81                     unsigned int on = (v & (0x00000001 << i)) != 0;
82                     err = m_parent.setPhantom(i, on);
83                     if (!err) {
84                         if (on) {
85                             m_value |= (0x01 << i);
86                         } else {
87                             m_value &= ~(0x01 << i);
88                         }
89                     }
90                 }
91             }
92             break;
93
94         // All RME_CTRL_INFO_* controls are read-only.  Warn on attempts to
95         // set these.
96         case RME_CTRL_INFO_MODEL:
97         case RME_CTRL_INFO_TCO_PRESENT:
98             debugOutput(DEBUG_LEVEL_ERROR, "Attempt to set readonly info control 0x%08x\n", m_type);
99             err = 1;
100             break;
101
102         default:
103             debugOutput(DEBUG_LEVEL_ERROR, "Unknown control type 0x%08x\n", m_type);
104             err = 1;
105     }
106
107     return err==0?true:false;
108 }
109
110 int
111 RmeSettingsCtrl::getValue() {
112
113 signed int i;
114 signed int val = 0;
115
116     switch (m_type) {
117         case RME_CTRL_NONE:
118             debugOutput(DEBUG_LEVEL_ERROR, "control has no type set\n");
119             break;
120
121         case RME_CTRL_PHANTOM_SW:
122             for (i=0; i<3; i++)
123                 val |= (m_parent.getPhantom(i) << i);
124             return val;
125             break;
126
127         case RME_CTRL_INFO_MODEL:
128             return m_parent.getRmeModel();
129             break;
130
131         case RME_CTRL_INFO_TCO_PRESENT:
132             return m_parent.getTcoPresent();
133
134         default:
135             debugOutput(DEBUG_LEVEL_ERROR, "Unknown control type 0x%08x\n", m_type);
136     }
137
138     return 0;
139 }
140
141 }
Note: See TracBrowser for help on using the browser.