initial import
[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   } NX_VID_MEMORY_INFO, *NX_VID_MEMORY_HANDLE;
55
56 //      Nexell Private Memory Allocator
57   NX_MEMORY_INFO *NX_AllocateMemory (int size, int align);
58   void NX_FreeMemory (NX_MEMORY_INFO * pMem);
59
60 //      Video Specific Allocator Wrapper
61   NX_VID_MEMORY_INFO *NX_AllocateVideoMemory (int width, int height,
62       int32_t planes, uint32_t format, int align);
63   void NX_FreeVideoMemory (NX_VID_MEMORY_INFO * pMem);
64
65   int NX_MapMemory (NX_MEMORY_INFO * pMem);
66   int NX_UnmapMemory (NX_MEMORY_INFO * pMem);
67
68   int NX_MapVideoMemory (NX_VID_MEMORY_INFO * pMem);
69   int NX_UnmapVideoMemory (NX_VID_MEMORY_INFO * pMem);
70
71   int NX_GetGEMHandles (int drmFd, NX_VID_MEMORY_INFO * pMem,
72       uint32_t handles[NX_MAX_PLANES]);
73   int NX_GetGemHandle (int drmFd, NX_VID_MEMORY_INFO * pMem, int32_t plane);
74
75 #ifdef  __cplusplus
76 };
77 #endif
78
79 #endif //      __NX_VIDEO_ALLOC_H__