video_mem.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) 2021-2022 Alibaba Group. All rights reserved.
  3. * License-Identifier: Apache-2.0
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  6. * not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #ifndef _VIDEO_MEM_H_
  19. #define _VIDEO_MEM_H_
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /* No special needs. */
  24. #define VMEM_FLAG_NONE 0x00000000
  25. /* Physical contiguous. */
  26. #define VMEM_FLAG_CONTIGUOUS 0x00000001
  27. /* Physical non contiguous. */
  28. #define VMEM_FLAG_NON_CONTIGUOUS 0x00000002
  29. /* Need 32bit address. */
  30. #define VMEM_FLAG_4GB_ADDR 0x00000004
  31. /* CMA priority */
  32. #define VMEM_FLAG_CMA 0x00000008
  33. /* Use VI reserved memory */
  34. #define VMEM_FLAG_VI 0x00000010
  35. /* Alloc rsvmem pool region id should be 0~15 */
  36. #define SET_ALLOC_FLAG_REGION(flag, region_id) (flag & 0x00ffffff) | (region_id << 24)
  37. #define GET_ALLOC_FLAG_REGION(flag) (flag >> 24)
  38. typedef enum _VmemStatus
  39. {
  40. VMEM_STATUS_OK = 0,
  41. VMEM_STATUS_ERROR = -1, /* general error */
  42. VMEM_STATUS_NO_MEMORY = -2, /* not enough memory to allocate buffer */
  43. } VmemStatus;
  44. typedef struct _VmemParams
  45. {
  46. int size;
  47. int flags;
  48. unsigned int phy_address;
  49. void *vir_address;
  50. int fd;
  51. } VmemParams;
  52. VmemStatus VMEM_create(void **vmem);
  53. VmemStatus VMEM_allocate(void *vmem, VmemParams *params);
  54. VmemStatus VMEM_mmap(void *vmem, VmemParams *params);
  55. VmemStatus VMEM_free(void *vmem, VmemParams *params);
  56. VmemStatus VMEM_destroy(void *vmem);
  57. VmemStatus VMEM_export(void *vmem, VmemParams *params);
  58. VmemStatus VMEM_import(void *vmem, VmemParams *params);
  59. VmemStatus VMEM_release(void *vmem, VmemParams *params);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif /* !_VIDEO_MEM_H_ */