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. void *buf;
  26. };
  27. struct msm_memory_pool {
  28. u32 type;
  29. u32 size;
  30. char *name;
  31. struct list_head free_pool; /* list of struct msm_memory_alloc_header */
  32. struct list_head busy_pool; /* list of struct msm_memory_alloc_header */
  33. };
  34. int msm_vidc_memory_alloc(struct msm_vidc_core *core,
  35. struct msm_vidc_alloc *alloc);
  36. int msm_vidc_memory_free(struct msm_vidc_core *core,
  37. struct msm_vidc_alloc *alloc);
  38. int msm_vidc_memory_map(struct msm_vidc_core *core,
  39. struct msm_vidc_map *map);
  40. int msm_vidc_memory_unmap(struct msm_vidc_core *core,
  41. struct msm_vidc_map *map);
  42. struct dma_buf *msm_vidc_memory_get_dmabuf(struct msm_vidc_inst *inst,
  43. int fd);
  44. void msm_vidc_memory_put_dmabuf(struct msm_vidc_inst *inst,
  45. struct dma_buf *dmabuf);
  46. void msm_vidc_memory_put_dmabuf_completely(struct msm_vidc_inst *inst,
  47. struct msm_memory_dmabuf *buf);
  48. int msm_memory_pools_init(struct msm_vidc_inst *inst);
  49. void msm_memory_pools_deinit(struct msm_vidc_inst *inst);
  50. void *msm_memory_alloc(struct msm_vidc_inst *inst,
  51. enum msm_memory_pool_type type);
  52. void msm_memory_free(struct msm_vidc_inst *inst,
  53. enum msm_memory_pool_type type, void *vidc_buf);
  54. #endif // _MSM_VIDC_MEMORY_H_