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 */
85 struct input_dev
*input_dev
;
87 struct timer_list keyup_timer
;
88 struct tasklet_struct ir_tasklet
;
89 void (*ir_handler
)(struct av7110
*av7110
, u32 ircom
);
101 /* place to store all the necessary device information */
106 struct dvb_device dvb_dev
;
107 struct dvb_net dvb_net
;
109 struct video_device v4l_dev
;
110 struct video_device vbi_dev
;
112 struct saa7146_dev
*dev
;
114 struct i2c_adapter i2c_adap
;
118 /* support for analog module of dvb-c */
119 int analog_tuner_flags
;
123 struct tasklet_struct debi_tasklet
;
124 struct tasklet_struct gpio_tasklet
;
126 int adac_type
; /* audio DAC type */
127 #define DVB_ADAC_TI 0
128 #define DVB_ADAC_CRYSTAL 1
129 #define DVB_ADAC_MSP34x0 2
130 #define DVB_ADAC_MSP34x5 3
131 #define DVB_ADAC_NONE -1
136 void *iobuf
; /* memory for all buffers */
137 struct dvb_ringbuffer avout
; /* buffer for video or A/V mux */
138 #define AVOUTLEN (128*1024)
139 struct dvb_ringbuffer aout
; /* buffer for audio */
140 #define AOUTLEN (64*1024)
142 #define BMPLEN (8*32768+1024)
144 /* bitmap buffers and states */
148 volatile int bmp_state
;
150 #define BMP_LOADING 1
152 wait_queue_head_t bmpq
;
155 /* DEBI and polled command interface */
158 struct mutex dcomlock
;
159 volatile int debitype
;
160 volatile int debilen
;
163 /* Recording and playback flags */
175 int osdwin
; /* currently active window */
177 struct mutex osd_mutex
;
181 struct ca_slot_info ci_slot
[2];
183 enum av7110_video_mode vidmode
;
184 struct dmxdev dmxdev
;
185 struct dvb_demux demux
;
187 struct dmx_frontend hw_frontend
;
188 struct dmx_frontend mem_frontend
;
190 /* for budget mode demux1 */
191 struct dmxdev dmxdev1
;
192 struct dvb_demux demux1
;
193 struct dvb_net dvb_net1
;
194 spinlock_t feedlock1
;
197 unsigned char *grabbing
;
198 struct saa7146_pgtable pt
;
199 struct tasklet_struct vpe_tasklet
;
203 struct mutex pid_mutex
;
206 struct video_status videostate
;
213 #define TRICK_FREEZE 3
214 struct audio_status audiostate
;
216 struct dvb_demux_filter
*handle2filter
[32];
217 struct av7110_p2t p2t_filter
[MAXFILT
];
218 struct dvb_filter_pes2ts p2t
[2];
219 struct ipack ipack
[2];
237 struct task_struct
*arm_thread
;
238 wait_queue_head_t arm_wait
;
244 u16 pids
[DMX_PES_OTHER
];
246 struct dvb_ringbuffer ci_rbuffer
;
247 struct dvb_ringbuffer ci_wbuffer
;
249 struct audio_mixer mixer
;
251 struct dvb_adapter dvb_adapter
;
252 struct dvb_device
*video_dev
;
253 struct dvb_device
*audio_dev
;
254 struct dvb_device
*ca_dev
;
255 struct dvb_device
*osd_dev
;
257 struct dvb_video_events video_events
;
258 video_size_t video_size
;
266 unsigned char *bin_fw
;
267 unsigned long size_fw
;
269 unsigned char *bin_dpram
;
270 unsigned long size_dpram
;
272 unsigned char *bin_root
;
273 unsigned long size_root
;
275 struct dvb_frontend
* fe
;
276 enum fe_status fe_status
;
278 struct mutex ioctl_mutex
;
281 void (*recover
)(struct av7110
* av7110
);
282 enum fe_sec_voltage saved_voltage
;
283 enum fe_sec_tone_mode saved_tone
;
284 struct dvb_diseqc_master_cmd saved_master_cmd
;
285 enum fe_sec_mini_cmd saved_minicmd
;
287 int (*fe_init
)(struct dvb_frontend
* fe
);
288 int (*fe_read_status
)(struct dvb_frontend
*fe
, enum fe_status
*status
);
289 int (*fe_diseqc_reset_overload
)(struct dvb_frontend
*fe
);
290 int (*fe_diseqc_send_master_cmd
)(struct dvb_frontend
*fe
,
291 struct dvb_diseqc_master_cmd
*cmd
);
292 int (*fe_diseqc_send_burst
)(struct dvb_frontend
*fe
,
293 enum fe_sec_mini_cmd minicmd
);
294 int (*fe_set_tone
)(struct dvb_frontend
*fe
,
295 enum fe_sec_tone_mode tone
);
296 int (*fe_set_voltage
)(struct dvb_frontend
*fe
,
297 enum fe_sec_voltage voltage
);
298 int (*fe_dishnetwork_send_legacy_command
)(struct dvb_frontend
*fe
,
300 int (*fe_set_frontend
)(struct dvb_frontend
*fe
);
304 extern int ChangePIDs(struct av7110
*av7110
, u16 vpid
, u16 apid
, u16 ttpid
,
305 u16 subpid
, u16 pcrpid
);
307 extern int av7110_check_ir_config(struct av7110
*av7110
, int force
);
308 extern int av7110_ir_init(struct av7110
*av7110
);
309 extern void av7110_ir_exit(struct av7110
*av7110
);
311 /* msp3400 i2c subaddresses */
312 #define MSP_WR_DEM 0x10
313 #define MSP_RD_DEM 0x11
314 #define MSP_WR_DSP 0x12
315 #define MSP_RD_DSP 0x13
317 extern int i2c_writereg(struct av7110
*av7110
, u8 id
, u8 reg
, u8 val
);
318 extern u8
i2c_readreg(struct av7110
*av7110
, u8 id
, u8 reg
);
319 extern int msp_writereg(struct av7110
*av7110
, u8 dev
, u16 reg
, u16 val
);
322 extern int av7110_init_analog_module(struct av7110
*av7110
);
323 extern int av7110_init_v4l(struct av7110
*av7110
);
324 extern int av7110_exit_v4l(struct av7110
*av7110
);
326 #endif /* _AV7110_H_ */