msm_vidc_memory.h 2.0 KB

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