add tbm bo allocation for tizen waylandsink
[platform/adaptation/nexell/nx-video-api.git] / src / nx_video_alloc.h
1 /*
2  * Copyright (C) 2016  Nexell Co., Ltd.
3  * Author: SeongO, Park <ray@nexell.co.kr>
4  */
5
6 #ifndef __NX_VIDEO_ALLOC_H__
7 #define __NX_VIDEO_ALLOC_H__
8
9
10 #ifdef  __cplusplus
11 extern "C"
12 {
13 #endif
14
15 #include <stdint.h>
16
17 #define NX_MAX_PLANES   4
18
19 //
20 //      Nexell Private Memory Type
21 //
22   typedef struct
23   {
24     int drmFd;                  //      DRM Device Handle
25     int dmaFd;                  //      DMA Memory Handle
26     int gemFd;                  //      GEM Handle
27     uint32_t flink;             //      flink name
28     int32_t size;               //      Allocate Size
29     int32_t align;              //      Start Address Align
30     void *pBuffer;              //      Virtual Address Pointer
31     uint32_t reserved;
32   } NX_MEMORY_INFO, *NX_MEMORY_HANDLE;
33
34
35 //
36 //      Nexell Private Video Memory Type
37 //
38   typedef struct
39   {
40     int32_t width;              //      Video Image's Width
41     int32_t height;             //      Video Image's Height
42     int32_t align;              //      Start address align
43     int32_t planes;             //      Number of valid planes
44     uint32_t format;            //      Pixel Format(N/A)
45
46     int drmFd;                  //      Drm Device Handle
47     int dmaFd[NX_MAX_PLANES];   //      DMA memory Handle
48     int gemFd[NX_MAX_PLANES];   //      GEM Handle
49     uint32_t flink[NX_MAX_PLANES];      //      flink name
50     int32_t size[NX_MAX_PLANES];        //      Each plane's size.
51     int32_t stride[NX_MAX_PLANES];      //      Each plane's stride.
52     void *pBuffer[NX_MAX_PLANES];       //      virtual address.
53     uint32_t reserved[NX_MAX_PLANES];   //      for debugging or future user.
54 #ifdef TIZEN_FEATURE_ARTIK530
55     void *bufmgr;
56     void *bo[NX_MAX_PLANES]; // tbm bo
57 #endif
58   } NX_VID_MEMORY_INFO, *NX_VID_MEMORY_HANDLE;
59
60 //      Nexell Private Memory Allocator
61   NX_MEMORY_INFO *NX_AllocateMemory (int size, int align);
62   void NX_FreeMemory (NX_MEMORY_INFO * pMem);
63
64 //      Video Specific Allocator Wrapper
65   NX_VID_MEMORY_INFO *NX_AllocateVideoMemory (int width, int height,
66       int32_t planes, uint32_t format, int align);
67   void NX_FreeVideoMemory (NX_VID_MEMORY_INFO * pMem);
68
69   int NX_MapMemory (NX_MEMORY_INFO * pMem);
70   int NX_UnmapMemory (NX_MEMORY_INFO * pMem);
71
72   int NX_MapVideoMemory (NX_VID_MEMORY_INFO * pMem);
73   int NX_UnmapVideoMemory (NX_VID_MEMORY_INFO * pMem);
74
75   int NX_GetGEMHandles (int drmFd, NX_VID_MEMORY_INFO * pMem,
76       uint32_t handles[NX_MAX_PLANES]);
77   int NX_GetGemHandle (int drmFd, NX_VID_MEMORY_INFO * pMem, int32_t plane);
78
79 #ifdef  __cplusplus
80 };
81 #endif
82
83 #endif //      __NX_VIDEO_ALLOC_H__