ark_api.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. #ifndef __ARK_API_H__
  2. #define __ARK_API_H__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include "basetype.h"
  7. #include "mfcapi.h"
  8. #include "ark_list.h"
  9. enum mirror_direction {
  10. LANDSCAPE,
  11. VERTICAL,
  12. };
  13. /* Surface formats. */
  14. enum ark_2d_format
  15. {
  16. /* RGB formats. */
  17. ARK_gcvSURF_R5G6B5 = 209,
  18. ARK_gcvSURF_R8G8B8,
  19. ARK_gcvSURF_A8R8G8B8 = 212,
  20. /* BGR formats. */
  21. ARK_gcvSURF_B5G6R5 = 302,
  22. ARK_gcvSURF_B8G8R8,
  23. ARK_gcvSURF_A8B8G8R8 = 306,
  24. /* YUV formats. */
  25. ARK_gcvSURF_YUY2 = 500,
  26. ARK_gcvSURF_UYVY,
  27. ARK_gcvSURF_YV12,
  28. ARK_gcvSURF_I420,
  29. ARK_gcvSURF_NV12,
  30. ARK_gcvSURF_NV21,
  31. ARK_gcvSURF_NV16,
  32. ARK_gcvSURF_NV61,
  33. ARK_gcvSURF_YVYU,
  34. ARK_gcvSURF_VYUY,
  35. };
  36. enum ark_disp_layer {
  37. PRIMARY_LAYER, //fb0 for UI
  38. VIDEO_LAYER, //video/phonelink display
  39. OVER_LAYER, //overlay for UI
  40. TVOUT_LAYER, //tvout display
  41. AUX_LAYER, //itu601/656 display
  42. MAX_LAYERS
  43. };
  44. enum ark_disp_mode {
  45. DISP_NONE = -1,
  46. DISP_PLAYER,
  47. DISP_CARLIFE,
  48. DISP_CARPLAY,
  49. DISP_AUX,
  50. DISP_MODE_NUM,
  51. };
  52. enum ark_disp_format {
  53. ARK_LCDC_FORMAT_YUV422,
  54. ARK_LCDC_FORMAT_YUV420,
  55. ARK_LCDC_FORMAT_VYUY,
  56. ARK_LCDC_FORMAT_YUV,
  57. ARK_LCDC_FORMAT_RGBI555,
  58. ARK_LCDC_FORMAT_R5G6B5,
  59. ARK_LCDC_FORMAT_RGBA888,
  60. ARK_LCDC_FORMAT_RGB888,
  61. ARK_LCDC_FORMAT_Y_UV422 = 0x10,
  62. ARK_LCDC_FORMAT_Y_UV420 = 0x11,
  63. };
  64. enum ark_scalar_format {
  65. ARK_SCALE_FORMAT_YUV422 = 0,
  66. ARK_SCALE_FORMAT_Y_UV422 = (1 << 8) | ARK_SCALE_FORMAT_YUV422,
  67. ARK_SCALE_FORMAT_Y_U_V420 = 1,
  68. ARK_SCALE_FORMAT_Y_UV420 = (1 << 8) | ARK_SCALE_FORMAT_Y_U_V420,
  69. ARK_SCALE_FORMAT_YUYV = 2,
  70. ARK_SCALE_FORMAT_YVYU = (1 << 8) | ARK_SCALE_FORMAT_YUYV,
  71. ARK_SCALE_FORMAT_UYVY = (2 << 8) | ARK_SCALE_FORMAT_YUYV,
  72. ARK_SCALE_FORMAT_VYUY = (3 << 8) | ARK_SCALE_FORMAT_YUYV,
  73. ARK_SCALE_FORMAT_YUV = 3,
  74. };
  75. enum ark_yuv_order {
  76. ARK_LCDC_ORDER_VYUY = 0x000000,
  77. ARK_LCDC_ORDER_UYVY = 0x010000,
  78. ARK_LCDC_ORDER_YVYU = 0x020000,
  79. ARK_LCDC_ORDER_YUYV = 0x030000,
  80. };
  81. enum ark_rgb_order {
  82. ARK_LCDC_ORDER_RGB = 0x00000000,
  83. ARK_LCDC_ORDER_RBG = 0x01000000,
  84. ARK_LCDC_ORDER_GRB = 0x02000000,
  85. ARK_LCDC_ORDER_GBR = 0x03000000,
  86. ARK_LCDC_ORDER_BRG = 0x04000000,
  87. ARK_LCDC_ORDER_BGR = 0x05000000,
  88. };
  89. enum ark_platform_type {
  90. ARK_PLATFORM_ARK1668,
  91. ARK_PLATFORM_ARKN141,
  92. ARK_PLATFORM_MAX
  93. };
  94. typedef struct ark_platform_info {
  95. u32 type;
  96. u32 reserve[32];
  97. } platform_info;
  98. typedef struct ark_disp_window {
  99. int pos_x;
  100. int pos_y;
  101. int width;
  102. int height;
  103. int format;
  104. int yuyv_order;
  105. int rgb_order;
  106. } disp_window;
  107. typedef struct ark_disp_scaler {
  108. int src_w;
  109. int src_h;
  110. int win_x;
  111. int win_y;
  112. int win_w;
  113. int win_h;
  114. int out_x;
  115. int out_y;
  116. int out_w;
  117. int out_h;
  118. int cut_top;
  119. int cut_bottom;
  120. int cut_left;
  121. int cut_right;
  122. } disp_scaler;
  123. typedef struct ark_disp_color {
  124. u8 contrast;
  125. u8 brightness;
  126. u8 saturation;
  127. u8 hue;
  128. } disp_color;
  129. typedef struct ark_screen {
  130. u32 type;
  131. u32 width;
  132. u32 height;
  133. u32 disp_x;
  134. u32 disp_y;
  135. u32 disp_width;
  136. u32 disp_height;
  137. } screen_info;
  138. typedef struct ark_disp_addr {
  139. u32 yaddr;
  140. u32 cbaddr;
  141. u32 craddr;
  142. u32 wait_vsync;
  143. } disp_addr;
  144. #define FRAME_MAX 5
  145. #define ROTATE_BUF_MAX 3
  146. typedef struct ark_reqbuf{
  147. struct list_head list;
  148. u32 count;
  149. u32 size;
  150. u32 phy_addr[FRAME_MAX];
  151. u32 *virt_addr[FRAME_MAX];
  152. }reqbuf_info;
  153. typedef struct{
  154. int fd;
  155. int reqbuf_cnt;
  156. reqbuf_info *reqbuf_head;
  157. } memalloc_handle;
  158. typedef struct ark_disp_handle{
  159. struct list_head list;
  160. memalloc_handle *mem_handle;
  161. int fd;
  162. int layer_id;
  163. int display_mode;
  164. int atomic_stat;
  165. int show;
  166. int force;
  167. disp_window win;
  168. disp_addr addr;
  169. disp_scaler scaler;
  170. disp_color color;
  171. screen_info screen;
  172. platform_info platform;
  173. reqbuf_info reqbuf;
  174. void *disp_head;
  175. u32 reserve[32];
  176. }disp_handle;
  177. typedef struct{
  178. u32 disp_x;
  179. u32 disp_y;
  180. u32 disp_width;
  181. u32 disp_height;
  182. u32 direction;
  183. }video_cfg;
  184. typedef struct{
  185. u32 src_width;
  186. u32 src_height;
  187. u32 win_src_x;
  188. u32 win_src_y;
  189. u32 win_src_width;
  190. u32 win_src_height;
  191. u32 dst_width;
  192. u32 dst_height;
  193. u32 win_dst_x;
  194. u32 win_dst_y;
  195. u32 win_dst_width;
  196. u32 win_dst_height;
  197. int src_format;
  198. int dst_format;
  199. int direction;
  200. }ark2d_cfg;
  201. typedef struct{
  202. struct list_head list;
  203. void * head_2d;
  204. ark2d_cfg cfg_2d;
  205. u32 out_width;
  206. u32 out_height;
  207. }ark2d_handle;
  208. typedef struct{
  209. struct list_head list;
  210. memalloc_handle *handle_mem;
  211. disp_handle *handle_disp;
  212. int first_show;
  213. u32 last_display_addr;
  214. int dec_first_frame;
  215. int rotate_buffer_index;
  216. ark2d_handle *handle_2d;
  217. int cur_direction;
  218. video_cfg cfg_vid;
  219. int active;
  220. MFCHandle *handle_mfc;
  221. OutFrameBuffer out_buffer;
  222. DWLLinearMem_t in_buffer;
  223. DWLLinearMem_t rotate_buffer[ROTATE_BUF_MAX];
  224. }video_handle;
  225. /*-----------------------------ARK API: VIDEO------------------------------------*/
  226. video_handle *arkapi_video_init(int stream_type);
  227. int arkapi_video_set_config(video_handle *handle, video_cfg *cfg_vid);
  228. int arkapi_video_get_config(video_handle *handle, video_cfg *cfg_vid);
  229. int arkapi_video_play(video_handle *handle, const void *src_addr, int len);
  230. int arkapi_video_show(video_handle *handle, int enable);// 1: show 0: hide
  231. void arkapi_video_release(video_handle *handle);
  232. /*-----------------------------ARK API BASE: DISPLAY------------------------------*/
  233. disp_handle *arkapi_display_open_layer(enum ark_disp_layer layer);
  234. void arkapi_display_close_layer(disp_handle *handle);
  235. int arkapi_display_show_layer(disp_handle *handle);
  236. int arkapi_display_hide_layer(disp_handle *handle);
  237. int arkapi_display_set_mode(disp_handle *handle, int mode);
  238. int arkapi_display_recycle_layer(enum ark_disp_layer layer);
  239. int arkapi_display_force_show_layer(enum ark_disp_layer layer);
  240. int arkapi_display_force_hide_layer(enum ark_disp_layer layer);
  241. int arkapi_display_set_layer_pos(disp_handle *handle, int x, int y);
  242. int arkapi_display_set_layer_size(disp_handle *handle, int width, int height);
  243. int arkapi_display_set_layer_format(disp_handle *handle, int format);
  244. int arkapi_display_set_layer_scaler(disp_handle *handle, disp_scaler* spara);
  245. int arkapi_display_set_layer_addr(disp_handle *handle, u32 pyrgbaddr, u32 pcbaddr, u32 pcraddr);
  246. /* arkapi_display_scalar_and_set_yuv_layer_addr:
  247. * user:
  248. * only used for arkn141
  249. * parameters:
  250. * pyrgbaddr: y phy address
  251. * pcbaddr : u phy address
  252. * pcraddr : v phy address
  253. * format : yuv420 use ARK_SCALE_FORMAT_Y_UV420
  254. * width : source width
  255. * height : source height
  256. * drop : whether drop current frame when there is no frame vsync interrupt.
  257. * set 0 when used for non-real time process (such as play video file, ...),it will wait for vsync interrupt(do not drop current frame).
  258. * set 1 when used for real-time process(such as camera, carplay projection screen, ...),it will drop current frame .
  259. */
  260. int arkapi_display_scalar_and_set_yuv_layer_addr(disp_handle *handle,
  261. u32 pyrgbaddr, u32 pcbaddr, u32 pcraddr, int format,
  262. u32 width, u32 height, u32 drop);
  263. int arkapi_display_set_layer_pos_atomic(disp_handle *handle, int x, int y);
  264. int arkapi_display_set_layer_size_atomic(disp_handle *handle, int width, int height);
  265. int arkapi_display_set_layer_format_atomic(disp_handle *handle, int format);
  266. int arkapi_display_set_layer_addr_atomic(disp_handle *handle, u32 pyrgbaddr, u32 pcbaddr, u32 pcraddr);
  267. int arkapi_display_set_layer_scaler_atomic(disp_handle *handle, disp_scaler *spara);
  268. int arkapi_display_layer_update_commit(disp_handle *handle);
  269. int arkapi_display_layer_set_color(enum ark_disp_layer layer, disp_color* vp);
  270. int arkapi_display_layer_get_color(enum ark_disp_layer layer, disp_color* vp);
  271. int arkapi_display_wait_for_vsync(disp_handle *handle);
  272. int arkapi_display_get_vsync_status(disp_handle *handle);
  273. int arkapi_display_get_layer_addr(disp_handle *handle, u32 *pyrgbaddr, u32 *pcbaddr, u32 *pcraddr);
  274. int arkapi_display_get_screen_info(screen_info *screen);
  275. int arkapi_display_set_screen_info(screen_info *screen);
  276. /*-----------------------------ARK API BASE: MEM-----------------------------------------*/
  277. memalloc_handle *arkapi_memalloc_init(void);
  278. int arkapi_memalloc_reqbuf(memalloc_handle *handle, reqbuf_info *reqbuf);
  279. void arkapi_memalloc_release(memalloc_handle *handle);
  280. int arkapi_memalloc_free(memalloc_handle *handle, reqbuf_info *reqbuf);
  281. void* arkapi_mem_map(unsigned int phy_addr, unsigned int size);
  282. int arkapi_mem_unmap(void* virt_addr, unsigned int size);
  283. /*-----------------------------------ARK API BASE: 2D-----------------------------------*/
  284. ark2d_handle *arkapi_2d_init(void);
  285. int arkapi_2d_set_config(ark2d_handle *handle, ark2d_cfg *cfg_2d);
  286. int arkapi_2d_get_config(ark2d_handle *handle, ark2d_cfg *cfg_2d);
  287. int arkapi_2d_process(ark2d_handle *handle, u32 src_phyaddr, u32 dst_phyaddr);
  288. void arkapi_2d_release(ark2d_handle *handle);
  289. /*-----------------------------------ARK API BASE: ARK API N141 SCALAR -----------------------*/
  290. int arkapi_n141_scalar(
  291. unsigned int iyaddr,
  292. unsigned int iuaddr,
  293. unsigned int ivaddr,
  294. unsigned int window_x,
  295. unsigned int window_y,
  296. unsigned int window_width,
  297. unsigned int window_height,
  298. unsigned int iwidth,
  299. unsigned int iheight,
  300. unsigned int owidth,
  301. unsigned int oheight,
  302. unsigned int ostride,
  303. unsigned int format,
  304. unsigned int yout,
  305. unsigned int uout,
  306. unsigned int vout);
  307. int arkapi_n141_scalar_lock(void);
  308. int arkapi_n141_scalar_unlock(void);
  309. /*----------------------------------------END------------------------------------------*/
  310. #ifdef __cplusplus
  311. }
  312. #endif
  313. #endif