av7110.h 7.0 KB

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