cx2341x.rst 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858
  1. The cx2341x driver
  2. ==================
  3. Memory at cx2341x chips
  4. -----------------------
  5. This section describes the cx2341x memory map and documents some of the
  6. register space.
  7. .. note:: the memory long words are little-endian ('intel format').
  8. .. warning::
  9. This information was figured out from searching through the memory
  10. and registers, this information may not be correct and is certainly
  11. not complete, and was not derived from anything more than searching
  12. through the memory space with commands like:
  13. .. code-block:: none
  14. ivtvctl -O min=0x02000000,max=0x020000ff
  15. So take this as is, I'm always searching for more stuff, it's a large
  16. register space :-).
  17. Memory Map
  18. ~~~~~~~~~~
  19. The cx2341x exposes its entire 64M memory space to the PCI host via the PCI BAR0
  20. (Base Address Register 0). The addresses here are offsets relative to the
  21. address held in BAR0.
  22. .. code-block:: none
  23. 0x00000000-0x00ffffff Encoder memory space
  24. 0x00000000-0x0003ffff Encode.rom
  25. ???-??? MPEG buffer(s)
  26. ???-??? Raw video capture buffer(s)
  27. ???-??? Raw audio capture buffer(s)
  28. ???-??? Display buffers (6 or 9)
  29. 0x01000000-0x01ffffff Decoder memory space
  30. 0x01000000-0x0103ffff Decode.rom
  31. ???-??? MPEG buffers(s)
  32. 0x0114b000-0x0115afff Audio.rom (deprecated?)
  33. 0x02000000-0x0200ffff Register Space
  34. Registers
  35. ~~~~~~~~~
  36. The registers occupy the 64k space starting at the 0x02000000 offset from BAR0.
  37. All of these registers are 32 bits wide.
  38. .. code-block:: none
  39. DMA Registers 0x000-0xff:
  40. 0x00 - Control:
  41. 0=reset/cancel, 1=read, 2=write, 4=stop
  42. 0x04 - DMA status:
  43. 1=read busy, 2=write busy, 4=read error, 8=write error, 16=link list error
  44. 0x08 - pci DMA pointer for read link list
  45. 0x0c - pci DMA pointer for write link list
  46. 0x10 - read/write DMA enable:
  47. 1=read enable, 2=write enable
  48. 0x14 - always 0xffffffff, if set any lower instability occurs, 0x00 crashes
  49. 0x18 - ??
  50. 0x1c - always 0x20 or 32, smaller values slow down DMA transactions
  51. 0x20 - always value of 0x780a010a
  52. 0x24-0x3c - usually just random values???
  53. 0x40 - Interrupt status
  54. 0x44 - Write a bit here and shows up in Interrupt status 0x40
  55. 0x48 - Interrupt Mask
  56. 0x4C - always value of 0xfffdffff,
  57. if changed to 0xffffffff DMA write interrupts break.
  58. 0x50 - always 0xffffffff
  59. 0x54 - always 0xffffffff (0x4c, 0x50, 0x54 seem like interrupt masks, are
  60. 3 processors on chip, Java ones, VPU, SPU, APU, maybe these are the
  61. interrupt masks???).
  62. 0x60-0x7C - random values
  63. 0x80 - first write linked list reg, for Encoder Memory addr
  64. 0x84 - first write linked list reg, for pci memory addr
  65. 0x88 - first write linked list reg, for length of buffer in memory addr
  66. (|0x80000000 or this for last link)
  67. 0x8c-0xdc - rest of write linked list reg, 8 sets of 3 total, DMA goes here
  68. from linked list addr in reg 0x0c, firmware must push through or
  69. something.
  70. 0xe0 - first (and only) read linked list reg, for pci memory addr
  71. 0xe4 - first (and only) read linked list reg, for Decoder memory addr
  72. 0xe8 - first (and only) read linked list reg, for length of buffer
  73. 0xec-0xff - Nothing seems to be in these registers, 0xec-f4 are 0x00000000.
  74. Memory locations for Encoder Buffers 0x700-0x7ff:
  75. These registers show offsets of memory locations pertaining to each
  76. buffer area used for encoding, have to shift them by <<1 first.
  77. - 0x07F8: Encoder SDRAM refresh
  78. - 0x07FC: Encoder SDRAM pre-charge
  79. Memory locations for Decoder Buffers 0x800-0x8ff:
  80. These registers show offsets of memory locations pertaining to each
  81. buffer area used for decoding, have to shift them by <<1 first.
  82. - 0x08F8: Decoder SDRAM refresh
  83. - 0x08FC: Decoder SDRAM pre-charge
  84. Other memory locations:
  85. - 0x2800: Video Display Module control
  86. - 0x2D00: AO (audio output?) control
  87. - 0x2D24: Bytes Flushed
  88. - 0x7000: LSB I2C write clock bit (inverted)
  89. - 0x7004: LSB I2C write data bit (inverted)
  90. - 0x7008: LSB I2C read clock bit
  91. - 0x700c: LSB I2C read data bit
  92. - 0x9008: GPIO get input state
  93. - 0x900c: GPIO set output state
  94. - 0x9020: GPIO direction (Bit7 (GPIO 0..7) - 0:input, 1:output)
  95. - 0x9050: SPU control
  96. - 0x9054: Reset HW blocks
  97. - 0x9058: VPU control
  98. - 0xA018: Bit6: interrupt pending?
  99. - 0xA064: APU command
  100. Interrupt Status Register
  101. ~~~~~~~~~~~~~~~~~~~~~~~~~
  102. The definition of the bits in the interrupt status register 0x0040, and the
  103. interrupt mask 0x0048. If a bit is cleared in the mask, then we want our ISR to
  104. execute.
  105. - bit 31 Encoder Start Capture
  106. - bit 30 Encoder EOS
  107. - bit 29 Encoder VBI capture
  108. - bit 28 Encoder Video Input Module reset event
  109. - bit 27 Encoder DMA complete
  110. - bit 24 Decoder audio mode change detection event (through event notification)
  111. - bit 22 Decoder data request
  112. - bit 20 Decoder DMA complete
  113. - bit 19 Decoder VBI re-insertion
  114. - bit 18 Decoder DMA err (linked-list bad)
  115. Missing documentation
  116. ---------------------
  117. - Encoder API post(?)
  118. - Decoder API post(?)
  119. - Decoder VTRACE event
  120. The cx2341x firmware upload
  121. ---------------------------
  122. This document describes how to upload the cx2341x firmware to the card.
  123. How to find
  124. ~~~~~~~~~~~
  125. See the web pages of the various projects that uses this chip for information
  126. on how to obtain the firmware.
  127. The firmware stored in a Windows driver can be detected as follows:
  128. - Each firmware image is 256k bytes.
  129. - The 1st 32-bit word of the Encoder image is 0x0000da7
  130. - The 1st 32-bit word of the Decoder image is 0x00003a7
  131. - The 2nd 32-bit word of both images is 0xaa55bb66
  132. How to load
  133. ~~~~~~~~~~~
  134. - Issue the FWapi command to stop the encoder if it is running. Wait for the
  135. command to complete.
  136. - Issue the FWapi command to stop the decoder if it is running. Wait for the
  137. command to complete.
  138. - Issue the I2C command to the digitizer to stop emitting VSYNC events.
  139. - Issue the FWapi command to halt the encoder's firmware.
  140. - Sleep for 10ms.
  141. - Issue the FWapi command to halt the decoder's firmware.
  142. - Sleep for 10ms.
  143. - Write 0x00000000 to register 0x2800 to stop the Video Display Module.
  144. - Write 0x00000005 to register 0x2D00 to stop the AO (audio output?).
  145. - Write 0x00000000 to register 0xA064 to ping? the APU.
  146. - Write 0xFFFFFFFE to register 0x9058 to stop the VPU.
  147. - Write 0xFFFFFFFF to register 0x9054 to reset the HW blocks.
  148. - Write 0x00000001 to register 0x9050 to stop the SPU.
  149. - Sleep for 10ms.
  150. - Write 0x0000001A to register 0x07FC to init the Encoder SDRAM's pre-charge.
  151. - Write 0x80000640 to register 0x07F8 to init the Encoder SDRAM's refresh to 1us.
  152. - Write 0x0000001A to register 0x08FC to init the Decoder SDRAM's pre-charge.
  153. - Write 0x80000640 to register 0x08F8 to init the Decoder SDRAM's refresh to 1us.
  154. - Sleep for 512ms. (600ms is recommended)
  155. - Transfer the encoder's firmware image to offset 0 in Encoder memory space.
  156. - Transfer the decoder's firmware image to offset 0 in Decoder memory space.
  157. - Use a read-modify-write operation to Clear bit 0 of register 0x9050 to
  158. re-enable the SPU.
  159. - Sleep for 1 second.
  160. - Use a read-modify-write operation to Clear bits 3 and 0 of register 0x9058
  161. to re-enable the VPU.
  162. - Sleep for 1 second.
  163. - Issue status API commands to both firmware images to verify.
  164. How to call the firmware API
  165. ----------------------------
  166. The preferred calling convention is known as the firmware mailbox. The
  167. mailboxes are basically a fixed length array that serves as the call-stack.
  168. Firmware mailboxes can be located by searching the encoder and decoder memory
  169. for a 16 byte signature. That signature will be located on a 256-byte boundary.
  170. Signature:
  171. .. code-block:: none
  172. 0x78, 0x56, 0x34, 0x12, 0x12, 0x78, 0x56, 0x34,
  173. 0x34, 0x12, 0x78, 0x56, 0x56, 0x34, 0x12, 0x78
  174. The firmware implements 20 mailboxes of 20 32-bit words. The first 10 are
  175. reserved for API calls. The second 10 are used by the firmware for event
  176. notification.
  177. ====== =================
  178. Index Name
  179. ====== =================
  180. 0 Flags
  181. 1 Command
  182. 2 Return value
  183. 3 Timeout
  184. 4-19 Parameter/Result
  185. ====== =================
  186. The flags are defined in the following table. The direction is from the
  187. perspective of the firmware.
  188. ==== ========== ============================================
  189. Bit Direction Purpose
  190. ==== ========== ============================================
  191. 2 O Firmware has processed the command.
  192. 1 I Driver has finished setting the parameters.
  193. 0 I Driver is using this mailbox.
  194. ==== ========== ============================================
  195. The command is a 32-bit enumerator. The API specifics may be found in this
  196. chapter.
  197. The return value is a 32-bit enumerator. Only two values are currently defined:
  198. - 0=success
  199. - -1=command undefined.
  200. There are 16 parameters/results 32-bit fields. The driver populates these fields
  201. with values for all the parameters required by the call. The driver overwrites
  202. these fields with result values returned by the call.
  203. The timeout value protects the card from a hung driver thread. If the driver
  204. doesn't handle the completed call within the timeout specified, the firmware
  205. will reset that mailbox.
  206. To make an API call, the driver iterates over each mailbox looking for the
  207. first one available (bit 0 has been cleared). The driver sets that bit, fills
  208. in the command enumerator, the timeout value and any required parameters. The
  209. driver then sets the parameter ready bit (bit 1). The firmware scans the
  210. mailboxes for pending commands, processes them, sets the result code, populates
  211. the result value array with that call's return values and sets the call
  212. complete bit (bit 2). Once bit 2 is set, the driver should retrieve the results
  213. and clear all the flags. If the driver does not perform this task within the
  214. time set in the timeout register, the firmware will reset that mailbox.
  215. Event notifications are sent from the firmware to the host. The host tells the
  216. firmware which events it is interested in via an API call. That call tells the
  217. firmware which notification mailbox to use. The firmware signals the host via
  218. an interrupt. Only the 16 Results fields are used, the Flags, Command, Return
  219. value and Timeout words are not used.
  220. OSD firmware API description
  221. ----------------------------
  222. .. note:: this API is part of the decoder firmware, so it's cx23415 only.
  223. CX2341X_OSD_GET_FRAMEBUFFER
  224. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  225. Enum: 65/0x41
  226. Description
  227. ^^^^^^^^^^^
  228. Return base and length of contiguous OSD memory.
  229. Result[0]
  230. ^^^^^^^^^
  231. OSD base address
  232. Result[1]
  233. ^^^^^^^^^
  234. OSD length
  235. CX2341X_OSD_GET_PIXEL_FORMAT
  236. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  237. Enum: 66/0x42
  238. Description
  239. ^^^^^^^^^^^
  240. Query OSD format
  241. Result[0]
  242. ^^^^^^^^^
  243. 0=8bit index
  244. 1=16bit RGB 5:6:5
  245. 2=16bit ARGB 1:5:5:5
  246. 3=16bit ARGB 1:4:4:4
  247. 4=32bit ARGB 8:8:8:8
  248. CX2341X_OSD_SET_PIXEL_FORMAT
  249. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  250. Enum: 67/0x43
  251. Description
  252. ^^^^^^^^^^^
  253. Assign pixel format
  254. Param[0]
  255. ^^^^^^^^
  256. - 0=8bit index
  257. - 1=16bit RGB 5:6:5
  258. - 2=16bit ARGB 1:5:5:5
  259. - 3=16bit ARGB 1:4:4:4
  260. - 4=32bit ARGB 8:8:8:8
  261. CX2341X_OSD_GET_STATE
  262. ~~~~~~~~~~~~~~~~~~~~~
  263. Enum: 68/0x44
  264. Description
  265. ^^^^^^^^^^^
  266. Query OSD state
  267. Result[0]
  268. ^^^^^^^^^
  269. - Bit 0 0=off, 1=on
  270. - Bits 1:2 alpha control
  271. - Bits 3:5 pixel format
  272. CX2341X_OSD_SET_STATE
  273. ~~~~~~~~~~~~~~~~~~~~~
  274. Enum: 69/0x45
  275. Description
  276. ^^^^^^^^^^^
  277. OSD switch
  278. Param[0]
  279. ^^^^^^^^
  280. 0=off, 1=on
  281. CX2341X_OSD_GET_OSD_COORDS
  282. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  283. Enum: 70/0x46
  284. Description
  285. ^^^^^^^^^^^
  286. Retrieve coordinates of OSD area blended with video
  287. Result[0]
  288. ^^^^^^^^^
  289. OSD buffer address
  290. Result[1]
  291. ^^^^^^^^^
  292. Stride in pixels
  293. Result[2]
  294. ^^^^^^^^^
  295. Lines in OSD buffer
  296. Result[3]
  297. ^^^^^^^^^
  298. Horizontal offset in buffer
  299. Result[4]
  300. ^^^^^^^^^
  301. Vertical offset in buffer
  302. CX2341X_OSD_SET_OSD_COORDS
  303. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  304. Enum: 71/0x47
  305. Description
  306. ^^^^^^^^^^^
  307. Assign the coordinates of the OSD area to blend with video
  308. Param[0]
  309. ^^^^^^^^
  310. buffer address
  311. Param[1]
  312. ^^^^^^^^
  313. buffer stride in pixels
  314. Param[2]
  315. ^^^^^^^^
  316. lines in buffer
  317. Param[3]
  318. ^^^^^^^^
  319. horizontal offset
  320. Param[4]
  321. ^^^^^^^^
  322. vertical offset
  323. CX2341X_OSD_GET_SCREEN_COORDS
  324. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  325. Enum: 72/0x48
  326. Description
  327. ^^^^^^^^^^^
  328. Retrieve OSD screen area coordinates
  329. Result[0]
  330. ^^^^^^^^^
  331. top left horizontal offset
  332. Result[1]
  333. ^^^^^^^^^
  334. top left vertical offset
  335. Result[2]
  336. ^^^^^^^^^
  337. bottom right horizontal offset
  338. Result[3]
  339. ^^^^^^^^^
  340. bottom right vertical offset
  341. CX2341X_OSD_SET_SCREEN_COORDS
  342. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  343. Enum: 73/0x49
  344. Description
  345. ^^^^^^^^^^^
  346. Assign the coordinates of the screen area to blend with video
  347. Param[0]
  348. ^^^^^^^^
  349. top left horizontal offset
  350. Param[1]
  351. ^^^^^^^^
  352. top left vertical offset
  353. Param[2]
  354. ^^^^^^^^
  355. bottom left horizontal offset
  356. Param[3]
  357. ^^^^^^^^
  358. bottom left vertical offset
  359. CX2341X_OSD_GET_GLOBAL_ALPHA
  360. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  361. Enum: 74/0x4A
  362. Description
  363. ^^^^^^^^^^^
  364. Retrieve OSD global alpha
  365. Result[0]
  366. ^^^^^^^^^
  367. global alpha: 0=off, 1=on
  368. Result[1]
  369. ^^^^^^^^^
  370. bits 0:7 global alpha
  371. CX2341X_OSD_SET_GLOBAL_ALPHA
  372. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  373. Enum: 75/0x4B
  374. Description
  375. ^^^^^^^^^^^
  376. Update global alpha
  377. Param[0]
  378. ^^^^^^^^
  379. global alpha: 0=off, 1=on
  380. Param[1]
  381. ^^^^^^^^
  382. global alpha (8 bits)
  383. Param[2]
  384. ^^^^^^^^
  385. local alpha: 0=on, 1=off
  386. CX2341X_OSD_SET_BLEND_COORDS
  387. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  388. Enum: 78/0x4C
  389. Description
  390. ^^^^^^^^^^^
  391. Move start of blending area within display buffer
  392. Param[0]
  393. ^^^^^^^^
  394. horizontal offset in buffer
  395. Param[1]
  396. ^^^^^^^^
  397. vertical offset in buffer
  398. CX2341X_OSD_GET_FLICKER_STATE
  399. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  400. Enum: 79/0x4F
  401. Description
  402. ^^^^^^^^^^^
  403. Retrieve flicker reduction module state
  404. Result[0]
  405. ^^^^^^^^^
  406. flicker state: 0=off, 1=on
  407. CX2341X_OSD_SET_FLICKER_STATE
  408. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  409. Enum: 80/0x50
  410. Description
  411. ^^^^^^^^^^^
  412. Set flicker reduction module state
  413. Param[0]
  414. ^^^^^^^^
  415. State: 0=off, 1=on
  416. CX2341X_OSD_BLT_COPY
  417. ~~~~~~~~~~~~~~~~~~~~
  418. Enum: 82/0x52
  419. Description
  420. ^^^^^^^^^^^
  421. BLT copy
  422. Param[0]
  423. ^^^^^^^^
  424. .. code-block:: none
  425. '0000' zero
  426. '0001' ~destination AND ~source
  427. '0010' ~destination AND source
  428. '0011' ~destination
  429. '0100' destination AND ~source
  430. '0101' ~source
  431. '0110' destination XOR source
  432. '0111' ~destination OR ~source
  433. '1000' ~destination AND ~source
  434. '1001' destination XNOR source
  435. '1010' source
  436. '1011' ~destination OR source
  437. '1100' destination
  438. '1101' destination OR ~source
  439. '1110' destination OR source
  440. '1111' one
  441. Param[1]
  442. ^^^^^^^^
  443. Resulting alpha blending
  444. - '01' source_alpha
  445. - '10' destination_alpha
  446. - '11' source_alpha*destination_alpha+1
  447. (zero if both source and destination alpha are zero)
  448. Param[2]
  449. ^^^^^^^^
  450. .. code-block:: none
  451. '00' output_pixel = source_pixel
  452. '01' if source_alpha=0:
  453. output_pixel = destination_pixel
  454. if 256 > source_alpha > 1:
  455. output_pixel = ((source_alpha + 1)*source_pixel +
  456. (255 - source_alpha)*destination_pixel)/256
  457. '10' if destination_alpha=0:
  458. output_pixel = source_pixel
  459. if 255 > destination_alpha > 0:
  460. output_pixel = ((255 - destination_alpha)*source_pixel +
  461. (destination_alpha + 1)*destination_pixel)/256
  462. '11' if source_alpha=0:
  463. source_temp = 0
  464. if source_alpha=255:
  465. source_temp = source_pixel*256
  466. if 255 > source_alpha > 0:
  467. source_temp = source_pixel*(source_alpha + 1)
  468. if destination_alpha=0:
  469. destination_temp = 0
  470. if destination_alpha=255:
  471. destination_temp = destination_pixel*256
  472. if 255 > destination_alpha > 0:
  473. destination_temp = destination_pixel*(destination_alpha + 1)
  474. output_pixel = (source_temp + destination_temp)/256
  475. Param[3]
  476. ^^^^^^^^
  477. width
  478. Param[4]
  479. ^^^^^^^^
  480. height
  481. Param[5]
  482. ^^^^^^^^
  483. destination pixel mask
  484. Param[6]
  485. ^^^^^^^^
  486. destination rectangle start address
  487. Param[7]
  488. ^^^^^^^^
  489. destination stride in dwords
  490. Param[8]
  491. ^^^^^^^^
  492. source stride in dwords
  493. Param[9]
  494. ^^^^^^^^
  495. source rectangle start address
  496. CX2341X_OSD_BLT_FILL
  497. ~~~~~~~~~~~~~~~~~~~~
  498. Enum: 83/0x53
  499. Description
  500. ^^^^^^^^^^^
  501. BLT fill color
  502. Param[0]
  503. ^^^^^^^^
  504. Same as Param[0] on API 0x52
  505. Param[1]
  506. ^^^^^^^^
  507. Same as Param[1] on API 0x52
  508. Param[2]
  509. ^^^^^^^^
  510. Same as Param[2] on API 0x52
  511. Param[3]
  512. ^^^^^^^^
  513. width
  514. Param[4]
  515. ^^^^^^^^
  516. height
  517. Param[5]
  518. ^^^^^^^^
  519. destination pixel mask
  520. Param[6]
  521. ^^^^^^^^
  522. destination rectangle start address
  523. Param[7]
  524. ^^^^^^^^
  525. destination stride in dwords
  526. Param[8]
  527. ^^^^^^^^
  528. color fill value
  529. CX2341X_OSD_BLT_TEXT
  530. ~~~~~~~~~~~~~~~~~~~~
  531. Enum: 84/0x54
  532. Description
  533. ^^^^^^^^^^^
  534. BLT for 8 bit alpha text source
  535. Param[0]
  536. ^^^^^^^^
  537. Same as Param[0] on API 0x52
  538. Param[1]
  539. ^^^^^^^^
  540. Same as Param[1] on API 0x52
  541. Param[2]
  542. ^^^^^^^^
  543. Same as Param[2] on API 0x52
  544. Param[3]
  545. ^^^^^^^^
  546. width
  547. Param[4]
  548. ^^^^^^^^
  549. height
  550. Param[5]
  551. ^^^^^^^^
  552. destination pixel mask
  553. Param[6]
  554. ^^^^^^^^
  555. destination rectangle start address
  556. Param[7]
  557. ^^^^^^^^
  558. destination stride in dwords
  559. Param[8]
  560. ^^^^^^^^
  561. source stride in dwords
  562. Param[9]
  563. ^^^^^^^^
  564. source rectangle start address
  565. Param[10]
  566. ^^^^^^^^^
  567. color fill value
  568. CX2341X_OSD_SET_FRAMEBUFFER_WINDOW
  569. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  570. Enum: 86/0x56
  571. Description
  572. ^^^^^^^^^^^
  573. Positions the main output window on the screen. The coordinates must be
  574. such that the entire window fits on the screen.
  575. Param[0]
  576. ^^^^^^^^
  577. window width
  578. Param[1]
  579. ^^^^^^^^
  580. window height
  581. Param[2]
  582. ^^^^^^^^
  583. top left window corner horizontal offset
  584. Param[3]
  585. ^^^^^^^^
  586. top left window corner vertical offset
  587. CX2341X_OSD_SET_CHROMA_KEY
  588. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  589. Enum: 96/0x60
  590. Description
  591. ^^^^^^^^^^^
  592. Chroma key switch and color
  593. Param[0]
  594. ^^^^^^^^
  595. state: 0=off, 1=on
  596. Param[1]
  597. ^^^^^^^^
  598. color
  599. CX2341X_OSD_GET_ALPHA_CONTENT_INDEX
  600. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  601. Enum: 97/0x61
  602. Description
  603. ^^^^^^^^^^^
  604. Retrieve alpha content index
  605. Result[0]
  606. ^^^^^^^^^
  607. alpha content index, Range 0:15
  608. CX2341X_OSD_SET_ALPHA_CONTENT_INDEX
  609. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  610. Enum: 98/0x62
  611. Description
  612. ^^^^^^^^^^^
  613. Assign alpha content index
  614. Param[0]
  615. ^^^^^^^^
  616. alpha content index, range 0:15
  617. Encoder firmware API description
  618. --------------------------------
  619. CX2341X_ENC_PING_FW
  620. ~~~~~~~~~~~~~~~~~~~
  621. Enum: 128/0x80
  622. Description
  623. ^^^^^^^^^^^
  624. Does nothing. Can be used to check if the firmware is responding.
  625. CX2341X_ENC_START_CAPTURE
  626. ~~~~~~~~~~~~~~~~~~~~~~~~~
  627. Enum: 129/0x81
  628. Description
  629. ^^^^^^^^^^^
  630. Commences the capture of video, audio and/or VBI data. All encoding
  631. parameters must be initialized prior to this API call. Captures frames
  632. continuously or until a predefined number of frames have been captured.
  633. Param[0]
  634. ^^^^^^^^
  635. Capture stream type:
  636. - 0=MPEG
  637. - 1=Raw
  638. - 2=Raw passthrough
  639. - 3=VBI
  640. Param[1]
  641. ^^^^^^^^
  642. Bitmask:
  643. - Bit 0 when set, captures YUV
  644. - Bit 1 when set, captures PCM audio
  645. - Bit 2 when set, captures VBI (same as param[0]=3)
  646. - Bit 3 when set, the capture destination is the decoder
  647. (same as param[0]=2)
  648. - Bit 4 when set, the capture destination is the host
  649. .. note:: this parameter is only meaningful for RAW capture type.
  650. CX2341X_ENC_STOP_CAPTURE
  651. ~~~~~~~~~~~~~~~~~~~~~~~~
  652. Enum: 130/0x82
  653. Description
  654. ^^^^^^^^^^^
  655. Ends a capture in progress
  656. Param[0]
  657. ^^^^^^^^
  658. - 0=stop at end of GOP (generates IRQ)
  659. - 1=stop immediate (no IRQ)
  660. Param[1]
  661. ^^^^^^^^
  662. Stream type to stop, see param[0] of API 0x81
  663. Param[2]
  664. ^^^^^^^^
  665. Subtype, see param[1] of API 0x81
  666. CX2341X_ENC_SET_AUDIO_ID
  667. ~~~~~~~~~~~~~~~~~~~~~~~~
  668. Enum: 137/0x89
  669. Description
  670. ^^^^^^^^^^^
  671. Assigns the transport stream ID of the encoded audio stream
  672. Param[0]
  673. ^^^^^^^^
  674. Audio Stream ID
  675. CX2341X_ENC_SET_VIDEO_ID
  676. ~~~~~~~~~~~~~~~~~~~~~~~~
  677. Enum: 139/0x8B
  678. Description
  679. ^^^^^^^^^^^
  680. Set video transport stream ID
  681. Param[0]
  682. ^^^^^^^^
  683. Video stream ID
  684. CX2341X_ENC_SET_PCR_ID
  685. ~~~~~~~~~~~~~~~~~~~~~~
  686. Enum: 141/0x8D
  687. Description
  688. ^^^^^^^^^^^
  689. Assigns the transport stream ID for PCR packets
  690. Param[0]
  691. ^^^^^^^^
  692. PCR Stream ID
  693. CX2341X_ENC_SET_FRAME_RATE
  694. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  695. Enum: 143/0x8F
  696. Description
  697. ^^^^^^^^^^^
  698. Set video frames per second. Change occurs at start of new GOP.
  699. Param[0]
  700. ^^^^^^^^
  701. - 0=30fps
  702. - 1=25fps
  703. CX2341X_ENC_SET_FRAME_SIZE
  704. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  705. Enum: 145/0x91
  706. Description
  707. ^^^^^^^^^^^
  708. Select video stream encoding resolution.
  709. Param[0]
  710. ^^^^^^^^
  711. Height in lines. Default 480
  712. Param[1]
  713. ^^^^^^^^
  714. Width in pixels. Default 720
  715. CX2341X_ENC_SET_BIT_RATE
  716. ~~~~~~~~~~~~~~~~~~~~~~~~
  717. Enum: 149/0x95
  718. Description
  719. ^^^^^^^^^^^
  720. Assign average video stream bitrate.
  721. Param[0]
  722. ^^^^^^^^
  723. 0=variable bitrate, 1=constant bitrate
  724. Param[1]
  725. ^^^^^^^^
  726. bitrate in bits per second
  727. Param[2]
  728. ^^^^^^^^
  729. peak bitrate in bits per second, divided by 400
  730. Param[3]
  731. ^^^^^^^^
  732. Mux bitrate in bits per second, divided by 400. May be 0 (default).
  733. Param[4]
  734. ^^^^^^^^
  735. Rate Control VBR Padding
  736. Param[5]
  737. ^^^^^^^^
  738. VBV Buffer used by encoder
  739. .. note::
  740. #) Param\[3\] and Param\[4\] seem to be always 0
  741. #) Param\[5\] doesn't seem to be used.
  742. CX2341X_ENC_SET_GOP_PROPERTIES
  743. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  744. Enum: 151/0x97
  745. Description
  746. ^^^^^^^^^^^
  747. Setup the GOP structure
  748. Param[0]
  749. ^^^^^^^^
  750. GOP size (maximum is 34)
  751. Param[1]
  752. ^^^^^^^^
  753. Number of B frames between the I and P frame, plus 1.
  754. For example: IBBPBBPBBPBB --> GOP size: 12, number of B frames: 2+1 = 3
  755. .. note::
  756. GOP size must be a multiple of (B-frames + 1).
  757. CX2341X_ENC_SET_ASPECT_RATIO
  758. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  759. Enum: 153/0x99
  760. Description
  761. ^^^^^^^^^^^
  762. Sets the encoding aspect ratio. Changes in the aspect ratio take effect
  763. at the start of the next GOP.
  764. Param[0]
  765. ^^^^^^^^
  766. - '0000' forbidden
  767. - '0001' 1:1 square
  768. - '0010' 4:3
  769. - '0011' 16:9
  770. - '0100' 2.21:1
  771. - '0101' to '1111' reserved
  772. CX2341X_ENC_SET_DNR_FILTER_MODE
  773. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  774. Enum: 155/0x9B
  775. Description
  776. ^^^^^^^^^^^
  777. Assign Dynamic Noise Reduction operating mode
  778. Param[0]
  779. ^^^^^^^^
  780. Bit0: Spatial filter, set=auto, clear=manual
  781. Bit1: Temporal filter, set=auto, clear=manual
  782. Param[1]
  783. ^^^^^^^^
  784. Median filter:
  785. - 0=Disabled
  786. - 1=Horizontal
  787. - 2=Vertical
  788. - 3=Horiz/Vert
  789. - 4=Diagonal
  790. CX2341X_ENC_SET_DNR_FILTER_PROPS
  791. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  792. Enum: 157/0x9D
  793. Description
  794. ^^^^^^^^^^^
  795. These Dynamic Noise Reduction filter values are only meaningful when
  796. the respective filter is set to "manual" (See API 0x9B)
  797. Param[0]
  798. ^^^^^^^^
  799. Spatial filter: default 0, range 0:15
  800. Param[1]
  801. ^^^^^^^^
  802. Temporal filter: default 0, range 0:31
  803. CX2341X_ENC_SET_CORING_LEVELS
  804. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  805. Enum: 159/0x9F
  806. Description
  807. ^^^^^^^^^^^
  808. Assign Dynamic Noise Reduction median filter properties.
  809. Param[0]
  810. ^^^^^^^^
  811. Threshold above which the luminance median filter is enabled.
  812. Default: 0, range 0:255
  813. Param[1]
  814. ^^^^^^^^
  815. Threshold below which the luminance median filter is enabled.
  816. Default: 255, range 0:255
  817. Param[2]
  818. ^^^^^^^^
  819. Threshold above which the chrominance median filter is enabled.
  820. Default: 0, range 0:255
  821. Param[3]
  822. ^^^^^^^^
  823. Threshold below which the chrominance median filter is enabled.
  824. Default: 255, range 0:255
  825. CX2341X_ENC_SET_SPATIAL_FILTER_TYPE
  826. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  827. Enum: 161/0xA1
  828. Description
  829. ^^^^^^^^^^^
  830. Assign spatial prefilter parameters
  831. Param[0]
  832. ^^^^^^^^
  833. Luminance filter
  834. - 0=Off
  835. - 1=1D Horizontal
  836. - 2=1D Vertical
  837. - 3=2D H/V Separable (default)
  838. - 4=2D Symmetric non-separable
  839. Param[1]
  840. ^^^^^^^^
  841. Chrominance filter
  842. - 0=Off
  843. - 1=1D Horizontal (default)
  844. CX2341X_ENC_SET_VBI_LINE
  845. ~~~~~~~~~~~~~~~~~~~~~~~~
  846. Enum: 183/0xB7
  847. Description
  848. ^^^^^^^^^^^
  849. Selects VBI line number.
  850. Param[0]
  851. ^^^^^^^^
  852. - Bits 0:4 line number
  853. - Bit 31 0=top_field, 1=bottom_field
  854. - Bits 0:31 all set specifies "all lines"
  855. Param[1]
  856. ^^^^^^^^
  857. VBI line information features: 0=disabled, 1=enabled
  858. Param[2]
  859. ^^^^^^^^
  860. Slicing: 0=None, 1=Closed Caption
  861. Almost certainly not implemented. Set to 0.
  862. Param[3]
  863. ^^^^^^^^
  864. Luminance samples in this line.
  865. Almost certainly not implemented. Set to 0.
  866. Param[4]
  867. ^^^^^^^^
  868. Chrominance samples in this line
  869. Almost certainly not implemented. Set to 0.
  870. CX2341X_ENC_SET_STREAM_TYPE
  871. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  872. Enum: 185/0xB9
  873. Description
  874. ^^^^^^^^^^^
  875. Assign stream type
  876. .. note::
  877. Transport stream is not working in recent firmwares.
  878. And in older firmwares the timestamps in the TS seem to be
  879. unreliable.
  880. Param[0]
  881. ^^^^^^^^
  882. - 0=Program stream
  883. - 1=Transport stream
  884. - 2=MPEG1 stream
  885. - 3=PES A/V stream
  886. - 5=PES Video stream
  887. - 7=PES Audio stream
  888. - 10=DVD stream
  889. - 11=VCD stream
  890. - 12=SVCD stream
  891. - 13=DVD_S1 stream
  892. - 14=DVD_S2 stream
  893. CX2341X_ENC_SET_OUTPUT_PORT
  894. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  895. Enum: 187/0xBB
  896. Description
  897. ^^^^^^^^^^^
  898. Assign stream output port. Normally 0 when the data is copied through
  899. the PCI bus (DMA), and 1 when the data is streamed to another chip
  900. (pvrusb and cx88-blackbird).
  901. Param[0]
  902. ^^^^^^^^
  903. - 0=Memory (default)
  904. - 1=Streaming
  905. - 2=Serial
  906. Param[1]
  907. ^^^^^^^^
  908. Unknown, but leaving this to 0 seems to work best. Indications are that
  909. this might have to do with USB support, although passing anything but 0
  910. only breaks things.
  911. CX2341X_ENC_SET_AUDIO_PROPERTIES
  912. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  913. Enum: 189/0xBD
  914. Description
  915. ^^^^^^^^^^^
  916. Set audio stream properties, may be called while encoding is in progress.
  917. .. note::
  918. All bitfields are consistent with ISO11172 documentation except
  919. bits 2:3 which ISO docs define as:
  920. - '11' Layer I
  921. - '10' Layer II
  922. - '01' Layer III
  923. - '00' Undefined
  924. This discrepancy may indicate a possible error in the documentation.
  925. Testing indicated that only Layer II is actually working, and that
  926. the minimum bitrate should be 192 kbps.
  927. Param[0]
  928. ^^^^^^^^
  929. Bitmask:
  930. .. code-block:: none
  931. 0:1 '00' 44.1Khz
  932. '01' 48Khz
  933. '10' 32Khz
  934. '11' reserved
  935. 2:3 '01'=Layer I
  936. '10'=Layer II
  937. 4:7 Bitrate:
  938. Index | Layer I | Layer II
  939. ------+-------------+------------
  940. '0000' | free format | free format
  941. '0001' | 32 kbit/s | 32 kbit/s
  942. '0010' | 64 kbit/s | 48 kbit/s
  943. '0011' | 96 kbit/s | 56 kbit/s
  944. '0100' | 128 kbit/s | 64 kbit/s
  945. '0101' | 160 kbit/s | 80 kbit/s
  946. '0110' | 192 kbit/s | 96 kbit/s
  947. '0111' | 224 kbit/s | 112 kbit/s
  948. '1000' | 256 kbit/s | 128 kbit/s
  949. '1001' | 288 kbit/s | 160 kbit/s
  950. '1010' | 320 kbit/s | 192 kbit/s
  951. '1011' | 352 kbit/s | 224 kbit/s
  952. '1100' | 384 kbit/s | 256 kbit/s
  953. '1101' | 416 kbit/s | 320 kbit/s
  954. '1110' | 448 kbit/s | 384 kbit/s
  955. .. note::
  956. For Layer II, not all combinations of total bitrate
  957. and mode are allowed. See ISO11172-3 3-Annex B,
  958. Table 3-B.2
  959. 8:9 '00'=Stereo
  960. '01'=JointStereo
  961. '10'=Dual
  962. '11'=Mono
  963. .. note::
  964. The cx23415 cannot decode Joint Stereo properly.
  965. 10:11 Mode Extension used in joint_stereo mode.
  966. In Layer I and II they indicate which subbands are in
  967. intensity_stereo. All other subbands are coded in stereo.
  968. '00' subbands 4-31 in intensity_stereo, bound==4
  969. '01' subbands 8-31 in intensity_stereo, bound==8
  970. '10' subbands 12-31 in intensity_stereo, bound==12
  971. '11' subbands 16-31 in intensity_stereo, bound==16
  972. 12:13 Emphasis:
  973. '00' None
  974. '01' 50/15uS
  975. '10' reserved
  976. '11' CCITT J.17
  977. 14 CRC:
  978. '0' off
  979. '1' on
  980. 15 Copyright:
  981. '0' off
  982. '1' on
  983. 16 Generation:
  984. '0' copy
  985. '1' original
  986. CX2341X_ENC_HALT_FW
  987. ~~~~~~~~~~~~~~~~~~~
  988. Enum: 195/0xC3
  989. Description
  990. ^^^^^^^^^^^
  991. The firmware is halted and no further API calls are serviced until the
  992. firmware is uploaded again.
  993. CX2341X_ENC_GET_VERSION
  994. ~~~~~~~~~~~~~~~~~~~~~~~
  995. Enum: 196/0xC4
  996. Description
  997. ^^^^^^^^^^^
  998. Returns the version of the encoder firmware.
  999. Result[0]
  1000. ^^^^^^^^^
  1001. Version bitmask:
  1002. - Bits 0:15 build
  1003. - Bits 16:23 minor
  1004. - Bits 24:31 major
  1005. CX2341X_ENC_SET_GOP_CLOSURE
  1006. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1007. Enum: 197/0xC5
  1008. Description
  1009. ^^^^^^^^^^^
  1010. Assigns the GOP open/close property.
  1011. Param[0]
  1012. ^^^^^^^^
  1013. - 0=Open
  1014. - 1=Closed
  1015. CX2341X_ENC_GET_SEQ_END
  1016. ~~~~~~~~~~~~~~~~~~~~~~~
  1017. Enum: 198/0xC6
  1018. Description
  1019. ^^^^^^^^^^^
  1020. Obtains the sequence end code of the encoder's buffer. When a capture
  1021. is started a number of interrupts are still generated, the last of
  1022. which will have Result[0] set to 1 and Result[1] will contain the size
  1023. of the buffer.
  1024. Result[0]
  1025. ^^^^^^^^^
  1026. State of the transfer (1 if last buffer)
  1027. Result[1]
  1028. ^^^^^^^^^
  1029. If Result[0] is 1, this contains the size of the last buffer, undefined
  1030. otherwise.
  1031. CX2341X_ENC_SET_PGM_INDEX_INFO
  1032. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1033. Enum: 199/0xC7
  1034. Description
  1035. ^^^^^^^^^^^
  1036. Sets the Program Index Information.
  1037. The information is stored as follows:
  1038. .. code-block:: c
  1039. struct info {
  1040. u32 length; // Length of this frame
  1041. u32 offset_low; // Offset in the file of the
  1042. u32 offset_high; // start of this frame
  1043. u32 mask1; // Bits 0-2 are the type mask:
  1044. // 1=I, 2=P, 4=B
  1045. // 0=End of Program Index, other fields
  1046. // are invalid.
  1047. u32 pts; // The PTS of the frame
  1048. u32 mask2; // Bit 0 is bit 32 of the pts.
  1049. };
  1050. u32 table_ptr;
  1051. struct info index[400];
  1052. The table_ptr is the encoder memory address in the table were
  1053. *new* entries will be written.
  1054. .. note:: This is a ringbuffer, so the table_ptr will wraparound.
  1055. Param[0]
  1056. ^^^^^^^^
  1057. Picture Mask:
  1058. - 0=No index capture
  1059. - 1=I frames
  1060. - 3=I,P frames
  1061. - 7=I,P,B frames
  1062. (Seems to be ignored, it always indexes I, P and B frames)
  1063. Param[1]
  1064. ^^^^^^^^
  1065. Elements requested (up to 400)
  1066. Result[0]
  1067. ^^^^^^^^^
  1068. Offset in the encoder memory of the start of the table.
  1069. Result[1]
  1070. ^^^^^^^^^
  1071. Number of allocated elements up to a maximum of Param[1]
  1072. CX2341X_ENC_SET_VBI_CONFIG
  1073. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1074. Enum: 200/0xC8
  1075. Description
  1076. ^^^^^^^^^^^
  1077. Configure VBI settings
  1078. Param[0]
  1079. ^^^^^^^^
  1080. Bitmap:
  1081. .. code-block:: none
  1082. 0 Mode '0' Sliced, '1' Raw
  1083. 1:3 Insertion:
  1084. '000' insert in extension & user data
  1085. '001' insert in private packets
  1086. '010' separate stream and user data
  1087. '111' separate stream and private data
  1088. 8:15 Stream ID (normally 0xBD)
  1089. Param[1]
  1090. ^^^^^^^^
  1091. Frames per interrupt (max 8). Only valid in raw mode.
  1092. Param[2]
  1093. ^^^^^^^^
  1094. Total raw VBI frames. Only valid in raw mode.
  1095. Param[3]
  1096. ^^^^^^^^
  1097. Start codes
  1098. Param[4]
  1099. ^^^^^^^^
  1100. Stop codes
  1101. Param[5]
  1102. ^^^^^^^^
  1103. Lines per frame
  1104. Param[6]
  1105. ^^^^^^^^
  1106. Byte per line
  1107. Result[0]
  1108. ^^^^^^^^^
  1109. Observed frames per interrupt in raw mode only. Rage 1 to Param[1]
  1110. Result[1]
  1111. ^^^^^^^^^
  1112. Observed number of frames in raw mode. Range 1 to Param[2]
  1113. Result[2]
  1114. ^^^^^^^^^
  1115. Memory offset to start or raw VBI data
  1116. CX2341X_ENC_SET_DMA_BLOCK_SIZE
  1117. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1118. Enum: 201/0xC9
  1119. Description
  1120. ^^^^^^^^^^^
  1121. Set DMA transfer block size
  1122. Param[0]
  1123. ^^^^^^^^
  1124. DMA transfer block size in bytes or frames. When unit is bytes,
  1125. supported block sizes are 2^7, 2^8 and 2^9 bytes.
  1126. Param[1]
  1127. ^^^^^^^^
  1128. Unit: 0=bytes, 1=frames
  1129. CX2341X_ENC_GET_PREV_DMA_INFO_MB_10
  1130. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1131. Enum: 202/0xCA
  1132. Description
  1133. ^^^^^^^^^^^
  1134. Returns information on the previous DMA transfer in conjunction with
  1135. bit 27 of the interrupt mask. Uses mailbox 10.
  1136. Result[0]
  1137. ^^^^^^^^^
  1138. Type of stream
  1139. Result[1]
  1140. ^^^^^^^^^
  1141. Address Offset
  1142. Result[2]
  1143. ^^^^^^^^^
  1144. Maximum size of transfer
  1145. CX2341X_ENC_GET_PREV_DMA_INFO_MB_9
  1146. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1147. Enum: 203/0xCB
  1148. Description
  1149. ^^^^^^^^^^^
  1150. Returns information on the previous DMA transfer in conjunction with
  1151. bit 27 or 18 of the interrupt mask. Uses mailbox 9.
  1152. Result[0]
  1153. ^^^^^^^^^
  1154. Status bits:
  1155. - 0 read completed
  1156. - 1 write completed
  1157. - 2 DMA read error
  1158. - 3 DMA write error
  1159. - 4 Scatter-Gather array error
  1160. Result[1]
  1161. ^^^^^^^^^
  1162. DMA type
  1163. Result[2]
  1164. ^^^^^^^^^
  1165. Presentation Time Stamp bits 0..31
  1166. Result[3]
  1167. ^^^^^^^^^
  1168. Presentation Time Stamp bit 32
  1169. CX2341X_ENC_SCHED_DMA_TO_HOST
  1170. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1171. Enum: 204/0xCC
  1172. Description
  1173. ^^^^^^^^^^^
  1174. Setup DMA to host operation
  1175. Param[0]
  1176. ^^^^^^^^
  1177. Memory address of link list
  1178. Param[1]
  1179. ^^^^^^^^
  1180. Length of link list (wtf: what units ???)
  1181. Param[2]
  1182. ^^^^^^^^
  1183. DMA type (0=MPEG)
  1184. CX2341X_ENC_INITIALIZE_INPUT
  1185. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1186. Enum: 205/0xCD
  1187. Description
  1188. ^^^^^^^^^^^
  1189. Initializes the video input
  1190. CX2341X_ENC_SET_FRAME_DROP_RATE
  1191. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1192. Enum: 208/0xD0
  1193. Description
  1194. ^^^^^^^^^^^
  1195. For each frame captured, skip specified number of frames.
  1196. Param[0]
  1197. ^^^^^^^^
  1198. Number of frames to skip
  1199. CX2341X_ENC_PAUSE_ENCODER
  1200. ~~~~~~~~~~~~~~~~~~~~~~~~~
  1201. Enum: 210/0xD2
  1202. Description
  1203. ^^^^^^^^^^^
  1204. During a pause condition, all frames are dropped instead of being encoded.
  1205. Param[0]
  1206. ^^^^^^^^
  1207. - 0=Pause encoding
  1208. - 1=Continue encoding
  1209. CX2341X_ENC_REFRESH_INPUT
  1210. ~~~~~~~~~~~~~~~~~~~~~~~~~
  1211. Enum: 211/0xD3
  1212. Description
  1213. ^^^^^^^^^^^
  1214. Refreshes the video input
  1215. CX2341X_ENC_SET_COPYRIGHT
  1216. ~~~~~~~~~~~~~~~~~~~~~~~~~
  1217. Enum: 212/0xD4
  1218. Description
  1219. ^^^^^^^^^^^
  1220. Sets stream copyright property
  1221. Param[0]
  1222. ^^^^^^^^
  1223. - 0=Stream is not copyrighted
  1224. - 1=Stream is copyrighted
  1225. CX2341X_ENC_SET_EVENT_NOTIFICATION
  1226. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1227. Enum: 213/0xD5
  1228. Description
  1229. ^^^^^^^^^^^
  1230. Setup firmware to notify the host about a particular event. Host must
  1231. unmask the interrupt bit.
  1232. Param[0]
  1233. ^^^^^^^^
  1234. Event (0=refresh encoder input)
  1235. Param[1]
  1236. ^^^^^^^^
  1237. Notification 0=disabled 1=enabled
  1238. Param[2]
  1239. ^^^^^^^^
  1240. Interrupt bit
  1241. Param[3]
  1242. ^^^^^^^^
  1243. Mailbox slot, -1 if no mailbox required.
  1244. CX2341X_ENC_SET_NUM_VSYNC_LINES
  1245. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1246. Enum: 214/0xD6
  1247. Description
  1248. ^^^^^^^^^^^
  1249. Depending on the analog video decoder used, this assigns the number
  1250. of lines for field 1 and 2.
  1251. Param[0]
  1252. ^^^^^^^^
  1253. Field 1 number of lines:
  1254. - 0x00EF for SAA7114
  1255. - 0x00F0 for SAA7115
  1256. - 0x0105 for Micronas
  1257. Param[1]
  1258. ^^^^^^^^
  1259. Field 2 number of lines:
  1260. - 0x00EF for SAA7114
  1261. - 0x00F0 for SAA7115
  1262. - 0x0106 for Micronas
  1263. CX2341X_ENC_SET_PLACEHOLDER
  1264. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1265. Enum: 215/0xD7
  1266. Description
  1267. ^^^^^^^^^^^
  1268. Provides a mechanism of inserting custom user data in the MPEG stream.
  1269. Param[0]
  1270. ^^^^^^^^
  1271. - 0=extension & user data
  1272. - 1=private packet with stream ID 0xBD
  1273. Param[1]
  1274. ^^^^^^^^
  1275. Rate at which to insert data, in units of frames (for private packet)
  1276. or GOPs (for ext. & user data)
  1277. Param[2]
  1278. ^^^^^^^^
  1279. Number of data DWORDs (below) to insert
  1280. Param[3]
  1281. ^^^^^^^^
  1282. Custom data 0
  1283. Param[4]
  1284. ^^^^^^^^
  1285. Custom data 1
  1286. Param[5]
  1287. ^^^^^^^^
  1288. Custom data 2
  1289. Param[6]
  1290. ^^^^^^^^
  1291. Custom data 3
  1292. Param[7]
  1293. ^^^^^^^^
  1294. Custom data 4
  1295. Param[8]
  1296. ^^^^^^^^
  1297. Custom data 5
  1298. Param[9]
  1299. ^^^^^^^^
  1300. Custom data 6
  1301. Param[10]
  1302. ^^^^^^^^^
  1303. Custom data 7
  1304. Param[11]
  1305. ^^^^^^^^^
  1306. Custom data 8
  1307. CX2341X_ENC_MUTE_VIDEO
  1308. ~~~~~~~~~~~~~~~~~~~~~~
  1309. Enum: 217/0xD9
  1310. Description
  1311. ^^^^^^^^^^^
  1312. Video muting
  1313. Param[0]
  1314. ^^^^^^^^
  1315. Bit usage:
  1316. .. code-block:: none
  1317. 0 '0'=video not muted
  1318. '1'=video muted, creates frames with the YUV color defined below
  1319. 1:7 Unused
  1320. 8:15 V chrominance information
  1321. 16:23 U chrominance information
  1322. 24:31 Y luminance information
  1323. CX2341X_ENC_MUTE_AUDIO
  1324. ~~~~~~~~~~~~~~~~~~~~~~
  1325. Enum: 218/0xDA
  1326. Description
  1327. ^^^^^^^^^^^
  1328. Audio muting
  1329. Param[0]
  1330. ^^^^^^^^
  1331. - 0=audio not muted
  1332. - 1=audio muted (produces silent mpeg audio stream)
  1333. CX2341X_ENC_SET_VERT_CROP_LINE
  1334. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1335. Enum: 219/0xDB
  1336. Description
  1337. ^^^^^^^^^^^
  1338. Something to do with 'Vertical Crop Line'
  1339. Param[0]
  1340. ^^^^^^^^
  1341. If saa7114 and raw VBI capture and 60 Hz, then set to 10001.
  1342. Else 0.
  1343. CX2341X_ENC_MISC
  1344. ~~~~~~~~~~~~~~~~
  1345. Enum: 220/0xDC
  1346. Description
  1347. ^^^^^^^^^^^
  1348. Miscellaneous actions. Not known for 100% what it does. It's really a
  1349. sort of ioctl call. The first parameter is a command number, the second
  1350. the value.
  1351. Param[0]
  1352. ^^^^^^^^
  1353. Command number:
  1354. .. code-block:: none
  1355. 1=set initial SCR value when starting encoding (works).
  1356. 2=set quality mode (apparently some test setting).
  1357. 3=setup advanced VIM protection handling.
  1358. Always 1 for the cx23416 and 0 for cx23415.
  1359. 4=generate DVD compatible PTS timestamps
  1360. 5=USB flush mode
  1361. 6=something to do with the quantization matrix
  1362. 7=set navigation pack insertion for DVD: adds 0xbf (private stream 2)
  1363. packets to the MPEG. The size of these packets is 2048 bytes (including
  1364. the header of 6 bytes: 0x000001bf + length). The payload is zeroed and
  1365. it is up to the application to fill them in. These packets are apparently
  1366. inserted every four frames.
  1367. 8=enable scene change detection (seems to be a failure)
  1368. 9=set history parameters of the video input module
  1369. 10=set input field order of VIM
  1370. 11=set quantization matrix
  1371. 12=reset audio interface after channel change or input switch (has no argument).
  1372. Needed for the cx2584x, not needed for the mspx4xx, but it doesn't seem to
  1373. do any harm calling it regardless.
  1374. 13=set audio volume delay
  1375. 14=set audio delay
  1376. Param[1]
  1377. ^^^^^^^^
  1378. Command value.
  1379. Decoder firmware API description
  1380. --------------------------------
  1381. .. note:: this API is part of the decoder firmware, so it's cx23415 only.
  1382. CX2341X_DEC_PING_FW
  1383. ~~~~~~~~~~~~~~~~~~~
  1384. Enum: 0/0x00
  1385. Description
  1386. ^^^^^^^^^^^
  1387. This API call does nothing. It may be used to check if the firmware
  1388. is responding.
  1389. CX2341X_DEC_START_PLAYBACK
  1390. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1391. Enum: 1/0x01
  1392. Description
  1393. ^^^^^^^^^^^
  1394. Begin or resume playback.
  1395. Param[0]
  1396. ^^^^^^^^
  1397. 0 based frame number in GOP to begin playback from.
  1398. Param[1]
  1399. ^^^^^^^^
  1400. Specifies the number of muted audio frames to play before normal
  1401. audio resumes. (This is not implemented in the firmware, leave at 0)
  1402. CX2341X_DEC_STOP_PLAYBACK
  1403. ~~~~~~~~~~~~~~~~~~~~~~~~~
  1404. Enum: 2/0x02
  1405. Description
  1406. ^^^^^^^^^^^
  1407. Ends playback and clears all decoder buffers. If PTS is not zero,
  1408. playback stops at specified PTS.
  1409. Param[0]
  1410. ^^^^^^^^
  1411. Display 0=last frame, 1=black
  1412. .. note::
  1413. this takes effect immediately, so if you want to wait for a PTS,
  1414. then use '0', otherwise the screen goes to black at once.
  1415. You can call this later (even if there is no playback) with a 1 value
  1416. to set the screen to black.
  1417. Param[1]
  1418. ^^^^^^^^
  1419. PTS low
  1420. Param[2]
  1421. ^^^^^^^^
  1422. PTS high
  1423. CX2341X_DEC_SET_PLAYBACK_SPEED
  1424. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1425. Enum: 3/0x03
  1426. Description
  1427. ^^^^^^^^^^^
  1428. Playback stream at speed other than normal. There are two modes of
  1429. operation:
  1430. - Smooth: host transfers entire stream and firmware drops unused
  1431. frames.
  1432. - Coarse: host drops frames based on indexing as required to achieve
  1433. desired speed.
  1434. Param[0]
  1435. ^^^^^^^^
  1436. .. code-block:: none
  1437. Bitmap:
  1438. 0:7 0 normal
  1439. 1 fast only "1.5 times"
  1440. n nX fast, 1/nX slow
  1441. 30 Framedrop:
  1442. '0' during 1.5 times play, every other B frame is dropped
  1443. '1' during 1.5 times play, stream is unchanged (bitrate
  1444. must not exceed 8mbps)
  1445. 31 Speed:
  1446. '0' slow
  1447. '1' fast
  1448. .. note::
  1449. n is limited to 2. Anything higher does not result in
  1450. faster playback. Instead the host should start dropping frames.
  1451. Param[1]
  1452. ^^^^^^^^
  1453. Direction: 0=forward, 1=reverse
  1454. .. note::
  1455. to make reverse playback work you have to write full GOPs in
  1456. reverse order.
  1457. Param[2]
  1458. ^^^^^^^^
  1459. .. code-block:: none
  1460. Picture mask:
  1461. 1=I frames
  1462. 3=I, P frames
  1463. 7=I, P, B frames
  1464. Param[3]
  1465. ^^^^^^^^
  1466. B frames per GOP (for reverse play only)
  1467. .. note::
  1468. for reverse playback the Picture Mask should be set to I or I, P.
  1469. Adding B frames to the mask will result in corrupt video. This field
  1470. has to be set to the correct value in order to keep the timing correct.
  1471. Param[4]
  1472. ^^^^^^^^
  1473. Mute audio: 0=disable, 1=enable
  1474. Param[5]
  1475. ^^^^^^^^
  1476. Display 0=frame, 1=field
  1477. Param[6]
  1478. ^^^^^^^^
  1479. Specifies the number of muted audio frames to play before normal audio
  1480. resumes. (Not implemented in the firmware, leave at 0)
  1481. CX2341X_DEC_STEP_VIDEO
  1482. ~~~~~~~~~~~~~~~~~~~~~~
  1483. Enum: 5/0x05
  1484. Description
  1485. ^^^^^^^^^^^
  1486. Each call to this API steps the playback to the next unit defined below
  1487. in the current playback direction.
  1488. Param[0]
  1489. ^^^^^^^^
  1490. 0=frame, 1=top field, 2=bottom field
  1491. CX2341X_DEC_SET_DMA_BLOCK_SIZE
  1492. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1493. Enum: 8/0x08
  1494. Description
  1495. ^^^^^^^^^^^
  1496. Set DMA transfer block size. Counterpart to API 0xC9
  1497. Param[0]
  1498. ^^^^^^^^
  1499. DMA transfer block size in bytes. A different size may be specified
  1500. when issuing the DMA transfer command.
  1501. CX2341X_DEC_GET_XFER_INFO
  1502. ~~~~~~~~~~~~~~~~~~~~~~~~~
  1503. Enum: 9/0x09
  1504. Description
  1505. ^^^^^^^^^^^
  1506. This API call may be used to detect an end of stream condition.
  1507. Result[0]
  1508. ^^^^^^^^^
  1509. Stream type
  1510. Result[1]
  1511. ^^^^^^^^^
  1512. Address offset
  1513. Result[2]
  1514. ^^^^^^^^^
  1515. Maximum bytes to transfer
  1516. Result[3]
  1517. ^^^^^^^^^
  1518. Buffer fullness
  1519. CX2341X_DEC_GET_DMA_STATUS
  1520. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1521. Enum: 10/0x0A
  1522. Description
  1523. ^^^^^^^^^^^
  1524. Status of the last DMA transfer
  1525. Result[0]
  1526. ^^^^^^^^^
  1527. Bit 1 set means transfer complete
  1528. Bit 2 set means DMA error
  1529. Bit 3 set means linked list error
  1530. Result[1]
  1531. ^^^^^^^^^
  1532. DMA type: 0=MPEG, 1=OSD, 2=YUV
  1533. CX2341X_DEC_SCHED_DMA_FROM_HOST
  1534. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1535. Enum: 11/0x0B
  1536. Description
  1537. ^^^^^^^^^^^
  1538. Setup DMA from host operation. Counterpart to API 0xCC
  1539. Param[0]
  1540. ^^^^^^^^
  1541. Memory address of link list
  1542. Param[1]
  1543. ^^^^^^^^
  1544. Total # of bytes to transfer
  1545. Param[2]
  1546. ^^^^^^^^
  1547. DMA type (0=MPEG, 1=OSD, 2=YUV)
  1548. CX2341X_DEC_PAUSE_PLAYBACK
  1549. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1550. Enum: 13/0x0D
  1551. Description
  1552. ^^^^^^^^^^^
  1553. Freeze playback immediately. In this mode, when internal buffers are
  1554. full, no more data will be accepted and data request IRQs will be
  1555. masked.
  1556. Param[0]
  1557. ^^^^^^^^
  1558. Display: 0=last frame, 1=black
  1559. CX2341X_DEC_HALT_FW
  1560. ~~~~~~~~~~~~~~~~~~~
  1561. Enum: 14/0x0E
  1562. Description
  1563. ^^^^^^^^^^^
  1564. The firmware is halted and no further API calls are serviced until
  1565. the firmware is uploaded again.
  1566. CX2341X_DEC_SET_STANDARD
  1567. ~~~~~~~~~~~~~~~~~~~~~~~~
  1568. Enum: 16/0x10
  1569. Description
  1570. ^^^^^^^^^^^
  1571. Selects display standard
  1572. Param[0]
  1573. ^^^^^^^^
  1574. 0=NTSC, 1=PAL
  1575. CX2341X_DEC_GET_VERSION
  1576. ~~~~~~~~~~~~~~~~~~~~~~~
  1577. Enum: 17/0x11
  1578. Description
  1579. ^^^^^^^^^^^
  1580. Returns decoder firmware version information
  1581. Result[0]
  1582. ^^^^^^^^^
  1583. Version bitmask:
  1584. - Bits 0:15 build
  1585. - Bits 16:23 minor
  1586. - Bits 24:31 major
  1587. CX2341X_DEC_SET_STREAM_INPUT
  1588. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1589. Enum: 20/0x14
  1590. Description
  1591. ^^^^^^^^^^^
  1592. Select decoder stream input port
  1593. Param[0]
  1594. ^^^^^^^^
  1595. 0=memory (default), 1=streaming
  1596. CX2341X_DEC_GET_TIMING_INFO
  1597. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1598. Enum: 21/0x15
  1599. Description
  1600. ^^^^^^^^^^^
  1601. Returns timing information from start of playback
  1602. Result[0]
  1603. ^^^^^^^^^
  1604. Frame count by decode order
  1605. Result[1]
  1606. ^^^^^^^^^
  1607. Video PTS bits 0:31 by display order
  1608. Result[2]
  1609. ^^^^^^^^^
  1610. Video PTS bit 32 by display order
  1611. Result[3]
  1612. ^^^^^^^^^
  1613. SCR bits 0:31 by display order
  1614. Result[4]
  1615. ^^^^^^^^^
  1616. SCR bit 32 by display order
  1617. CX2341X_DEC_SET_AUDIO_MODE
  1618. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1619. Enum: 22/0x16
  1620. Description
  1621. ^^^^^^^^^^^
  1622. Select audio mode
  1623. Param[0]
  1624. ^^^^^^^^
  1625. Dual mono mode action
  1626. 0=Stereo, 1=Left, 2=Right, 3=Mono, 4=Swap, -1=Unchanged
  1627. Param[1]
  1628. ^^^^^^^^
  1629. Stereo mode action:
  1630. 0=Stereo, 1=Left, 2=Right, 3=Mono, 4=Swap, -1=Unchanged
  1631. CX2341X_DEC_SET_EVENT_NOTIFICATION
  1632. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1633. Enum: 23/0x17
  1634. Description
  1635. ^^^^^^^^^^^
  1636. Setup firmware to notify the host about a particular event.
  1637. Counterpart to API 0xD5
  1638. Param[0]
  1639. ^^^^^^^^
  1640. Event:
  1641. - 0=Audio mode change between mono, (joint) stereo and dual channel.
  1642. - 3=Decoder started
  1643. - 4=Unknown: goes off 10-15 times per second while decoding.
  1644. - 5=Some sync event: goes off once per frame.
  1645. Param[1]
  1646. ^^^^^^^^
  1647. Notification 0=disabled, 1=enabled
  1648. Param[2]
  1649. ^^^^^^^^
  1650. Interrupt bit
  1651. Param[3]
  1652. ^^^^^^^^
  1653. Mailbox slot, -1 if no mailbox required.
  1654. CX2341X_DEC_SET_DISPLAY_BUFFERS
  1655. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1656. Enum: 24/0x18
  1657. Description
  1658. ^^^^^^^^^^^
  1659. Number of display buffers. To decode all frames in reverse playback you
  1660. must use nine buffers.
  1661. Param[0]
  1662. ^^^^^^^^
  1663. 0=six buffers, 1=nine buffers
  1664. CX2341X_DEC_EXTRACT_VBI
  1665. ~~~~~~~~~~~~~~~~~~~~~~~
  1666. Enum: 25/0x19
  1667. Description
  1668. ^^^^^^^^^^^
  1669. Extracts VBI data
  1670. Param[0]
  1671. ^^^^^^^^
  1672. 0=extract from extension & user data, 1=extract from private packets
  1673. Result[0]
  1674. ^^^^^^^^^
  1675. VBI table location
  1676. Result[1]
  1677. ^^^^^^^^^
  1678. VBI table size
  1679. CX2341X_DEC_SET_DECODER_SOURCE
  1680. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1681. Enum: 26/0x1A
  1682. Description
  1683. ^^^^^^^^^^^
  1684. Selects decoder source. Ensure that the parameters passed to this
  1685. API match the encoder settings.
  1686. Param[0]
  1687. ^^^^^^^^
  1688. Mode: 0=MPEG from host, 1=YUV from encoder, 2=YUV from host
  1689. Param[1]
  1690. ^^^^^^^^
  1691. YUV picture width
  1692. Param[2]
  1693. ^^^^^^^^
  1694. YUV picture height
  1695. Param[3]
  1696. ^^^^^^^^
  1697. Bitmap: see Param[0] of API 0xBD
  1698. CX2341X_DEC_SET_PREBUFFERING
  1699. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1700. Enum: 30/0x1E
  1701. Description
  1702. ^^^^^^^^^^^
  1703. Decoder prebuffering, when enabled up to 128KB are buffered for
  1704. streams <8mpbs or 640KB for streams >8mbps
  1705. Param[0]
  1706. ^^^^^^^^
  1707. 0=off, 1=on
  1708. PVR350 Video decoder registers 0x02002800 -> 0x02002B00
  1709. -------------------------------------------------------
  1710. Author: Ian Armstrong <ian@iarmst.demon.co.uk>
  1711. Version: v0.4
  1712. Date: 12 March 2007
  1713. This list has been worked out through trial and error. There will be mistakes
  1714. and omissions. Some registers have no obvious effect so it's hard to say what
  1715. they do, while others interact with each other, or require a certain load
  1716. sequence. Horizontal filter setup is one example, with six registers working
  1717. in unison and requiring a certain load sequence to correctly configure. The
  1718. indexed colour palette is much easier to set at just two registers, but again
  1719. it requires a certain load sequence.
  1720. Some registers are fussy about what they are set to. Load in a bad value & the
  1721. decoder will fail. A firmware reload will often recover, but sometimes a reset
  1722. is required. For registers containing size information, setting them to 0 is
  1723. generally a bad idea. For other control registers i.e. 2878, you'll only find
  1724. out what values are bad when it hangs.
  1725. .. code-block:: none
  1726. --------------------------------------------------------------------------------
  1727. 2800
  1728. bit 0
  1729. Decoder enable
  1730. 0 = disable
  1731. 1 = enable
  1732. --------------------------------------------------------------------------------
  1733. 2804
  1734. bits 0:31
  1735. Decoder horizontal Y alias register 1
  1736. ---------------
  1737. 2808
  1738. bits 0:31
  1739. Decoder horizontal Y alias register 2
  1740. ---------------
  1741. 280C
  1742. bits 0:31
  1743. Decoder horizontal Y alias register 3
  1744. ---------------
  1745. 2810
  1746. bits 0:31
  1747. Decoder horizontal Y alias register 4
  1748. ---------------
  1749. 2814
  1750. bits 0:31
  1751. Decoder horizontal Y alias register 5
  1752. ---------------
  1753. 2818
  1754. bits 0:31
  1755. Decoder horizontal Y alias trigger
  1756. These six registers control the horizontal aliasing filter for the Y plane.
  1757. The first five registers must all be loaded before accessing the trigger
  1758. (2818), as this register actually clocks the data through for the first
  1759. five.
  1760. To correctly program set the filter, this whole procedure must be done 16
  1761. times. The actual register contents are copied from a lookup-table in the
  1762. firmware which contains 4 different filter settings.
  1763. --------------------------------------------------------------------------------
  1764. 281C
  1765. bits 0:31
  1766. Decoder horizontal UV alias register 1
  1767. ---------------
  1768. 2820
  1769. bits 0:31
  1770. Decoder horizontal UV alias register 2
  1771. ---------------
  1772. 2824
  1773. bits 0:31
  1774. Decoder horizontal UV alias register 3
  1775. ---------------
  1776. 2828
  1777. bits 0:31
  1778. Decoder horizontal UV alias register 4
  1779. ---------------
  1780. 282C
  1781. bits 0:31
  1782. Decoder horizontal UV alias register 5
  1783. ---------------
  1784. 2830
  1785. bits 0:31
  1786. Decoder horizontal UV alias trigger
  1787. These six registers control the horizontal aliasing for the UV plane.
  1788. Operation is the same as the Y filter, with 2830 being the trigger
  1789. register.
  1790. --------------------------------------------------------------------------------
  1791. 2834
  1792. bits 0:15
  1793. Decoder Y source width in pixels
  1794. bits 16:31
  1795. Decoder Y destination width in pixels
  1796. ---------------
  1797. 2838
  1798. bits 0:15
  1799. Decoder UV source width in pixels
  1800. bits 16:31
  1801. Decoder UV destination width in pixels
  1802. NOTE: For both registers, the resulting image must be fully visible on
  1803. screen. If the image exceeds the right edge both the source and destination
  1804. size must be adjusted to reflect the visible portion. For the source width,
  1805. you must take into account the scaling when calculating the new value.
  1806. --------------------------------------------------------------------------------
  1807. 283C
  1808. bits 0:31
  1809. Decoder Y horizontal scaling
  1810. Normally = Reg 2854 >> 2
  1811. ---------------
  1812. 2840
  1813. bits 0:31
  1814. Decoder ?? unknown - horizontal scaling
  1815. Usually 0x00080514
  1816. ---------------
  1817. 2844
  1818. bits 0:31
  1819. Decoder UV horizontal scaling
  1820. Normally = Reg 2854 >> 2
  1821. ---------------
  1822. 2848
  1823. bits 0:31
  1824. Decoder ?? unknown - horizontal scaling
  1825. Usually 0x00100514
  1826. ---------------
  1827. 284C
  1828. bits 0:31
  1829. Decoder ?? unknown - Y plane
  1830. Usually 0x00200020
  1831. ---------------
  1832. 2850
  1833. bits 0:31
  1834. Decoder ?? unknown - UV plane
  1835. Usually 0x00200020
  1836. ---------------
  1837. 2854
  1838. bits 0:31
  1839. Decoder 'master' value for horizontal scaling
  1840. ---------------
  1841. 2858
  1842. bits 0:31
  1843. Decoder ?? unknown
  1844. Usually 0
  1845. ---------------
  1846. 285C
  1847. bits 0:31
  1848. Decoder ?? unknown
  1849. Normally = Reg 2854 >> 1
  1850. ---------------
  1851. 2860
  1852. bits 0:31
  1853. Decoder ?? unknown
  1854. Usually 0
  1855. ---------------
  1856. 2864
  1857. bits 0:31
  1858. Decoder ?? unknown
  1859. Normally = Reg 2854 >> 1
  1860. ---------------
  1861. 2868
  1862. bits 0:31
  1863. Decoder ?? unknown
  1864. Usually 0
  1865. Most of these registers either control horizontal scaling, or appear linked
  1866. to it in some way. Register 2854 contains the 'master' value & the other
  1867. registers can be calculated from that one. You must also remember to
  1868. correctly set the divider in Reg 2874.
  1869. To enlarge:
  1870. Reg 2854 = (source_width * 0x00200000) / destination_width
  1871. Reg 2874 = No divide
  1872. To reduce from full size down to half size:
  1873. Reg 2854 = (source_width/2 * 0x00200000) / destination width
  1874. Reg 2874 = Divide by 2
  1875. To reduce from half size down to quarter size:
  1876. Reg 2854 = (source_width/4 * 0x00200000) / destination width
  1877. Reg 2874 = Divide by 4
  1878. The result is always rounded up.
  1879. --------------------------------------------------------------------------------
  1880. 286C
  1881. bits 0:15
  1882. Decoder horizontal Y buffer offset
  1883. bits 15:31
  1884. Decoder horizontal UV buffer offset
  1885. Offset into the video image buffer. If the offset is gradually incremented,
  1886. the on screen image will move left & wrap around higher up on the right.
  1887. --------------------------------------------------------------------------------
  1888. 2870
  1889. bits 0:15
  1890. Decoder horizontal Y output offset
  1891. bits 16:31
  1892. Decoder horizontal UV output offset
  1893. Offsets the actual video output. Controls output alignment of the Y & UV
  1894. planes. The higher the value, the greater the shift to the left. Use
  1895. reg 2890 to move the image right.
  1896. --------------------------------------------------------------------------------
  1897. 2874
  1898. bits 0:1
  1899. Decoder horizontal Y output size divider
  1900. 00 = No divide
  1901. 01 = Divide by 2
  1902. 10 = Divide by 3
  1903. bits 4:5
  1904. Decoder horizontal UV output size divider
  1905. 00 = No divide
  1906. 01 = Divide by 2
  1907. 10 = Divide by 3
  1908. bit 8
  1909. Decoder ?? unknown
  1910. 0 = Normal
  1911. 1 = Affects video output levels
  1912. bit 16
  1913. Decoder ?? unknown
  1914. 0 = Normal
  1915. 1 = Disable horizontal filter
  1916. --------------------------------------------------------------------------------
  1917. 2878
  1918. bit 0
  1919. ?? unknown
  1920. bit 1
  1921. osd on/off
  1922. 0 = osd off
  1923. 1 = osd on
  1924. bit 2
  1925. Decoder + osd video timing
  1926. 0 = NTSC
  1927. 1 = PAL
  1928. bits 3:4
  1929. ?? unknown
  1930. bit 5
  1931. Decoder + osd
  1932. Swaps upper & lower fields
  1933. --------------------------------------------------------------------------------
  1934. 287C
  1935. bits 0:10
  1936. Decoder & osd ?? unknown
  1937. Moves entire screen horizontally. Starts at 0x005 with the screen
  1938. shifted heavily to the right. Incrementing in steps of 0x004 will
  1939. gradually shift the screen to the left.
  1940. bits 11:31
  1941. ?? unknown
  1942. Normally contents are 0x00101111 (NTSC) or 0x1010111d (PAL)
  1943. --------------------------------------------------------------------------------
  1944. 2880 -------- ?? unknown
  1945. 2884 -------- ?? unknown
  1946. --------------------------------------------------------------------------------
  1947. 2888
  1948. bit 0
  1949. Decoder + osd ?? unknown
  1950. 0 = Normal
  1951. 1 = Misaligned fields (Correctable through 289C & 28A4)
  1952. bit 4
  1953. ?? unknown
  1954. bit 8
  1955. ?? unknown
  1956. Warning: Bad values will require a firmware reload to recover.
  1957. Known to be bad are 0x000,0x011,0x100,0x111
  1958. --------------------------------------------------------------------------------
  1959. 288C
  1960. bits 0:15
  1961. osd ?? unknown
  1962. Appears to affect the osd position stability. The higher the value the
  1963. more unstable it becomes. Decoder output remains stable.
  1964. bits 16:31
  1965. osd ?? unknown
  1966. Same as bits 0:15
  1967. --------------------------------------------------------------------------------
  1968. 2890
  1969. bits 0:11
  1970. Decoder output horizontal offset.
  1971. Horizontal offset moves the video image right. A small left shift is
  1972. possible, but it's better to use reg 2870 for that due to its greater
  1973. range.
  1974. NOTE: Video corruption will occur if video window is shifted off the right
  1975. edge. To avoid this read the notes for 2834 & 2838.
  1976. --------------------------------------------------------------------------------
  1977. 2894
  1978. bits 0:23
  1979. Decoder output video surround colour.
  1980. Contains the colour (in yuv) used to fill the screen when the video is
  1981. running in a window.
  1982. --------------------------------------------------------------------------------
  1983. 2898
  1984. bits 0:23
  1985. Decoder video window colour
  1986. Contains the colour (in yuv) used to fill the video window when the
  1987. video is turned off.
  1988. bit 24
  1989. Decoder video output
  1990. 0 = Video on
  1991. 1 = Video off
  1992. bit 28
  1993. Decoder plane order
  1994. 0 = Y,UV
  1995. 1 = UV,Y
  1996. bit 29
  1997. Decoder second plane byte order
  1998. 0 = Normal (UV)
  1999. 1 = Swapped (VU)
  2000. In normal usage, the first plane is Y & the second plane is UV. Though the
  2001. order of the planes can be swapped, only the byte order of the second plane
  2002. can be swapped. This isn't much use for the Y plane, but can be useful for
  2003. the UV plane.
  2004. --------------------------------------------------------------------------------
  2005. 289C
  2006. bits 0:15
  2007. Decoder vertical field offset 1
  2008. bits 16:31
  2009. Decoder vertical field offset 2
  2010. Controls field output vertical alignment. The higher the number, the lower
  2011. the image on screen. Known starting values are 0x011E0017 (NTSC) &
  2012. 0x01500017 (PAL)
  2013. --------------------------------------------------------------------------------
  2014. 28A0
  2015. bits 0:15
  2016. Decoder & osd width in pixels
  2017. bits 16:31
  2018. Decoder & osd height in pixels
  2019. All output from the decoder & osd are disabled beyond this area. Decoder
  2020. output will simply go black outside of this region. If the osd tries to
  2021. exceed this area it will become corrupt.
  2022. --------------------------------------------------------------------------------
  2023. 28A4
  2024. bits 0:11
  2025. osd left shift.
  2026. Has a range of 0x770->0x7FF. With the exception of 0, any value outside of
  2027. this range corrupts the osd.
  2028. --------------------------------------------------------------------------------
  2029. 28A8
  2030. bits 0:15
  2031. osd vertical field offset 1
  2032. bits 16:31
  2033. osd vertical field offset 2
  2034. Controls field output vertical alignment. The higher the number, the lower
  2035. the image on screen. Known starting values are 0x011E0017 (NTSC) &
  2036. 0x01500017 (PAL)
  2037. --------------------------------------------------------------------------------
  2038. 28AC -------- ?? unknown
  2039. |
  2040. V
  2041. 28BC -------- ?? unknown
  2042. --------------------------------------------------------------------------------
  2043. 28C0
  2044. bit 0
  2045. Current output field
  2046. 0 = first field
  2047. 1 = second field
  2048. bits 16:31
  2049. Current scanline
  2050. The scanline counts from the top line of the first field
  2051. through to the last line of the second field.
  2052. --------------------------------------------------------------------------------
  2053. 28C4 -------- ?? unknown
  2054. |
  2055. V
  2056. 28F8 -------- ?? unknown
  2057. --------------------------------------------------------------------------------
  2058. 28FC
  2059. bit 0
  2060. ?? unknown
  2061. 0 = Normal
  2062. 1 = Breaks decoder & osd output
  2063. --------------------------------------------------------------------------------
  2064. 2900
  2065. bits 0:31
  2066. Decoder vertical Y alias register 1
  2067. ---------------
  2068. 2904
  2069. bits 0:31
  2070. Decoder vertical Y alias register 2
  2071. ---------------
  2072. 2908
  2073. bits 0:31
  2074. Decoder vertical Y alias trigger
  2075. These three registers control the vertical aliasing filter for the Y plane.
  2076. Operation is similar to the horizontal Y filter (2804). The only real
  2077. difference is that there are only two registers to set before accessing
  2078. the trigger register (2908). As for the horizontal filter, the values are
  2079. taken from a lookup table in the firmware, and the procedure must be
  2080. repeated 16 times to fully program the filter.
  2081. --------------------------------------------------------------------------------
  2082. 290C
  2083. bits 0:31
  2084. Decoder vertical UV alias register 1
  2085. ---------------
  2086. 2910
  2087. bits 0:31
  2088. Decoder vertical UV alias register 2
  2089. ---------------
  2090. 2914
  2091. bits 0:31
  2092. Decoder vertical UV alias trigger
  2093. These three registers control the vertical aliasing filter for the UV
  2094. plane. Operation is the same as the Y filter, with 2914 being the trigger.
  2095. --------------------------------------------------------------------------------
  2096. 2918
  2097. bits 0:15
  2098. Decoder Y source height in pixels
  2099. bits 16:31
  2100. Decoder Y destination height in pixels
  2101. ---------------
  2102. 291C
  2103. bits 0:15
  2104. Decoder UV source height in pixels divided by 2
  2105. bits 16:31
  2106. Decoder UV destination height in pixels
  2107. NOTE: For both registers, the resulting image must be fully visible on
  2108. screen. If the image exceeds the bottom edge both the source and
  2109. destination size must be adjusted to reflect the visible portion. For the
  2110. source height, you must take into account the scaling when calculating the
  2111. new value.
  2112. --------------------------------------------------------------------------------
  2113. 2920
  2114. bits 0:31
  2115. Decoder Y vertical scaling
  2116. Normally = Reg 2930 >> 2
  2117. ---------------
  2118. 2924
  2119. bits 0:31
  2120. Decoder Y vertical scaling
  2121. Normally = Reg 2920 + 0x514
  2122. ---------------
  2123. 2928
  2124. bits 0:31
  2125. Decoder UV vertical scaling
  2126. When enlarging = Reg 2930 >> 2
  2127. When reducing = Reg 2930 >> 3
  2128. ---------------
  2129. 292C
  2130. bits 0:31
  2131. Decoder UV vertical scaling
  2132. Normally = Reg 2928 + 0x514
  2133. ---------------
  2134. 2930
  2135. bits 0:31
  2136. Decoder 'master' value for vertical scaling
  2137. ---------------
  2138. 2934
  2139. bits 0:31
  2140. Decoder ?? unknown - Y vertical scaling
  2141. ---------------
  2142. 2938
  2143. bits 0:31
  2144. Decoder Y vertical scaling
  2145. Normally = Reg 2930
  2146. ---------------
  2147. 293C
  2148. bits 0:31
  2149. Decoder ?? unknown - Y vertical scaling
  2150. ---------------
  2151. 2940
  2152. bits 0:31
  2153. Decoder UV vertical scaling
  2154. When enlarging = Reg 2930 >> 1
  2155. When reducing = Reg 2930
  2156. ---------------
  2157. 2944
  2158. bits 0:31
  2159. Decoder ?? unknown - UV vertical scaling
  2160. ---------------
  2161. 2948
  2162. bits 0:31
  2163. Decoder UV vertical scaling
  2164. Normally = Reg 2940
  2165. ---------------
  2166. 294C
  2167. bits 0:31
  2168. Decoder ?? unknown - UV vertical scaling
  2169. Most of these registers either control vertical scaling, or appear linked
  2170. to it in some way. Register 2930 contains the 'master' value & all other
  2171. registers can be calculated from that one. You must also remember to
  2172. correctly set the divider in Reg 296C
  2173. To enlarge:
  2174. Reg 2930 = (source_height * 0x00200000) / destination_height
  2175. Reg 296C = No divide
  2176. To reduce from full size down to half size:
  2177. Reg 2930 = (source_height/2 * 0x00200000) / destination height
  2178. Reg 296C = Divide by 2
  2179. To reduce from half down to quarter.
  2180. Reg 2930 = (source_height/4 * 0x00200000) / destination height
  2181. Reg 296C = Divide by 4
  2182. --------------------------------------------------------------------------------
  2183. 2950
  2184. bits 0:15
  2185. Decoder Y line index into display buffer, first field
  2186. bits 16:31
  2187. Decoder Y vertical line skip, first field
  2188. --------------------------------------------------------------------------------
  2189. 2954
  2190. bits 0:15
  2191. Decoder Y line index into display buffer, second field
  2192. bits 16:31
  2193. Decoder Y vertical line skip, second field
  2194. --------------------------------------------------------------------------------
  2195. 2958
  2196. bits 0:15
  2197. Decoder UV line index into display buffer, first field
  2198. bits 16:31
  2199. Decoder UV vertical line skip, first field
  2200. --------------------------------------------------------------------------------
  2201. 295C
  2202. bits 0:15
  2203. Decoder UV line index into display buffer, second field
  2204. bits 16:31
  2205. Decoder UV vertical line skip, second field
  2206. --------------------------------------------------------------------------------
  2207. 2960
  2208. bits 0:15
  2209. Decoder destination height minus 1
  2210. bits 16:31
  2211. Decoder destination height divided by 2
  2212. --------------------------------------------------------------------------------
  2213. 2964
  2214. bits 0:15
  2215. Decoder Y vertical offset, second field
  2216. bits 16:31
  2217. Decoder Y vertical offset, first field
  2218. These two registers shift the Y plane up. The higher the number, the
  2219. greater the shift.
  2220. --------------------------------------------------------------------------------
  2221. 2968
  2222. bits 0:15
  2223. Decoder UV vertical offset, second field
  2224. bits 16:31
  2225. Decoder UV vertical offset, first field
  2226. These two registers shift the UV plane up. The higher the number, the
  2227. greater the shift.
  2228. --------------------------------------------------------------------------------
  2229. 296C
  2230. bits 0:1
  2231. Decoder vertical Y output size divider
  2232. 00 = No divide
  2233. 01 = Divide by 2
  2234. 10 = Divide by 4
  2235. bits 8:9
  2236. Decoder vertical UV output size divider
  2237. 00 = No divide
  2238. 01 = Divide by 2
  2239. 10 = Divide by 4
  2240. --------------------------------------------------------------------------------
  2241. 2970
  2242. bit 0
  2243. Decoder ?? unknown
  2244. 0 = Normal
  2245. 1 = Affect video output levels
  2246. bit 16
  2247. Decoder ?? unknown
  2248. 0 = Normal
  2249. 1 = Disable vertical filter
  2250. --------------------------------------------------------------------------------
  2251. 2974 -------- ?? unknown
  2252. |
  2253. V
  2254. 29EF -------- ?? unknown
  2255. --------------------------------------------------------------------------------
  2256. 2A00
  2257. bits 0:2
  2258. osd colour mode
  2259. 000 = 8 bit indexed
  2260. 001 = 16 bit (565)
  2261. 010 = 15 bit (555)
  2262. 011 = 12 bit (444)
  2263. 100 = 32 bit (8888)
  2264. bits 4:5
  2265. osd display bpp
  2266. 01 = 8 bit
  2267. 10 = 16 bit
  2268. 11 = 32 bit
  2269. bit 8
  2270. osd global alpha
  2271. 0 = Off
  2272. 1 = On
  2273. bit 9
  2274. osd local alpha
  2275. 0 = Off
  2276. 1 = On
  2277. bit 10
  2278. osd colour key
  2279. 0 = Off
  2280. 1 = On
  2281. bit 11
  2282. osd ?? unknown
  2283. Must be 1
  2284. bit 13
  2285. osd colour space
  2286. 0 = ARGB
  2287. 1 = AYVU
  2288. bits 16:31
  2289. osd ?? unknown
  2290. Must be 0x001B (some kind of buffer pointer ?)
  2291. When the bits-per-pixel is set to 8, the colour mode is ignored and
  2292. assumed to be 8 bit indexed. For 16 & 32 bits-per-pixel the colour depth
  2293. is honoured, and when using a colour depth that requires fewer bytes than
  2294. allocated the extra bytes are used as padding. So for a 32 bpp with 8 bit
  2295. index colour, there are 3 padding bytes per pixel. It's also possible to
  2296. select 16bpp with a 32 bit colour mode. This results in the pixel width
  2297. being doubled, but the color key will not work as expected in this mode.
  2298. Colour key is as it suggests. You designate a colour which will become
  2299. completely transparent. When using 565, 555 or 444 colour modes, the
  2300. colour key is always 16 bits wide. The colour to key on is set in Reg 2A18.
  2301. Local alpha works differently depending on the colour mode. For 32bpp & 8
  2302. bit indexed, local alpha is a per-pixel 256 step transparency, with 0 being
  2303. transparent and 255 being solid. For the 16bpp modes 555 & 444, the unused
  2304. bit(s) act as a simple transparency switch, with 0 being solid & 1 being
  2305. fully transparent. There is no local alpha support for 16bit 565.
  2306. Global alpha is a 256 step transparency that applies to the entire osd,
  2307. with 0 being transparent & 255 being solid.
  2308. It's possible to combine colour key, local alpha & global alpha.
  2309. --------------------------------------------------------------------------------
  2310. 2A04
  2311. bits 0:15
  2312. osd x coord for left edge
  2313. bits 16:31
  2314. osd y coord for top edge
  2315. ---------------
  2316. 2A08
  2317. bits 0:15
  2318. osd x coord for right edge
  2319. bits 16:31
  2320. osd y coord for bottom edge
  2321. For both registers, (0,0) = top left corner of the display area. These
  2322. registers do not control the osd size, only where it's positioned & how
  2323. much is visible. The visible osd area cannot exceed the right edge of the
  2324. display, otherwise the osd will become corrupt. See reg 2A10 for
  2325. setting osd width.
  2326. --------------------------------------------------------------------------------
  2327. 2A0C
  2328. bits 0:31
  2329. osd buffer index
  2330. An index into the osd buffer. Slowly incrementing this moves the osd left,
  2331. wrapping around onto the right edge
  2332. --------------------------------------------------------------------------------
  2333. 2A10
  2334. bits 0:11
  2335. osd buffer 32 bit word width
  2336. Contains the width of the osd measured in 32 bit words. This means that all
  2337. colour modes are restricted to a byte width which is divisible by 4.
  2338. --------------------------------------------------------------------------------
  2339. 2A14
  2340. bits 0:15
  2341. osd height in pixels
  2342. bits 16:32
  2343. osd line index into buffer
  2344. osd will start displaying from this line.
  2345. --------------------------------------------------------------------------------
  2346. 2A18
  2347. bits 0:31
  2348. osd colour key
  2349. Contains the colour value which will be transparent.
  2350. --------------------------------------------------------------------------------
  2351. 2A1C
  2352. bits 0:7
  2353. osd global alpha
  2354. Contains the global alpha value (equiv ivtvfbctl --alpha XX)
  2355. --------------------------------------------------------------------------------
  2356. 2A20 -------- ?? unknown
  2357. |
  2358. V
  2359. 2A2C -------- ?? unknown
  2360. --------------------------------------------------------------------------------
  2361. 2A30
  2362. bits 0:7
  2363. osd colour to change in indexed palette
  2364. ---------------
  2365. 2A34
  2366. bits 0:31
  2367. osd colour for indexed palette
  2368. To set the new palette, first load the index of the colour to change into
  2369. 2A30, then load the new colour into 2A34. The full palette is 256 colours,
  2370. so the index range is 0x00-0xFF
  2371. --------------------------------------------------------------------------------
  2372. 2A38 -------- ?? unknown
  2373. 2A3C -------- ?? unknown
  2374. --------------------------------------------------------------------------------
  2375. 2A40
  2376. bits 0:31
  2377. osd ?? unknown
  2378. Affects overall brightness, wrapping around to black
  2379. --------------------------------------------------------------------------------
  2380. 2A44
  2381. bits 0:31
  2382. osd ?? unknown
  2383. Green tint
  2384. --------------------------------------------------------------------------------
  2385. 2A48
  2386. bits 0:31
  2387. osd ?? unknown
  2388. Red tint
  2389. --------------------------------------------------------------------------------
  2390. 2A4C
  2391. bits 0:31
  2392. osd ?? unknown
  2393. Affects overall brightness, wrapping around to black
  2394. --------------------------------------------------------------------------------
  2395. 2A50
  2396. bits 0:31
  2397. osd ?? unknown
  2398. Colour shift
  2399. --------------------------------------------------------------------------------
  2400. 2A54
  2401. bits 0:31
  2402. osd ?? unknown
  2403. Colour shift
  2404. --------------------------------------------------------------------------------
  2405. 2A58 -------- ?? unknown
  2406. |
  2407. V
  2408. 2AFC -------- ?? unknown
  2409. --------------------------------------------------------------------------------
  2410. 2B00
  2411. bit 0
  2412. osd filter control
  2413. 0 = filter off
  2414. 1 = filter on
  2415. bits 1:4
  2416. osd ?? unknown
  2417. --------------------------------------------------------------------------------
  2418. The cx231xx DMA engine
  2419. ----------------------
  2420. This page describes the structures and procedures used by the cx2341x DMA
  2421. engine.
  2422. Introduction
  2423. ~~~~~~~~~~~~
  2424. The cx2341x PCI interface is busmaster capable. This means it has a DMA
  2425. engine to efficiently transfer large volumes of data between the card and main
  2426. memory without requiring help from a CPU. Like most hardware, it must operate
  2427. on contiguous physical memory. This is difficult to come by in large quantities
  2428. on virtual memory machines.
  2429. Therefore, it also supports a technique called "scatter-gather". The card can
  2430. transfer multiple buffers in one operation. Instead of allocating one large
  2431. contiguous buffer, the driver can allocate several smaller buffers.
  2432. In practice, I've seen the average transfer to be roughly 80K, but transfers
  2433. above 128K were not uncommon, particularly at startup. The 128K figure is
  2434. important, because that is the largest block that the kernel can normally
  2435. allocate. Even still, 128K blocks are hard to come by, so the driver writer is
  2436. urged to choose a smaller block size and learn the scatter-gather technique.
  2437. Mailbox #10 is reserved for DMA transfer information.
  2438. Note: the hardware expects little-endian data ('intel format').
  2439. Flow
  2440. ~~~~
  2441. This section describes, in general, the order of events when handling DMA
  2442. transfers. Detailed information follows this section.
  2443. - The card raises the Encoder interrupt.
  2444. - The driver reads the transfer type, offset and size from Mailbox #10.
  2445. - The driver constructs the scatter-gather array from enough free dma buffers
  2446. to cover the size.
  2447. - The driver schedules the DMA transfer via the ScheduleDMAtoHost API call.
  2448. - The card raises the DMA Complete interrupt.
  2449. - The driver checks the DMA status register for any errors.
  2450. - The driver post-processes the newly transferred buffers.
  2451. NOTE! It is possible that the Encoder and DMA Complete interrupts get raised
  2452. simultaneously. (End of the last, start of the next, etc.)
  2453. Mailbox #10
  2454. ~~~~~~~~~~~
  2455. The Flags, Command, Return Value and Timeout fields are ignored.
  2456. - Name: Mailbox #10
  2457. - Results[0]: Type: 0: MPEG.
  2458. - Results[1]: Offset: The position relative to the card's memory space.
  2459. - Results[2]: Size: The exact number of bytes to transfer.
  2460. My speculation is that since the StartCapture API has a capture type of "RAW"
  2461. available, that the type field will have other values that correspond to YUV
  2462. and PCM data.
  2463. Scatter-Gather Array
  2464. ~~~~~~~~~~~~~~~~~~~~
  2465. The scatter-gather array is a contiguously allocated block of memory that
  2466. tells the card the source and destination of each data-block to transfer.
  2467. Card "addresses" are derived from the offset supplied by Mailbox #10. Host
  2468. addresses are the physical memory location of the target DMA buffer.
  2469. Each S-G array element is a struct of three 32-bit words. The first word is
  2470. the source address, the second is the destination address. Both take up the
  2471. entire 32 bits. The lowest 18 bits of the third word is the transfer byte
  2472. count. The high-bit of the third word is the "last" flag. The last-flag tells
  2473. the card to raise the DMA_DONE interrupt. From hard personal experience, if
  2474. you forget to set this bit, the card will still "work" but the stream will
  2475. most likely get corrupted.
  2476. The transfer count must be a multiple of 256. Therefore, the driver will need
  2477. to track how much data in the target buffer is valid and deal with it
  2478. accordingly.
  2479. Array Element:
  2480. - 32-bit Source Address
  2481. - 32-bit Destination Address
  2482. - 14-bit reserved (high bit is the last flag)
  2483. - 18-bit byte count
  2484. DMA Transfer Status
  2485. ~~~~~~~~~~~~~~~~~~~
  2486. Register 0x0004 holds the DMA Transfer Status:
  2487. - bit 0: read completed
  2488. - bit 1: write completed
  2489. - bit 2: DMA read error
  2490. - bit 3: DMA write error
  2491. - bit 4: Scatter-Gather array error
  2492. Non-compressed file format
  2493. --------------------------
  2494. The cx23416 can produce (and the cx23415 can also read) raw YUV output. The
  2495. format of a YUV frame is specific to this chip and is called HM12. 'HM' stands
  2496. for 'Hauppauge Macroblock', which is a misnomer as 'Conexant Macroblock' would
  2497. be more accurate.
  2498. The format is YUV 4:2:0 which uses 1 Y byte per pixel and 1 U and V byte per
  2499. four pixels.
  2500. The data is encoded as two macroblock planes, the first containing the Y
  2501. values, the second containing UV macroblocks.
  2502. The Y plane is divided into blocks of 16x16 pixels from left to right
  2503. and from top to bottom. Each block is transmitted in turn, line-by-line.
  2504. So the first 16 bytes are the first line of the top-left block, the
  2505. second 16 bytes are the second line of the top-left block, etc. After
  2506. transmitting this block the first line of the block on the right to the
  2507. first block is transmitted, etc.
  2508. The UV plane is divided into blocks of 16x8 UV values going from left
  2509. to right, top to bottom. Each block is transmitted in turn, line-by-line.
  2510. So the first 16 bytes are the first line of the top-left block and
  2511. contain 8 UV value pairs (16 bytes in total). The second 16 bytes are the
  2512. second line of 8 UV pairs of the top-left block, etc. After transmitting
  2513. this block the first line of the block on the right to the first block is
  2514. transmitted, etc.
  2515. The code below is given as an example on how to convert HM12 to separate
  2516. Y, U and V planes. This code assumes frames of 720x576 (PAL) pixels.
  2517. The width of a frame is always 720 pixels, regardless of the actual specified
  2518. width.
  2519. If the height is not a multiple of 32 lines, then the captured video is
  2520. missing macroblocks at the end and is unusable. So the height must be a
  2521. multiple of 32.
  2522. Raw format c example
  2523. ~~~~~~~~~~~~~~~~~~~~
  2524. .. code-block:: c
  2525. #include <stdio.h>
  2526. #include <stdlib.h>
  2527. #include <string.h>
  2528. static unsigned char frame[576*720*3/2];
  2529. static unsigned char framey[576*720];
  2530. static unsigned char frameu[576*720 / 4];
  2531. static unsigned char framev[576*720 / 4];
  2532. static void de_macro_y(unsigned char* dst, unsigned char *src, int dstride, int w, int h)
  2533. {
  2534. unsigned int y, x, i;
  2535. // descramble Y plane
  2536. // dstride = 720 = w
  2537. // The Y plane is divided into blocks of 16x16 pixels
  2538. // Each block in transmitted in turn, line-by-line.
  2539. for (y = 0; y < h; y += 16) {
  2540. for (x = 0; x < w; x += 16) {
  2541. for (i = 0; i < 16; i++) {
  2542. memcpy(dst + x + (y + i) * dstride, src, 16);
  2543. src += 16;
  2544. }
  2545. }
  2546. }
  2547. }
  2548. static void de_macro_uv(unsigned char *dstu, unsigned char *dstv, unsigned char *src, int dstride, int w, int h)
  2549. {
  2550. unsigned int y, x, i;
  2551. // descramble U/V plane
  2552. // dstride = 720 / 2 = w
  2553. // The U/V values are interlaced (UVUV...).
  2554. // Again, the UV plane is divided into blocks of 16x16 UV values.
  2555. // Each block in transmitted in turn, line-by-line.
  2556. for (y = 0; y < h; y += 16) {
  2557. for (x = 0; x < w; x += 8) {
  2558. for (i = 0; i < 16; i++) {
  2559. int idx = x + (y + i) * dstride;
  2560. dstu[idx+0] = src[0]; dstv[idx+0] = src[1];
  2561. dstu[idx+1] = src[2]; dstv[idx+1] = src[3];
  2562. dstu[idx+2] = src[4]; dstv[idx+2] = src[5];
  2563. dstu[idx+3] = src[6]; dstv[idx+3] = src[7];
  2564. dstu[idx+4] = src[8]; dstv[idx+4] = src[9];
  2565. dstu[idx+5] = src[10]; dstv[idx+5] = src[11];
  2566. dstu[idx+6] = src[12]; dstv[idx+6] = src[13];
  2567. dstu[idx+7] = src[14]; dstv[idx+7] = src[15];
  2568. src += 16;
  2569. }
  2570. }
  2571. }
  2572. }
  2573. /*************************************************************************/
  2574. int main(int argc, char **argv)
  2575. {
  2576. FILE *fin;
  2577. int i;
  2578. if (argc == 1) fin = stdin;
  2579. else fin = fopen(argv[1], "r");
  2580. if (fin == NULL) {
  2581. fprintf(stderr, "cannot open input\n");
  2582. exit(-1);
  2583. }
  2584. while (fread(frame, sizeof(frame), 1, fin) == 1) {
  2585. de_macro_y(framey, frame, 720, 720, 576);
  2586. de_macro_uv(frameu, framev, frame + 720 * 576, 720 / 2, 720 / 2, 576 / 2);
  2587. fwrite(framey, sizeof(framey), 1, stdout);
  2588. fwrite(framev, sizeof(framev), 1, stdout);
  2589. fwrite(frameu, sizeof(frameu), 1, stdout);
  2590. }
  2591. fclose(fin);
  2592. return 0;
  2593. }
  2594. Format of embedded V4L2_MPEG_STREAM_VBI_FMT_IVTV VBI data
  2595. ---------------------------------------------------------
  2596. Author: Hans Verkuil <hverkuil@xs4all.nl>
  2597. This section describes the V4L2_MPEG_STREAM_VBI_FMT_IVTV format of the VBI data
  2598. embedded in an MPEG-2 program stream. This format is in part dictated by some
  2599. hardware limitations of the ivtv driver (the driver for the Conexant cx23415/6
  2600. chips), in particular a maximum size for the VBI data. Anything longer is cut
  2601. off when the MPEG stream is played back through the cx23415.
  2602. The advantage of this format is it is very compact and that all VBI data for
  2603. all lines can be stored while still fitting within the maximum allowed size.
  2604. The stream ID of the VBI data is 0xBD. The maximum size of the embedded data is
  2605. 4 + 43 * 36, which is 4 bytes for a header and 2 * 18 VBI lines with a 1 byte
  2606. header and a 42 bytes payload each. Anything beyond this limit is cut off by
  2607. the cx23415/6 firmware. Besides the data for the VBI lines we also need 36 bits
  2608. for a bitmask determining which lines are captured and 4 bytes for a magic cookie,
  2609. signifying that this data package contains V4L2_MPEG_STREAM_VBI_FMT_IVTV VBI data.
  2610. If all lines are used, then there is no longer room for the bitmask. To solve this
  2611. two different magic numbers were introduced:
  2612. 'itv0': After this magic number two unsigned longs follow. Bits 0-17 of the first
  2613. unsigned long denote which lines of the first field are captured. Bits 18-31 of
  2614. the first unsigned long and bits 0-3 of the second unsigned long are used for the
  2615. second field.
  2616. 'ITV0': This magic number assumes all VBI lines are captured, i.e. it implicitly
  2617. implies that the bitmasks are 0xffffffff and 0xf.
  2618. After these magic cookies (and the 8 byte bitmask in case of cookie 'itv0') the
  2619. captured VBI lines start:
  2620. For each line the least significant 4 bits of the first byte contain the data type.
  2621. Possible values are shown in the table below. The payload is in the following 42
  2622. bytes.
  2623. Here is the list of possible data types:
  2624. .. code-block:: c
  2625. #define IVTV_SLICED_TYPE_TELETEXT 0x1 // Teletext (uses lines 6-22 for PAL)
  2626. #define IVTV_SLICED_TYPE_CC 0x4 // Closed Captions (line 21 NTSC)
  2627. #define IVTV_SLICED_TYPE_WSS 0x5 // Wide Screen Signal (line 23 PAL)
  2628. #define IVTV_SLICED_TYPE_VPS 0x7 // Video Programming System (PAL) (line 16)