video_memory.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (C) 2021 - 2022 Alibaba Group. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef __VIDEO_MEMORY_H_
  19. #define __VIDEO_MEMORY_H_
  20. #define IN
  21. #define OUT
  22. #define INOUT
  23. #define OPTIONAL
  24. /* No special needs. */
  25. #define ALLOC_FLAG_NONE 0x00000000
  26. /* Physical contiguous. */
  27. #define ALLOC_FLAG_CONTIGUOUS 0x00000001
  28. /* Physical non contiguous. */
  29. #define ALLOC_FLAG_NON_CONTIGUOUS 0x00000002
  30. /* Need 32bit address. */
  31. #define ALLOC_FLAG_4GB_ADDR 0x00000004
  32. /* CMA priority */
  33. #define ALLOC_FLAG_CMA 0x00000008
  34. /* Use VI reserved memory */
  35. #define ALLOC_FLAG_VI 0x00000010
  36. /* Alloc rsvmem pool region id should be 0~15 */
  37. #define SET_ALLOC_FLAG_REGION(flag, region_id) (flag & 0x00ffffff) | (region_id << 24)
  38. #define GET_ALLOC_FLAG_REGION(flag) (flag >> 24)
  39. #define MEMORY_IOC_MAGIC 'a'
  40. #define MEMORY_IOC_ALLOCATE _IOWR(MEMORY_IOC_MAGIC, 1, VidmemParams *)
  41. #define MEMORY_IOC_FREE _IOWR(MEMORY_IOC_MAGIC, 2, VidmemParams *)
  42. #define MEMORY_IOC_DMABUF_EXPORT _IOWR(MEMORY_IOC_MAGIC, 3, VidmemParams *)
  43. #define MEMORY_IOC_DMABUF_IMPORT _IOWR(MEMORY_IOC_MAGIC, 4, VidmemParams *)
  44. #define MEMORY_IOC_DMABUF_RELEASE _IOWR(MEMORY_IOC_MAGIC, 5, VidmemParams *)
  45. #define MEMORY_IOC_MAXNR 5
  46. typedef struct {
  47. unsigned long bus_address;
  48. unsigned int size;
  49. unsigned long translation_offset;
  50. int fd;
  51. int flags;
  52. } VidmemParams;
  53. #endif /* __VIDEO_MEMORY_H_ */