Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * $Id$ |
| 4 | * |
| 5 | * Copyright (C) 2005 Mike Isely <isely@pobox.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | * |
| 20 | */ |
| 21 | #ifndef __PVRUSB2_IO_H |
| 22 | #define __PVRUSB2_IO_H |
| 23 | |
| 24 | #include <linux/usb.h> |
| 25 | #include <linux/list.h> |
| 26 | |
| 27 | typedef void (*pvr2_stream_callback)(void *); |
| 28 | |
| 29 | enum pvr2_buffer_state { |
| 30 | pvr2_buffer_state_none = 0, // Not on any list |
| 31 | pvr2_buffer_state_idle = 1, // Buffer is ready to be used again |
| 32 | pvr2_buffer_state_queued = 2, // Buffer has been queued for filling |
| 33 | pvr2_buffer_state_ready = 3, // Buffer has data available |
| 34 | }; |
| 35 | |
| 36 | struct pvr2_stream; |
| 37 | struct pvr2_buffer; |
| 38 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 39 | /* Initialize / tear down stream structure */ |
| 40 | struct pvr2_stream *pvr2_stream_create(void); |
| 41 | void pvr2_stream_destroy(struct pvr2_stream *); |
| 42 | void pvr2_stream_setup(struct pvr2_stream *, |
| 43 | struct usb_device *dev,int endpoint, |
| 44 | unsigned int tolerance); |
| 45 | void pvr2_stream_set_callback(struct pvr2_stream *, |
| 46 | pvr2_stream_callback func, |
| 47 | void *data); |
| 48 | |
| 49 | /* Query / set the nominal buffer count */ |
Mike Isely | e61b6fc | 2006-07-18 22:42:18 -0300 | [diff] [blame] | 50 | int pvr2_stream_get_buffer_count(struct pvr2_stream *); |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 51 | int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int); |
| 52 | |
| 53 | /* Get a pointer to a buffer that is either idle, ready, or is specified |
| 54 | named. */ |
| 55 | struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *); |
| 56 | struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *); |
| 57 | struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id); |
| 58 | |
| 59 | /* Find out how many buffers are idle or ready */ |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 60 | int pvr2_stream_get_ready_count(struct pvr2_stream *); |
| 61 | |
Mike Isely | e61b6fc | 2006-07-18 22:42:18 -0300 | [diff] [blame] | 62 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 63 | /* Kill all pending buffers and throw away any ready buffers as well */ |
| 64 | void pvr2_stream_kill(struct pvr2_stream *); |
| 65 | |
| 66 | /* Set up the actual storage for a buffer */ |
| 67 | int pvr2_buffer_set_buffer(struct pvr2_buffer *,void *ptr,unsigned int cnt); |
| 68 | |
| 69 | /* Find out size of data in the given ready buffer */ |
| 70 | unsigned int pvr2_buffer_get_count(struct pvr2_buffer *); |
| 71 | |
| 72 | /* Retrieve completion code for given ready buffer */ |
| 73 | int pvr2_buffer_get_status(struct pvr2_buffer *); |
| 74 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 75 | /* Retrieve ID of given buffer */ |
| 76 | int pvr2_buffer_get_id(struct pvr2_buffer *); |
| 77 | |
| 78 | /* Start reading into given buffer (kill it if needed) */ |
| 79 | int pvr2_buffer_queue(struct pvr2_buffer *); |
| 80 | |
Mike Isely | d855497 | 2006-06-26 20:58:46 -0300 | [diff] [blame] | 81 | #endif /* __PVRUSB2_IO_H */ |
| 82 | |
| 83 | /* |
| 84 | Stuff for Emacs to see, in order to encourage consistent editing style: |
| 85 | *** Local Variables: *** |
| 86 | *** mode: c *** |
| 87 | *** fill-column: 75 *** |
| 88 | *** tab-width: 8 *** |
| 89 | *** c-basic-offset: 8 *** |
| 90 | *** End: *** |
| 91 | */ |