18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci#ifndef __PVRUSB2_IO_H
78c2ecf20Sopenharmony_ci#define __PVRUSB2_IO_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/usb.h>
108c2ecf20Sopenharmony_ci#include <linux/list.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_citypedef void (*pvr2_stream_callback)(void *);
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cienum pvr2_buffer_state {
158c2ecf20Sopenharmony_ci	pvr2_buffer_state_none = 0,   // Not on any list
168c2ecf20Sopenharmony_ci	pvr2_buffer_state_idle = 1,   // Buffer is ready to be used again
178c2ecf20Sopenharmony_ci	pvr2_buffer_state_queued = 2, // Buffer has been queued for filling
188c2ecf20Sopenharmony_ci	pvr2_buffer_state_ready = 3,  // Buffer has data available
198c2ecf20Sopenharmony_ci};
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_cistruct pvr2_stream;
228c2ecf20Sopenharmony_cistruct pvr2_buffer;
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistruct pvr2_stream_stats {
258c2ecf20Sopenharmony_ci	unsigned int buffers_in_queue;
268c2ecf20Sopenharmony_ci	unsigned int buffers_in_idle;
278c2ecf20Sopenharmony_ci	unsigned int buffers_in_ready;
288c2ecf20Sopenharmony_ci	unsigned int buffers_processed;
298c2ecf20Sopenharmony_ci	unsigned int buffers_failed;
308c2ecf20Sopenharmony_ci	unsigned int bytes_processed;
318c2ecf20Sopenharmony_ci};
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/* Initialize / tear down stream structure */
348c2ecf20Sopenharmony_cistruct pvr2_stream *pvr2_stream_create(void);
358c2ecf20Sopenharmony_civoid pvr2_stream_destroy(struct pvr2_stream *);
368c2ecf20Sopenharmony_civoid pvr2_stream_setup(struct pvr2_stream *,
378c2ecf20Sopenharmony_ci		       struct usb_device *dev,int endpoint,
388c2ecf20Sopenharmony_ci		       unsigned int tolerance);
398c2ecf20Sopenharmony_civoid pvr2_stream_set_callback(struct pvr2_stream *,
408c2ecf20Sopenharmony_ci			      pvr2_stream_callback func,
418c2ecf20Sopenharmony_ci			      void *data);
428c2ecf20Sopenharmony_civoid pvr2_stream_get_stats(struct pvr2_stream *,
438c2ecf20Sopenharmony_ci			   struct pvr2_stream_stats *,
448c2ecf20Sopenharmony_ci			   int zero_counts);
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/* Query / set the nominal buffer count */
478c2ecf20Sopenharmony_ciint pvr2_stream_get_buffer_count(struct pvr2_stream *);
488c2ecf20Sopenharmony_ciint pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int);
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/* Get a pointer to a buffer that is either idle, ready, or is specified
518c2ecf20Sopenharmony_ci   named. */
528c2ecf20Sopenharmony_cistruct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *);
538c2ecf20Sopenharmony_cistruct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *);
548c2ecf20Sopenharmony_cistruct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id);
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* Find out how many buffers are idle or ready */
578c2ecf20Sopenharmony_ciint pvr2_stream_get_ready_count(struct pvr2_stream *);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/* Kill all pending buffers and throw away any ready buffers as well */
618c2ecf20Sopenharmony_civoid pvr2_stream_kill(struct pvr2_stream *);
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* Set up the actual storage for a buffer */
648c2ecf20Sopenharmony_ciint pvr2_buffer_set_buffer(struct pvr2_buffer *,void *ptr,unsigned int cnt);
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/* Find out size of data in the given ready buffer */
678c2ecf20Sopenharmony_ciunsigned int pvr2_buffer_get_count(struct pvr2_buffer *);
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci/* Retrieve completion code for given ready buffer */
708c2ecf20Sopenharmony_ciint pvr2_buffer_get_status(struct pvr2_buffer *);
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/* Retrieve ID of given buffer */
738c2ecf20Sopenharmony_ciint pvr2_buffer_get_id(struct pvr2_buffer *);
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci/* Start reading into given buffer (kill it if needed) */
768c2ecf20Sopenharmony_ciint pvr2_buffer_queue(struct pvr2_buffer *);
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#endif /* __PVRUSB2_IO_H */
79