xref: /OK3568_Linux_fs/external/rknpu2/examples/rknn_yolov5_demo/include/drm_func.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 #ifndef __DRM_FUNC_H__
2 #define __DRM_FUNC_H__
3 #include <stdint.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <sys/fcntl.h>// open function
8 #include <unistd.h> // close function
9 #include <errno.h>
10 #include <sys/mman.h>
11 
12 
13 #include <linux/input.h>
14 #include "libdrm/drm_fourcc.h"
15 #include "xf86drm.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 typedef int (* FUNC_DRM_IOCTL)(int fd, unsigned long request, void *arg);
22 
23 typedef struct _drm_context{
24     void *drm_handle;
25     FUNC_DRM_IOCTL io_func;
26 } drm_context;
27 
28 /* memory type definitions. */
29 enum drm_rockchip_gem_mem_type
30 {
31     /* Physically Continuous memory and used as default. */
32     ROCKCHIP_BO_CONTIG = 1 << 0,
33     /* cachable mapping. */
34     ROCKCHIP_BO_CACHABLE = 1 << 1,
35     /* write-combine mapping. */
36     ROCKCHIP_BO_WC = 1 << 2,
37     ROCKCHIP_BO_SECURE = 1 << 3,
38     ROCKCHIP_BO_MASK = ROCKCHIP_BO_CONTIG | ROCKCHIP_BO_CACHABLE |
39                        ROCKCHIP_BO_WC | ROCKCHIP_BO_SECURE
40 };
41 
42 int drm_init(drm_context *drm_ctx);
43 
44 void* drm_buf_alloc(drm_context *drm_ctx,int drm_fd, int TexWidth, int TexHeight,int bpp,int *fd,unsigned int *handle,size_t *actual_size);
45 
46 int drm_buf_destroy(drm_context *drm_ctx,int drm_fd,int buf_fd, int handle,void *drm_buf,size_t size);
47 
48 void drm_deinit(drm_context *drm_ctx, int drm_fd);
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 #endif /*__DRM_FUNC_H__*/