xref: /linux/drivers/media/usb/pvrusb2/pvrusb2-context.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*2504ba9fSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
20c0d06caSMauro Carvalho Chehab /*
30c0d06caSMauro Carvalho Chehab  *
40c0d06caSMauro Carvalho Chehab  *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
50c0d06caSMauro Carvalho Chehab  */
60c0d06caSMauro Carvalho Chehab #ifndef __PVRUSB2_CONTEXT_H
70c0d06caSMauro Carvalho Chehab #define __PVRUSB2_CONTEXT_H
80c0d06caSMauro Carvalho Chehab 
90c0d06caSMauro Carvalho Chehab #include <linux/mutex.h>
100c0d06caSMauro Carvalho Chehab #include <linux/usb.h>
110c0d06caSMauro Carvalho Chehab #include <linux/workqueue.h>
120c0d06caSMauro Carvalho Chehab 
130c0d06caSMauro Carvalho Chehab struct pvr2_hdw;     /* hardware interface - defined elsewhere */
140c0d06caSMauro Carvalho Chehab struct pvr2_stream;  /* stream interface - defined elsewhere */
150c0d06caSMauro Carvalho Chehab 
160c0d06caSMauro Carvalho Chehab struct pvr2_context;        /* All central state */
170c0d06caSMauro Carvalho Chehab struct pvr2_channel;        /* One I/O pathway to a user */
180c0d06caSMauro Carvalho Chehab struct pvr2_context_stream; /* Wrapper for a stream */
190c0d06caSMauro Carvalho Chehab struct pvr2_ioread;         /* Low level stream structure */
200c0d06caSMauro Carvalho Chehab 
210c0d06caSMauro Carvalho Chehab struct pvr2_context_stream {
220c0d06caSMauro Carvalho Chehab 	struct pvr2_channel *user;
230c0d06caSMauro Carvalho Chehab 	struct pvr2_stream *stream;
240c0d06caSMauro Carvalho Chehab };
250c0d06caSMauro Carvalho Chehab 
260c0d06caSMauro Carvalho Chehab struct pvr2_context {
270c0d06caSMauro Carvalho Chehab 	struct pvr2_channel *mc_first;
280c0d06caSMauro Carvalho Chehab 	struct pvr2_channel *mc_last;
290c0d06caSMauro Carvalho Chehab 	struct pvr2_context *exist_next;
300c0d06caSMauro Carvalho Chehab 	struct pvr2_context *exist_prev;
310c0d06caSMauro Carvalho Chehab 	struct pvr2_context *notify_next;
320c0d06caSMauro Carvalho Chehab 	struct pvr2_context *notify_prev;
330c0d06caSMauro Carvalho Chehab 	struct pvr2_hdw *hdw;
340c0d06caSMauro Carvalho Chehab 	struct pvr2_context_stream video_stream;
350c0d06caSMauro Carvalho Chehab 	struct mutex mutex;
360c0d06caSMauro Carvalho Chehab 	int notify_flag;
370c0d06caSMauro Carvalho Chehab 	int initialized_flag;
380c0d06caSMauro Carvalho Chehab 	int disconnect_flag;
390c0d06caSMauro Carvalho Chehab 
400c0d06caSMauro Carvalho Chehab 	/* Called after pvr2_context initialization is complete */
410c0d06caSMauro Carvalho Chehab 	void (*setup_func)(struct pvr2_context *);
420c0d06caSMauro Carvalho Chehab 
430c0d06caSMauro Carvalho Chehab };
440c0d06caSMauro Carvalho Chehab 
450c0d06caSMauro Carvalho Chehab struct pvr2_channel {
460c0d06caSMauro Carvalho Chehab 	struct pvr2_context *mc_head;
470c0d06caSMauro Carvalho Chehab 	struct pvr2_channel *mc_next;
480c0d06caSMauro Carvalho Chehab 	struct pvr2_channel *mc_prev;
490c0d06caSMauro Carvalho Chehab 	struct pvr2_context_stream *stream;
500c0d06caSMauro Carvalho Chehab 	struct pvr2_hdw *hdw;
510c0d06caSMauro Carvalho Chehab 	unsigned int input_mask;
520c0d06caSMauro Carvalho Chehab 	void (*check_func)(struct pvr2_channel *);
530c0d06caSMauro Carvalho Chehab };
540c0d06caSMauro Carvalho Chehab 
550c0d06caSMauro Carvalho Chehab struct pvr2_context *pvr2_context_create(struct usb_interface *intf,
560c0d06caSMauro Carvalho Chehab 					 const struct usb_device_id *devid,
570c0d06caSMauro Carvalho Chehab 					 void (*setup_func)(struct pvr2_context *));
580c0d06caSMauro Carvalho Chehab void pvr2_context_disconnect(struct pvr2_context *);
590c0d06caSMauro Carvalho Chehab 
600c0d06caSMauro Carvalho Chehab void pvr2_channel_init(struct pvr2_channel *,struct pvr2_context *);
610c0d06caSMauro Carvalho Chehab void pvr2_channel_done(struct pvr2_channel *);
620c0d06caSMauro Carvalho Chehab int pvr2_channel_limit_inputs(struct pvr2_channel *,unsigned int);
630c0d06caSMauro Carvalho Chehab unsigned int pvr2_channel_get_limited_inputs(struct pvr2_channel *);
640c0d06caSMauro Carvalho Chehab int pvr2_channel_claim_stream(struct pvr2_channel *,
650c0d06caSMauro Carvalho Chehab 			      struct pvr2_context_stream *);
660c0d06caSMauro Carvalho Chehab struct pvr2_ioread *pvr2_channel_create_mpeg_stream(
670c0d06caSMauro Carvalho Chehab 	struct pvr2_context_stream *);
680c0d06caSMauro Carvalho Chehab 
690c0d06caSMauro Carvalho Chehab int pvr2_context_global_init(void);
700c0d06caSMauro Carvalho Chehab void pvr2_context_global_done(void);
710c0d06caSMauro Carvalho Chehab 
720c0d06caSMauro Carvalho Chehab #endif /* __PVRUSB2_CONTEXT_H */
73