root/trunk/libffado/src/rme/rme_avdevice.h

Revision 2008, 7.8 kB (checked in by jwoithe, 9 years ago)

rme: refine input matrix mixer channel names. Add low level support for mixer channel phase inversion and muting (untested). Add playback mixer to RME ffado-mixer.

Line 
1 /*
2  * Copyright (C) 2005-2008 by Jonathan Woithe
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 #ifndef RMEDEVICE_H
26 #define RMEDEVICE_H
27
28 #include "ffadodevice.h"
29
30 #include "debugmodule/debugmodule.h"
31 #include "libavc/avc_definitions.h"
32
33 #include "libutil/Configuration.h"
34
35 #include "fireface_def.h"
36 #include "libstreaming/rme/RmeReceiveStreamProcessor.h"
37 #include "libstreaming/rme/RmeTransmitStreamProcessor.h"
38
39 #include "rme_shm.h"
40
41 class ConfigRom;
42 class Ieee1394Service;
43
44 namespace Rme {
45
46 // Note: the values in this enum do not have to correspond to the unit
47 // version reported by the respective devices.  It just so happens that they
48 // currently do for the Fireface-800 and Fireface-400.
49 enum ERmeModel {
50     RME_MODEL_NONE          = 0x0000,
51     RME_MODEL_FIREFACE800   = 0x0001,
52     RME_MODEL_FIREFACE400   = 0x0002,
53 };
54
55 class Device : public FFADODevice {
56 public:
57
58     Device( DeviceManager& d,
59                std::auto_ptr<ConfigRom>( configRom ));
60     virtual ~Device();
61
62     virtual bool buildMixer();
63     virtual bool destroyMixer();
64
65     static bool probe( Util::Configuration& c, ConfigRom& configRom, bool generic = false );
66     static FFADODevice * createDevice( DeviceManager& d,
67                                         std::auto_ptr<ConfigRom>( configRom ));
68     static int getConfigurationId( );
69     virtual bool discover();
70
71     virtual void showDevice();
72
73     bool setDDSFrequency( int dds_freq );
74     virtual bool setSamplingFrequency( int samplingFrequency );
75     virtual int getSamplingFrequency( );
76     virtual std::vector<int> getSupportedSamplingFrequencies();
77
78     virtual ClockSourceVector getSupportedClockSources();
79     virtual bool setActiveClockSource(ClockSource);
80     virtual ClockSource getActiveClockSource();
81
82     virtual int getStreamCount();
83     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
84
85     virtual bool prepare();
86     virtual bool lock();
87     virtual bool unlock();
88
89     virtual bool startStreamByIndex(int i);
90     virtual bool stopStreamByIndex(int i);
91
92     signed int getNumChannels(void) { return num_channels; };
93     signed int getFramesPerPacket(void);
94
95     bool addPort(Streaming::StreamProcessor *s_processor,
96              char *name, enum Streaming::Port::E_Direction direction,
97              int position, int size);
98     bool addDirPorts(enum Streaming::Port::E_Direction direction);
99
100     unsigned int readRegister(fb_nodeaddr_t reg);
101     signed int readBlock(fb_nodeaddr_t reg, quadlet_t *buf, unsigned int n_quads);
102     signed int writeRegister(fb_nodeaddr_t reg, quadlet_t data);
103     signed int writeBlock(fb_nodeaddr_t reg, quadlet_t *data, unsigned int n_quads);
104
105     /* Device control functions */
106     signed int getPhantom(unsigned int channel);
107     signed int setPhantom(unsigned int channel, unsigned int status);
108     signed int getInputLevel(void);
109     signed int setInputLevel(unsigned int level);
110     signed int getOutputLevel(void);
111     signed int setOutputLevel(unsigned int level);
112     signed int getPhonesLevel(void);
113     signed int setPhonesLevel(unsigned int level);
114     signed int getInputPadOpt(unsigned int channel);
115     signed int setInputPadOpt(unsigned int channel, unsigned int status);
116     signed int getInputInstrOpt(unsigned int channel);
117     signed int setInputInstrOpt(unsigned int channel, unsigned int status);
118     signed int getAmpGain(unsigned int index);
119     signed int setAmpGain(unsigned int index, signed int val);
120     signed int getMixerGain(unsigned int ctype,
121         unsigned int src_channel, unsigned int dest_channel);
122     signed int setMixerGain(unsigned int ctype,
123         unsigned int src_channel, unsigned int dest_channel, signed int val);
124     signed int getMixerFlags(unsigned int ctype,
125         unsigned int src_channel, unsigned int dest_channel, unsigned int flagmask);
126     signed int setMixerFlags(unsigned int ctype,
127         unsigned int src_channel, unsigned int dest_channel, unsigned int flagmask, signed int val);
128
129     /* General information functions */
130     signed int getRmeModel(void) { return m_rme_model; }
131     signed int getTcoPresent(void) { return dev_config->tco_present; }
132     Streaming::RmeReceiveStreamProcessor *getRxSP(void) { return m_receiveProcessor; }
133
134 protected:
135     enum ERmeModel m_rme_model;
136
137     FF_software_settings_t *settings;
138     FF_TCO_settings_t *tco_settings;
139
140     rme_shm_t *dev_config, local_dev_config_obj;
141
142     signed int num_channels;
143     signed int frames_per_packet; // 1 frame includes 1 sample from each channel
144     signed int speed800;
145
146     signed int iso_tx_channel, iso_rx_channel;
147
148     Streaming::RmeReceiveStreamProcessor *m_receiveProcessor;
149     Streaming::RmeTransmitStreamProcessor *m_transmitProcessor;
150
151 private:
152     unsigned long long int cmd_buffer_addr();
153     unsigned long long int stream_init_reg();
154     unsigned long long int stream_start_reg();
155     unsigned long long int stream_end_reg();
156     unsigned long long int flash_settings_addr();
157     unsigned long long int flash_mixer_vol_addr();
158     unsigned long long int flash_mixer_pan_addr();
159     unsigned long long int flash_mixer_hw_addr();
160
161     /* Low-level flash memory functions */
162     signed int wait_while_busy(unsigned int init_delay);
163     signed int get_revision(unsigned int *revision);
164     signed int read_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads);
165     signed int erase_flash(unsigned int flags);
166     signed int write_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads);
167
168     /* Upper level flash memory functions */
169     signed int read_device_flash_settings(FF_software_settings_t *settings);
170     signed int write_device_flash_settings(FF_software_settings_t *settings);
171
172     /* Low-level hardware functions */
173     unsigned int multiplier_of_freq(unsigned int freq);
174     void config_lock(void);
175     void config_unlock(void);
176     signed int init_hardware(void);
177     signed int get_hardware_status(unsigned int *stat0, unsigned int *stat1);
178     signed int get_hardware_streaming_status(unsigned int *stat, unsigned int n);
179     signed int get_hardware_state(FF_state_t *state);
180     signed int set_hardware_params(FF_software_settings_t *use_settings = NULL);
181
182     signed int read_tco(quadlet_t *tco_data, signed int size);
183     signed int write_tco(quadlet_t *tco_data, signed int size);
184     signed int hardware_is_streaming(void);
185
186     signed int read_tco_state(FF_TCO_state_t *tco_state);
187     signed int write_tco_settings(FF_TCO_settings_t *tco_settings);
188
189     signed int set_hardware_dds_freq(signed int freq);
190
191     signed int hardware_init_streaming(unsigned int sample_rate, unsigned int tx_channel);
192     signed int hardware_start_streaming(unsigned int listen_channel);
193     signed int hardware_stop_streaming(void);
194
195     signed int set_hardware_ampgain(unsigned int index, signed int val);
196     signed int set_hardware_mixergain(unsigned int ctype,
197         unsigned int src_channel, unsigned int dest_channel, signed int val);
198
199     signed int set_hardware_channel_mute(signed int mute);
200     signed int set_hardware_output_rec(signed int rec);
201
202     signed int getMixerGainIndex(unsigned int src_channel, unsigned int dest_channel);
203
204     Control::Container *m_MixerContainer;
205     Control::Container *m_ControlContainer;
206 };
207
208 }
209
210 #endif
Note: See TracBrowser for help on using the browser.