blob: fe02bdb845982e89b2a0463a58068865d40e4f59 [file] [log] [blame]
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -03001Encoder firmware API description
2================================
3
4-------------------------------------------------------------------------------
5
6Name CX2341X_ENC_PING_FW
7Enum 128/0x80
8Description
9 Does nothing. Can be used to check if the firmware is responding.
10
11-------------------------------------------------------------------------------
12
13Name CX2341X_ENC_START_CAPTURE
14Enum 129/0x81
15Description
16 Commences the capture of video, audio and/or VBI data. All encoding
17 parameters must be initialized prior to this API call. Captures frames
18 continuously or until a predefined number of frames have been captured.
19Param[0]
20 Capture stream type:
21 0=MPEG
22 1=Raw
23 2=Raw passthrough
24 3=VBI
25
26Param[1]
27 Bitmask:
28 Bit 0 when set, captures YUV
29 Bit 1 when set, captures PCM audio
30 Bit 2 when set, captures VBI (same as param[0]=3)
31 Bit 3 when set, the capture destination is the decoder
32 (same as param[0]=2)
33 Bit 4 when set, the capture destination is the host
34 Note: this parameter is only meaningful for RAW capture type.
35
36-------------------------------------------------------------------------------
37
38Name CX2341X_ENC_STOP_CAPTURE
39Enum 130/0x82
40Description
41 Ends a capture in progress
42Param[0]
43 0=stop at end of GOP (generates IRQ)
44 1=stop immediate (no IRQ)
45Param[1]
46 Stream type to stop, see param[0] of API 0x81
47Param[2]
48 Subtype, see param[1] of API 0x81
49
50-------------------------------------------------------------------------------
51
52Name CX2341X_ENC_SET_AUDIO_ID
53Enum 137/0x89
54Description
55 Assigns the transport stream ID of the encoded audio stream
56Param[0]
57 Audio Stream ID
58
59-------------------------------------------------------------------------------
60
61Name CX2341X_ENC_SET_VIDEO_ID
62Enum 139/0x8B
63Description
64 Set video transport stream ID
65Param[0]
66 Video stream ID
67
68-------------------------------------------------------------------------------
69
70Name CX2341X_ENC_SET_PCR_ID
71Enum 141/0x8D
72Description
73 Assigns the transport stream ID for PCR packets
74Param[0]
75 PCR Stream ID
76
77-------------------------------------------------------------------------------
78
79Name CX2341X_ENC_SET_FRAME_RATE
80Enum 143/0x8F
81Description
82 Set video frames per second. Change occurs at start of new GOP.
83Param[0]
84 0=30fps
85 1=25fps
86
87-------------------------------------------------------------------------------
88
89Name CX2341X_ENC_SET_FRAME_SIZE
90Enum 145/0x91
91Description
92 Select video stream encoding resolution.
93Param[0]
94 Height in lines. Default 480
95Param[1]
96 Width in pixels. Default 720
97
98-------------------------------------------------------------------------------
99
100Name CX2341X_ENC_SET_BIT_RATE
101Enum 149/0x95
102Description
Hans Verkuil54f577b2006-06-18 14:56:12 -0300103 Assign average video stream bitrate. Note on the last three params:
104 Param[3] and [4] seem to be always 0, param [5] doesn't seem to be used.
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300105Param[0]
106 0=variable bitrate, 1=constant bitrate
107Param[1]
108 bitrate in bits per second
109Param[2]
110 peak bitrate in bits per second, divided by 400
Hans Verkuil54f577b2006-06-18 14:56:12 -0300111Param[3]
112 Mux bitrate in bits per second, divided by 400. May be 0 (default).
113Param[4]
114 Rate Control VBR Padding
115Param[5]
116 VBV Buffer used by encoder
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300117
118-------------------------------------------------------------------------------
119
120Name CX2341X_ENC_SET_GOP_PROPERTIES
121Enum 151/0x97
122Description
123 Setup the GOP structure
124Param[0]
Hans Verkuil54f577b2006-06-18 14:56:12 -0300125 GOP size (maximum is 34)
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300126Param[1]
127 Number of B frames between the I and P frame, plus 1.
128 For example: IBBPBBPBBPBB --> GOP size: 12, number of B frames: 2+1 = 3
Hans Verkuil54f577b2006-06-18 14:56:12 -0300129 Note that GOP size must be a multiple of (B-frames + 1).
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300130
131-------------------------------------------------------------------------------
132
133Name CX2341X_ENC_SET_ASPECT_RATIO
134Enum 153/0x99
135Description
136 Sets the encoding aspect ratio. Changes in the aspect ratio take effect
137 at the start of the next GOP.
138Param[0]
139 '0000' forbidden
140 '0001' 1:1 square
141 '0010' 4:3
142 '0011' 16:9
143 '0100' 2.21:1
144 '0101' reserved
145 ....
146 '1111' reserved
147
148-------------------------------------------------------------------------------
149
150Name CX2341X_ENC_SET_DNR_FILTER_MODE
151Enum 155/0x9B
152Description
153 Assign Dynamic Noise Reduction operating mode
154Param[0]
155 Bit0: Spatial filter, set=auto, clear=manual
156 Bit1: Temporal filter, set=auto, clear=manual
157Param[1]
158 Median filter:
159 0=Disabled
160 1=Horizontal
161 2=Vertical
162 3=Horiz/Vert
163 4=Diagonal
164
165-------------------------------------------------------------------------------
166
167Name CX2341X_ENC_SET_DNR_FILTER_PROPS
168Enum 157/0x9D
169Description
170 These Dynamic Noise Reduction filter values are only meaningful when
171 the respective filter is set to "manual" (See API 0x9B)
172Param[0]
173 Spatial filter: default 0, range 0:15
174Param[1]
175 Temporal filter: default 0, range 0:31
176
177-------------------------------------------------------------------------------
178
179Name CX2341X_ENC_SET_CORING_LEVELS
180Enum 159/0x9F
181Description
182 Assign Dynamic Noise Reduction median filter properties.
183Param[0]
184 Threshold above which the luminance median filter is enabled.
185 Default: 0, range 0:255
186Param[1]
187 Threshold below which the luminance median filter is enabled.
188 Default: 255, range 0:255
189Param[2]
190 Threshold above which the chrominance median filter is enabled.
191 Default: 0, range 0:255
192Param[3]
193 Threshold below which the chrominance median filter is enabled.
194 Default: 255, range 0:255
195
196-------------------------------------------------------------------------------
197
198Name CX2341X_ENC_SET_SPATIAL_FILTER_TYPE
199Enum 161/0xA1
200Description
201 Assign spatial prefilter parameters
202Param[0]
203 Luminance filter
204 0=Off
205 1=1D Horizontal
206 2=1D Vertical
207 3=2D H/V Separable (default)
208 4=2D Symmetric non-separable
209Param[1]
210 Chrominance filter
211 0=Off
212 1=1D Horizontal (default)
213
214-------------------------------------------------------------------------------
215
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300216Name CX2341X_ENC_SET_VBI_LINE
217Enum 183/0xB7
218Description
219 Selects VBI line number.
220Param[0]
221 Bits 0:4 line number
222 Bit 31 0=top_field, 1=bottom_field
223 Bits 0:31 all set specifies "all lines"
224Param[1]
225 VBI line information features: 0=disabled, 1=enabled
226Param[2]
227 Slicing: 0=None, 1=Closed Caption
228 Almost certainly not implemented. Set to 0.
229Param[3]
230 Luminance samples in this line.
231 Almost certainly not implemented. Set to 0.
232Param[4]
233 Chrominance samples in this line
234 Almost certainly not implemented. Set to 0.
235
236-------------------------------------------------------------------------------
237
238Name CX2341X_ENC_SET_STREAM_TYPE
239Enum 185/0xB9
240Description
241 Assign stream type
Hans Verkuil54f577b2006-06-18 14:56:12 -0300242 Note: Transport stream is not working in recent firmwares.
243 And in older firmwares the timestamps in the TS seem to be
244 unreliable.
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300245Param[0]
246 0=Program stream
247 1=Transport stream
248 2=MPEG1 stream
249 3=PES A/V stream
250 5=PES Video stream
251 7=PES Audio stream
252 10=DVD stream
253 11=VCD stream
254 12=SVCD stream
255 13=DVD_S1 stream
256 14=DVD_S2 stream
257
258-------------------------------------------------------------------------------
259
260Name CX2341X_ENC_SET_OUTPUT_PORT
261Enum 187/0xBB
262Description
Hans Verkuil45ad9f82006-06-21 17:04:13 -0300263 Assign stream output port. Normally 0 when the data is copied through
264 the PCI bus (DMA), and 1 when the data is streamed to another chip
265 (pvrusb and cx88-blackbird).
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300266Param[0]
267 0=Memory (default)
268 1=Streaming
269 2=Serial
Hans Verkuil45ad9f82006-06-21 17:04:13 -0300270Param[1]
271 Unknown, but leaving this to 0 seems to work best. Indications are that
272 this might have to do with USB support, although passing anything but 0
Matt LaPlante992caac2006-10-03 22:52:05 +0200273 only breaks things.
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300274
275-------------------------------------------------------------------------------
276
277Name CX2341X_ENC_SET_AUDIO_PROPERTIES
278Enum 189/0xBD
279Description
280 Set audio stream properties, may be called while encoding is in progress.
281 Note: all bitfields are consistent with ISO11172 documentation except
282 bits 2:3 which ISO docs define as:
283 '11' Layer I
284 '10' Layer II
285 '01' Layer III
286 '00' Undefined
287 This discrepancy may indicate a possible error in the documentation.
Hans Verkuil54f577b2006-06-18 14:56:12 -0300288 Testing indicated that only Layer II is actually working, and that
289 the minimum bitrate should be 192 kbps.
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300290Param[0]
291 Bitmask:
292 0:1 '00' 44.1Khz
Trent Piepho657de3c2006-06-20 00:30:57 -0300293 '01' 48Khz
294 '10' 32Khz
295 '11' reserved
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300296
297 2:3 '01'=Layer I
298 '10'=Layer II
299
300 4:7 Bitrate:
Trent Piepho657de3c2006-06-20 00:30:57 -0300301 Index | Layer I | Layer II
302 ------+-------------+------------
303 '0000' | free format | free format
304 '0001' | 32 kbit/s | 32 kbit/s
305 '0010' | 64 kbit/s | 48 kbit/s
306 '0011' | 96 kbit/s | 56 kbit/s
307 '0100' | 128 kbit/s | 64 kbit/s
308 '0101' | 160 kbit/s | 80 kbit/s
309 '0110' | 192 kbit/s | 96 kbit/s
310 '0111' | 224 kbit/s | 112 kbit/s
311 '1000' | 256 kbit/s | 128 kbit/s
312 '1001' | 288 kbit/s | 160 kbit/s
313 '1010' | 320 kbit/s | 192 kbit/s
314 '1011' | 352 kbit/s | 224 kbit/s
315 '1100' | 384 kbit/s | 256 kbit/s
316 '1101' | 416 kbit/s | 320 kbit/s
317 '1110' | 448 kbit/s | 384 kbit/s
318 Note: For Layer II, not all combinations of total bitrate
319 and mode are allowed. See ISO11172-3 3-Annex B, Table 3-B.2
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300320
321 8:9 '00'=Stereo
Trent Piepho657de3c2006-06-20 00:30:57 -0300322 '01'=JointStereo
323 '10'=Dual
324 '11'=Mono
Hans Verkuild84e2bd2006-12-20 06:50:18 -0300325 Note: the cx23415 cannot decode Joint Stereo properly.
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300326
327 10:11 Mode Extension used in joint_stereo mode.
Trent Piepho657de3c2006-06-20 00:30:57 -0300328 In Layer I and II they indicate which subbands are in
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300329 intensity_stereo. All other subbands are coded in stereo.
Trent Piepho657de3c2006-06-20 00:30:57 -0300330 '00' subbands 4-31 in intensity_stereo, bound==4
331 '01' subbands 8-31 in intensity_stereo, bound==8
332 '10' subbands 12-31 in intensity_stereo, bound==12
333 '11' subbands 16-31 in intensity_stereo, bound==16
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300334
335 12:13 Emphasis:
Trent Piepho657de3c2006-06-20 00:30:57 -0300336 '00' None
337 '01' 50/15uS
338 '10' reserved
339 '11' CCITT J.17
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300340
341 14 CRC:
Trent Piepho657de3c2006-06-20 00:30:57 -0300342 '0' off
343 '1' on
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300344
345 15 Copyright:
Trent Piepho657de3c2006-06-20 00:30:57 -0300346 '0' off
347 '1' on
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300348
349 16 Generation:
Trent Piepho657de3c2006-06-20 00:30:57 -0300350 '0' copy
351 '1' original
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300352
353-------------------------------------------------------------------------------
354
355Name CX2341X_ENC_HALT_FW
356Enum 195/0xC3
357Description
358 The firmware is halted and no further API calls are serviced until the
359 firmware is uploaded again.
360
361-------------------------------------------------------------------------------
362
363Name CX2341X_ENC_GET_VERSION
364Enum 196/0xC4
365Description
366 Returns the version of the encoder firmware.
367Result[0]
368 Version bitmask:
369 Bits 0:15 build
370 Bits 16:23 minor
371 Bits 24:31 major
372
373-------------------------------------------------------------------------------
374
375Name CX2341X_ENC_SET_GOP_CLOSURE
376Enum 197/0xC5
377Description
378 Assigns the GOP open/close property.
379Param[0]
380 0=Open
381 1=Closed
382
383-------------------------------------------------------------------------------
384
385Name CX2341X_ENC_GET_SEQ_END
386Enum 198/0xC6
387Description
388 Obtains the sequence end code of the encoder's buffer. When a capture
389 is started a number of interrupts are still generated, the last of
390 which will have Result[0] set to 1 and Result[1] will contain the size
391 of the buffer.
392Result[0]
393 State of the transfer (1 if last buffer)
394Result[1]
395 If Result[0] is 1, this contains the size of the last buffer, undefined
396 otherwise.
397
398-------------------------------------------------------------------------------
399
400Name CX2341X_ENC_SET_PGM_INDEX_INFO
401Enum 199/0xC7
402Description
403 Sets the Program Index Information.
Hans Verkuild84e2bd2006-12-20 06:50:18 -0300404 The information is stored as follows:
405
406 struct info {
407 u32 length; // Length of this frame
408 u32 offset_low; // Offset in the file of the
409 u32 offset_high; // start of this frame
410 u32 mask1; // Bits 0-1 are the type mask:
411 // 1=I, 2=P, 4=B
412 u32 pts; // The PTS of the frame
413 u32 mask2; // Bit 0 is bit 32 of the pts.
414 };
415 u32 table_ptr;
416 struct info index[400];
417
418 The table_ptr is the encoder memory address in the table were
419 *new* entries will be written. Note that this is a ringbuffer,
420 so the table_ptr will wraparound.
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300421Param[0]
422 Picture Mask:
423 0=No index capture
424 1=I frames
425 3=I,P frames
426 7=I,P,B frames
Hans Verkuild84e2bd2006-12-20 06:50:18 -0300427 (Seems to be ignored, it always indexes I, P and B frames)
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300428Param[1]
429 Elements requested (up to 400)
430Result[0]
Hans Verkuild84e2bd2006-12-20 06:50:18 -0300431 Offset in the encoder memory of the start of the table.
Mauro Carvalho Chehab447d6fb2006-05-22 10:31:37 -0300432Result[1]
433 Number of allocated elements up to a maximum of Param[1]
434
435-------------------------------------------------------------------------------
436
437Name CX2341X_ENC_SET_VBI_CONFIG
438Enum 200/0xC8
439Description
440 Configure VBI settings
441Param[0]
442 Bitmap:
443 0 Mode '0' Sliced, '1' Raw
444 1:3 Insertion:
445 '000' insert in extension & user data
446 '001' insert in private packets
447 '010' separate stream and user data
448 '111' separate stream and private data
449 8:15 Stream ID (normally 0xBD)
450Param[1]
451 Frames per interrupt (max 8). Only valid in raw mode.
452Param[2]
453 Total raw VBI frames. Only valid in raw mode.
454Param[3]
455 Start codes
456Param[4]
457 Stop codes
458Param[5]
459 Lines per frame
460Param[6]
461 Byte per line
462Result[0]
463 Observed frames per interrupt in raw mode only. Rage 1 to Param[1]
464Result[1]
465 Observed number of frames in raw mode. Range 1 to Param[2]
466Result[2]
467 Memory offset to start or raw VBI data
468
469-------------------------------------------------------------------------------
470
471Name CX2341X_ENC_SET_DMA_BLOCK_SIZE
472Enum 201/0xC9
473Description
474 Set DMA transfer block size
475Param[0]
476 DMA transfer block size in bytes or frames. When unit is bytes,
477 supported block sizes are 2^7, 2^8 and 2^9 bytes.
478Param[1]
479 Unit: 0=bytes, 1=frames
480
481-------------------------------------------------------------------------------
482
483Name CX2341X_ENC_GET_PREV_DMA_INFO_MB_10
484Enum 202/0xCA
485Description
486 Returns information on the previous DMA transfer in conjunction with
487 bit 27 of the interrupt mask. Uses mailbox 10.
488Result[0]
489 Type of stream
490Result[1]
491 Address Offset
492Result[2]
493 Maximum size of transfer
494
495-------------------------------------------------------------------------------
496
497Name CX2341X_ENC_GET_PREV_DMA_INFO_MB_9
498Enum 203/0xCB
499Description
500 Returns information on the previous DMA transfer in conjunction with
501 bit 27 of the interrupt mask. Uses mailbox 9.
502Result[0]
503 Status bits:
504 Bit 0 set indicates transfer complete
505 Bit 2 set indicates transfer error
506 Bit 4 set indicates linked list error
507Result[1]
508 DMA type
509Result[2]
510 Presentation Time Stamp bits 0..31
511Result[3]
512 Presentation Time Stamp bit 32
513
514-------------------------------------------------------------------------------
515
516Name CX2341X_ENC_SCHED_DMA_TO_HOST
517Enum 204/0xCC
518Description
519 Setup DMA to host operation
520Param[0]
521 Memory address of link list
522Param[1]
523 Length of link list (wtf: what units ???)
524Param[2]
525 DMA type (0=MPEG)
526
527-------------------------------------------------------------------------------
528
529Name CX2341X_ENC_INITIALIZE_INPUT
530Enum 205/0xCD
531Description
532 Initializes the video input
533
534-------------------------------------------------------------------------------
535
536Name CX2341X_ENC_SET_FRAME_DROP_RATE
537Enum 208/0xD0
538Description
539 For each frame captured, skip specified number of frames.
540Param[0]
541 Number of frames to skip
542
543-------------------------------------------------------------------------------
544
545Name CX2341X_ENC_PAUSE_ENCODER
546Enum 210/0xD2
547Description
548 During a pause condition, all frames are dropped instead of being encoded.
549Param[0]
550 0=Pause encoding
551 1=Continue encoding
552
553-------------------------------------------------------------------------------
554
555Name CX2341X_ENC_REFRESH_INPUT
556Enum 211/0xD3
557Description
558 Refreshes the video input
559
560-------------------------------------------------------------------------------
561
562Name CX2341X_ENC_SET_COPYRIGHT
563Enum 212/0xD4
564Description
565 Sets stream copyright property
566Param[0]
567 0=Stream is not copyrighted
568 1=Stream is copyrighted
569
570-------------------------------------------------------------------------------
571
572Name CX2341X_ENC_SET_EVENT_NOTIFICATION
573Enum 213/0xD5
574Description
575 Setup firmware to notify the host about a particular event. Host must
576 unmask the interrupt bit.
577Param[0]
578 Event (0=refresh encoder input)
579Param[1]
580 Notification 0=disabled 1=enabled
581Param[2]
582 Interrupt bit
583Param[3]
584 Mailbox slot, -1 if no mailbox required.
585
586-------------------------------------------------------------------------------
587
588Name CX2341X_ENC_SET_NUM_VSYNC_LINES
589Enum 214/0xD6
590Description
591 Depending on the analog video decoder used, this assigns the number
592 of lines for field 1 and 2.
593Param[0]
594 Field 1 number of lines:
595 0x00EF for SAA7114
596 0x00F0 for SAA7115
597 0x0105 for Micronas
598Param[1]
599 Field 2 number of lines:
600 0x00EF for SAA7114
601 0x00F0 for SAA7115
602 0x0106 for Micronas
603
604-------------------------------------------------------------------------------
605
606Name CX2341X_ENC_SET_PLACEHOLDER
607Enum 215/0xD7
608Description
609 Provides a mechanism of inserting custom user data in the MPEG stream.
610Param[0]
611 0=extension & user data
612 1=private packet with stream ID 0xBD
613Param[1]
614 Rate at which to insert data, in units of frames (for private packet)
615 or GOPs (for ext. & user data)
616Param[2]
617 Number of data DWORDs (below) to insert
618Param[3]
619 Custom data 0
620Param[4]
621 Custom data 1
622Param[5]
623 Custom data 2
624Param[6]
625 Custom data 3
626Param[7]
627 Custom data 4
628Param[8]
629 Custom data 5
630Param[9]
631 Custom data 6
632Param[10]
633 Custom data 7
634Param[11]
635 Custom data 8
636
637-------------------------------------------------------------------------------
638
639Name CX2341X_ENC_MUTE_VIDEO
640Enum 217/0xD9
641Description
642 Video muting
643Param[0]
644 Bit usage:
645 0 '0'=video not muted
646 '1'=video muted, creates frames with the YUV color defined below
647 1:7 Unused
648 8:15 V chrominance information
649 16:23 U chrominance information
650 24:31 Y luminance information
651
652-------------------------------------------------------------------------------
653
654Name CX2341X_ENC_MUTE_AUDIO
655Enum 218/0xDA
656Description
657 Audio muting
658Param[0]
659 0=audio not muted
660 1=audio muted (produces silent mpeg audio stream)
661
662-------------------------------------------------------------------------------
663
664Name CX2341X_ENC_UNKNOWN
665Enum 219/0xDB
666Description
667 Unknown API, it's used by Hauppauge though.
668Param[0]
669 0 This is the value Hauppauge uses, Unknown what it means.
670
671-------------------------------------------------------------------------------
672
673Name CX2341X_ENC_MISC
674Enum 220/0xDC
675Description
676 Miscellaneous actions. Not known for 100% what it does. It's really a
677 sort of ioctl call. The first parameter is a command number, the second
678 the value.
679Param[0]
680 Command number:
681 1=set initial SCR value when starting encoding.
682 2=set quality mode (apparently some test setting).
683 3=setup advanced VIM protection handling (supposedly only for the cx23416
684 for raw YUV).
685 Actually it looks like this should be 0 for saa7114/5 based card and 1
686 for cx25840 based cards.
687 4=generate artificial PTS timestamps
688 5=USB flush mode
689 6=something to do with the quantization matrix
690 7=set navigation pack insertion for DVD
691 8=enable scene change detection (seems to be a failure)
692 9=set history parameters of the video input module
693 10=set input field order of VIM
694 11=set quantization matrix
695 12=reset audio interface
696 13=set audio volume delay
697 14=set audio delay
698
699Param[1]
700 Command value.