av7110.h 6.9 KB

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