av7110.h 7.0 KB

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