0001
0002 #ifndef _AV7110_H_
0003 #define _AV7110_H_
0004
0005 #include <linux/interrupt.h>
0006 #include <linux/socket.h>
0007 #include <linux/netdevice.h>
0008 #include <linux/i2c.h>
0009 #include <linux/input.h>
0010 #include <linux/time.h>
0011
0012 #include <linux/dvb/video.h>
0013 #include <linux/dvb/audio.h>
0014 #include <linux/dvb/dmx.h>
0015 #include <linux/dvb/ca.h>
0016 #include <linux/dvb/osd.h>
0017 #include <linux/dvb/net.h>
0018 #include <linux/mutex.h>
0019
0020 #include <media/dvbdev.h>
0021 #include <media/demux.h>
0022 #include <media/dvb_demux.h>
0023 #include <media/dmxdev.h>
0024 #include "dvb_filter.h"
0025 #include <media/dvb_net.h>
0026 #include <media/dvb_ringbuffer.h>
0027 #include <media/dvb_frontend.h>
0028 #include "ves1820.h"
0029 #include "ves1x93.h"
0030 #include "stv0299.h"
0031 #include "tda8083.h"
0032 #include "sp8870.h"
0033 #include "stv0297.h"
0034 #include "l64781.h"
0035
0036 #include <media/drv-intf/saa7146_vv.h>
0037
0038
0039 #define ANALOG_TUNER_VES1820 1
0040 #define ANALOG_TUNER_STV0297 2
0041
0042 extern int av7110_debug;
0043
0044 #define dprintk(level, fmt, arg...) do { \
0045 if (level & av7110_debug) \
0046 printk(KERN_DEBUG KBUILD_MODNAME ": %s(): " fmt, \
0047 __func__, ##arg); \
0048 } while (0)
0049
0050 #define MAXFILT 32
0051
0052 enum {AV_PES_STREAM, PS_STREAM, TS_STREAM, PES_STREAM};
0053
0054 enum av7110_video_mode {
0055 AV7110_VIDEO_MODE_PAL = 0,
0056 AV7110_VIDEO_MODE_NTSC = 1
0057 };
0058
0059 struct av7110_p2t {
0060 u8 pes[TS_SIZE];
0061 u8 counter;
0062 long int pos;
0063 int frags;
0064 struct dvb_demux_feed *feed;
0065 };
0066
0067
0068
0069 #define MAX_VIDEO_EVENT 8
0070 struct dvb_video_events {
0071 struct video_event events[MAX_VIDEO_EVENT];
0072 int eventw;
0073 int eventr;
0074 int overflow;
0075 wait_queue_head_t wait_queue;
0076 spinlock_t lock;
0077 };
0078
0079
0080 struct av7110;
0081
0082
0083 struct infrared {
0084 struct rc_dev *rcdev;
0085 char input_phys[32];
0086 u32 ir_config;
0087 };
0088
0089
0090 struct av7110 {
0091
0092
0093
0094 struct dvb_device dvb_dev;
0095 struct dvb_net dvb_net;
0096
0097 struct video_device v4l_dev;
0098 struct video_device vbi_dev;
0099
0100 struct saa7146_dev *dev;
0101
0102 struct i2c_adapter i2c_adap;
0103
0104 char *card_name;
0105
0106
0107 int analog_tuner_flags;
0108 int current_input;
0109 u32 current_freq;
0110
0111 struct tasklet_struct debi_tasklet;
0112 struct tasklet_struct gpio_tasklet;
0113
0114 int adac_type;
0115 #define DVB_ADAC_TI 0
0116 #define DVB_ADAC_CRYSTAL 1
0117 #define DVB_ADAC_MSP34x0 2
0118 #define DVB_ADAC_MSP34x5 3
0119 #define DVB_ADAC_NONE -1
0120
0121
0122
0123
0124 void *iobuf;
0125 struct dvb_ringbuffer avout;
0126 #define AVOUTLEN (128*1024)
0127 struct dvb_ringbuffer aout;
0128 #define AOUTLEN (64*1024)
0129 void *bmpbuf;
0130 #define BMPLEN (8*32768+1024)
0131
0132
0133
0134 int bmpp;
0135 int bmplen;
0136 volatile int bmp_state;
0137 #define BMP_NONE 0
0138 #define BMP_LOADING 1
0139 #define BMP_LOADED 2
0140 wait_queue_head_t bmpq;
0141
0142
0143
0144
0145 spinlock_t debilock;
0146 struct mutex dcomlock;
0147 volatile int debitype;
0148 volatile int debilen;
0149
0150
0151
0152
0153 int rec_mode;
0154 int playing;
0155 #define RP_NONE 0
0156 #define RP_VIDEO 1
0157 #define RP_AUDIO 2
0158 #define RP_AV 3
0159
0160
0161
0162
0163 int osdwin;
0164 u16 osdbpp[8];
0165 struct mutex osd_mutex;
0166
0167
0168
0169 struct ca_slot_info ci_slot[2];
0170
0171 enum av7110_video_mode vidmode;
0172 struct dmxdev dmxdev;
0173 struct dvb_demux demux;
0174
0175 struct dmx_frontend hw_frontend;
0176 struct dmx_frontend mem_frontend;
0177
0178
0179 struct dmxdev dmxdev1;
0180 struct dvb_demux demux1;
0181 struct dvb_net dvb_net1;
0182 spinlock_t feedlock1;
0183 int feeding1;
0184 u32 ttbp;
0185 unsigned char *grabbing;
0186 struct saa7146_pgtable pt;
0187 struct tasklet_struct vpe_tasklet;
0188 bool full_ts;
0189
0190 int fe_synced;
0191 struct mutex pid_mutex;
0192
0193 int video_blank;
0194 struct video_status videostate;
0195 u16 display_panscan;
0196 int display_ar;
0197 int trickmode;
0198 #define TRICK_NONE 0
0199 #define TRICK_FAST 1
0200 #define TRICK_SLOW 2
0201 #define TRICK_FREEZE 3
0202 struct audio_status audiostate;
0203
0204 struct dvb_demux_filter *handle2filter[32];
0205 struct av7110_p2t p2t_filter[MAXFILT];
0206 struct dvb_filter_pes2ts p2t[2];
0207 struct ipack ipack[2];
0208 u8 *kbuf[2];
0209
0210 int sinfo;
0211 int feeding;
0212
0213 int arm_errors;
0214 int registered;
0215
0216
0217
0218
0219 u32 arm_fw;
0220 u32 arm_rtsl;
0221 u32 arm_vid;
0222 u32 arm_app;
0223 u32 avtype;
0224 int arm_ready;
0225 struct task_struct *arm_thread;
0226 wait_queue_head_t arm_wait;
0227 u16 arm_loops;
0228
0229 void *debi_virt;
0230 dma_addr_t debi_bus;
0231
0232 u16 pids[DMX_PES_OTHER];
0233
0234 struct dvb_ringbuffer ci_rbuffer;
0235 struct dvb_ringbuffer ci_wbuffer;
0236
0237 struct audio_mixer mixer;
0238
0239 struct dvb_adapter dvb_adapter;
0240 struct dvb_device *video_dev;
0241 struct dvb_device *audio_dev;
0242 struct dvb_device *ca_dev;
0243 struct dvb_device *osd_dev;
0244
0245 struct dvb_video_events video_events;
0246 video_size_t video_size;
0247
0248 u16 wssMode;
0249 u16 wssData;
0250
0251 struct infrared ir;
0252
0253
0254 unsigned char *bin_fw;
0255 unsigned long size_fw;
0256
0257 unsigned char *bin_dpram;
0258 unsigned long size_dpram;
0259
0260 unsigned char *bin_root;
0261 unsigned long size_root;
0262
0263 struct dvb_frontend* fe;
0264 enum fe_status fe_status;
0265
0266 struct mutex ioctl_mutex;
0267
0268
0269 void (*recover)(struct av7110* av7110);
0270 enum fe_sec_voltage saved_voltage;
0271 enum fe_sec_tone_mode saved_tone;
0272 struct dvb_diseqc_master_cmd saved_master_cmd;
0273 enum fe_sec_mini_cmd saved_minicmd;
0274
0275 int (*fe_init)(struct dvb_frontend* fe);
0276 int (*fe_read_status)(struct dvb_frontend *fe, enum fe_status *status);
0277 int (*fe_diseqc_reset_overload)(struct dvb_frontend *fe);
0278 int (*fe_diseqc_send_master_cmd)(struct dvb_frontend *fe,
0279 struct dvb_diseqc_master_cmd *cmd);
0280 int (*fe_diseqc_send_burst)(struct dvb_frontend *fe,
0281 enum fe_sec_mini_cmd minicmd);
0282 int (*fe_set_tone)(struct dvb_frontend *fe,
0283 enum fe_sec_tone_mode tone);
0284 int (*fe_set_voltage)(struct dvb_frontend *fe,
0285 enum fe_sec_voltage voltage);
0286 int (*fe_dishnetwork_send_legacy_command)(struct dvb_frontend *fe,
0287 unsigned long cmd);
0288 int (*fe_set_frontend)(struct dvb_frontend *fe);
0289 };
0290
0291
0292 extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
0293 u16 subpid, u16 pcrpid);
0294
0295 void av7110_ir_handler(struct av7110 *av7110, u32 ircom);
0296 int av7110_set_ir_config(struct av7110 *av7110);
0297 int av7110_ir_init(struct av7110 *av7110);
0298 void av7110_ir_exit(struct av7110 *av7110);
0299
0300
0301 #define MSP_WR_DEM 0x10
0302 #define MSP_RD_DEM 0x11
0303 #define MSP_WR_DSP 0x12
0304 #define MSP_RD_DSP 0x13
0305
0306 extern int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val);
0307 extern u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg);
0308 extern int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val);
0309
0310
0311 extern int av7110_init_analog_module(struct av7110 *av7110);
0312 extern int av7110_init_v4l(struct av7110 *av7110);
0313 extern int av7110_exit_v4l(struct av7110 *av7110);
0314
0315 #endif