msm_vidc_memory.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_BUF_TIMER,
  24. MSM_MEM_POOL_BUF_STATS,
  25. MSM_MEM_POOL_MAX,
  26. };
  27. struct msm_memory_alloc_header {
  28. struct list_head list;
  29. u32 type;
  30. bool busy;
  31. void *buf;
  32. };
  33. struct msm_memory_pool {
  34. u32 size;
  35. char *name;
  36. struct list_head free_pool; /* list of struct msm_memory_alloc_header */
  37. struct list_head busy_pool; /* list of struct msm_memory_alloc_header */
  38. };
  39. int msm_vidc_memory_alloc(struct msm_vidc_core *core,
  40. struct msm_vidc_alloc *alloc);
  41. int msm_vidc_memory_free(struct msm_vidc_core *core,
  42. struct msm_vidc_alloc *alloc);
  43. int msm_vidc_memory_map(struct msm_vidc_core *core,
  44. struct msm_vidc_map *map);
  45. int msm_vidc_memory_unmap(struct msm_vidc_core *core,
  46. struct msm_vidc_map *map);
  47. struct dma_buf *msm_vidc_memory_get_dmabuf(struct msm_vidc_inst *inst,
  48. int fd);
  49. void msm_vidc_memory_put_dmabuf(struct msm_vidc_inst *inst,
  50. struct dma_buf *dmabuf);
  51. void msm_vidc_memory_put_dmabuf_completely(struct msm_vidc_inst *inst,
  52. struct msm_memory_dmabuf *buf);
  53. int msm_memory_pools_init(struct msm_vidc_inst *inst);
  54. void msm_memory_pools_deinit(struct msm_vidc_inst *inst);
  55. void *msm_memory_pool_alloc(struct msm_vidc_inst *inst,
  56. enum msm_memory_pool_type type);
  57. void msm_memory_pool_free(struct msm_vidc_inst *inst, void *vidc_buf);
  58. int msm_vidc_vmem_alloc(unsigned long size, void **mem, const char *msg);
  59. void msm_vidc_vmem_free(void **addr);
  60. #endif // _MSM_VIDC_MEMORY_H_