brintos

brintos / linux-shallow public Read only

0
0
Text · 2.5 KiB · 80e4f83 Raw
79 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 *4 *  Copyright (C) 2005 Mike Isely <isely@pobox.com>5 */6#ifndef __PVRUSB2_IO_H7#define __PVRUSB2_IO_H8 9#include <linux/usb.h>10#include <linux/list.h>11 12typedef void (*pvr2_stream_callback)(void *);13 14enum pvr2_buffer_state {15	pvr2_buffer_state_none = 0,   // Not on any list16	pvr2_buffer_state_idle = 1,   // Buffer is ready to be used again17	pvr2_buffer_state_queued = 2, // Buffer has been queued for filling18	pvr2_buffer_state_ready = 3,  // Buffer has data available19};20 21struct pvr2_stream;22struct pvr2_buffer;23 24struct 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 */34struct pvr2_stream *pvr2_stream_create(void);35void pvr2_stream_destroy(struct pvr2_stream *);36void pvr2_stream_setup(struct pvr2_stream *,37		       struct usb_device *dev,int endpoint,38		       unsigned int tolerance);39void pvr2_stream_set_callback(struct pvr2_stream *,40			      pvr2_stream_callback func,41			      void *data);42void pvr2_stream_get_stats(struct pvr2_stream *,43			   struct pvr2_stream_stats *,44			   int zero_counts);45 46/* Query / set the nominal buffer count */47int pvr2_stream_get_buffer_count(struct pvr2_stream *);48int 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 specified51   named. */52struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *);53struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *);54struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id);55 56/* Find out how many buffers are idle or ready */57int pvr2_stream_get_ready_count(struct pvr2_stream *);58 59 60/* Kill all pending buffers and throw away any ready buffers as well */61void pvr2_stream_kill(struct pvr2_stream *);62 63/* Set up the actual storage for a buffer */64int pvr2_buffer_set_buffer(struct pvr2_buffer *,void *ptr,unsigned int cnt);65 66/* Find out size of data in the given ready buffer */67unsigned int pvr2_buffer_get_count(struct pvr2_buffer *);68 69/* Retrieve completion code for given ready buffer */70int pvr2_buffer_get_status(struct pvr2_buffer *);71 72/* Retrieve ID of given buffer */73int pvr2_buffer_get_id(struct pvr2_buffer *);74 75/* Start reading into given buffer (kill it if needed) */76int pvr2_buffer_queue(struct pvr2_buffer *);77 78#endif /* __PVRUSB2_IO_H */79