Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *
0004  *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
0005  */
0006 #ifndef __PVRUSB2_IO_H
0007 #define __PVRUSB2_IO_H
0008 
0009 #include <linux/usb.h>
0010 #include <linux/list.h>
0011 
0012 typedef void (*pvr2_stream_callback)(void *);
0013 
0014 enum pvr2_buffer_state {
0015     pvr2_buffer_state_none = 0,   // Not on any list
0016     pvr2_buffer_state_idle = 1,   // Buffer is ready to be used again
0017     pvr2_buffer_state_queued = 2, // Buffer has been queued for filling
0018     pvr2_buffer_state_ready = 3,  // Buffer has data available
0019 };
0020 
0021 struct pvr2_stream;
0022 struct pvr2_buffer;
0023 
0024 struct pvr2_stream_stats {
0025     unsigned int buffers_in_queue;
0026     unsigned int buffers_in_idle;
0027     unsigned int buffers_in_ready;
0028     unsigned int buffers_processed;
0029     unsigned int buffers_failed;
0030     unsigned int bytes_processed;
0031 };
0032 
0033 /* Initialize / tear down stream structure */
0034 struct pvr2_stream *pvr2_stream_create(void);
0035 void pvr2_stream_destroy(struct pvr2_stream *);
0036 void pvr2_stream_setup(struct pvr2_stream *,
0037                struct usb_device *dev,int endpoint,
0038                unsigned int tolerance);
0039 void pvr2_stream_set_callback(struct pvr2_stream *,
0040                   pvr2_stream_callback func,
0041                   void *data);
0042 void pvr2_stream_get_stats(struct pvr2_stream *,
0043                struct pvr2_stream_stats *,
0044                int zero_counts);
0045 
0046 /* Query / set the nominal buffer count */
0047 int pvr2_stream_get_buffer_count(struct pvr2_stream *);
0048 int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int);
0049 
0050 /* Get a pointer to a buffer that is either idle, ready, or is specified
0051    named. */
0052 struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *);
0053 struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *);
0054 struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id);
0055 
0056 /* Find out how many buffers are idle or ready */
0057 int pvr2_stream_get_ready_count(struct pvr2_stream *);
0058 
0059 
0060 /* Kill all pending buffers and throw away any ready buffers as well */
0061 void pvr2_stream_kill(struct pvr2_stream *);
0062 
0063 /* Set up the actual storage for a buffer */
0064 int pvr2_buffer_set_buffer(struct pvr2_buffer *,void *ptr,unsigned int cnt);
0065 
0066 /* Find out size of data in the given ready buffer */
0067 unsigned int pvr2_buffer_get_count(struct pvr2_buffer *);
0068 
0069 /* Retrieve completion code for given ready buffer */
0070 int pvr2_buffer_get_status(struct pvr2_buffer *);
0071 
0072 /* Retrieve ID of given buffer */
0073 int pvr2_buffer_get_id(struct pvr2_buffer *);
0074 
0075 /* Start reading into given buffer (kill it if needed) */
0076 int pvr2_buffer_queue(struct pvr2_buffer *);
0077 
0078 #endif /* __PVRUSB2_IO_H */