root/trunk/libffado/src/libieee1394/IEC61883.h

Revision 742, 5.8 kB (checked in by ppalmers, 16 years ago)

- Remove some obsolete support files and dirs

- Clean up the license statements in the source files. Everything is

GPL version 3 now.

- Add license and copyright notices to scons scripts

- Clean up some other text files

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