1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 *
4 *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
5 */
6#ifndef __PVRUSB2_CONTEXT_H
7#define __PVRUSB2_CONTEXT_H
8
9#include <linux/mutex.h>
10#include <linux/usb.h>
11#include <linux/workqueue.h>
12
13struct pvr2_hdw;     /* hardware interface - defined elsewhere */
14struct pvr2_stream;  /* stream interface - defined elsewhere */
15
16struct pvr2_context;        /* All central state */
17struct pvr2_channel;        /* One I/O pathway to a user */
18struct pvr2_context_stream; /* Wrapper for a stream */
19struct pvr2_ioread;         /* Low level stream structure */
20
21struct pvr2_context_stream {
22	struct pvr2_channel *user;
23	struct pvr2_stream *stream;
24};
25
26struct pvr2_context {
27	struct pvr2_channel *mc_first;
28	struct pvr2_channel *mc_last;
29	struct pvr2_context *exist_next;
30	struct pvr2_context *exist_prev;
31	struct pvr2_context *notify_next;
32	struct pvr2_context *notify_prev;
33	struct pvr2_hdw *hdw;
34	struct pvr2_context_stream video_stream;
35	struct mutex mutex;
36	int notify_flag;
37	int initialized_flag;
38	int disconnect_flag;
39
40	/* Called after pvr2_context initialization is complete */
41	void (*setup_func)(struct pvr2_context *);
42
43};
44
45struct pvr2_channel {
46	struct pvr2_context *mc_head;
47	struct pvr2_channel *mc_next;
48	struct pvr2_channel *mc_prev;
49	struct pvr2_context_stream *stream;
50	struct pvr2_hdw *hdw;
51	unsigned int input_mask;
52	void (*check_func)(struct pvr2_channel *);
53};
54
55struct pvr2_context *pvr2_context_create(struct usb_interface *intf,
56					 const struct usb_device_id *devid,
57					 void (*setup_func)(struct pvr2_context *));
58void pvr2_context_disconnect(struct pvr2_context *);
59
60void pvr2_channel_init(struct pvr2_channel *,struct pvr2_context *);
61void pvr2_channel_done(struct pvr2_channel *);
62int pvr2_channel_limit_inputs(struct pvr2_channel *,unsigned int);
63unsigned int pvr2_channel_get_limited_inputs(struct pvr2_channel *);
64int pvr2_channel_claim_stream(struct pvr2_channel *,
65			      struct pvr2_context_stream *);
66struct pvr2_ioread *pvr2_channel_create_mpeg_stream(
67	struct pvr2_context_stream *);
68
69int pvr2_context_global_init(void);
70void pvr2_context_global_done(void);
71
72#endif /* __PVRUSB2_CONTEXT_H */
73