g2d_driver.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. /* g2d_driver.h
  2. *
  3. * Copyright (c) 2011 xxxx Electronics
  4. * 2011 Yupu Tang
  5. *
  6. * @ F23 G2D driver
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
  16. * GNU General Public License for more details.
  17. */
  18. #ifndef __G2D_DRIVER_H
  19. #define __G2D_DRIVER_H
  20. #include <typedef.h>
  21. #include <errno.h>
  22. /* data format */
  23. typedef enum {
  24. G2D_FORMAT_ARGB8888,
  25. G2D_FORMAT_ABGR8888,
  26. G2D_FORMAT_RGBA8888,
  27. G2D_FORMAT_BGRA8888,
  28. G2D_FORMAT_XRGB8888,
  29. G2D_FORMAT_XBGR8888,
  30. G2D_FORMAT_RGBX8888,
  31. G2D_FORMAT_BGRX8888,
  32. G2D_FORMAT_RGB888,
  33. G2D_FORMAT_BGR888,
  34. G2D_FORMAT_RGB565,
  35. G2D_FORMAT_BGR565,
  36. G2D_FORMAT_ARGB4444,
  37. G2D_FORMAT_ABGR4444,
  38. G2D_FORMAT_RGBA4444,
  39. G2D_FORMAT_BGRA4444,
  40. G2D_FORMAT_ARGB1555,
  41. G2D_FORMAT_ABGR1555,
  42. G2D_FORMAT_RGBA5551,
  43. G2D_FORMAT_BGRA5551,
  44. G2D_FORMAT_ARGB2101010,
  45. G2D_FORMAT_ABGR2101010,
  46. G2D_FORMAT_RGBA1010102,
  47. G2D_FORMAT_BGRA1010102,
  48. /* invailed for UI channel */
  49. G2D_FORMAT_IYUV422_V0Y1U0Y0 = 0x20,
  50. G2D_FORMAT_IYUV422_Y1V0Y0U0,
  51. G2D_FORMAT_IYUV422_U0Y1V0Y0,
  52. G2D_FORMAT_IYUV422_Y1U0Y0V0,
  53. G2D_FORMAT_YUV422UVC_V1U1V0U0,
  54. G2D_FORMAT_YUV422UVC_U1V1U0V0,
  55. G2D_FORMAT_YUV422_PLANAR,
  56. G2D_FORMAT_YUV420UVC_V1U1V0U0 = 0x28,
  57. G2D_FORMAT_YUV420UVC_U1V1U0V0,
  58. G2D_FORMAT_YUV420_PLANAR,
  59. G2D_FORMAT_YUV411UVC_V1U1V0U0 = 0x2c,
  60. G2D_FORMAT_YUV411UVC_U1V1U0V0,
  61. G2D_FORMAT_YUV411_PLANAR,
  62. G2D_FORMAT_Y8 = 0x30,
  63. /* YUV 10bit format */
  64. G2D_FORMAT_YVU10_P010 = 0x34,
  65. G2D_FORMAT_YVU10_P210 = 0x36,
  66. G2D_FORMAT_YVU10_444 = 0x38,
  67. G2D_FORMAT_YUV10_444 = 0x39,
  68. G2D_FORMAT_MAX,
  69. } g2d_fmt_enh;
  70. /* mixer data format */
  71. typedef enum {
  72. /* share data format */
  73. G2D_FMT_ARGB_AYUV8888 = (0x0),
  74. G2D_FMT_BGRA_VUYA8888 = (0x1),
  75. G2D_FMT_ABGR_AVUY8888 = (0x2),
  76. G2D_FMT_RGBA_YUVA8888 = (0x3),
  77. G2D_FMT_XRGB8888 = (0x4),
  78. G2D_FMT_BGRX8888 = (0x5),
  79. G2D_FMT_XBGR8888 = (0x6),
  80. G2D_FMT_RGBX8888 = (0x7),
  81. G2D_FMT_ARGB4444 = (0x8),
  82. G2D_FMT_ABGR4444 = (0x9),
  83. G2D_FMT_RGBA4444 = (0xA),
  84. G2D_FMT_BGRA4444 = (0xB),
  85. G2D_FMT_ARGB1555 = (0xC),
  86. G2D_FMT_ABGR1555 = (0xD),
  87. G2D_FMT_RGBA5551 = (0xE),
  88. G2D_FMT_BGRA5551 = (0xF),
  89. G2D_FMT_RGB565 = (0x10),
  90. G2D_FMT_BGR565 = (0x11),
  91. G2D_FMT_IYUV422 = (0x12),
  92. G2D_FMT_8BPP_MONO = (0x13),
  93. G2D_FMT_4BPP_MONO = (0x14),
  94. G2D_FMT_2BPP_MONO = (0x15),
  95. G2D_FMT_1BPP_MONO = (0x16),
  96. G2D_FMT_PYUV422UVC = (0x17),
  97. G2D_FMT_PYUV420UVC = (0x18),
  98. G2D_FMT_PYUV411UVC = (0x19),
  99. /* just for output format */
  100. G2D_FMT_PYUV422 = (0x1A),
  101. G2D_FMT_PYUV420 = (0x1B),
  102. G2D_FMT_PYUV411 = (0x1C),
  103. /* just for input format */
  104. G2D_FMT_8BPP_PALETTE = (0x1D),
  105. G2D_FMT_4BPP_PALETTE = (0x1E),
  106. G2D_FMT_2BPP_PALETTE = (0x1F),
  107. G2D_FMT_1BPP_PALETTE = (0x20),
  108. G2D_FMT_PYUV422UVC_MB16 = (0x21),
  109. G2D_FMT_PYUV420UVC_MB16 = (0x22),
  110. G2D_FMT_PYUV411UVC_MB16 = (0x23),
  111. G2D_FMT_PYUV422UVC_MB32 = (0x24),
  112. G2D_FMT_PYUV420UVC_MB32 = (0x25),
  113. G2D_FMT_PYUV411UVC_MB32 = (0x26),
  114. G2D_FMT_PYUV422UVC_MB64 = (0x27),
  115. G2D_FMT_PYUV420UVC_MB64 = (0x28),
  116. G2D_FMT_PYUV411UVC_MB64 = (0x29),
  117. G2D_FMT_PYUV422UVC_MB128 = (0x2A),
  118. G2D_FMT_PYUV420UVC_MB128 = (0x2B),
  119. G2D_FMT_PYUV411UVC_MB128 = (0x2C),
  120. } g2d_data_fmt;
  121. /* pixel sequence in double word */
  122. typedef enum {
  123. G2D_SEQ_NORMAL = 0x0,
  124. /* for interleaved yuv422 */
  125. G2D_SEQ_VYUY = 0x1, /* pixel 0�ڵ�16λ */
  126. G2D_SEQ_YVYU = 0x2, /* pixel 1�ڵ�16λ */
  127. /* for uv_combined yuv420 */
  128. G2D_SEQ_VUVU = 0x3,
  129. /* for 16bpp rgb */
  130. G2D_SEQ_P10 = 0x4, /* pixel 0�ڵ�16λ */
  131. G2D_SEQ_P01 = 0x5, /* pixel 1�ڵ�16λ */
  132. /* planar format or 8bpp rgb */
  133. G2D_SEQ_P3210 = 0x6, /* pixel 0�ڵ�8λ */
  134. G2D_SEQ_P0123 = 0x7, /* pixel 3�ڵ�8λ */
  135. /* for 4bpp rgb */
  136. G2D_SEQ_P76543210 = 0x8, /* 7,6,5,4,3,2,1,0 */
  137. G2D_SEQ_P67452301 = 0x9, /* 6,7,4,5,2,3,0,1 */
  138. G2D_SEQ_P10325476 = 0xA, /* 1,0,3,2,5,4,7,6 */
  139. G2D_SEQ_P01234567 = 0xB, /* 0,1,2,3,4,5,6,7 */
  140. /* for 2bpp rgb */
  141. /* 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 */
  142. G2D_SEQ_2BPP_BIG_BIG = 0xC,
  143. /* 12,13,14,15,8,9,10,11,4,5,6,7,0,1,2,3 */
  144. G2D_SEQ_2BPP_BIG_LITTER = 0xD,
  145. /* 3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12 */
  146. G2D_SEQ_2BPP_LITTER_BIG = 0xE,
  147. /* 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 */
  148. G2D_SEQ_2BPP_LITTER_LITTER = 0xF,
  149. /* for 1bpp rgb */
  150. /* 31,30,29,28,27,26,25,24,23,22,21,20,
  151. * 19,18,17,16,15,14,13,12,11,10,9,8,7,
  152. * 6,5,4,3,2,1,0
  153. */
  154. G2D_SEQ_1BPP_BIG_BIG = 0x10,
  155. /* 24,25,26,27,28,29,30,31,16,17,
  156. * 18,19,20,21,22,23,8,9,10,11,12,
  157. * 13,14,15,0,1,2,3,4,5,6,7
  158. */
  159. G2D_SEQ_1BPP_BIG_LITTER = 0x11,
  160. /* 7,6,5,4,3,2,1,0,15,14,13,12,11,
  161. * 10,9,8,23,22,21,20,19,18,17,16,
  162. * 31,30,29,28,27,26,25,24
  163. */
  164. G2D_SEQ_1BPP_LITTER_BIG = 0x12,
  165. /* 0,1,2,3,4,5,6,7,8,9,10,11,12,13,
  166. * 14,15,16,17,18,19,20,21,22,23,24,
  167. * 25,26,27,28,29,30,31
  168. */
  169. G2D_SEQ_1BPP_LITTER_LITTER = 0x13,
  170. } g2d_pixel_seq;
  171. /* */
  172. typedef enum {
  173. G2D_BLT_NONE_H = 0x0,
  174. G2D_BLT_BLACKNESS,
  175. G2D_BLT_NOTMERGEPEN,
  176. G2D_BLT_MASKNOTPEN,
  177. G2D_BLT_NOTCOPYPEN,
  178. G2D_BLT_MASKPENNOT,
  179. G2D_BLT_NOT,
  180. G2D_BLT_XORPEN,
  181. G2D_BLT_NOTMASKPEN,
  182. G2D_BLT_MASKPEN,
  183. G2D_BLT_NOTXORPEN,
  184. G2D_BLT_NOP,
  185. G2D_BLT_MERGENOTPEN,
  186. G2D_BLT_COPYPEN,
  187. G2D_BLT_MERGEPENNOT,
  188. G2D_BLT_MERGEPEN,
  189. G2D_BLT_WHITENESS = 0x000000ff,
  190. G2D_ROT_90 = 0x00000100,
  191. G2D_ROT_180 = 0x00000200,
  192. G2D_ROT_270 = 0x00000300,
  193. G2D_ROT_0 = 0x00000400,
  194. G2D_ROT_H = 0x00001000,
  195. G2D_ROT_V = 0x00002000,
  196. /* G2D_SM_TDLR_1 = 0x10000000, */
  197. G2D_SM_DTLR_1 = 0x10000000,
  198. /* G2D_SM_TDRL_1 = 0x20000000, */
  199. /* G2D_SM_DTRL_1 = 0x30000000, */
  200. } g2d_blt_flags_h;
  201. /* ROP3 command */
  202. typedef enum {
  203. G2D_ROP3_BLACKNESS = 0x00,
  204. G2D_ROP3_NOTSRCERASE = 0x11,
  205. G2D_ROP3_NOTSRCCOPY = 0x33,
  206. G2D_ROP3_SRCERASE = 0x44,
  207. G2D_ROP3_DSTINVERT = 0x55,
  208. G2D_ROP3_PATINVERT = 0x5A,
  209. G2D_ROP3_SRCINVERT = 0x66,
  210. G2D_ROP3_SRCAND = 0x88,
  211. G2D_ROP3_MERGEPAINT = 0xBB,
  212. G2D_ROP3_MERGECOPY = 0xC0,
  213. G2D_ROP3_SRCCOPY = 0xCC,
  214. G2D_ROP3_SRCPAINT = 0xEE,
  215. G2D_ROP3_PATCOPY = 0xF0,
  216. G2D_ROP3_PATPAINT = 0xFB,
  217. G2D_ROP3_WHITENESS = 0xFF,
  218. } g2d_rop3_cmd_flag;
  219. typedef enum {
  220. G2D_FIL_NONE = 0x00000000,
  221. G2D_FIL_PIXEL_ALPHA = 0x00000001,
  222. G2D_FIL_PLANE_ALPHA = 0x00000002,
  223. G2D_FIL_MULTI_ALPHA = 0x00000004,
  224. } g2d_fillrect_flags;
  225. typedef enum {
  226. G2D_BLT_NONE = 0x00000000,
  227. G2D_BLT_PIXEL_ALPHA = 0x00000001,
  228. G2D_BLT_PLANE_ALPHA = 0x00000002,
  229. G2D_BLT_MULTI_ALPHA = 0x00000004,
  230. G2D_BLT_SRC_COLORKEY = 0x00000008,
  231. G2D_BLT_DST_COLORKEY = 0x00000010,
  232. G2D_BLT_FLIP_HORIZONTAL = 0x00000020,
  233. G2D_BLT_FLIP_VERTICAL = 0x00000040,
  234. G2D_BLT_ROTATE90 = 0x00000080,
  235. G2D_BLT_ROTATE180 = 0x00000100,
  236. G2D_BLT_ROTATE270 = 0x00000200,
  237. G2D_BLT_MIRROR45 = 0x00000400,
  238. G2D_BLT_MIRROR135 = 0x00000800,
  239. G2D_BLT_SRC_PREMULTIPLY = 0x00001000,
  240. G2D_BLT_DST_PREMULTIPLY = 0x00002000,
  241. } g2d_blt_flags;
  242. /* BLD LAYER ALPHA MODE*/
  243. typedef enum {
  244. G2D_PIXEL_ALPHA,
  245. G2D_GLOBAL_ALPHA,
  246. G2D_MIXER_ALPHA,
  247. } g2d_alpha_mode_enh;
  248. /* flip rectangle struct */
  249. typedef struct {
  250. __s32 x; /* left top point coordinate x */
  251. __s32 y; /* left top point coordinate y */
  252. __u32 w; /* rectangle width */
  253. __u32 h; /* rectangle height */
  254. } g2d_rect;
  255. /* g2d color gamut */
  256. typedef enum {
  257. G2D_BT601,
  258. G2D_BT709,
  259. G2D_BT2020,
  260. } g2d_color_gmt;
  261. /* image struct */
  262. typedef struct {
  263. __u32 addr[3];/* base addr of image frame buffer in byte */
  264. __u32 w; /* width of image frame buffer in pixel */
  265. __u32 h; /* height of image frame buffer in pixel */
  266. g2d_data_fmt format; /* pixel format of image frame buffer */
  267. g2d_pixel_seq pixel_seq;/* pixel sequence of image frame buffer */
  268. } g2d_image;
  269. typedef struct {
  270. /* left point coordinate x of dst rect */
  271. unsigned int x;
  272. /* top point coordinate y of dst rect */
  273. unsigned int y;
  274. } g2d_coor;
  275. /* image struct */
  276. typedef struct {
  277. int bbuff;
  278. __u32 color;
  279. g2d_fmt_enh format;
  280. __u32 laddr[3];
  281. __u32 haddr[3];
  282. __u32 width;
  283. __u32 height;
  284. __u32 align[3];
  285. g2d_rect clip_rect;
  286. g2d_coor coor;
  287. __u32 gamut;
  288. int bpremul;
  289. __u8 alpha;
  290. g2d_alpha_mode_enh mode;
  291. int fd;
  292. __u32 use_phy_addr;
  293. } g2d_image_enh;
  294. /*
  295. * 0:Top to down, Left to right
  296. * 1:Top to down, Right to left
  297. * 2:Down to top, Left to right
  298. * 3:Down to top, Right to left
  299. */
  300. enum g2d_scan_order {
  301. G2D_SM_TDLR = 0x00000000,
  302. G2D_SM_TDRL = 0x00000001,
  303. G2D_SM_DTLR = 0x00000002,
  304. G2D_SM_DTRL = 0x00000003,
  305. };
  306. typedef struct {
  307. g2d_fillrect_flags flag;
  308. g2d_image dst_image;
  309. g2d_rect dst_rect;
  310. __u32 color; /* fill color */
  311. __u32 alpha; /* plane alpha value */
  312. } g2d_fillrect;
  313. typedef struct {
  314. g2d_image_enh dst_image_h;
  315. } g2d_fillrect_h;
  316. typedef struct {
  317. g2d_blt_flags flag;
  318. g2d_image src_image;
  319. g2d_rect src_rect;
  320. g2d_image dst_image;
  321. /* left top point coordinate x of dst rect */
  322. __s32 dst_x;
  323. /* left top point coordinate y of dst rect */
  324. __s32 dst_y;
  325. __u32 color; /* colorkey color */
  326. __u32 alpha; /* plane alpha value */
  327. } g2d_blt;
  328. typedef struct {
  329. g2d_blt_flags_h flag_h;
  330. g2d_image_enh src_image_h;
  331. g2d_image_enh dst_image_h;
  332. } g2d_blt_h;
  333. typedef struct {
  334. g2d_blt_h blt;
  335. __u32 lbc_cmp_ratio;
  336. __u8 enc_is_lossy;
  337. __u8 dec_is_lossy;
  338. } g2d_lbc_rot;
  339. typedef struct {
  340. g2d_blt_flags flag;
  341. g2d_image src_image;
  342. g2d_rect src_rect;
  343. g2d_image dst_image;
  344. g2d_rect dst_rect;
  345. __u32 color; /* colorkey color */
  346. __u32 alpha; /* plane alpha value */
  347. } g2d_stretchblt;
  348. typedef struct {
  349. g2d_rop3_cmd_flag back_flag;
  350. g2d_rop3_cmd_flag fore_flag;
  351. g2d_image_enh dst_image_h;
  352. g2d_image_enh src_image_h;
  353. g2d_image_enh ptn_image_h;
  354. g2d_image_enh mask_image_h;
  355. } g2d_maskblt;
  356. /* Porter Duff BLD command*/
  357. typedef enum {
  358. G2D_BLD_CLEAR = 0x00000001,
  359. G2D_BLD_COPY = 0x00000002,
  360. G2D_BLD_DST = 0x00000003,
  361. G2D_BLD_SRCOVER = 0x00000004,
  362. G2D_BLD_DSTOVER = 0x00000005,
  363. G2D_BLD_SRCIN = 0x00000006,
  364. G2D_BLD_DSTIN = 0x00000007,
  365. G2D_BLD_SRCOUT = 0x00000008,
  366. G2D_BLD_DSTOUT = 0x00000009,
  367. G2D_BLD_SRCATOP = 0x0000000a,
  368. G2D_BLD_DSTATOP = 0x0000000b,
  369. G2D_BLD_XOR = 0x0000000c,
  370. G2D_CK_SRC = 0x00010000,
  371. G2D_CK_DST = 0x00020000,
  372. } g2d_bld_cmd_flag;
  373. typedef struct {
  374. __u32 *pbuffer;
  375. __u32 size;
  376. } g2d_palette;
  377. typedef struct {
  378. long start;
  379. long end;
  380. } g2d_cache_range;
  381. /* CK PARA struct */
  382. typedef struct {
  383. int match_rule;
  384. __u32 max_color;
  385. __u32 min_color;
  386. } g2d_ck;
  387. typedef struct {
  388. g2d_bld_cmd_flag bld_cmd;
  389. g2d_image_enh dst_image;
  390. g2d_image_enh src_image[4];/*now only ch0 and ch3*/
  391. g2d_ck ck_para;
  392. } g2d_bld; /* blending enhance */
  393. typedef enum {
  394. OP_FILLRECT = 0x1,
  395. OP_BITBLT = 0x2,
  396. OP_BLEND = 0x4,
  397. OP_MASK = 0x8,
  398. OP_SPLIT_MEM = 0x10,
  399. } g2d_operation_flag;
  400. /**
  401. * mixer_para
  402. */
  403. struct mixer_para {
  404. g2d_operation_flag op_flag;
  405. g2d_blt_flags_h flag_h;
  406. g2d_rop3_cmd_flag back_flag;
  407. g2d_rop3_cmd_flag fore_flag;
  408. g2d_bld_cmd_flag bld_cmd;
  409. g2d_image_enh src_image_h;
  410. g2d_image_enh dst_image_h;
  411. g2d_image_enh ptn_image_h;
  412. g2d_image_enh mask_image_h;
  413. g2d_ck ck_para;
  414. };
  415. /*
  416. #define SUNXI_G2D_IOC_MAGIC 'G'
  417. #define SUNXI_G2D_IO(nr) _IO(SUNXI_G2D_IOC_MAGIC, nr)
  418. #define SUNXI_G2D_IOR(nr, size) _IOR(SUNXI_G2D_IOC_MAGIC, nr, size)
  419. #define SUNXI_G2D_IOW(nr, size) _IOW(SUNXI_G2D_IOC_MAGIC, nr, size)
  420. #define SUNXI_G2D_IOWR(nr, size) _IOWR(SUNXI_G2D_IOC_MAGIC, nr, size)
  421. */
  422. typedef enum {
  423. G2D_CMD_BITBLT = 0x50,
  424. G2D_CMD_FILLRECT = 0x51,
  425. G2D_CMD_STRETCHBLT = 0x52,
  426. G2D_CMD_PALETTE_TBL = 0x53,
  427. G2D_CMD_QUEUE = 0x54,
  428. G2D_CMD_BITBLT_H = 0x55,
  429. G2D_CMD_FILLRECT_H = 0x56,
  430. G2D_CMD_BLD_H = 0x57,
  431. G2D_CMD_MASK_H = 0x58,
  432. G2D_CMD_MEM_REQUEST = 0x59,
  433. G2D_CMD_MEM_RELEASE = 0x5A,
  434. G2D_CMD_MEM_GETADR = 0x5B,
  435. G2D_CMD_MEM_SELIDX = 0x5C,
  436. G2D_CMD_MEM_FLUSH_CACHE = 0x5D,
  437. G2D_CMD_INVERTED_ORDER = 0x5E,
  438. G2D_CMD_MIXER_TASK = 0x5F,
  439. /*G2D_CMD_CREATE_TASK = SUNXI_G2D_IOW(0x1, struct mixer_para),
  440. G2D_CMD_TASK_APPLY = SUNXI_G2D_IOW(0x2, struct mixer_para),
  441. G2D_CMD_TASK_DESTROY = SUNXI_G2D_IOW(0x3, unsigned int),
  442. G2D_CMD_TASK_GET_PARA = SUNXI_G2D_IOR(0x4, struct mixer_para), */
  443. G2D_CMD_CREATE_TASK = 0x60,
  444. G2D_CMD_TASK_APPLY = 0x61,
  445. G2D_CMD_TASK_DESTROY = 0x62,
  446. G2D_CMD_TASK_GET_PARA = 0x63,
  447. G2D_CMD_LBC_ROT = 0x64,
  448. } g2d_cmd;
  449. #endif /* __G2D_DRIVER_H */