xref: /linux/drivers/media/pci/ttpci/budget.h (revision 3269d6fb7580e91313f40dffcff70c01cd3f0717)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef __BUDGET_DVB__
4 #define __BUDGET_DVB__
5 
6 #ifdef pr_fmt
7 #undef pr_fmt
8 #endif
9 
10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11 
12 #include <media/dvb_frontend.h>
13 #include <media/dvbdev.h>
14 #include <media/demux.h>
15 #include <media/dvb_demux.h>
16 #include <media/dmxdev.h>
17 #include <media/dvb_net.h>
18 
19 #include <linux/module.h>
20 #include <linux/mutex.h>
21 
22 #include <media/drv-intf/saa7146.h>
23 
24 extern int budget_debug;
25 
26 #ifdef dprintk
27 #undef dprintk
28 #endif
29 
30 #define dprintk(level, fmt, arg...) do {				\
31 	if ((level) & budget_debug)					\
32 		pr_info("%s(): " fmt, __func__, ##arg);			\
33 } while (0)
34 
35 #define TS_SIZE        188
36 
37 struct budget_info {
38 	char *name;
39 	int type;
40 };
41 
42 /* place to store all the necessary device information */
43 struct budget {
44 
45 	/* devices */
46 	struct dvb_device dvb_dev;
47 	struct dvb_net dvb_net;
48 
49 	struct saa7146_dev *dev;
50 
51 	struct i2c_adapter i2c_adap;
52 	struct budget_info *card;
53 
54 	unsigned char *grabbing;
55 	struct saa7146_pgtable pt;
56 
57 	struct tasklet_struct fidb_tasklet;
58 	struct tasklet_struct vpe_tasklet;
59 
60 	struct dmxdev dmxdev;
61 	struct dvb_demux demux;
62 
63 	struct dmx_frontend hw_frontend;
64 	struct dmx_frontend mem_frontend;
65 
66 	int ci_present;
67 	int video_port;
68 
69 	u32 buffer_width;
70 	u32 buffer_height;
71 	u32 buffer_size;
72 	u32 buffer_warning_threshold;
73 	u32 buffer_warnings;
74 	unsigned long buffer_warning_time;
75 
76 	u32 ttbp;
77 	int feeding;
78 
79 	spinlock_t feedlock;
80 
81 	spinlock_t debilock;
82 
83 	struct dvb_adapter dvb_adapter;
84 	struct dvb_frontend *dvb_frontend;
85 	int (*read_fe_status)(struct dvb_frontend *fe, enum fe_status *status);
86 	int fe_synced;
87 
88 	void *priv;
89 };
90 
91 #define MAKE_BUDGET_INFO(x_var, x_name, x_type) \
92 static struct budget_info x_var ## _info = { \
93 	.name = x_name,	\
94 	.type = x_type };	\
95 static struct saa7146_pci_extension_data x_var = { \
96 	.ext_priv = &x_var ## _info, \
97 	.ext = &budget_extension }
98 
99 #define BUDGET_TT		   0
100 #define BUDGET_TT_HW_DISEQC	   1
101 #define BUDGET_PATCH		   3
102 #define BUDGET_FS_ACTIVY	   4
103 #define BUDGET_CIN1200S		   5
104 #define BUDGET_CIN1200C		   6
105 #define BUDGET_CIN1200T		   7
106 #define BUDGET_KNC1S		   8
107 #define BUDGET_KNC1C		   9
108 #define BUDGET_KNC1T		   10
109 #define BUDGET_KNC1SP		   11
110 #define BUDGET_KNC1CP		   12
111 #define BUDGET_KNC1TP		   13
112 #define BUDGET_TVSTAR		   14
113 #define BUDGET_CIN1200C_MK3	   15
114 #define BUDGET_KNC1C_MK3	   16
115 #define BUDGET_KNC1CP_MK3	   17
116 #define BUDGET_KNC1S2              18
117 #define BUDGET_KNC1C_TDA10024	   19
118 
119 #define BUDGET_VIDEO_PORTA         0
120 #define BUDGET_VIDEO_PORTB         1
121 
122 extern int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
123 			     struct saa7146_pci_extension_data *info,
124 			     struct module *owner, short *adapter_nums);
125 extern void ttpci_budget_init_hooks(struct budget *budget);
126 extern int ttpci_budget_deinit(struct budget *budget);
127 extern void ttpci_budget_irq10_handler(struct saa7146_dev *dev, u32 *isr);
128 extern void ttpci_budget_set_video_port(struct saa7146_dev *dev, int video_port);
129 extern int ttpci_budget_debiread(struct budget *budget, u32 config, int addr, int count,
130 				 int uselocks, int nobusyloop);
131 extern int ttpci_budget_debiwrite(struct budget *budget, u32 config, int addr, int count, u32 value,
132 				  int uselocks, int nobusyloop);
133 
134 #endif
135