Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef _AV7110_H_ |
3 | #define _AV7110_H_ | |
4 | ||
5 | #include <linux/interrupt.h> | |
6 | #include <linux/socket.h> | |
7 | #include <linux/netdevice.h> | |
8 | #include <linux/i2c.h> | |
ee820a64 | 9 | #include <linux/input.h> |
b2409b65 | 10 | #include <linux/time.h> |
1da177e4 | 11 | |
1da177e4 LT |
12 | #include <linux/dvb/video.h> |
13 | #include <linux/dvb/audio.h> | |
14 | #include <linux/dvb/dmx.h> | |
15 | #include <linux/dvb/ca.h> | |
16 | #include <linux/dvb/osd.h> | |
17 | #include <linux/dvb/net.h> | |
3593cab5 | 18 | #include <linux/mutex.h> |
1da177e4 | 19 | |
fada1935 MCC |
20 | #include <media/dvbdev.h> |
21 | #include <media/demux.h> | |
22 | #include <media/dvb_demux.h> | |
23 | #include <media/dmxdev.h> | |
1da177e4 | 24 | #include "dvb_filter.h" |
fada1935 MCC |
25 | #include <media/dvb_net.h> |
26 | #include <media/dvb_ringbuffer.h> | |
27 | #include <media/dvb_frontend.h> | |
1da177e4 LT |
28 | #include "ves1820.h" |
29 | #include "ves1x93.h" | |
30 | #include "stv0299.h" | |
31 | #include "tda8083.h" | |
32 | #include "sp8870.h" | |
33 | #include "stv0297.h" | |
34 | #include "l64781.h" | |
35 | ||
d647f0b7 | 36 | #include <media/drv-intf/saa7146_vv.h> |
1da177e4 LT |
37 | |
38 | ||
39 | #define ANALOG_TUNER_VES1820 1 | |
40 | #define ANALOG_TUNER_STV0297 2 | |
1da177e4 LT |
41 | |
42 | extern int av7110_debug; | |
43 | ||
a80e1d96 MCC |
44 | #define dprintk(level, fmt, arg...) do { \ |
45 | if (level & av7110_debug) \ | |
46 | printk(KERN_DEBUG KBUILD_MODNAME ": %s(): " fmt, \ | |
47 | __func__, ##arg); \ | |
48 | } while (0) | |
1da177e4 LT |
49 | |
50 | #define MAXFILT 32 | |
51 | ||
52 | enum {AV_PES_STREAM, PS_STREAM, TS_STREAM, PES_STREAM}; | |
53 | ||
58a44040 | 54 | enum av7110_video_mode { |
6e6a8b5a | 55 | AV7110_VIDEO_MODE_PAL = 0, |
58a44040 MS |
56 | AV7110_VIDEO_MODE_NTSC = 1 |
57 | }; | |
58 | ||
1da177e4 LT |
59 | struct av7110_p2t { |
60 | u8 pes[TS_SIZE]; | |
61 | u8 counter; | |
62 | long int pos; | |
63 | int frags; | |
64 | struct dvb_demux_feed *feed; | |
65 | }; | |
66 | ||
67 | /* video MPEG decoder events: */ | |
68 | /* (code copied from dvb_frontend.c, should maybe be factored out...) */ | |
69 | #define MAX_VIDEO_EVENT 8 | |
70 | struct dvb_video_events { | |
71 | struct video_event events[MAX_VIDEO_EVENT]; | |
72 | int eventw; | |
73 | int eventr; | |
74 | int overflow; | |
75 | wait_queue_head_t wait_queue; | |
76 | spinlock_t lock; | |
77 | }; | |
78 | ||
79 | ||
ee820a64 OE |
80 | struct av7110; |
81 | ||
82 | /* infrared remote control */ | |
83 | struct infrared { | |
71f49a8b | 84 | struct rc_dev *rcdev; |
ee820a64 | 85 | char input_phys[32]; |
ee820a64 | 86 | u32 ir_config; |
ee820a64 OE |
87 | }; |
88 | ||
1da177e4 LT |
89 | /* place to store all the necessary device information */ |
90 | struct av7110 { | |
91 | ||
92 | /* devices */ | |
93 | ||
94 | struct dvb_device dvb_dev; | |
95 | struct dvb_net dvb_net; | |
96 | ||
3ae863e0 HV |
97 | struct video_device v4l_dev; |
98 | struct video_device vbi_dev; | |
1da177e4 LT |
99 | |
100 | struct saa7146_dev *dev; | |
101 | ||
102 | struct i2c_adapter i2c_adap; | |
103 | ||
104 | char *card_name; | |
105 | ||
106 | /* support for analog module of dvb-c */ | |
107 | int analog_tuner_flags; | |
108 | int current_input; | |
109 | u32 current_freq; | |
110 | ||
111 | struct tasklet_struct debi_tasklet; | |
112 | struct tasklet_struct gpio_tasklet; | |
113 | ||
114 | int adac_type; /* audio DAC type */ | |
115 | #define DVB_ADAC_TI 0 | |
116 | #define DVB_ADAC_CRYSTAL 1 | |
1c13b95c MS |
117 | #define DVB_ADAC_MSP34x0 2 |
118 | #define DVB_ADAC_MSP34x5 3 | |
1da177e4 LT |
119 | #define DVB_ADAC_NONE -1 |
120 | ||
121 | ||
122 | /* buffers */ | |
123 | ||
124 | void *iobuf; /* memory for all buffers */ | |
125 | struct dvb_ringbuffer avout; /* buffer for video or A/V mux */ | |
126 | #define AVOUTLEN (128*1024) | |
127 | struct dvb_ringbuffer aout; /* buffer for audio */ | |
128 | #define AOUTLEN (64*1024) | |
129 | void *bmpbuf; | |
130 | #define BMPLEN (8*32768+1024) | |
131 | ||
132 | /* bitmap buffers and states */ | |
133 | ||
134 | int bmpp; | |
135 | int bmplen; | |
136 | volatile int bmp_state; | |
137 | #define BMP_NONE 0 | |
138 | #define BMP_LOADING 1 | |
c9090ebb | 139 | #define BMP_LOADED 2 |
1da177e4 LT |
140 | wait_queue_head_t bmpq; |
141 | ||
142 | ||
143 | /* DEBI and polled command interface */ | |
144 | ||
145 | spinlock_t debilock; | |
3593cab5 | 146 | struct mutex dcomlock; |
1da177e4 LT |
147 | volatile int debitype; |
148 | volatile int debilen; | |
149 | ||
150 | ||
151 | /* Recording and playback flags */ | |
152 | ||
153 | int rec_mode; | |
154 | int playing; | |
155 | #define RP_NONE 0 | |
156 | #define RP_VIDEO 1 | |
157 | #define RP_AUDIO 2 | |
158 | #define RP_AV 3 | |
159 | ||
160 | ||
161 | /* OSD */ | |
162 | ||
163 | int osdwin; /* currently active window */ | |
164 | u16 osdbpp[8]; | |
3593cab5 | 165 | struct mutex osd_mutex; |
1da177e4 LT |
166 | |
167 | /* CA */ | |
168 | ||
c93022a7 | 169 | struct ca_slot_info ci_slot[2]; |
1da177e4 | 170 | |
58a44040 | 171 | enum av7110_video_mode vidmode; |
1da177e4 LT |
172 | struct dmxdev dmxdev; |
173 | struct dvb_demux demux; | |
174 | ||
175 | struct dmx_frontend hw_frontend; | |
176 | struct dmx_frontend mem_frontend; | |
177 | ||
178 | /* for budget mode demux1 */ | |
179 | struct dmxdev dmxdev1; | |
180 | struct dvb_demux demux1; | |
181 | struct dvb_net dvb_net1; | |
182 | spinlock_t feedlock1; | |
183 | int feeding1; | |
1da177e4 LT |
184 | u32 ttbp; |
185 | unsigned char *grabbing; | |
186 | struct saa7146_pgtable pt; | |
187 | struct tasklet_struct vpe_tasklet; | |
9e615eac | 188 | bool full_ts; |
1da177e4 LT |
189 | |
190 | int fe_synced; | |
3593cab5 | 191 | struct mutex pid_mutex; |
1da177e4 LT |
192 | |
193 | int video_blank; | |
194 | struct video_status videostate; | |
defd574e | 195 | u16 display_panscan; |
1da177e4 LT |
196 | int display_ar; |
197 | int trickmode; | |
198 | #define TRICK_NONE 0 | |
199 | #define TRICK_FAST 1 | |
200 | #define TRICK_SLOW 2 | |
201 | #define TRICK_FREEZE 3 | |
202 | struct audio_status audiostate; | |
203 | ||
204 | struct dvb_demux_filter *handle2filter[32]; | |
205 | struct av7110_p2t p2t_filter[MAXFILT]; | |
206 | struct dvb_filter_pes2ts p2t[2]; | |
207 | struct ipack ipack[2]; | |
208 | u8 *kbuf[2]; | |
209 | ||
210 | int sinfo; | |
211 | int feeding; | |
212 | ||
213 | int arm_errors; | |
214 | int registered; | |
215 | ||
216 | ||
217 | /* AV711X */ | |
218 | ||
219 | u32 arm_fw; | |
220 | u32 arm_rtsl; | |
221 | u32 arm_vid; | |
222 | u32 arm_app; | |
223 | u32 avtype; | |
224 | int arm_ready; | |
225 | struct task_struct *arm_thread; | |
226 | wait_queue_head_t arm_wait; | |
227 | u16 arm_loops; | |
1da177e4 LT |
228 | |
229 | void *debi_virt; | |
230 | dma_addr_t debi_bus; | |
231 | ||
232 | u16 pids[DMX_PES_OTHER]; | |
233 | ||
234 | struct dvb_ringbuffer ci_rbuffer; | |
235 | struct dvb_ringbuffer ci_wbuffer; | |
236 | ||
237 | struct audio_mixer mixer; | |
238 | ||
fdc53a6d | 239 | struct dvb_adapter dvb_adapter; |
1da177e4 LT |
240 | struct dvb_device *video_dev; |
241 | struct dvb_device *audio_dev; | |
242 | struct dvb_device *ca_dev; | |
243 | struct dvb_device *osd_dev; | |
244 | ||
245 | struct dvb_video_events video_events; | |
246 | video_size_t video_size; | |
247 | ||
5b0fa4ff OE |
248 | u16 wssMode; |
249 | u16 wssData; | |
250 | ||
ee820a64 | 251 | struct infrared ir; |
1da177e4 LT |
252 | |
253 | /* firmware stuff */ | |
254 | unsigned char *bin_fw; | |
255 | unsigned long size_fw; | |
256 | ||
257 | unsigned char *bin_dpram; | |
258 | unsigned long size_dpram; | |
259 | ||
260 | unsigned char *bin_root; | |
261 | unsigned long size_root; | |
262 | ||
263 | struct dvb_frontend* fe; | |
0df289a2 | 264 | enum fe_status fe_status; |
66190a27 | 265 | |
30ad64b8 NS |
266 | struct mutex ioctl_mutex; |
267 | ||
66190a27 OE |
268 | /* crash recovery */ |
269 | void (*recover)(struct av7110* av7110); | |
0df289a2 MCC |
270 | enum fe_sec_voltage saved_voltage; |
271 | enum fe_sec_tone_mode saved_tone; | |
66190a27 | 272 | struct dvb_diseqc_master_cmd saved_master_cmd; |
0df289a2 | 273 | enum fe_sec_mini_cmd saved_minicmd; |
66190a27 | 274 | |
1da177e4 | 275 | int (*fe_init)(struct dvb_frontend* fe); |
0df289a2 MCC |
276 | int (*fe_read_status)(struct dvb_frontend *fe, enum fe_status *status); |
277 | int (*fe_diseqc_reset_overload)(struct dvb_frontend *fe); | |
278 | int (*fe_diseqc_send_master_cmd)(struct dvb_frontend *fe, | |
279 | struct dvb_diseqc_master_cmd *cmd); | |
280 | int (*fe_diseqc_send_burst)(struct dvb_frontend *fe, | |
281 | enum fe_sec_mini_cmd minicmd); | |
282 | int (*fe_set_tone)(struct dvb_frontend *fe, | |
283 | enum fe_sec_tone_mode tone); | |
284 | int (*fe_set_voltage)(struct dvb_frontend *fe, | |
285 | enum fe_sec_voltage voltage); | |
286 | int (*fe_dishnetwork_send_legacy_command)(struct dvb_frontend *fe, | |
287 | unsigned long cmd); | |
b5c7cfd1 | 288 | int (*fe_set_frontend)(struct dvb_frontend *fe); |
1da177e4 LT |
289 | }; |
290 | ||
291 | ||
ce18a223 | 292 | extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, |
1da177e4 LT |
293 | u16 subpid, u16 pcrpid); |
294 | ||
71f49a8b SY |
295 | void av7110_ir_handler(struct av7110 *av7110, u32 ircom); |
296 | int av7110_set_ir_config(struct av7110 *av7110); | |
297 | int av7110_ir_init(struct av7110 *av7110); | |
298 | void av7110_ir_exit(struct av7110 *av7110); | |
1da177e4 LT |
299 | |
300 | /* msp3400 i2c subaddresses */ | |
301 | #define MSP_WR_DEM 0x10 | |
302 | #define MSP_RD_DEM 0x11 | |
303 | #define MSP_WR_DSP 0x12 | |
304 | #define MSP_RD_DSP 0x13 | |
305 | ||
306 | extern int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val); | |
307 | extern u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg); | |
308 | extern int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val); | |
1da177e4 LT |
309 | |
310 | ||
311 | extern int av7110_init_analog_module(struct av7110 *av7110); | |
312 | extern int av7110_init_v4l(struct av7110 *av7110); | |
313 | extern int av7110_exit_v4l(struct av7110 *av7110); | |
314 | ||
315 | #endif /* _AV7110_H_ */ |