av7110.h 6.6 KB

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