cam_cdm_intf_api.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _CAM_CDM_API_H_
  6. #define _CAM_CDM_API_H_
  7. #include <media/cam_defs.h>
  8. #include "cam_cdm_util.h"
  9. #include "cam_soc_util.h"
  10. /* enum cam_cdm_id - Enum for possible CAM CDM hardwares */
  11. enum cam_cdm_id {
  12. CAM_CDM_VIRTUAL,
  13. CAM_CDM_HW_ANY,
  14. CAM_CDM_CPAS_0,
  15. CAM_CDM_IPE0,
  16. CAM_CDM_IPE1,
  17. CAM_CDM_BPS,
  18. CAM_CDM_VFE,
  19. CAM_CDM_MAX
  20. };
  21. /* enum cam_cdm_cb_status - Enum for possible CAM CDM callback */
  22. enum cam_cdm_cb_status {
  23. CAM_CDM_CB_STATUS_BL_SUCCESS,
  24. CAM_CDM_CB_STATUS_INVALID_BL_CMD,
  25. CAM_CDM_CB_STATUS_PAGEFAULT,
  26. CAM_CDM_CB_STATUS_HW_RESET_ONGOING,
  27. CAM_CDM_CB_STATUS_HW_RESET_DONE,
  28. CAM_CDM_CB_STATUS_UNKNOWN_ERROR,
  29. };
  30. /* enum cam_cdm_bl_cmd_addr_type - Enum for possible CDM bl cmd addr types */
  31. enum cam_cdm_bl_cmd_addr_type {
  32. CAM_CDM_BL_CMD_TYPE_MEM_HANDLE,
  33. CAM_CDM_BL_CMD_TYPE_HW_IOVA,
  34. CAM_CDM_BL_CMD_TYPE_KERNEL_IOVA,
  35. };
  36. /**
  37. * struct cam_cdm_acquire_data - Cam CDM acquire data structure
  38. *
  39. * @identifier : Input identifier string which is the device label from dt
  40. * like vfe, ife, jpeg etc
  41. * @cell_index : Input integer identifier pointing to the cell index from dt
  42. * of the device. This can be used to form a unique string
  43. * with @identifier like vfe0, ife1, jpeg0 etc
  44. * @id : ID of a specific or any CDM HW which needs to be acquired.
  45. * @userdata : Input private data which will be returned as part
  46. * of callback.
  47. * @cam_cdm_callback : Input callback pointer for triggering the
  48. * callbacks from CDM driver
  49. * @handle : CDM Client handle
  50. * @userdata : Private data given at the time of acquire
  51. * @status : Callback status
  52. * @cookie : Cookie if the callback is gen irq status
  53. * @base_array_cnt : Input number of ioremapped address pair pointing
  54. * in base_array, needed only if selected cdm is a virtual.
  55. * @base_array : Input pointer to ioremapped address pair arrary
  56. * needed only if selected cdm is a virtual.
  57. * @cdm_version : CDM version is output while acquiring HW cdm and
  58. * it is Input while acquiring virtual cdm, Currently fixing it
  59. * to one version below acquire API.
  60. * @ops : Output pointer updated by cdm driver to the CDM
  61. * util ops for this HW version of CDM acquired.
  62. * @handle : Output Unique handle generated for this acquire
  63. *
  64. */
  65. struct cam_cdm_acquire_data {
  66. char identifier[128];
  67. uint32_t cell_index;
  68. enum cam_cdm_id id;
  69. void *userdata;
  70. void (*cam_cdm_callback)(uint32_t handle, void *userdata,
  71. enum cam_cdm_cb_status status, uint64_t cookie);
  72. uint32_t base_array_cnt;
  73. struct cam_soc_reg_map *base_array[CAM_SOC_MAX_BLOCK];
  74. struct cam_hw_version cdm_version;
  75. struct cam_cdm_utils_ops *ops;
  76. uint32_t handle;
  77. };
  78. /**
  79. * struct cam_cdm_bl_cmd - Cam CDM HW bl command
  80. *
  81. * @bl_addr : Union of all three type for CDM BL commands
  82. * @mem_handle : Input mem handle of bl cmd
  83. * @offset : Input offset of the actual bl cmd in the memory pointed
  84. * by mem_handle
  85. * @len : Input length of the BL command, Cannot be more than 1MB and
  86. * this is will be validated with offset+size of the memory pointed
  87. * by mem_handle
  88. *
  89. */
  90. struct cam_cdm_bl_cmd {
  91. union {
  92. int32_t mem_handle;
  93. uint32_t *hw_iova;
  94. uintptr_t kernel_iova;
  95. } bl_addr;
  96. uint32_t offset;
  97. uint32_t len;
  98. };
  99. /**
  100. * struct cam_cdm_bl_request - Cam CDM HW base & length (BL) request
  101. *
  102. * @flag : 1 for callback needed and 0 for no callback when this BL
  103. * request is done
  104. * @userdata :Input private data which will be returned as part
  105. * of callback if request for this bl request in flags.
  106. * @cookie : Cookie if the callback is gen irq status
  107. * @type : type of the submitted bl cmd address.
  108. * @cmd_arrary_count : Input number of BL commands to be submitted to CDM
  109. * @bl_cmd_array : Input payload holding the BL cmd's arrary
  110. * to be sumbitted.
  111. *
  112. */
  113. struct cam_cdm_bl_request {
  114. int flag;
  115. void *userdata;
  116. uint64_t cookie;
  117. enum cam_cdm_bl_cmd_addr_type type;
  118. uint32_t cmd_arrary_count;
  119. struct cam_cdm_bl_cmd cmd[1];
  120. };
  121. /**
  122. * @brief : API to get the CDM capabilities for a camera device type
  123. *
  124. * @identifier : Input pointer to a string which is the device label from dt
  125. * like vfe, ife, jpeg etc, We do not need cell index
  126. * assuming all devices of a single type maps to one SMMU
  127. * client
  128. * @cdm_handles : Input iommu handle memory pointer to update handles
  129. *
  130. * @return 0 on success
  131. */
  132. int cam_cdm_get_iommu_handle(char *identifier,
  133. struct cam_iommu_handle *cdm_handles);
  134. /**
  135. * @brief : API to acquire a CDM
  136. *
  137. * @data : Input data for the CDM to be acquired
  138. *
  139. * @return 0 on success
  140. */
  141. int cam_cdm_acquire(struct cam_cdm_acquire_data *data);
  142. /**
  143. * @brief : API to release a previously acquired CDM
  144. *
  145. * @handle : Input handle for the CDM to be released
  146. *
  147. * @return 0 on success
  148. */
  149. int cam_cdm_release(uint32_t handle);
  150. /**
  151. * @brief : API to submit the base & length (BL's) for acquired CDM
  152. *
  153. * @handle : Input cdm handle to which the BL's needs to be sumbitted.
  154. * @data : Input pointer to the BL's to be sumbitted
  155. *
  156. * @return 0 on success
  157. */
  158. int cam_cdm_submit_bls(uint32_t handle, struct cam_cdm_bl_request *data);
  159. /**
  160. * @brief : API to stream ON a previously acquired CDM,
  161. * during this we turn on/off clocks/power based on active clients.
  162. *
  163. * @handle : Input handle for the CDM to be released
  164. *
  165. * @return 0 on success
  166. */
  167. int cam_cdm_stream_on(uint32_t handle);
  168. /**
  169. * @brief : API to stream OFF a previously acquired CDM,
  170. * during this we turn on/off clocks/power based on active clients.
  171. *
  172. * @handle : Input handle for the CDM to be released
  173. *
  174. * @return 0 on success
  175. */
  176. int cam_cdm_stream_off(uint32_t handle);
  177. /**
  178. * @brief : API to reset previously acquired CDM,
  179. * this can be only performed only the CDM is private.
  180. *
  181. * @handle : Input handle of the CDM to reset
  182. *
  183. * @return 0 on success
  184. */
  185. int cam_cdm_reset_hw(uint32_t handle);
  186. /**
  187. * @brief : API to register CDM hw to platform framework.
  188. * @return struct platform_device pointer on on success, or ERR_PTR() on error.
  189. */
  190. int cam_hw_cdm_init_module(void);
  191. /**
  192. * @brief : API to register CDM interface to platform framework.
  193. * @return struct platform_device pointer on on success, or ERR_PTR() on error.
  194. */
  195. int cam_cdm_intf_init_module(void);
  196. /**
  197. * @brief : API to remove CDM interface from platform framework.
  198. */
  199. void cam_cdm_intf_exit_module(void);
  200. /**
  201. * @brief : API to remove CDM hw from platform framework.
  202. */
  203. void cam_hw_cdm_exit_module(void);
  204. #endif /* _CAM_CDM_API_H_ */