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

Revision 2037, 8.5 kB (checked in by jwoithe, 9 years ago)

rme: make clock mode control active. Note that this isn't overly useful without the other clock-related controls and indicators being active. They will follow soon.

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     ClockSource dummyClockSource(void);
79     virtual ClockSourceVector getSupportedClockSources();
80     virtual bool setActiveClockSource(ClockSource);
81     virtual ClockSource getActiveClockSource();
82
83     virtual int getStreamCount();
84     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
85
86     virtual bool prepare();
87     virtual bool lock();
88     virtual bool unlock();
89
90     virtual bool startStreamByIndex(int i);
91     virtual bool stopStreamByIndex(int i);
92
93     signed int getNumChannels(void) { return num_channels; };
94     signed int getFramesPerPacket(void);
95
96     bool addPort(Streaming::StreamProcessor *s_processor,
97              char *name, enum Streaming::Port::E_Direction direction,
98              int position, int size);
99     bool addDirPorts(enum Streaming::Port::E_Direction direction);
100
101     unsigned int readRegister(fb_nodeaddr_t reg);
102     signed int readBlock(fb_nodeaddr_t reg, quadlet_t *buf, unsigned int n_quads);
103     signed int writeRegister(fb_nodeaddr_t reg, quadlet_t data);
104     signed int writeBlock(fb_nodeaddr_t reg, quadlet_t *data, unsigned int n_quads);
105
106     /* Device control functions */
107     signed int getPhantom(unsigned int channel);
108     signed int setPhantom(unsigned int channel, unsigned int status);
109     signed int getInputLevel(void);
110     signed int setInputLevel(unsigned int level);
111     signed int getOutputLevel(void);
112     signed int setOutputLevel(unsigned int level);
113     signed int getPhonesLevel(void);
114     signed int setPhonesLevel(unsigned int level);
115     signed int getInputPadOpt(unsigned int channel);
116     signed int setInputPadOpt(unsigned int channel, unsigned int status);
117     signed int getInputInstrOpt(unsigned int channel);
118     signed int setInputInstrOpt(unsigned int channel, unsigned int status);
119     signed int getSpdifInputMode(void);
120     signed int setSpdifInputMode(signed int mode);
121     signed int getSpdifOutputIsOptical(void);
122     signed int setSpdifOutputIsOptical(signed int enable);
123     signed int getSpdifOutputEmphasisOn(void);
124     signed int setSpdifOutputEmphasisOn(signed int enable);
125     signed int getSpdifOutputNonAudioOn(void);
126     signed int setSpdifOutputNonAudioOn(signed int enable);
127     signed int getSpdifOutputProOn(void);
128     signed int setSpdifOutputProOn(signed int enable);
129     signed int getAmpGain(unsigned int index);
130     signed int setAmpGain(unsigned int index, signed int val);
131     signed int getMixerGain(unsigned int ctype,
132         unsigned int src_channel, unsigned int dest_channel);
133     signed int setMixerGain(unsigned int ctype,
134         unsigned int src_channel, unsigned int dest_channel, signed int val);
135     signed int getMixerFlags(unsigned int ctype,
136         unsigned int src_channel, unsigned int dest_channel, unsigned int flagmask);
137     signed int setMixerFlags(unsigned int ctype,
138         unsigned int src_channel, unsigned int dest_channel, unsigned int flagmask, signed int val);
139     signed int getClockMode(void);
140     signed int setClockMode(signed int mode);
141
142     /* General information functions */
143     signed int getRmeModel(void) { return m_rme_model; }
144     signed int getTcoPresent(void) { return dev_config->tco_present; }
145     Streaming::RmeReceiveStreamProcessor *getRxSP(void) { return m_receiveProcessor; }
146
147 protected:
148     enum ERmeModel m_rme_model;
149
150     FF_software_settings_t *settings;
151     FF_TCO_settings_t *tco_settings;
152
153     rme_shm_t *dev_config, local_dev_config_obj;
154
155     signed int num_channels;
156     signed int frames_per_packet; // 1 frame includes 1 sample from each channel
157     signed int speed800;
158
159     signed int iso_tx_channel, iso_rx_channel;
160
161     Streaming::RmeReceiveStreamProcessor *m_receiveProcessor;
162     Streaming::RmeTransmitStreamProcessor *m_transmitProcessor;
163
164 private:
165     unsigned long long int cmd_buffer_addr();
166     unsigned long long int stream_init_reg();
167     unsigned long long int stream_start_reg();
168     unsigned long long int stream_end_reg();
169     unsigned long long int flash_settings_addr();
170     unsigned long long int flash_mixer_vol_addr();
171     unsigned long long int flash_mixer_pan_addr();
172     unsigned long long int flash_mixer_hw_addr();
173
174     /* Low-level flash memory functions */
175     signed int wait_while_busy(unsigned int init_delay);
176     signed int get_revision(unsigned int *revision);
177     signed int read_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads);
178     signed int erase_flash(unsigned int flags);
179     signed int write_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads);
180
181     /* Upper level flash memory functions */
182     signed int read_device_flash_settings(FF_software_settings_t *settings);
183     signed int write_device_flash_settings(FF_software_settings_t *settings);
184
185     /* Low-level hardware functions */
186     unsigned int multiplier_of_freq(unsigned int freq);
187     void config_lock(void);
188     void config_unlock(void);
189     signed int init_hardware(void);
190     signed int get_hardware_status(unsigned int *stat0, unsigned int *stat1);
191     signed int get_hardware_streaming_status(unsigned int *stat, unsigned int n);
192     signed int get_hardware_state(FF_state_t *state);
193     signed int set_hardware_params(FF_software_settings_t *use_settings = NULL);
194
195     signed int read_tco(quadlet_t *tco_data, signed int size);
196     signed int write_tco(quadlet_t *tco_data, signed int size);
197     signed int hardware_is_streaming(void);
198
199     signed int read_tco_state(FF_TCO_state_t *tco_state);
200     signed int write_tco_settings(FF_TCO_settings_t *tco_settings);
201
202     signed int set_hardware_dds_freq(signed int freq);
203
204     signed int hardware_init_streaming(unsigned int sample_rate, unsigned int tx_channel);
205     signed int hardware_start_streaming(unsigned int listen_channel);
206     signed int hardware_stop_streaming(void);
207
208     signed int set_hardware_ampgain(unsigned int index, signed int val);
209     signed int set_hardware_mixergain(unsigned int ctype,
210         unsigned int src_channel, unsigned int dest_channel, signed int val);
211
212     signed int set_hardware_channel_mute(signed int chan, signed int mute);
213     signed int set_hardware_output_rec(signed int rec);
214
215     signed int getMixerGainIndex(unsigned int src_channel, unsigned int dest_channel);
216
217     Control::Container *m_MixerContainer;
218     Control::Container *m_ControlContainer;
219 };
220
221 }
222
223 #endif
Note: See TracBrowser for help on using the browser.