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