root/trunk/libffado/src/libstreaming/rme/RmeTransmitStreamProcessor.h

Revision 2802, 5.2 kB (checked in by jwoithe, 3 years ago)

Cosmetic: "Firewire" becomes "FireWire?".

Officially both the "F" and "W" were capitalised in the FireWire? name, so
reflect this throughout FFADO's source tree. This mostly affects comments.

This patch originated from pander on the ffado-devel mailing list. To
maintain consistency, the committed version has been expanded to include
files not originally included in the original patch.

Line 
1 /*
2  * Copyright (C) 2005-2009 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 __FFADO_RMETRANSMITSTREAMPROCESSOR__
26 #define __FFADO_RMETRANSMITSTREAMPROCESSOR__
27
28 /**
29  * This class implements RME based streaming
30  */
31
32 #include "debugmodule/debugmodule.h"
33
34 #include "../generic/StreamProcessor.h"
35 #include "../util/cip.h"
36
37 namespace Streaming {
38
39 class Port;
40 class RmeAudioPort;
41 class RmeMidiPort;
42 /*!
43 \brief The Base Class for an RME transmit stream processor
44
45  This class implements a TransmitStreamProcessor that multiplexes Ports
46  into RME streams.
47
48 */
49 class RmeTransmitStreamProcessor
50     : public StreamProcessor
51 {
52
53 public:
54     /**
55      * Create a RME transmit StreamProcessor
56      */
57     RmeTransmitStreamProcessor(FFADODevice &parent,
58                                unsigned int model, unsigned int event_size);
59     virtual ~RmeTransmitStreamProcessor() {};
60
61     enum eChildReturnValue generatePacketHeader(unsigned char *data, unsigned int *length,
62                                                 unsigned char *tag, unsigned char *sy,
63                                                 uint32_t pkt_ctr);
64     enum eChildReturnValue generatePacketData(unsigned char *data, unsigned int *length);
65     enum eChildReturnValue generateEmptyPacketHeader(unsigned char *data, unsigned int *length,
66                                                      unsigned char *tag, unsigned char *sy,
67                                                      uint32_t pkt_ctr);
68     enum eChildReturnValue generateEmptyPacketData(unsigned char *data, unsigned int *length);
69     enum eChildReturnValue generateSilentPacketHeader(unsigned char *data, unsigned int *length,
70                                                       unsigned char *tag, unsigned char *sy,
71                                                       uint32_t pkt_ctr);
72     enum eChildReturnValue generateSilentPacketData(unsigned char *data, unsigned int *length);
73     virtual bool prepareChild();
74
75     bool resetForStreaming();
76
77 public:
78     virtual unsigned int getEventSize()
79                 {return m_event_size;};
80     virtual unsigned int getMaxPacketSize();
81     virtual unsigned int getEventsPerFrame()
82                     { return 1; };
83     virtual unsigned int getNominalFramesPerPacket();
84
85 protected:
86     bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset);
87     bool transmitSilenceBlock(char *data, unsigned int nevents, unsigned int offset);
88
89 private:
90     unsigned int fillNoDataPacketHeader(quadlet_t *data, unsigned int* length);
91     unsigned int fillDataPacketHeader(quadlet_t *data, unsigned int* length, uint32_t ts);
92
93     int transmitBlock(char *data, unsigned int nevents,
94                         unsigned int offset);
95
96     bool encodePacketPorts(quadlet_t *data, unsigned int nevents,
97                            unsigned int dbc);
98
99     int encodePortToRmeEvents(RmeAudioPort *, quadlet_t *data,
100                                 unsigned int offset, unsigned int nevents);
101     int encodeSilencePortToRmeEvents(RmeAudioPort *, quadlet_t *data,
102                                 unsigned int offset, unsigned int nevents);
103
104     int encodePortToRmeMidiEvents(
105                        RmeMidiPort *p, quadlet_t *data,
106                        unsigned int offset, unsigned int nevents);
107     int encodeSilencePortToRmeMidiEvents(
108                        RmeMidiPort *p, quadlet_t *data,
109                        unsigned int offset, unsigned int nevents);
110
111     unsigned int m_rme_model;
112
113     /*
114      * An iso packet mostly consists of multiple events.  m_event_size
115      * is the size of a single 'event' in bytes.
116      */
117     unsigned int m_event_size;
118
119     // Keep track of transmission data block count
120     unsigned int m_tx_dbc;
121
122     // A simple circular buffer for outgoing MIDI data to allow
123     // a rate control to be implemented on the data to suit the RME
124     // devices.  Note that this buffer's size is forced to be a power
125     // of 2 to allow for buffer manipulation optimisations.
126     // FIXME: it is yet to be determined whether this is necessary for
127     // the RME device.
128     #define MIDIBUFFER_SIZE_EXP 10
129     #define MIDIBUFFER_SIZE     (1<<MIDIBUFFER_SIZE_EXP)
130     unsigned int midibuffer[MIDIBUFFER_SIZE];
131     unsigned int mb_head, mb_tail;
132     unsigned int midi_lock;
133     signed int streaming_has_run, streaming_has_dryrun;
134     signed int streaming_start_count;
135     unsigned int midi_tx_period; /* Measured in audio clock periods */
136 };
137
138 } // end of namespace Streaming
139
140 #endif /* __FFADO_RMETRANSMITSTREAMPROCESSOR__ */
141
Note: See TracBrowser for help on using the browser.