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

Revision 1684, 6.6 kB (checked in by jwoithe, 14 years ago)

RME: more preparatory work on the streaming system

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     unsigned int readRegister(fb_nodeaddr_t reg);
93     signed int readBlock(fb_nodeaddr_t reg, quadlet_t *buf, unsigned int n_quads);
94     signed int writeRegister(fb_nodeaddr_t reg, quadlet_t data);
95     signed int writeBlock(fb_nodeaddr_t reg, quadlet_t *data, unsigned int n_quads);
96
97     /* Device control functions */
98     signed int getPhantom(unsigned int channel);
99     signed int setPhantom(unsigned int channel, unsigned int status);
100     signed int getInputLevel(void);
101     signed int setInputLevel(unsigned int level);
102     signed int getOutputLevel(void);
103     signed int setOutputLevel(unsigned int level);
104     signed int getPhonesLevel(void);
105     signed int setPhonesLevel(unsigned int level);
106     signed int getInputPadOpt(unsigned int channel);
107     signed int setInputPadOpt(unsigned int channel, unsigned int status);
108     signed int getInputInstrOpt(unsigned int channel);
109     signed int setInputInstrOpt(unsigned int channel, unsigned int status);
110     signed int getAmpGain(unsigned int index);
111     signed int setAmpGain(unsigned int index, signed int val);
112
113     /* General information functions */
114     signed int getRmeModel(void) { return m_rme_model; }
115     signed int getTcoPresent(void) { return dev_config->tco_present; }
116
117 protected:
118     enum ERmeModel m_rme_model;
119
120     FF_software_settings_t *settings;
121     FF_TCO_settings_t *tco_settings;
122
123     rme_shm_t *dev_config, local_dev_config_obj;
124
125     signed int num_channels;
126     signed int frames_per_packet; // 1 frame includes 1 sample from each channel
127     signed int speed800;
128
129     signed int iso_tx_channel, iso_rx_channel;
130
131     Streaming::RmeReceiveStreamProcessor *m_receiveProcessor;
132     Streaming::RmeTransmitStreamProcessor *m_transmitProcessor;
133
134 private:
135     unsigned long long int cmd_buffer_addr();
136     unsigned long long int stream_init_reg();
137     unsigned long long int stream_start_reg();
138     unsigned long long int stream_end_reg();
139     unsigned long long int flash_settings_addr();
140     unsigned long long int flash_mixer_vol_addr();
141     unsigned long long int flash_mixer_pan_addr();
142     unsigned long long int flash_mixer_hw_addr();
143
144     /* Low-level flash memory functions */
145     signed int wait_while_busy(unsigned int init_delay);
146     signed int get_revision(unsigned int *revision);
147     signed int read_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads);
148     signed int erase_flash(unsigned int flags);
149     signed int write_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads);
150
151     /* Upper level flash memory functions */
152     signed int read_device_flash_settings(FF_software_settings_t *settings);
153     signed int write_device_flash_settings(FF_software_settings_t *settings);
154
155     /* Low-level hardware functions */
156     unsigned int multiplier_of_freq(unsigned int freq);
157     void config_lock(void);
158     void config_unlock(void);
159     signed int init_hardware(void);
160     signed int get_hardware_status(unsigned int *stat0, unsigned int *stat1);
161     signed int get_hardware_streaming_status(unsigned int *stat, unsigned int n);
162     signed int get_hardware_state(FF_state_t *state);
163     signed int set_hardware_params(FF_software_settings_t *use_settings = NULL);
164
165     signed int read_tco(quadlet_t *tco_data, signed int size);
166     signed int write_tco(quadlet_t *tco_data, signed int size);
167     signed int hardware_is_streaming(void);
168
169     signed int read_tco_state(FF_TCO_state_t *tco_state);
170     signed int write_tco_settings(FF_TCO_settings_t *tco_settings);
171
172     signed int set_hardware_dds_freq(signed int freq);
173
174     signed int hardware_init_streaming(unsigned int sample_rate, unsigned int tx_channel);
175     signed int hardware_start_streaming(unsigned int listen_channel);
176     signed int hardware_stop_streaming(void);
177
178     signed int set_hardware_ampgain(unsigned int index, signed int val);
179
180     Control::Container *m_MixerContainer;
181     Control::Container *m_ControlContainer;
182 };
183
184 }
185
186 #endif
Note: See TracBrowser for help on using the browser.