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