msm_vidc_memory.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021,, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _MSM_VIDC_MEMORY_H_
  6. #define _MSM_VIDC_MEMORY_H_
  7. #include "msm_vidc_internal.h"
  8. struct msm_vidc_core;
  9. struct msm_vidc_inst;
  10. #define MSM_MEM_POOL_PACKET_SIZE 1024
  11. struct msm_memory_dmabuf {
  12. struct list_head list;
  13. struct dma_buf *dmabuf;
  14. u32 refcount;
  15. };
  16. enum msm_memory_pool_type {
  17. MSM_MEM_POOL_BUFFER = 0,
  18. MSM_MEM_POOL_MAP,
  19. MSM_MEM_POOL_ALLOC,
  20. MSM_MEM_POOL_TIMESTAMP,
  21. MSM_MEM_POOL_DMABUF,
  22. MSM_MEM_POOL_PACKET,
  23. MSM_MEM_POOL_MAX,
  24. };
  25. struct msm_memory_alloc_header {
  26. struct list_head list;
  27. u32 type;
  28. bool busy;
  29. void *buf;
  30. };
  31. struct msm_memory_pool {
  32. u32 size;
  33. char *name;
  34. struct list_head free_pool; /* list of struct msm_memory_alloc_header */
  35. struct list_head busy_pool; /* list of struct msm_memory_alloc_header */
  36. };
  37. int msm_vidc_memory_alloc(struct msm_vidc_core *core,
  38. struct msm_vidc_alloc *alloc);
  39. int msm_vidc_memory_free(struct msm_vidc_core *core,
  40. struct msm_vidc_alloc *alloc);
  41. int msm_vidc_memory_map(struct msm_vidc_core *core,
  42. struct msm_vidc_map *map);
  43. int msm_vidc_memory_unmap(struct msm_vidc_core *core,
  44. struct msm_vidc_map *map);
  45. struct dma_buf *msm_vidc_memory_get_dmabuf(struct msm_vidc_inst *inst,
  46. int fd);
  47. void msm_vidc_memory_put_dmabuf(struct msm_vidc_inst *inst,
  48. struct dma_buf *dmabuf);
  49. void msm_vidc_memory_put_dmabuf_completely(struct msm_vidc_inst *inst,
  50. struct msm_memory_dmabuf *buf);
  51. int msm_memory_pools_init(struct msm_vidc_inst *inst);
  52. void msm_memory_pools_deinit(struct msm_vidc_inst *inst);
  53. void *msm_memory_pool_alloc(struct msm_vidc_inst *inst,
  54. enum msm_memory_pool_type type);
  55. void msm_memory_pool_free(struct msm_vidc_inst *inst, void *vidc_buf);
  56. #endif // _MSM_VIDC_MEMORY_H_