msm_vidc_memory.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #include "msm_vidc_dt.h"
  9. struct msm_vidc_core;
  10. struct msm_vidc_inst;
  11. #define MSM_MEM_POOL_PACKET_SIZE 1024
  12. struct msm_memory_dmabuf {
  13. struct list_head list;
  14. struct dma_buf *dmabuf;
  15. u32 refcount;
  16. };
  17. enum msm_memory_pool_type {
  18. MSM_MEM_POOL_BUFFER = 0,
  19. MSM_MEM_POOL_MAP,
  20. MSM_MEM_POOL_ALLOC,
  21. MSM_MEM_POOL_TIMESTAMP,
  22. MSM_MEM_POOL_DMABUF,
  23. MSM_MEM_POOL_PACKET,
  24. MSM_MEM_POOL_BUF_TIMER,
  25. MSM_MEM_POOL_BUF_STATS,
  26. MSM_MEM_POOL_MAX,
  27. };
  28. struct msm_memory_alloc_header {
  29. struct list_head list;
  30. u32 type;
  31. bool busy;
  32. void *buf;
  33. };
  34. struct msm_memory_pool {
  35. u32 size;
  36. char *name;
  37. struct list_head free_pool; /* list of struct msm_memory_alloc_header */
  38. struct list_head busy_pool; /* list of struct msm_memory_alloc_header */
  39. };
  40. int msm_vidc_memory_alloc(struct msm_vidc_core *core,
  41. struct msm_vidc_alloc *alloc);
  42. int msm_vidc_memory_free(struct msm_vidc_core *core,
  43. struct msm_vidc_alloc *alloc);
  44. int msm_vidc_memory_map(struct msm_vidc_core *core,
  45. struct msm_vidc_map *map);
  46. int msm_vidc_memory_unmap(struct msm_vidc_core *core,
  47. struct msm_vidc_map *map);
  48. struct dma_buf *msm_vidc_memory_get_dmabuf(struct msm_vidc_inst *inst,
  49. int fd);
  50. void msm_vidc_memory_put_dmabuf(struct msm_vidc_inst *inst,
  51. struct dma_buf *dmabuf);
  52. void msm_vidc_memory_put_dmabuf_completely(struct msm_vidc_inst *inst,
  53. struct msm_memory_dmabuf *buf);
  54. int msm_memory_pools_init(struct msm_vidc_inst *inst);
  55. void msm_memory_pools_deinit(struct msm_vidc_inst *inst);
  56. void *msm_memory_pool_alloc(struct msm_vidc_inst *inst,
  57. enum msm_memory_pool_type type);
  58. void msm_memory_pool_free(struct msm_vidc_inst *inst, void *vidc_buf);
  59. int msm_vidc_vmem_alloc(unsigned long size, void **mem, const char *msg);
  60. void msm_vidc_vmem_free(void **addr);
  61. struct context_bank_info *msm_vidc_get_context_bank(struct msm_vidc_core *core,
  62. enum msm_vidc_buffer_region region);
  63. struct dma_buf_attachment *msm_vidc_dma_buf_attach(struct dma_buf *dbuf,
  64. struct device *dev);
  65. int msm_vidc_dma_buf_detach(struct dma_buf *dbuf,
  66. struct dma_buf_attachment *attach);
  67. struct sg_table *msm_vidc_dma_buf_map_attachment(
  68. struct dma_buf_attachment *attach);
  69. int msm_vidc_dma_buf_unmap_attachment(struct dma_buf_attachment *attach,
  70. struct sg_table *table);
  71. #endif // _MSM_VIDC_MEMORY_H_