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