av7110_hw.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. #ifndef _AV7110_HW_H_
  2. #define _AV7110_HW_H_
  3. #include "av7110.h"
  4. /* DEBI transfer mode defs */
  5. #define DEBINOSWAP 0x000e0000
  6. #define DEBISWAB 0x001e0000
  7. #define DEBISWAP 0x002e0000
  8. #define ARM_WAIT_FREE (HZ)
  9. #define ARM_WAIT_SHAKE (HZ/5)
  10. #define ARM_WAIT_OSD (HZ)
  11. enum av7110_bootstate
  12. {
  13. BOOTSTATE_BUFFER_EMPTY = 0,
  14. BOOTSTATE_BUFFER_FULL = 1,
  15. BOOTSTATE_AV7110_BOOT_COMPLETE = 2
  16. };
  17. enum av7110_type_rec_play_format
  18. { RP_None,
  19. AudioPES,
  20. AudioMp2,
  21. AudioPCM,
  22. VideoPES,
  23. AV_PES
  24. };
  25. enum av7110_osd_palette_type
  26. {
  27. NoPalet = 0, /* No palette */
  28. Pal1Bit = 2, /* 2 colors for 1 Bit Palette */
  29. Pal2Bit = 4, /* 4 colors for 2 bit palette */
  30. Pal4Bit = 16, /* 16 colors for 4 bit palette */
  31. Pal8Bit = 256 /* 256 colors for 16 bit palette */
  32. };
  33. /* switch defines */
  34. #define SB_GPIO 3
  35. #define SB_OFF SAA7146_GPIO_OUTLO /* SlowBlank off (TV-Mode) */
  36. #define SB_ON SAA7146_GPIO_INPUT /* SlowBlank on (AV-Mode) */
  37. #define SB_WIDE SAA7146_GPIO_OUTHI /* SlowBlank 6V (16/9-Mode) (not implemented) */
  38. #define FB_GPIO 1
  39. #define FB_OFF SAA7146_GPIO_LO /* FastBlank off (CVBS-Mode) */
  40. #define FB_ON SAA7146_GPIO_OUTHI /* FastBlank on (RGB-Mode) */
  41. #define FB_LOOP SAA7146_GPIO_INPUT /* FastBlank loop-through (PC graphics ???) */
  42. enum av7110_video_output_mode
  43. {
  44. NO_OUT = 0, /* disable analog output */
  45. CVBS_RGB_OUT = 1,
  46. CVBS_YC_OUT = 2,
  47. YC_OUT = 3
  48. };
  49. /* firmware internal msg q status: */
  50. #define GPMQFull 0x0001 /* Main Message Queue Full */
  51. #define GPMQOver 0x0002 /* Main Message Queue Overflow */
  52. #define HPQFull 0x0004 /* High Priority Msg Queue Full */
  53. #define HPQOver 0x0008
  54. #define OSDQFull 0x0010 /* OSD Queue Full */
  55. #define OSDQOver 0x0020
  56. #define GPMQBusy 0x0040 /* Queue not empty, FW >= 261d */
  57. #define HPQBusy 0x0080
  58. #define OSDQBusy 0x0100
  59. /* hw section filter flags */
  60. #define SECTION_EIT 0x01
  61. #define SECTION_SINGLE 0x00
  62. #define SECTION_CYCLE 0x02
  63. #define SECTION_CONTINUOS 0x04
  64. #define SECTION_MODE 0x06
  65. #define SECTION_IPMPE 0x0C /* size up to 4k */
  66. #define SECTION_HIGH_SPEED 0x1C /* larger buffer */
  67. #define DATA_PIPING_FLAG 0x20 /* for Data Piping Filter */
  68. #define PBUFSIZE_NONE 0x0000
  69. #define PBUFSIZE_1P 0x0100
  70. #define PBUFSIZE_2P 0x0200
  71. #define PBUFSIZE_1K 0x0300
  72. #define PBUFSIZE_2K 0x0400
  73. #define PBUFSIZE_4K 0x0500
  74. #define PBUFSIZE_8K 0x0600
  75. #define PBUFSIZE_16K 0x0700
  76. #define PBUFSIZE_32K 0x0800
  77. /* firmware command codes */
  78. enum av7110_osd_command {
  79. WCreate,
  80. WDestroy,
  81. WMoveD,
  82. WMoveA,
  83. WHide,
  84. WTop,
  85. DBox,
  86. DLine,
  87. DText,
  88. Set_Font,
  89. SetColor,
  90. SetBlend,
  91. SetWBlend,
  92. SetCBlend,
  93. SetNonBlend,
  94. LoadBmp,
  95. BlitBmp,
  96. ReleaseBmp,
  97. SetWTrans,
  98. SetWNoTrans,
  99. Set_Palette
  100. };
  101. enum av7110_pid_command {
  102. MultiPID,
  103. VideoPID,
  104. AudioPID,
  105. InitFilt,
  106. FiltError,
  107. NewVersion,
  108. CacheError,
  109. AddPIDFilter,
  110. DelPIDFilter,
  111. Scan,
  112. SetDescr,
  113. SetIR,
  114. FlushTSQueue
  115. };
  116. enum av7110_mpeg_command {
  117. SelAudChannels
  118. };
  119. enum av7110_audio_command {
  120. AudioDAC,
  121. CabADAC,
  122. ON22K,
  123. OFF22K,
  124. MainSwitch,
  125. ADSwitch,
  126. SendDiSEqC,
  127. SetRegister,
  128. SpdifSwitch
  129. };
  130. enum av7110_request_command {
  131. AudioState,
  132. AudioBuffState,
  133. VideoState1,
  134. VideoState2,
  135. VideoState3,
  136. CrashCounter,
  137. ReqVersion,
  138. ReqVCXO,
  139. ReqRegister,
  140. ReqSecFilterError,
  141. ReqSTC
  142. };
  143. enum av7110_encoder_command {
  144. SetVidMode,
  145. SetTestMode,
  146. LoadVidCode,
  147. SetMonitorType,
  148. SetPanScanType,
  149. SetFreezeMode,
  150. SetWSSConfig
  151. };
  152. enum av7110_rec_play_state {
  153. __Record,
  154. __Stop,
  155. __Play,
  156. __Pause,
  157. __Slow,
  158. __FF_IP,
  159. __Scan_I,
  160. __Continue
  161. };
  162. enum av7110_fw_cmd_misc {
  163. AV7110_FW_VIDEO_ZOOM = 1,
  164. AV7110_FW_VIDEO_COMMAND,
  165. AV7110_FW_AUDIO_COMMAND
  166. };
  167. enum av7110_command_type {
  168. COMTYPE_NOCOM,
  169. COMTYPE_PIDFILTER,
  170. COMTYPE_MPEGDECODER,
  171. COMTYPE_OSD,
  172. COMTYPE_BMP,
  173. COMTYPE_ENCODER,
  174. COMTYPE_AUDIODAC,
  175. COMTYPE_REQUEST,
  176. COMTYPE_SYSTEM,
  177. COMTYPE_REC_PLAY,
  178. COMTYPE_COMMON_IF,
  179. COMTYPE_PID_FILTER,
  180. COMTYPE_PES,
  181. COMTYPE_TS,
  182. COMTYPE_VIDEO,
  183. COMTYPE_AUDIO,
  184. COMTYPE_CI_LL,
  185. COMTYPE_MISC = 0x80
  186. };
  187. #define VID_NONE_PREF 0x00 /* No aspect ration processing preferred */
  188. #define VID_PAN_SCAN_PREF 0x01 /* Pan and Scan Display preferred */
  189. #define VID_VERT_COMP_PREF 0x02 /* Vertical compression display preferred */
  190. #define VID_VC_AND_PS_PREF 0x03 /* PanScan and vertical Compression if allowed */
  191. #define VID_CENTRE_CUT_PREF 0x05 /* PanScan with zero vector */
  192. /* MPEG video decoder commands */
  193. #define AV_VIDEO_CMD_STOP 0x000e
  194. #define AV_VIDEO_CMD_PLAY 0x000d
  195. #define AV_VIDEO_CMD_FREEZE 0x0102
  196. #define AV_VIDEO_CMD_FFWD 0x0016
  197. #define AV_VIDEO_CMD_SLOW 0x0022
  198. /* MPEG audio decoder commands */
  199. #define AUDIO_CMD_MUTE 0x0001
  200. #define AUDIO_CMD_UNMUTE 0x0002
  201. #define AUDIO_CMD_PCM16 0x0010
  202. #define AUDIO_CMD_STEREO 0x0080
  203. #define AUDIO_CMD_MONO_L 0x0100
  204. #define AUDIO_CMD_MONO_R 0x0200
  205. #define AUDIO_CMD_SYNC_OFF 0x000e
  206. #define AUDIO_CMD_SYNC_ON 0x000f
  207. /* firmware data interface codes */
  208. #define DATA_NONE 0x00
  209. #define DATA_FSECTION 0x01
  210. #define DATA_IPMPE 0x02
  211. #define DATA_MPEG_RECORD 0x03
  212. #define DATA_DEBUG_MESSAGE 0x04
  213. #define DATA_COMMON_INTERFACE 0x05
  214. #define DATA_MPEG_PLAY 0x06
  215. #define DATA_BMP_LOAD 0x07
  216. #define DATA_IRCOMMAND 0x08
  217. #define DATA_PIPING 0x09
  218. #define DATA_STREAMING 0x0a
  219. #define DATA_CI_GET 0x0b
  220. #define DATA_CI_PUT 0x0c
  221. #define DATA_MPEG_VIDEO_EVENT 0x0d
  222. #define DATA_PES_RECORD 0x10
  223. #define DATA_PES_PLAY 0x11
  224. #define DATA_TS_RECORD 0x12
  225. #define DATA_TS_PLAY 0x13
  226. /* ancient CI command codes, only two are actually still used
  227. * by the link level CI firmware */
  228. #define CI_CMD_ERROR 0x00
  229. #define CI_CMD_ACK 0x01
  230. #define CI_CMD_SYSTEM_READY 0x02
  231. #define CI_CMD_KEYPRESS 0x03
  232. #define CI_CMD_ON_TUNED 0x04
  233. #define CI_CMD_ON_SWITCH_PROGRAM 0x05
  234. #define CI_CMD_SECTION_ARRIVED 0x06
  235. #define CI_CMD_SECTION_TIMEOUT 0x07
  236. #define CI_CMD_TIME 0x08
  237. #define CI_CMD_ENTER_MENU 0x09
  238. #define CI_CMD_FAST_PSI 0x0a
  239. #define CI_CMD_GET_SLOT_INFO 0x0b
  240. #define CI_MSG_NONE 0x00
  241. #define CI_MSG_CI_INFO 0x01
  242. #define CI_MSG_MENU 0x02
  243. #define CI_MSG_LIST 0x03
  244. #define CI_MSG_TEXT 0x04
  245. #define CI_MSG_REQUEST_INPUT 0x05
  246. #define CI_MSG_INPUT_COMPLETE 0x06
  247. #define CI_MSG_LIST_MORE 0x07
  248. #define CI_MSG_MENU_MORE 0x08
  249. #define CI_MSG_CLOSE_MMI_IMM 0x09
  250. #define CI_MSG_SECTION_REQUEST 0x0a
  251. #define CI_MSG_CLOSE_FILTER 0x0b
  252. #define CI_PSI_COMPLETE 0x0c
  253. #define CI_MODULE_READY 0x0d
  254. #define CI_SWITCH_PRG_REPLY 0x0e
  255. #define CI_MSG_TEXT_MORE 0x0f
  256. #define CI_MSG_CA_PMT 0xe0
  257. #define CI_MSG_ERROR 0xf0
  258. /* base address of the dual ported RAM which serves as communication
  259. * area between PCI bus and av7110,
  260. * as seen by the DEBI bus of the saa7146 */
  261. #define DPRAM_BASE 0x4000
  262. /* boot protocol area */
  263. #define AV7110_BOOT_STATE (DPRAM_BASE + 0x3F8)
  264. #define AV7110_BOOT_SIZE (DPRAM_BASE + 0x3FA)
  265. #define AV7110_BOOT_BASE (DPRAM_BASE + 0x3FC)
  266. #define AV7110_BOOT_BLOCK (DPRAM_BASE + 0x400)
  267. #define AV7110_BOOT_MAX_SIZE 0xc00
  268. /* firmware command protocol area */
  269. #define IRQ_STATE (DPRAM_BASE + 0x0F4)
  270. #define IRQ_STATE_EXT (DPRAM_BASE + 0x0F6)
  271. #define MSGSTATE (DPRAM_BASE + 0x0F8)
  272. #define COMMAND (DPRAM_BASE + 0x0FC)
  273. #define COM_BUFF (DPRAM_BASE + 0x100)
  274. #define COM_BUFF_SIZE 0x20
  275. /* various data buffers */
  276. #define BUFF1_BASE (DPRAM_BASE + 0x120)
  277. #define BUFF1_SIZE 0xE0
  278. #define DATA_BUFF0_BASE (DPRAM_BASE + 0x200)
  279. #define DATA_BUFF0_SIZE 0x0800
  280. #define DATA_BUFF1_BASE (DATA_BUFF0_BASE+DATA_BUFF0_SIZE)
  281. #define DATA_BUFF1_SIZE 0x0800
  282. #define DATA_BUFF2_BASE (DATA_BUFF1_BASE+DATA_BUFF1_SIZE)
  283. #define DATA_BUFF2_SIZE 0x0800
  284. #define DATA_BUFF3_BASE (DATA_BUFF2_BASE+DATA_BUFF2_SIZE)
  285. #define DATA_BUFF3_SIZE 0x0400
  286. #define Reserved (DPRAM_BASE + 0x1E00)
  287. #define Reserved_SIZE 0x1C0
  288. /* firmware status area */
  289. #define STATUS_BASE (DPRAM_BASE + 0x1FC0)
  290. #define STATUS_LOOPS (STATUS_BASE + 0x08)
  291. #define STATUS_MPEG_WIDTH (STATUS_BASE + 0x0C)
  292. /* ((aspect_ratio & 0xf) << 12) | (height & 0xfff) */
  293. #define STATUS_MPEG_HEIGHT_AR (STATUS_BASE + 0x0E)
  294. /* firmware data protocol area */
  295. #define RX_TYPE (DPRAM_BASE + 0x1FE8)
  296. #define RX_LEN (DPRAM_BASE + 0x1FEA)
  297. #define TX_TYPE (DPRAM_BASE + 0x1FEC)
  298. #define TX_LEN (DPRAM_BASE + 0x1FEE)
  299. #define RX_BUFF (DPRAM_BASE + 0x1FF4)
  300. #define TX_BUFF (DPRAM_BASE + 0x1FF6)
  301. #define HANDSHAKE_REG (DPRAM_BASE + 0x1FF8)
  302. #define COM_IF_LOCK (DPRAM_BASE + 0x1FFA)
  303. #define IRQ_RX (DPRAM_BASE + 0x1FFC)
  304. #define IRQ_TX (DPRAM_BASE + 0x1FFE)
  305. /* used by boot protocol to load firmware into av7110 DRAM */
  306. #define DRAM_START_CODE 0x2e000404
  307. #define DRAM_MAX_CODE_SIZE 0x00100000
  308. /* saa7146 gpio lines */
  309. #define RESET_LINE 2
  310. #define DEBI_DONE_LINE 1
  311. #define ARM_IRQ_LINE 0
  312. extern int av7110_bootarm(struct av7110 *av7110);
  313. extern int av7110_firmversion(struct av7110 *av7110);
  314. #define FW_CI_LL_SUPPORT(arm_app) ((arm_app) & 0x80000000)
  315. #define FW_4M_SDRAM(arm_app) ((arm_app) & 0x40000000)
  316. #define FW_VERSION(arm_app) ((arm_app) & 0x0000FFFF)
  317. extern int av7110_wait_msgstate(struct av7110 *av7110, u16 flags);
  318. extern int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...);
  319. extern int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
  320. int request_buf_len, u16 *reply_buf, int reply_buf_len);
  321. /* DEBI (saa7146 data extension bus interface) access */
  322. extern int av7110_debiwrite(struct av7110 *av7110, u32 config,
  323. int addr, u32 val, unsigned int count);
  324. extern u32 av7110_debiread(struct av7110 *av7110, u32 config,
  325. int addr, unsigned int count);
  326. /* DEBI during interrupt */
  327. /* single word writes */
  328. static inline void iwdebi(struct av7110 *av7110, u32 config, int addr, u32 val, unsigned int count)
  329. {
  330. av7110_debiwrite(av7110, config, addr, val, count);
  331. }
  332. /* buffer writes */
  333. static inline void mwdebi(struct av7110 *av7110, u32 config, int addr,
  334. const u8 *val, int count)
  335. {
  336. memcpy(av7110->debi_virt, val, count);
  337. av7110_debiwrite(av7110, config, addr, 0, count);
  338. }
  339. static inline u32 irdebi(struct av7110 *av7110, u32 config, int addr, u32 val, unsigned int count)
  340. {
  341. u32 res;
  342. res=av7110_debiread(av7110, config, addr, count);
  343. if (count<=4)
  344. memcpy(av7110->debi_virt, (char *) &res, count);
  345. return res;
  346. }
  347. /* DEBI outside interrupts, only for count <= 4! */
  348. static inline void wdebi(struct av7110 *av7110, u32 config, int addr, u32 val, unsigned int count)
  349. {
  350. unsigned long flags;
  351. spin_lock_irqsave(&av7110->debilock, flags);
  352. av7110_debiwrite(av7110, config, addr, val, count);
  353. spin_unlock_irqrestore(&av7110->debilock, flags);
  354. }
  355. static inline u32 rdebi(struct av7110 *av7110, u32 config, int addr, u32 val, unsigned int count)
  356. {
  357. unsigned long flags;
  358. u32 res;
  359. spin_lock_irqsave(&av7110->debilock, flags);
  360. res=av7110_debiread(av7110, config, addr, count);
  361. spin_unlock_irqrestore(&av7110->debilock, flags);
  362. return res;
  363. }
  364. /* handle mailbox registers of the dual ported RAM */
  365. static inline void ARM_ResetMailBox(struct av7110 *av7110)
  366. {
  367. unsigned long flags;
  368. spin_lock_irqsave(&av7110->debilock, flags);
  369. av7110_debiread(av7110, DEBINOSWAP, IRQ_RX, 2);
  370. av7110_debiwrite(av7110, DEBINOSWAP, IRQ_RX, 0, 2);
  371. spin_unlock_irqrestore(&av7110->debilock, flags);
  372. }
  373. static inline void ARM_ClearMailBox(struct av7110 *av7110)
  374. {
  375. iwdebi(av7110, DEBINOSWAP, IRQ_RX, 0, 2);
  376. }
  377. static inline void ARM_ClearIrq(struct av7110 *av7110)
  378. {
  379. irdebi(av7110, DEBINOSWAP, IRQ_RX, 0, 2);
  380. }
  381. /****************************************************************************
  382. * Firmware commands
  383. ****************************************************************************/
  384. static inline int SendDAC(struct av7110 *av7110, u8 addr, u8 data)
  385. {
  386. return av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, AudioDAC, 2, addr, data);
  387. }
  388. static inline int av7710_set_video_mode(struct av7110 *av7110, int mode)
  389. {
  390. return av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetVidMode, 1, mode);
  391. }
  392. static inline int vidcom(struct av7110 *av7110, u32 com, u32 arg)
  393. {
  394. return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_VIDEO_COMMAND, 4,
  395. (com>>16), (com&0xffff),
  396. (arg>>16), (arg&0xffff));
  397. }
  398. static inline int audcom(struct av7110 *av7110, u32 com)
  399. {
  400. return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_AUDIO_COMMAND, 2,
  401. (com>>16), (com&0xffff));
  402. }
  403. static inline int Set22K(struct av7110 *av7110, int state)
  404. {
  405. return av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, (state ? ON22K : OFF22K), 0);
  406. }
  407. extern int av7110_diseqc_send(struct av7110 *av7110, int len, u8 *msg, unsigned long burst);
  408. #ifdef CONFIG_DVB_AV7110_OSD
  409. extern int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc);
  410. extern int av7110_osd_capability(struct av7110 *av7110, osd_cap_t *cap);
  411. #endif /* CONFIG_DVB_AV7110_OSD */
  412. #endif /* _AV7110_HW_H_ */