1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/interrupt.h>
6 #include <linux/socket.h>
7 #include <linux/netdevice.h>
9 #include <linux/input.h>
10 #include <linux/time.h>
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>
18 #include <linux/mutex.h>
20 #include <media/dvbdev.h>
21 #include <media/demux.h>
22 #include <media/dvb_demux.h>
23 #include <media/dmxdev.h>
24 #include "dvb_filter.h"
25 #include <media/dvb_net.h>
26 #include <media/dvb_ringbuffer.h>
27 #include <media/dvb_frontend.h>
36 #include <media/drv-intf/saa7146_vv.h>
39 #define ANALOG_TUNER_VES1820 1
40 #define ANALOG_TUNER_STV0297 2
42 extern int av7110_debug
;
44 #define dprintk(level, fmt, arg...) do { \
45 if (level & av7110_debug) \
46 printk(KERN_DEBUG KBUILD_MODNAME ": %s(): " fmt, \
52 enum {AV_PES_STREAM
, PS_STREAM
, TS_STREAM
, PES_STREAM
};
54 enum av7110_video_mode
{
55 AV7110_VIDEO_MODE_PAL
= 0,
56 AV7110_VIDEO_MODE_NTSC
= 1
64 struct dvb_demux_feed
*feed
;
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
];
75 wait_queue_head_t wait_queue
;
82 /* infrared remote control */
89 /* place to store all the necessary device information */
94 struct dvb_device dvb_dev
;
95 struct dvb_net dvb_net
;
97 struct video_device v4l_dev
;
98 struct video_device vbi_dev
;
100 struct saa7146_dev
*dev
;
102 struct i2c_adapter i2c_adap
;
106 /* support for analog module of dvb-c */
107 int analog_tuner_flags
;
111 struct tasklet_struct debi_tasklet
;
112 struct tasklet_struct gpio_tasklet
;
114 int adac_type
; /* audio DAC type */
115 #define DVB_ADAC_TI 0
116 #define DVB_ADAC_CRYSTAL 1
117 #define DVB_ADAC_MSP34x0 2
118 #define DVB_ADAC_MSP34x5 3
119 #define DVB_ADAC_NONE -1
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)
130 #define BMPLEN (8*32768+1024)
132 /* bitmap buffers and states */
136 volatile int bmp_state
;
138 #define BMP_LOADING 1
140 wait_queue_head_t bmpq
;
143 /* DEBI and polled command interface */
146 struct mutex dcomlock
;
147 volatile int debitype
;
148 volatile int debilen
;
151 /* Recording and playback flags */
163 int osdwin
; /* currently active window */
165 struct mutex osd_mutex
;
169 struct ca_slot_info ci_slot
[2];
171 enum av7110_video_mode vidmode
;
172 struct dmxdev dmxdev
;
173 struct dvb_demux demux
;
175 struct dmx_frontend hw_frontend
;
176 struct dmx_frontend mem_frontend
;
178 /* for budget mode demux1 */
179 struct dmxdev dmxdev1
;
180 struct dvb_demux demux1
;
181 struct dvb_net dvb_net1
;
182 spinlock_t feedlock1
;
185 unsigned char *grabbing
;
186 struct saa7146_pgtable pt
;
187 struct tasklet_struct vpe_tasklet
;
191 struct mutex pid_mutex
;
194 struct video_status videostate
;
201 #define TRICK_FREEZE 3
202 struct audio_status audiostate
;
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];
225 struct task_struct
*arm_thread
;
226 wait_queue_head_t arm_wait
;
232 u16 pids
[DMX_PES_OTHER
];
234 struct dvb_ringbuffer ci_rbuffer
;
235 struct dvb_ringbuffer ci_wbuffer
;
237 struct audio_mixer mixer
;
239 struct dvb_adapter dvb_adapter
;
240 struct dvb_device
*video_dev
;
241 struct dvb_device
*audio_dev
;
242 struct dvb_device
*ca_dev
;
243 struct dvb_device
*osd_dev
;
245 struct dvb_video_events video_events
;
246 video_size_t video_size
;
254 unsigned char *bin_fw
;
255 unsigned long size_fw
;
257 unsigned char *bin_dpram
;
258 unsigned long size_dpram
;
260 unsigned char *bin_root
;
261 unsigned long size_root
;
263 struct dvb_frontend
* fe
;
264 enum fe_status fe_status
;
266 struct mutex ioctl_mutex
;
269 void (*recover
)(struct av7110
* av7110
);
270 enum fe_sec_voltage saved_voltage
;
271 enum fe_sec_tone_mode saved_tone
;
272 struct dvb_diseqc_master_cmd saved_master_cmd
;
273 enum fe_sec_mini_cmd saved_minicmd
;
275 int (*fe_init
)(struct dvb_frontend
* fe
);
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
,
288 int (*fe_set_frontend
)(struct dvb_frontend
*fe
);
292 extern int ChangePIDs(struct av7110
*av7110
, u16 vpid
, u16 apid
, u16 ttpid
,
293 u16 subpid
, u16 pcrpid
);
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
);
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
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
);
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
);
315 #endif /* _AV7110_H_ */