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

Revision 2032, 7.9 kB (checked in by jwoithe, 9 years ago)

rme: implement SPDIF input mode selection via ffado-mixer. Whether this has the desired effect on the device remains to be seen - I do not have anything to test the mode of the optical port right now.

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