ark_api.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. #ifndef __ARK_API_H__
  2. #define __ARK_API_H__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <semaphore.h>
  7. #include "basetype.h"
  8. #include "mfcapi.h"
  9. #include "ark_list.h"
  10. enum mirror_direction {
  11. LANDSCAPE,
  12. VERTICAL,
  13. };
  14. /* Surface formats. */
  15. enum ark_2d_format
  16. {
  17. /* RGB formats. */
  18. ARK_gcvSURF_R5G6B5 = 209,
  19. ARK_gcvSURF_R8G8B8,
  20. ARK_gcvSURF_A8R8G8B8 = 212,
  21. /* BGR formats. */
  22. ARK_gcvSURF_B5G6R5 = 302,
  23. ARK_gcvSURF_B8G8R8,
  24. ARK_gcvSURF_A8B8G8R8 = 306,
  25. /* YUV formats. */
  26. ARK_gcvSURF_YUY2 = 500,
  27. ARK_gcvSURF_UYVY,
  28. ARK_gcvSURF_YV12,
  29. ARK_gcvSURF_I420,
  30. ARK_gcvSURF_NV12,
  31. ARK_gcvSURF_NV21,
  32. ARK_gcvSURF_NV16,
  33. ARK_gcvSURF_NV61,
  34. ARK_gcvSURF_YVYU,
  35. ARK_gcvSURF_VYUY,
  36. };
  37. enum ark_disp_layer {
  38. PRIMARY_LAYER, //fb0 for UI
  39. VIDEO_LAYER, //video/phonelink display
  40. OVER_LAYER, //overlay for UI
  41. TVOUT_LAYER, //tvout display
  42. AUX_LAYER, //itu601/656 display
  43. MAX_LAYERS
  44. };
  45. enum ark_disp_mode {
  46. DISP_NONE = -1,
  47. DISP_PLAYER,
  48. DISP_PHONELINK,
  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. typedef 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. }scalar_in_format;
  75. typedef enum ark_scalar_output_format {
  76. ARK_SCALE_OUT_FORMAT_Y_UV422 = (1 << 8) | ARK_SCALE_FORMAT_YUV422,
  77. ARK_SCALE_OUT_FORMAT_Y_UV420 = (1 << 8) | ARK_SCALE_FORMAT_Y_U_V420,
  78. ARK_SCALE_OUT_FORMAT_YUYV = 2,
  79. ARK_SCALE_OUT_FORMAT_END
  80. }scalar_out_format;
  81. enum ark_yuv_order {
  82. ARK_LCDC_ORDER_VYUY = 0x000000,
  83. ARK_LCDC_ORDER_UYVY = 0x010000,
  84. ARK_LCDC_ORDER_YVYU = 0x020000,
  85. ARK_LCDC_ORDER_YUYV = 0x030000,
  86. };
  87. enum ark_rgb_order {
  88. ARK_LCDC_ORDER_RGB = 0x00000000,
  89. ARK_LCDC_ORDER_RBG = 0x01000000,
  90. ARK_LCDC_ORDER_GRB = 0x02000000,
  91. ARK_LCDC_ORDER_GBR = 0x03000000,
  92. ARK_LCDC_ORDER_BRG = 0x04000000,
  93. ARK_LCDC_ORDER_BGR = 0x05000000,
  94. };
  95. enum ark_platform_type {
  96. ARK_PLATFORM_ARK1668,
  97. ARK_PLATFORM_ARKN141,
  98. ARK_PLATFORM_ARK1668E,
  99. ARK_PLATFORM_MAX
  100. };
  101. typedef enum ark_scale_rotate {
  102. SCALE_ROTATE_0,
  103. SCALE_ROTATE_90,
  104. SCALE_ROTATE_180,
  105. SCALE_ROTATE_270,
  106. SCALE_ROTATE_0_MIRROR,
  107. SCALE_ROTATE_90_MIRROR,
  108. SCALE_ROTATE_180_MIRROR,
  109. SCALE_ROTATE_270_MIRROR,
  110. SCALE_ROTATE_END
  111. } scale_rotate;
  112. typedef struct ark_platform_info {
  113. u32 type;
  114. u32 reserve[32];
  115. } platform_info;
  116. typedef struct ark_disp_window {
  117. int pos_x;
  118. int pos_y;
  119. int width;
  120. int height;
  121. int format;
  122. int yuyv_order;
  123. int rgb_order;
  124. } disp_window;
  125. /* lcd display video layer scale */
  126. typedef struct ark_disp_scaler {
  127. int src_w;
  128. int src_h;
  129. int win_x;
  130. int win_y;
  131. int win_w;
  132. int win_h;
  133. int out_x;
  134. int out_y;
  135. int out_w;
  136. int out_h;
  137. int cut_top;
  138. int cut_bottom;
  139. int cut_left;
  140. int cut_right;
  141. } disp_scaler;
  142. typedef struct ark_disp_color {
  143. u8 contrast;
  144. u8 brightness;
  145. u8 saturation;
  146. u8 hue;
  147. } disp_color;
  148. typedef struct ark_disp_vp {
  149. struct ark_disp_color color;
  150. int reg[6];
  151. }disp_vp;
  152. typedef struct ark_screen {
  153. u32 type;
  154. u32 width;
  155. u32 height;
  156. u32 disp_x;
  157. u32 disp_y;
  158. u32 disp_width;
  159. u32 disp_height;
  160. } screen_info;
  161. typedef struct ark_disp_addr {
  162. u32 yaddr;
  163. u32 cbaddr;
  164. u32 craddr;
  165. u32 wait_vsync;
  166. } disp_addr;
  167. #define FRAME_MAX 5
  168. #define ROTATE_BUF_MAX 4
  169. typedef struct ark_reqbuf{
  170. struct list_head list;
  171. u32 count;
  172. u32 size;
  173. u32 phy_addr[FRAME_MAX];
  174. u32 *virt_addr[FRAME_MAX];
  175. }reqbuf_info;
  176. typedef struct{
  177. int fd;
  178. int reqbuf_cnt;
  179. struct list_head reqbuf_list;
  180. } memalloc_handle;
  181. typedef struct ark_disp_handle{
  182. struct list_head list;
  183. memalloc_handle *mem_handle;
  184. int fd;
  185. int layer_id;
  186. int display_mode;
  187. int atomic_stat;
  188. int show;
  189. int force;
  190. disp_window win;
  191. disp_addr addr;
  192. disp_scaler scaler;
  193. disp_color color;
  194. screen_info screen;
  195. platform_info platform;
  196. reqbuf_info reqbuf;
  197. void *disp_head;
  198. u32 reserve[32];
  199. }disp_handle;
  200. typedef struct{
  201. u32 win_src_x;
  202. u32 win_src_y;
  203. u32 win_src_width;
  204. u32 win_src_height;
  205. u32 disp_x;
  206. u32 disp_y;
  207. u32 disp_width;
  208. u32 disp_height;
  209. u32 direction;
  210. i32 keep_aspect_ratio;
  211. }video_cfg;
  212. typedef struct{
  213. u32 src_width;
  214. u32 src_height;
  215. u32 win_src_x;
  216. u32 win_src_y;
  217. u32 win_src_width;
  218. u32 win_src_height;
  219. u32 dst_width;
  220. u32 dst_height;
  221. u32 win_dst_x;
  222. u32 win_dst_y;
  223. u32 win_dst_width;
  224. u32 win_dst_height;
  225. int src_format;
  226. int dst_format;
  227. int direction;
  228. int keep_aspect_ratio;
  229. }ark2d_cfg;
  230. typedef struct{
  231. struct list_head list;
  232. void * head_2d;
  233. ark2d_cfg cfg_2d;
  234. u32 out_width;
  235. u32 out_height;
  236. }ark2d_handle;
  237. typedef struct{
  238. struct list_head list;
  239. sem_t sem_lock;
  240. memalloc_handle *handle_mem;
  241. disp_handle *handle_disp;
  242. int first_show;
  243. unsigned int last_display_addr;
  244. unsigned int last_render_yaddr;
  245. unsigned int last_render_uaddr;
  246. unsigned int last_render_vaddr;
  247. int dec_first_frame;
  248. int rotate_buffer_index;
  249. ark2d_handle *handle_2d;
  250. int cur_direction;
  251. video_cfg cfg_vid;
  252. int active;
  253. MFCHandle *handle_mfc;
  254. OutFrameBuffer out_buffer;
  255. DWLLinearMem_t in_buffer;
  256. DWLLinearMem_t rotate_buffer[ROTATE_BUF_MAX];
  257. }video_handle;
  258. struct vin_para{
  259. int xpos;
  260. int ypos;
  261. int width;
  262. int height;
  263. int source;
  264. int tvout;
  265. int hori_mirror;
  266. int vert_mirror;
  267. int left_blank;
  268. int right_blank;
  269. int top_blank;
  270. int bottom_blank;
  271. int progressive;
  272. int itu601en;
  273. };
  274. struct vin_screen {
  275. unsigned int disp_x;
  276. unsigned int disp_y;
  277. unsigned int disp_width;
  278. unsigned int disp_height;
  279. };
  280. enum dvr_source {
  281. DVR_SOURCE_CAMERA,
  282. DVR_SOURCE_AUX,
  283. DVR_SOURCE_DVD,
  284. };
  285. /*-----------------------------ARK API: VIDEO------------------------------------*/
  286. int arkapi_video_set_display_mode(int mode);
  287. video_handle *arkapi_video_init(int stream_type);
  288. int arkapi_video_set_config(video_handle *handle, video_cfg *cfg_vid);
  289. int arkapi_video_get_config(video_handle *handle, video_cfg *cfg_vid);
  290. int arkapi_video_play(video_handle *handle, const void *src_addr, int len, int fps);
  291. int arkapi_video_play_eof(video_handle *handle, int fps);
  292. int arkapi_video_show(video_handle *handle, int enable);// 1: show 0: hide
  293. int arkapi_video_show_mode(video_handle *handle, int mode, int enable);
  294. void arkapi_video_release(video_handle *handle);
  295. int arkapi_enter_carback(void);
  296. int arkapi_exit_carback(void);
  297. video_handle * arkapi_softdec_init(void);
  298. void arkapi_softdec_release(video_handle *handle);
  299. int arkapi_softdec_play(video_handle *handle, const void *src_addr);
  300. /*-----------------------------ARK API BASE: DISPLAY------------------------------*/
  301. disp_handle *arkapi_display_open_layer(enum ark_disp_layer layer);
  302. void arkapi_display_close_layer(disp_handle *handle);
  303. int arkapi_display_show_layer(disp_handle *handle);
  304. int arkapi_display_hide_layer(disp_handle *handle);
  305. int arkapi_display_set_mode(disp_handle *handle, int mode);
  306. int arkapi_display_recycle_layer(enum ark_disp_layer layer);
  307. int arkapi_display_force_show_layer(enum ark_disp_layer layer);
  308. int arkapi_display_force_hide_layer(enum ark_disp_layer layer);
  309. int arkapi_display_set_layer_pos(disp_handle *handle, int x, int y);
  310. int arkapi_display_set_layer_size(disp_handle *handle, int width, int height);
  311. int arkapi_display_set_layer_format(disp_handle *handle, int format);
  312. int arkapi_display_set_layer_scaler(disp_handle *handle, disp_scaler* spara);
  313. int arkapi_display_set_layer_addr(disp_handle *handle, u32 pyrgbaddr, u32 pcbaddr, u32 pcraddr);
  314. int arkapi_set_layer_priority(disp_handle *handle,int video_pri, int video2_pri, int win1_pri,int win2_pri,int win3_pri);
  315. int arkapi_display_set_layer_pos_atomic(disp_handle *handle, int x, int y);
  316. int arkapi_display_set_layer_size_atomic(disp_handle *handle, int width, int height);
  317. int arkapi_display_set_layer_format_atomic(disp_handle *handle, int format);
  318. int arkapi_display_set_layer_addr_atomic(disp_handle *handle, u32 pyrgbaddr, u32 pcbaddr, u32 pcraddr);
  319. int arkapi_display_set_layer_scaler_atomic(disp_handle *handle, disp_scaler *spara);
  320. int arkapi_display_layer_update_commit(disp_handle *handle);
  321. int arkapi_display_layer_set_color(enum ark_disp_layer layer, disp_color* vp);
  322. int arkapi_display_layer_get_color(enum ark_disp_layer layer, disp_color* vp);
  323. int arkapi_display_wait_for_vsync(disp_handle *handle);
  324. int arkapi_display_get_vsync_status(disp_handle *handle);
  325. int arkapi_display_get_layer_addr(disp_handle *handle, u32 *pyrgbaddr, u32 *pcbaddr, u32 *pcraddr);
  326. int arkapi_display_get_screen_info(screen_info *screen);
  327. int arkapi_display_set_screen_info(screen_info *screen);
  328. /*-----------------------------ARK API BASE: MEM-----------------------------------------*/
  329. memalloc_handle *arkapi_memalloc_init(void);
  330. reqbuf_info *arkapi_memalloc_reqbuf(memalloc_handle *handle, int size, int count);
  331. void arkapi_memalloc_release(memalloc_handle *handle);
  332. void arkapi_memalloc_free(memalloc_handle *handle, reqbuf_info *pbuf);
  333. void* arkapi_mem_map(unsigned int phy_addr, unsigned int size);
  334. int arkapi_mem_unmap(void* virt_addr, unsigned int size);
  335. /*-----------------------------------ARK API BASE: 2D-----------------------------------*/
  336. ark2d_handle *arkapi_2d_init(void);
  337. int arkapi_2d_set_config(ark2d_handle *handle, ark2d_cfg *cfg_2d);
  338. int arkapi_2d_get_config(ark2d_handle *handle, ark2d_cfg *cfg_2d);
  339. int arkapi_2d_process(ark2d_handle *handle, u32 src_phyaddr, u32 dst_phyaddr);
  340. void arkapi_2d_release(ark2d_handle *handle);
  341. /*-----------------------------------ARK API BASE: VIN-----------------------------------*/
  342. int arkapi_open_vin(void);
  343. int arkapi_close_vin(int vin_fd);
  344. int arkapi_vin_config(int vin_fd,int progressive, int itu601en);
  345. int arkapi_vin_start(int vin_fd);
  346. int arkapi_vin_stop(int vin_fd);
  347. int arkapi_vin_detect_signal(int vin_fd);
  348. int arkapi_vin_switch_channel(int vin_fd, enum dvr_source source);
  349. /*-----------------------------------ARK API BASE: ARK API SCALAR -----------------------*/
  350. int arkapi_scalar(
  351. unsigned int iyaddr,
  352. unsigned int iuaddr,
  353. unsigned int ivaddr,
  354. scalar_in_format iformat,
  355. unsigned int iwidth,
  356. unsigned int iheight,
  357. unsigned int iwindow_x,
  358. unsigned int iwindow_y,
  359. unsigned int iwinwidth,
  360. unsigned int iwinheight,
  361. unsigned int left_cut,
  362. unsigned int right_cut,
  363. unsigned int up_cut,
  364. unsigned int bottom_cut,
  365. unsigned int owidth,
  366. unsigned int oheight,
  367. unsigned int oyaddr,
  368. unsigned int ouaddr,
  369. unsigned int ovaddr,
  370. scalar_out_format oformat, //oformat: not effect for arkn141.
  371. scale_rotate rotate); //rotate: not effect for arkn141.
  372. int arkapi_scalar_nowait(
  373. unsigned int iyaddr,
  374. unsigned int iuaddr,
  375. unsigned int ivaddr,
  376. scalar_in_format iformat,
  377. unsigned int iwidth,
  378. unsigned int iheight,
  379. unsigned int iwindow_x,
  380. unsigned int iwindow_y,
  381. unsigned int iwinwidth,
  382. unsigned int iwinheight,
  383. unsigned int left_cut,
  384. unsigned int right_cut,
  385. unsigned int up_cut,
  386. unsigned int bottom_cut,
  387. unsigned int owidth,
  388. unsigned int oheight,
  389. unsigned int oyaddr,
  390. unsigned int ouaddr,
  391. unsigned int ovaddr,
  392. scalar_out_format oformat, //oformat: not effect for arkn141.
  393. scale_rotate rotate); //rotate: not effect for arkn141.
  394. int arkapi_scalar_wait_idle(void);
  395. /*-----------------------------------ARK API BASE: ARK API N141 SCALAR -----------------------*/
  396. //\D2\D4\CF½ӿ\DA\C6\F4\B6\AF\A3\AC\C7\EBʹ\D3\C3arkapi_scalar() \B4\FA\CC\E6arkapi_n141_scalar().
  397. /* <<< ****** Abandon Warning ****** >>>
  398. *
  399. * arkn141 interface have been abandoned as follows,
  400. * please using arkapi_scalar() instead it.
  401. *
  402. */
  403. int arkapi_n141_scalar(
  404. unsigned int iyaddr,
  405. unsigned int iuaddr,
  406. unsigned int ivaddr,
  407. unsigned int window_x,
  408. unsigned int window_y,
  409. unsigned int window_width,
  410. unsigned int window_height,
  411. unsigned int iwidth,
  412. unsigned int iheight,
  413. unsigned int owidth,
  414. unsigned int oheight,
  415. unsigned int ostride,
  416. unsigned int format,
  417. unsigned int yout,
  418. unsigned int uout,
  419. unsigned int vout);
  420. int arkapi_n141_scalar_lock(void);
  421. int arkapi_n141_scalar_unlock(void);
  422. #define LIBARKAPI_ARK1668 0
  423. #define LIBARKAPI_ARKN141 1
  424. #define LIBARKAPI_ARK1668E 2
  425. /*----------------------------------------END------------------------------------------*/
  426. #ifdef __cplusplus
  427. }
  428. #endif
  429. #endif