Linux-libre 5.3-gnu
[librecmc/linux-libre.git] / drivers / media / usb / pvrusb2 / pvrusb2-context.h
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
13 struct pvr2_hdw;     /* hardware interface - defined elsewhere */
14 struct pvr2_stream;  /* stream interface - defined elsewhere */
15
16 struct pvr2_context;        /* All central state */
17 struct pvr2_channel;        /* One I/O pathway to a user */
18 struct pvr2_context_stream; /* Wrapper for a stream */
19 struct pvr2_ioread;         /* Low level stream structure */
20
21 struct pvr2_context_stream {
22         struct pvr2_channel *user;
23         struct pvr2_stream *stream;
24 };
25
26 struct 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
45 struct 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
55 struct pvr2_context *pvr2_context_create(struct usb_interface *intf,
56                                          const struct usb_device_id *devid,
57                                          void (*setup_func)(struct pvr2_context *));
58 void pvr2_context_disconnect(struct pvr2_context *);
59
60 void pvr2_channel_init(struct pvr2_channel *,struct pvr2_context *);
61 void pvr2_channel_done(struct pvr2_channel *);
62 int pvr2_channel_limit_inputs(struct pvr2_channel *,unsigned int);
63 unsigned int pvr2_channel_get_limited_inputs(struct pvr2_channel *);
64 int pvr2_channel_claim_stream(struct pvr2_channel *,
65                               struct pvr2_context_stream *);
66 struct pvr2_ioread *pvr2_channel_create_mpeg_stream(
67         struct pvr2_context_stream *);
68
69 int pvr2_context_global_init(void);
70 void pvr2_context_global_done(void);
71
72 #endif /* __PVRUSB2_CONTEXT_H */