source: trunk/src/testing/app/svc/include/unused/iec61883.h @ 4

Revision 4, 36.6 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Copyright (C) 2004 Electronic Visualization Laboratory,
5 * University of Illinois at Chicago
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above
15 *    copyright notice, this list of conditions and the following disclaimer
16 *    in the documentation and/or other materials provided with the distribution.
17 *  * Neither the name of the University of Illinois at Chicago nor
18 *    the names of its contributors may be used to endorse or promote
19 *    products derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/
34 *
35 *****************************************************************************/
36
37/*
38 * libiec61883/iec61883.h - Linux IEEE 1394 streaming media library.
39 * Copyright (C) 2004 Kristian Hogsberg, Dan Dennedy, and Dan Maas.
40 *
41 * This library is free software; you can redistribute it and/or
42 * modify it under the terms of the GNU Lesser General Public
43 * License as published by the Free Software Foundation; either
44 * version 2 of the License, or (at your option) any later version.
45 *
46 * This library is distributed in the hope that it will be useful,
47 * but WITHOUT ANY WARRANTY; without even the implied warranty of
48 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
49 * Lesser General Public License for more details.
50 *
51 * You should have received a copy of the GNU Lesser General Public
52 * License along with this library; if not, write to the Free Software
53 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
54 */
55
56#ifndef _IEC61883_H
57#define _IEC61883_H
58
59#include <libraw1394/raw1394.h>
60#include <endian.h>
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66enum iec61883_datarate {
67    IEC61883_DATARATE_100 = 0,
68    IEC61883_DATARATE_200,
69    IEC61883_DATARATE_400
70};
71
72/*******************************************************************************
73 * Audio and Music Data Transport Protocol
74 **/
75
76enum iec61883_amdtp_format {
77        IEC61883_AMDTP_FORMAT_RAW,
78        IEC61883_AMDTP_FORMAT_IEC958_PCM,
79        IEC61883_AMDTP_FORMAT_IEC958_AC3
80};
81
82enum iec61883_cip_mode {
83        IEC61883_MODE_BLOCKING_EMPTY,
84        IEC61883_MODE_BLOCKING_NODATA,
85        IEC61883_MODE_NON_BLOCKING,
86};
87
88enum iec61883_amdtp_sample_format {
89        IEC61883_AMDTP_INPUT_NA = -1,
90        IEC61883_AMDTP_INPUT_LE16 = 0,
91        IEC61883_AMDTP_INPUT_BE16,
92        IEC61883_AMDTP_INPUT_LE20,
93        IEC61883_AMDTP_INPUT_BE20,
94        IEC61883_AMDTP_INPUT_LE24,
95        IEC61883_AMDTP_INPUT_BE24
96};
97
98#define IEC61883_FDF_SFC_32KHZ   0x00
99#define IEC61883_FDF_SFC_44K1HZ  0x01
100#define IEC61883_FDF_SFC_48KHZ   0x02
101#define IEC61883_FDF_SFC_88K2HZ  0x03
102#define IEC61883_FDF_SFC_96KHZ   0x04
103#define IEC61883_FDF_SFC_176K4HZ 0x05
104#define IEC61883_FDF_SFC_192KHZ  0x06
105
106typedef struct iec61883_amdtp* iec61883_amdtp_t;
107
108/**
109 * iec61883_amdtp_recv_t - AMDTP receive callback function prototype
110 * @data: pointer to the buffer containing audio data
111 * @nsamples: the number of samples in the buffer
112 * @dimension: the number of audio channels
113 * @rate: sampling frequency
114 * @format: one of enum iec61883_amdtp_format
115 * @sample_format: one of enum iec61883_amdtp_sample_format
116 * @callback_data: the opaque pointer you supplied in the init function
117 *
118 * The buffer contains consumer-ready 16bit raw PCM if it is in that format.
119 * Otherwise, the data consists of quadlets containing only one sample with
120 * any necessary padding minus the label if pcm, otherwise, for IEC958
121 * audio data, the header remains intact.
122 *
123 * Returns:
124 * 0 for success or -1 for failure
125 */
126typedef int
127(*iec61883_amdtp_recv_t) (iec61883_amdtp_t amdtp, char *data, int nsamples,
128        unsigned int dbc, unsigned int dropped, void *callback_data);
129
130typedef int
131(*iec61883_amdtp_xmit_t) (iec61883_amdtp_t amdtp, char *data, int nevents,
132        unsigned int dbc, unsigned int dropped, void *callback_data);
133
134/**
135 * iec61883_amdtp_xmit_init - setup transmission of AMDTP
136 * @handle: the libraw1394 handle to use for all operations
137 * @rate: one of enum iec61883_datarate
138 * @format: one of enum iec61883_amdtp_format to describe audio data format
139 * @sample_format: one of enum iec61883_amdtp_sample_format
140 * @mode: one of iec61883_cip_mode
141 * @dimension: the number of audio channels
142 * @get_data: a function pointer to your callback routine
143 * @callback_data: an opaque pointer to provide to your callback function
144 *
145 * AMDTP =  Audio and Music Data Transport Protocol
146 *
147 * Returns:
148 * A pointer to an iec61883_amdtp object upon success or NULL on failure.
149 **/
150iec61883_amdtp_t
151iec61883_amdtp_xmit_init(raw1394handle_t handle,
152                int rate, int format, int sample_format, int mode, int dimension,
153                iec61883_amdtp_xmit_t get_data, void *callback_data);
154
155/**
156 * iec61883_amdtp_recv_init - setup reception of AMDTP
157 * @handle: the libraw1394 handle to use for all operations
158 * @put_data: a function pointer to your callback routine
159 * @callback_data: an opaque pointer to provide to your callback function
160 *
161 * Returns:
162 * A pointer to an iec61883_amdtp object upon success or NULL on failure.
163 **/
164iec61883_amdtp_t
165iec61883_amdtp_recv_init(raw1394handle_t handle,
166                iec61883_amdtp_recv_t put_data, void *callback_data);
167
168/**
169 * iec61883_amdtp_xmit_start - start transmission of AMDTP
170 * @amdtp: pointer to iec61883_amdtp object
171 * @channel: the isochronous channel number to use
172 **/
173int
174iec61883_amdtp_xmit_start(iec61883_amdtp_t amdtp, int channel);
175
176/**
177 * iec61883_amdtp_xmit_stop - stop transmission of AMDTP
178 * @amdtp: pointer to iec61883_amdtp object
179 **/
180void
181iec61883_amdtp_xmit_stop(iec61883_amdtp_t amdtp);
182
183/**
184 * iec61883_amdtp_recv_start - start reception of AMDTP
185 * @amdtp: pointer to iec61883_amdtp object
186 * @channel: the isochronous channel number to use
187 **/
188int
189iec61883_amdtp_recv_start(iec61883_amdtp_t amdtp, int channel);
190
191/**
192 * iec61883_amdtp_recv_stop - stop reception of AMDTP
193 * @amdtp: pointer to iec61883_amdtp object
194 **/
195void
196iec61883_amdtp_recv_stop(iec61883_amdtp_t amdtp);
197
198/**
199 * iec61883_amdtp_close - destroy an amdtp object
200 * @amdtp: pointer to iec61883_amdtp object
201 **/
202void
203iec61883_amdtp_close(iec61883_amdtp_t amdtp);
204
205/**
206 * iec61883_amdtp_get_buffers - get the size of the buffer
207 * @amdtp: pointer to iec61883_amdtp object
208 **/
209unsigned int
210iec61883_amdtp_get_buffers(iec61883_amdtp_t amdtp);
211
212/**
213 * iec61883_amdtp_set_buffers - set the size of the buffer
214 * @amdtp: pointer to iec61883_amdtp object
215 * @packets: the size of the buffer in packets
216 *
217 * This is an advanced option that can only be set after initialization and
218 * before reception or transmission.
219 **/
220void
221iec61883_amdtp_set_buffers(iec61883_amdtp_t amdtp, unsigned int packets);
222
223/**
224 * iec61883_amdtp_get_prebuffers - get the size of the pre-transmission buffer
225 * @amdtp: pointer to iec61883_amdtp object
226 **/
227unsigned int
228iec61883_amdtp_get_prebuffers(iec61883_amdtp_t amdtp);
229
230/**
231 * iec61883_amdtp_set_prebuffers - set the size of the pre-transmission buffer
232 * @amdtp: pointer to iec61883_amdtp object
233 * @packets: the size of the buffer in packets
234 *
235 * This is an advanced option that can only be set after initialization and
236 * before reception or transmission.
237 **/
238void
239iec61883_amdtp_set_prebuffers(iec61883_amdtp_t amdtp, unsigned int packets);
240
241/**
242 * iec61883_amdtp_get_irq_interval - get the interrupt rate
243 * @amdtp: pointer to iec61883_amdtp object
244 **/
245unsigned int
246iec61883_amdtp_get_irq_interval(iec61883_amdtp_t amdtp);
247
248/**
249 * iec61883_amdtp_set_irq_interval - set the interrupt rate
250 * @amdtp: pointer to iec61883_amdtp object
251 * @packets: the size of the interval in packets
252 *
253 * This is an advanced option that can only be set after initialization and
254 * before reception or transmission.
255 **/
256void
257iec61883_amdtp_set_irq_interval(iec61883_amdtp_t amdtp, unsigned int packets);
258
259/**
260 * iec61883_amdtp_get_synch - get behavior on close
261 * @amdtp: pointer to iec61883_amdtp object
262 *
263 * If synch is not zero, then when stopping reception all packets in
264 * raw1394 buffers are flushed and invoking your callback function and when
265 * stopping transmission all packets in the raw1394 buffers are sent before
266 * the close function returns.
267 **/
268int
269iec61883_amdtp_get_synch(iec61883_amdtp_t amdtp);
270
271/**
272 * iec61883_amdtp_set_synch - set behavior on close
273 * @amdtp: pointer to iec61883_amdtp object
274 * @synch: 1 if you want sync behaviour, 0 otherwise
275 *
276 * If synch is not zero, then when stopping reception all packets in
277 * raw1394 buffers are flushed and invoking your callback function and when
278 * stopping transmission all packets in the raw1394 buffers are sent before
279 * the close function returns.
280 **/
281void
282iec61883_amdtp_set_synch(iec61883_amdtp_t amdtp, int synch);
283
284/**
285 * iec61883_amdtp_get_speed - get data rate for transmission
286 * @amdtp: pointer to iec61883_amdtp object
287 *
288 * Returns:
289 * one of enum raw1394_iso_speed (S100, S200, or S400)
290 **/
291int
292iec61883_amdtp_get_speed(iec61883_amdtp_t amdtp);
293
294/**
295 * iec61883_amdtp_set_speed - set data rate for transmission
296 * @amdtp: pointer to iec61883_amdtp object
297 * @speed: one of enum raw1394_iso_speed (S100, S200, or S400)
298 **/
299void
300iec61883_amdtp_set_speed(iec61883_amdtp_t amdtp, int speed);
301
302/**
303 * iec61883_amdtp_get_dropped - get the total number of dropped packets
304 * @amdtp: pointer to iec61883_amdtp object
305 *
306 * Returns:
307 * The total number of dropped packets since starting transmission or reception.
308 **/
309unsigned int
310iec61883_amdtp_get_dropped(iec61883_amdtp_t amdtp);
311
312/**
313 * iec61883_amdtp_get_callback_data - get the callback data you supplied
314 * @amdtp: pointer to iec61883_amdtp object
315 *
316 * This function is useful in bus reset callback routines because only
317 * the libraw1394 handle is available, and libiec61883 uses the userdata
318 * field of the libraw1394 handle.
319 *
320 * Returns:
321 * An opaque pointer to whatever you supplied when you called init.
322 **/
323void *
324iec61883_amdtp_get_callback_data(iec61883_amdtp_t amdtp);
325
326/**
327 * iec61883_amdtp_get_dimension - get the AMDTP dimension
328 * @amdtp: pointer to iec61883_amdtp object
329 *
330 * This function is useful in your callbacks.
331 *
332 * Returns:
333 * The numeric value of the current dimension.
334 **/
335int
336iec61883_amdtp_get_dimension(iec61883_amdtp_t amdtp);
337
338/**
339 * iec61883_amdtp_get_rate - get the AMDTP sampling frequency
340 * @amdtp: pointer to iec61883_amdtp object
341 *
342 * This function is useful in your callbacks.
343 *
344 * Returns:
345 * The numeric value of the sampling frequency.
346 **/
347int
348iec61883_amdtp_get_rate(iec61883_amdtp_t amdtp);
349
350/**
351 * iec61883_amdtp_get_format - get the AMDTP data format
352 * @amdtp: pointer to iec61883_amdtp object
353 *
354 * This function is useful in your callbacks.
355 *
356 * Returns:
357 * One of enum iec61883_amdtp_format.
358 **/
359enum iec61883_amdtp_format
360iec61883_amdtp_get_format(iec61883_amdtp_t amdtp);
361
362/**
363 * iec61883_amdtp_get_sample_format - get the AMDTP sample format
364 * @amdtp: pointer to iec61883_amdtp object
365 *
366 * This function is useful in your callbacks.
367 *
368 * Returns:
369 * One of enum iec61883_amdtp_sample_format.
370 **/
371enum iec61883_amdtp_sample_format
372iec61883_amdtp_get_sample_format(iec61883_amdtp_t amdtp);
373
374
375
376/*******************************************************************************
377 * DV Digital Video
378 **/
379
380typedef struct iec61883_dv* iec61883_dv_t;
381
382typedef int
383(*iec61883_dv_recv_t)(unsigned char *data, int len, unsigned int dropped,
384        void *callback_data);
385
386typedef int
387(*iec61883_dv_xmit_t)(unsigned char *data, int n_dif_blocks,
388        unsigned int dropped, void *callback_data);
389
390/**
391 * iec61883_dv_recv_init - setup reception of a DV stream
392 * @handle: the libraw1394 handle to use for all operations
393 * @put_data: a function pointer to your reception callback routine
394 * @callback_data: an opaque data pointer to provide to your callback function
395 *
396 * Returns:
397 * A pointer to an iec61883_dv object upon success or NULL on failure.
398 **/
399iec61883_dv_t
400iec61883_dv_recv_init(raw1394handle_t handle,
401                iec61883_dv_recv_t put_data,
402                void *callback_data);
403
404/**
405 * iec61883_dv_xmit_init - setup transmission of a DV stream
406 * @handle: the libraw1394 handle to use for all operations
407 * @is_pal: set to non-zero if transmitting a PAL stream (applies to transmission only)
408 * @get_data: a function pointer to your transmission callback routine
409 * @callback_data: an opaque data pointer to provide to your callback function
410 *
411 * Returns:
412 * A pointer to an iec61883_dv object upon success or NULL on failure.
413 **/
414iec61883_dv_t
415iec61883_dv_xmit_init(raw1394handle_t handle, int is_pal,
416                iec61883_dv_xmit_t get_data,
417                void *callback_data);
418
419/**
420 * iec61883_dv_recv_start - start receiving a DV stream
421 * @dv: pointer to iec61883_dv object
422 * @channel: the isochronous channel number
423 *
424 * Returns:
425 * 0 for success or -1 for failure
426 **/
427int
428iec61883_dv_recv_start(iec61883_dv_t dv, int channel);
429
430/**
431 * iec61883_dv_xmit_start - start transmitting a DV stream
432 * @dv: pointer to iec61883_dv object
433 * @channel: the isochronous channel number
434 *
435 * Returns:
436 * 0 for success or -1 for failure
437 **/
438int
439iec61883_dv_xmit_start(iec61883_dv_t dv, int channel);
440
441/**
442 * iec61883_dv_recv_stop - stop reception of a DV stream
443 * @dv: pointer to iec61883_dv ojbect
444 **/
445void
446iec61883_dv_recv_stop(iec61883_dv_t dv);
447
448/**
449 * iec61883_dv_xmit_stop - stop transmission of a DV stream
450 * @dv: pointer to iec61883_dv object
451 **/
452void
453iec61883_dv_xmit_stop(iec61883_dv_t dv);
454
455/**
456 * iec61883_dv_close - stop reception or transmission and destroy iec61883_dv object
457 * @dv: pointer to iec61883_dv object
458 **/
459void
460iec61883_dv_close(iec61883_dv_t dv);
461
462/**
463 * iec61883_dv_get_buffers - get the size of the buffer
464 * @dv: pointer to iec61883_dv object
465 **/
466unsigned int
467iec61883_dv_get_buffers(iec61883_dv_t dv);
468
469/**
470 * iec61883_dv_set_buffers - set the size of the buffer
471 * @dv: pointer to iec61883_dv object
472 * @packets: the size of the buffer in packets
473 *
474 * This is an advanced option that can only be set after initialization and
475 * before reception or transmission.
476 **/
477void
478iec61883_dv_set_buffers(iec61883_dv_t dv, unsigned int packets);
479
480/**
481 * iec61883_dv_get_prebuffers - get the size of the pre-transmission buffer
482 * @dv: pointer to iec61883_dv object
483 **/
484unsigned int
485iec61883_dv_get_prebuffers(iec61883_dv_t dv);
486
487/**
488 * iec61883_dv_set_prebuffers - set the size of the pre-transmission buffer
489 * @dv: pointer to iec61883_dv object
490 * @packets: the size of the buffer in packets
491 *
492 * This is an advanced option that can only be set after initialization and
493 * before reception or transmission.
494 **/
495void
496iec61883_dv_set_prebuffers(iec61883_dv_t dv, unsigned int packets);
497
498/**
499 * iec61883_dv_get_irq_interval - get the interrupt rate
500 * @dv: pointer to iec61883_dv object
501 **/
502unsigned int
503iec61883_dv_get_irq_interval(iec61883_dv_t dv);
504
505/**
506 * iec61883_dv_set_irq_interval - set the interrupt rate
507 * @dv: pointer to iec61883_dv object
508 * @packets: the size of the interval in packets
509 *
510 * This is an advanced option that can only be set after initialization and
511 * before reception or transmission.
512 **/
513void
514iec61883_dv_set_irq_interval(iec61883_dv_t dv, unsigned int packets);
515
516/**
517 * iec61883_dv_get_synch - get behavior on close
518 * @dv: pointer to iec61883_dv object
519 *
520 * If synch is not zero, then when stopping reception all packets in
521 * raw1394 buffers are flushed and invoking your callback function and when
522 * stopping transmission all packets in the raw1394 buffers are sent before
523 * the close function returns.
524 **/
525int
526iec61883_dv_get_synch(iec61883_dv_t dv);
527
528/**
529 * iec61883_dv_set_synch - set behavior on close
530 * @dv: pointer to iec61883_dv object
531 * @synch: 1 if you want sync behaviour, 0 otherwise
532 *
533 * If synch is not zero, then when stopping reception all packets in
534 * raw1394 buffers are flushed and invoking your callback function and when
535 * stopping transmission all packets in the raw1394 buffers are sent before
536 * the close function returns.
537 **/
538void
539iec61883_dv_set_synch(iec61883_dv_t dv, int synch);
540
541/**
542 * iec61883_dv_get_speed - get data rate for transmission
543 * @dv: pointer to iec61883_dv object
544 *
545 * Returns:
546 * one of enum raw1394_iso_speed (S100, S200, or S400)
547 **/
548int
549iec61883_dv_get_speed(iec61883_dv_t dv);
550
551/**
552 * iec61883_dv_set_speed - set data rate for transmission
553 * @dv: pointer to iec61883_dv object
554 * @speed: one of enum raw1394_iso_speed (S100, S200, or S400)
555 **/
556void
557iec61883_dv_set_speed(iec61883_dv_t dv, int speed);
558
559/**
560 * iec61883_dv_get_dropped - get the total number of dropped packets
561 * @dv: pointer to iec61883_dv object
562 *
563 * Returns:
564 * The total number of dropped packets since starting transmission or reception.
565 **/
566unsigned int
567iec61883_dv_get_dropped(iec61883_dv_t dv);
568
569/**
570 * iec61883_dv_get_callback_data - get the callback data you supplied
571 * @dv: pointer to iec61883_dv object
572 *
573 * This function is useful in bus reset callback routines because only
574 * the libraw1394 handle is available, and libiec61883 uses the userdata
575 * field of the libraw1394 handle.
576 *
577 * Returns:
578 * An opaque pointer to whatever you supplied when you called init.
579 **/
580void *
581iec61883_dv_get_callback_data(iec61883_dv_t dv);
582
583
584/*******************************************************************************
585 * The DV frame interface
586 **/
587
588typedef struct iec61883_dv_fb* iec61883_dv_fb_t;
589
590typedef int
591(*iec61883_dv_fb_recv_t)(unsigned char *data, int len, int complete,
592        void *callback_data);
593
594/**
595 * iec61883_dv_fb_init - setup reception of DV frames
596 * @handle: raw1394 handle.
597 * @put_data: your callback function.
598 * @callback_data: an opaque pointer you can send to your callback.
599 *
600 * This provides a frame-oriented instead of stream-oriented interface as
601 * compared to iec61883_dv_init(). This means that starts at the beginning of a
602 * frame, and all data is frame-aligned. Your callback function
603 * will receive a complete DV frame even if packets are dropped.
604 * The callback parameter @complete indicates if a full frame is received.
605 *
606 * Returns:
607 * A pointer to an iec61883_dv_fb object upon success or NULL on failure.
608 **/
609iec61883_dv_fb_t
610iec61883_dv_fb_init (raw1394handle_t handle,
611                iec61883_dv_fb_recv_t put_data,
612                void *callback_data);
613
614/**
615 * iec61883_dv_fb_start - start receiving DV frames
616 * @dvfb: pointer to iec61883_dv_fb object
617 * @channel: the isochronous channel number
618 *
619 * Returns:
620 * 0 for success or -1 for failure
621 **/
622int
623iec61883_dv_fb_start(iec61883_dv_fb_t dvfb, int channel);
624
625/**
626 * iec61883_dv_fb_stop - stop receiving DV frames
627 * @dvfb: pointer to iec61883_dv_fb object
628 **/
629void
630iec61883_dv_fb_stop(iec61883_dv_fb_t dvfb);
631
632/**
633 * iec61883_dv_fb_close - stop receiving DV frames and destroy iec61883_dv_fb object
634 * @dvfb: pointer to iec61883_dv_fb object
635 **/
636void
637iec61883_dv_fb_close(iec61883_dv_fb_t dvfb);
638
639/**
640 * iec61883_dv_fb_get_incomplete - get the total number of incomplete frames
641 * @dvfb: point to the iec61883_dv_fb object
642 *
643 * Returns:
644 * The total number of incomplete frames due to dropped packets since starting
645 * reception.
646 **/
647unsigned int
648iec61883_dv_fb_get_incomplete(iec61883_dv_fb_t dvfb);
649
650/**
651 * iec61883_dv_fb_get_callback_data - get the callback data you supplied
652 * @dvfb: pointer to iec61883_dv_fb object
653 *
654 * This function is useful in bus reset callback routines because only
655 * the libraw1394 handle is available, and libiec61883 uses the userdata
656 * field of the libraw1394 handle.
657 *
658 * Returns:
659 * An opaque pointer to whatever you supplied when you called init.
660 **/
661void *
662iec61883_dv_fb_get_callback_data(iec61883_dv_fb_t dvfb);
663
664
665/*******************************************************************************
666 * MPEG-2 Transport Stream
667 **/
668
669/* MPEG2 Time Shift Flag - not currently used anywhere */
670#define IEC61883_FDF_MPEG2_TSF 0x01
671
672/* size of a MPEG-2 Transport Stream packet */
673#define IEC61883_MPEG2_TSP_SIZE 188
674
675typedef struct iec61883_mpeg2* iec61883_mpeg2_t;
676
677typedef int
678(*iec61883_mpeg2_recv_t)(unsigned char *data, int len, unsigned int dropped,
679        void *callback_data);
680
681typedef int
682(*iec61883_mpeg2_xmit_t)(unsigned char *data, int n_packets,
683        unsigned int dropped, void *callback_data);
684
685/**
686 * iec61883_mpeg2_recv_init - setup reception of MPEG2-TS
687 * @handle: the libraw1394 handle to use for all operations
688 * @put_data: a function pointer to your callback routine
689 * @callback_data: an opaque pointer to provide to your callback function
690 *
691 * Returns:
692 * A pointer to an iec61883_mpeg2 object upon success or NULL for failure.
693 **/
694iec61883_mpeg2_t
695iec61883_mpeg2_recv_init(raw1394handle_t handle,
696                iec61883_mpeg2_recv_t put_data,
697                void *callback_data);
698
699/**
700 * iec61883_mpeg2_xmit_init - setup transmission of MPEG2-TS
701 * @handle: the libraw1394 handle to use for all operations
702 * @get_data: a function pointer to your callback routine
703 * @callback_data: an opaque pointer to provide to your callback function
704 *
705 * Returns:
706 * A pointer to an iec61883_mpeg2 object upon success or NULL for failure.
707 **/
708iec61883_mpeg2_t
709iec61883_mpeg2_xmit_init(raw1394handle_t handle,
710                iec61883_mpeg2_xmit_t get_data,
711                void *callback_data);
712
713/**
714 * iec61883_mpeg2_recv_start - start receiving MPEG2-TS
715 * @mpeg2: pointer to iec61883_mpeg2 object
716 * @channel: isochronous channel number
717 *
718 * Returns:
719 * 0 for success or -1 for failure
720 **/
721int
722iec61883_mpeg2_recv_start(iec61883_mpeg2_t mpeg2, int channel);
723
724/**
725 * iec61883_mpeg2_xmit_start - start transmitting MPEG2-TS
726 * @mpeg2: pointer to iec61883_mpeg2 object
727 * @pid: the program ID of the transport stream to select
728 * @channel: isochronous channel number
729 *
730 * Returns:
731 * 0 for success or -1 for failure
732 **/
733int
734iec61883_mpeg2_xmit_start(iec61883_mpeg2_t mpeg2, int pid, int channel);
735
736/**
737 * iec61883_mpeg2_recv_stop - stop receiving MPEG2-TS
738 * @mpeg2: pointer to the iec61883_mpeg2 object
739 **/
740void
741iec61883_mpeg2_recv_stop(iec61883_mpeg2_t mpeg2);
742
743/**
744 * iec61883_mpeg2_xmit_stop - stop transmitting MPEG2-TS
745 * @mpeg2: pointer to the iec61883_mpeg2 object
746 **/
747void
748iec61883_mpeg2_xmit_stop(iec61883_mpeg2_t mpeg2);
749
750/**
751 * iec61883_mpeg2_close - stop receiving or transmitting and destroy iec61883_mpeg2 object
752 * @mpeg2: pointer to iec61883_mpeg2 object
753 **/
754void
755iec61883_mpeg2_close(iec61883_mpeg2_t mpeg2);
756
757/**
758 * iec61883_mpeg2_get_buffers - get the size of the raw1394 buffer
759 * @mpeg2: pointer to iec61883_mpeg2 object
760 **/
761unsigned int
762iec61883_mpeg2_get_buffers(iec61883_mpeg2_t mpeg2);
763
764/**
765 * iec61883_mpeg2_set_buffers - set the size of the raw1394 buffer
766 * @mpeg2: pointer to iec61883_mpeg2 object
767 * @packets: the size of the buffer in packets
768 *
769 * This is an advanced option that can only be set after initialization and
770 * before reception or transmission.
771 **/
772void
773iec61883_mpeg2_set_buffers(iec61883_mpeg2_t mpeg2, unsigned int packets);
774
775/**
776 * iec61883_mpeg2_get_prebuffers - get the size of the pre-transmission buffer
777 * @mpeg2: pointer to iec61883_mpeg2 object
778 **/
779unsigned int
780iec61883_mpeg2_get_prebuffers(iec61883_mpeg2_t mpeg2);
781
782/**
783 * iec61883_mpeg2_set_prebuffers - set the size of the pre-transmission buffer
784 * @mpeg2: pointer to iec61883_mpeg2 object
785 * @packets: the size of the buffer in packets
786 *
787 * This is an advanced option that can only be set after initialization and
788 * before reception or transmission.
789 **/
790void
791iec61883_mpeg2_set_prebuffers(iec61883_mpeg2_t mpeg2, unsigned int packets);
792
793/**
794 * iec61883_mpeg2_get_irq_interval - get the interrupt rate
795 * @mpeg2: pointer to iec61883_mpeg2 object
796 **/
797unsigned int
798iec61883_mpeg2_get_irq_interval(iec61883_mpeg2_t mpeg2);
799
800/**
801 * iec61883_mpeg2_set_irq_interval - set the interrupt rate
802 * @mpeg2: pointer to iec61883_mpeg2 object
803 * @packets: the size of the interval in packets
804 *
805 * This is an advanced option that can only be set after initialization and
806 * before reception or transmission.
807 **/
808void
809iec61883_mpeg2_set_irq_interval(iec61883_mpeg2_t mpeg2, unsigned int packets);
810
811/**
812 * iec61883_mpeg2_get_synch - get behavior on close
813 * @mpeg2: pointer to iec61883_mpeg2 object
814 *
815 * If synch is not zero, then when stopping reception all packets in
816 * raw1394 buffers are flushed and invoking your callback function and when
817 * stopping transmission all packets in the raw1394 buffers are sent before
818 * the close function returns.
819 **/
820int
821iec61883_mpeg2_get_synch(iec61883_mpeg2_t mpeg2);
822
823/**
824 * iec61883_mpeg2_set_synch - set behavior on close
825 * @mpeg2: pointer to iec61883_mpeg2 object
826 * @synch: 1 if you want sync behaviour, 0 otherwise
827 *
828 * If synch is not zero, then when stopping reception all packets in
829 * raw1394 buffers are flushed and invoking your callback function and when
830 * stopping transmission all packets in the raw1394 buffers are sent before
831 * the close function returns.
832 **/
833void
834iec61883_mpeg2_set_synch(iec61883_mpeg2_t mpeg2, int synch);
835
836/**
837 * iec61883_mpeg2_get_speed - get data rate for transmission
838 * @mpeg2: pointer to iec61883_mpeg2 object
839 *
840 * Returns:
841 * one of enum raw1394_iso_speed (S100, S200, or S400)
842 **/
843int
844iec61883_mpeg2_get_speed(iec61883_mpeg2_t mpeg2);
845
846/**
847 * iec61883_mpeg2_set_speed - set data rate for transmission
848 * @mpeg2: pointer to iec61883_mepg2 object
849 * @speed: one of enum raw1394_iso_speed (S100, S200, or S400)
850 **/
851void
852iec61883_mpeg2_set_speed(iec61883_mpeg2_t mpeg2, int speed);
853
854/**
855 * iec61883_mpeg2_get_dropped - get the total number of dropped packets
856 * @mpeg2: pointer to iec61883_mpeg2 object
857 *
858 * Returns:
859 * The total number of dropped packets since starting transmission or reception.
860 **/
861unsigned int
862iec61883_mpeg2_get_dropped(iec61883_mpeg2_t mpeg2);
863
864/**
865 * iec61883_mpeg2_get_callback_data - get the callback data you supplied
866 * @mpeg2: pointer to iec61883_mpeg2 object
867 *
868 * This function is useful in bus reset callback routines because only
869 * the libraw1394 handle is available, and libiec61883 uses the userdata
870 * field of the libraw1394 handle.
871 *
872 * Returns:
873 * An opaque pointer to whatever you supplied when you called init.
874 **/
875void *
876iec61883_mpeg2_get_callback_data(iec61883_mpeg2_t mpeg2);
877
878
879/*******************************************************************************
880 * Connection Management Procedures
881 **/
882
883enum iec61883_pcr_overhead_id {
884        IEC61883_OVERHEAD_512 = 0,
885        IEC61883_OVERHEAD_32,
886        IEC61883_OVERHEAD_64,
887        IEC61883_OVERHEAD_96,
888        IEC61883_OVERHEAD_128,
889        IEC61883_OVERHEAD_160,
890        IEC61883_OVERHEAD_192,
891        IEC61883_OVERHEAD_224,
892        IEC61883_OVERHEAD_256,
893        IEC61883_OVERHEAD_288,
894        IEC61883_OVERHEAD_320,
895        IEC61883_OVERHEAD_352,
896        IEC61883_OVERHEAD_384,
897        IEC61883_OVERHEAD_416,
898        IEC61883_OVERHEAD_448,
899        IEC61883_OVERHEAD_480
900};
901
902/**
903 * iec61883_cmp_calc_bandwidth - calculate bandwidth allocation units
904 * @handle: a libraw1394 handle
905 * @output: the node id of the transmitter
906 * @plug: the index of the output plug
907 * @speed: if >= 0 then override the data rate factor
908 *
909 * Uses parameters of the output plug control register of the transmitter to
910 * calculate what its bandwidth requirements are. Parameters inlude payload,
911 * overhead_id, and data rate (optionally @speed).
912 *
913 * Returns:
914 * bandwidth allocation units or -1 on failure
915 **/
916int
917iec61883_cmp_calc_bandwidth (raw1394handle_t handle, nodeid_t output, int plug,
918        int speed);
919
920/**
921 * iec61883_cmp_connect - establish or overlay connection automatically
922 * @handle: a libraw1394 handle
923 * @output: node id of the transmitter
924 * @oplug: the output plug to use. If -1, find the first online plug, and
925 * upon return, contains the plug number used.
926 * @input: node id of the receiver
927 * @iplug: the input plug to use. If -1, find the first online plug, and
928 * upon return, contains the plug number used.
929 * @bandwidth: an input/output parameter. As an input this is a boolean that
930 * indicates whether to perform bandwidth allocation. Supply 0 to skip bandwidth
931 * allocation; any other value permits it. Upon return, actual bandwidth allocation
932 * units allocated are returned, which you supply to the disconnect routine.
933 *
934 * This is a high level function that attempts to be as smart as possible, but
935 * it gives point-to-point connections higher priority over broadcast connections.
936 * It can automatically handle situations where either @input and/or @output does
937 * not implement plug control registers. However, if one node implements plug
938 * registers it assumes the other node has some sort of manual channel selection
939 * (i.e., through software or a control panel).
940 *
941 * Returns:
942 * It returns the isochronous channel number selected or -1 if the function has
943 * failed for any reason.
944 **/
945int
946iec61883_cmp_connect (raw1394handle_t handle, nodeid_t output, int *oplug,
947        nodeid_t input, int *iplug, int *bandwidth);
948
949/**
950 * iec61883_cmp_reconnect - reestablish or overlay connection after a bus reset
951 * @handle: a libraw1394 handle
952 * @output: node id of the transmitter
953 * @oplug: the output plug to use. If -1, find the first online plug, and
954 * upon return, contains the plug number used.
955 * @input: node id of the receiver
956 * @iplug: the input plug to use. If -1, find the first online plug, and
957 * upon return, contains the plug number used.
958 * @bandwidth: an input/output parameter. As an input this is a boolean that
959 * indicates whether to perform bandwidth allocation. Supply 0 to skip bandwidth
960 * allocation; any other value permits it. Upon return, actual bandwidth allocation
961 * units allocated are returned, which you supply to the disconnect routine.
962 * @channel: the channel number on which to reconnect, if possible
963 *
964 * This is a high level function that attempts to be as smart as possible, but
965 * it gives point-to-point connections higher priority over broadcast connections.
966 * It can automatically handle situations where either @input and/or @output does
967 * not implement plug control registers. However, if one node implements plug
968 * registers it assumes the other node has some sort of manual channel selection
969 * (i.e., through software or a control panel).
970 *
971 * This function is useful in bus reset situations where it would be nice to
972 * reconfigure the transmission or reception if the channel does not need to
973 * change.
974 *
975 * Returns:
976 * It returns the isochronous channel number selected or -1 if the function has
977 * failed for any reason.
978 **/
979int
980iec61883_cmp_reconnect (raw1394handle_t handle, nodeid_t output, int *oplug,
981        nodeid_t input, int *iplug, int *bandwidth, int channel);
982
983/**
984 * iec61883_cmp_disconnect - break connection automatically
985 * @handle: a libraw1394 handle
986 * @output: node id of the transmitter
987 * @oplug: the output plug to use, or -1 to find the first online plug.
988 * @input: node id of the receiver
989 * @iplug: the input plug to use, or -1 to find the first online plug.
990 * @channel: the isochronous channel in use
991 * @bandwidth: the number of bandwidth allocation units to release when needed
992 *
993 * This high level connection management function automatically locates the
994 * appropriate plug on @output and @input based upon the channel number. It
995 * gracefully handles when node plugs exist on @output and/or @input. When there
996 * are no more point-to-point connections on output plug, then the channel and
997 * bandwidth are released.
998 *
999 * Returns:
1000 * 0 on success or -1 on failure
1001 **/
1002int
1003iec61883_cmp_disconnect (raw1394handle_t handle, nodeid_t output, int oplug,
1004        nodeid_t input, int iplug, unsigned int channel, unsigned int bandwidth);
1005
1006/**
1007 * iec61883_cmp_normalize_output - make IRM channels available consistent with plug
1008 * @handle: a libraw1394 handle
1009 * @node: node id of the transmitter
1010 *
1011 * Loops over every output plug on the node, and if it has a point-to-point or
1012 * broadcast connection, then make sure the channel is allocated with the
1013 * isochronous resource manager. This is used to help provide bus sanity and prevent
1014 * a channel from being used on a subsequent connection that might really already be
1015 * in usage!
1016 *
1017 * Returns:
1018 * 0 on success or -1 ojn failure
1019 **/
1020int
1021iec61883_cmp_normalize_output (raw1394handle_t handle, nodeid_t node);
1022
1023/*
1024 * The following CMP functions are lower level routines used by the above
1025 * connection procedures exposed here in case the above procedures do not fit
1026 * your use cases.
1027 */
1028int
1029iec61883_cmp_create_p2p (raw1394handle_t handle,
1030        nodeid_t output_node, int output_plug,
1031        nodeid_t input_node, int input_plug,
1032        unsigned int channel, unsigned int speed);
1033
1034int
1035iec61883_cmp_create_p2p_output (raw1394handle_t handle,
1036        nodeid_t output_node, int output_plug,
1037        unsigned int channel, unsigned int speed);
1038
1039int
1040iec61883_cmp_create_p2p_input (raw1394handle_t handle,
1041        nodeid_t input_node, int input_plug,
1042        unsigned int channel);
1043
1044int
1045iec61883_cmp_create_bcast (raw1394handle_t handle,
1046        nodeid_t output_node, int output_plug,
1047        nodeid_t input_node, int input_plug,
1048        unsigned int channel, unsigned int speed);
1049
1050int
1051iec61883_cmp_create_bcast_output (raw1394handle_t handle,
1052        nodeid_t output_node, int output_plug,
1053        unsigned int channel, unsigned int speed);
1054
1055int
1056iec61883_cmp_create_bcast_input (raw1394handle_t handle,
1057        nodeid_t input_node, int input_plug,
1058        unsigned int channel);
1059
1060int
1061iec61883_cmp_overlay_p2p (raw1394handle_t handle,
1062        nodeid_t output_node, int output_plug,
1063        nodeid_t input_node, int input_plug);
1064
1065int
1066iec61883_cmp_overlay_p2p_output (raw1394handle_t handle,
1067        nodeid_t output_node, int output_plug);
1068
1069int
1070iec61883_cmp_overlay_p2p_input (raw1394handle_t handle,
1071        nodeid_t input_node, int input_plug);
1072
1073int
1074iec61883_cmp_overlay_bcast (raw1394handle_t handle,
1075        nodeid_t output_node, int output_plug,
1076        nodeid_t input_node, int input_plug);
1077
1078/**
1079 * iec61883_plug_impr_init - Initialise hosting of local input plug registers.
1080 * @h: A raw1394 handle.
1081 * @data_rate: an enum iec61883_datarate
1082 *
1083 * Initially, no plugs are available; call iec61883_plug_add_ipcr() to add
1084 * plugs.
1085 *
1086 * Returns:
1087 * 0 for success, -EINVAL if data_rate is invalid, or or -1 (errno) on
1088 * libraw1394 failure.
1089 **/
1090int
1091iec61883_plug_impr_init (raw1394handle_t h, unsigned int data_rate);
1092
1093/**
1094 * ice61883_plug_impr_clear - Set the number of input plugs to zero.
1095 * @h: A raw1394 handle.
1096 **/
1097void
1098iec61883_plug_impr_clear (raw1394handle_t h);
1099
1100/**
1101 * iec61883_plug_impr_close - Stop hosting local input plugs.
1102 * @h: A raw1394 handle.
1103 *
1104 * Returns:
1105 * 0 for success, -1 (errno) on error.
1106 **/
1107int
1108iec61883_plug_impr_close (raw1394handle_t h);
1109
1110/**
1111 * iec61883_plug_add_ipcr - Add a local input plug.
1112 * @h: A raw1394 handle.
1113 * @online: The initial state of the plug: online (1) or not (0).
1114 *
1115 * You must call iec61883_plug_impr_init() before this.
1116 *
1117 * Returns:
1118 * plug number (>=0) on sucess or -EINVAL if online is not 0 or 1,
1119 * -ENOSPC if maximum plugs reached, or -EPERM if iec61883_plug_impr_init()
1120 * not called.
1121 **/
1122int
1123iec61883_plug_ipcr_add (raw1394handle_t h, unsigned int online);
1124
1125/**
1126 * iec61883_plug_ompr_init - Initialise hosting of local output plug registers.
1127 * @h: A raw1394 handle
1128 * @data_rate: one of enum iec61883_datarate
1129 * @bcast_channel: the broacast channel base (0 - 63)
1130 *
1131 * Initially, no plugs are available; call iec61883_plug_add_opcr() to add
1132 * plugs.
1133 *
1134 * Returns:
1135 * 0 for success, -EINVAL if data_rate or bcast_channel is invalid,
1136 * or or -1 (errno) on libraw1394 failure.
1137 **/
1138int
1139iec61883_plug_ompr_init (raw1394handle_t h, unsigned int data_rate,
1140        unsigned int bcast_channel);
1141
1142/**
1143 * ice61883_plug_ompr_clear - Set the number of output plugs to zero.
1144 * @h: A raw1394 handle.
1145 **/
1146void
1147iec61883_plug_ompr_clear (raw1394handle_t h);
1148
1149/**
1150 * iec61883_plug_ompr_close - Stop hosting local output plugs.
1151 * @h: A raw1394 handle.
1152 *
1153 * Returns:
1154 * 0 for success, -1 (errno) on error.
1155 **/
1156int
1157iec61883_plug_ompr_close (raw1394handle_t h);
1158
1159/**
1160 * iec61883_plug_add_opcr - Add a local output plug.
1161 * @h: A raw1394 handle.
1162 * @online: The initial state of the plug: online (1) or not (0).
1163 * @overhead_id: one of enum iec61883_pcr_overhead_id.
1164 * @payload: the maximum number of quadlets per packet.
1165 *
1166 * You must call iec61883_plug_ompr_init() before this.
1167 *
1168 * Returns:
1169 * plug number (>=0) on sucess, -EINVAL if online is not 0 or 1 or
1170 * if overhead_id or payload are out of range, -ENOSPC if maximum plugs
1171 * reached, or -EPERM if iec61883_plug_ompr_init() not called.
1172 **/
1173int
1174iec61883_plug_opcr_add (raw1394handle_t h, unsigned int online,
1175        unsigned int overhead_id, unsigned int payload);
1176
1177
1178#ifdef __cplusplus
1179}
1180#endif
1181
1182#endif /* _IEC61883_H */
Note: See TracBrowser for help on using the repository browser.