2 * Copyright (C) 2016 Nexell Co., Ltd.
3 * Author: SeongO, Park <ray@nexell.co.kr>
6 #ifndef __NX_VIDEO_ALLOC_H__
7 #define __NX_VIDEO_ALLOC_H__
16 #include <tbm_surface.h>
17 #include <tbm_surface_internal.h>
19 #define NX_MAX_PLANES 4
22 // Nexell Private Memory Type
26 int drmFd; // DRM Device Handle
27 int dmaFd; // DMA Memory Handle
28 int gemFd; // GEM Handle
29 uint32_t flink; // flink name
30 int32_t size; // Allocate Size
31 int32_t align; // Start Address Align
32 void *pBuffer; // Virtual Address Pointer
34 } NX_MEMORY_INFO, *NX_MEMORY_HANDLE;
38 // Nexell Private Video Memory Type
42 int32_t width; // Video Image's Width
43 int32_t height; // Video Image's Height
44 int32_t align; // Start address align
45 int32_t planes; // Number of valid planes
46 uint32_t format; // Pixel Format(N/A)
48 int drmFd; // Drm Device Handle
49 int dmaFd[NX_MAX_PLANES]; // DMA memory Handle
50 int gemFd[NX_MAX_PLANES]; // GEM Handle
51 uint32_t flink[NX_MAX_PLANES]; // flink name
52 int32_t size[NX_MAX_PLANES]; // Each plane's size.
53 int32_t stride[NX_MAX_PLANES]; // Each plane's stride.
54 void *pBuffer[NX_MAX_PLANES]; // virtual address.
55 uint32_t reserved[NX_MAX_PLANES]; // for debugging or future user.
56 #ifdef TIZEN_FEATURE_ARTIK530
57 void *bo[NX_MAX_PLANES]; // tbm bo
58 tbm_surface_h surface;
60 } NX_VID_MEMORY_INFO, *NX_VID_MEMORY_HANDLE;
62 // Nexell Private Memory Allocator
63 NX_MEMORY_INFO *NX_AllocateMemory (int size, int align);
64 void NX_FreeMemory (NX_MEMORY_INFO * pMem);
66 // Video Specific Allocator Wrapper
67 NX_VID_MEMORY_INFO *NX_AllocateVideoMemory (void *bufmgr, int width, int height,
68 int32_t planes, uint32_t format, int align);
69 void NX_FreeVideoMemory (NX_VID_MEMORY_INFO * pMem);
71 int NX_MapMemory (NX_MEMORY_INFO * pMem);
72 int NX_UnmapMemory (NX_MEMORY_INFO * pMem);
74 int NX_MapVideoMemory (NX_VID_MEMORY_INFO * pMem);
75 int NX_UnmapVideoMemory (NX_VID_MEMORY_INFO * pMem);
77 int NX_GetGEMHandles (int drmFd, NX_VID_MEMORY_INFO * pMem,
78 uint32_t handles[NX_MAX_PLANES]);
79 int NX_GetGemHandle (int drmFd, NX_VID_MEMORY_INFO * pMem, int32_t plane);
85 #endif // __NX_VIDEO_ALLOC_H__