av7110.h 7.1 KB

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