cam_tfe.h 15 KB

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