GNU Linux-libre 4.14.259-gnu1
[releases.git] / drivers / media / usb / pvrusb2 / pvrusb2-context.h
1 /*
2  *
3  *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  */
15 #ifndef __PVRUSB2_CONTEXT_H
16 #define __PVRUSB2_CONTEXT_H
17
18 #include <linux/mutex.h>
19 #include <linux/usb.h>
20 #include <linux/workqueue.h>
21
22 struct pvr2_hdw;     /* hardware interface - defined elsewhere */
23 struct pvr2_stream;  /* stream interface - defined elsewhere */
24
25 struct pvr2_context;        /* All central state */
26 struct pvr2_channel;        /* One I/O pathway to a user */
27 struct pvr2_context_stream; /* Wrapper for a stream */
28 struct pvr2_ioread;         /* Low level stream structure */
29
30 struct pvr2_context_stream {
31         struct pvr2_channel *user;
32         struct pvr2_stream *stream;
33 };
34
35 struct pvr2_context {
36         struct pvr2_channel *mc_first;
37         struct pvr2_channel *mc_last;
38         struct pvr2_context *exist_next;
39         struct pvr2_context *exist_prev;
40         struct pvr2_context *notify_next;
41         struct pvr2_context *notify_prev;
42         struct pvr2_hdw *hdw;
43         struct pvr2_context_stream video_stream;
44         struct mutex mutex;
45         int notify_flag;
46         int initialized_flag;
47         int disconnect_flag;
48
49         /* Called after pvr2_context initialization is complete */
50         void (*setup_func)(struct pvr2_context *);
51
52 };
53
54 struct pvr2_channel {
55         struct pvr2_context *mc_head;
56         struct pvr2_channel *mc_next;
57         struct pvr2_channel *mc_prev;
58         struct pvr2_context_stream *stream;
59         struct pvr2_hdw *hdw;
60         unsigned int input_mask;
61         void (*check_func)(struct pvr2_channel *);
62 };
63
64 struct pvr2_context *pvr2_context_create(struct usb_interface *intf,
65                                          const struct usb_device_id *devid,
66                                          void (*setup_func)(struct pvr2_context *));
67 void pvr2_context_disconnect(struct pvr2_context *);
68
69 void pvr2_channel_init(struct pvr2_channel *,struct pvr2_context *);
70 void pvr2_channel_done(struct pvr2_channel *);
71 int pvr2_channel_limit_inputs(struct pvr2_channel *,unsigned int);
72 unsigned int pvr2_channel_get_limited_inputs(struct pvr2_channel *);
73 int pvr2_channel_claim_stream(struct pvr2_channel *,
74                               struct pvr2_context_stream *);
75 struct pvr2_ioread *pvr2_channel_create_mpeg_stream(
76         struct pvr2_context_stream *);
77
78 int pvr2_context_global_init(void);
79 void pvr2_context_global_done(void);
80
81 #endif /* __PVRUSB2_CONTEXT_H */