cam_icp.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __UAPI_CAM_ICP_H__
  7. #define __UAPI_CAM_ICP_H__
  8. #include <media/cam_defs.h>
  9. #include <media/cam_cpas.h>
  10. /* icp, ipe, bps, cdm(ipe/bps) are used in querycap */
  11. #define CAM_ICP_DEV_TYPE_A5 1
  12. #define CAM_ICP_DEV_TYPE_IPE 2
  13. #define CAM_ICP_DEV_TYPE_BPS 3
  14. #define CAM_ICP_DEV_TYPE_IPE_CDM 4
  15. #define CAM_ICP_DEV_TYPE_BPS_CDM 5
  16. /**
  17. * This macro is deprecated; a device type max is not necessary.
  18. * The new macro CAM_ICP_MAX_NUM_OF_DEV_TYPES will dictate
  19. * max number of different types of devices supported by a single
  20. * instance of the ICP device.
  21. */
  22. #define CAM_ICP_DEV_TYPE_MAX 5
  23. /* ICP and OFE types added to indicate capability to userspace */
  24. #define CAM_ICP_DEV_TYPE_ICP 6
  25. #define CAM_ICP_DEV_TYPE_OFE 7
  26. /* definitions needed for icp aquire device */
  27. #define CAM_ICP_RES_TYPE_BPS 1
  28. #define CAM_ICP_RES_TYPE_IPE_RT 2
  29. #define CAM_ICP_RES_TYPE_IPE 3
  30. #define CAM_ICP_RES_TYPE_IPE_SEMI_RT 4
  31. #define CAM_ICP_RES_TYPE_BPS_RT 5
  32. #define CAM_ICP_RES_TYPE_BPS_SEMI_RT 6
  33. /* This macro is deprecated and no longer needed */
  34. #define CAM_ICP_RES_TYPE_MAX 7
  35. #define CAM_ICP_RES_TYPE_OFE_RT 7
  36. #define CAM_ICP_RES_TYPE_OFE 8
  37. #define CAM_ICP_RES_TYPE_OFE_SEMI_RT 9
  38. /* packet opcode types */
  39. #define CAM_ICP_OPCODE_IPE_UPDATE 0
  40. #define CAM_ICP_OPCODE_BPS_UPDATE 1
  41. #define CAM_ICP_OPCODE_IPE_SETTINGS 2
  42. #define CAM_ICP_OPCODE_BPS_SETTINGS 3
  43. #define CAM_ICP_OPCODE_OFE_UPDATE 4
  44. #define CAM_ICP_OPCODE_OFE_SETTINGS 5
  45. /* IPE input port resource type */
  46. #define CAM_ICP_IPE_INPUT_IMAGE_FULL 0x0
  47. #define CAM_ICP_IPE_INPUT_IMAGE_DS4 0x1
  48. #define CAM_ICP_IPE_INPUT_IMAGE_DS16 0x2
  49. #define CAM_ICP_IPE_INPUT_IMAGE_DS64 0x3
  50. #define CAM_ICP_IPE_INPUT_IMAGE_FULL_REF 0x4
  51. #define CAM_ICP_IPE_INPUT_IMAGE_DS4_REF 0x5
  52. #define CAM_ICP_IPE_INPUT_IMAGE_DS16_REF 0x6
  53. #define CAM_ICP_IPE_INPUT_IMAGE_DS64_REF 0x7
  54. /* IPE output port resource type */
  55. #define CAM_ICP_IPE_OUTPUT_IMAGE_DISPLAY 0x8
  56. #define CAM_ICP_IPE_OUTPUT_IMAGE_VIDEO 0x9
  57. #define CAM_ICP_IPE_OUTPUT_IMAGE_FULL_REF 0xA
  58. #define CAM_ICP_IPE_OUTPUT_IMAGE_DS4_REF 0xB
  59. #define CAM_ICP_IPE_OUTPUT_IMAGE_DS16_REF 0xC
  60. #define CAM_ICP_IPE_OUTPUT_IMAGE_DS64_REF 0xD
  61. #define CAM_ICP_IPE_OUTPUT_IMAGE_FD 0x33
  62. #define CAM_ICP_IPE_OUTPUT_IMAGE_STATS_IHIST 0x3D
  63. #define CAM_ICP_IPE_IMAGE_MAX (CAM_ICP_IPE_OUTPUT_IMAGE_STATS_IHIST + 1)
  64. /* BPS input port resource type */
  65. #define CAM_ICP_BPS_INPUT_IMAGE 0x0
  66. /* BPS output port resource type */
  67. #define CAM_ICP_BPS_OUTPUT_IMAGE_FULL 0x1
  68. #define CAM_ICP_BPS_OUTPUT_IMAGE_DS4 0x2
  69. #define CAM_ICP_BPS_OUTPUT_IMAGE_DS16 0x3
  70. #define CAM_ICP_BPS_OUTPUT_IMAGE_DS64 0x4
  71. #define CAM_ICP_BPS_OUTPUT_IMAGE_STATS_BG 0x5
  72. #define CAM_ICP_BPS_OUTPUT_IMAGE_STATS_BHIST 0x6
  73. #define CAM_ICP_BPS_OUTPUT_IMAGE_REG1 0x7
  74. #define CAM_ICP_BPS_OUTPUT_IMAGE_REG2 0x8
  75. #define CAM_ICP_BPS_IO_IMAGES_MAX 0x9
  76. /* Command meta types */
  77. #define CAM_ICP_CMD_META_GENERIC_BLOB 0x1
  78. /* Generic blob types */
  79. #define CAM_ICP_CMD_GENERIC_BLOB_CLK 0x1
  80. #define CAM_ICP_CMD_GENERIC_BLOB_CFG_IO 0x2
  81. #define CAM_ICP_CMD_GENERIC_BLOB_FW_MEM_MAP 0x3
  82. #define CAM_ICP_CMD_GENERIC_BLOB_FW_MEM_UNMAP 0x4
  83. #define CAM_ICP_CMD_GENERIC_BLOB_CLK_V2 0x5
  84. #define CAM_ICP_CMD_GENERIC_BLOB_PRESIL_HANGDUMP 0x6
  85. /* Max number of device types supported per ICP instance */
  86. #define CAM_ICP_MAX_NUM_OF_DEV_TYPES 0x5
  87. /**
  88. * struct cam_icp_clk_bw_request_v2
  89. *
  90. * @budget_ns: Time required to process frame
  91. * @frame_cycles: Frame cycles needed to process the frame
  92. * @rt_flag: Flag to indicate real time stream
  93. * @reserved: For memory alignment
  94. * @num_paths: Number of axi paths in bw request
  95. * @axi_path: Per path vote info for IPE/BPS
  96. */
  97. struct cam_icp_clk_bw_request_v2 {
  98. __u64 budget_ns;
  99. __u32 frame_cycles;
  100. __u32 rt_flag;
  101. __u32 reserved;
  102. __u32 num_paths;
  103. struct cam_axi_per_path_bw_vote axi_path[1];
  104. };
  105. /**
  106. * struct cam_icp_clk_bw_request
  107. *
  108. * @budget_ns: Time required to process frame
  109. * @frame_cycles: Frame cycles needed to process the frame
  110. * @rt_flag: Flag to indicate real time stream
  111. * @uncompressed_bw: Bandwidth required to process frame
  112. * @compressed_bw: Compressed bandwidth to process frame
  113. */
  114. struct cam_icp_clk_bw_request {
  115. __u64 budget_ns;
  116. __u32 frame_cycles;
  117. __u32 rt_flag;
  118. __u64 uncompressed_bw;
  119. __u64 compressed_bw;
  120. };
  121. /**
  122. * struct cam_icp_dev_ver - Device information for particular hw type
  123. *
  124. * This is used to get device version info of
  125. * ICP, IPE, BPS and CDM related IPE and BPS from firmware
  126. * and use this info in CAM_QUERY_CAP IOCTL
  127. *
  128. * @dev_type: hardware type for the cap info(icp, ipe, bps, cdm(ipe/bps))
  129. * @reserved: reserved field
  130. * @hw_ver: major, minor and incr values of a device version
  131. */
  132. struct cam_icp_dev_ver {
  133. __u32 dev_type;
  134. __u32 reserved;
  135. struct cam_hw_version hw_ver;
  136. };
  137. /**
  138. * struct cam_icp_ver - ICP version info
  139. *
  140. * This strcuture is used for fw and api version
  141. * this is used to get firmware version and api version from firmware
  142. * and use this info in CAM_QUERY_CAP IOCTL
  143. *
  144. * @major: FW version major
  145. * @minor: FW version minor
  146. * @revision: FW version increment
  147. */
  148. struct cam_icp_ver {
  149. __u32 major;
  150. __u32 minor;
  151. __u32 revision;
  152. __u32 reserved;
  153. };
  154. /**
  155. * struct cam_icp_query_cap_cmd - ICP query device capability payload
  156. *
  157. * @dev_iommu_handle: icp iommu handles for secure/non secure modes
  158. * @cdm_iommu_handle: iommu handles for secure/non secure modes
  159. * @fw_version: firmware version info
  160. * @api_version: api version info
  161. * @num_ipe: number of ipes
  162. * @num_bps: number of bps
  163. * @dev_ver: returned device capability array
  164. */
  165. struct cam_icp_query_cap_cmd {
  166. struct cam_iommu_handle dev_iommu_handle;
  167. struct cam_iommu_handle cdm_iommu_handle;
  168. struct cam_icp_ver fw_version;
  169. struct cam_icp_ver api_version;
  170. __u32 num_ipe;
  171. __u32 num_bps;
  172. struct cam_icp_dev_ver dev_ver[CAM_ICP_DEV_TYPE_MAX];
  173. };
  174. /**
  175. * struct cam_icp_device_info - ICP device info
  176. *
  177. * @dev_type: type of the device (IPE/BPS/..)
  178. * @num_devices: number of such devices
  179. * @dev_version: device HW version
  180. * @num_valid_params: number of valid params
  181. * @valid_param_mask: valid param mask
  182. * @params: additional parameters for future usage
  183. */
  184. struct cam_icp_device_info {
  185. __u32 dev_type;
  186. __u32 num_devices;
  187. struct cam_hw_version dev_version;
  188. __u32 num_valid_params;
  189. __u32 valid_param_mask;
  190. __u32 params[6];
  191. };
  192. /**
  193. * struct cam_icp_query_cap_cmd_v2 - ICP query device capability payload
  194. *
  195. * @version: struct version
  196. * @dev_iommu_handle: icp iommu handles for secure/non secure modes
  197. * @cdm_iommu_handle: iommu handles for secure/non secure modes
  198. * @fw_version: firmware version info
  199. * @num_dev_info: number of devices present in this queried subdevice
  200. * @dev_info: returned icp devices capability array
  201. * @hw_fence_info_size: size of the data pointed to by hw_fence_info_hdl
  202. * if the size is 0, hw fence info will not be populated
  203. * treated as non-fatal
  204. * @hw_fence_info_hdl: Handle to the hw fence session data if applicable
  205. * @num_valid_params: number of valid params
  206. * @valid_param_mask: valid param mask
  207. * @params: additional parameters for future usage
  208. */
  209. struct cam_icp_query_cap_cmd_v2 {
  210. __u32 version;
  211. struct cam_iommu_handle dev_iommu_handle;
  212. struct cam_iommu_handle cdm_iommu_handle;
  213. struct cam_icp_ver fw_version;
  214. __u32 num_dev_info;
  215. struct cam_icp_device_info dev_info[CAM_ICP_MAX_NUM_OF_DEV_TYPES];
  216. __u32 hw_fence_info_size;
  217. __u64 hw_fence_info_hdl;
  218. __u32 num_valid_params;
  219. __u32 valid_param_mask;
  220. __u32 params[5];
  221. };
  222. /**
  223. * struct cam_icp_res_info - ICP output resource info
  224. *
  225. * @format: format of the resource
  226. * @width: width in pixels
  227. * @height: height in lines
  228. * @fps: fps
  229. */
  230. struct cam_icp_res_info {
  231. __u32 format;
  232. __u32 width;
  233. __u32 height;
  234. __u32 fps;
  235. };
  236. /**
  237. * struct cam_icp_acquire_dev_info - An ICP device info
  238. *
  239. * @scratch_mem_size: Output param - size of scratch memory
  240. * @dev_type: device type (IPE_RT/IPE_NON_RT/BPS)
  241. * @io_config_cmd_size: size of IO config command
  242. * @io_config_cmd_handle: IO config command for each acquire
  243. * @secure_mode: camera mode (secure/non secure)
  244. * @chain_info: chaining info of FW device handles
  245. * @in_res: resource info used for clock and bandwidth calculation
  246. * @num_out_res: number of output resources
  247. * @out_res: output resource
  248. */
  249. struct cam_icp_acquire_dev_info {
  250. __u32 scratch_mem_size;
  251. __u32 dev_type;
  252. __u32 io_config_cmd_size;
  253. __s32 io_config_cmd_handle;
  254. __u32 secure_mode;
  255. __s32 chain_info;
  256. struct cam_icp_res_info in_res;
  257. __u32 num_out_res;
  258. struct cam_icp_res_info out_res[1];
  259. } __attribute__((__packed__));
  260. #endif /* __UAPI_CAM_ICP_H__ */