tw5864-reg.h 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142
  1. /*
  2. * TW5864 driver - registers description
  3. *
  4. * Copyright (C) 2016 Bluecherry, LLC <maintainers@bluecherrydvr.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. /* According to TW5864_datasheet_0.6d.pdf, tw5864b1-ds.pdf */
  17. /* Register Description - Direct Map Space */
  18. /* 0x0000 ~ 0x1ffc - H264 Register Map */
  19. /* [15:0] The Version register for H264 core (Read Only) */
  20. #define TW5864_H264REV 0x0000
  21. #define TW5864_EMU 0x0004
  22. /* Define controls in register TW5864_EMU */
  23. /* DDR controller enabled */
  24. #define TW5864_EMU_EN_DDR BIT(0)
  25. /* Enable bit for Inter module */
  26. #define TW5864_EMU_EN_ME BIT(1)
  27. /* Enable bit for Sensor Interface module */
  28. #define TW5864_EMU_EN_SEN BIT(2)
  29. /* Enable bit for Host Burst Access */
  30. #define TW5864_EMU_EN_BHOST BIT(3)
  31. /* Enable bit for Loop Filter module */
  32. #define TW5864_EMU_EN_LPF BIT(4)
  33. /* Enable bit for PLBK module */
  34. #define TW5864_EMU_EN_PLBK BIT(5)
  35. /*
  36. * Video Frame mapping in DDR
  37. * 00 CIF
  38. * 01 D1
  39. * 10 Reserved
  40. * 11 Reserved
  41. *
  42. */
  43. #define TW5864_DSP_FRAME_TYPE (3 << 6)
  44. #define TW5864_DSP_FRAME_TYPE_D1 BIT(6)
  45. #define TW5864_UNDECLARED_H264REV_PART2 0x0008
  46. #define TW5864_SLICE 0x000c
  47. /* Define controls in register TW5864_SLICE */
  48. /* VLC Slice end flag */
  49. #define TW5864_VLC_SLICE_END BIT(0)
  50. /* Master Slice End Flag */
  51. #define TW5864_MAS_SLICE_END BIT(4)
  52. /* Host to start a new slice Address */
  53. #define TW5864_START_NSLICE BIT(15)
  54. /*
  55. * [15:0] Two bit for each channel (channel 0 ~ 7). Each two bits are the buffer
  56. * pointer for the last encoded frame of the corresponding channel.
  57. */
  58. #define TW5864_ENC_BUF_PTR_REC1 0x0010
  59. /* [5:0] DSP_MB_QP and [15:10] DSP_LPF_OFFSET */
  60. #define TW5864_DSP_QP 0x0018
  61. /* Define controls in register TW5864_DSP_QP */
  62. /* [5:0] H264 QP Value for codec */
  63. #define TW5864_DSP_MB_QP 0x003f
  64. /*
  65. * [15:10] H264 LPF_OFFSET Address
  66. * (Default 0)
  67. */
  68. #define TW5864_DSP_LPF_OFFSET 0xfc00
  69. #define TW5864_DSP_CODEC 0x001c
  70. /* Define controls in register TW5864_DSP_CODEC */
  71. /*
  72. * 0: Encode (TW5864 Default)
  73. * 1: Decode
  74. */
  75. #define TW5864_DSP_CODEC_MODE BIT(0)
  76. /*
  77. * 0->3 4 VLC data buffer in DDR (1M each)
  78. * 0->7 8 VLC data buffer in DDR (512k each)
  79. */
  80. #define TW5864_VLC_BUF_ID (7 << 2)
  81. /*
  82. * 0 4CIF in 1 MB
  83. * 1 1CIF in 1 MB
  84. */
  85. #define TW5864_CIF_MAP_MD BIT(6)
  86. /*
  87. * 0 2 falf D1 in 1 MB
  88. * 1 1 half D1 in 1 MB
  89. */
  90. #define TW5864_HD1_MAP_MD BIT(7)
  91. /* VLC Stream valid */
  92. #define TW5864_VLC_VLD BIT(8)
  93. /* MV Vector Valid */
  94. #define TW5864_MV_VECT_VLD BIT(9)
  95. /* MV Flag Valid */
  96. #define TW5864_MV_FLAG_VLD BIT(10)
  97. #define TW5864_DSP_SEN 0x0020
  98. /* Define controls in register TW5864_DSP_SEN */
  99. /* Org Buffer Base for Luma (default 0) */
  100. #define TW5864_DSP_SEN_PIC_LU 0x000f
  101. /* Org Buffer Base for Chroma (default 4) */
  102. #define TW5864_DSP_SEN_PIC_CHM 0x00f0
  103. /* Maximum Number of Buffers (default 4) */
  104. #define TW5864_DSP_SEN_PIC_MAX 0x0700
  105. /*
  106. * Original Frame D1 or HD1 switch
  107. * (Default 0)
  108. */
  109. #define TW5864_DSP_SEN_HFULL 0x1000
  110. #define TW5864_DSP_REF_PIC 0x0024
  111. /* Define controls in register TW5864_DSP_REF_PIC */
  112. /* Ref Buffer Base for Luma (default 0) */
  113. #define TW5864_DSP_REF_PIC_LU 0x000f
  114. /* Ref Buffer Base for Chroma (default 4) */
  115. #define TW5864_DSP_REF_PIC_CHM 0x00f0
  116. /* Maximum Number of Buffers (default 4) */
  117. #define TW5864_DSP_REF_PIC_MAX 0x0700
  118. /* [15:0] SEN_EN_CH[n] SENIF original frame capture enable for each channel */
  119. #define TW5864_SEN_EN_CH 0x0028
  120. #define TW5864_DSP 0x002c
  121. /* Define controls in register TW5864_DSP */
  122. /* The ID for channel selected for encoding operation */
  123. #define TW5864_DSP_ENC_CHN 0x000f
  124. /* See DSP_MB_DELAY below */
  125. #define TW5864_DSP_MB_WAIT 0x0010
  126. /*
  127. * DSP Chroma Switch
  128. * 0 DDRB
  129. * 1 DDRA
  130. */
  131. #define TW5864_DSP_CHROM_SW 0x0020
  132. /* VLC Flow Control: 1 for enable */
  133. #define TW5864_DSP_FLW_CNTL 0x0040
  134. /*
  135. * If DSP_MB_WAIT == 0, MB delay is DSP_MB_DELAY * 16
  136. * If DSP_MB_DELAY == 1, MB delay is DSP_MB_DELAY * 128
  137. */
  138. #define TW5864_DSP_MB_DELAY 0x0f00
  139. #define TW5864_DDR 0x0030
  140. /* Define controls in register TW5864_DDR */
  141. /* DDR Single Access Page Number */
  142. #define TW5864_DDR_PAGE_CNTL 0x00ff
  143. /* DDR-DPR Burst Read Enable */
  144. #define TW5864_DDR_BRST_EN BIT(13)
  145. /*
  146. * DDR A/B Select as HOST access
  147. * 0 Select DDRA
  148. * 1 Select DDRB
  149. */
  150. #define TW5864_DDR_AB_SEL BIT(14)
  151. /*
  152. * DDR Access Mode Select
  153. * 0 Single R/W Access (Host <-> DDR)
  154. * 1 Burst R/W Access (Host <-> DPR)
  155. */
  156. #define TW5864_DDR_MODE BIT(15)
  157. /* The original frame capture pointer. Two bits for each channel */
  158. /* SENIF_ORG_FRM_PTR [15:0] */
  159. #define TW5864_SENIF_ORG_FRM_PTR1 0x0038
  160. /* SENIF_ORG_FRM_PTR [31:16] */
  161. #define TW5864_SENIF_ORG_FRM_PTR2 0x003c
  162. #define TW5864_DSP_SEN_MODE 0x0040
  163. /* Define controls in register TW5864_DSP_SEN_MODE */
  164. #define TW5864_DSP_SEN_MODE_CH0 0x000f
  165. #define TW5864_DSP_SEN_MODE_CH1 0x00f0
  166. /*
  167. * [15:0]: ENC_BUF_PTR_REC[31:16] Two bit for each channel (channel 8 ~ 15).
  168. * Each two bits are the buffer pointer for the last encoded frame of a channel
  169. */
  170. #define TW5864_ENC_BUF_PTR_REC2 0x004c
  171. /* Current MV Flag Status Pointer for Channel n. (Read only) */
  172. /*
  173. * [1:0] CH0_MV_PTR, ..., [15:14] CH7_MV_PTR
  174. */
  175. #define TW5864_CH_MV_PTR1 0x0060
  176. /*
  177. * [1:0] CH8_MV_PTR, ..., [15:14] CH15_MV_PTR
  178. */
  179. #define TW5864_CH_MV_PTR2 0x0064
  180. /*
  181. * [15:0] Reset Current MV Flag Status Pointer for Channel n (one bit each)
  182. */
  183. #define TW5864_RST_MV_PTR 0x0068
  184. #define TW5864_INTERLACING 0x0200
  185. /* Define controls in register TW5864_INTERLACING */
  186. /*
  187. * Inter_Mode Start. 2-nd bit? A guess. Missing in datasheet. Without this bit
  188. * set, the output video is interlaced (stripy).
  189. */
  190. #define TW5864_DSP_INTER_ST BIT(1)
  191. /* Deinterlacer Enable */
  192. #define TW5864_DI_EN BIT(2)
  193. /*
  194. * De-interlacer Mode
  195. * 1 Shuffled frame
  196. * 0 Normal Un-Shuffled Frame
  197. */
  198. #define TW5864_DI_MD BIT(3)
  199. /*
  200. * Down scale original frame in X direction
  201. * 11: Un-used
  202. * 10: down-sample to 1/4
  203. * 01: down-sample to 1/2
  204. * 00: down-sample disabled
  205. */
  206. #define TW5864_DSP_DWN_X (3 << 4)
  207. /*
  208. * Down scale original frame in Y direction
  209. * 11: Un-used
  210. * 10: down-sample to 1/4
  211. * 01: down-sample to 1/2
  212. * 00: down-sample disabled
  213. */
  214. #define TW5864_DSP_DWN_Y (3 << 6)
  215. /*
  216. * 1 Dual Stream
  217. * 0 Single Stream
  218. */
  219. #define TW5864_DUAL_STR BIT(8)
  220. #define TW5864_DSP_REF 0x0204
  221. /* Define controls in register TW5864_DSP_REF */
  222. /* Number of reference frame (Default 1 for TW5864B) */
  223. #define TW5864_DSP_REF_FRM 0x000f
  224. /* Window size */
  225. #define TW5864_DSP_WIN_SIZE 0x02f0
  226. #define TW5864_DSP_SKIP 0x0208
  227. /* Define controls in register TW5864_DSP_SKIP */
  228. /*
  229. * Skip Offset Enable bit
  230. * 0 DSP_SKIP_OFFSET value is not used (default 8)
  231. * 1 DSP_SKIP_OFFSET value is used in HW
  232. */
  233. #define TW5864_DSP_SKIP_OFEN 0x0080
  234. /* Skip mode cost offset (default 8) */
  235. #define TW5864_DSP_SKIP_OFFSET 0x007f
  236. #define TW5864_MOTION_SEARCH_ETC 0x020c
  237. /* Define controls in register TW5864_MOTION_SEARCH_ETC */
  238. /* Enable quarter pel search mode */
  239. #define TW5864_QPEL_EN BIT(0)
  240. /* Enable half pel search mode */
  241. #define TW5864_HPEL_EN BIT(1)
  242. /* Enable motion search mode */
  243. #define TW5864_ME_EN BIT(2)
  244. /* Enable Intra mode */
  245. #define TW5864_INTRA_EN BIT(3)
  246. /* Enable Skip Mode */
  247. #define TW5864_SKIP_EN BIT(4)
  248. /* Search Option (Default 2"b01) */
  249. #define TW5864_SRCH_OPT (3 << 5)
  250. #define TW5864_DSP_ENC_REC 0x0210
  251. /* Define controls in register TW5864_DSP_ENC_REC */
  252. /* Reference Buffer Pointer for encoding */
  253. #define TW5864_DSP_ENC_REF_PTR 0x0007
  254. /* Reconstruct Buffer pointer */
  255. #define TW5864_DSP_REC_BUF_PTR 0x7000
  256. /* [15:0] Lambda Value for H264 */
  257. #define TW5864_DSP_REF_MVP_LAMBDA 0x0214
  258. #define TW5864_DSP_PIC_MAX_MB 0x0218
  259. /* Define controls in register TW5864_DSP_PIC_MAX_MB */
  260. /* The MB number in Y direction for a frame */
  261. #define TW5864_DSP_PIC_MAX_MB_Y 0x007f
  262. /* The MB number in X direction for a frame */
  263. #define TW5864_DSP_PIC_MAX_MB_X 0x7f00
  264. /* The original frame pointer for encoding */
  265. #define TW5864_DSP_ENC_ORG_PTR_REG 0x021c
  266. /* Mask to use with TW5864_DSP_ENC_ORG_PTR */
  267. #define TW5864_DSP_ENC_ORG_PTR_MASK 0x7000
  268. /* Number of bits to shift with TW5864_DSP_ENC_ORG_PTR */
  269. #define TW5864_DSP_ENC_ORG_PTR_SHIFT 12
  270. /* DDR base address of OSD rectangle attribute data */
  271. #define TW5864_DSP_OSD_ATTRI_BASE 0x0220
  272. /* OSD enable bit for each channel */
  273. #define TW5864_DSP_OSD_ENABLE 0x0228
  274. /* 0x0280 ~ 0x029c – Motion Vector for 1st 4x4 Block, e.g., 80 (X), 84 (Y) */
  275. #define TW5864_ME_MV_VEC1 0x0280
  276. /* 0x02a0 ~ 0x02bc – Motion Vector for 2nd 4x4 Block, e.g., A0 (X), A4 (Y) */
  277. #define TW5864_ME_MV_VEC2 0x02a0
  278. /* 0x02c0 ~ 0x02dc – Motion Vector for 3rd 4x4 Block, e.g., C0 (X), C4 (Y) */
  279. #define TW5864_ME_MV_VEC3 0x02c0
  280. /* 0x02e0 ~ 0x02fc – Motion Vector for 4th 4x4 Block, e.g., E0 (X), E4 (Y) */
  281. #define TW5864_ME_MV_VEC4 0x02e0
  282. /*
  283. * [5:0]
  284. * if (intra16x16_cost < (intra4x4_cost+dsp_i4x4_offset))
  285. * Intra_mode = intra16x16_mode
  286. * Else
  287. * Intra_mode = intra4x4_mode
  288. */
  289. #define TW5864_DSP_I4x4_OFFSET 0x040c
  290. /*
  291. * [6:4]
  292. * 0x5 Only 4x4
  293. * 0x6 Only 16x16
  294. * 0x7 16x16 & 4x4
  295. */
  296. #define TW5864_DSP_INTRA_MODE 0x0410
  297. #define TW5864_DSP_INTRA_MODE_SHIFT 4
  298. #define TW5864_DSP_INTRA_MODE_MASK (7 << 4)
  299. #define TW5864_DSP_INTRA_MODE_4x4 0x5
  300. #define TW5864_DSP_INTRA_MODE_16x16 0x6
  301. #define TW5864_DSP_INTRA_MODE_4x4_AND_16x16 0x7
  302. /*
  303. * [5:0] WEIGHT Factor for I4x4 cost calculation (QP dependent)
  304. */
  305. #define TW5864_DSP_I4x4_WEIGHT 0x0414
  306. /*
  307. * [7:0] Offset used to affect Intra/ME model decision
  308. * If (me_cost < intra_cost + dsp_resid_mode_offset)
  309. * Pred_Mode = me_mode
  310. * Else
  311. * Pred_mode = intra_mode
  312. */
  313. #define TW5864_DSP_RESID_MODE_OFFSET 0x0604
  314. /* 0x0800 ~ 0x09ff - Quantization TABLE Values */
  315. #define TW5864_QUAN_TAB 0x0800
  316. /* Valid channel value [0; f], frame value [0; 3] */
  317. #define TW5864_RT_CNTR_CH_FRM(channel, frame) \
  318. (0x0c00 | (channel << 4) | (frame << 2))
  319. #define TW5864_FRAME_BUS1 0x0d00
  320. /*
  321. * 1 Progressive in part A in bus n
  322. * 0 Interlaced in part A in bus n
  323. */
  324. #define TW5864_PROG_A BIT(0)
  325. /*
  326. * 1 Progressive in part B in bus n
  327. * 0 Interlaced in part B in bus n
  328. */
  329. #define TW5864_PROG_B BIT(1)
  330. /*
  331. * 1 Frame Mode in bus n
  332. * 0 Field Mode in bus n
  333. */
  334. #define TW5864_FRAME BIT(2)
  335. /*
  336. * 0 4CIF in bus n
  337. * 1 1D1 + 4 CIF in bus n
  338. * 2 2D1 in bus n
  339. */
  340. #define TW5864_BUS_D1 (3 << 3)
  341. /* Bus 1 goes in TW5864_FRAME_BUS1 in [4:0] */
  342. /* Bus 2 goes in TW5864_FRAME_BUS1 in [12:8] */
  343. #define TW5864_FRAME_BUS2 0x0d04
  344. /* Bus 3 goes in TW5864_FRAME_BUS2 in [4:0] */
  345. /* Bus 4 goes in TW5864_FRAME_BUS2 in [12:8] */
  346. /* [15:0] Horizontal Mirror for channel n */
  347. #define TW5864_SENIF_HOR_MIR 0x0d08
  348. /* [15:0] Vertical Mirror for channel n */
  349. #define TW5864_SENIF_VER_MIR 0x0d0c
  350. /*
  351. * FRAME_WIDTH_BUSn_A
  352. * 0x15f: 4 CIF
  353. * 0x2cf: 1 D1 + 3 CIF
  354. * 0x2cf: 2 D1
  355. * FRAME_WIDTH_BUSn_B
  356. * 0x15f: 4 CIF
  357. * 0x2cf: 1 D1 + 3 CIF
  358. * 0x2cf: 2 D1
  359. * FRAME_HEIGHT_BUSn_A
  360. * 0x11f: 4CIF (PAL)
  361. * 0x23f: 1D1 + 3CIF (PAL)
  362. * 0x23f: 2 D1 (PAL)
  363. * 0x0ef: 4CIF (NTSC)
  364. * 0x1df: 1D1 + 3CIF (NTSC)
  365. * 0x1df: 2 D1 (NTSC)
  366. * FRAME_HEIGHT_BUSn_B
  367. * 0x11f: 4CIF (PAL)
  368. * 0x23f: 1D1 + 3CIF (PAL)
  369. * 0x23f: 2 D1 (PAL)
  370. * 0x0ef: 4CIF (NTSC)
  371. * 0x1df: 1D1 + 3CIF (NTSC)
  372. * 0x1df: 2 D1 (NTSC)
  373. */
  374. #define TW5864_FRAME_WIDTH_BUS_A(bus) (0x0d10 + 0x0010 * bus)
  375. #define TW5864_FRAME_WIDTH_BUS_B(bus) (0x0d14 + 0x0010 * bus)
  376. #define TW5864_FRAME_HEIGHT_BUS_A(bus) (0x0d18 + 0x0010 * bus)
  377. #define TW5864_FRAME_HEIGHT_BUS_B(bus) (0x0d1c + 0x0010 * bus)
  378. /*
  379. * 1: the bus mapped Channel n Full D1
  380. * 0: the bus mapped Channel n Half D1
  381. */
  382. #define TW5864_FULL_HALF_FLAG 0x0d50
  383. /*
  384. * 0 The bus mapped Channel select partA Mode
  385. * 1 The bus mapped Channel select partB Mode
  386. */
  387. #define TW5864_FULL_HALF_MODE_SEL 0x0d54
  388. #define TW5864_VLC 0x1000
  389. /* Define controls in register TW5864_VLC */
  390. /* QP Value used by H264 CAVLC */
  391. #define TW5864_VLC_SLICE_QP 0x003f
  392. /*
  393. * Swap byte order of VLC stream in d-word.
  394. * 1 Normal (VLC output= [31:0])
  395. * 0 Swap (VLC output={[23:16],[31:24],[7:0], [15:8]})
  396. */
  397. #define TW5864_VLC_BYTE_SWP BIT(6)
  398. /* Enable Adding 03 circuit for VLC stream */
  399. #define TW5864_VLC_ADD03_EN BIT(7)
  400. /* Number of bit for VLC bit Align */
  401. #define TW5864_VLC_BIT_ALIGN_SHIFT 8
  402. #define TW5864_VLC_BIT_ALIGN_MASK (0x1f << 8)
  403. /*
  404. * Synchronous Interface select for VLC Stream
  405. * 1 CDC_VLCS_MAS read VLC stream
  406. * 0 CPU read VLC stream
  407. */
  408. #define TW5864_VLC_INF_SEL BIT(13)
  409. /* Enable VLC overflow control */
  410. #define TW5864_VLC_OVFL_CNTL BIT(14)
  411. /*
  412. * 1 PCI Master Mode
  413. * 0 Non PCI Master Mode
  414. */
  415. #define TW5864_VLC_PCI_SEL BIT(15)
  416. /*
  417. * 0 Enable Adding 03 to VLC header and stream
  418. * 1 Disable Adding 03 to VLC header of "00000001"
  419. */
  420. #define TW5864_VLC_A03_DISAB BIT(16)
  421. /*
  422. * Status of VLC stream in DDR (one bit for each buffer)
  423. * 1 VLC is ready in buffer n (HW set)
  424. * 0 VLC is not ready in buffer n (SW clear)
  425. */
  426. #define TW5864_VLC_BUF_RDY_SHIFT 24
  427. #define TW5864_VLC_BUF_RDY_MASK (0xff << 24)
  428. /* Total number of bit in the slice */
  429. #define TW5864_SLICE_TOTAL_BIT 0x1004
  430. /* Total number of bit in the residue */
  431. #define TW5864_RES_TOTAL_BIT 0x1008
  432. #define TW5864_VLC_BUF 0x100c
  433. /* Define controls in register TW5864_VLC_BUF */
  434. /* VLC BK0 full status, write ‘1’ to clear */
  435. #define TW5864_VLC_BK0_FULL BIT(0)
  436. /* VLC BK1 full status, write ‘1’ to clear */
  437. #define TW5864_VLC_BK1_FULL BIT(1)
  438. /* VLC end slice status, write ‘1’ to clear */
  439. #define TW5864_VLC_END_SLICE BIT(2)
  440. /* VLC Buffer overflow status, write ‘1’ to clear */
  441. #define TW5864_DSP_RD_OF BIT(3)
  442. /* VLC string length in either buffer 0 or 1 at end of frame */
  443. #define TW5864_VLC_STREAM_LEN_SHIFT 4
  444. #define TW5864_VLC_STREAM_LEN_MASK (0x1ff << 4)
  445. /* [15:0] Total coefficient number in a frame */
  446. #define TW5864_TOTAL_COEF_NO 0x1010
  447. /* [0] VLC Encoder Interrupt. Write ‘1’ to clear */
  448. #define TW5864_VLC_DSP_INTR 0x1014
  449. /* [31:0] VLC stream CRC checksum */
  450. #define TW5864_VLC_STREAM_CRC 0x1018
  451. #define TW5864_VLC_RD 0x101c
  452. /* Define controls in register TW5864_VLC_RD */
  453. /*
  454. * 1 Read VLC lookup Memory
  455. * 0 Read VLC Stream Memory
  456. */
  457. #define TW5864_VLC_RD_MEM BIT(0)
  458. /*
  459. * 1 Read VLC Stream Memory in burst mode
  460. * 0 Read VLC Stream Memory in single mode
  461. */
  462. #define TW5864_VLC_RD_BRST BIT(1)
  463. /* 0x2000 ~ 0x2ffc -- H264 Stream Memory Map */
  464. /*
  465. * A word is 4 bytes. I.e.,
  466. * VLC_STREAM_MEM[0] address: 0x2000
  467. * VLC_STREAM_MEM[1] address: 0x2004
  468. * ...
  469. * VLC_STREAM_MEM[3FF] address: 0x2ffc
  470. */
  471. #define TW5864_VLC_STREAM_MEM_START 0x2000
  472. #define TW5864_VLC_STREAM_MEM_MAX_OFFSET 0x3ff
  473. #define TW5864_VLC_STREAM_MEM(offset) (TW5864_VLC_STREAM_MEM_START + 4 * offset)
  474. /* 0x4000 ~ 0x4ffc -- Audio Register Map */
  475. /* [31:0] config 1ms cnt = Realtime clk/1000 */
  476. #define TW5864_CFG_1MS_CNT 0x4000
  477. #define TW5864_ADPCM 0x4004
  478. /* Define controls in register TW5864_ADPCM */
  479. /* ADPCM decoder enable */
  480. #define TW5864_ADPCM_DEC BIT(0)
  481. /* ADPCM input data enable */
  482. #define TW5864_ADPCM_IN_DATA BIT(1)
  483. /* ADPCM encoder enable */
  484. #define TW5864_ADPCM_ENC BIT(2)
  485. #define TW5864_AUD 0x4008
  486. /* Define controls in register TW5864_AUD */
  487. /* Record path PCM Audio enable bit for each channel */
  488. #define TW5864_AUD_ORG_CH_EN 0x00ff
  489. /* Speaker path PCM Audio Enable */
  490. #define TW5864_SPK_ORG_EN BIT(16)
  491. /*
  492. * 0 16bit
  493. * 1 8bit
  494. */
  495. #define TW5864_AD_BIT_MODE BIT(17)
  496. #define TW5864_AUD_TYPE_SHIFT 18
  497. /*
  498. * 0 PCM
  499. * 3 ADPCM
  500. */
  501. #define TW5864_AUD_TYPE (0xf << 18)
  502. #define TW5864_AUD_SAMPLE_RATE_SHIFT 22
  503. /*
  504. * 0 8K
  505. * 1 16K
  506. */
  507. #define TW5864_AUD_SAMPLE_RATE (3 << 22)
  508. /* Channel ID used to select audio channel (0 to 16) for loopback */
  509. #define TW5864_TESTLOOP_CHID_SHIFT 24
  510. #define TW5864_TESTLOOP_CHID (0x1f << 24)
  511. /* Enable AD Loopback Test */
  512. #define TW5864_TEST_ADLOOP_EN BIT(30)
  513. /*
  514. * 0 Asynchronous Mode or PCI target mode
  515. * 1 PCI Initiator Mode
  516. */
  517. #define TW5864_AUD_MODE BIT(31)
  518. #define TW5864_AUD_ADPCM 0x400c
  519. /* Define controls in register TW5864_AUD_ADPCM */
  520. /* Record path ADPCM audio channel enable, one bit for each */
  521. #define TW5864_AUD_ADPCM_CH_EN 0x00ff
  522. /* Speaker path ADPCM audio channel enable */
  523. #define TW5864_SPK_ADPCM_EN BIT(16)
  524. #define TW5864_PC_BLOCK_ADPCM_RD_NO 0x4018
  525. #define TW5864_PC_BLOCK_ADPCM_RD_NO_MASK 0x1f
  526. /*
  527. * For ADPCM_ENC_WR_PTR, ADPCM_ENC_RD_PTR (see below):
  528. * Bit[2:0] ch0
  529. * Bit[5:3] ch1
  530. * Bit[8:6] ch2
  531. * Bit[11:9] ch3
  532. * Bit[14:12] ch4
  533. * Bit[17:15] ch5
  534. * Bit[20:18] ch6
  535. * Bit[23:21] ch7
  536. * Bit[26:24] ch8
  537. * Bit[29:27] ch9
  538. * Bit[32:30] ch10
  539. * Bit[35:33] ch11
  540. * Bit[38:36] ch12
  541. * Bit[41:39] ch13
  542. * Bit[44:42] ch14
  543. * Bit[47:45] ch15
  544. * Bit[50:48] ch16
  545. */
  546. #define TW5864_ADPCM_ENC_XX_MASK 0x3fff
  547. #define TW5864_ADPCM_ENC_XX_PTR2_SHIFT 30
  548. /* ADPCM_ENC_WR_PTR[29:0] */
  549. #define TW5864_ADPCM_ENC_WR_PTR1 0x401c
  550. /* ADPCM_ENC_WR_PTR[50:30] */
  551. #define TW5864_ADPCM_ENC_WR_PTR2 0x4020
  552. /* ADPCM_ENC_RD_PTR[29:0] */
  553. #define TW5864_ADPCM_ENC_RD_PTR1 0x4024
  554. /* ADPCM_ENC_RD_PTR[50:30] */
  555. #define TW5864_ADPCM_ENC_RD_PTR2 0x4028
  556. /* [3:0] rd ch0, [7:4] rd ch1, [11:8] wr ch0, [15:12] wr ch1 */
  557. #define TW5864_ADPCM_DEC_RD_WR_PTR 0x402c
  558. /*
  559. * For TW5864_AD_ORIG_WR_PTR, TW5864_AD_ORIG_RD_PTR:
  560. * Bit[3:0] ch0
  561. * Bit[7:4] ch1
  562. * Bit[11:8] ch2
  563. * Bit[15:12] ch3
  564. * Bit[19:16] ch4
  565. * Bit[23:20] ch5
  566. * Bit[27:24] ch6
  567. * Bit[31:28] ch7
  568. * Bit[35:32] ch8
  569. * Bit[39:36] ch9
  570. * Bit[43:40] ch10
  571. * Bit[47:44] ch11
  572. * Bit[51:48] ch12
  573. * Bit[55:52] ch13
  574. * Bit[59:56] ch14
  575. * Bit[63:60] ch15
  576. * Bit[67:64] ch16
  577. */
  578. /* AD_ORIG_WR_PTR[31:0] */
  579. #define TW5864_AD_ORIG_WR_PTR1 0x4030
  580. /* AD_ORIG_WR_PTR[63:32] */
  581. #define TW5864_AD_ORIG_WR_PTR2 0x4034
  582. /* AD_ORIG_WR_PTR[67:64] */
  583. #define TW5864_AD_ORIG_WR_PTR3 0x4038
  584. /* AD_ORIG_RD_PTR[31:0] */
  585. #define TW5864_AD_ORIG_RD_PTR1 0x403c
  586. /* AD_ORIG_RD_PTR[63:32] */
  587. #define TW5864_AD_ORIG_RD_PTR2 0x4040
  588. /* AD_ORIG_RD_PTR[67:64] */
  589. #define TW5864_AD_ORIG_RD_PTR3 0x4044
  590. #define TW5864_PC_BLOCK_ORIG_RD_NO 0x4048
  591. #define TW5864_PC_BLOCK_ORIG_RD_NO_MASK 0x1f
  592. #define TW5864_PCI_AUD 0x404c
  593. /* Define controls in register TW5864_PCI_AUD */
  594. /*
  595. * The register is applicable to PCI initiator mode only. Used to select PCM(0)
  596. * or ADPCM(1) audio data sent to PC. One bit for each channel
  597. */
  598. #define TW5864_PCI_DATA_SEL 0xffff
  599. /*
  600. * Audio flow control mode selection bit.
  601. * 0 Flow control disabled. TW5864 continuously sends audio frame to PC
  602. * (initiator mode)
  603. * 1 Flow control enabled
  604. */
  605. #define TW5864_PCI_FLOW_EN BIT(16)
  606. /*
  607. * When PCI_FLOW_EN is set, PCI need to toggle this bit to send an audio frame
  608. * to PC. One toggle to send one frame.
  609. */
  610. #define TW5864_PCI_AUD_FRM_EN BIT(17)
  611. /* [1:0] CS valid to data valid CLK cycles when writing operation */
  612. #define TW5864_CS2DAT_CNT 0x8000
  613. /* [2:0] Data valid signal width by system clock cycles */
  614. #define TW5864_DATA_VLD_WIDTH 0x8004
  615. #define TW5864_SYNC 0x8008
  616. /* Define controls in register TW5864_SYNC */
  617. /*
  618. * 0 vlc stream to syncrous port
  619. * 1 vlc stream to ddr buffers
  620. */
  621. #define TW5864_SYNC_CFG BIT(7)
  622. /*
  623. * 0 SYNC Address sampled on Rising edge
  624. * 1 SYNC Address sampled on Falling edge
  625. */
  626. #define TW5864_SYNC_ADR_EDGE BIT(0)
  627. #define TW5864_VLC_STR_DELAY_SHIFT 1
  628. /*
  629. * 0 No system delay
  630. * 1 One system clock delay
  631. * 2 Two system clock delay
  632. * 3 Three system clock delay
  633. */
  634. #define TW5864_VLC_STR_DELAY (3 << 1)
  635. /*
  636. * 0 Rising edge output
  637. * 1 Falling edge output
  638. */
  639. #define TW5864_VLC_OUT_EDGE BIT(3)
  640. /*
  641. * [1:0]
  642. * 2’b00 phase set to 180 degree
  643. * 2’b01 phase set to 270 degree
  644. * 2’b10 phase set to 0 degree
  645. * 2’b11 phase set to 90 degree
  646. */
  647. #define TW5864_I2C_PHASE_CFG 0x800c
  648. /*
  649. * The system / DDR clock (166 MHz) is generated with an on-chip system clock
  650. * PLL (SYSPLL) using input crystal clock of 27 MHz. The system clock PLL
  651. * frequency is controlled with the following equation.
  652. * CLK_OUT = CLK_IN * (M+1) / ((N+1) * P)
  653. * SYSPLL_M M parameter
  654. * SYSPLL_N N parameter
  655. * SYSPLL_P P parameter
  656. */
  657. /* SYSPLL_M[7:0] */
  658. #define TW5864_SYSPLL1 0x8018
  659. /* Define controls in register TW5864_SYSPLL1 */
  660. #define TW5864_SYSPLL_M_LOW 0x00ff
  661. /* [2:0]: SYSPLL_M[10:8], [7:3]: SYSPLL_N[4:0] */
  662. #define TW5864_SYSPLL2 0x8019
  663. /* Define controls in register TW5864_SYSPLL2 */
  664. #define TW5864_SYSPLL_M_HI 0x07
  665. #define TW5864_SYSPLL_N_LOW_SHIFT 3
  666. #define TW5864_SYSPLL_N_LOW (0x1f << 3)
  667. /*
  668. * [1:0]: SYSPLL_N[6:5], [3:2]: SYSPLL_P, [4]: SYSPLL_IREF, [7:5]: SYSPLL_CP_SEL
  669. */
  670. #define TW5864_SYSPLL3 0x8020
  671. /* Define controls in register TW5864_SYSPLL3 */
  672. #define TW5864_SYSPLL_N_HI 0x03
  673. #define TW5864_SYSPLL_P_SHIFT 2
  674. #define TW5864_SYSPLL_P (0x03 << 2)
  675. /*
  676. * SYSPLL bias current control
  677. * 0 Lower current (default)
  678. * 1 30% higher current
  679. */
  680. #define TW5864_SYSPLL_IREF BIT(4)
  681. /*
  682. * SYSPLL charge pump current selection
  683. * 0 1,5 uA
  684. * 1 4 uA
  685. * 2 9 uA
  686. * 3 19 uA
  687. * 4 39 uA
  688. * 5 79 uA
  689. * 6 159 uA
  690. * 7 319 uA
  691. */
  692. #define TW5864_SYSPLL_CP_SEL_SHIFT 5
  693. #define TW5864_SYSPLL_CP_SEL (0x07 << 5)
  694. /*
  695. * [1:0]: SYSPLL_VCO, [3:2]: SYSPLL_LP_X8, [5:4]: SYSPLL_ICP_SEL,
  696. * [6]: SYSPLL_LPF_5PF, [7]: SYSPLL_ED_SEL
  697. */
  698. #define TW5864_SYSPLL4 0x8021
  699. /* Define controls in register TW5864_SYSPLL4 */
  700. /*
  701. * SYSPLL_VCO VCO Range selection
  702. * 00 5 ~ 75 MHz
  703. * 01 50 ~ 140 MHz
  704. * 10 110 ~ 320 MHz
  705. * 11 270 ~ 700 MHz
  706. */
  707. #define TW5864_SYSPLL_VCO 0x03
  708. #define TW5864_SYSPLL_LP_X8_SHIFT 2
  709. /*
  710. * Loop resister
  711. * 0 38.5K ohms
  712. * 1 6.6K ohms (default)
  713. * 2 2.2K ohms
  714. * 3 1.1K ohms
  715. */
  716. #define TW5864_SYSPLL_LP_X8 (0x03 << 2)
  717. #define TW5864_SYSPLL_ICP_SEL_SHIFT 4
  718. /*
  719. * PLL charge pump fine tune
  720. * 00 x1 (default)
  721. * 01 x1/2
  722. * 10 x1/7
  723. * 11 x1/8
  724. */
  725. #define TW5864_SYSPLL_ICP_SEL (0x03 << 4)
  726. /*
  727. * PLL low pass filter phase margin adjustment
  728. * 0 no 5pF (default)
  729. * 1 5pF added
  730. */
  731. #define TW5864_SYSPLL_LPF_5PF BIT(6)
  732. /*
  733. * PFD select edge for detection
  734. * 0 Falling edge (default)
  735. * 1 Rising edge
  736. */
  737. #define TW5864_SYSPLL_ED_SEL BIT(7)
  738. /* [0]: SYSPLL_RST, [4]: SYSPLL_PD */
  739. #define TW5864_SYSPLL5 0x8024
  740. /* Define controls in register TW5864_SYSPLL5 */
  741. /* Reset SYSPLL */
  742. #define TW5864_SYSPLL_RST BIT(0)
  743. /* Power down SYSPLL */
  744. #define TW5864_SYSPLL_PD BIT(4)
  745. #define TW5864_PLL_CFG 0x801c
  746. /* Define controls in register TW5864_PLL_CFG */
  747. /*
  748. * Issue Soft Reset from Async Host Interface / PCI Interface clock domain.
  749. * Become valid after sync to the xtal clock domain. This bit is set only if
  750. * LOAD register bit is also set to 1.
  751. */
  752. #define TW5864_SRST BIT(0)
  753. /*
  754. * Issue SYSPLL (166 MHz) configuration latch from Async host interface / PCI
  755. * Interface clock domain. The configuration setting becomes effective only if
  756. * LOAD register bit is also set to 1.
  757. */
  758. #define TW5864_SYSPLL_CFG BIT(2)
  759. /*
  760. * Issue SPLL (108 MHz) configuration load from Async host interface / PCI
  761. * Interface clock domain. The configuration setting becomes effective only if
  762. * the LOAD register bit is also set to 1.
  763. */
  764. #define TW5864_SPLL_CFG BIT(4)
  765. /*
  766. * Set this bit to latch the SRST, SYSPLL_CFG, SPLL_CFG setting into the xtal
  767. * clock domain to restart the PLL. This bit is self cleared.
  768. */
  769. #define TW5864_LOAD BIT(3)
  770. /* SPLL_IREF, SPLL_LPX4, SPLL_CPX4, SPLL_PD, SPLL_DBG */
  771. #define TW5864_SPLL 0x8028
  772. /* 0x8800 ~ 0x88fc -- Interrupt Register Map */
  773. /*
  774. * Trigger mode of interrupt source 0 ~ 15
  775. * 1 Edge trigger mode
  776. * 0 Level trigger mode
  777. */
  778. #define TW5864_TRIGGER_MODE_L 0x8800
  779. /* Trigger mode of interrupt source 16 ~ 31 */
  780. #define TW5864_TRIGGER_MODE_H 0x8804
  781. /* Enable of interrupt source 0 ~ 15 */
  782. #define TW5864_INTR_ENABLE_L 0x8808
  783. /* Enable of interrupt source 16 ~ 31 */
  784. #define TW5864_INTR_ENABLE_H 0x880c
  785. /* Clear interrupt command of interrupt source 0 ~ 15 */
  786. #define TW5864_INTR_CLR_L 0x8810
  787. /* Clear interrupt command of interrupt source 16 ~ 31 */
  788. #define TW5864_INTR_CLR_H 0x8814
  789. /*
  790. * Assertion of interrupt source 0 ~ 15
  791. * 1 High level or pos-edge is assertion
  792. * 0 Low level or neg-edge is assertion
  793. */
  794. #define TW5864_INTR_ASSERT_L 0x8818
  795. /* Assertion of interrupt source 16 ~ 31 */
  796. #define TW5864_INTR_ASSERT_H 0x881c
  797. /*
  798. * Output level of interrupt
  799. * 1 Interrupt output is high assertion
  800. * 0 Interrupt output is low assertion
  801. */
  802. #define TW5864_INTR_OUT_LEVEL 0x8820
  803. /*
  804. * Status of interrupt source 0 ~ 15
  805. * Bit[0]: VLC 4k RAM interrupt
  806. * Bit[1]: BURST DDR RAM interrupt
  807. * Bit[2]: MV DSP interrupt
  808. * Bit[3]: video lost interrupt
  809. * Bit[4]: gpio 0 interrupt
  810. * Bit[5]: gpio 1 interrupt
  811. * Bit[6]: gpio 2 interrupt
  812. * Bit[7]: gpio 3 interrupt
  813. * Bit[8]: gpio 4 interrupt
  814. * Bit[9]: gpio 5 interrupt
  815. * Bit[10]: gpio 6 interrupt
  816. * Bit[11]: gpio 7 interrupt
  817. * Bit[12]: JPEG interrupt
  818. * Bit[13:15]: Reserved
  819. */
  820. #define TW5864_INTR_STATUS_L 0x8838
  821. /*
  822. * Status of interrupt source 16 ~ 31
  823. * Bit[0]: Reserved
  824. * Bit[1]: VLC done interrupt
  825. * Bit[2]: Reserved
  826. * Bit[3]: AD Vsync interrupt
  827. * Bit[4]: Preview eof interrupt
  828. * Bit[5]: Preview overflow interrupt
  829. * Bit[6]: Timer interrupt
  830. * Bit[7]: Reserved
  831. * Bit[8]: Audio eof interrupt
  832. * Bit[9]: I2C done interrupt
  833. * Bit[10]: AD interrupt
  834. * Bit[11:15]: Reserved
  835. */
  836. #define TW5864_INTR_STATUS_H 0x883c
  837. /* Defines of interrupt bits, united for both low and high word registers */
  838. #define TW5864_INTR_VLC_RAM BIT(0)
  839. #define TW5864_INTR_BURST BIT(1)
  840. #define TW5864_INTR_MV_DSP BIT(2)
  841. #define TW5864_INTR_VIN_LOST BIT(3)
  842. /* n belongs to [0; 7] */
  843. #define TW5864_INTR_GPIO(n) (1 << (4 + n))
  844. #define TW5864_INTR_JPEG BIT(12)
  845. #define TW5864_INTR_VLC_DONE BIT(17)
  846. #define TW5864_INTR_AD_VSYNC BIT(19)
  847. #define TW5864_INTR_PV_EOF BIT(20)
  848. #define TW5864_INTR_PV_OVERFLOW BIT(21)
  849. #define TW5864_INTR_TIMER BIT(22)
  850. #define TW5864_INTR_AUD_EOF BIT(24)
  851. #define TW5864_INTR_I2C_DONE BIT(25)
  852. #define TW5864_INTR_AD BIT(26)
  853. /* 0x9000 ~ 0x920c -- Video Capture (VIF) Register Map */
  854. /*
  855. * H264EN_CH_STATUS[n] Status of Vsync synchronized H264EN_CH_EN (Read Only)
  856. * 1 Channel Enabled
  857. * 0 Channel Disabled
  858. */
  859. #define TW5864_H264EN_CH_STATUS 0x9000
  860. /*
  861. * [15:0] H264EN_CH_EN[n] H264 Encoding Path Enable for channel
  862. * 1 Channel Enabled
  863. * 0 Channel Disabled
  864. */
  865. #define TW5864_H264EN_CH_EN 0x9004
  866. /*
  867. * H264EN_CH_DNS[n] H264 Encoding Path Downscale Video Decoder Input for
  868. * channel n
  869. * 1 Downscale Y to 1/2
  870. * 0 Does not downscale
  871. */
  872. #define TW5864_H264EN_CH_DNS 0x9008
  873. /*
  874. * H264EN_CH_PROG[n] H264 Encoding Path channel n is progressive
  875. * 1 Progressive (Not valid for TW5864)
  876. * 0 Interlaced (TW5864 default)
  877. */
  878. #define TW5864_H264EN_CH_PROG 0x900c
  879. /*
  880. * [3:0] H264EN_BUS_MAX_CH[n]
  881. * H264 Encoding Path maximum number of channel on BUS n
  882. * 0 Max 4 channels
  883. * 1 Max 2 channels
  884. */
  885. #define TW5864_H264EN_BUS_MAX_CH 0x9010
  886. /*
  887. * H264EN_RATE_MAX_LINE_n H264 Encoding path Rate Mapping Maximum Line Number
  888. * on Bus n
  889. */
  890. #define TW5864_H264EN_RATE_MAX_LINE_EVEN 0x1f
  891. #define TW5864_H264EN_RATE_MAX_LINE_ODD_SHIFT 5
  892. #define TW5864_H264EN_RATE_MAX_LINE_ODD (0x1f << 5)
  893. /*
  894. * [4:0] H264EN_RATE_MAX_LINE_0
  895. * [9:5] H264EN_RATE_MAX_LINE_1
  896. */
  897. #define TW5864_H264EN_RATE_MAX_LINE_REG1 0x9014
  898. /*
  899. * [4:0] H264EN_RATE_MAX_LINE_2
  900. * [9:5] H264EN_RATE_MAX_LINE_3
  901. */
  902. #define TW5864_H264EN_RATE_MAX_LINE_REG2 0x9018
  903. /*
  904. * H264EN_CHn_FMT H264 Encoding Path Format configuration of Channel n
  905. * 00 D1 (For D1 and hD1 frame)
  906. * 01 (Reserved)
  907. * 10 (Reserved)
  908. * 11 D1 with 1/2 size in X (for CIF frame)
  909. * Note: To be used with 0x9008 register to configure the frame size
  910. */
  911. /*
  912. * [1:0]: H264EN_CH0_FMT,
  913. * ..., [15:14]: H264EN_CH7_FMT
  914. */
  915. #define TW5864_H264EN_CH_FMT_REG1 0x9020
  916. /*
  917. * [1:0]: H264EN_CH8_FMT (?),
  918. * ..., [15:14]: H264EN_CH15_FMT (?)
  919. */
  920. #define TW5864_H264EN_CH_FMT_REG2 0x9024
  921. /*
  922. * H264EN_RATE_CNTL_BUSm_CHn H264 Encoding Path BUS m Rate Control for Channel n
  923. */
  924. #define TW5864_H264EN_RATE_CNTL_LO_WORD(bus, channel) \
  925. (0x9100 + bus * 0x20 + channel * 0x08)
  926. #define TW5864_H264EN_RATE_CNTL_HI_WORD(bus, channel) \
  927. (0x9104 + bus * 0x20 + channel * 0x08)
  928. /*
  929. * H264EN_BUSm_MAP_CHn The 16-to-1 MUX configuration register for each encoding
  930. * channel (total of 16 channels). Four bits for each channel.
  931. */
  932. #define TW5864_H264EN_BUS0_MAP 0x9200
  933. #define TW5864_H264EN_BUS1_MAP 0x9204
  934. #define TW5864_H264EN_BUS2_MAP 0x9208
  935. #define TW5864_H264EN_BUS3_MAP 0x920c
  936. /* This register is not defined in datasheet, but used in reference driver */
  937. #define TW5864_UNDECLARED_ERROR_FLAGS_0x9218 0x9218
  938. #define TW5864_GPIO1 0x9800
  939. #define TW5864_GPIO2 0x9804
  940. /* Define controls in registers TW5864_GPIO1, TW5864_GPIO2 */
  941. /* GPIO DATA of Group n */
  942. #define TW5864_GPIO_DATA 0x00ff
  943. #define TW5864_GPIO_OEN_SHIFT 8
  944. /* GPIO Output Enable of Group n */
  945. #define TW5864_GPIO_OEN (0xff << 8)
  946. /* 0xa000 ~ 0xa8ff – DDR Controller Register Map */
  947. /* DDR Controller A */
  948. /*
  949. * [2:0] Data valid counter after read command to DDR. This is the delay value
  950. * to show how many cycles the data will be back from DDR after we issue a read
  951. * command.
  952. */
  953. #define TW5864_RD_ACK_VLD_MUX 0xa000
  954. #define TW5864_DDR_PERIODS 0xa004
  955. /* Define controls in register TW5864_DDR_PERIODS */
  956. /*
  957. * Tras value, the minimum cycle of active to precharge command period,
  958. * default is 7
  959. */
  960. #define TW5864_TRAS_CNT_MAX 0x000f
  961. /*
  962. * Trfc value, the minimum cycle of refresh to active or refresh command period,
  963. * default is 4"hf
  964. */
  965. #define TW5864_RFC_CNT_MAX_SHIFT 8
  966. #define TW5864_RFC_CNT_MAX (0x0f << 8)
  967. /*
  968. * Trcd value, the minimum cycle of active to internal read/write command
  969. * period, default is 4"h2
  970. */
  971. #define TW5864_TCD_CNT_MAX_SHIFT 4
  972. #define TW5864_TCD_CNT_MAX (0x0f << 4)
  973. /* Twr value, write recovery time, default is 4"h3 */
  974. #define TW5864_TWR_CNT_MAX_SHIFT 12
  975. #define TW5864_TWR_CNT_MAX (0x0f << 12)
  976. /*
  977. * [2:0] CAS latency, the delay cycle between internal read command and the
  978. * availability of the first bit of output data, default is 3
  979. */
  980. #define TW5864_CAS_LATENCY 0xa008
  981. /*
  982. * [15:0] Maximum average periodic refresh, the value is based on the current
  983. * frequency to match 7.8mcs
  984. */
  985. #define TW5864_DDR_REF_CNTR_MAX 0xa00c
  986. /*
  987. * DDR_ON_CHIP_MAP [1:0]
  988. * 0 256M DDR on board
  989. * 1 512M DDR on board
  990. * 2 1G DDR on board
  991. * DDR_ON_CHIP_MAP [2]
  992. * 0 Only one DDR chip
  993. * 1 Two DDR chips
  994. */
  995. #define TW5864_DDR_ON_CHIP_MAP 0xa01c
  996. #define TW5864_DDR_SELFTEST_MODE 0xa020
  997. /* Define controls in register TW5864_DDR_SELFTEST_MODE */
  998. /*
  999. * 0 Common read/write mode
  1000. * 1 DDR self-test mode
  1001. */
  1002. #define TW5864_MASTER_MODE BIT(0)
  1003. /*
  1004. * 0 DDR self-test single read/write
  1005. * 1 DDR self-test burst read/write
  1006. */
  1007. #define TW5864_SINGLE_PROC BIT(1)
  1008. /*
  1009. * 0 DDR self-test write command
  1010. * 1 DDR self-test read command
  1011. */
  1012. #define TW5864_WRITE_FLAG BIT(2)
  1013. #define TW5864_DATA_MODE_SHIFT 4
  1014. /*
  1015. * 0 write 32'haaaa5555 to DDR
  1016. * 1 write 32'hffffffff to DDR
  1017. * 2 write 32'hha5a55a5a to DDR
  1018. * 3 write increasing data to DDR
  1019. */
  1020. #define TW5864_DATA_MODE (0x3 << 4)
  1021. /* [7:0] The maximum data of one burst in DDR self-test mode */
  1022. #define TW5864_BURST_CNTR_MAX 0xa024
  1023. /* [15:0] The maximum burst counter (bit 15~0) in DDR self-test mode */
  1024. #define TW5864_DDR_PROC_CNTR_MAX_L 0xa028
  1025. /* The maximum burst counter (bit 31~16) in DDR self-test mode */
  1026. #define TW5864_DDR_PROC_CNTR_MAX_H 0xa02c
  1027. /* [0]: Start one DDR self-test */
  1028. #define TW5864_DDR_SELF_TEST_CMD 0xa030
  1029. /* The maximum error counter (bit 15 ~ 0) in DDR self-test */
  1030. #define TW5864_ERR_CNTR_L 0xa034
  1031. #define TW5864_ERR_CNTR_H_AND_FLAG 0xa038
  1032. /* Define controls in register TW5864_ERR_CNTR_H_AND_FLAG */
  1033. /* The maximum error counter (bit 30 ~ 16) in DDR self-test */
  1034. #define TW5864_ERR_CNTR_H_MASK 0x3fff
  1035. /* DDR self-test end flag */
  1036. #define TW5864_END_FLAG 0x8000
  1037. /*
  1038. * DDR Controller B: same as 0xa000 ~ 0xa038, but add TW5864_DDR_B_OFFSET to all
  1039. * addresses
  1040. */
  1041. #define TW5864_DDR_B_OFFSET 0x0800
  1042. /* 0xb004 ~ 0xb018 – HW version/ARB12 Register Map */
  1043. /* [15:0] Default is C013 */
  1044. #define TW5864_HW_VERSION 0xb004
  1045. #define TW5864_REQS_ENABLE 0xb010
  1046. /* Define controls in register TW5864_REQS_ENABLE */
  1047. /* Audio data in to DDR enable (default 1) */
  1048. #define TW5864_AUD_DATA_IN_ENB BIT(0)
  1049. /* Audio encode request to DDR enable (default 1) */
  1050. #define TW5864_AUD_ENC_REQ_ENB BIT(1)
  1051. /* Audio decode request0 to DDR enable (default 1) */
  1052. #define TW5864_AUD_DEC_REQ0_ENB BIT(2)
  1053. /* Audio decode request1 to DDR enable (default 1) */
  1054. #define TW5864_AUD_DEC_REQ1_ENB BIT(3)
  1055. /* VLC stream request to DDR enable (default 1) */
  1056. #define TW5864_VLC_STRM_REQ_ENB BIT(4)
  1057. /* H264 MV request to DDR enable (default 1) */
  1058. #define TW5864_DVM_MV_REQ_ENB BIT(5)
  1059. /* mux_core MVD request to DDR enable (default 1) */
  1060. #define TW5864_MVD_REQ_ENB BIT(6)
  1061. /* mux_core MVD temp data request to DDR enable (default 1) */
  1062. #define TW5864_MVD_TMP_REQ_ENB BIT(7)
  1063. /* JPEG request to DDR enable (default 1) */
  1064. #define TW5864_JPEG_REQ_ENB BIT(8)
  1065. /* mv_flag request to DDR enable (default 1) */
  1066. #define TW5864_MV_FLAG_REQ_ENB BIT(9)
  1067. #define TW5864_ARB12 0xb018
  1068. /* Define controls in register TW5864_ARB12 */
  1069. /* ARB12 Enable (default 1) */
  1070. #define TW5864_ARB12_ENB BIT(15)
  1071. /* ARB12 maximum value of time out counter (default 15"h1FF) */
  1072. #define TW5864_ARB12_TIME_OUT_CNT 0x7fff
  1073. /* 0xb800 ~ 0xb80c -- Indirect Access Register Map */
  1074. /*
  1075. * Spec says:
  1076. * In order to access the indirect register space, the following procedure is
  1077. * followed.
  1078. * But reference driver implementation, and current driver, too, does it
  1079. * differently.
  1080. *
  1081. * Write Registers:
  1082. * (1) Write IND_DATA at 0xb804 ~ 0xb807
  1083. * (2) Read BUSY flag from 0xb803. Wait until BUSY signal is 0.
  1084. * (3) Write IND_ADDR at 0xb800 ~ 0xb801. Set R/W to "1", ENABLE to "1"
  1085. * Read Registers:
  1086. * (1) Read BUSY flag from 0xb803. Wait until BUSY signal is 0.
  1087. * (2) Write IND_ADDR at 0xb800 ~ 0xb801. Set R/W to "0", ENABLE to "1"
  1088. * (3) Read BUSY flag from 0xb803. Wait until BUSY signal is 0.
  1089. * (4) Read IND_DATA from 0xb804 ~ 0xb807
  1090. */
  1091. #define TW5864_IND_CTL 0xb800
  1092. /* Define controls in register TW5864_IND_CTL */
  1093. /* Address used to access indirect register space */
  1094. #define TW5864_IND_ADDR 0x0000ffff
  1095. /* Wait until this bit is "0" before using indirect access */
  1096. #define TW5864_BUSY BIT(31)
  1097. /* Activate the indirect access. This bit is self cleared */
  1098. #define TW5864_ENABLE BIT(25)
  1099. /* Read/Write command */
  1100. #define TW5864_RW BIT(24)
  1101. /* [31:0] Data used to read/write indirect register space */
  1102. #define TW5864_IND_DATA 0xb804
  1103. /* 0xc000 ~ 0xc7fc -- Preview Register Map */
  1104. /* Mostly skipped this section. */
  1105. /*
  1106. * [15:0] Status of Vsync Synchronized PCI_PV_CH_EN (Read Only)
  1107. * 1 Channel Enabled
  1108. * 0 Channel Disabled
  1109. */
  1110. #define TW5864_PCI_PV_CH_STATUS 0xc000
  1111. /*
  1112. * [15:0] PCI Preview Path Enable for channel n
  1113. * 1 Channel Enable
  1114. * 0 Channel Disable
  1115. */
  1116. #define TW5864_PCI_PV_CH_EN 0xc004
  1117. /* 0xc800 ~ 0xc804 -- JPEG Capture Register Map */
  1118. /* Skipped. */
  1119. /* 0xd000 ~ 0xd0fc -- JPEG Control Register Map */
  1120. /* Skipped. */
  1121. /* 0xe000 ~ 0xfc04 – Motion Vector Register Map */
  1122. /* ME Motion Vector data (Four Byte Each) 0xe000 ~ 0xe7fc */
  1123. #define TW5864_ME_MV_VEC_START 0xe000
  1124. #define TW5864_ME_MV_VEC_MAX_OFFSET 0x1ff
  1125. #define TW5864_ME_MV_VEC(offset) (TW5864_ME_MV_VEC_START + 4 * offset)
  1126. #define TW5864_MV 0xfc00
  1127. /* Define controls in register TW5864_MV */
  1128. /* mv bank0 full status , write "1" to clear */
  1129. #define TW5864_MV_BK0_FULL BIT(0)
  1130. /* mv bank1 full status , write "1" to clear */
  1131. #define TW5864_MV_BK1_FULL BIT(1)
  1132. /* slice end status; write "1" to clear */
  1133. #define TW5864_MV_EOF BIT(2)
  1134. /* mv encode interrupt status; write "1" to clear */
  1135. #define TW5864_MV_DSP_INTR BIT(3)
  1136. /* mv write memory overflow, write "1" to clear */
  1137. #define TW5864_DSP_WR_OF BIT(4)
  1138. #define TW5864_MV_LEN_SHIFT 5
  1139. /* mv stream length */
  1140. #define TW5864_MV_LEN (0xff << 5)
  1141. /* The configured status bit written into bit 15 of 0xfc04 */
  1142. #define TW5864_MPI_DDR_SEL BIT(13)
  1143. #define TW5864_MPI_DDR_SEL_REG 0xfc04
  1144. /* Define controls in register TW5864_MPI_DDR_SEL_REG */
  1145. /*
  1146. * SW configure register
  1147. * 0 MV is saved in internal DPR
  1148. * 1 MV is saved in DDR
  1149. */
  1150. #define TW5864_MPI_DDR_SEL2 BIT(15)
  1151. /* 0x18000 ~ 0x181fc – PCI Master/Slave Control Map */
  1152. #define TW5864_PCI_INTR_STATUS 0x18000
  1153. /* Define controls in register TW5864_PCI_INTR_STATUS */
  1154. /* vlc done */
  1155. #define TW5864_VLC_DONE_INTR BIT(1)
  1156. /* ad vsync */
  1157. #define TW5864_AD_VSYNC_INTR BIT(3)
  1158. /* preview eof */
  1159. #define TW5864_PREV_EOF_INTR BIT(4)
  1160. /* preview overflow interrupt */
  1161. #define TW5864_PREV_OVERFLOW_INTR BIT(5)
  1162. /* timer interrupt */
  1163. #define TW5864_TIMER_INTR BIT(6)
  1164. /* audio eof */
  1165. #define TW5864_AUDIO_EOF_INTR BIT(8)
  1166. /* IIC done */
  1167. #define TW5864_IIC_DONE_INTR BIT(24)
  1168. /* ad interrupt (e.g.: video lost, video format changed) */
  1169. #define TW5864_AD_INTR_REG BIT(25)
  1170. #define TW5864_PCI_INTR_CTL 0x18004
  1171. /* Define controls in register TW5864_PCI_INTR_CTL */
  1172. /* master enable */
  1173. #define TW5864_PCI_MAST_ENB BIT(0)
  1174. /* mvd&vlc master enable */
  1175. #define TW5864_MVD_VLC_MAST_ENB 0x06
  1176. /* (Need to set 0 in TW5864A) */
  1177. #define TW5864_AD_MAST_ENB BIT(3)
  1178. /* preview master enable */
  1179. #define TW5864_PREV_MAST_ENB BIT(4)
  1180. /* preview overflow enable */
  1181. #define TW5864_PREV_OVERFLOW_ENB BIT(5)
  1182. /* timer interrupt enable */
  1183. #define TW5864_TIMER_INTR_ENB BIT(6)
  1184. /* JPEG master (push mode) enable */
  1185. #define TW5864_JPEG_MAST_ENB BIT(7)
  1186. #define TW5864_AU_MAST_ENB_CHN_SHIFT 8
  1187. /* audio master channel enable */
  1188. #define TW5864_AU_MAST_ENB_CHN (0xffff << 8)
  1189. /* IIC interrupt enable */
  1190. #define TW5864_IIC_INTR_ENB BIT(24)
  1191. /* ad interrupt enable */
  1192. #define TW5864_AD_INTR_ENB BIT(25)
  1193. /* target burst enable */
  1194. #define TW5864_PCI_TAR_BURST_ENB BIT(26)
  1195. /* vlc stream burst enable */
  1196. #define TW5864_PCI_VLC_BURST_ENB BIT(27)
  1197. /* ddr burst enable (1 enable, and must set DDR_BRST_EN) */
  1198. #define TW5864_PCI_DDR_BURST_ENB BIT(28)
  1199. /*
  1200. * Because preview and audio have 16 channels separately, so using this
  1201. * registers to indicate interrupt status for every channels. This is secondary
  1202. * interrupt status register. OR operating of the PREV_INTR_REG is
  1203. * PREV_EOF_INTR, OR operating of the AU_INTR_REG bits is AUDIO_EOF_INTR
  1204. */
  1205. #define TW5864_PREV_AND_AU_INTR 0x18008
  1206. /* Define controls in register TW5864_PREV_AND_AU_INTR */
  1207. /* preview eof interrupt flag */
  1208. #define TW5864_PREV_INTR_REG 0x0000ffff
  1209. #define TW5864_AU_INTR_REG_SHIFT 16
  1210. /* audio eof interrupt flag */
  1211. #define TW5864_AU_INTR_REG (0xffff << 16)
  1212. #define TW5864_MASTER_ENB_REG 0x1800c
  1213. /* Define controls in register TW5864_MASTER_ENB_REG */
  1214. /* master enable */
  1215. #define TW5864_PCI_VLC_INTR_ENB BIT(1)
  1216. /* mvd and vlc master enable */
  1217. #define TW5864_PCI_PREV_INTR_ENB BIT(4)
  1218. /* ad vsync master enable */
  1219. #define TW5864_PCI_PREV_OF_INTR_ENB BIT(5)
  1220. /* jpeg master enable */
  1221. #define TW5864_PCI_JPEG_INTR_ENB BIT(7)
  1222. /* preview master enable */
  1223. #define TW5864_PCI_AUD_INTR_ENB BIT(8)
  1224. /*
  1225. * Every channel of preview and audio have ping-pong buffers in system memory,
  1226. * this register is the buffer flag to notify software which buffer is been
  1227. * operated.
  1228. */
  1229. #define TW5864_PREV_AND_AU_BUF_FLAG 0x18010
  1230. /* Define controls in register TW5864_PREV_AND_AU_BUF_FLAG */
  1231. /* preview buffer A/B flag */
  1232. #define TW5864_PREV_BUF_FLAG 0xffff
  1233. #define TW5864_AUDIO_BUF_FLAG_SHIFT 16
  1234. /* audio buffer A/B flag */
  1235. #define TW5864_AUDIO_BUF_FLAG (0xffff << 16)
  1236. #define TW5864_IIC 0x18014
  1237. /* Define controls in register TW5864_IIC */
  1238. /* register data */
  1239. #define TW5864_IIC_DATA 0x00ff
  1240. #define TW5864_IIC_REG_ADDR_SHIFT 8
  1241. /* register addr */
  1242. #define TW5864_IIC_REG_ADDR (0xff << 8)
  1243. /* rd/wr flag rd=1,wr=0 */
  1244. #define TW5864_IIC_RW BIT(16)
  1245. #define TW5864_IIC_DEV_ADDR_SHIFT 17
  1246. /* device addr */
  1247. #define TW5864_IIC_DEV_ADDR (0x7f << 17)
  1248. /*
  1249. * iic done, software kick off one time iic transaction through setting this
  1250. * bit to 1. Then poll this bit, value 1 indicate iic transaction have
  1251. * completed, if read, valid data have been stored in iic_data
  1252. */
  1253. #define TW5864_IIC_DONE BIT(24)
  1254. #define TW5864_RST_AND_IF_INFO 0x18018
  1255. /* Define controls in register TW5864_RST_AND_IF_INFO */
  1256. /* application software soft reset */
  1257. #define TW5864_APP_SOFT_RST BIT(0)
  1258. #define TW5864_PCI_INF_VERSION_SHIFT 16
  1259. /* PCI interface version, read only */
  1260. #define TW5864_PCI_INF_VERSION (0xffff << 16)
  1261. /* vlc stream crc value, it is calculated in pci module */
  1262. #define TW5864_VLC_CRC_REG 0x1801c
  1263. /*
  1264. * vlc max length, it is defined by software based on software assign memory
  1265. * space for vlc
  1266. */
  1267. #define TW5864_VLC_MAX_LENGTH 0x18020
  1268. /* vlc length of one frame */
  1269. #define TW5864_VLC_LENGTH 0x18024
  1270. /* vlc original crc value */
  1271. #define TW5864_VLC_INTRA_CRC_I_REG 0x18028
  1272. /* vlc original crc value */
  1273. #define TW5864_VLC_INTRA_CRC_O_REG 0x1802c
  1274. /* mv stream crc value, it is calculated in pci module */
  1275. #define TW5864_VLC_PAR_CRC_REG 0x18030
  1276. /* mv length */
  1277. #define TW5864_VLC_PAR_LENGTH_REG 0x18034
  1278. /* mv original crc value */
  1279. #define TW5864_VLC_PAR_I_REG 0x18038
  1280. /* mv original crc value */
  1281. #define TW5864_VLC_PAR_O_REG 0x1803c
  1282. /*
  1283. * Configuration register for 9[or 10] CIFs or 1D1+15QCIF Preview mode.
  1284. * PREV_PCI_ENB_CHN[0] Enable 9th preview channel (9CIF prev) or 1D1 channel in
  1285. * (1D1+15QCIF prev)
  1286. * PREV_PCI_ENB_CHN[1] Enable 10th preview channel
  1287. */
  1288. #define TW5864_PREV_PCI_ENB_CHN 0x18040
  1289. /* Description skipped. */
  1290. #define TW5864_PREV_FRAME_FORMAT_IN 0x18044
  1291. /* IIC enable */
  1292. #define TW5864_IIC_ENB 0x18048
  1293. /*
  1294. * Timer interrupt interval
  1295. * 0 1ms
  1296. * 1 2ms
  1297. * 2 4ms
  1298. * 3 8ms
  1299. */
  1300. #define TW5864_PCI_INTTM_SCALE 0x1804c
  1301. /*
  1302. * The above register is pci base address registers. Application software will
  1303. * initialize them to tell chip where the corresponding stream will be dumped
  1304. * to. Application software will select appropriate base address interval based
  1305. * on the stream length.
  1306. */
  1307. /* VLC stream base address */
  1308. #define TW5864_VLC_STREAM_BASE_ADDR 0x18080
  1309. /* MV stream base address */
  1310. #define TW5864_MV_STREAM_BASE_ADDR 0x18084
  1311. /* 0x180a0 – 0x180bc: audio burst base address. Skipped. */
  1312. /* 0x180c0 ~ 0x180dc – JPEG Push Mode Buffer Base Address. Skipped. */
  1313. /* 0x18100 – 0x1817c: preview burst base address. Skipped. */
  1314. /* 0x80000 ~ 0x87fff -- DDR Burst RW Register Map */
  1315. #define TW5864_DDR_CTL 0x80000
  1316. /* Define controls in register TW5864_DDR_CTL */
  1317. #define TW5864_BRST_LENGTH_SHIFT 2
  1318. /* Length of 32-bit data burst */
  1319. #define TW5864_BRST_LENGTH (0x3fff << 2)
  1320. /*
  1321. * Burst Read/Write
  1322. * 0 Read Burst from DDR
  1323. * 1 Write Burst to DDR
  1324. */
  1325. #define TW5864_BRST_RW BIT(16)
  1326. /* Begin a new DDR Burst. This bit is self cleared */
  1327. #define TW5864_NEW_BRST_CMD BIT(17)
  1328. /* DDR Burst End Flag */
  1329. #define TW5864_BRST_END BIT(24)
  1330. /* Enable Error Interrupt for Single DDR Access */
  1331. #define TW5864_SING_ERR_INTR BIT(25)
  1332. /* Enable Error Interrupt for Burst DDR Access */
  1333. #define TW5864_BRST_ERR_INTR BIT(26)
  1334. /* Enable Interrupt for End of DDR Burst Access */
  1335. #define TW5864_BRST_END_INTR BIT(27)
  1336. /* DDR Single Access Error Flag */
  1337. #define TW5864_SINGLE_ERR BIT(28)
  1338. /* DDR Single Access Busy Flag */
  1339. #define TW5864_SINGLE_BUSY BIT(29)
  1340. /* DDR Burst Access Error Flag */
  1341. #define TW5864_BRST_ERR BIT(30)
  1342. /* DDR Burst Access Busy Flag */
  1343. #define TW5864_BRST_BUSY BIT(31)
  1344. /* [27:0] DDR Access Address. Bit [1:0] has to be 0 */
  1345. #define TW5864_DDR_ADDR 0x80004
  1346. /* DDR Access Internal Buffer Address. Bit [1:0] has to be 0 */
  1347. #define TW5864_DPR_BUF_ADDR 0x80008
  1348. /* SRAM Buffer MPI Access Space. Totally 16 KB */
  1349. #define TW5864_DPR_BUF_START 0x84000
  1350. /* 0x84000 - 0x87ffc */
  1351. #define TW5864_DPR_BUF_SIZE 0x4000
  1352. /* Indirect Map Space */
  1353. /*
  1354. * The indirect space is accessed through 0xb800 ~ 0xb807 registers in direct
  1355. * access space
  1356. */
  1357. /* Analog Video / Audio Decoder / Encoder */
  1358. /* Allowed channel values: [0; 3] */
  1359. /* Read-only register */
  1360. #define TW5864_INDIR_VIN_0(channel) (0x000 + channel * 0x010)
  1361. /* Define controls in register TW5864_INDIR_VIN_0 */
  1362. /*
  1363. * 1 Video not present. (sync is not detected in number of consecutive line
  1364. * periods specified by MISSCNT register)
  1365. * 0 Video detected.
  1366. */
  1367. #define TW5864_INDIR_VIN_0_VDLOSS BIT(7)
  1368. /*
  1369. * 1 Horizontal sync PLL is locked to the incoming video source.
  1370. * 0 Horizontal sync PLL is not locked.
  1371. */
  1372. #define TW5864_INDIR_VIN_0_HLOCK BIT(6)
  1373. /*
  1374. * 1 Sub-carrier PLL is locked to the incoming video source.
  1375. * 0 Sub-carrier PLL is not locked.
  1376. */
  1377. #define TW5864_INDIR_VIN_0_SLOCK BIT(5)
  1378. /*
  1379. * 1 Even field is being decoded.
  1380. * 0 Odd field is being decoded.
  1381. */
  1382. #define TW5864_INDIR_VIN_0_FLD BIT(4)
  1383. /*
  1384. * 1 Vertical logic is locked to the incoming video source.
  1385. * 0 Vertical logic is not locked.
  1386. */
  1387. #define TW5864_INDIR_VIN_0_VLOCK BIT(3)
  1388. /*
  1389. * 1 No color burst signal detected.
  1390. * 0 Color burst signal detected.
  1391. */
  1392. #define TW5864_INDIR_VIN_0_MONO BIT(1)
  1393. /*
  1394. * 0 60Hz source detected
  1395. * 1 50Hz source detected
  1396. * The actual vertical scanning frequency depends on the current standard
  1397. * invoked.
  1398. */
  1399. #define TW5864_INDIR_VIN_0_DET50 BIT(0)
  1400. #define TW5864_INDIR_VIN_1(channel) (0x001 + channel * 0x010)
  1401. /* VCR signal indicator. Read-only. */
  1402. #define TW5864_INDIR_VIN_1_VCR BIT(7)
  1403. /* Weak signal indicator 2. Read-only. */
  1404. #define TW5864_INDIR_VIN_1_WKAIR BIT(6)
  1405. /* Weak signal indicator controlled by WKTH. Read-only. */
  1406. #define TW5864_INDIR_VIN_1_WKAIR1 BIT(5)
  1407. /*
  1408. * 1 = Standard signal
  1409. * 0 = Non-standard signal
  1410. * Read-only
  1411. */
  1412. #define TW5864_INDIR_VIN_1_VSTD BIT(4)
  1413. /*
  1414. * 1 = Non-interlaced signal
  1415. * 0 = interlaced signal
  1416. * Read-only
  1417. */
  1418. #define TW5864_INDIR_VIN_1_NINTL BIT(3)
  1419. /*
  1420. * Vertical Sharpness Control. Writable.
  1421. * 0 = None (default)
  1422. * 7 = Highest
  1423. * **Note: VSHP must be set to ‘0’ if COMB = 0
  1424. */
  1425. #define TW5864_INDIR_VIN_1_VSHP 0x07
  1426. /* HDELAY_XY[7:0] */
  1427. #define TW5864_INDIR_VIN_2_HDELAY_XY_LO(channel) (0x002 + channel * 0x010)
  1428. /* HACTIVE_XY[7:0] */
  1429. #define TW5864_INDIR_VIN_3_HACTIVE_XY_LO(channel) (0x003 + channel * 0x010)
  1430. /* VDELAY_XY[7:0] */
  1431. #define TW5864_INDIR_VIN_4_VDELAY_XY_LO(channel) (0x004 + channel * 0x010)
  1432. /* VACTIVE_XY[7:0] */
  1433. #define TW5864_INDIR_VIN_5_VACTIVE_XY_LO(channel) (0x005 + channel * 0x010)
  1434. #define TW5864_INDIR_VIN_6(channel) (0x006 + channel * 0x010)
  1435. /* Define controls in register TW5864_INDIR_VIN_6 */
  1436. #define TW5864_INDIR_VIN_6_HDELAY_XY_HI 0x03
  1437. #define TW5864_INDIR_VIN_6_HACTIVE_XY_HI_SHIFT 2
  1438. #define TW5864_INDIR_VIN_6_HACTIVE_XY_HI (0x03 << 2)
  1439. #define TW5864_INDIR_VIN_6_VDELAY_XY_HI BIT(4)
  1440. #define TW5864_INDIR_VIN_6_VACTIVE_XY_HI BIT(5)
  1441. /*
  1442. * HDELAY_XY This 10bit register defines the starting location of horizontal
  1443. * active pixel for display / record path. A unit is 1 pixel. The default value
  1444. * is 0x00f for NTSC and 0x00a for PAL.
  1445. *
  1446. * HACTIVE_XY This 10bit register defines the number of horizontal active pixel
  1447. * for display / record path. A unit is 1 pixel. The default value is decimal
  1448. * 720.
  1449. *
  1450. * VDELAY_XY This 9bit register defines the starting location of vertical
  1451. * active for display / record path. A unit is 1 line. The default value is
  1452. * decimal 6.
  1453. *
  1454. * VACTIVE_XY This 9bit register defines the number of vertical active lines
  1455. * for display / record path. A unit is 1 line. The default value is decimal
  1456. * 240.
  1457. */
  1458. /* HUE These bits control the color hue as 2's complement number. They have
  1459. * value from +36o (7Fh) to -36o (80h) with an increment of 2.8o. The 2 LSB has
  1460. * no effect. The positive value gives greenish tone and negative value gives
  1461. * purplish tone. The default value is 0o (00h). This is effective only on NTSC
  1462. * system. The default is 00h.
  1463. */
  1464. #define TW5864_INDIR_VIN_7_HUE(channel) (0x007 + channel * 0x010)
  1465. #define TW5864_INDIR_VIN_8(channel) (0x008 + channel * 0x010)
  1466. /* Define controls in register TW5864_INDIR_VIN_8 */
  1467. /*
  1468. * This bit controls the center frequency of the peaking filter.
  1469. * The corresponding gain adjustment is HFLT.
  1470. * 0 Low
  1471. * 1 center
  1472. */
  1473. #define TW5864_INDIR_VIN_8_SCURVE BIT(7)
  1474. /* CTI level selection. The default is 1.
  1475. * 0 None
  1476. * 3 Highest
  1477. */
  1478. #define TW5864_INDIR_VIN_8_CTI_SHIFT 4
  1479. #define TW5864_INDIR_VIN_8_CTI (0x03 << 4)
  1480. /*
  1481. * These bits control the amount of sharpness enhancement on the luminance
  1482. * signals. There are 16 levels of control with "0" having no effect on the
  1483. * output image. 1 through 15 provides sharpness enhancement with "F" being the
  1484. * strongest. The default is 1.
  1485. */
  1486. #define TW5864_INDIR_VIN_8_SHARPNESS 0x0f
  1487. /*
  1488. * These bits control the luminance contrast gain. A value of 100 (64h) has a
  1489. * gain of 1. The range adjustment is from 0% to 255% at 1% per step. The
  1490. * default is 64h.
  1491. */
  1492. #define TW5864_INDIR_VIN_9_CNTRST(channel) (0x009 + channel * 0x010)
  1493. /*
  1494. * These bits control the brightness. They have value of –128 to 127 in 2's
  1495. * complement form. Positive value increases brightness. A value 0 has no
  1496. * effect on the data. The default is 00h.
  1497. */
  1498. #define TW5864_INDIR_VIN_A_BRIGHT(channel) (0x00a + channel * 0x010)
  1499. /*
  1500. * These bits control the digital gain adjustment to the U (or Cb) component of
  1501. * the digital video signal. The color saturation can be adjusted by adjusting
  1502. * the U and V color gain components by the same amount in the normal
  1503. * situation. The U and V can also be adjusted independently to provide greater
  1504. * flexibility. The range of adjustment is 0 to 200%. A value of 128 (80h) has
  1505. * gain of 100%. The default is 80h.
  1506. */
  1507. #define TW5864_INDIR_VIN_B_SAT_U(channel) (0x00b + channel * 0x010)
  1508. /*
  1509. * These bits control the digital gain adjustment to the V (or Cr) component of
  1510. * the digital video signal. The color saturation can be adjusted by adjusting
  1511. * the U and V color gain components by the same amount in the normal
  1512. * situation. The U and V can also be adjusted independently to provide greater
  1513. * flexibility. The range of adjustment is 0 to 200%. A value of 128 (80h) has
  1514. * gain of 100%. The default is 80h.
  1515. */
  1516. #define TW5864_INDIR_VIN_C_SAT_V(channel) (0x00c + channel * 0x010)
  1517. /* Read-only */
  1518. #define TW5864_INDIR_VIN_D(channel) (0x00d + channel * 0x010)
  1519. /* Define controls in register TW5864_INDIR_VIN_D */
  1520. /* Macrovision color stripe detection may be un-reliable */
  1521. #define TW5864_INDIR_VIN_D_CSBAD BIT(3)
  1522. /* Macrovision AGC pulse detected */
  1523. #define TW5864_INDIR_VIN_D_MCVSN BIT(2)
  1524. /* Macrovision color stripe protection burst detected */
  1525. #define TW5864_INDIR_VIN_D_CSTRIPE BIT(1)
  1526. /*
  1527. * This bit is valid only when color stripe protection is detected, i.e. if
  1528. * CSTRIPE=1,
  1529. * 1 Type 2 color stripe protection
  1530. * 0 Type 3 color stripe protection
  1531. */
  1532. #define TW5864_INDIR_VIN_D_CTYPE2 BIT(0)
  1533. /* Read-only */
  1534. #define TW5864_INDIR_VIN_E(channel) (0x00e + channel * 0x010)
  1535. /* Define controls in register TW5864_INDIR_VIN_E */
  1536. /*
  1537. * Read-only.
  1538. * 0 Idle
  1539. * 1 Detection in progress
  1540. */
  1541. #define TW5864_INDIR_VIN_E_DETSTUS BIT(7)
  1542. /*
  1543. * STDNOW Current standard invoked
  1544. * 0 NTSC (M)
  1545. * 1 PAL (B, D, G, H, I)
  1546. * 2 SECAM
  1547. * 3 NTSC4.43
  1548. * 4 PAL (M)
  1549. * 5 PAL (CN)
  1550. * 6 PAL 60
  1551. * 7 Not valid
  1552. */
  1553. #define TW5864_INDIR_VIN_E_STDNOW_SHIFT 4
  1554. #define TW5864_INDIR_VIN_E_STDNOW (0x07 << 4)
  1555. /*
  1556. * 1 Disable the shadow registers
  1557. * 0 Enable VACTIVE and HDELAY shadow registers value depending on STANDARD.
  1558. * (Default)
  1559. */
  1560. #define TW5864_INDIR_VIN_E_ATREG BIT(3)
  1561. /*
  1562. * STANDARD Standard selection
  1563. * 0 NTSC (M)
  1564. * 1 PAL (B, D, G, H, I)
  1565. * 2 SECAM
  1566. * 3 NTSC4.43
  1567. * 4 PAL (M)
  1568. * 5 PAL (CN)
  1569. * 6 PAL 60
  1570. * 7 Auto detection (Default)
  1571. */
  1572. #define TW5864_INDIR_VIN_E_STANDARD 0x07
  1573. #define TW5864_INDIR_VIN_F(channel) (0x00f + channel * 0x010)
  1574. /* Define controls in register TW5864_INDIR_VIN_F */
  1575. /*
  1576. * 1 Writing 1 to this bit will manually initiate the auto format detection
  1577. * process. This bit is a self-clearing bit
  1578. * 0 Manual initiation of auto format detection is done. (Default)
  1579. */
  1580. #define TW5864_INDIR_VIN_F_ATSTART BIT(7)
  1581. /* Enable recognition of PAL60 (Default) */
  1582. #define TW5864_INDIR_VIN_F_PAL60EN BIT(6)
  1583. /* Enable recognition of PAL (CN). (Default) */
  1584. #define TW5864_INDIR_VIN_F_PALCNEN BIT(5)
  1585. /* Enable recognition of PAL (M). (Default) */
  1586. #define TW5864_INDIR_VIN_F_PALMEN BIT(4)
  1587. /* Enable recognition of NTSC 4.43. (Default) */
  1588. #define TW5864_INDIR_VIN_F_NTSC44EN BIT(3)
  1589. /* Enable recognition of SECAM. (Default) */
  1590. #define TW5864_INDIR_VIN_F_SECAMEN BIT(2)
  1591. /* Enable recognition of PAL (B, D, G, H, I). (Default) */
  1592. #define TW5864_INDIR_VIN_F_PALBEN BIT(1)
  1593. /* Enable recognition of NTSC (M). (Default) */
  1594. #define TW5864_INDIR_VIN_F_NTSCEN BIT(0)
  1595. /* Some registers skipped. */
  1596. /* Use falling edge to sample VD1-VD4 from 54 MHz to 108 MHz */
  1597. #define TW5864_INDIR_VD_108_POL 0x041
  1598. #define TW5864_INDIR_VD_108_POL_VD12 BIT(0)
  1599. #define TW5864_INDIR_VD_108_POL_VD34 BIT(1)
  1600. #define TW5864_INDIR_VD_108_POL_BOTH \
  1601. (TW5864_INDIR_VD_108_POL_VD12 | TW5864_INDIR_VD_108_POL_VD34)
  1602. /* Some registers skipped. */
  1603. /*
  1604. * Audio Input ADC gain control
  1605. * 0 0.25
  1606. * 1 0.31
  1607. * 2 0.38
  1608. * 3 0.44
  1609. * 4 0.50
  1610. * 5 0.63
  1611. * 6 0.75
  1612. * 7 0.88
  1613. * 8 1.00 (default)
  1614. * 9 1.25
  1615. * 10 1.50
  1616. * 11 1.75
  1617. * 12 2.00
  1618. * 13 2.25
  1619. * 14 2.50
  1620. * 15 2.75
  1621. */
  1622. /* [3:0] channel 0, [7:4] channel 1 */
  1623. #define TW5864_INDIR_AIGAIN1 0x060
  1624. /* [3:0] channel 2, [7:4] channel 3 */
  1625. #define TW5864_INDIR_AIGAIN2 0x061
  1626. /* Some registers skipped */
  1627. #define TW5864_INDIR_AIN_0x06D 0x06d
  1628. /* Define controls in register TW5864_INDIR_AIN_0x06D */
  1629. /*
  1630. * LAWMD Select u-Law/A-Law/PCM/SB data output format on ADATR and ADATM pin.
  1631. * 0 PCM output (default)
  1632. * 1 SB (Signed MSB bit in PCM data is inverted) output
  1633. * 2 u-Law output
  1634. * 3 A-Law output
  1635. */
  1636. #define TW5864_INDIR_AIN_LAWMD_SHIFT 6
  1637. #define TW5864_INDIR_AIN_LAWMD (0x03 << 6)
  1638. /*
  1639. * Disable the mixing ratio value for all audio.
  1640. * 0 Apply individual mixing ratio value for each audio (default)
  1641. * 1 Apply nominal value for all audio commonly
  1642. */
  1643. #define TW5864_INDIR_AIN_MIX_DERATIO BIT(5)
  1644. /*
  1645. * Enable the mute function for audio channel AINn when n is 0 to 3. It effects
  1646. * only for mixing. When n = 4, it enable the mute function of the playback
  1647. * audio input. It effects only for single chip or the last stage chip
  1648. * 0 Normal
  1649. * 1 Muted (default)
  1650. */
  1651. #define TW5864_INDIR_AIN_MIX_MUTE 0x1f
  1652. /* Some registers skipped */
  1653. #define TW5864_INDIR_AIN_0x0E3 0x0e3
  1654. /* Define controls in register TW5864_INDIR_AIN_0x0E3 */
  1655. /*
  1656. * ADATP signal is coming from external ADPCM decoder, instead of on-chip ADPCM
  1657. * decoder
  1658. */
  1659. #define TW5864_INDIR_AIN_0x0E3_EXT_ADATP BIT(7)
  1660. /* ACLKP output signal polarity inverse */
  1661. #define TW5864_INDIR_AIN_0x0E3_ACLKPPOLO BIT(6)
  1662. /*
  1663. * ACLKR input signal polarity inverse.
  1664. * 0 Not inversed (Default)
  1665. * 1 Inversed
  1666. */
  1667. #define TW5864_INDIR_AIN_0x0E3_ACLKRPOL BIT(5)
  1668. /*
  1669. * ACLKP input signal polarity inverse.
  1670. * 0 Not inversed (Default)
  1671. * 1 Inversed
  1672. */
  1673. #define TW5864_INDIR_AIN_0x0E3_ACLKPPOLI BIT(4)
  1674. /*
  1675. * ACKI [21:0] control automatic set up with AFMD registers
  1676. * This mode is only effective when ACLKRMASTER=1
  1677. * 0 ACKI [21:0] registers set up ACKI control
  1678. * 1 ACKI control is automatically set up by AFMD register values
  1679. */
  1680. #define TW5864_INDIR_AIN_0x0E3_AFAUTO BIT(3)
  1681. /*
  1682. * AFAUTO control mode
  1683. * 0 8kHz setting (Default)
  1684. * 1 16kHz setting
  1685. * 2 32kHz setting
  1686. * 3 44.1kHz setting
  1687. * 4 48kHz setting
  1688. */
  1689. #define TW5864_INDIR_AIN_0x0E3_AFMD 0x07
  1690. #define TW5864_INDIR_AIN_0x0E4 0x0e4
  1691. /* Define controls in register TW5864_INDIR_AIN_0x0ED */
  1692. /*
  1693. * 8bit I2S Record output mode.
  1694. * 0 L/R half length separated output (Default).
  1695. * 1 One continuous packed output equal to DSP output format.
  1696. */
  1697. #define TW5864_INDIR_AIN_0x0E4_I2S8MODE BIT(7)
  1698. /*
  1699. * Audio Clock Master ACLKR output wave format.
  1700. * 0 High periods is one 27MHz clock period (default).
  1701. * 1 Almost duty 50-50% clock output on ACLKR pin. If this mode is selected, two
  1702. * times bigger number value need to be set up on the ACKI register. If
  1703. * AFAUTO=1, ACKI control is automatically set up even if MASCKMD=1.
  1704. */
  1705. #define TW5864_INDIR_AIN_0x0E4_MASCKMD BIT(6)
  1706. /* Playback ACLKP/ASYNP/ADATP input data MSB-LSB swapping */
  1707. #define TW5864_INDIR_AIN_0x0E4_PBINSWAP BIT(5)
  1708. /*
  1709. * ASYNR input signal delay.
  1710. * 0 No delay
  1711. * 1 Add one 27MHz period delay in ASYNR signal input
  1712. */
  1713. #define TW5864_INDIR_AIN_0x0E4_ASYNRDLY BIT(4)
  1714. /*
  1715. * ASYNP input signal delay.
  1716. * 0 no delay
  1717. * 1 add one 27MHz period delay in ASYNP signal input
  1718. */
  1719. #define TW5864_INDIR_AIN_0x0E4_ASYNPDLY BIT(3)
  1720. /*
  1721. * ADATP input data delay by one ACLKP clock.
  1722. * 0 No delay (Default). This is for I2S type 1T delay input interface.
  1723. * 1 Add 1 ACLKP clock delay in ADATP input data. This is for left-justified
  1724. * type 0T delay input interface.
  1725. */
  1726. #define TW5864_INDIR_AIN_0x0E4_ADATPDLY BIT(2)
  1727. /*
  1728. * Select u-Law/A-Law/PCM/SB data input format on ADATP pin.
  1729. * 0 PCM input (Default)
  1730. * 1 SB (Signed MSB bit in PCM data is inverted) input
  1731. * 2 u-Law input
  1732. * 3 A-Law input
  1733. */
  1734. #define TW5864_INDIR_AIN_0x0E4_INLAWMD 0x03
  1735. /*
  1736. * Enable state register updating and interrupt request of audio AIN5 detection
  1737. * for each input
  1738. */
  1739. #define TW5864_INDIR_AIN_A5DETENA 0x0e5
  1740. /* Some registers skipped */
  1741. /*
  1742. * [7:3]: DEV_ID The TW5864 product ID code is 01000
  1743. * [2:0]: REV_ID The revision number is 0h
  1744. */
  1745. #define TW5864_INDIR_ID 0x0fe
  1746. #define TW5864_INDIR_IN_PIC_WIDTH(channel) (0x200 + 4 * channel)
  1747. #define TW5864_INDIR_IN_PIC_HEIGHT(channel) (0x201 + 4 * channel)
  1748. #define TW5864_INDIR_OUT_PIC_WIDTH(channel) (0x202 + 4 * channel)
  1749. #define TW5864_INDIR_OUT_PIC_HEIGHT(channel) (0x203 + 4 * channel)
  1750. /* Some registers skipped */
  1751. #define TW5864_INDIR_CROP_ETC 0x260
  1752. /* Define controls in register TW5864_INDIR_CROP_ETC */
  1753. /* Enable cropping from 720 to 704 */
  1754. #define TW5864_INDIR_CROP_ETC_CROP_EN 0x4
  1755. /*
  1756. * Interrupt status register from the front-end. Write "1" to each bit to clear
  1757. * the interrupt
  1758. * 15:0 Motion detection interrupt for channel 0 ~ 15
  1759. * 31:16 Night detection interrupt for channel 0 ~ 15
  1760. * 47:32 Blind detection interrupt for channel 0 ~ 15
  1761. * 63:48 No video interrupt for channel 0 ~ 15
  1762. * 79:64 Line mode underflow interrupt for channel 0 ~ 15
  1763. * 95:80 Line mode overflow interrupt for channel 0 ~ 15
  1764. */
  1765. /* 0x2d0~0x2d7: [63:0] bits */
  1766. #define TW5864_INDIR_INTERRUPT1 0x2d0
  1767. /* 0x2e0~0x2e3: [95:64] bits */
  1768. #define TW5864_INDIR_INTERRUPT2 0x2e0
  1769. /*
  1770. * Interrupt mask register for interrupts in 0x2d0 ~ 0x2d7
  1771. * 15:0 Motion detection interrupt for channel 0 ~ 15
  1772. * 31:16 Night detection interrupt for channel 0 ~ 15
  1773. * 47:32 Blind detection interrupt for channel 0 ~ 15
  1774. * 63:48 No video interrupt for channel 0 ~ 15
  1775. * 79:64 Line mode underflow interrupt for channel 0 ~ 15
  1776. * 95:80 Line mode overflow interrupt for channel 0 ~ 15
  1777. */
  1778. /* 0x2d8~0x2df: [63:0] bits */
  1779. #define TW5864_INDIR_INTERRUPT_MASK1 0x2d8
  1780. /* 0x2e8~0x2eb: [95:64] bits */
  1781. #define TW5864_INDIR_INTERRUPT_MASK2 0x2e8
  1782. /* [11:0]: Interrupt summary register for interrupts & interrupt mask from in
  1783. * 0x2d0 ~ 0x2d7 and 0x2d8 ~ 0x2df
  1784. * bit 0: interrupt occurs in 0x2d0 & 0x2d8
  1785. * bit 1: interrupt occurs in 0x2d1 & 0x2d9
  1786. * bit 2: interrupt occurs in 0x2d2 & 0x2da
  1787. * bit 3: interrupt occurs in 0x2d3 & 0x2db
  1788. * bit 4: interrupt occurs in 0x2d4 & 0x2dc
  1789. * bit 5: interrupt occurs in 0x2d5 & 0x2dd
  1790. * bit 6: interrupt occurs in 0x2d6 & 0x2de
  1791. * bit 7: interrupt occurs in 0x2d7 & 0x2df
  1792. * bit 8: interrupt occurs in 0x2e0 & 0x2e8
  1793. * bit 9: interrupt occurs in 0x2e1 & 0x2e9
  1794. * bit 10: interrupt occurs in 0x2e2 & 0x2ea
  1795. * bit 11: interrupt occurs in 0x2e3 & 0x2eb
  1796. */
  1797. #define TW5864_INDIR_INTERRUPT_SUMMARY 0x2f0
  1798. /* Motion / Blind / Night Detection */
  1799. /* valid value for channel is [0:15] */
  1800. #define TW5864_INDIR_DETECTION_CTL0(channel) (0x300 + channel * 0x08)
  1801. /* Define controls in register TW5864_INDIR_DETECTION_CTL0 */
  1802. /*
  1803. * Disable the motion and blind detection.
  1804. * 0 Enable motion and blind detection (default)
  1805. * 1 Disable motion and blind detection
  1806. */
  1807. #define TW5864_INDIR_DETECTION_CTL0_MD_DIS BIT(5)
  1808. /*
  1809. * Request to start motion detection on manual trigger mode
  1810. * 0 None Operation (default)
  1811. * 1 Request to start motion detection
  1812. */
  1813. #define TW5864_INDIR_DETECTION_CTL0_MD_STRB BIT(3)
  1814. /*
  1815. * Select the trigger mode of motion detection
  1816. * 0 Automatic trigger mode of motion detection (default)
  1817. * 1 Manual trigger mode for motion detection
  1818. */
  1819. #define TW5864_INDIR_DETECTION_CTL0_MD_STRB_EN BIT(2)
  1820. /*
  1821. * Define the threshold of cell for blind detection.
  1822. * 0 Low threshold (More sensitive) (default)
  1823. * : :
  1824. * 3 High threshold (Less sensitive)
  1825. */
  1826. #define TW5864_INDIR_DETECTION_CTL0_BD_CELSENS 0x03
  1827. #define TW5864_INDIR_DETECTION_CTL1(channel) (0x301 + channel * 0x08)
  1828. /* Define controls in register TW5864_INDIR_DETECTION_CTL1 */
  1829. /*
  1830. * Control the temporal sensitivity of motion detector.
  1831. * 0 More Sensitive (default)
  1832. * : :
  1833. * 15 Less Sensitive
  1834. */
  1835. #define TW5864_INDIR_DETECTION_CTL1_MD_TMPSENS_SHIFT 4
  1836. #define TW5864_INDIR_DETECTION_CTL1_MD_TMPSENS (0x0f << 4)
  1837. /*
  1838. * Adjust the horizontal starting position for motion detection
  1839. * 0 0 pixel (default)
  1840. * : :
  1841. * 15 15 pixels
  1842. */
  1843. #define TW5864_INDIR_DETECTION_CTL1_MD_PIXEL_OS 0x0f
  1844. #define TW5864_INDIR_DETECTION_CTL2(channel) (0x302 + channel * 0x08)
  1845. /* Define controls in register TW5864_INDIR_DETECTION_CTL2 */
  1846. /*
  1847. * Control the updating time of reference field for motion detection.
  1848. * 0 Update reference field every field (default)
  1849. * 1 Update reference field according to MD_SPEED
  1850. */
  1851. #define TW5864_INDIR_DETECTION_CTL2_MD_REFFLD BIT(7)
  1852. /*
  1853. * Select the field for motion detection.
  1854. * 0 Detecting motion for only odd field (default)
  1855. * 1 Detecting motion for only even field
  1856. * 2 Detecting motion for any field
  1857. * 3 Detecting motion for both odd and even field
  1858. */
  1859. #define TW5864_INDIR_DETECTION_CTL2_MD_FIELD_SHIFT 5
  1860. #define TW5864_INDIR_DETECTION_CTL2_MD_FIELD (0x03 << 5)
  1861. /*
  1862. * Control the level sensitivity of motion detector.
  1863. * 0 More sensitive (default)
  1864. * : :
  1865. * 15 Less sensitive
  1866. */
  1867. #define TW5864_INDIR_DETECTION_CTL2_MD_LVSENS 0x1f
  1868. #define TW5864_INDIR_DETECTION_CTL3(channel) (0x303 + channel * 0x08)
  1869. /* Define controls in register TW5864_INDIR_DETECTION_CTL3 */
  1870. /*
  1871. * Define the threshold of sub-cell number for motion detection.
  1872. * 0 Motion is detected if 1 sub-cell has motion (More sensitive) (default)
  1873. * 1 Motion is detected if 2 sub-cells have motion
  1874. * 2 Motion is detected if 3 sub-cells have motion
  1875. * 3 Motion is detected if 4 sub-cells have motion (Less sensitive)
  1876. */
  1877. #define TW5864_INDIR_DETECTION_CTL3_MD_CELSENS_SHIFT 6
  1878. #define TW5864_INDIR_DETECTION_CTL3_MD_CELSENS (0x03 << 6)
  1879. /*
  1880. * Control the velocity of motion detector.
  1881. * Large value is suitable for slow motion detection.
  1882. * In MD_DUAL_EN = 1, MD_SPEED should be limited to 0 ~ 31.
  1883. * 0 1 field intervals (default)
  1884. * 1 2 field intervals
  1885. * : :
  1886. * 61 62 field intervals
  1887. * 62 63 field intervals
  1888. * 63 Not supported
  1889. */
  1890. #define TW5864_INDIR_DETECTION_CTL3_MD_SPEED 0x3f
  1891. #define TW5864_INDIR_DETECTION_CTL4(channel) (0x304 + channel * 0x08)
  1892. /* Define controls in register TW5864_INDIR_DETECTION_CTL4 */
  1893. /*
  1894. * Control the spatial sensitivity of motion detector.
  1895. * 0 More Sensitive (default)
  1896. * : :
  1897. * 15 Less Sensitive
  1898. */
  1899. #define TW5864_INDIR_DETECTION_CTL4_MD_SPSENS_SHIFT 4
  1900. #define TW5864_INDIR_DETECTION_CTL4_MD_SPSENS (0x0f << 4)
  1901. /*
  1902. * Define the threshold of level for blind detection.
  1903. * 0 Low threshold (More sensitive) (default)
  1904. * : :
  1905. * 15 High threshold (Less sensitive)
  1906. */
  1907. #define TW5864_INDIR_DETECTION_CTL4_BD_LVSENS 0x0f
  1908. #define TW5864_INDIR_DETECTION_CTL5(channel) (0x305 + channel * 0x08)
  1909. /*
  1910. * Define the threshold of temporal sensitivity for night detection.
  1911. * 0 Low threshold (More sensitive) (default)
  1912. * : :
  1913. * 15 High threshold (Less sensitive)
  1914. */
  1915. #define TW5864_INDIR_DETECTION_CTL5_ND_TMPSENS_SHIFT 4
  1916. #define TW5864_INDIR_DETECTION_CTL5_ND_TMPSENS (0x0f << 4)
  1917. /*
  1918. * Define the threshold of level for night detection.
  1919. * 0 Low threshold (More sensitive) (default)
  1920. * : :
  1921. * 3 High threshold (Less sensitive)
  1922. */
  1923. #define TW5864_INDIR_DETECTION_CTL5_ND_LVSENS 0x0f
  1924. /*
  1925. * [11:0] The base address of the motion detection buffer. This address is in
  1926. * unit of 64K bytes. The generated DDR address will be {MD_BASE_ADDR,
  1927. * 16"h0000}. The default value should be 12"h000
  1928. */
  1929. #define TW5864_INDIR_MD_BASE_ADDR 0x380
  1930. /*
  1931. * This controls the channel of the motion detection result shown in register
  1932. * 0x3a0 ~ 0x3b7. Before reading back motion result, always set this first.
  1933. */
  1934. #define TW5864_INDIR_RGR_MOTION_SEL 0x382
  1935. /* [15:0] MD strobe has been performed at channel n (read only) */
  1936. #define TW5864_INDIR_MD_STRB 0x386
  1937. /* NO_VIDEO Detected from channel n (read only) */
  1938. #define TW5864_INDIR_NOVID_DET 0x388
  1939. /* Motion Detected from channel n (read only) */
  1940. #define TW5864_INDIR_MD_DET 0x38a
  1941. /* Blind Detected from channel n (read only) */
  1942. #define TW5864_INDIR_BD_DET 0x38c
  1943. /* Night Detected from channel n (read only) */
  1944. #define TW5864_INDIR_ND_DET 0x38e
  1945. /* 192 bit motion flag of the channel specified by RGR_MOTION_SEL in 0x382 */
  1946. #define TW5864_INDIR_MOTION_FLAG 0x3a0
  1947. #define TW5864_INDIR_MOTION_FLAG_BYTE_COUNT 24
  1948. /*
  1949. * [9:0] The motion cell count of a specific channel selected by 0x382. This is
  1950. * for DI purpose
  1951. */
  1952. #define TW5864_INDIR_MD_DI_CNT 0x3b8
  1953. /* The motion detection cell sensitivity for DI purpose */
  1954. #define TW5864_INDIR_MD_DI_CELLSENS 0x3ba
  1955. /* The motion detection threshold level for DI purpose */
  1956. #define TW5864_INDIR_MD_DI_LVSENS 0x3bb
  1957. /* 192 bit motion mask of the channel specified by MASK_CH_SEL in 0x3fe */
  1958. #define TW5864_INDIR_MOTION_MASK 0x3e0
  1959. #define TW5864_INDIR_MOTION_MASK_BYTE_COUNT 24
  1960. /* [4:0] The channel selection to access masks in 0x3e0 ~ 0x3f7 */
  1961. #define TW5864_INDIR_MASK_CH_SEL 0x3fe
  1962. /* Clock PLL / Analog IP Control */
  1963. /* Some registers skipped */
  1964. #define TW5864_INDIR_DDRA_DLL_DQS_SEL0 0xee6
  1965. #define TW5864_INDIR_DDRA_DLL_DQS_SEL1 0xee7
  1966. #define TW5864_INDIR_DDRA_DLL_CLK90_SEL 0xee8
  1967. #define TW5864_INDIR_DDRA_DLL_TEST_SEL_AND_TAP_S 0xee9
  1968. #define TW5864_INDIR_DDRB_DLL_DQS_SEL0 0xeeb
  1969. #define TW5864_INDIR_DDRB_DLL_DQS_SEL1 0xeec
  1970. #define TW5864_INDIR_DDRB_DLL_CLK90_SEL 0xeed
  1971. #define TW5864_INDIR_DDRB_DLL_TEST_SEL_AND_TAP_S 0xeee
  1972. #define TW5864_INDIR_RESET 0xef0
  1973. #define TW5864_INDIR_RESET_VD BIT(7)
  1974. #define TW5864_INDIR_RESET_DLL BIT(6)
  1975. #define TW5864_INDIR_RESET_MUX_CORE BIT(5)
  1976. #define TW5864_INDIR_PV_VD_CK_POL 0xefd
  1977. #define TW5864_INDIR_PV_VD_CK_POL_PV(channel) BIT(channel)
  1978. #define TW5864_INDIR_PV_VD_CK_POL_VD(channel) BIT(channel + 4)
  1979. #define TW5864_INDIR_CLK0_SEL 0xefe
  1980. #define TW5864_INDIR_CLK0_SEL_VD_SHIFT 0
  1981. #define TW5864_INDIR_CLK0_SEL_VD_MASK 0x3
  1982. #define TW5864_INDIR_CLK0_SEL_PV_SHIFT 2
  1983. #define TW5864_INDIR_CLK0_SEL_PV_MASK (0x3 << 2)
  1984. #define TW5864_INDIR_CLK0_SEL_PV2_SHIFT 4
  1985. #define TW5864_INDIR_CLK0_SEL_PV2_MASK (0x3 << 4)