ubwcp_dma_heap.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __UBWCP_DMA_HEAP_H_
  6. #define __UBWCP_DMA_HEAP_H_
  7. #include <linux/types.h>
  8. #include <linux/dma-buf.h>
  9. /**
  10. *
  11. * Initialize ubwcp buffer for the given dma_buf. This
  12. * initializes ubwcp internal data structures and possibly hw to
  13. * use ubwcp for this buffer.
  14. *
  15. * @param dmabuf : ptr to the buffer to be configured for ubwcp
  16. *
  17. * @return int : 0 on success, otherwise error code
  18. */
  19. typedef int (*init_buffer)(struct dma_buf *dmabuf);
  20. /**
  21. * Free up ubwcp resources for this buffer.
  22. *
  23. * @param dmabuf : ptr to the dma buf
  24. *
  25. * @return int : 0 on success, otherwise error code
  26. */
  27. typedef int (*free_buffer)(struct dma_buf *dmabuf);
  28. /**
  29. * Lock buffer for CPU access. This prepares ubwcp hw to allow
  30. * CPU access to the compressed buffer. It will perform
  31. * necessary address translation configuration and cache maintenance ops
  32. * so that CPU can safely access ubwcp buffer, if this call is
  33. * successful.
  34. *
  35. * @param dmabuf : ptr to the dma buf
  36. * @param direction : direction of access
  37. *
  38. * @return int : 0 on success, otherwise error code
  39. */
  40. typedef int (*lock_buffer)(struct dma_buf *dma_buf, enum dma_data_direction direction);
  41. /**
  42. * Unlock buffer from CPU access. This prepares ubwcp hw to
  43. * safely allow for device access to the compressed buffer including any
  44. * necessary cache maintenance ops. It may also free up certain ubwcp
  45. * resources that could result in error when accessed by CPU in
  46. * unlocked state.
  47. *
  48. * @param dmabuf : ptr to the dma buf
  49. * @param direction : direction of access
  50. *
  51. * @return int : 0 on success, otherwise error code
  52. */
  53. typedef int (*unlock_buffer)(struct dma_buf *dmabuf, enum dma_data_direction direction);
  54. /**
  55. * Set the callbacks that will allow the UBWC-P DMA-BUF heap driver
  56. * to call back into the UBWC-P driver.
  57. *
  58. * @param init_buf_fn_ptr : Pointer to init_buffer function
  59. * @param free_buf_fn_ptr : Pointer to free_buffer function
  60. * @param lock_buf_fn_ptr : Pointer to lock_buffer function
  61. * @param unlock_buf_fn_ptr : Pointer to unlock_buffer function
  62. *
  63. * @return int : 0 on success, otherwise error code
  64. */
  65. int msm_ubwcp_set_ops(init_buffer init_buf_fn_ptr,
  66. free_buffer free_buf_fn_ptr,
  67. lock_buffer lock_buf_fn_ptr,
  68. unlock_buffer unlock_buf_fn_ptr);
  69. /**
  70. * Configures whether a DMA-BUF allocated from the UBWC-P heap is in
  71. * linear or UBWC-P mode.
  72. *
  73. * @param dmabuf : ptr to the dma buf
  74. * @param linear : controls which mode this buffer will be placed into
  75. * @param ula_pa_addr : ULA-PA "physical address" to mmap a buffer to
  76. * @param ula_pa_size : size of the ULA-PA buffer mapping to be used
  77. * during mmap
  78. *
  79. * @return int : 0 on success, otherwise error code
  80. */
  81. int msm_ubwcp_dma_buf_configure_mmap(struct dma_buf *dmabuf, bool linear,
  82. phys_addr_t ula_pa_addr,
  83. size_t ula_pa_size);
  84. #endif /* __UBWCP_DMA_HEAP_H_ */