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