annotate dv1394.h @ 771:581bec6f0eb0 libavformat

update current_sample number for non split mode fix chunk split decission
author michael
date Sat, 21 May 2005 10:41:52 +0000
parents d98ed04d62a6
children da1d5db0ce5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
1 /*
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
2 * dv1394.h - DV input/output over IEEE 1394 on OHCI chips
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
3 * Copyright (C)2001 Daniel Maas <dmaas@dcine.com>
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
4 * receive, proc_fs by Dan Dennedy <dan@dennedy.org>
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
5 *
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
6 * based on:
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
7 * video1394.h - driver for OHCI 1394 boards
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
8 * Copyright (C)1999,2000 Sebastien Rougeaux <sebastien.rougeaux@anu.edu.au>
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
9 * Peter Schlaile <udbz@rz.uni-karlsruhe.de>
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
10 *
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
14 * (at your option) any later version.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
15 *
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
19 * GNU General Public License for more details.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
20 *
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
22 * along with this program; if not, write to the Free Software Foundation,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
23 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
24 */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
25
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
26 #ifndef _DV_1394_H
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
27 #define _DV_1394_H
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
28
185
d98ed04d62a6 patch for DV capturing by Dan Dennedy <dan at dennedy dot org>
romansh
parents: 156
diff changeset
29 #define DV1394_DEFAULT_CHANNEL 63
27
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
30 #define DV1394_DEFAULT_CARD 0
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
31 #define DV1394_RING_FRAMES 20
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
32
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
33 #define DV1394_WIDTH 720
156
al3x
parents: 155
diff changeset
34 #define DV1394_NTSC_HEIGHT 480
al3x
parents: 155
diff changeset
35 #define DV1394_PAL_HEIGHT 576
27
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
36
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
37 /* This is the public user-space interface. Try not to break it. */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
38
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
39 #define DV1394_API_VERSION 0x20011127
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
40
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
41 /* ********************
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
42 ** **
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
43 ** DV1394 API **
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
44 ** **
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
45 ********************
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
46
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
47 There are two methods of operating the DV1394 DV output device.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
48
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
49 1)
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
50
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
51 The simplest is an interface based on write(): simply write
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
52 full DV frames of data to the device, and they will be transmitted
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
53 as quickly as possible. The FD may be set for non-blocking I/O,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
54 in which case you can use select() or poll() to wait for output
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
55 buffer space.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
56
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
57 To set the DV output parameters (e.g. whether you want NTSC or PAL
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
58 video), use the DV1394_INIT ioctl, passing in the parameters you
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
59 want in a struct dv1394_init.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
60
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
61 Example 1:
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
62 To play a raw .DV file: cat foo.DV > /dev/dv1394
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
63 (cat will use write() internally)
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
64
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
65 Example 2:
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
66 static struct dv1394_init init = {
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
67 0x63, (broadcast channel)
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
68 4, (four-frame ringbuffer)
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
69 DV1394_NTSC, (send NTSC video)
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
70 0, 0 (default empty packet rate)
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
71 }
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
72
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
73 ioctl(fd, DV1394_INIT, &init);
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
74
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
75 while(1) {
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
76 read( <a raw DV file>, buf, DV1394_NTSC_FRAME_SIZE );
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
77 write( <the dv1394 FD>, buf, DV1394_NTSC_FRAME_SIZE );
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
78 }
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
79
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
80 2)
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
81
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
82 For more control over buffering, and to avoid unnecessary copies
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
83 of the DV data, you can use the more sophisticated the mmap() interface.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
84 First, call the DV1394_INIT ioctl to specify your parameters,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
85 including the number of frames in the ringbuffer. Then, calling mmap()
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
86 on the dv1394 device will give you direct access to the ringbuffer
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
87 from which the DV card reads your frame data.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
88
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
89 The ringbuffer is simply one large, contiguous region of memory
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
90 containing two or more frames of packed DV data. Each frame of DV data
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
91 is 120000 bytes (NTSC) or 144000 bytes (PAL).
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
92
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
93 Fill one or more frames in the ringbuffer, then use the DV1394_SUBMIT_FRAMES
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
94 ioctl to begin I/O. You can use either the DV1394_WAIT_FRAMES ioctl
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
95 or select()/poll() to wait until the frames are transmitted. Next, you'll
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
96 need to call the DV1394_GET_STATUS ioctl to determine which ringbuffer
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
97 frames are clear (ready to be filled with new DV data). Finally, use
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
98 DV1394_SUBMIT_FRAMES again to send the new data to the DV output.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
99
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
100
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
101 Example: here is what a four-frame ringbuffer might look like
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
102 during DV transmission:
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
103
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
104
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
105 frame 0 frame 1 frame 2 frame 3
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
106
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
107 *--------------------------------------*
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
108 | CLEAR | DV data | DV data | CLEAR |
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
109 *--------------------------------------*
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
110 <ACTIVE>
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
111
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
112 transmission goes in this direction --->>>
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
113
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
114
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
115 The DV hardware is currently transmitting the data in frame 1.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
116 Once frame 1 is finished, it will automatically transmit frame 2.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
117 (if frame 2 finishes before frame 3 is submitted, the device
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
118 will continue to transmit frame 2, and will increase the dropped_frames
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
119 counter each time it repeats the transmission).
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
120
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
121
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
122 If you called DV1394_GET_STATUS at this instant, you would
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
123 receive the following values:
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
124
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
125 n_frames = 4
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
126 active_frame = 1
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
127 first_clear_frame = 3
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
128 n_clear_frames = 2
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
129
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
130 At this point, you should write new DV data into frame 3 and optionally
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
131 frame 0. Then call DV1394_SUBMIT_FRAMES to inform the device that
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
132 it may transmit the new frames.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
133
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
134 ERROR HANDLING
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
135
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
136 An error (buffer underflow/overflow or a break in the DV stream due
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
137 to a 1394 bus reset) can be detected by checking the dropped_frames
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
138 field of struct dv1394_status (obtained through the
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
139 DV1394_GET_STATUS ioctl).
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
140
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
141 The best way to recover from such an error is to re-initialize
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
142 dv1394, either by using the DV1394_INIT ioctl call, or closing the
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
143 file descriptor and opening it again. (note that you must unmap all
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
144 ringbuffer mappings when closing the file descriptor, or else
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
145 dv1394 will still be considered 'in use').
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
146
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
147 MAIN LOOP
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
148
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
149 For maximum efficiency and robustness against bus errors, you are
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
150 advised to model the main loop of your application after the
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
151 following pseudo-code example:
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
152
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
153 (checks of system call return values omitted for brevity; always
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
154 check return values in your code!)
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
155
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
156 while( frames left ) {
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
157
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
158 struct pollfd *pfd = ...;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
159
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
160 pfd->fd = dv1394_fd;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
161 pfd->revents = 0;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
162 pfd->events = POLLOUT | POLLIN; (OUT for transmit, IN for receive)
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
163
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
164 (add other sources of I/O here)
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
165
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
166 poll(pfd, 1, -1); (or select(); add a timeout if you want)
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
167
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
168 if(pfd->revents) {
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
169 struct dv1394_status status;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
170
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
171 ioctl(dv1394_fd, DV1394_GET_STATUS, &status);
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
172
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
173 if(status.dropped_frames > 0) {
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
174 reset_dv1394();
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
175 } else {
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
176 for(int i = 0; i < status.n_clear_frames; i++) {
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
177 copy_DV_frame();
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
178 }
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
179 }
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
180 }
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
181 }
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
182
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
183 where copy_DV_frame() reads or writes on the dv1394 file descriptor
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
184 (read/write mode) or copies data to/from the mmap ringbuffer and
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
185 then calls ioctl(DV1394_SUBMIT_FRAMES) to notify dv1394 that new
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
186 frames are availble (mmap mode).
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
187
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
188 reset_dv1394() is called in the event of a buffer
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
189 underflow/overflow or a halt in the DV stream (e.g. due to a 1394
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
190 bus reset). To guarantee recovery from the error, this function
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
191 should close the dv1394 file descriptor (and munmap() all
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
192 ringbuffer mappings, if you are using them), then re-open the
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
193 dv1394 device (and re-map the ringbuffer).
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
194
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
195 */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
196
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
197
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
198 /* maximum number of frames in the ringbuffer */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
199 #define DV1394_MAX_FRAMES 32
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
200
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
201 /* number of *full* isochronous packets per DV frame */
185
d98ed04d62a6 patch for DV capturing by Dan Dennedy <dan at dennedy dot org>
romansh
parents: 156
diff changeset
202 #define DV1394_NTSC_PACKETS_PER_FRAME 250
d98ed04d62a6 patch for DV capturing by Dan Dennedy <dan at dennedy dot org>
romansh
parents: 156
diff changeset
203 #define DV1394_PAL_PACKETS_PER_FRAME 300
27
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
204
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
205 /* size of one frame's worth of DV data, in bytes */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
206 #define DV1394_NTSC_FRAME_SIZE (480 * DV1394_NTSC_PACKETS_PER_FRAME)
185
d98ed04d62a6 patch for DV capturing by Dan Dennedy <dan at dennedy dot org>
romansh
parents: 156
diff changeset
207 #define DV1394_PAL_FRAME_SIZE (480 * DV1394_PAL_PACKETS_PER_FRAME)
27
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
208
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
209
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
210 /* ioctl() commands */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
211
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
212 enum {
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
213 /* I don't like using 0 as a valid ioctl() */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
214 DV1394_INVALID = 0,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
215
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
216
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
217 /* get the driver ready to transmit video.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
218 pass a struct dv1394_init* as the parameter (see below),
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
219 or NULL to get default parameters */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
220 DV1394_INIT,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
221
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
222
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
223 /* stop transmitting video and free the ringbuffer */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
224 DV1394_SHUTDOWN,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
225
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
226
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
227 /* submit N new frames to be transmitted, where
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
228 the index of the first new frame is first_clear_buffer,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
229 and the index of the last new frame is
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
230 (first_clear_buffer + N) % n_frames */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
231 DV1394_SUBMIT_FRAMES,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
232
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
233
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
234 /* block until N buffers are clear (pass N as the parameter)
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
235 Because we re-transmit the last frame on underrun, there
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
236 will at most be n_frames - 1 clear frames at any time */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
237 DV1394_WAIT_FRAMES,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
238
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
239 /* capture new frames that have been received, where
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
240 the index of the first new frame is first_clear_buffer,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
241 and the index of the last new frame is
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
242 (first_clear_buffer + N) % n_frames */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
243 DV1394_RECEIVE_FRAMES,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
244
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
245
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
246 DV1394_START_RECEIVE,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
247
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
248
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
249 /* pass a struct dv1394_status* as the parameter (see below) */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
250 DV1394_GET_STATUS,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
251 };
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
252
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
253
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
254
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
255 enum pal_or_ntsc {
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
256 DV1394_NTSC = 0,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
257 DV1394_PAL
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
258 };
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
259
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
260
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
261
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
262
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
263 /* this is the argument to DV1394_INIT */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
264 struct dv1394_init {
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
265 /* DV1394_API_VERSION */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
266 unsigned int api_version;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
267
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
268 /* isochronous transmission channel to use */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
269 unsigned int channel;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
270
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
271 /* number of frames in the ringbuffer. Must be at least 2
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
272 and at most DV1394_MAX_FRAMES. */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
273 unsigned int n_frames;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
274
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
275 /* send/receive PAL or NTSC video format */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
276 enum pal_or_ntsc format;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
277
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
278 /* the following are used only for transmission */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
279
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
280 /* set these to zero unless you want a
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
281 non-default empty packet rate (see below) */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
282 unsigned long cip_n;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
283 unsigned long cip_d;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
284
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
285 /* set this to zero unless you want a
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
286 non-default SYT cycle offset (default = 3 cycles) */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
287 unsigned int syt_offset;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
288 };
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
289
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
290 /* NOTE: you may only allocate the DV frame ringbuffer once each time
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
291 you open the dv1394 device. DV1394_INIT will fail if you call it a
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
292 second time with different 'n_frames' or 'format' arguments (which
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
293 would imply a different size for the ringbuffer). If you need a
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
294 different buffer size, simply close and re-open the device, then
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
295 initialize it with your new settings. */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
296
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
297 /* Q: What are cip_n and cip_d? */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
298
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
299 /*
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
300 A: DV video streams do not utilize 100% of the potential bandwidth offered
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
301 by IEEE 1394 (FireWire). To achieve the correct rate of data transmission,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
302 DV devices must periodically insert empty packets into the 1394 data stream.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
303 Typically there is one empty packet per 14-16 data-carrying packets.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
304
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
305 Some DV devices will accept a wide range of empty packet rates, while others
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
306 require a precise rate. If the dv1394 driver produces empty packets at
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
307 a rate that your device does not accept, you may see ugly patterns on the
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
308 DV output, or even no output at all.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
309
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
310 The default empty packet insertion rate seems to work for many people; if
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
311 your DV output is stable, you can simply ignore this discussion. However,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
312 we have exposed the empty packet rate as a parameter to support devices that
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
313 do not work with the default rate.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
314
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
315 The decision to insert an empty packet is made with a numerator/denominator
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
316 algorithm. Empty packets are produced at an average rate of CIP_N / CIP_D.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
317 You can alter the empty packet rate by passing non-zero values for cip_n
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
318 and cip_d to the INIT ioctl.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
319
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
320 */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
321
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
322
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
323
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
324 struct dv1394_status {
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
325 /* this embedded init struct returns the current dv1394
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
326 parameters in use */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
327 struct dv1394_init init;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
328
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
329 /* the ringbuffer frame that is currently being
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
330 displayed. (-1 if the device is not transmitting anything) */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
331 int active_frame;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
332
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
333 /* index of the first buffer (ahead of active_frame) that
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
334 is ready to be filled with data */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
335 unsigned int first_clear_frame;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
336
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
337 /* how many buffers, including first_clear_buffer, are
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
338 ready to be filled with data */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
339 unsigned int n_clear_frames;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
340
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
341 /* how many times the DV stream has underflowed, overflowed,
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
342 or otherwise encountered an error, since the previous call
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
343 to DV1394_GET_STATUS */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
344 unsigned int dropped_frames;
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
345
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
346 /* N.B. The dropped_frames counter is only a lower bound on the actual
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
347 number of dropped frames, with the special case that if dropped_frames
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
348 is zero, then it is guaranteed that NO frames have been dropped
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
349 since the last call to DV1394_GET_STATUS.
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
350 */
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
351 };
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
352
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
353
fcdea3df94fe dv patch by Max Krasnyansky (maxk at qualcomm dot com)
bellard
parents:
diff changeset
354 #endif /* _DV_1394_H */