tw5864-reg.h 64 KB

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