1 /* SPDX-License-Identifier: GPL-2.0-only */
10 #include <linux/list.h>
12 typedef void (*pvr2_stream_callback)(void *);
14 enum pvr2_buffer_state {
15 pvr2_buffer_state_none = 0, // Not on any list
16 pvr2_buffer_state_idle = 1, // Buffer is ready to be used again
17 pvr2_buffer_state_queued = 2, // Buffer has been queued for filling
18 pvr2_buffer_state_ready = 3, // Buffer has data available
24 struct pvr2_stream_stats {
25 unsigned int buffers_in_queue;
26 unsigned int buffers_in_idle;
27 unsigned int buffers_in_ready;
28 unsigned int buffers_processed;
29 unsigned int buffers_failed;
30 unsigned int bytes_processed;
33 /* Initialize / tear down stream structure */
34 struct pvr2_stream *pvr2_stream_create(void);
35 void pvr2_stream_destroy(struct pvr2_stream *);
36 void pvr2_stream_setup(struct pvr2_stream *,
37 struct usb_device *dev,int endpoint,
38 unsigned int tolerance);
39 void pvr2_stream_set_callback(struct pvr2_stream *,
40 pvr2_stream_callback func,
42 void pvr2_stream_get_stats(struct pvr2_stream *,
43 struct pvr2_stream_stats *,
46 /* Query / set the nominal buffer count */
47 int pvr2_stream_get_buffer_count(struct pvr2_stream *);
48 int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int);
50 /* Get a pointer to a buffer that is either idle, ready, or is specified
52 struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *);
53 struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *);
54 struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id);
56 /* Find out how many buffers are idle or ready */
57 int pvr2_stream_get_ready_count(struct pvr2_stream *);
60 /* Kill all pending buffers and throw away any ready buffers as well */
61 void pvr2_stream_kill(struct pvr2_stream *);
63 /* Set up the actual storage for a buffer */
64 int pvr2_buffer_set_buffer(struct pvr2_buffer *,void *ptr,unsigned int cnt);
66 /* Find out size of data in the given ready buffer */
67 unsigned int pvr2_buffer_get_count(struct pvr2_buffer *);
69 /* Retrieve completion code for given ready buffer */
70 int pvr2_buffer_get_status(struct pvr2_buffer *);
72 /* Retrieve ID of given buffer */
73 int pvr2_buffer_get_id(struct pvr2_buffer *);
75 /* Start reading into given buffer (kill it if needed) */
76 int pvr2_buffer_queue(struct pvr2_buffer *);
78 #endif /* __PVRUSB2_IO_H */