]>
Commit | Line | Data |
---|---|---|
d855497e MI |
1 | /* |
2 | * | |
d855497e MI |
3 | * |
4 | * Copyright (C) 2005 Mike Isely <isely@pobox.com> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
d855497e MI |
15 | */ |
16 | #ifndef __PVRUSB2_IO_H | |
17 | #define __PVRUSB2_IO_H | |
18 | ||
19 | #include <linux/usb.h> | |
20 | #include <linux/list.h> | |
21 | ||
22 | typedef void (*pvr2_stream_callback)(void *); | |
23 | ||
24 | enum pvr2_buffer_state { | |
25 | pvr2_buffer_state_none = 0, // Not on any list | |
26 | pvr2_buffer_state_idle = 1, // Buffer is ready to be used again | |
27 | pvr2_buffer_state_queued = 2, // Buffer has been queued for filling | |
28 | pvr2_buffer_state_ready = 3, // Buffer has data available | |
29 | }; | |
30 | ||
31 | struct pvr2_stream; | |
32 | struct pvr2_buffer; | |
33 | ||
ad0992e9 MI |
34 | struct pvr2_stream_stats { |
35 | unsigned int buffers_in_queue; | |
36 | unsigned int buffers_in_idle; | |
37 | unsigned int buffers_in_ready; | |
38 | unsigned int buffers_processed; | |
39 | unsigned int buffers_failed; | |
40 | unsigned int bytes_processed; | |
41 | }; | |
42 | ||
d855497e MI |
43 | /* Initialize / tear down stream structure */ |
44 | struct pvr2_stream *pvr2_stream_create(void); | |
45 | void pvr2_stream_destroy(struct pvr2_stream *); | |
46 | void pvr2_stream_setup(struct pvr2_stream *, | |
47 | struct usb_device *dev,int endpoint, | |
48 | unsigned int tolerance); | |
49 | void pvr2_stream_set_callback(struct pvr2_stream *, | |
50 | pvr2_stream_callback func, | |
51 | void *data); | |
ad0992e9 MI |
52 | void pvr2_stream_get_stats(struct pvr2_stream *, |
53 | struct pvr2_stream_stats *, | |
54 | int zero_counts); | |
d855497e MI |
55 | |
56 | /* Query / set the nominal buffer count */ | |
e61b6fc5 | 57 | int pvr2_stream_get_buffer_count(struct pvr2_stream *); |
d855497e MI |
58 | int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int); |
59 | ||
60 | /* Get a pointer to a buffer that is either idle, ready, or is specified | |
61 | named. */ | |
62 | struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *); | |
63 | struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *); | |
64 | struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id); | |
65 | ||
66 | /* Find out how many buffers are idle or ready */ | |
d855497e MI |
67 | int pvr2_stream_get_ready_count(struct pvr2_stream *); |
68 | ||
e61b6fc5 | 69 | |
d855497e MI |
70 | /* Kill all pending buffers and throw away any ready buffers as well */ |
71 | void pvr2_stream_kill(struct pvr2_stream *); | |
72 | ||
73 | /* Set up the actual storage for a buffer */ | |
74 | int pvr2_buffer_set_buffer(struct pvr2_buffer *,void *ptr,unsigned int cnt); | |
75 | ||
76 | /* Find out size of data in the given ready buffer */ | |
77 | unsigned int pvr2_buffer_get_count(struct pvr2_buffer *); | |
78 | ||
79 | /* Retrieve completion code for given ready buffer */ | |
80 | int pvr2_buffer_get_status(struct pvr2_buffer *); | |
81 | ||
d855497e MI |
82 | /* Retrieve ID of given buffer */ |
83 | int pvr2_buffer_get_id(struct pvr2_buffer *); | |
84 | ||
85 | /* Start reading into given buffer (kill it if needed) */ | |
86 | int pvr2_buffer_queue(struct pvr2_buffer *); | |
87 | ||
d855497e | 88 | #endif /* __PVRUSB2_IO_H */ |