msm_vidc_memory.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_dma_buf_get(struct msm_vidc_inst *inst,
  48. int fd);
  49. void msm_vidc_dma_buf_put(struct msm_vidc_inst *inst,
  50. struct dma_buf *dmabuf);
  51. void msm_vidc_dma_buf_put_completely(struct msm_vidc_inst *inst,
  52. struct msm_memory_dmabuf *buf);
  53. int msm_vidc_pools_init(struct msm_vidc_inst *inst);
  54. void msm_vidc_pools_deinit(struct msm_vidc_inst *inst);
  55. void *msm_vidc_pool_alloc(struct msm_vidc_inst *inst,
  56. enum msm_memory_pool_type type);
  57. void msm_vidc_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. struct dma_buf_attachment *msm_vidc_dma_buf_attach(struct msm_vidc_core *core,
  61. struct dma_buf *dbuf, struct device *dev);
  62. int msm_vidc_dma_buf_detach(struct msm_vidc_core *core, struct dma_buf *dbuf,
  63. struct dma_buf_attachment *attach);
  64. struct sg_table *msm_vidc_dma_buf_map_attachment(struct msm_vidc_core *core,
  65. struct dma_buf_attachment *attach);
  66. int msm_vidc_dma_buf_unmap_attachment(struct msm_vidc_core *core,
  67. struct dma_buf_attachment *attach, struct sg_table *table);
  68. u32 msm_vidc_buffer_region(struct msm_vidc_inst *inst,
  69. enum msm_vidc_buffer_type buffer_type);
  70. #endif // _MSM_VIDC_MEMORY_H_