rga-hw.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. /*
  2. * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
  3. * Author: Jacob Chen <jacob-chen@iotwrt.com>
  4. *
  5. * This software is licensed under the terms of the GNU General Public
  6. * License version 2, as published by the Free Software Foundation, and
  7. * may be copied, distributed, and modified under those terms.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef __RGA_HW_H__
  15. #define __RGA_HW_H__
  16. #define RGA_CMDBUF_SIZE 0x20
  17. /* Hardware limits */
  18. #define MAX_WIDTH 8192
  19. #define MAX_HEIGHT 8192
  20. #define MIN_WIDTH 34
  21. #define MIN_HEIGHT 34
  22. #define DEFAULT_WIDTH 100
  23. #define DEFAULT_HEIGHT 100
  24. #define RGA_TIMEOUT 500
  25. /* Registers address */
  26. #define RGA_SYS_CTRL 0x0000
  27. #define RGA_CMD_CTRL 0x0004
  28. #define RGA_CMD_BASE 0x0008
  29. #define RGA_INT 0x0010
  30. #define RGA_MMU_CTRL0 0x0014
  31. #define RGA_VERSION_INFO 0x0028
  32. #define RGA_MODE_BASE_REG 0x0100
  33. #define RGA_MODE_MAX_REG 0x017C
  34. #define RGA_MODE_CTRL 0x0100
  35. #define RGA_SRC_INFO 0x0104
  36. #define RGA_SRC_Y_RGB_BASE_ADDR 0x0108
  37. #define RGA_SRC_CB_BASE_ADDR 0x010c
  38. #define RGA_SRC_CR_BASE_ADDR 0x0110
  39. #define RGA_SRC1_RGB_BASE_ADDR 0x0114
  40. #define RGA_SRC_VIR_INFO 0x0118
  41. #define RGA_SRC_ACT_INFO 0x011c
  42. #define RGA_SRC_X_FACTOR 0x0120
  43. #define RGA_SRC_Y_FACTOR 0x0124
  44. #define RGA_SRC_BG_COLOR 0x0128
  45. #define RGA_SRC_FG_COLOR 0x012c
  46. #define RGA_SRC_TR_COLOR0 0x0130
  47. #define RGA_SRC_TR_COLOR1 0x0134
  48. #define RGA_DST_INFO 0x0138
  49. #define RGA_DST_Y_RGB_BASE_ADDR 0x013c
  50. #define RGA_DST_CB_BASE_ADDR 0x0140
  51. #define RGA_DST_CR_BASE_ADDR 0x0144
  52. #define RGA_DST_VIR_INFO 0x0148
  53. #define RGA_DST_ACT_INFO 0x014c
  54. #define RGA_ALPHA_CTRL0 0x0150
  55. #define RGA_ALPHA_CTRL1 0x0154
  56. #define RGA_FADING_CTRL 0x0158
  57. #define RGA_PAT_CON 0x015c
  58. #define RGA_ROP_CON0 0x0160
  59. #define RGA_ROP_CON1 0x0164
  60. #define RGA_MASK_BASE 0x0168
  61. #define RGA_MMU_CTRL1 0x016C
  62. #define RGA_MMU_SRC_BASE 0x0170
  63. #define RGA_MMU_SRC1_BASE 0x0174
  64. #define RGA_MMU_DST_BASE 0x0178
  65. /* Registers value */
  66. #define RGA_MODE_RENDER_BITBLT 0
  67. #define RGA_MODE_RENDER_COLOR_PALETTE 1
  68. #define RGA_MODE_RENDER_RECTANGLE_FILL 2
  69. #define RGA_MODE_RENDER_UPDATE_PALETTE_LUT_RAM 3
  70. #define RGA_MODE_BITBLT_MODE_SRC_TO_DST 0
  71. #define RGA_MODE_BITBLT_MODE_SRC_SRC1_TO_DST 1
  72. #define RGA_MODE_CF_ROP4_SOLID 0
  73. #define RGA_MODE_CF_ROP4_PATTERN 1
  74. #define RGA_COLOR_FMT_ABGR8888 0
  75. #define RGA_COLOR_FMT_XBGR8888 1
  76. #define RGA_COLOR_FMT_RGB888 2
  77. #define RGA_COLOR_FMT_BGR565 4
  78. #define RGA_COLOR_FMT_ABGR1555 5
  79. #define RGA_COLOR_FMT_ABGR4444 6
  80. #define RGA_COLOR_FMT_YUV422SP 8
  81. #define RGA_COLOR_FMT_YUV422P 9
  82. #define RGA_COLOR_FMT_YUV420SP 10
  83. #define RGA_COLOR_FMT_YUV420P 11
  84. /* SRC_COLOR Palette */
  85. #define RGA_COLOR_FMT_CP_1BPP 12
  86. #define RGA_COLOR_FMT_CP_2BPP 13
  87. #define RGA_COLOR_FMT_CP_4BPP 14
  88. #define RGA_COLOR_FMT_CP_8BPP 15
  89. #define RGA_COLOR_FMT_MASK 15
  90. #define RGA_COLOR_NONE_SWAP 0
  91. #define RGA_COLOR_RB_SWAP 1
  92. #define RGA_COLOR_ALPHA_SWAP 2
  93. #define RGA_COLOR_UV_SWAP 4
  94. #define RGA_SRC_CSC_MODE_BYPASS 0
  95. #define RGA_SRC_CSC_MODE_BT601_R0 1
  96. #define RGA_SRC_CSC_MODE_BT601_R1 2
  97. #define RGA_SRC_CSC_MODE_BT709_R0 3
  98. #define RGA_SRC_CSC_MODE_BT709_R1 4
  99. #define RGA_SRC_ROT_MODE_0_DEGREE 0
  100. #define RGA_SRC_ROT_MODE_90_DEGREE 1
  101. #define RGA_SRC_ROT_MODE_180_DEGREE 2
  102. #define RGA_SRC_ROT_MODE_270_DEGREE 3
  103. #define RGA_SRC_MIRR_MODE_NO 0
  104. #define RGA_SRC_MIRR_MODE_X 1
  105. #define RGA_SRC_MIRR_MODE_Y 2
  106. #define RGA_SRC_MIRR_MODE_X_Y 3
  107. #define RGA_SRC_HSCL_MODE_NO 0
  108. #define RGA_SRC_HSCL_MODE_DOWN 1
  109. #define RGA_SRC_HSCL_MODE_UP 2
  110. #define RGA_SRC_VSCL_MODE_NO 0
  111. #define RGA_SRC_VSCL_MODE_DOWN 1
  112. #define RGA_SRC_VSCL_MODE_UP 2
  113. #define RGA_SRC_TRANS_ENABLE_R 1
  114. #define RGA_SRC_TRANS_ENABLE_G 2
  115. #define RGA_SRC_TRANS_ENABLE_B 4
  116. #define RGA_SRC_TRANS_ENABLE_A 8
  117. #define RGA_SRC_BIC_COE_SELEC_CATROM 0
  118. #define RGA_SRC_BIC_COE_SELEC_MITCHELL 1
  119. #define RGA_SRC_BIC_COE_SELEC_HERMITE 2
  120. #define RGA_SRC_BIC_COE_SELEC_BSPLINE 3
  121. #define RGA_DST_DITHER_MODE_888_TO_666 0
  122. #define RGA_DST_DITHER_MODE_888_TO_565 1
  123. #define RGA_DST_DITHER_MODE_888_TO_555 2
  124. #define RGA_DST_DITHER_MODE_888_TO_444 3
  125. #define RGA_DST_CSC_MODE_BYPASS 0
  126. #define RGA_DST_CSC_MODE_BT601_R0 1
  127. #define RGA_DST_CSC_MODE_BT601_R1 2
  128. #define RGA_DST_CSC_MODE_BT709_R0 3
  129. #define RGA_ALPHA_ROP_MODE_2 0
  130. #define RGA_ALPHA_ROP_MODE_3 1
  131. #define RGA_ALPHA_ROP_MODE_4 2
  132. #define RGA_ALPHA_SELECT_ALPHA 0
  133. #define RGA_ALPHA_SELECT_ROP 1
  134. #define RGA_ALPHA_MASK_BIG_ENDIAN 0
  135. #define RGA_ALPHA_MASK_LITTLE_ENDIAN 1
  136. #define RGA_ALPHA_NORMAL 0
  137. #define RGA_ALPHA_REVERSE 1
  138. #define RGA_ALPHA_BLEND_GLOBAL 0
  139. #define RGA_ALPHA_BLEND_NORMAL 1
  140. #define RGA_ALPHA_BLEND_MULTIPLY 2
  141. #define RGA_ALPHA_CAL_CUT 0
  142. #define RGA_ALPHA_CAL_NORMAL 1
  143. #define RGA_ALPHA_FACTOR_ZERO 0
  144. #define RGA_ALPHA_FACTOR_ONE 1
  145. #define RGA_ALPHA_FACTOR_OTHER 2
  146. #define RGA_ALPHA_FACTOR_OTHER_REVERSE 3
  147. #define RGA_ALPHA_FACTOR_SELF 4
  148. #define RGA_ALPHA_COLOR_NORMAL 0
  149. #define RGA_ALPHA_COLOR_MULTIPLY_CAL 1
  150. /* Registers union */
  151. union rga_mode_ctrl {
  152. unsigned int val;
  153. struct {
  154. /* [0:2] */
  155. unsigned int render:3;
  156. /* [3:6] */
  157. unsigned int bitblt:1;
  158. unsigned int cf_rop4_pat:1;
  159. unsigned int alpha_zero_key:1;
  160. unsigned int gradient_sat:1;
  161. /* [7:31] */
  162. unsigned int reserved:25;
  163. } data;
  164. };
  165. union rga_src_info {
  166. unsigned int val;
  167. struct {
  168. /* [0:3] */
  169. unsigned int format:4;
  170. /* [4:7] */
  171. unsigned int swap:3;
  172. unsigned int cp_endian:1;
  173. /* [8:17] */
  174. unsigned int csc_mode:2;
  175. unsigned int rot_mode:2;
  176. unsigned int mir_mode:2;
  177. unsigned int hscl_mode:2;
  178. unsigned int vscl_mode:2;
  179. /* [18:22] */
  180. unsigned int trans_mode:1;
  181. unsigned int trans_enable:4;
  182. /* [23:25] */
  183. unsigned int dither_up_en:1;
  184. unsigned int bic_coe_sel:2;
  185. /* [26:31] */
  186. unsigned int reserved:6;
  187. } data;
  188. };
  189. union rga_src_vir_info {
  190. unsigned int val;
  191. struct {
  192. /* [0:15] */
  193. unsigned int vir_width:15;
  194. unsigned int reserved:1;
  195. /* [16:25] */
  196. unsigned int vir_stride:10;
  197. /* [26:31] */
  198. unsigned int reserved1:6;
  199. } data;
  200. };
  201. union rga_src_act_info {
  202. unsigned int val;
  203. struct {
  204. /* [0:15] */
  205. unsigned int act_width:13;
  206. unsigned int reserved:3;
  207. /* [16:31] */
  208. unsigned int act_height:13;
  209. unsigned int reserved1:3;
  210. } data;
  211. };
  212. union rga_src_x_factor {
  213. unsigned int val;
  214. struct {
  215. /* [0:15] */
  216. unsigned int down_scale_factor:16;
  217. /* [16:31] */
  218. unsigned int up_scale_factor:16;
  219. } data;
  220. };
  221. union rga_src_y_factor {
  222. unsigned int val;
  223. struct {
  224. /* [0:15] */
  225. unsigned int down_scale_factor:16;
  226. /* [16:31] */
  227. unsigned int up_scale_factor:16;
  228. } data;
  229. };
  230. /* Alpha / Red / Green / Blue */
  231. union rga_src_cp_gr_color {
  232. unsigned int val;
  233. struct {
  234. /* [0:15] */
  235. unsigned int gradient_x:16;
  236. /* [16:31] */
  237. unsigned int gradient_y:16;
  238. } data;
  239. };
  240. union rga_src_transparency_color0 {
  241. unsigned int val;
  242. struct {
  243. /* [0:7] */
  244. unsigned int trans_rmin:8;
  245. /* [8:15] */
  246. unsigned int trans_gmin:8;
  247. /* [16:23] */
  248. unsigned int trans_bmin:8;
  249. /* [24:31] */
  250. unsigned int trans_amin:8;
  251. } data;
  252. };
  253. union rga_src_transparency_color1 {
  254. unsigned int val;
  255. struct {
  256. /* [0:7] */
  257. unsigned int trans_rmax:8;
  258. /* [8:15] */
  259. unsigned int trans_gmax:8;
  260. /* [16:23] */
  261. unsigned int trans_bmax:8;
  262. /* [24:31] */
  263. unsigned int trans_amax:8;
  264. } data;
  265. };
  266. union rga_dst_info {
  267. unsigned int val;
  268. struct {
  269. /* [0:3] */
  270. unsigned int format:4;
  271. /* [4:6] */
  272. unsigned int swap:3;
  273. /* [7:9] */
  274. unsigned int src1_format:3;
  275. /* [10:11] */
  276. unsigned int src1_swap:2;
  277. /* [12:15] */
  278. unsigned int dither_up_en:1;
  279. unsigned int dither_down_en:1;
  280. unsigned int dither_down_mode:2;
  281. /* [16:18] */
  282. unsigned int csc_mode:2;
  283. unsigned int csc_clip:1;
  284. /* [19:31] */
  285. unsigned int reserved:13;
  286. } data;
  287. };
  288. union rga_dst_vir_info {
  289. unsigned int val;
  290. struct {
  291. /* [0:15] */
  292. unsigned int vir_stride:15;
  293. unsigned int reserved:1;
  294. /* [16:31] */
  295. unsigned int src1_vir_stride:15;
  296. unsigned int reserved1:1;
  297. } data;
  298. };
  299. union rga_dst_act_info {
  300. unsigned int val;
  301. struct {
  302. /* [0:15] */
  303. unsigned int act_width:12;
  304. unsigned int reserved:4;
  305. /* [16:31] */
  306. unsigned int act_height:12;
  307. unsigned int reserved1:4;
  308. } data;
  309. };
  310. union rga_alpha_ctrl0 {
  311. unsigned int val;
  312. struct {
  313. /* [0:3] */
  314. unsigned int rop_en:1;
  315. unsigned int rop_select:1;
  316. unsigned int rop_mode:2;
  317. /* [4:11] */
  318. unsigned int src_fading_val:8;
  319. /* [12:20] */
  320. unsigned int dst_fading_val:8;
  321. unsigned int mask_endian:1;
  322. /* [21:31] */
  323. unsigned int reserved:11;
  324. } data;
  325. };
  326. union rga_alpha_ctrl1 {
  327. unsigned int val;
  328. struct {
  329. /* [0:1] */
  330. unsigned int dst_color_m0:1;
  331. unsigned int src_color_m0:1;
  332. /* [2:7] */
  333. unsigned int dst_factor_m0:3;
  334. unsigned int src_factor_m0:3;
  335. /* [8:9] */
  336. unsigned int dst_alpha_cal_m0:1;
  337. unsigned int src_alpha_cal_m0:1;
  338. /* [10:13] */
  339. unsigned int dst_blend_m0:2;
  340. unsigned int src_blend_m0:2;
  341. /* [14:15] */
  342. unsigned int dst_alpha_m0:1;
  343. unsigned int src_alpha_m0:1;
  344. /* [16:21] */
  345. unsigned int dst_factor_m1:3;
  346. unsigned int src_factor_m1:3;
  347. /* [22:23] */
  348. unsigned int dst_alpha_cal_m1:1;
  349. unsigned int src_alpha_cal_m1:1;
  350. /* [24:27] */
  351. unsigned int dst_blend_m1:2;
  352. unsigned int src_blend_m1:2;
  353. /* [28:29] */
  354. unsigned int dst_alpha_m1:1;
  355. unsigned int src_alpha_m1:1;
  356. /* [30:31] */
  357. unsigned int reserved:2;
  358. } data;
  359. };
  360. union rga_fading_ctrl {
  361. unsigned int val;
  362. struct {
  363. /* [0:7] */
  364. unsigned int fading_offset_r:8;
  365. /* [8:15] */
  366. unsigned int fading_offset_g:8;
  367. /* [16:23] */
  368. unsigned int fading_offset_b:8;
  369. /* [24:31] */
  370. unsigned int fading_en:1;
  371. unsigned int reserved:7;
  372. } data;
  373. };
  374. union rga_pat_con {
  375. unsigned int val;
  376. struct {
  377. /* [0:7] */
  378. unsigned int width:8;
  379. /* [8:15] */
  380. unsigned int height:8;
  381. /* [16:23] */
  382. unsigned int offset_x:8;
  383. /* [24:31] */
  384. unsigned int offset_y:8;
  385. } data;
  386. };
  387. #endif