av7110.h 7.1 KB

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