cam_tfe.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __UAPI_CAM_TFE_H__
  6. #define __UAPI_CAM_TFE_H__
  7. #include "cam_defs.h"
  8. #include "cam_isp_tfe.h"
  9. #include "cam_cpas.h"
  10. /* ISP TFE driver name */
  11. #define CAM_ISP_TFE_DEV_NAME "cam-isp"
  12. /* HW type */
  13. #define CAM_ISP_TFE_HW_BASE 0
  14. #define CAM_ISP_TFE_HW_CSID 1
  15. #define CAM_ISP_TFE_HW_TFE 2
  16. #define CAM_ISP_TFE_HW_MAX 3
  17. /* Color Pattern */
  18. #define CAM_ISP_TFE_PATTERN_BAYER_RGRGRG 0
  19. #define CAM_ISP_TFE_PATTERN_BAYER_GRGRGR 1
  20. #define CAM_ISP_TFE_PATTERN_BAYER_BGBGBG 2
  21. #define CAM_ISP_TFE_PATTERN_BAYER_GBGBGB 3
  22. #define CAM_ISP_TFE_PATTERN_YUV_YCBYCR 4
  23. #define CAM_ISP_TFE_PATTERN_YUV_YCRYCB 5
  24. #define CAM_ISP_TFE_PATTERN_YUV_CBYCRY 6
  25. #define CAM_ISP_TFE_PATTERN_YUV_CRYCBY 7
  26. #define CAM_ISP_TFE_PATTERN_MAX 8
  27. /* Usage Type */
  28. #define CAM_ISP_TFE_IN_RES_USAGE_SINGLE 0
  29. #define CAM_ISP_TFE_IN_RES_USAGE_DUAL 1
  30. #define CAM_ISP_TFE_IN_RES_USAGE_MAX 2
  31. /* Resource ID */
  32. #define CAM_ISP_TFE_RES_ID_PORT 0
  33. #define CAM_ISP_TFE_RES_ID_MAX 1
  34. /* Resource Type - Type of resource for the resource id
  35. * defined in cam_isp_tfe.h
  36. */
  37. /* Lane Type in input resource for Port */
  38. #define CAM_ISP_TFE_IN_LANE_TYPE_DPHY 0
  39. #define CAM_ISP_TFE_IN_LANE_TYPE_CPHY 1
  40. #define CAM_ISP_TFE_IN_LANE_TYPE_MAX 2
  41. /* ISP TFE packet opcode */
  42. #define CAM_ISP_TFE_PACKET_OP_BASE 0
  43. #define CAM_ISP_TFE_PACKET_INIT_DEV 1
  44. #define CAM_ISP_TFE_PACKET_CONFIG_DEV 2
  45. #define CAM_ISP_TFE_PACKET_OP_MAX 3
  46. /* ISP TFE packet meta_data type for command buffer */
  47. #define CAM_ISP_TFE_PACKET_META_BASE 0
  48. #define CAM_ISP_TFE_PACKET_META_LEFT 1
  49. #define CAM_ISP_TFE_PACKET_META_RIGHT 2
  50. #define CAM_ISP_TFE_PACKET_META_COMMON 3
  51. #define CAM_ISP_TFE_PACKET_META_DUAL_CONFIG 4
  52. #define CAM_ISP_TFE_PACKET_META_GENERIC_BLOB_COMMON 5
  53. #define CAM_ISP_TFE_PACKET_META_REG_DUMP_PER_REQUEST 6
  54. #define CAM_ISP_TFE_PACKET_META_REG_DUMP_ON_FLUSH 7
  55. #define CAM_ISP_TFE_PACKET_META_REG_DUMP_ON_ERROR 8
  56. /* ISP TFE Generic Cmd Buffer Blob types */
  57. #define CAM_ISP_TFE_GENERIC_BLOB_TYPE_HFR_CONFIG 0
  58. #define CAM_ISP_TFE_GENERIC_BLOB_TYPE_CLOCK_CONFIG 1
  59. #define CAM_ISP_TFE_GENERIC_BLOB_TYPE_BW_CONFIG_V2 2
  60. #define CAM_ISP_TFE_GENERIC_BLOB_TYPE_CSID_CLOCK_CONFIG 3
  61. /* DSP mode */
  62. #define CAM_ISP_TFE_DSP_MODE_NONE 0
  63. #define CAM_ISP_TFE_DSP_MODE_ONE_WAY 1
  64. #define CAM_ISP_TFE_DSP_MODE_ROUND 2
  65. /* Per Path Usage Data */
  66. #define CAM_ISP_TFE_USAGE_INVALID 0
  67. #define CAM_ISP_TFE_USAGE_LEFT_PX 1
  68. #define CAM_ISP_TFE_USAGE_RIGHT_PX 2
  69. #define CAM_ISP_TFE_USAGE_RDI 3
  70. /* Query devices */
  71. /**
  72. * struct cam_isp_tfe_dev_cap_info - A cap info for particular hw type
  73. *
  74. * @hw_type: Hardware type for the cap info
  75. * @reserved: reserved field for alignment
  76. * @hw_version: Hardware version
  77. *
  78. */
  79. struct cam_isp_tfe_dev_cap_info {
  80. uint32_t hw_type;
  81. uint32_t reserved;
  82. struct cam_hw_version hw_version;
  83. };
  84. /**
  85. * struct cam_isp_tfe_query_cap_cmd - ISP TFE query device
  86. * capability payload
  87. *
  88. * @device_iommu: returned iommu handles for device
  89. * @cdm_iommu: returned iommu handles for cdm
  90. * @num_dev: returned number of device capabilities
  91. * @reserved: reserved field for alignment
  92. * @dev_caps: returned device capability array
  93. *
  94. */
  95. struct cam_isp_tfe_query_cap_cmd {
  96. struct cam_iommu_handle device_iommu;
  97. struct cam_iommu_handle cdm_iommu;
  98. int32_t num_dev;
  99. uint32_t reserved;
  100. struct cam_isp_tfe_dev_cap_info dev_caps[CAM_ISP_TFE_HW_MAX];
  101. };
  102. /* Acquire Device */
  103. /**
  104. * struct cam_isp_tfe_out_port_info - An output port resource info
  105. *
  106. * @res_id: output resource id defined in file
  107. * cam_isp_tfe.h
  108. * @format: output format of the resource
  109. * @width: output width in pixels
  110. * @height: output height in lines
  111. * @stride: output stride
  112. * @comp_grp_id: composite group id for the resource.
  113. * @secure_mode: flag to tell if output should be run in secure
  114. * mode or not. See cam_defs.h for definition
  115. * @wm_mode: wm mode
  116. * @reserved: reserved field for alignment
  117. *
  118. */
  119. struct cam_isp_tfe_out_port_info {
  120. uint32_t res_id;
  121. uint32_t format;
  122. uint32_t width;
  123. uint32_t height;
  124. uint32_t stride;
  125. uint32_t comp_grp_id;
  126. uint32_t secure_mode;
  127. uint32_t wm_mode;
  128. uint32_t reserved;
  129. };
  130. /**
  131. * struct cam_isp_tfe_in_port_info - An input port resource info
  132. *
  133. * @res_id: input resource id CAM_ISP_TFE_IN_RES_XXX
  134. * @lane_type: lane type: c-phy or d-phy.
  135. * @lane_num: active lane number
  136. * @lane_cfg: lane configurations: 4 bits per lane
  137. * @vc: input virtual channel number
  138. * @dt: input data type number
  139. * @format: input format
  140. * @pix_pattern: pixel pattern
  141. * @usage_type: whether dual tfe is required
  142. * @left_start: left input start offset in pixels
  143. * @left_end: left input stop offset in pixels
  144. * @left_width: left input width in pixels
  145. * @right_start: right input start offset in pixels.
  146. * Only for Dual TFE
  147. * @right_end: right input stop offset in
  148. * pixels. Only for Dual TFE
  149. * @right_width: right input width in pixels.
  150. * Only for dual TFE
  151. * @line_start: top of the line number
  152. * @line_stop: bottome of the line number
  153. * @height: input height in lines
  154. * @batch_size: batch size for HFR mode
  155. * @dsp_mode: DSP stream mode(Defines as
  156. * CAM_ISP_TFE_DSP_MODE_*)
  157. * @sensor_width: sensor width
  158. * @sensor_height: sensor height
  159. * @hbi_value: sensor HBI value
  160. * @vbi_value: sensor VBI value
  161. * @sensor_fps: sensor fps
  162. * @init_frame_drop init frame drop value.
  163. * @num_out_res: number of the output resource associated
  164. * @data: payload that contains the output resources,
  165. * array of cam_isp_tfe_out_port_info data
  166. *
  167. */
  168. struct cam_isp_tfe_in_port_info {
  169. uint32_t res_id;
  170. uint32_t lane_type;
  171. uint32_t lane_num;
  172. uint32_t lane_cfg;
  173. uint32_t vc;
  174. uint32_t dt;
  175. uint32_t format;
  176. uint32_t pix_pattern;
  177. uint32_t usage_type;
  178. uint32_t left_start;
  179. uint32_t left_end;
  180. uint32_t left_width;
  181. uint32_t right_start;
  182. uint32_t right_end;
  183. uint32_t right_width;
  184. uint32_t line_start;
  185. uint32_t line_end;
  186. uint32_t height;
  187. uint32_t batch_size;
  188. uint32_t dsp_mode;
  189. uint32_t sensor_width;
  190. uint32_t sensor_height;
  191. uint32_t sensor_hbi;
  192. uint32_t sensor_vbi;
  193. uint32_t sensor_fps;
  194. uint32_t init_frame_drop;
  195. uint32_t num_out_res;
  196. struct cam_isp_tfe_out_port_info data[1];
  197. };
  198. /**
  199. * struct cam_isp_tfe_resource - A resource bundle
  200. *
  201. * @resoruce_id: resource id for the resource bundle
  202. * @length: length of the while resource blob
  203. * @handle_type: type of the resource handle
  204. * @reserved: reserved field for alignment
  205. * @res_hdl: resource handle that points to the
  206. * resource array
  207. *
  208. */
  209. struct cam_isp_tfe_resource {
  210. uint32_t resource_id;
  211. uint32_t length;
  212. uint32_t handle_type;
  213. uint32_t reserved;
  214. uint64_t res_hdl;
  215. };
  216. /**
  217. * struct cam_isp_tfe_port_hfr_config - HFR configuration for
  218. * this port
  219. *
  220. * @resource_type: Resource type
  221. * @subsample_pattern: Subsample pattern. Used in HFR mode. It
  222. * should be consistent with batchSize and
  223. * CAMIF programming.
  224. * @subsample_period: Subsample period. Used in HFR mode. It
  225. * should be consistent with batchSize and
  226. * CAMIF programming.
  227. * @framedrop_pattern: Framedrop pattern
  228. * @framedrop_period: Framedrop period
  229. * @reserved: Reserved for alignment
  230. */
  231. struct cam_isp_tfe_port_hfr_config {
  232. uint32_t resource_type;
  233. uint32_t subsample_pattern;
  234. uint32_t subsample_period;
  235. uint32_t framedrop_pattern;
  236. uint32_t framedrop_period;
  237. uint32_t reserved;
  238. } __attribute__((packed));
  239. /**
  240. * struct cam_isp_tfe_resource_hfr_config - Resource HFR
  241. * configuration
  242. *
  243. * @num_ports: Number of ports
  244. * @reserved: Reserved for alignment
  245. * @port_hfr_config: HFR configuration for each IO port
  246. */
  247. struct cam_isp_tfe_resource_hfr_config {
  248. uint32_t num_ports;
  249. uint32_t reserved;
  250. struct cam_isp_tfe_port_hfr_config port_hfr_config[1];
  251. } __attribute__((packed));
  252. /**
  253. * struct cam_isp_tfe_dual_stripe_config - stripe config per bus
  254. * client
  255. *
  256. * @offset: Start horizontal offset relative to
  257. * output buffer
  258. * @width: Width of the stripe in pixels
  259. * @port_id: Port id of ISP TFE output
  260. * @reserved: Reserved for alignment
  261. *
  262. */
  263. struct cam_isp_tfe_dual_stripe_config {
  264. uint32_t offset;
  265. uint32_t width;
  266. uint32_t port_id;
  267. uint32_t reserved;
  268. };
  269. /**
  270. * struct cam_isp_tfe_dual_config - dual isp configuration
  271. *
  272. * @num_ports Number of isp output ports
  273. * @reserved Reserved field for alignment
  274. * @stripes: Stripe information
  275. *
  276. */
  277. struct cam_isp_tfe_dual_config {
  278. uint32_t num_ports;
  279. uint32_t reserved;
  280. struct cam_isp_tfe_dual_stripe_config stripes[1];
  281. } __attribute__((packed));
  282. /**
  283. * struct cam_isp_tfe_clock_config - Clock configuration
  284. *
  285. * @usage_type: Usage type (Single/Dual)
  286. * @num_rdi: Number of RDI votes
  287. * @left_pix_hz: Pixel Clock for Left ISP
  288. * @right_pix_hz: Pixel Clock for Right ISP
  289. * valid only if Dual
  290. * @rdi_hz: RDI Clock. ISP TFE clock will be
  291. * max of RDI and PIX clocks. For a
  292. * particular context which ISP TFE
  293. * HW the RDI is allocated to is
  294. * not known to UMD. Hence pass the
  295. * clock and let KMD decide.
  296. */
  297. struct cam_isp_tfe_clock_config {
  298. uint32_t usage_type;
  299. uint32_t num_rdi;
  300. uint64_t left_pix_hz;
  301. uint64_t right_pix_hz;
  302. uint64_t rdi_hz[1];
  303. } __attribute__((packed));
  304. /**
  305. * struct cam_isp_tfe_csid_clock_config - CSID clock
  306. * configuration
  307. *
  308. * @csid_clock CSID clock
  309. * @csi_phy_clock Phy clock valid if tpg is selected
  310. */
  311. struct cam_isp_tfe_csid_clock_config {
  312. uint64_t csid_clock;
  313. uint64_t phy_clock;
  314. } __attribute__((packed));
  315. /**
  316. * struct cam_isp_tfe_bw_config_v2 - Bandwidth configuration
  317. *
  318. * @usage_type: Usage type (Single/Dual)
  319. * @num_paths: Number of axi data paths
  320. * @axi_path Per path vote info
  321. */
  322. struct cam_isp_tfe_bw_config_v2 {
  323. uint32_t usage_type;
  324. uint32_t num_paths;
  325. struct cam_axi_per_path_bw_vote axi_path[1];
  326. } __attribute__((packed));
  327. /**
  328. * struct cam_isp_acquire_hw_info - ISP TFE acquire HW params
  329. *
  330. * @common_info_version : Version of common info struct used
  331. * @common_info_size : Size of common info struct used
  332. * @common_info_offset : Offset of common info from start of data
  333. * @num_inputs : Number of inputs
  334. * @input_info_version : Version of input info struct used
  335. * @input_info_size : Size of input info struct used
  336. * @input_info_offset : Offset of input info from start of data
  337. * @data : Data pointer to point the cam_isp_tfe_in_port_info
  338. * structure
  339. */
  340. struct cam_isp_tfe_acquire_hw_info {
  341. uint16_t common_info_version;
  342. uint16_t common_info_size;
  343. uint32_t common_info_offset;
  344. uint32_t num_inputs;
  345. uint32_t input_info_version;
  346. uint32_t input_info_size;
  347. uint32_t input_info_offset;
  348. uint64_t data;
  349. };
  350. #define CAM_TFE_ACQUIRE_COMMON_VER0 0x1000
  351. #define CAM_TFE_ACQUIRE_COMMON_SIZE_VER0 0x0
  352. #define CAM_TFE_ACQUIRE_INPUT_VER0 0x2000
  353. #define CAM_TFE_ACQUIRE_INPUT_SIZE_VER0 sizeof(struct cam_isp_tfe_in_port_info)
  354. #define CAM_TFE_ACQUIRE_OUT_VER0 0x3000
  355. #define CAM_TFE_ACQUIRE_OUT_SIZE_VER0 sizeof(struct cam_isp_tfe_out_port_info)
  356. #endif /* __UAPI_CAM_TFE_H__ */