fw-encoder-api.txt 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. Encoder firmware API description
  2. ================================
  3. -------------------------------------------------------------------------------
  4. Name CX2341X_ENC_PING_FW
  5. Enum 128/0x80
  6. Description
  7. Does nothing. Can be used to check if the firmware is responding.
  8. -------------------------------------------------------------------------------
  9. Name CX2341X_ENC_START_CAPTURE
  10. Enum 129/0x81
  11. Description
  12. Commences the capture of video, audio and/or VBI data. All encoding
  13. parameters must be initialized prior to this API call. Captures frames
  14. continuously or until a predefined number of frames have been captured.
  15. Param[0]
  16. Capture stream type:
  17. 0=MPEG
  18. 1=Raw
  19. 2=Raw passthrough
  20. 3=VBI
  21. Param[1]
  22. Bitmask:
  23. Bit 0 when set, captures YUV
  24. Bit 1 when set, captures PCM audio
  25. Bit 2 when set, captures VBI (same as param[0]=3)
  26. Bit 3 when set, the capture destination is the decoder
  27. (same as param[0]=2)
  28. Bit 4 when set, the capture destination is the host
  29. Note: this parameter is only meaningful for RAW capture type.
  30. -------------------------------------------------------------------------------
  31. Name CX2341X_ENC_STOP_CAPTURE
  32. Enum 130/0x82
  33. Description
  34. Ends a capture in progress
  35. Param[0]
  36. 0=stop at end of GOP (generates IRQ)
  37. 1=stop immediate (no IRQ)
  38. Param[1]
  39. Stream type to stop, see param[0] of API 0x81
  40. Param[2]
  41. Subtype, see param[1] of API 0x81
  42. -------------------------------------------------------------------------------
  43. Name CX2341X_ENC_SET_AUDIO_ID
  44. Enum 137/0x89
  45. Description
  46. Assigns the transport stream ID of the encoded audio stream
  47. Param[0]
  48. Audio Stream ID
  49. -------------------------------------------------------------------------------
  50. Name CX2341X_ENC_SET_VIDEO_ID
  51. Enum 139/0x8B
  52. Description
  53. Set video transport stream ID
  54. Param[0]
  55. Video stream ID
  56. -------------------------------------------------------------------------------
  57. Name CX2341X_ENC_SET_PCR_ID
  58. Enum 141/0x8D
  59. Description
  60. Assigns the transport stream ID for PCR packets
  61. Param[0]
  62. PCR Stream ID
  63. -------------------------------------------------------------------------------
  64. Name CX2341X_ENC_SET_FRAME_RATE
  65. Enum 143/0x8F
  66. Description
  67. Set video frames per second. Change occurs at start of new GOP.
  68. Param[0]
  69. 0=30fps
  70. 1=25fps
  71. -------------------------------------------------------------------------------
  72. Name CX2341X_ENC_SET_FRAME_SIZE
  73. Enum 145/0x91
  74. Description
  75. Select video stream encoding resolution.
  76. Param[0]
  77. Height in lines. Default 480
  78. Param[1]
  79. Width in pixels. Default 720
  80. -------------------------------------------------------------------------------
  81. Name CX2341X_ENC_SET_BIT_RATE
  82. Enum 149/0x95
  83. Description
  84. Assign average video stream bitrate.
  85. Param[0]
  86. 0=variable bitrate, 1=constant bitrate
  87. Param[1]
  88. bitrate in bits per second
  89. Param[2]
  90. peak bitrate in bits per second, divided by 400
  91. -------------------------------------------------------------------------------
  92. Name CX2341X_ENC_SET_GOP_PROPERTIES
  93. Enum 151/0x97
  94. Description
  95. Setup the GOP structure
  96. Param[0]
  97. GOP size
  98. Param[1]
  99. Number of B frames between the I and P frame, plus 1.
  100. For example: IBBPBBPBBPBB --> GOP size: 12, number of B frames: 2+1 = 3
  101. -------------------------------------------------------------------------------
  102. Name CX2341X_ENC_SET_ASPECT_RATIO
  103. Enum 153/0x99
  104. Description
  105. Sets the encoding aspect ratio. Changes in the aspect ratio take effect
  106. at the start of the next GOP.
  107. Param[0]
  108. '0000' forbidden
  109. '0001' 1:1 square
  110. '0010' 4:3
  111. '0011' 16:9
  112. '0100' 2.21:1
  113. '0101' reserved
  114. ....
  115. '1111' reserved
  116. -------------------------------------------------------------------------------
  117. Name CX2341X_ENC_SET_DNR_FILTER_MODE
  118. Enum 155/0x9B
  119. Description
  120. Assign Dynamic Noise Reduction operating mode
  121. Param[0]
  122. Bit0: Spatial filter, set=auto, clear=manual
  123. Bit1: Temporal filter, set=auto, clear=manual
  124. Param[1]
  125. Median filter:
  126. 0=Disabled
  127. 1=Horizontal
  128. 2=Vertical
  129. 3=Horiz/Vert
  130. 4=Diagonal
  131. -------------------------------------------------------------------------------
  132. Name CX2341X_ENC_SET_DNR_FILTER_PROPS
  133. Enum 157/0x9D
  134. Description
  135. These Dynamic Noise Reduction filter values are only meaningful when
  136. the respective filter is set to "manual" (See API 0x9B)
  137. Param[0]
  138. Spatial filter: default 0, range 0:15
  139. Param[1]
  140. Temporal filter: default 0, range 0:31
  141. -------------------------------------------------------------------------------
  142. Name CX2341X_ENC_SET_CORING_LEVELS
  143. Enum 159/0x9F
  144. Description
  145. Assign Dynamic Noise Reduction median filter properties.
  146. Param[0]
  147. Threshold above which the luminance median filter is enabled.
  148. Default: 0, range 0:255
  149. Param[1]
  150. Threshold below which the luminance median filter is enabled.
  151. Default: 255, range 0:255
  152. Param[2]
  153. Threshold above which the chrominance median filter is enabled.
  154. Default: 0, range 0:255
  155. Param[3]
  156. Threshold below which the chrominance median filter is enabled.
  157. Default: 255, range 0:255
  158. -------------------------------------------------------------------------------
  159. Name CX2341X_ENC_SET_SPATIAL_FILTER_TYPE
  160. Enum 161/0xA1
  161. Description
  162. Assign spatial prefilter parameters
  163. Param[0]
  164. Luminance filter
  165. 0=Off
  166. 1=1D Horizontal
  167. 2=1D Vertical
  168. 3=2D H/V Separable (default)
  169. 4=2D Symmetric non-separable
  170. Param[1]
  171. Chrominance filter
  172. 0=Off
  173. 1=1D Horizontal (default)
  174. -------------------------------------------------------------------------------
  175. Name CX2341X_ENC_SET_3_2_PULLDOWN
  176. Enum 177/0xB1
  177. Description
  178. 3:2 pulldown properties
  179. Param[0]
  180. 0=enabled
  181. 1=disabled
  182. -------------------------------------------------------------------------------
  183. Name CX2341X_ENC_SET_VBI_LINE
  184. Enum 183/0xB7
  185. Description
  186. Selects VBI line number.
  187. Param[0]
  188. Bits 0:4 line number
  189. Bit 31 0=top_field, 1=bottom_field
  190. Bits 0:31 all set specifies "all lines"
  191. Param[1]
  192. VBI line information features: 0=disabled, 1=enabled
  193. Param[2]
  194. Slicing: 0=None, 1=Closed Caption
  195. Almost certainly not implemented. Set to 0.
  196. Param[3]
  197. Luminance samples in this line.
  198. Almost certainly not implemented. Set to 0.
  199. Param[4]
  200. Chrominance samples in this line
  201. Almost certainly not implemented. Set to 0.
  202. -------------------------------------------------------------------------------
  203. Name CX2341X_ENC_SET_STREAM_TYPE
  204. Enum 185/0xB9
  205. Description
  206. Assign stream type
  207. Param[0]
  208. 0=Program stream
  209. 1=Transport stream
  210. 2=MPEG1 stream
  211. 3=PES A/V stream
  212. 5=PES Video stream
  213. 7=PES Audio stream
  214. 10=DVD stream
  215. 11=VCD stream
  216. 12=SVCD stream
  217. 13=DVD_S1 stream
  218. 14=DVD_S2 stream
  219. -------------------------------------------------------------------------------
  220. Name CX2341X_ENC_SET_OUTPUT_PORT
  221. Enum 187/0xBB
  222. Description
  223. Assign stream output port (not recommended you change setting from default)
  224. Param[0]
  225. 0=Memory (default)
  226. 1=Streaming
  227. 2=Serial
  228. -------------------------------------------------------------------------------
  229. Name CX2341X_ENC_SET_AUDIO_PROPERTIES
  230. Enum 189/0xBD
  231. Description
  232. Set audio stream properties, may be called while encoding is in progress.
  233. Note: all bitfields are consistent with ISO11172 documentation except
  234. bits 2:3 which ISO docs define as:
  235. '11' Layer I
  236. '10' Layer II
  237. '01' Layer III
  238. '00' Undefined
  239. This discrepancy may indicate a possible error in the documentation.
  240. Param[0]
  241. Bitmask:
  242. 0:1 '00' 44.1Khz
  243. '01' 48Khz
  244. '10' 32Khz
  245. '11' reserved
  246. 2:3 '01'=Layer I
  247. '10'=Layer II
  248. 4:7 Bitrate:
  249. Index | Layer I | Layer II
  250. ------+-------------+------------
  251. '0000' | free format | free format
  252. '0001' | 32 kbit/s | 32 kbit/s
  253. '0010' | 64 kbit/s | 48 kbit/s
  254. '0011' | 96 kbit/s | 56 kbit/s
  255. '0100' | 128 kbit/s | 64 kbit/s
  256. '0101' | 160 kbit/s | 80 kbit/s
  257. '0110' | 192 kbit/s | 96 kbit/s
  258. '0111' | 224 kbit/s | 112 kbit/s
  259. '1000' | 256 kbit/s | 128 kbit/s
  260. '1001' | 288 kbit/s | 160 kbit/s
  261. '1010' | 320 kbit/s | 192 kbit/s
  262. '1011' | 352 kbit/s | 224 kbit/s
  263. '1100' | 384 kbit/s | 256 kbit/s
  264. '1101' | 416 kbit/s | 320 kbit/s
  265. '1110' | 448 kbit/s | 384 kbit/s
  266. Note: For Layer II, not all combinations of total bitrate
  267. and mode are allowed. See ISO11172-3 3-Annex B, Table 3-B.2
  268. 8:9 '00'=Stereo
  269. '01'=JointStereo
  270. '10'=Dual
  271. '11'=Mono
  272. 10:11 Mode Extension used in joint_stereo mode.
  273. In Layer I and II they indicate which subbands are in
  274. intensity_stereo. All other subbands are coded in stereo.
  275. '00' subbands 4-31 in intensity_stereo, bound==4
  276. '01' subbands 8-31 in intensity_stereo, bound==8
  277. '10' subbands 12-31 in intensity_stereo, bound==12
  278. '11' subbands 16-31 in intensity_stereo, bound==16
  279. 12:13 Emphasis:
  280. '00' None
  281. '01' 50/15uS
  282. '10' reserved
  283. '11' CCITT J.17
  284. 14 CRC:
  285. '0' off
  286. '1' on
  287. 15 Copyright:
  288. '0' off
  289. '1' on
  290. 16 Generation:
  291. '0' copy
  292. '1' original
  293. -------------------------------------------------------------------------------
  294. Name CX2341X_ENC_HALT_FW
  295. Enum 195/0xC3
  296. Description
  297. The firmware is halted and no further API calls are serviced until the
  298. firmware is uploaded again.
  299. -------------------------------------------------------------------------------
  300. Name CX2341X_ENC_GET_VERSION
  301. Enum 196/0xC4
  302. Description
  303. Returns the version of the encoder firmware.
  304. Result[0]
  305. Version bitmask:
  306. Bits 0:15 build
  307. Bits 16:23 minor
  308. Bits 24:31 major
  309. -------------------------------------------------------------------------------
  310. Name CX2341X_ENC_SET_GOP_CLOSURE
  311. Enum 197/0xC5
  312. Description
  313. Assigns the GOP open/close property.
  314. Param[0]
  315. 0=Open
  316. 1=Closed
  317. -------------------------------------------------------------------------------
  318. Name CX2341X_ENC_GET_SEQ_END
  319. Enum 198/0xC6
  320. Description
  321. Obtains the sequence end code of the encoder's buffer. When a capture
  322. is started a number of interrupts are still generated, the last of
  323. which will have Result[0] set to 1 and Result[1] will contain the size
  324. of the buffer.
  325. Result[0]
  326. State of the transfer (1 if last buffer)
  327. Result[1]
  328. If Result[0] is 1, this contains the size of the last buffer, undefined
  329. otherwise.
  330. -------------------------------------------------------------------------------
  331. Name CX2341X_ENC_SET_PGM_INDEX_INFO
  332. Enum 199/0xC7
  333. Description
  334. Sets the Program Index Information.
  335. Param[0]
  336. Picture Mask:
  337. 0=No index capture
  338. 1=I frames
  339. 3=I,P frames
  340. 7=I,P,B frames
  341. Param[1]
  342. Elements requested (up to 400)
  343. Result[0]
  344. Offset in SDF memory of the table.
  345. Result[1]
  346. Number of allocated elements up to a maximum of Param[1]
  347. -------------------------------------------------------------------------------
  348. Name CX2341X_ENC_SET_VBI_CONFIG
  349. Enum 200/0xC8
  350. Description
  351. Configure VBI settings
  352. Param[0]
  353. Bitmap:
  354. 0 Mode '0' Sliced, '1' Raw
  355. 1:3 Insertion:
  356. '000' insert in extension & user data
  357. '001' insert in private packets
  358. '010' separate stream and user data
  359. '111' separate stream and private data
  360. 8:15 Stream ID (normally 0xBD)
  361. Param[1]
  362. Frames per interrupt (max 8). Only valid in raw mode.
  363. Param[2]
  364. Total raw VBI frames. Only valid in raw mode.
  365. Param[3]
  366. Start codes
  367. Param[4]
  368. Stop codes
  369. Param[5]
  370. Lines per frame
  371. Param[6]
  372. Byte per line
  373. Result[0]
  374. Observed frames per interrupt in raw mode only. Rage 1 to Param[1]
  375. Result[1]
  376. Observed number of frames in raw mode. Range 1 to Param[2]
  377. Result[2]
  378. Memory offset to start or raw VBI data
  379. -------------------------------------------------------------------------------
  380. Name CX2341X_ENC_SET_DMA_BLOCK_SIZE
  381. Enum 201/0xC9
  382. Description
  383. Set DMA transfer block size
  384. Param[0]
  385. DMA transfer block size in bytes or frames. When unit is bytes,
  386. supported block sizes are 2^7, 2^8 and 2^9 bytes.
  387. Param[1]
  388. Unit: 0=bytes, 1=frames
  389. -------------------------------------------------------------------------------
  390. Name CX2341X_ENC_GET_PREV_DMA_INFO_MB_10
  391. Enum 202/0xCA
  392. Description
  393. Returns information on the previous DMA transfer in conjunction with
  394. bit 27 of the interrupt mask. Uses mailbox 10.
  395. Result[0]
  396. Type of stream
  397. Result[1]
  398. Address Offset
  399. Result[2]
  400. Maximum size of transfer
  401. -------------------------------------------------------------------------------
  402. Name CX2341X_ENC_GET_PREV_DMA_INFO_MB_9
  403. Enum 203/0xCB
  404. Description
  405. Returns information on the previous DMA transfer in conjunction with
  406. bit 27 of the interrupt mask. Uses mailbox 9.
  407. Result[0]
  408. Status bits:
  409. Bit 0 set indicates transfer complete
  410. Bit 2 set indicates transfer error
  411. Bit 4 set indicates linked list error
  412. Result[1]
  413. DMA type
  414. Result[2]
  415. Presentation Time Stamp bits 0..31
  416. Result[3]
  417. Presentation Time Stamp bit 32
  418. -------------------------------------------------------------------------------
  419. Name CX2341X_ENC_SCHED_DMA_TO_HOST
  420. Enum 204/0xCC
  421. Description
  422. Setup DMA to host operation
  423. Param[0]
  424. Memory address of link list
  425. Param[1]
  426. Length of link list (wtf: what units ???)
  427. Param[2]
  428. DMA type (0=MPEG)
  429. -------------------------------------------------------------------------------
  430. Name CX2341X_ENC_INITIALIZE_INPUT
  431. Enum 205/0xCD
  432. Description
  433. Initializes the video input
  434. -------------------------------------------------------------------------------
  435. Name CX2341X_ENC_SET_FRAME_DROP_RATE
  436. Enum 208/0xD0
  437. Description
  438. For each frame captured, skip specified number of frames.
  439. Param[0]
  440. Number of frames to skip
  441. -------------------------------------------------------------------------------
  442. Name CX2341X_ENC_PAUSE_ENCODER
  443. Enum 210/0xD2
  444. Description
  445. During a pause condition, all frames are dropped instead of being encoded.
  446. Param[0]
  447. 0=Pause encoding
  448. 1=Continue encoding
  449. -------------------------------------------------------------------------------
  450. Name CX2341X_ENC_REFRESH_INPUT
  451. Enum 211/0xD3
  452. Description
  453. Refreshes the video input
  454. -------------------------------------------------------------------------------
  455. Name CX2341X_ENC_SET_COPYRIGHT
  456. Enum 212/0xD4
  457. Description
  458. Sets stream copyright property
  459. Param[0]
  460. 0=Stream is not copyrighted
  461. 1=Stream is copyrighted
  462. -------------------------------------------------------------------------------
  463. Name CX2341X_ENC_SET_EVENT_NOTIFICATION
  464. Enum 213/0xD5
  465. Description
  466. Setup firmware to notify the host about a particular event. Host must
  467. unmask the interrupt bit.
  468. Param[0]
  469. Event (0=refresh encoder input)
  470. Param[1]
  471. Notification 0=disabled 1=enabled
  472. Param[2]
  473. Interrupt bit
  474. Param[3]
  475. Mailbox slot, -1 if no mailbox required.
  476. -------------------------------------------------------------------------------
  477. Name CX2341X_ENC_SET_NUM_VSYNC_LINES
  478. Enum 214/0xD6
  479. Description
  480. Depending on the analog video decoder used, this assigns the number
  481. of lines for field 1 and 2.
  482. Param[0]
  483. Field 1 number of lines:
  484. 0x00EF for SAA7114
  485. 0x00F0 for SAA7115
  486. 0x0105 for Micronas
  487. Param[1]
  488. Field 2 number of lines:
  489. 0x00EF for SAA7114
  490. 0x00F0 for SAA7115
  491. 0x0106 for Micronas
  492. -------------------------------------------------------------------------------
  493. Name CX2341X_ENC_SET_PLACEHOLDER
  494. Enum 215/0xD7
  495. Description
  496. Provides a mechanism of inserting custom user data in the MPEG stream.
  497. Param[0]
  498. 0=extension & user data
  499. 1=private packet with stream ID 0xBD
  500. Param[1]
  501. Rate at which to insert data, in units of frames (for private packet)
  502. or GOPs (for ext. & user data)
  503. Param[2]
  504. Number of data DWORDs (below) to insert
  505. Param[3]
  506. Custom data 0
  507. Param[4]
  508. Custom data 1
  509. Param[5]
  510. Custom data 2
  511. Param[6]
  512. Custom data 3
  513. Param[7]
  514. Custom data 4
  515. Param[8]
  516. Custom data 5
  517. Param[9]
  518. Custom data 6
  519. Param[10]
  520. Custom data 7
  521. Param[11]
  522. Custom data 8
  523. -------------------------------------------------------------------------------
  524. Name CX2341X_ENC_MUTE_VIDEO
  525. Enum 217/0xD9
  526. Description
  527. Video muting
  528. Param[0]
  529. Bit usage:
  530. 0 '0'=video not muted
  531. '1'=video muted, creates frames with the YUV color defined below
  532. 1:7 Unused
  533. 8:15 V chrominance information
  534. 16:23 U chrominance information
  535. 24:31 Y luminance information
  536. -------------------------------------------------------------------------------
  537. Name CX2341X_ENC_MUTE_AUDIO
  538. Enum 218/0xDA
  539. Description
  540. Audio muting
  541. Param[0]
  542. 0=audio not muted
  543. 1=audio muted (produces silent mpeg audio stream)
  544. -------------------------------------------------------------------------------
  545. Name CX2341X_ENC_UNKNOWN
  546. Enum 219/0xDB
  547. Description
  548. Unknown API, it's used by Hauppauge though.
  549. Param[0]
  550. 0 This is the value Hauppauge uses, Unknown what it means.
  551. -------------------------------------------------------------------------------
  552. Name CX2341X_ENC_MISC
  553. Enum 220/0xDC
  554. Description
  555. Miscellaneous actions. Not known for 100% what it does. It's really a
  556. sort of ioctl call. The first parameter is a command number, the second
  557. the value.
  558. Param[0]
  559. Command number:
  560. 1=set initial SCR value when starting encoding.
  561. 2=set quality mode (apparently some test setting).
  562. 3=setup advanced VIM protection handling (supposedly only for the cx23416
  563. for raw YUV).
  564. Actually it looks like this should be 0 for saa7114/5 based card and 1
  565. for cx25840 based cards.
  566. 4=generate artificial PTS timestamps
  567. 5=USB flush mode
  568. 6=something to do with the quantization matrix
  569. 7=set navigation pack insertion for DVD
  570. 8=enable scene change detection (seems to be a failure)
  571. 9=set history parameters of the video input module
  572. 10=set input field order of VIM
  573. 11=set quantization matrix
  574. 12=reset audio interface
  575. 13=set audio volume delay
  576. 14=set audio delay
  577. Param[1]
  578. Command value.