xref: /haiku/headers/os/drivers/USB_rle.h (revision 4f2fd49bdc6078128b1391191e4edac647044c3d)
1 /*
2 ** USB_rle.h
3 **
4 ** Copyright 1999, Be Incorporated. All Rights Reserved.
5 **
6 */
7 
8 #ifndef _USB_RLE_H
9 #define _USB_RLE_H
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 struct _usbd_param_hdr;
16 
17 /*
18 Run Length encoding records for isochronous IN transfers.
19 
20 Run Length encoding records are used to identify which samples in
21 the buffer are good which are bad and which are missing.
22 Bad bytes are not extracted from the buffer, but are padded to next
23 nearest sample boundary.  The ultimate consumer of the buffer
24 should also receive the RLE array.
25 
26 RLE records are constructed based on the following rules:
27 
28 1.	an RLE record contains a sample count and a status
29 	(good, bad, missing or unknown). A buffer has
30 	associated with it an array of rle records. The number of
31 	rle records available is specified in the RLE header. The
32 	number used is also in the RLE header.
33 
34 2.	Within the scope of a buffer, successive packets with the
35 	same completion status are represented with (1) rle record.
36 	For example, after three transactions which have completion
37 	status of success, the byte count in the rle record for this
38 	position in the data stream represents the bytes received in
39 	all three packets.
40 
41 3.	New rle records are initialized each time the status for a
42 	given packet differs from that of the previous packet.
43 
44 */
45 
46 #define RLE_GOOD       1
47 #define RLE_BAD        2
48 #define RLE_MISSING    3
49 #define RLE_UNKNOWN    4
50 
51 /*
52 Name:    rle
53 Purpose: used to represent the state of a portion of a data buffer
54 Fields:
55 	rle_status		will contain only the values: RLE_GOOD, RLE_BAD, RLE_MISSING
56 	sample_count	the number of usb samples in the buffer associated with this rle
57 					record.
58 Notes:
59 	If the buffer length field in queue_buffer_single structure changes to an
60 	uint32 from uin16, then the sample_count data type must
61 	track this change.
62 */
63 typedef struct rle {
64 	uint16	rle_status;
65 	uint16	sample_count;
66 } rle;
67 
68 
69 /*
70 Name:    rlea
71 Purpose: used as the primary rle information data structure between the
72 	USB driver stack and a consuming client.
73 
74 Fields:
75 	length		the number of rle records available in this structure.
76 	num_valid	filled in by the USB driver. indicates the number of valid
77 				records filled.
78 	rles[]		unconstrained array of rle records.
79 */
80 typedef struct rlea {
81 	uint16	length;
82 	uint16	num_valid;
83 	rle		rles[1];
84 } rlea;
85 
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif
92