jpeg-regs.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /* linux/drivers/media/platform/s5p-jpeg/jpeg-regs.h
  2. *
  3. * Register definition file for Samsung JPEG codec driver
  4. *
  5. * Copyright (c) 2011-2014 Samsung Electronics Co., Ltd.
  6. * http://www.samsung.com
  7. *
  8. * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
  9. * Author: Jacek Anaszewski <j.anaszewski@samsung.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #ifndef JPEG_REGS_H_
  16. #define JPEG_REGS_H_
  17. /* Register and bit definitions for S5PC210 */
  18. /* JPEG mode register */
  19. #define S5P_JPGMOD 0x00
  20. #define S5P_PROC_MODE_MASK (0x1 << 3)
  21. #define S5P_PROC_MODE_DECOMPR (0x1 << 3)
  22. #define S5P_PROC_MODE_COMPR (0x0 << 3)
  23. #define S5P_SUBSAMPLING_MODE_MASK 0x7
  24. #define S5P_SUBSAMPLING_MODE_444 (0x0 << 0)
  25. #define S5P_SUBSAMPLING_MODE_422 (0x1 << 0)
  26. #define S5P_SUBSAMPLING_MODE_420 (0x2 << 0)
  27. #define S5P_SUBSAMPLING_MODE_GRAY (0x3 << 0)
  28. /* JPEG operation status register */
  29. #define S5P_JPGOPR 0x04
  30. /* Quantization tables*/
  31. #define S5P_JPG_QTBL 0x08
  32. #define S5P_QT_NUMt_SHIFT(t) (((t) - 1) << 1)
  33. #define S5P_QT_NUMt_MASK(t) (0x3 << S5P_QT_NUMt_SHIFT(t))
  34. /* Huffman tables */
  35. #define S5P_JPG_HTBL 0x0c
  36. #define S5P_HT_NUMt_AC_SHIFT(t) (((t) << 1) - 1)
  37. #define S5P_HT_NUMt_AC_MASK(t) (0x1 << S5P_HT_NUMt_AC_SHIFT(t))
  38. #define S5P_HT_NUMt_DC_SHIFT(t) (((t) - 1) << 1)
  39. #define S5P_HT_NUMt_DC_MASK(t) (0x1 << S5P_HT_NUMt_DC_SHIFT(t))
  40. /* JPEG restart interval register upper byte */
  41. #define S5P_JPGDRI_U 0x10
  42. /* JPEG restart interval register lower byte */
  43. #define S5P_JPGDRI_L 0x14
  44. /* JPEG vertical resolution register upper byte */
  45. #define S5P_JPGY_U 0x18
  46. /* JPEG vertical resolution register lower byte */
  47. #define S5P_JPGY_L 0x1c
  48. /* JPEG horizontal resolution register upper byte */
  49. #define S5P_JPGX_U 0x20
  50. /* JPEG horizontal resolution register lower byte */
  51. #define S5P_JPGX_L 0x24
  52. /* JPEG byte count register upper byte */
  53. #define S5P_JPGCNT_U 0x28
  54. /* JPEG byte count register middle byte */
  55. #define S5P_JPGCNT_M 0x2c
  56. /* JPEG byte count register lower byte */
  57. #define S5P_JPGCNT_L 0x30
  58. /* JPEG interrupt setting register */
  59. #define S5P_JPGINTSE 0x34
  60. #define S5P_RSTm_INT_EN_MASK (0x1 << 7)
  61. #define S5P_RSTm_INT_EN (0x1 << 7)
  62. #define S5P_DATA_NUM_INT_EN_MASK (0x1 << 6)
  63. #define S5P_DATA_NUM_INT_EN (0x1 << 6)
  64. #define S5P_FINAL_MCU_NUM_INT_EN_MASK (0x1 << 5)
  65. #define S5P_FINAL_MCU_NUM_INT_EN (0x1 << 5)
  66. /* JPEG interrupt status register */
  67. #define S5P_JPGINTST 0x38
  68. #define S5P_RESULT_STAT_SHIFT 6
  69. #define S5P_RESULT_STAT_MASK (0x1 << S5P_RESULT_STAT_SHIFT)
  70. #define S5P_STREAM_STAT_SHIFT 5
  71. #define S5P_STREAM_STAT_MASK (0x1 << S5P_STREAM_STAT_SHIFT)
  72. /* JPEG command register */
  73. #define S5P_JPGCOM 0x4c
  74. #define S5P_INT_RELEASE (0x1 << 2)
  75. /* Raw image data r/w address register */
  76. #define S5P_JPG_IMGADR 0x50
  77. /* JPEG file r/w address register */
  78. #define S5P_JPG_JPGADR 0x58
  79. /* Coefficient for RGB-to-YCbCr converter register */
  80. #define S5P_JPG_COEF(n) (0x5c + (((n) - 1) << 2))
  81. #define S5P_COEFn_SHIFT(j) ((3 - (j)) << 3)
  82. #define S5P_COEFn_MASK(j) (0xff << S5P_COEFn_SHIFT(j))
  83. /* JPEG color mode register */
  84. #define S5P_JPGCMOD 0x68
  85. #define S5P_MOD_SEL_MASK (0x7 << 5)
  86. #define S5P_MOD_SEL_422 (0x1 << 5)
  87. #define S5P_MOD_SEL_565 (0x2 << 5)
  88. #define S5P_MODE_Y16_MASK (0x1 << 1)
  89. #define S5P_MODE_Y16 (0x1 << 1)
  90. /* JPEG clock control register */
  91. #define S5P_JPGCLKCON 0x6c
  92. #define S5P_CLK_DOWN_READY (0x1 << 1)
  93. #define S5P_POWER_ON (0x1 << 0)
  94. /* JPEG start register */
  95. #define S5P_JSTART 0x70
  96. /* JPEG SW reset register */
  97. #define S5P_JPG_SW_RESET 0x78
  98. /* JPEG timer setting register */
  99. #define S5P_JPG_TIMER_SE 0x7c
  100. #define S5P_TIMER_INT_EN_MASK (0x1 << 31)
  101. #define S5P_TIMER_INT_EN (0x1 << 31)
  102. #define S5P_TIMER_INIT_MASK 0x7fffffff
  103. /* JPEG timer status register */
  104. #define S5P_JPG_TIMER_ST 0x80
  105. #define S5P_TIMER_INT_STAT_SHIFT 31
  106. #define S5P_TIMER_INT_STAT_MASK (0x1 << S5P_TIMER_INT_STAT_SHIFT)
  107. #define S5P_TIMER_CNT_SHIFT 0
  108. #define S5P_TIMER_CNT_MASK 0x7fffffff
  109. /* JPEG decompression output format register */
  110. #define S5P_JPG_OUTFORM 0x88
  111. #define S5P_DEC_OUT_FORMAT_MASK (0x1 << 0)
  112. #define S5P_DEC_OUT_FORMAT_422 (0x0 << 0)
  113. #define S5P_DEC_OUT_FORMAT_420 (0x1 << 0)
  114. /* JPEG version register */
  115. #define S5P_JPG_VERSION 0x8c
  116. /* JPEG compressed stream size interrupt setting register */
  117. #define S5P_JPG_ENC_STREAM_INTSE 0x98
  118. #define S5P_ENC_STREAM_INT_MASK (0x1 << 24)
  119. #define S5P_ENC_STREAM_INT_EN (0x1 << 24)
  120. #define S5P_ENC_STREAM_BOUND_MASK 0xffffff
  121. /* JPEG compressed stream size interrupt status register */
  122. #define S5P_JPG_ENC_STREAM_INTST 0x9c
  123. #define S5P_ENC_STREAM_INT_STAT_MASK 0x1
  124. /* JPEG quantizer table register */
  125. #define S5P_JPG_QTBL_CONTENT(n) (0x400 + (n) * 0x100)
  126. /* JPEG DC Huffman table register */
  127. #define S5P_JPG_HDCTBL(n) (0x800 + (n) * 0x400)
  128. /* JPEG DC Huffman table register */
  129. #define S5P_JPG_HDCTBLG(n) (0x840 + (n) * 0x400)
  130. /* JPEG AC Huffman table register */
  131. #define S5P_JPG_HACTBL(n) (0x880 + (n) * 0x400)
  132. /* JPEG AC Huffman table register */
  133. #define S5P_JPG_HACTBLG(n) (0x8c0 + (n) * 0x400)
  134. /* Register and bit definitions for Exynos 4x12 */
  135. /* JPEG Codec Control Registers */
  136. #define EXYNOS4_JPEG_CNTL_REG 0x00
  137. #define EXYNOS4_INT_EN_REG 0x04
  138. #define EXYNOS4_INT_TIMER_COUNT_REG 0x08
  139. #define EXYNOS4_INT_STATUS_REG 0x0c
  140. #define EXYNOS4_OUT_MEM_BASE_REG 0x10
  141. #define EXYNOS4_JPEG_IMG_SIZE_REG 0x14
  142. #define EXYNOS4_IMG_BA_PLANE_1_REG 0x18
  143. #define EXYNOS4_IMG_SO_PLANE_1_REG 0x1c
  144. #define EXYNOS4_IMG_PO_PLANE_1_REG 0x20
  145. #define EXYNOS4_IMG_BA_PLANE_2_REG 0x24
  146. #define EXYNOS4_IMG_SO_PLANE_2_REG 0x28
  147. #define EXYNOS4_IMG_PO_PLANE_2_REG 0x2c
  148. #define EXYNOS4_IMG_BA_PLANE_3_REG 0x30
  149. #define EXYNOS4_IMG_SO_PLANE_3_REG 0x34
  150. #define EXYNOS4_IMG_PO_PLANE_3_REG 0x38
  151. #define EXYNOS4_TBL_SEL_REG 0x3c
  152. #define EXYNOS4_IMG_FMT_REG 0x40
  153. #define EXYNOS4_BITSTREAM_SIZE_REG 0x44
  154. #define EXYNOS4_PADDING_REG 0x48
  155. #define EXYNOS4_HUFF_CNT_REG 0x4c
  156. #define EXYNOS4_FIFO_STATUS_REG 0x50
  157. #define EXYNOS4_DECODE_XY_SIZE_REG 0x54
  158. #define EXYNOS4_DECODE_IMG_FMT_REG 0x58
  159. #define EXYNOS4_QUAN_TBL_ENTRY_REG 0x100
  160. #define EXYNOS4_HUFF_TBL_ENTRY_REG 0x200
  161. /****************************************************************/
  162. /* Bit definition part */
  163. /****************************************************************/
  164. /* JPEG CNTL Register bit */
  165. #define EXYNOS4_ENC_DEC_MODE_MASK (0xfffffffc << 0)
  166. #define EXYNOS4_DEC_MODE (1 << 0)
  167. #define EXYNOS4_ENC_MODE (1 << 1)
  168. #define EXYNOS4_AUTO_RST_MARKER (1 << 2)
  169. #define EXYNOS4_RST_INTERVAL_SHIFT 3
  170. #define EXYNOS4_RST_INTERVAL(x) (((x) & 0xffff) \
  171. << EXYNOS4_RST_INTERVAL_SHIFT)
  172. #define EXYNOS4_HUF_TBL_EN (1 << 19)
  173. #define EXYNOS4_HOR_SCALING_SHIFT 20
  174. #define EXYNOS4_HOR_SCALING_MASK (3 << EXYNOS4_HOR_SCALING_SHIFT)
  175. #define EXYNOS4_HOR_SCALING(x) (((x) & 0x3) \
  176. << EXYNOS4_HOR_SCALING_SHIFT)
  177. #define EXYNOS4_VER_SCALING_SHIFT 22
  178. #define EXYNOS4_VER_SCALING_MASK (3 << EXYNOS4_VER_SCALING_SHIFT)
  179. #define EXYNOS4_VER_SCALING(x) (((x) & 0x3) \
  180. << EXYNOS4_VER_SCALING_SHIFT)
  181. #define EXYNOS4_PADDING (1 << 27)
  182. #define EXYNOS4_SYS_INT_EN (1 << 28)
  183. #define EXYNOS4_SOFT_RESET_HI (1 << 29)
  184. /* JPEG INT Register bit */
  185. #define EXYNOS4_INT_EN_MASK (0x1f << 0)
  186. #define EXYNOS5433_INT_EN_MASK (0x1ff << 0)
  187. #define EXYNOS4_PROT_ERR_INT_EN (1 << 0)
  188. #define EXYNOS4_IMG_COMPLETION_INT_EN (1 << 1)
  189. #define EXYNOS4_DEC_INVALID_FORMAT_EN (1 << 2)
  190. #define EXYNOS4_MULTI_SCAN_ERROR_EN (1 << 3)
  191. #define EXYNOS4_FRAME_ERR_EN (1 << 4)
  192. #define EXYNOS4_INT_EN_ALL (0x1f << 0)
  193. #define EXYNOS5433_INT_EN_ALL (0x1b6 << 0)
  194. #define EXYNOS4_MOD_REG_PROC_ENC (0 << 3)
  195. #define EXYNOS4_MOD_REG_PROC_DEC (1 << 3)
  196. #define EXYNOS4_MOD_REG_SUBSAMPLE_444 (0 << 0)
  197. #define EXYNOS4_MOD_REG_SUBSAMPLE_422 (1 << 0)
  198. #define EXYNOS4_MOD_REG_SUBSAMPLE_420 (2 << 0)
  199. #define EXYNOS4_MOD_REG_SUBSAMPLE_GRAY (3 << 0)
  200. /* JPEG IMAGE SIZE Register bit */
  201. #define EXYNOS4_X_SIZE_SHIFT 0
  202. #define EXYNOS4_X_SIZE_MASK (0xffff << EXYNOS4_X_SIZE_SHIFT)
  203. #define EXYNOS4_X_SIZE(x) (((x) & 0xffff) << EXYNOS4_X_SIZE_SHIFT)
  204. #define EXYNOS4_Y_SIZE_SHIFT 16
  205. #define EXYNOS4_Y_SIZE_MASK (0xffff << EXYNOS4_Y_SIZE_SHIFT)
  206. #define EXYNOS4_Y_SIZE(x) (((x) & 0xffff) << EXYNOS4_Y_SIZE_SHIFT)
  207. /* JPEG IMAGE FORMAT Register bit */
  208. #define EXYNOS4_ENC_IN_FMT_MASK 0xffff0000
  209. #define EXYNOS4_ENC_GRAY_IMG (0 << 0)
  210. #define EXYNOS4_ENC_RGB_IMG (1 << 0)
  211. #define EXYNOS4_ENC_YUV_444_IMG (2 << 0)
  212. #define EXYNOS4_ENC_YUV_422_IMG (3 << 0)
  213. #define EXYNOS4_ENC_YUV_440_IMG (4 << 0)
  214. #define EXYNOS4_DEC_GRAY_IMG (0 << 0)
  215. #define EXYNOS4_DEC_RGB_IMG (1 << 0)
  216. #define EXYNOS4_DEC_YUV_444_IMG (2 << 0)
  217. #define EXYNOS4_DEC_YUV_422_IMG (3 << 0)
  218. #define EXYNOS4_DEC_YUV_420_IMG (4 << 0)
  219. #define EXYNOS4_GRAY_IMG_IP_SHIFT 3
  220. #define EXYNOS4_GRAY_IMG_IP_MASK (7 << EXYNOS4_GRAY_IMG_IP_SHIFT)
  221. #define EXYNOS4_GRAY_IMG_IP (4 << EXYNOS4_GRAY_IMG_IP_SHIFT)
  222. #define EXYNOS4_RGB_IP_SHIFT 6
  223. #define EXYNOS4_RGB_IP_MASK (7 << EXYNOS4_RGB_IP_SHIFT)
  224. #define EXYNOS4_RGB_IP_RGB_16BIT_IMG (4 << EXYNOS4_RGB_IP_SHIFT)
  225. #define EXYNOS4_RGB_IP_RGB_32BIT_IMG (5 << EXYNOS4_RGB_IP_SHIFT)
  226. #define EXYNOS4_YUV_444_IP_SHIFT 9
  227. #define EXYNOS4_YUV_444_IP_MASK (7 << EXYNOS4_YUV_444_IP_SHIFT)
  228. #define EXYNOS4_YUV_444_IP_YUV_444_2P_IMG (4 << EXYNOS4_YUV_444_IP_SHIFT)
  229. #define EXYNOS4_YUV_444_IP_YUV_444_3P_IMG (5 << EXYNOS4_YUV_444_IP_SHIFT)
  230. #define EXYNOS4_YUV_422_IP_SHIFT 12
  231. #define EXYNOS4_YUV_422_IP_MASK (7 << EXYNOS4_YUV_422_IP_SHIFT)
  232. #define EXYNOS4_YUV_422_IP_YUV_422_1P_IMG (4 << EXYNOS4_YUV_422_IP_SHIFT)
  233. #define EXYNOS4_YUV_422_IP_YUV_422_2P_IMG (5 << EXYNOS4_YUV_422_IP_SHIFT)
  234. #define EXYNOS4_YUV_422_IP_YUV_422_3P_IMG (6 << EXYNOS4_YUV_422_IP_SHIFT)
  235. #define EXYNOS4_YUV_420_IP_SHIFT 15
  236. #define EXYNOS4_YUV_420_IP_MASK (7 << EXYNOS4_YUV_420_IP_SHIFT)
  237. #define EXYNOS4_YUV_420_IP_YUV_420_2P_IMG (4 << EXYNOS4_YUV_420_IP_SHIFT)
  238. #define EXYNOS4_YUV_420_IP_YUV_420_3P_IMG (5 << EXYNOS4_YUV_420_IP_SHIFT)
  239. #define EXYNOS4_ENC_FMT_SHIFT 24
  240. #define EXYNOS4_ENC_FMT_MASK (3 << EXYNOS4_ENC_FMT_SHIFT)
  241. #define EXYNOS5433_ENC_FMT_MASK (7 << EXYNOS4_ENC_FMT_SHIFT)
  242. #define EXYNOS4_ENC_FMT_GRAY (0 << EXYNOS4_ENC_FMT_SHIFT)
  243. #define EXYNOS4_ENC_FMT_YUV_444 (1 << EXYNOS4_ENC_FMT_SHIFT)
  244. #define EXYNOS4_ENC_FMT_YUV_422 (2 << EXYNOS4_ENC_FMT_SHIFT)
  245. #define EXYNOS4_ENC_FMT_YUV_420 (3 << EXYNOS4_ENC_FMT_SHIFT)
  246. #define EXYNOS4_JPEG_DECODED_IMG_FMT_MASK 0x03
  247. #define EXYNOS4_SWAP_CHROMA_CRCB (1 << 26)
  248. #define EXYNOS4_SWAP_CHROMA_CBCR (0 << 26)
  249. #define EXYNOS5433_SWAP_CHROMA_CRCB (1 << 27)
  250. #define EXYNOS5433_SWAP_CHROMA_CBCR (0 << 27)
  251. /* JPEG HUFF count Register bit */
  252. #define EXYNOS4_HUFF_COUNT_MASK 0xffff
  253. /* JPEG Decoded_img_x_y_size Register bit */
  254. #define EXYNOS4_DECODED_SIZE_MASK 0x0000ffff
  255. /* JPEG Decoded image format Register bit */
  256. #define EXYNOS4_DECODED_IMG_FMT_MASK 0x3
  257. /* JPEG TBL SEL Register bit */
  258. #define EXYNOS4_Q_TBL_COMP(c, n) ((n) << (((c) - 1) << 1))
  259. #define EXYNOS4_Q_TBL_COMP1_0 EXYNOS4_Q_TBL_COMP(1, 0)
  260. #define EXYNOS4_Q_TBL_COMP1_1 EXYNOS4_Q_TBL_COMP(1, 1)
  261. #define EXYNOS4_Q_TBL_COMP1_2 EXYNOS4_Q_TBL_COMP(1, 2)
  262. #define EXYNOS4_Q_TBL_COMP1_3 EXYNOS4_Q_TBL_COMP(1, 3)
  263. #define EXYNOS4_Q_TBL_COMP2_0 EXYNOS4_Q_TBL_COMP(2, 0)
  264. #define EXYNOS4_Q_TBL_COMP2_1 EXYNOS4_Q_TBL_COMP(2, 1)
  265. #define EXYNOS4_Q_TBL_COMP2_2 EXYNOS4_Q_TBL_COMP(2, 2)
  266. #define EXYNOS4_Q_TBL_COMP2_3 EXYNOS4_Q_TBL_COMP(2, 3)
  267. #define EXYNOS4_Q_TBL_COMP3_0 EXYNOS4_Q_TBL_COMP(3, 0)
  268. #define EXYNOS4_Q_TBL_COMP3_1 EXYNOS4_Q_TBL_COMP(3, 1)
  269. #define EXYNOS4_Q_TBL_COMP3_2 EXYNOS4_Q_TBL_COMP(3, 2)
  270. #define EXYNOS4_Q_TBL_COMP3_3 EXYNOS4_Q_TBL_COMP(3, 3)
  271. #define EXYNOS4_HUFF_TBL_COMP(c, n) ((n) << ((((c) - 1) << 1) + 6))
  272. #define EXYNOS4_HUFF_TBL_COMP1_AC_0_DC_0 \
  273. EXYNOS4_HUFF_TBL_COMP(1, 0)
  274. #define EXYNOS4_HUFF_TBL_COMP1_AC_0_DC_1 \
  275. EXYNOS4_HUFF_TBL_COMP(1, 1)
  276. #define EXYNOS4_HUFF_TBL_COMP1_AC_1_DC_0 \
  277. EXYNOS4_HUFF_TBL_COMP(1, 2)
  278. #define EXYNOS4_HUFF_TBL_COMP1_AC_1_DC_1 \
  279. EXYNOS4_HUFF_TBL_COMP(1, 3)
  280. #define EXYNOS4_HUFF_TBL_COMP2_AC_0_DC_0 \
  281. EXYNOS4_HUFF_TBL_COMP(2, 0)
  282. #define EXYNOS4_HUFF_TBL_COMP2_AC_0_DC_1 \
  283. EXYNOS4_HUFF_TBL_COMP(2, 1)
  284. #define EXYNOS4_HUFF_TBL_COMP2_AC_1_DC_0 \
  285. EXYNOS4_HUFF_TBL_COMP(2, 2)
  286. #define EXYNOS4_HUFF_TBL_COMP2_AC_1_DC_1 \
  287. EXYNOS4_HUFF_TBL_COMP(2, 3)
  288. #define EXYNOS4_HUFF_TBL_COMP3_AC_0_DC_0 \
  289. EXYNOS4_HUFF_TBL_COMP(3, 0)
  290. #define EXYNOS4_HUFF_TBL_COMP3_AC_0_DC_1 \
  291. EXYNOS4_HUFF_TBL_COMP(3, 1)
  292. #define EXYNOS4_HUFF_TBL_COMP3_AC_1_DC_0 \
  293. EXYNOS4_HUFF_TBL_COMP(3, 2)
  294. #define EXYNOS4_HUFF_TBL_COMP3_AC_1_DC_1 \
  295. EXYNOS4_HUFF_TBL_COMP(3, 3)
  296. #define EXYNOS4_NF_SHIFT 16
  297. #define EXYNOS4_NF_MASK 0xff
  298. #define EXYNOS4_NF(x) \
  299. (((x) << EXYNOS4_NF_SHIFT) & EXYNOS4_NF_MASK)
  300. /* JPEG quantizer table register */
  301. #define EXYNOS4_QTBL_CONTENT(n) (0x100 + (n) * 0x40)
  302. /* JPEG DC luminance (code length) Huffman table register */
  303. #define EXYNOS4_HUFF_TBL_HDCLL 0x200
  304. /* JPEG DC luminance (values) Huffman table register */
  305. #define EXYNOS4_HUFF_TBL_HDCLV 0x210
  306. /* JPEG DC chrominance (code length) Huffman table register */
  307. #define EXYNOS4_HUFF_TBL_HDCCL 0x220
  308. /* JPEG DC chrominance (values) Huffman table register */
  309. #define EXYNOS4_HUFF_TBL_HDCCV 0x230
  310. /* JPEG AC luminance (code length) Huffman table register */
  311. #define EXYNOS4_HUFF_TBL_HACLL 0x240
  312. /* JPEG AC luminance (values) Huffman table register */
  313. #define EXYNOS4_HUFF_TBL_HACLV 0x250
  314. /* JPEG AC chrominance (code length) Huffman table register */
  315. #define EXYNOS4_HUFF_TBL_HACCL 0x300
  316. /* JPEG AC chrominance (values) Huffman table register */
  317. #define EXYNOS4_HUFF_TBL_HACCV 0x310
  318. /* Register and bit definitions for Exynos 3250 */
  319. /* JPEG mode register */
  320. #define EXYNOS3250_JPGMOD 0x00
  321. #define EXYNOS3250_PROC_MODE_MASK (0x1 << 3)
  322. #define EXYNOS3250_PROC_MODE_DECOMPR (0x1 << 3)
  323. #define EXYNOS3250_PROC_MODE_COMPR (0x0 << 3)
  324. #define EXYNOS3250_SUBSAMPLING_MODE_MASK (0x7 << 0)
  325. #define EXYNOS3250_SUBSAMPLING_MODE_444 (0x0 << 0)
  326. #define EXYNOS3250_SUBSAMPLING_MODE_422 (0x1 << 0)
  327. #define EXYNOS3250_SUBSAMPLING_MODE_420 (0x2 << 0)
  328. #define EXYNOS3250_SUBSAMPLING_MODE_411 (0x6 << 0)
  329. #define EXYNOS3250_SUBSAMPLING_MODE_GRAY (0x3 << 0)
  330. /* JPEG operation status register */
  331. #define EXYNOS3250_JPGOPR 0x04
  332. #define EXYNOS3250_JPGOPR_MASK 0x01
  333. /* Quantization and Huffman tables register */
  334. #define EXYNOS3250_QHTBL 0x08
  335. #define EXYNOS3250_QT_NUM_SHIFT(t) ((((t) - 1) << 1) + 8)
  336. #define EXYNOS3250_QT_NUM_MASK(t) (0x3 << EXYNOS3250_QT_NUM_SHIFT(t))
  337. /* Huffman tables */
  338. #define EXYNOS3250_HT_NUM_AC_SHIFT(t) (((t) << 1) - 1)
  339. #define EXYNOS3250_HT_NUM_AC_MASK(t) (0x1 << EXYNOS3250_HT_NUM_AC_SHIFT(t))
  340. #define EXYNOS3250_HT_NUM_DC_SHIFT(t) (((t) - 1) << 1)
  341. #define EXYNOS3250_HT_NUM_DC_MASK(t) (0x1 << EXYNOS3250_HT_NUM_DC_SHIFT(t))
  342. /* JPEG restart interval register */
  343. #define EXYNOS3250_JPGDRI 0x0c
  344. #define EXYNOS3250_JPGDRI_MASK 0xffff
  345. /* JPEG vertical resolution register */
  346. #define EXYNOS3250_JPGY 0x10
  347. #define EXYNOS3250_JPGY_MASK 0xffff
  348. /* JPEG horizontal resolution register */
  349. #define EXYNOS3250_JPGX 0x14
  350. #define EXYNOS3250_JPGX_MASK 0xffff
  351. /* JPEG byte count register */
  352. #define EXYNOS3250_JPGCNT 0x18
  353. #define EXYNOS3250_JPGCNT_MASK 0xffffff
  354. /* JPEG interrupt mask register */
  355. #define EXYNOS3250_JPGINTSE 0x1c
  356. #define EXYNOS3250_JPEG_DONE_EN (1 << 11)
  357. #define EXYNOS3250_WDMA_DONE_EN (1 << 10)
  358. #define EXYNOS3250_RDMA_DONE_EN (1 << 9)
  359. #define EXYNOS3250_ENC_STREAM_INT_EN (1 << 8)
  360. #define EXYNOS3250_CORE_DONE_EN (1 << 5)
  361. #define EXYNOS3250_ERR_INT_EN (1 << 4)
  362. #define EXYNOS3250_HEAD_INT_EN (1 << 3)
  363. /* JPEG interrupt status register */
  364. #define EXYNOS3250_JPGINTST 0x20
  365. #define EXYNOS3250_JPEG_DONE (1 << 11)
  366. #define EXYNOS3250_WDMA_DONE (1 << 10)
  367. #define EXYNOS3250_RDMA_DONE (1 << 9)
  368. #define EXYNOS3250_ENC_STREAM_STAT (1 << 8)
  369. #define EXYNOS3250_RESULT_STAT (1 << 5)
  370. #define EXYNOS3250_STREAM_STAT (1 << 4)
  371. #define EXYNOS3250_HEADER_STAT (1 << 3)
  372. /*
  373. * Base address of the luma component DMA buffer
  374. * of the raw input or output image.
  375. */
  376. #define EXYNOS3250_LUMA_BASE 0x100
  377. #define EXYNOS3250_SRC_TILE_EN_MASK 0x100
  378. /* Stride of source or destination luma raw image buffer */
  379. #define EXYNOS3250_LUMA_STRIDE 0x104
  380. /* Horizontal/vertical offset of active region in luma raw image buffer */
  381. #define EXYNOS3250_LUMA_XY_OFFSET 0x108
  382. #define EXYNOS3250_LUMA_YY_OFFSET_SHIFT 18
  383. #define EXYNOS3250_LUMA_YY_OFFSET_MASK (0x1fff << EXYNOS3250_LUMA_YY_OFFSET_SHIFT)
  384. #define EXYNOS3250_LUMA_YX_OFFSET_SHIFT 2
  385. #define EXYNOS3250_LUMA_YX_OFFSET_MASK (0x1fff << EXYNOS3250_LUMA_YX_OFFSET_SHIFT)
  386. /*
  387. * Base address of the chroma(Cb) component DMA buffer
  388. * of the raw input or output image.
  389. */
  390. #define EXYNOS3250_CHROMA_BASE 0x10c
  391. /* Stride of source or destination chroma(Cb) raw image buffer */
  392. #define EXYNOS3250_CHROMA_STRIDE 0x110
  393. /* Horizontal/vertical offset of active region in chroma(Cb) raw image buffer */
  394. #define EXYNOS3250_CHROMA_XY_OFFSET 0x114
  395. #define EXYNOS3250_CHROMA_YY_OFFSET_SHIFT 18
  396. #define EXYNOS3250_CHROMA_YY_OFFSET_MASK (0x1fff << EXYNOS3250_CHROMA_YY_OFFSET_SHIFT)
  397. #define EXYNOS3250_CHROMA_YX_OFFSET_SHIFT 2
  398. #define EXYNOS3250_CHROMA_YX_OFFSET_MASK (0x1fff << EXYNOS3250_CHROMA_YX_OFFSET_SHIFT)
  399. /*
  400. * Base address of the chroma(Cr) component DMA buffer
  401. * of the raw input or output image.
  402. */
  403. #define EXYNOS3250_CHROMA_CR_BASE 0x118
  404. /* Stride of source or destination chroma(Cr) raw image buffer */
  405. #define EXYNOS3250_CHROMA_CR_STRIDE 0x11c
  406. /* Horizontal/vertical offset of active region in chroma(Cb) raw image buffer */
  407. #define EXYNOS3250_CHROMA_CR_XY_OFFSET 0x120
  408. #define EXYNOS3250_CHROMA_CR_YY_OFFSET_SHIFT 18
  409. #define EXYNOS3250_CHROMA_CR_YY_OFFSET_MASK (0x1fff << EXYNOS3250_CHROMA_CR_YY_OFFSET_SHIFT)
  410. #define EXYNOS3250_CHROMA_CR_YX_OFFSET_SHIFT 2
  411. #define EXYNOS3250_CHROMA_CR_YX_OFFSET_MASK (0x1fff << EXYNOS3250_CHROMA_CR_YX_OFFSET_SHIFT)
  412. /* Raw image data r/w address register */
  413. #define EXYNOS3250_JPG_IMGADR 0x50
  414. /* Source or destination JPEG file DMA buffer address */
  415. #define EXYNOS3250_JPG_JPGADR 0x124
  416. /* Coefficients for RGB-to-YCbCr converter register */
  417. #define EXYNOS3250_JPG_COEF(n) (0x128 + (((n) - 1) << 2))
  418. #define EXYNOS3250_COEF_SHIFT(j) ((3 - (j)) << 3)
  419. #define EXYNOS3250_COEF_MASK(j) (0xff << EXYNOS3250_COEF_SHIFT(j))
  420. /* Raw input format setting */
  421. #define EXYNOS3250_JPGCMOD 0x134
  422. #define EXYNOS3250_SRC_TILE_EN (0x1 << 10)
  423. #define EXYNOS3250_SRC_NV_MASK (0x1 << 9)
  424. #define EXYNOS3250_SRC_NV12 (0x0 << 9)
  425. #define EXYNOS3250_SRC_NV21 (0x1 << 9)
  426. #define EXYNOS3250_SRC_BIG_ENDIAN_MASK (0x1 << 8)
  427. #define EXYNOS3250_SRC_BIG_ENDIAN (0x1 << 8)
  428. #define EXYNOS3250_MODE_SEL_MASK (0x7 << 5)
  429. #define EXYNOS3250_MODE_SEL_420_2P (0x0 << 5)
  430. #define EXYNOS3250_MODE_SEL_422_1P_LUM_CHR (0x1 << 5)
  431. #define EXYNOS3250_MODE_SEL_RGB565 (0x2 << 5)
  432. #define EXYNOS3250_MODE_SEL_422_1P_CHR_LUM (0x3 << 5)
  433. #define EXYNOS3250_MODE_SEL_ARGB8888 (0x4 << 5)
  434. #define EXYNOS3250_MODE_SEL_420_3P (0x5 << 5)
  435. #define EXYNOS3250_SRC_SWAP_RGB (0x1 << 3)
  436. #define EXYNOS3250_SRC_SWAP_UV (0x1 << 2)
  437. #define EXYNOS3250_MODE_Y16_MASK (0x1 << 1)
  438. #define EXYNOS3250_MODE_Y16 (0x1 << 1)
  439. #define EXYNOS3250_HALF_EN_MASK (0x1 << 0)
  440. #define EXYNOS3250_HALF_EN (0x1 << 0)
  441. /* Power on/off and clock down control */
  442. #define EXYNOS3250_JPGCLKCON 0x138
  443. #define EXYNOS3250_CLK_DOWN_READY (0x1 << 1)
  444. #define EXYNOS3250_POWER_ON (0x1 << 0)
  445. /* Start compression or decompression */
  446. #define EXYNOS3250_JSTART 0x13c
  447. /* Restart decompression after header analysis */
  448. #define EXYNOS3250_JRSTART 0x140
  449. /* JPEG SW reset register */
  450. #define EXYNOS3250_SW_RESET 0x144
  451. /* JPEG timer setting register */
  452. #define EXYNOS3250_TIMER_SE 0x148
  453. #define EXYNOS3250_TIMER_INT_EN_SHIFT 31
  454. #define EXYNOS3250_TIMER_INT_EN (1 << EXYNOS3250_TIMER_INT_EN_SHIFT)
  455. #define EXYNOS3250_TIMER_INIT_MASK 0x7fffffff
  456. /* JPEG timer status register */
  457. #define EXYNOS3250_TIMER_ST 0x14c
  458. #define EXYNOS3250_TIMER_INT_STAT_SHIFT 31
  459. #define EXYNOS3250_TIMER_INT_STAT (1 << EXYNOS3250_TIMER_INT_STAT_SHIFT)
  460. #define EXYNOS3250_TIMER_CNT_SHIFT 0
  461. #define EXYNOS3250_TIMER_CNT_MASK 0x7fffffff
  462. /* Command status register */
  463. #define EXYNOS3250_COMSTAT 0x150
  464. #define EXYNOS3250_CUR_PROC_MODE (0x1 << 1)
  465. #define EXYNOS3250_CUR_COM_MODE (0x1 << 0)
  466. /* JPEG decompression output format register */
  467. #define EXYNOS3250_OUTFORM 0x154
  468. #define EXYNOS3250_OUT_ALPHA_MASK (0xff << 24)
  469. #define EXYNOS3250_OUT_TILE_EN (0x1 << 10)
  470. #define EXYNOS3250_OUT_NV_MASK (0x1 << 9)
  471. #define EXYNOS3250_OUT_NV12 (0x0 << 9)
  472. #define EXYNOS3250_OUT_NV21 (0x1 << 9)
  473. #define EXYNOS3250_OUT_BIG_ENDIAN_MASK (0x1 << 8)
  474. #define EXYNOS3250_OUT_BIG_ENDIAN (0x1 << 8)
  475. #define EXYNOS3250_OUT_SWAP_RGB (0x1 << 7)
  476. #define EXYNOS3250_OUT_SWAP_UV (0x1 << 6)
  477. #define EXYNOS3250_OUT_FMT_MASK (0x7 << 0)
  478. #define EXYNOS3250_OUT_FMT_420_2P (0x0 << 0)
  479. #define EXYNOS3250_OUT_FMT_422_1P_LUM_CHR (0x1 << 0)
  480. #define EXYNOS3250_OUT_FMT_422_1P_CHR_LUM (0x3 << 0)
  481. #define EXYNOS3250_OUT_FMT_420_3P (0x4 << 0)
  482. #define EXYNOS3250_OUT_FMT_RGB565 (0x5 << 0)
  483. #define EXYNOS3250_OUT_FMT_ARGB8888 (0x6 << 0)
  484. /* Input JPEG stream byte size for decompression */
  485. #define EXYNOS3250_DEC_STREAM_SIZE 0x158
  486. #define EXYNOS3250_DEC_STREAM_MASK 0x1fffffff
  487. /* The upper bound of the byte size of output compressed stream */
  488. #define EXYNOS3250_ENC_STREAM_BOUND 0x15c
  489. #define EXYNOS3250_ENC_STREAM_BOUND_MASK 0xffffc0
  490. /* Scale-down ratio when decoding */
  491. #define EXYNOS3250_DEC_SCALING_RATIO 0x160
  492. #define EXYNOS3250_DEC_SCALE_FACTOR_MASK 0x3
  493. #define EXYNOS3250_DEC_SCALE_FACTOR_8_8 0x0
  494. #define EXYNOS3250_DEC_SCALE_FACTOR_4_8 0x1
  495. #define EXYNOS3250_DEC_SCALE_FACTOR_2_8 0x2
  496. #define EXYNOS3250_DEC_SCALE_FACTOR_1_8 0x3
  497. /* Error check */
  498. #define EXYNOS3250_CRC_RESULT 0x164
  499. /* RDMA and WDMA operation status register */
  500. #define EXYNOS3250_DMA_OPER_STATUS 0x168
  501. #define EXYNOS3250_WDMA_OPER_STATUS (0x1 << 1)
  502. #define EXYNOS3250_RDMA_OPER_STATUS (0x1 << 0)
  503. /* DMA issue gathering number and issue number settings */
  504. #define EXYNOS3250_DMA_ISSUE_NUM 0x16c
  505. #define EXYNOS3250_WDMA_ISSUE_NUM_SHIFT 16
  506. #define EXYNOS3250_WDMA_ISSUE_NUM_MASK (0x7 << EXYNOS3250_WDMA_ISSUE_NUM_SHIFT)
  507. #define EXYNOS3250_RDMA_ISSUE_NUM_SHIFT 8
  508. #define EXYNOS3250_RDMA_ISSUE_NUM_MASK (0x7 << EXYNOS3250_RDMA_ISSUE_NUM_SHIFT)
  509. #define EXYNOS3250_ISSUE_GATHER_NUM_SHIFT 0
  510. #define EXYNOS3250_ISSUE_GATHER_NUM_MASK (0x7 << EXYNOS3250_ISSUE_GATHER_NUM_SHIFT)
  511. #define EXYNOS3250_DMA_MO_COUNT 0x7
  512. /* Version register */
  513. #define EXYNOS3250_VERSION 0x1fc
  514. /* RGB <-> YUV conversion coefficients */
  515. #define EXYNOS3250_JPEG_ENC_COEF1 0x01352e1e
  516. #define EXYNOS3250_JPEG_ENC_COEF2 0x00b0ae83
  517. #define EXYNOS3250_JPEG_ENC_COEF3 0x020cdc13
  518. #define EXYNOS3250_JPEG_DEC_COEF1 0x04a80199
  519. #define EXYNOS3250_JPEG_DEC_COEF2 0x04a9a064
  520. #define EXYNOS3250_JPEG_DEC_COEF3 0x04a80102
  521. #endif /* JPEG_REGS_H_ */