David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 4 | * Copyright (C) 2005 Mike Isely <isely@pobox.com> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __PVRUSB2_IO_H |
| 7 | #define __PVRUSB2_IO_H |
| 8 | |
| 9 | #include <linux/usb.h> |
| 10 | #include <linux/list.h> |
| 11 | |
| 12 | typedef void (*pvr2_stream_callback)(void *); |
| 13 | |
| 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 |
| 19 | }; |
| 20 | |
| 21 | struct pvr2_stream; |
| 22 | struct pvr2_buffer; |
| 23 | |
| 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; |
| 31 | }; |
| 32 | |
| 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, |
| 41 | void *data); |
| 42 | void pvr2_stream_get_stats(struct pvr2_stream *, |
| 43 | struct pvr2_stream_stats *, |
| 44 | int zero_counts); |
| 45 | |
| 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); |
| 49 | |
| 50 | /* Get a pointer to a buffer that is either idle, ready, or is specified |
| 51 | named. */ |
| 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); |
| 55 | |
| 56 | /* Find out how many buffers are idle or ready */ |
| 57 | int pvr2_stream_get_ready_count(struct pvr2_stream *); |
| 58 | |
| 59 | |
| 60 | /* Kill all pending buffers and throw away any ready buffers as well */ |
| 61 | void pvr2_stream_kill(struct pvr2_stream *); |
| 62 | |
| 63 | /* Set up the actual storage for a buffer */ |
| 64 | int pvr2_buffer_set_buffer(struct pvr2_buffer *,void *ptr,unsigned int cnt); |
| 65 | |
| 66 | /* Find out size of data in the given ready buffer */ |
| 67 | unsigned int pvr2_buffer_get_count(struct pvr2_buffer *); |
| 68 | |
| 69 | /* Retrieve completion code for given ready buffer */ |
| 70 | int pvr2_buffer_get_status(struct pvr2_buffer *); |
| 71 | |
| 72 | /* Retrieve ID of given buffer */ |
| 73 | int pvr2_buffer_get_id(struct pvr2_buffer *); |
| 74 | |
| 75 | /* Start reading into given buffer (kill it if needed) */ |
| 76 | int pvr2_buffer_queue(struct pvr2_buffer *); |
| 77 | |
| 78 | #endif /* __PVRUSB2_IO_H */ |