root/branches/streaming-rework/src/libieee1394/IEC61883.h

Revision 424, 5.9 kB (checked in by pieterpalmers, 14 years ago)

- The library can now be started in 'slave mode', creating a BounceSlaveDevice?.

On a discovering node, this slave device is discovered as a BounceDevice?.
Streaming does not work yet, something wrong with the timestamps.

- Implemented the 'snoop mode', that allows a client to 'snoop' the streams

between another host and a device. It is only implemented for BeBoB devices.
The channel numbers and stream configuration are automatically detected.
Note that it currently relies on a rather hackish support for reading the
{i,o}PCR plugs by using private functions of libiec61883

- changed jack backend to support these two new features

Line 
1 /* $Id$ */
2
3 /*
4  *   FreeBob Streaming API
5  *   FreeBob = Firewire (pro-)audio for linux
6  *
7  *   http://freebob.sf.net
8  *
9  *   Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>
10  *
11  *   This program is free software {} you can redistribute it and/or modify
12  *   it under the terms of the GNU General Public License as published by
13  *   the Free Software Foundation {} either version 2 of the License, or
14  *   (at your option) any later version.
15  *
16  *   This program is distributed in the hope that it will be useful,
17  *   but WITHOUT ANY WARRANTY {} without even the implied warranty of
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *   GNU General Public License for more details.
20  *
21  *   You should have received a copy of the GNU General Public License
22  *   along with this program {} if not, write to the Free Software
23  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  *
25  *
26  *
27  */
28 #ifndef __FREEBOB_IEC61883__
29 #define __FREEBOB_IEC61883__
30
31 #include "../debugmodule/debugmodule.h"
32
33 /*
34  * This is shamelessly stolen from iec61883-private,
35  * but I need these functions!
36  * FIXME: this will only work until somebody decides to change
37  *        these in libiec61883.
38  */
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /**
44  * Plug Control Registers
45  **/
46
47 /* maximum number of PCRs allowed within the standard
48  * MPR/PCR addresses defined in IEC-61883.
49  * This refers to the number of output or input PCRs--
50  * not the MPRs and not the combined total.
51  */
52 #define IEC61883_PCR_MAX 31
53
54 /* standard CSR offsets for plugs */
55 #define CSR_O_MPR   0x900
56 #define CSR_O_PCR_0 0x904
57
58 #define CSR_I_MPR   0x980
59 #define CSR_I_PCR_0 0x984
60
61 #if ( __BYTE_ORDER == __BIG_ENDIAN )
62
63 struct iec61883_oMPR {
64     unsigned int data_rate:2;
65     unsigned int bcast_channel:6;
66     unsigned int non_persist_ext:8;
67     unsigned int persist_ext:8;
68     unsigned int reserved:3;
69     unsigned int n_plugs:5;
70 };
71
72 struct iec61883_iMPR {
73     unsigned int data_rate:2;
74     unsigned int reserved:6;
75     unsigned int non_persist_ext:8;
76     unsigned int persist_ext:8;
77     unsigned int reserved2:3;
78     unsigned int n_plugs:5;
79 };
80
81 struct iec61883_oPCR {
82     unsigned int online:1;
83     unsigned int bcast_connection:1;
84     unsigned int n_p2p_connections:6;
85     unsigned int reserved:2;
86     unsigned int channel:6;
87     unsigned int data_rate:2;
88     unsigned int overhead_id:4;
89     unsigned int payload:10;
90 };
91
92 struct iec61883_iPCR {
93     unsigned int online:1;
94     unsigned int bcast_connection:1;
95     unsigned int n_p2p_connections:6;
96     unsigned int reserved:2;
97     unsigned int channel:6;
98     unsigned int reserved2:16;
99 };
100
101 #else
102
103 struct iec61883_oMPR {
104     unsigned int n_plugs:5;
105     unsigned int reserved:3;
106     unsigned int persist_ext:8;
107     unsigned int non_persist_ext:8;
108     unsigned int bcast_channel:6;
109     unsigned int data_rate:2;
110 };
111
112 struct iec61883_iMPR {
113     unsigned int n_plugs:5;
114     unsigned int reserved2:3;
115     unsigned int persist_ext:8;
116     unsigned int non_persist_ext:8;
117     unsigned int reserved:6;
118     unsigned int data_rate:2;
119 };
120
121 struct iec61883_oPCR {
122     unsigned int payload:10;
123     unsigned int overhead_id:4;
124     unsigned int data_rate:2;
125     unsigned int channel:6;
126     unsigned int reserved:2;
127     unsigned int n_p2p_connections:6;
128     unsigned int bcast_connection:1;
129     unsigned int online:1;
130 };
131
132 struct iec61883_iPCR {
133     unsigned int reserved2:16;
134     unsigned int channel:6;
135     unsigned int reserved:2;
136     unsigned int n_p2p_connections:6;
137     unsigned int bcast_connection:1;
138     unsigned int online:1;
139 };
140
141 #endif
142
143 /**
144  * iec61883_plug_get - Read a node's plug register.
145  * @h: A raw1394 handle.
146  * @n: The node id of the node to read
147  * @a: The CSR offset address (relative to base) of the register to read.
148  * @value: A pointer to a quadlet where the plug register's value will be stored.
149  *
150  * This function handles bus to host endian conversion. It returns 0 for
151  * suceess or -1 for error (errno available).
152  **/
153 int
154 iec61883_plug_get(raw1394handle_t h, nodeid_t n, nodeaddr_t a, quadlet_t *value);
155
156
157 /**
158  * iec61883_plug_set - Write a node's plug register.
159  * @h: A raw1394 handle.
160  * @n: The node id of the node to read
161  * @a: The CSR offset address (relative to CSR base) of the register to write.
162  * @value: A quadlet containing the new register value.
163  *
164  * This uses a compare/swap lock operation to safely write the
165  * new register value, as required by IEC 61883-1.
166  * This function handles host to bus endian conversion. It returns 0 for success
167  * or -1 for error (errno available).
168  **/
169 int
170 iec61883_plug_set(raw1394handle_t h, nodeid_t n, nodeaddr_t a, quadlet_t value);
171
172 /**
173  * High level plug access macros
174  */
175
176 #define iec61883_get_oMPR(h,n,v) iec61883_plug_get((h), (n), CSR_O_MPR, (quadlet_t *)(v))
177 #define iec61883_set_oMPR(h,n,v) iec61883_plug_set((h), (n), CSR_O_MPR, *((quadlet_t *)&(v)))
178 #define iec61883_get_oPCR0(h,n,v) iec61883_plug_get((h), (n), CSR_O_PCR_0, (quadlet_t *)(v))
179 #define iec61883_set_oPCR0(h,n,v) iec61883_plug_set((h), (n), CSR_O_PCR_0, *((quadlet_t *)&(v)))
180 #define iec61883_get_oPCRX(h,n,v,x) iec61883_plug_get((h), (n), CSR_O_PCR_0+(4*(x)), (quadlet_t *)(v))
181 #define iec61883_set_oPCRX(h,n,v,x) iec61883_plug_set((h), (n), CSR_O_PCR_0+(4*(x)), *((quadlet_t *)&(v)))
182 #define iec61883_get_iMPR(h,n,v) iec61883_plug_get((h), (n), CSR_I_MPR, (quadlet_t *)(v))
183 #define iec61883_set_iMPR(h,n,v) iec61883_plug_set((h), (n), CSR_I_MPR, *((quadlet_t *)&(v)))
184 #define iec61883_get_iPCR0(h,n,v) iec61883_plug_get((h), (n), CSR_I_PCR_0, (quadlet_t *)(v))
185 #define iec61883_set_iPCR0(h,n,v) iec61883_plug_set((h), (n), CSR_I_PCR_0, *((quadlet_t *)&(v)))
186 #define iec61883_get_iPCRX(h,n,v,x) iec61883_plug_get((h), (n), CSR_I_PCR_0+(4*(x)), (quadlet_t *)(v))
187 #define iec61883_set_iPCRX(h,n,v,x) iec61883_plug_set((h), (n), CSR_I_PCR_0+(4*(x)), *((quadlet_t *)&(v)))
188
189
190 #ifdef __cplusplus
191 }
192 #endif
193
194 class IEC61883 {
195
196 public:
197
198     IEC61883();
199     virtual ~IEC61883();
200
201 protected:
202     DECLARE_DEBUG_MODULE;
203
204 };
205
206 #endif /* __FREEBOB_IEC61883__ */
207
208
Note: See TracBrowser for help on using the browser.