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

Revision 2803, 10.6 kB (checked in by jwoithe, 1 year ago)

Cosmetic: capitalise "L" in "Linux".

"Linux" is a proper noun so it should start with a capital letter. These
changes are almost all within comments.

This patch was originally proposed by pander on the ffado-devel mailing
list. It has been expanded to cover all similar cases to maintain
consistency throughout the source tree.

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 #include "libutil/ByteSwap.h"
35
36 #include "fireface_def.h"
37 #include "libstreaming/rme/RmeReceiveStreamProcessor.h"
38 #include "libstreaming/rme/RmeTransmitStreamProcessor.h"
39
40 #include "rme_shm.h"
41
42 class ConfigRom;
43 class Ieee1394Service;
44
45 namespace Rme {
46
47 // The RME devices expect packet data in little endian format (as
48 // opposed to bus order, which is big endian).  Therefore define our own
49 // 32-bit byteswap function to account for this.
50 #if __BYTE_ORDER == __BIG_ENDIAN
51 #define RME_BYTESWAP32(x)       ByteSwap32(x)
52 #else
53 #define RME_BYTESWAP32(x)       (x)
54 #endif
55
56 static inline uint32_t
57 ByteSwapToDevice32(uint32_t d)
58 {
59     return RME_BYTESWAP32(d);
60 }
61 static inline uint32_t
62 ByteSwapFromDevice32(uint32_t d)
63 {
64     return RME_BYTESWAP32(d);
65 }
66        
67 // Note: the values in this enum do not have to correspond to the unit
68 // version reported by the respective devices.  It just so happens that they
69 // currently do for the Fireface-800 and Fireface-400.
70 enum ERmeModel {
71     RME_MODEL_NONE          = 0x0000,
72     RME_MODEL_FIREFACE800   = 0x0001,
73     RME_MODEL_FIREFACE400   = 0x0002,
74     RME_MODEL_FIREFACE_UFX  = 0x0003,
75     RME_MODEL_FIREFACE_UCX  = 0x0004,
76 };
77
78 class Device : public FFADODevice {
79 public:
80
81     Device( DeviceManager& d,
82                ffado_smartptr<ConfigRom>( configRom ));
83     virtual ~Device();
84
85     virtual bool buildMixer();
86     virtual bool destroyMixer();
87
88     static bool probe( Util::Configuration& c, ConfigRom& configRom, bool generic = false );
89     static FFADODevice * createDevice( DeviceManager& d,
90                                         ffado_smartptr<ConfigRom>( configRom ));
91     static int getConfigurationId( );
92     virtual bool discover();
93
94     virtual void showDevice();
95
96     bool setDDSFrequency( int dds_freq );
97     virtual bool setSamplingFrequency( int samplingFrequency );
98     virtual int getSamplingFrequency( );
99     virtual std::vector<int> getSupportedSamplingFrequencies();
100
101     ClockSource dummyClockSource(void);
102     virtual ClockSourceVector getSupportedClockSources();
103     virtual bool setActiveClockSource(ClockSource);
104     virtual ClockSource getActiveClockSource();
105
106     virtual int getStreamCount();
107     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
108
109     virtual bool resetForStreaming();
110     virtual bool prepare();
111     virtual bool lock();
112     virtual bool unlock();
113
114     virtual enum FFADODevice::eStreamingState getStreamingState();
115     virtual bool startStreamByIndex(int i);
116     virtual bool stopStreamByIndex(int i);
117
118     signed int getNumChannels(void) { return num_channels; };
119     signed int getFramesPerPacket(void);
120
121     bool addPort(Streaming::StreamProcessor *s_processor,
122              char *name, enum Streaming::Port::E_Direction direction,
123              int position, int size);
124     bool addDirPorts(enum Streaming::Port::E_Direction direction);
125
126     unsigned int readRegister(fb_nodeaddr_t reg);
127     signed int readBlock(fb_nodeaddr_t reg, quadlet_t *buf, unsigned int n_quads);
128     signed int writeRegister(fb_nodeaddr_t reg, quadlet_t data);
129     signed int writeBlock(fb_nodeaddr_t reg, quadlet_t *data, unsigned int n_quads);
130
131     /* Device control functions */
132     signed int getPhantom(unsigned int channel);
133     signed int setPhantom(unsigned int channel, unsigned int status);
134     signed int getInputLevel(void);
135     signed int setInputLevel(unsigned int level);
136     signed int getOutputLevel(void);
137     signed int setOutputLevel(unsigned int level);
138     signed int getPhonesLevel(void);
139     signed int setPhonesLevel(unsigned int level);
140     signed int getInputPadOpt(unsigned int channel);
141     signed int setInputPadOpt(unsigned int channel, unsigned int status);
142     signed int getInputInstrOpt(unsigned int channel);
143     signed int setInputInstrOpt(unsigned int channel, unsigned int status);
144     signed int getInputSource(unsigned int channel);
145     signed int setInputSource(unsigned int channel, unsigned int src);
146     signed int getSpdifInputMode(void);
147     signed int setSpdifInputMode(signed int mode);
148     signed int getSpdifOutputIsOptical(void);
149     signed int setSpdifOutputIsOptical(signed int enable);
150     signed int getSpdifOutputEmphasisOn(void);
151     signed int setSpdifOutputEmphasisOn(signed int enable);
152     signed int getSpdifOutputNonAudioOn(void);
153     signed int setSpdifOutputNonAudioOn(signed int enable);
154     signed int getSpdifOutputProOn(void);
155     signed int setSpdifOutputProOn(signed int enable);
156     signed int getAmpGain(unsigned int index);
157     signed int setAmpGain(unsigned int index, signed int val);
158     signed int getMixerGain(unsigned int ctype,
159         unsigned int src_channel, unsigned int dest_channel);
160     signed int setMixerGain(unsigned int ctype,
161         unsigned int src_channel, unsigned int dest_channel, signed int val);
162     signed int getMixerFlags(unsigned int ctype,
163         unsigned int src_channel, unsigned int dest_channel, unsigned int flagmask);
164     signed int setMixerFlags(unsigned int ctype,
165         unsigned int src_channel, unsigned int dest_channel, unsigned int flagmask, signed int val);
166     signed int getClockMode(void);
167     signed int setClockMode(signed int mode);
168     signed int getSyncRef(void);
169     signed int setSyncRef(signed int ref);
170     signed int getBandwidthLimit(void);
171     signed int setBandwidthLimit(signed int limit);
172
173     /* TCO control functions */
174     signed int getTcoLtc(void);
175     signed int getTcoLtcValid(void);
176     signed int getTcoLock(void);
177     signed int getTcoLtcFrameRate(void);
178     signed int getTcoLtcDropFrame(void);
179     signed int getTcoVideoType(void);
180     signed int getTcoWordClk(void);
181     float getTcoFrequency(void);
182     signed int getTcoWordClkState(void);
183     signed int getTcoSyncSrc(void);
184     signed int setTcoSyncSrc(signed int src);
185     signed int getTcoFrameRate(void);
186     signed int setTcoFrameRate(signed int rate_id);
187     signed int getTcoPull(void);
188     signed int setTcoPull(signed int pull);
189     signed int getTcoSampleRate(void);
190     signed int setTcoSampleRate(signed int rate_param_id);
191     signed int getTcoTermination(void);
192     signed int setTcoTermination(signed int enable);
193     signed int getTcoWordClkConv(void);
194     signed int setTcoWordClkConv(signed int conv);
195
196     /* General information functions */
197     signed int getRmeModel(void) { return m_rme_model; }
198     signed int getTcoPresent(void) { return dev_config->tco_present; }
199     Streaming::RmeReceiveStreamProcessor *getRxSP(void) { return m_receiveProcessor; }
200
201 protected:
202     enum ERmeModel m_rme_model;
203
204     FF_software_settings_t *settings;
205     FF_TCO_settings_t *tco_settings;
206
207     rme_shm_t *dev_config, local_dev_config_obj;
208
209     signed int num_channels;
210     signed int frames_per_packet; // 1 frame includes 1 sample from each channel
211     signed int speed800;
212     signed int provide_midi;      // 0=no, 1=yes
213
214     signed int iso_tx_channel, iso_rx_channel;
215
216     Streaming::RmeReceiveStreamProcessor *m_receiveProcessor;
217     Streaming::RmeTransmitStreamProcessor *m_transmitProcessor;
218
219 private:
220     unsigned long long int cmd_buffer_addr();
221     unsigned long long int stream_init_reg();
222     unsigned long long int stream_start_reg();
223     unsigned long long int stream_end_reg();
224     unsigned long long int flash_settings_addr();
225     unsigned long long int flash_mixer_vol_addr();
226     unsigned long long int flash_mixer_pan_addr();
227     unsigned long long int flash_mixer_hw_addr();
228
229     /* Low-level flash memory functions */
230     signed int wait_while_busy(unsigned int init_delay);
231     signed int get_revision(unsigned int *revision);
232     signed int read_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads);
233     signed int erase_flash(unsigned int flags);
234     signed int write_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads);
235
236     /* Upper level flash memory functions */
237 public:
238     signed int read_device_flash_settings(FF_software_settings_t *dsettings);
239     signed int write_device_flash_settings(FF_software_settings_t *dsettings);
240     signed int read_device_mixer_settings(FF_software_settings_t *dsettings);
241     signed int write_device_mixer_settings(FF_software_settings_t *dsettings);
242
243 private:
244     /* Low-level hardware functions */
245     unsigned int multiplier_of_freq(unsigned int freq);
246     void config_lock(void);
247     void config_unlock(void);
248     signed int init_hardware(void);
249     signed int get_hardware_status(unsigned int *stat0, unsigned int *stat1);
250     signed int get_hardware_streaming_status(unsigned int *stat, unsigned int n);
251 public:
252     signed int get_hardware_state(FF_state_t *state);
253 private:
254     signed int set_hardware_params(FF_software_settings_t *use_settings = NULL);
255
256     signed int read_tco(quadlet_t *tco_data, signed int size);
257     signed int write_tco(quadlet_t *tco_data, signed int size);
258     signed int hardware_is_streaming(void);
259
260     signed int read_tco_state(FF_TCO_state_t *tco_state);
261     signed int write_tco_settings(FF_TCO_settings_t *tco_settings);
262
263     signed int set_hardware_dds_freq(signed int freq);
264
265     signed int hardware_init_streaming(unsigned int sample_rate, unsigned int tx_channel);
266     signed int hardware_start_streaming(unsigned int listen_channel);
267     signed int hardware_stop_streaming(void);
268
269     signed int set_hardware_ampgain(unsigned int index, signed int val);
270     signed int set_hardware_mixergain(unsigned int ctype,
271         unsigned int src_channel, unsigned int dest_channel, signed int val);
272
273     signed int set_hardware_channel_mute(signed int chan, signed int mute);
274     signed int set_hardware_output_rec(signed int rec);
275
276     signed int getMixerGainIndex(unsigned int src_channel, unsigned int dest_channel);
277
278     Control::Container *m_MixerContainer;
279     Control::Container *m_ControlContainer;
280 };
281
282 }
283
284 #endif
Note: See TracBrowser for help on using the browser.