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