fw-encoder-api.txt 18 KB

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