cx23418.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. /*
  2. * cx18 header containing common defines.
  3. *
  4. * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  19. * 02111-1307 USA
  20. */
  21. #ifndef CX23418_H
  22. #define CX23418_H
  23. #include <media/cx2341x.h>
  24. #define MGR_CMD_MASK 0x40000000
  25. /* The MSB of the command code indicates that this is the completion of a
  26. command */
  27. #define MGR_CMD_MASK_ACK (MGR_CMD_MASK | 0x80000000)
  28. /* Description: This command creates a new instance of a certain task
  29. IN[0] - Task ID. This is one of the XPU_CMD_MASK_YYY where XPU is
  30. the processor on which the task YYY will be created
  31. OUT[0] - Task handle. This handle is passed along with commands to
  32. dispatch to the right instance of the task
  33. ReturnCode - One of the ERR_SYS_... */
  34. #define CX18_CREATE_TASK (MGR_CMD_MASK | 0x0001)
  35. /* Description: This command destroys an instance of a task
  36. IN[0] - Task handle. Hanlde of the task to destroy
  37. ReturnCode - One of the ERR_SYS_... */
  38. #define CX18_DESTROY_TASK (MGR_CMD_MASK | 0x0002)
  39. /* All commands for CPU have the following mask set */
  40. #define CPU_CMD_MASK 0x20000000
  41. #define CPU_CMD_MASK_ACK (CPU_CMD_MASK | 0x80000000)
  42. #define CPU_CMD_MASK_CAPTURE (CPU_CMD_MASK | 0x00020000)
  43. #define CPU_CMD_MASK_TS (CPU_CMD_MASK | 0x00040000)
  44. #define EPU_CMD_MASK 0x02000000
  45. #define EPU_CMD_MASK_DEBUG (EPU_CMD_MASK | 0x000000)
  46. #define EPU_CMD_MASK_DE (EPU_CMD_MASK | 0x040000)
  47. #define APU_CMD_MASK 0x10000000
  48. #define APU_CMD_MASK_ACK (APU_CMD_MASK | 0x80000000)
  49. #define CX18_APU_RESETAI (APU_CMD_MASK | 0x05)
  50. /* Description: This command indicates that a Memory Descriptor List has been
  51. filled with the requested channel type
  52. IN[0] - Task handle. Handle of the task
  53. IN[1] - Offset of the MDL_ACK from the beginning of the local DDR.
  54. IN[2] - Number of CNXT_MDL_ACK structures in the array pointed to by IN[1]
  55. ReturnCode - One of the ERR_DE_... */
  56. #define CX18_EPU_DMA_DONE (EPU_CMD_MASK_DE | 0x0001)
  57. /* Something interesting happened
  58. IN[0] - A value to log
  59. IN[1] - An offset of a string in the MiniMe memory;
  60. 0/zero/NULL means "I have nothing to say" */
  61. #define CX18_EPU_DEBUG (EPU_CMD_MASK_DEBUG | 0x0003)
  62. /* Description: This command starts streaming with the set channel type
  63. IN[0] - Task handle. Handle of the task to start
  64. ReturnCode - One of the ERR_CAPTURE_... */
  65. #define CX18_CPU_CAPTURE_START (CPU_CMD_MASK_CAPTURE | 0x0002)
  66. /* Description: This command stops streaming with the set channel type
  67. IN[0] - Task handle. Handle of the task to stop
  68. IN[1] - 0 = stop at end of GOP, 1 = stop at end of frame (MPEG only)
  69. ReturnCode - One of the ERR_CAPTURE_... */
  70. #define CX18_CPU_CAPTURE_STOP (CPU_CMD_MASK_CAPTURE | 0x0003)
  71. /* Description: This command pauses streaming with the set channel type
  72. IN[0] - Task handle. Handle of the task to pause
  73. ReturnCode - One of the ERR_CAPTURE_... */
  74. #define CX18_CPU_CAPTURE_PAUSE (CPU_CMD_MASK_CAPTURE | 0x0007)
  75. /* Description: This command resumes streaming with the set channel type
  76. IN[0] - Task handle. Handle of the task to resume
  77. ReturnCode - One of the ERR_CAPTURE_... */
  78. #define CX18_CPU_CAPTURE_RESUME (CPU_CMD_MASK_CAPTURE | 0x0008)
  79. #define CAPTURE_CHANNEL_TYPE_NONE 0
  80. #define CAPTURE_CHANNEL_TYPE_MPEG 1
  81. #define CAPTURE_CHANNEL_TYPE_INDEX 2
  82. #define CAPTURE_CHANNEL_TYPE_YUV 3
  83. #define CAPTURE_CHANNEL_TYPE_PCM 4
  84. #define CAPTURE_CHANNEL_TYPE_VBI 5
  85. #define CAPTURE_CHANNEL_TYPE_SLICED_VBI 6
  86. #define CAPTURE_CHANNEL_TYPE_TS 7
  87. #define CAPTURE_CHANNEL_TYPE_MAX 15
  88. /* Description: This command sets the channel type. This can only be done
  89. when stopped.
  90. IN[0] - Task handle. Handle of the task to start
  91. IN[1] - Channel Type. See Below.
  92. ReturnCode - One of the ERR_CAPTURE_... */
  93. #define CX18_CPU_SET_CHANNEL_TYPE (CPU_CMD_MASK_CAPTURE + 1)
  94. /* Description: Set stream output type
  95. IN[0] - task handle. Handle of the task to start
  96. IN[1] - type
  97. ReturnCode - One of the ERR_CAPTURE_... */
  98. #define CX18_CPU_SET_STREAM_OUTPUT_TYPE (CPU_CMD_MASK_CAPTURE | 0x0012)
  99. /* Description: Set video input resolution and frame rate
  100. IN[0] - task handle
  101. IN[1] - reserved
  102. IN[2] - reserved
  103. IN[3] - reserved
  104. IN[4] - reserved
  105. IN[5] - frame rate, 0 - 29.97f/s, 1 - 25f/s
  106. ReturnCode - One of the ERR_CAPTURE_... */
  107. #define CX18_CPU_SET_VIDEO_IN (CPU_CMD_MASK_CAPTURE | 0x0004)
  108. /* Description: Set video frame rate
  109. IN[0] - task handle. Handle of the task to start
  110. IN[1] - video bit rate mode
  111. IN[2] - video average rate
  112. IN[3] - video peak rate
  113. IN[4] - system mux rate
  114. ReturnCode - One of the ERR_CAPTURE_... */
  115. #define CX18_CPU_SET_VIDEO_RATE (CPU_CMD_MASK_CAPTURE | 0x0005)
  116. /* Description: Set video output resolution
  117. IN[0] - task handle
  118. IN[1] - horizontal size
  119. IN[2] - vertical size
  120. ReturnCode - One of the ERR_CAPTURE_... */
  121. #define CX18_CPU_SET_VIDEO_RESOLUTION (CPU_CMD_MASK_CAPTURE | 0x0006)
  122. /* Description: This command set filter parameters
  123. IN[0] - Task handle. Handle of the task
  124. IN[1] - type, 0 - temporal, 1 - spatial, 2 - median
  125. IN[2] - mode, temporal/spatial: 0 - disable, 1 - static, 2 - dynamic
  126. median: 0 = disable, 1 = horizontal, 2 = vertical,
  127. 3 = horizontal/vertical, 4 = diagonal
  128. IN[3] - strength, temporal 0 - 31, spatial 0 - 15
  129. ReturnCode - One of the ERR_CAPTURE_... */
  130. #define CX18_CPU_SET_FILTER_PARAM (CPU_CMD_MASK_CAPTURE | 0x0009)
  131. /* Description: This command set spatial filter type
  132. IN[0] - Task handle.
  133. IN[1] - luma type: 0 = disable, 1 = 1D horizontal only, 2 = 1D vertical only,
  134. 3 = 2D H/V separable, 4 = 2D symmetric non-separable
  135. IN[2] - chroma type: 0 - diable, 1 = 1D horizontal
  136. ReturnCode - One of the ERR_CAPTURE_... */
  137. #define CX18_CPU_SET_SPATIAL_FILTER_TYPE (CPU_CMD_MASK_CAPTURE | 0x000C)
  138. /* Description: This command set coring levels for median filter
  139. IN[0] - Task handle.
  140. IN[1] - luma_high
  141. IN[2] - luma_low
  142. IN[3] - chroma_high
  143. IN[4] - chroma_low
  144. ReturnCode - One of the ERR_CAPTURE_... */
  145. #define CX18_CPU_SET_MEDIAN_CORING (CPU_CMD_MASK_CAPTURE | 0x000E)
  146. /* Description: This command set the picture type mask for index file
  147. IN[0] - 0 = disable index file output
  148. 1 = output I picture
  149. 2 = P picture
  150. 4 = B picture
  151. other = illegal */
  152. #define CX18_CPU_SET_INDEXTABLE (CPU_CMD_MASK_CAPTURE | 0x0010)
  153. /* Description: Set audio parameters
  154. IN[0] - task handle. Handle of the task to start
  155. IN[1] - audio parameter
  156. ReturnCode - One of the ERR_CAPTURE_... */
  157. #define CX18_CPU_SET_AUDIO_PARAMETERS (CPU_CMD_MASK_CAPTURE | 0x0011)
  158. /* Description: Set video mute
  159. IN[0] - task handle. Handle of the task to start
  160. IN[1] - bit31-24: muteYvalue
  161. bit23-16: muteUvalue
  162. bit15-8: muteVvalue
  163. bit0: 1:mute, 0: unmute
  164. ReturnCode - One of the ERR_CAPTURE_... */
  165. #define CX18_CPU_SET_VIDEO_MUTE (CPU_CMD_MASK_CAPTURE | 0x0013)
  166. /* Description: Set audio mute
  167. IN[0] - task handle. Handle of the task to start
  168. IN[1] - mute/unmute
  169. ReturnCode - One of the ERR_CAPTURE_... */
  170. #define CX18_CPU_SET_AUDIO_MUTE (CPU_CMD_MASK_CAPTURE | 0x0014)
  171. /* Description: Set stream output type
  172. IN[0] - task handle. Handle of the task to start
  173. IN[1] - subType
  174. SET_INITIAL_SCR 1
  175. SET_QUALITY_MODE 2
  176. SET_VIM_PROTECT_MODE 3
  177. SET_PTS_CORRECTION 4
  178. SET_USB_FLUSH_MODE 5
  179. SET_MERAQPAR_ENABLE 6
  180. SET_NAV_PACK_INSERTION 7
  181. SET_SCENE_CHANGE_ENABLE 8
  182. IN[2] - parameter 1
  183. IN[3] - parameter 2
  184. ReturnCode - One of the ERR_CAPTURE_... */
  185. #define CX18_CPU_SET_MISC_PARAMETERS (CPU_CMD_MASK_CAPTURE | 0x0015)
  186. /* Description: Set raw VBI parameters
  187. IN[0] - Task handle
  188. IN[1] - No. of input lines per field:
  189. bit[15:0]: field 1,
  190. bit[31:16]: field 2
  191. IN[2] - No. of input bytes per line
  192. IN[3] - No. of output frames per transfer
  193. IN[4] - start code
  194. IN[5] - stop code
  195. ReturnCode */
  196. #define CX18_CPU_SET_RAW_VBI_PARAM (CPU_CMD_MASK_CAPTURE | 0x0016)
  197. /* Description: Set capture line No.
  198. IN[0] - task handle. Handle of the task to start
  199. IN[1] - height1
  200. IN[2] - height2
  201. ReturnCode - One of the ERR_CAPTURE_... */
  202. #define CX18_CPU_SET_CAPTURE_LINE_NO (CPU_CMD_MASK_CAPTURE | 0x0017)
  203. /* Description: Set copyright
  204. IN[0] - task handle. Handle of the task to start
  205. IN[1] - copyright
  206. ReturnCode - One of the ERR_CAPTURE_... */
  207. #define CX18_CPU_SET_COPYRIGHT (CPU_CMD_MASK_CAPTURE | 0x0018)
  208. /* Description: Set audio PID
  209. IN[0] - task handle. Handle of the task to start
  210. IN[1] - PID
  211. ReturnCode - One of the ERR_CAPTURE_... */
  212. #define CX18_CPU_SET_AUDIO_PID (CPU_CMD_MASK_CAPTURE | 0x0019)
  213. /* Description: Set video PID
  214. IN[0] - task handle. Handle of the task to start
  215. IN[1] - PID
  216. ReturnCode - One of the ERR_CAPTURE_... */
  217. #define CX18_CPU_SET_VIDEO_PID (CPU_CMD_MASK_CAPTURE | 0x001A)
  218. /* Description: Set Vertical Crop Line
  219. IN[0] - task handle. Handle of the task to start
  220. IN[1] - Line
  221. ReturnCode - One of the ERR_CAPTURE_... */
  222. #define CX18_CPU_SET_VER_CROP_LINE (CPU_CMD_MASK_CAPTURE | 0x001B)
  223. /* Description: Set COP structure
  224. IN[0] - task handle. Handle of the task to start
  225. IN[1] - M
  226. IN[2] - N
  227. ReturnCode - One of the ERR_CAPTURE_... */
  228. #define CX18_CPU_SET_GOP_STRUCTURE (CPU_CMD_MASK_CAPTURE | 0x001C)
  229. /* Description: Set Scene Change Detection
  230. IN[0] - task handle. Handle of the task to start
  231. IN[1] - scene change
  232. ReturnCode - One of the ERR_CAPTURE_... */
  233. #define CX18_CPU_SET_SCENE_CHANGE_DETECTION (CPU_CMD_MASK_CAPTURE | 0x001D)
  234. /* Description: Set Aspect Ratio
  235. IN[0] - task handle. Handle of the task to start
  236. IN[1] - AspectRatio
  237. ReturnCode - One of the ERR_CAPTURE_... */
  238. #define CX18_CPU_SET_ASPECT_RATIO (CPU_CMD_MASK_CAPTURE | 0x001E)
  239. /* Description: Set Skip Input Frame
  240. IN[0] - task handle. Handle of the task to start
  241. IN[1] - skip input frames
  242. ReturnCode - One of the ERR_CAPTURE_... */
  243. #define CX18_CPU_SET_SKIP_INPUT_FRAME (CPU_CMD_MASK_CAPTURE | 0x001F)
  244. /* Description: Set sliced VBI parameters -
  245. Note This API will only apply to MPEG and Sliced VBI Channels
  246. IN[0] - Task handle
  247. IN[1] - output type, 0 - CC, 1 - Moji, 2 - Teletext
  248. IN[2] - start / stop line
  249. bit[15:0] start line number
  250. bit[31:16] stop line number
  251. IN[3] - number of output frames per interrupt
  252. IN[4] - VBI insertion mode
  253. bit 0: output user data, 1 - enable
  254. bit 1: output private stream, 1 - enable
  255. bit 2: mux option, 0 - in GOP, 1 - in picture
  256. bit[7:0] private stream ID
  257. IN[5] - insertion period while mux option is in picture
  258. ReturnCode - VBI data offset */
  259. #define CX18_CPU_SET_SLICED_VBI_PARAM (CPU_CMD_MASK_CAPTURE | 0x0020)
  260. /* Description: Set the user data place holder
  261. IN[0] - type of data (0 for user)
  262. IN[1] - Stuffing period
  263. IN[2] - ID data size in word (less than 10)
  264. IN[3] - Pointer to ID buffer */
  265. #define CX18_CPU_SET_USERDATA_PLACE_HOLDER (CPU_CMD_MASK_CAPTURE | 0x0021)
  266. /* Description:
  267. In[0] Task Handle
  268. return parameter:
  269. Out[0] Reserved
  270. Out[1] Video PTS bit[32:2] of last output video frame.
  271. Out[2] Video PTS bit[ 1:0] of last output video frame.
  272. Out[3] Hardware Video PTS counter bit[31:0],
  273. these bits get incremented on every 90kHz clock tick.
  274. Out[4] Hardware Video PTS counter bit32,
  275. these bits get incremented on every 90kHz clock tick.
  276. ReturnCode */
  277. #define CX18_CPU_GET_ENC_PTS (CPU_CMD_MASK_CAPTURE | 0x0022)
  278. /* Below is the list of commands related to the data exchange */
  279. #define CPU_CMD_MASK_DE (CPU_CMD_MASK | 0x040000)
  280. /* Description: This command provides the physical base address of the local
  281. DDR as viewed by EPU
  282. IN[0] - Physical offset where EPU has the local DDR mapped
  283. ReturnCode - One of the ERR_DE_... */
  284. #define CPU_CMD_DE_SetBase (CPU_CMD_MASK_DE | 0x0001)
  285. /* Description: This command provides the offsets in the device memory where
  286. the 2 cx18_mdl_ack blocks reside
  287. IN[0] - Task handle. Handle of the task to start
  288. IN[1] - Offset of the first cx18_mdl_ack from the beginning of the
  289. local DDR.
  290. IN[2] - Offset of the second cx18_mdl_ack from the beginning of the
  291. local DDR.
  292. ReturnCode - One of the ERR_DE_... */
  293. #define CX18_CPU_DE_SET_MDL_ACK (CPU_CMD_MASK_DE | 0x0002)
  294. /* Description: This command provides the offset to a Memory Descriptor List
  295. IN[0] - Task handle. Handle of the task to start
  296. IN[1] - Offset of the MDL from the beginning of the local DDR.
  297. IN[2] - Number of cx18_mdl structures in the array pointed to by IN[1]
  298. IN[3] - Buffer ID
  299. IN[4] - Total buffer length
  300. ReturnCode - One of the ERR_DE_... */
  301. #define CX18_CPU_DE_SET_MDL (CPU_CMD_MASK_DE | 0x0005)
  302. /* Description: This command requests return of all current Memory
  303. Descriptor Lists to the driver
  304. IN[0] - Task handle. Handle of the task to start
  305. ReturnCode - One of the ERR_DE_... */
  306. /* #define CX18_CPU_DE_ReleaseMDL (CPU_CMD_MASK_DE | 0x0006) */
  307. /* Description: This command signals the cpu that the dat buffer has been
  308. consumed and ready for re-use.
  309. IN[0] - Task handle. Handle of the task
  310. IN[1] - Offset of the data block from the beginning of the local DDR.
  311. IN[2] - Number of bytes in the data block
  312. ReturnCode - One of the ERR_DE_... */
  313. /* #define CX18_CPU_DE_RELEASE_BUFFER (CPU_CMD_MASK_DE | 0x0007) */
  314. /* No Error / Success */
  315. #define CNXT_OK 0x000000
  316. /* Received unknown command */
  317. #define CXERR_UNK_CMD 0x000001
  318. /* First parameter in the command is invalid */
  319. #define CXERR_INVALID_PARAM1 0x000002
  320. /* Second parameter in the command is invalid */
  321. #define CXERR_INVALID_PARAM2 0x000003
  322. /* Device interface is not open/found */
  323. #define CXERR_DEV_NOT_FOUND 0x000004
  324. /* Requested function is not implemented/available */
  325. #define CXERR_NOTSUPPORTED 0x000005
  326. /* Invalid pointer is provided */
  327. #define CXERR_BADPTR 0x000006
  328. /* Unable to allocate memory */
  329. #define CXERR_NOMEM 0x000007
  330. /* Object/Link not found */
  331. #define CXERR_LINK 0x000008
  332. /* Device busy, command cannot be executed */
  333. #define CXERR_BUSY 0x000009
  334. /* File/device/handle is not open. */
  335. #define CXERR_NOT_OPEN 0x00000A
  336. /* Value is out of range */
  337. #define CXERR_OUTOFRANGE 0x00000B
  338. /* Buffer overflow */
  339. #define CXERR_OVERFLOW 0x00000C
  340. /* Version mismatch */
  341. #define CXERR_BADVER 0x00000D
  342. /* Operation timed out */
  343. #define CXERR_TIMEOUT 0x00000E
  344. /* Operation aborted */
  345. #define CXERR_ABORT 0x00000F
  346. /* Specified I2C device not found for read/write */
  347. #define CXERR_I2CDEV_NOTFOUND 0x000010
  348. /* Error in I2C data xfer (but I2C device is present) */
  349. #define CXERR_I2CDEV_XFERERR 0x000011
  350. /* Chanel changing component not ready */
  351. #define CXERR_CHANNELNOTREADY 0x000012
  352. /* PPU (Presensation/Decoder) mail box is corrupted */
  353. #define CXERR_PPU_MB_CORRUPT 0x000013
  354. /* CPU (Capture/Encoder) mail box is corrupted */
  355. #define CXERR_CPU_MB_CORRUPT 0x000014
  356. /* APU (Audio) mail box is corrupted */
  357. #define CXERR_APU_MB_CORRUPT 0x000015
  358. /* Unable to open file for reading */
  359. #define CXERR_FILE_OPEN_READ 0x000016
  360. /* Unable to open file for writing */
  361. #define CXERR_FILE_OPEN_WRITE 0x000017
  362. /* Unable to find the I2C section specified */
  363. #define CXERR_I2C_BADSECTION 0x000018
  364. /* Error in I2C data xfer (but I2C device is present) */
  365. #define CXERR_I2CDEV_DATALOW 0x000019
  366. /* Error in I2C data xfer (but I2C device is present) */
  367. #define CXERR_I2CDEV_CLOCKLOW 0x00001A
  368. /* No Interrupt received from HW (for I2C access) */
  369. #define CXERR_NO_HW_I2C_INTR 0x00001B
  370. /* RPU is not ready to accept commands! */
  371. #define CXERR_RPU_NOT_READY 0x00001C
  372. /* RPU is not ready to accept commands! */
  373. #define CXERR_RPU_NO_ACK 0x00001D
  374. /* The are no buffers ready. Try again soon! */
  375. #define CXERR_NODATA_AGAIN 0x00001E
  376. /* The stream is stopping. Function not alllowed now! */
  377. #define CXERR_STOPPING_STATUS 0x00001F
  378. /* Trying to access hardware when the power is turned OFF */
  379. #define CXERR_DEVPOWER_OFF 0x000020
  380. #endif /* CX23418_H */