av7110.h 6.5 KB

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