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

Revision 2033, 8.3 kB (checked in by jwoithe, 9 years ago)

rme: implement SPDIF output option control via ffado-mixer. Again, I haven't the means to confirm whether these settings have the desired effect on the SPDIF bitstream yet.

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 getSpdifInputMode(void);
119     signed int setSpdifInputMode(signed int mode);
120     signed int getSpdifOutputIsOptical(void);
121     signed int setSpdifOutputIsOptical(signed int enable);
122     signed int getSpdifOutputEmphasisOn(void);
123     signed int setSpdifOutputEmphasisOn(signed int enable);
124     signed int getSpdifOutputNonAudioOn(void);
125     signed int setSpdifOutputNonAudioOn(signed int enable);
126     signed int getSpdifOutputProOn(void);
127     signed int setSpdifOutputProOn(signed int enable);
128     signed int getAmpGain(unsigned int index);
129     signed int setAmpGain(unsigned int index, signed int val);
130     signed int getMixerGain(unsigned int ctype,
131         unsigned int src_channel, unsigned int dest_channel);
132     signed int setMixerGain(unsigned int ctype,
133         unsigned int src_channel, unsigned int dest_channel, signed int val);
134     signed int getMixerFlags(unsigned int ctype,
135         unsigned int src_channel, unsigned int dest_channel, unsigned int flagmask);
136     signed int setMixerFlags(unsigned int ctype,
137         unsigned int src_channel, unsigned int dest_channel, unsigned int flagmask, signed int val);
138
139     /* General information functions */
140     signed int getRmeModel(void) { return m_rme_model; }
141     signed int getTcoPresent(void) { return dev_config->tco_present; }
142     Streaming::RmeReceiveStreamProcessor *getRxSP(void) { return m_receiveProcessor; }
143
144 protected:
145     enum ERmeModel m_rme_model;
146
147     FF_software_settings_t *settings;
148     FF_TCO_settings_t *tco_settings;
149
150     rme_shm_t *dev_config, local_dev_config_obj;
151
152     signed int num_channels;
153     signed int frames_per_packet; // 1 frame includes 1 sample from each channel
154     signed int speed800;
155
156     signed int iso_tx_channel, iso_rx_channel;
157
158     Streaming::RmeReceiveStreamProcessor *m_receiveProcessor;
159     Streaming::RmeTransmitStreamProcessor *m_transmitProcessor;
160
161 private:
162     unsigned long long int cmd_buffer_addr();
163     unsigned long long int stream_init_reg();
164     unsigned long long int stream_start_reg();
165     unsigned long long int stream_end_reg();
166     unsigned long long int flash_settings_addr();
167     unsigned long long int flash_mixer_vol_addr();
168     unsigned long long int flash_mixer_pan_addr();
169     unsigned long long int flash_mixer_hw_addr();
170
171     /* Low-level flash memory functions */
172     signed int wait_while_busy(unsigned int init_delay);
173     signed int get_revision(unsigned int *revision);
174     signed int read_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads);
175     signed int erase_flash(unsigned int flags);
176     signed int write_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads);
177
178     /* Upper level flash memory functions */
179     signed int read_device_flash_settings(FF_software_settings_t *settings);
180     signed int write_device_flash_settings(FF_software_settings_t *settings);
181
182     /* Low-level hardware functions */
183     unsigned int multiplier_of_freq(unsigned int freq);
184     void config_lock(void);
185     void config_unlock(void);
186     signed int init_hardware(void);
187     signed int get_hardware_status(unsigned int *stat0, unsigned int *stat1);
188     signed int get_hardware_streaming_status(unsigned int *stat, unsigned int n);
189     signed int get_hardware_state(FF_state_t *state);
190     signed int set_hardware_params(FF_software_settings_t *use_settings = NULL);
191
192     signed int read_tco(quadlet_t *tco_data, signed int size);
193     signed int write_tco(quadlet_t *tco_data, signed int size);
194     signed int hardware_is_streaming(void);
195
196     signed int read_tco_state(FF_TCO_state_t *tco_state);
197     signed int write_tco_settings(FF_TCO_settings_t *tco_settings);
198
199     signed int set_hardware_dds_freq(signed int freq);
200
201     signed int hardware_init_streaming(unsigned int sample_rate, unsigned int tx_channel);
202     signed int hardware_start_streaming(unsigned int listen_channel);
203     signed int hardware_stop_streaming(void);
204
205     signed int set_hardware_ampgain(unsigned int index, signed int val);
206     signed int set_hardware_mixergain(unsigned int ctype,
207         unsigned int src_channel, unsigned int dest_channel, signed int val);
208
209     signed int set_hardware_channel_mute(signed int chan, signed int mute);
210     signed int set_hardware_output_rec(signed int rec);
211
212     signed int getMixerGainIndex(unsigned int src_channel, unsigned int dest_channel);
213
214     Control::Container *m_MixerContainer;
215     Control::Container *m_ControlContainer;
216 };
217
218 }
219
220 #endif
Note: See TracBrowser for help on using the browser.