msm_vidc_memory.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. struct msm_memory_dmabuf {
  11. struct list_head list;
  12. struct dma_buf *dmabuf;
  13. u32 refcount;
  14. };
  15. enum msm_memory_pool_type {
  16. MSM_MEM_POOL_BUFFER = 0,
  17. MSM_MEM_POOL_MAP,
  18. MSM_MEM_POOL_ALLOC,
  19. MSM_MEM_POOL_TIMESTAMP,
  20. MSM_MEM_POOL_DMABUF,
  21. MSM_MEM_POOL_MAX,
  22. };
  23. struct msm_memory_alloc_header {
  24. struct list_head list;
  25. u32 type;
  26. bool busy;
  27. void *buf;
  28. };
  29. struct msm_memory_pool {
  30. u32 size;
  31. char *name;
  32. struct list_head free_pool; /* list of struct msm_memory_alloc_header */
  33. struct list_head busy_pool; /* list of struct msm_memory_alloc_header */
  34. };
  35. int msm_vidc_memory_alloc(struct msm_vidc_core *core,
  36. struct msm_vidc_alloc *alloc);
  37. int msm_vidc_memory_free(struct msm_vidc_core *core,
  38. struct msm_vidc_alloc *alloc);
  39. int msm_vidc_memory_map(struct msm_vidc_core *core,
  40. struct msm_vidc_map *map);
  41. int msm_vidc_memory_unmap(struct msm_vidc_core *core,
  42. struct msm_vidc_map *map);
  43. struct dma_buf *msm_vidc_memory_get_dmabuf(struct msm_vidc_inst *inst,
  44. int fd);
  45. void msm_vidc_memory_put_dmabuf(struct msm_vidc_inst *inst,
  46. struct dma_buf *dmabuf);
  47. void msm_vidc_memory_put_dmabuf_completely(struct msm_vidc_inst *inst,
  48. struct msm_memory_dmabuf *buf);
  49. int msm_memory_pools_init(struct msm_vidc_inst *inst);
  50. void msm_memory_pools_deinit(struct msm_vidc_inst *inst);
  51. void *msm_memory_alloc(struct msm_vidc_inst *inst,
  52. enum msm_memory_pool_type type);
  53. void msm_memory_free(struct msm_vidc_inst *inst, void *vidc_buf);
  54. #endif // _MSM_VIDC_MEMORY_H_