cam_tfe.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __UAPI_CAM_TFE_H__
  7. #define __UAPI_CAM_TFE_H__
  8. #include <media/cam_defs.h>
  9. #include <media/cam_isp_tfe.h>
  10. #include <media/cam_cpas.h>
  11. /* ISP TFE driver name */
  12. #define CAM_ISP_TFE_DEV_NAME "cam-isp"
  13. /* HW type */
  14. #define CAM_ISP_TFE_HW_BASE 0
  15. #define CAM_ISP_TFE_HW_CSID 1
  16. #define CAM_ISP_TFE_HW_TFE 2
  17. #define CAM_ISP_TFE_HW_MAX 3
  18. /* Color Pattern */
  19. #define CAM_ISP_TFE_PATTERN_BAYER_RGRGRG 0
  20. #define CAM_ISP_TFE_PATTERN_BAYER_GRGRGR 1
  21. #define CAM_ISP_TFE_PATTERN_BAYER_BGBGBG 2
  22. #define CAM_ISP_TFE_PATTERN_BAYER_GBGBGB 3
  23. #define CAM_ISP_TFE_PATTERN_YUV_YCBYCR 4
  24. #define CAM_ISP_TFE_PATTERN_YUV_YCRYCB 5
  25. #define CAM_ISP_TFE_PATTERN_YUV_CBYCRY 6
  26. #define CAM_ISP_TFE_PATTERN_YUV_CRYCBY 7
  27. #define CAM_ISP_TFE_PATTERN_MAX 8
  28. /* Usage Type */
  29. #define CAM_ISP_TFE_IN_RES_USAGE_SINGLE 0
  30. #define CAM_ISP_TFE_IN_RES_USAGE_DUAL 1
  31. #define CAM_ISP_TFE_IN_RES_USAGE_MAX 2
  32. /* Resource ID */
  33. #define CAM_ISP_TFE_RES_ID_PORT 0
  34. #define CAM_ISP_TFE_RES_ID_MAX 1
  35. /* Resource Type - Type of resource for the resource id
  36. * defined in cam_isp_tfe.h
  37. */
  38. /* Lane Type in input resource for Port */
  39. #define CAM_ISP_TFE_IN_LANE_TYPE_DPHY 0
  40. #define CAM_ISP_TFE_IN_LANE_TYPE_CPHY 1
  41. #define CAM_ISP_TFE_IN_LANE_TYPE_MAX 2
  42. /* ISP TFE packet opcode */
  43. #define CAM_ISP_TFE_PACKET_OP_BASE 0
  44. #define CAM_ISP_TFE_PACKET_INIT_DEV 1
  45. #define CAM_ISP_TFE_PACKET_CONFIG_DEV 2
  46. #define CAM_ISP_TFE_PACKET_OP_MAX 3
  47. /* ISP TFE packet meta_data type for command buffer */
  48. #define CAM_ISP_TFE_PACKET_META_BASE 0
  49. #define CAM_ISP_TFE_PACKET_META_LEFT 1
  50. #define CAM_ISP_TFE_PACKET_META_RIGHT 2
  51. #define CAM_ISP_TFE_PACKET_META_COMMON 3
  52. #define CAM_ISP_TFE_PACKET_META_DUAL_CONFIG 4
  53. #define CAM_ISP_TFE_PACKET_META_GENERIC_BLOB_COMMON 5
  54. #define CAM_ISP_TFE_PACKET_META_REG_DUMP_PER_REQUEST 6
  55. #define CAM_ISP_TFE_PACKET_META_REG_DUMP_ON_FLUSH 7
  56. #define CAM_ISP_TFE_PACKET_META_REG_DUMP_ON_ERROR 8
  57. /* ISP TFE Generic Cmd Buffer Blob types */
  58. #define CAM_ISP_TFE_GENERIC_BLOB_TYPE_HFR_CONFIG 0
  59. #define CAM_ISP_TFE_GENERIC_BLOB_TYPE_CLOCK_CONFIG 1
  60. #define CAM_ISP_TFE_GENERIC_BLOB_TYPE_BW_CONFIG_V2 2
  61. #define CAM_ISP_TFE_GENERIC_BLOB_TYPE_CSID_CLOCK_CONFIG 3
  62. #define CAM_ISP_TFE_GENERIC_BLOB_TYPE_BW_LIMITER_CFG 16
  63. #define CAM_ISP_TFE_GENERIC_BLOB_TYPE_DYNAMIC_MODE_SWITCH 15
  64. /* DSP mode */
  65. #define CAM_ISP_TFE_DSP_MODE_NONE 0
  66. #define CAM_ISP_TFE_DSP_MODE_ONE_WAY 1
  67. #define CAM_ISP_TFE_DSP_MODE_ROUND 2
  68. /* Per Path Usage Data */
  69. #define CAM_ISP_TFE_USAGE_INVALID 0
  70. #define CAM_ISP_TFE_USAGE_LEFT_PX 1
  71. #define CAM_ISP_TFE_USAGE_RIGHT_PX 2
  72. #define CAM_ISP_TFE_USAGE_RDI 3
  73. /* Bus write master modes */
  74. #define CAM_ISP_TFE_WM_FRAME_BASED_MODE 0
  75. #define CAM_ISP_TFE_WM_LINE_BASED_MODE 1
  76. #define CAM_ISP_TFE_WM_INDEX_BASED_MODE 2
  77. #define CAM_ISP_TFE_VC_DT_CFG 2
  78. /* Feature Flag indicators */
  79. #define CAM_ISP_TFE_FLAG_QCFA_BIN BIT(0)
  80. #define CAM_ISP_TFE_FLAG_BAYER_BIN BIT(1)
  81. /* Query devices */
  82. /**
  83. * struct cam_isp_tfe_dev_cap_info - A cap info for particular hw type
  84. *
  85. * @hw_type: Hardware type for the cap info
  86. * @reserved: reserved field for alignment
  87. * @hw_version: Hardware version
  88. *
  89. */
  90. struct cam_isp_tfe_dev_cap_info {
  91. __u32 hw_type;
  92. __u32 reserved;
  93. struct cam_hw_version hw_version;
  94. };
  95. /**
  96. * struct cam_isp_tfe_query_cap_cmd - ISP TFE query device
  97. * capability payload
  98. *
  99. * @device_iommu: returned iommu handles for device
  100. * @cdm_iommu: returned iommu handles for cdm
  101. * @num_dev: returned number of device capabilities
  102. * @reserved: reserved field for alignment
  103. * @dev_caps: returned device capability array
  104. *
  105. */
  106. struct cam_isp_tfe_query_cap_cmd {
  107. struct cam_iommu_handle device_iommu;
  108. struct cam_iommu_handle cdm_iommu;
  109. __s32 num_dev;
  110. __u32 reserved;
  111. struct cam_isp_tfe_dev_cap_info dev_caps[CAM_ISP_TFE_HW_MAX];
  112. };
  113. /* Acquire Device */
  114. /**
  115. * struct cam_isp_tfe_out_port_info - An output port resource info
  116. *
  117. * @res_id: output resource id defined in file
  118. * cam_isp_tfe.h
  119. * @format: output format of the resource
  120. * @width: output width in pixels
  121. * @height: output height in lines
  122. * @stride: output stride
  123. * @comp_grp_id: composite group id for the resource.
  124. * @secure_mode: flag to tell if output should be run in secure
  125. * mode or not. See cam_defs.h for definition
  126. * @wm_mode: wm mode
  127. * @reserved: reserved field for alignment
  128. *
  129. */
  130. struct cam_isp_tfe_out_port_info {
  131. __u32 res_id;
  132. __u32 format;
  133. __u32 width;
  134. __u32 height;
  135. __u32 stride;
  136. __u32 comp_grp_id;
  137. __u32 secure_mode;
  138. __u32 wm_mode;
  139. __u32 reserved;
  140. };
  141. /**
  142. * struct cam_isp_tfe_in_port_info - An input port resource info
  143. *
  144. * @res_id: input resource id CAM_ISP_TFE_IN_RES_XXX
  145. * @lane_type: lane type: c-phy or d-phy.
  146. * @lane_num: active lane number
  147. * @lane_cfg: lane configurations: 4 bits per lane
  148. * @vc: input virtual channel number
  149. * @dt: input data type number
  150. * @format: input format
  151. * @pix_pattern: pixel pattern
  152. * @usage_type: whether dual tfe is required
  153. * @left_start: left input start offset in pixels
  154. * @left_end: left input stop offset in pixels
  155. * @left_width: left input width in pixels
  156. * @right_start: right input start offset in pixels.
  157. * Only for Dual TFE
  158. * @right_end: right input stop offset in
  159. * pixels. Only for Dual TFE
  160. * @right_width: right input width in pixels.
  161. * Only for dual TFE
  162. * @line_start: top of the line number
  163. * @line_stop: bottome of the line number
  164. * @height: input height in lines
  165. * @batch_size: batch size for HFR mode
  166. * @dsp_mode: DSP stream mode(Defines as
  167. * CAM_ISP_TFE_DSP_MODE_*)
  168. * @sensor_width: sensor width
  169. * @sensor_height: sensor height
  170. * @hbi_value: sensor HBI value
  171. * @vbi_value: sensor VBI value
  172. * @sensor_fps: sensor fps
  173. * @init_frame_drop init frame drop value.
  174. * @num_out_res: number of the output resource associated
  175. * @data: payload that contains the output resources,
  176. * array of cam_isp_tfe_out_port_info data
  177. *
  178. */
  179. struct cam_isp_tfe_in_port_info {
  180. __u32 res_id;
  181. __u32 lane_type;
  182. __u32 lane_num;
  183. __u32 lane_cfg;
  184. __u32 vc;
  185. __u32 dt;
  186. __u32 format;
  187. __u32 pix_pattern;
  188. __u32 usage_type;
  189. __u32 left_start;
  190. __u32 left_end;
  191. __u32 left_width;
  192. __u32 right_start;
  193. __u32 right_end;
  194. __u32 right_width;
  195. __u32 line_start;
  196. __u32 line_end;
  197. __u32 height;
  198. __u32 batch_size;
  199. __u32 dsp_mode;
  200. __u32 sensor_width;
  201. __u32 sensor_height;
  202. __u32 sensor_hbi;
  203. __u32 sensor_vbi;
  204. __u32 sensor_fps;
  205. __u32 init_frame_drop;
  206. __u32 num_out_res;
  207. struct cam_isp_tfe_out_port_info data[1];
  208. };
  209. /**
  210. * struct cam_isp_tfe_in_port_info_v2 - An input port resource info
  211. *
  212. * @res_id: input resource id CAM_ISP_TFE_IN_RES_XXX
  213. * @lane_type: lane type: c-phy or d-phy.
  214. * @lane_num: active lane number
  215. * @lane_cfg: lane configurations: 4 bits per lane
  216. * @vc: input virtual channel number
  217. * @dt: input data type number
  218. * @format: input format
  219. * @pix_pattern: pixel pattern
  220. * @usage_type: whether dual tfe is required
  221. * @left_start: left input start offset in pixels
  222. * @left_end: left input stop offset in pixels
  223. * @left_width: left input width in pixels
  224. * @right_start: right input start offset in pixels.
  225. * Only for Dual TFE
  226. * @right_end: right input stop offset in
  227. * pixels. Only for Dual TFE
  228. * @right_width: right input width in pixels.
  229. * Only for dual TFE
  230. * @line_start: top of the line number
  231. * @line_stop: bottome of the line number
  232. * @height: input height in lines
  233. * @batch_size: batch size for HFR mode
  234. * @dsp_mode: DSP stream mode(Defines as
  235. * CAM_ISP_TFE_DSP_MODE_*)
  236. * @sensor_width: sensor width
  237. * @sensor_height: sensor height
  238. * @sensor_hbi: sensor HBI value
  239. * @sensor_vbi: sensor VBI value
  240. * @sensor_fps: sensor fps
  241. * @init_frame_drop init frame drop value.
  242. * @num_out_res: number of the output resource associated
  243. * @feature_flag: Feature flags for indicating QCFA, Bayer bin
  244. * @core_cfg: Core configuration
  245. * @reserve_field_1: Reserve field 1
  246. * @reserve_field_2: Reserve field 2
  247. * @reserve_field_3: Reserve field 3
  248. * @reserve_field_4: Reserve field 4
  249. * @reserve_field_5: Reserve field 5
  250. * @reserve_field_6: Reserve filed 6
  251. * @data: payload that contains the output resources,
  252. * array of cam_isp_tfe_out_port_info data
  253. *
  254. */
  255. struct cam_isp_tfe_in_port_info_v2 {
  256. __u32 res_id;
  257. __u32 lane_type;
  258. __u32 lane_num;
  259. __u32 lane_cfg;
  260. __u32 vc[CAM_ISP_TFE_VC_DT_CFG];
  261. __u32 dt[CAM_ISP_TFE_VC_DT_CFG];
  262. __u32 num_valid_vc_dt;
  263. __u32 format;
  264. __u32 pix_pattern;
  265. __u32 usage_type;
  266. __u32 left_start;
  267. __u32 left_end;
  268. __u32 left_width;
  269. __u32 right_start;
  270. __u32 right_end;
  271. __u32 right_width;
  272. __u32 line_start;
  273. __u32 line_end;
  274. __u32 height;
  275. __u32 batch_size;
  276. __u32 dsp_mode;
  277. __u32 sensor_width;
  278. __u32 sensor_height;
  279. __u32 sensor_hbi;
  280. __u32 sensor_vbi;
  281. __u32 sensor_fps;
  282. __u32 init_frame_drop;
  283. __u32 num_out_res;
  284. __u32 feature_flag;
  285. __u32 core_cfg;
  286. __u32 reserve_field_1;
  287. __u32 reserve_field_2;
  288. __u32 reserve_field_3;
  289. __u32 reserve_field_4;
  290. __u32 reserve_field_5;
  291. __u32 reserve_field_6;
  292. struct cam_isp_tfe_out_port_info data[1];
  293. };
  294. /**
  295. * struct cam_isp_tfe_resource - A resource bundle
  296. *
  297. * @resoruce_id: resource id for the resource bundle
  298. * @length: length of the while resource blob
  299. * @handle_type: type of the resource handle
  300. * @reserved: reserved field for alignment
  301. * @res_hdl: resource handle that points to the
  302. * resource array
  303. *
  304. */
  305. struct cam_isp_tfe_resource {
  306. __u32 resource_id;
  307. __u32 length;
  308. __u32 handle_type;
  309. __u32 reserved;
  310. __u64 res_hdl;
  311. };
  312. /**
  313. * struct cam_isp_tfe_port_hfr_config - HFR configuration for
  314. * this port
  315. *
  316. * @resource_type: Resource type
  317. * @subsample_pattern: Subsample pattern. Used in HFR mode. It
  318. * should be consistent with batchSize and
  319. * CAMIF programming.
  320. * @subsample_period: Subsample period. Used in HFR mode. It
  321. * should be consistent with batchSize and
  322. * CAMIF programming.
  323. * @framedrop_pattern: Framedrop pattern
  324. * @framedrop_period: Framedrop period
  325. * @reserved: Reserved for alignment
  326. */
  327. struct cam_isp_tfe_port_hfr_config {
  328. __u32 resource_type;
  329. __u32 subsample_pattern;
  330. __u32 subsample_period;
  331. __u32 framedrop_pattern;
  332. __u32 framedrop_period;
  333. __u32 reserved;
  334. } __attribute__((packed));
  335. /**
  336. * struct cam_isp_tfe_resource_hfr_config - Resource HFR
  337. * configuration
  338. *
  339. * @num_ports: Number of ports
  340. * @reserved: Reserved for alignment
  341. * @port_hfr_config: HFR configuration for each IO port
  342. */
  343. struct cam_isp_tfe_resource_hfr_config {
  344. __u32 num_ports;
  345. __u32 reserved;
  346. struct cam_isp_tfe_port_hfr_config port_hfr_config[1];
  347. } __attribute__((packed));
  348. /**
  349. * struct cam_isp_tfe_dual_stripe_config - stripe config per bus
  350. * client
  351. *
  352. * @offset: Start horizontal offset relative to
  353. * output buffer
  354. * @width: Width of the stripe in pixels
  355. * @port_id: Port id of ISP TFE output
  356. * @reserved: Reserved for alignment
  357. *
  358. */
  359. struct cam_isp_tfe_dual_stripe_config {
  360. __u32 offset;
  361. __u32 width;
  362. __u32 port_id;
  363. __u32 reserved;
  364. };
  365. /**
  366. * struct cam_isp_tfe_dual_config - dual isp configuration
  367. *
  368. * @num_ports Number of isp output ports
  369. * @reserved Reserved field for alignment
  370. * @stripes: Stripe information
  371. *
  372. */
  373. struct cam_isp_tfe_dual_config {
  374. __u32 num_ports;
  375. __u32 reserved;
  376. struct cam_isp_tfe_dual_stripe_config stripes[1];
  377. } __attribute__((packed));
  378. /**
  379. * struct cam_isp_tfe_clock_config - Clock configuration
  380. *
  381. * @usage_type: Usage type (Single/Dual)
  382. * @num_rdi: Number of RDI votes
  383. * @left_pix_hz: Pixel Clock for Left ISP
  384. * @right_pix_hz: Pixel Clock for Right ISP
  385. * valid only if Dual
  386. * @rdi_hz: RDI Clock. ISP TFE clock will be
  387. * max of RDI and PIX clocks. For a
  388. * particular context which ISP TFE
  389. * HW the RDI is allocated to is
  390. * not known to UMD. Hence pass the
  391. * clock and let KMD decide.
  392. */
  393. struct cam_isp_tfe_clock_config {
  394. __u32 usage_type;
  395. __u32 num_rdi;
  396. __u64 left_pix_hz;
  397. __u64 right_pix_hz;
  398. __u64 rdi_hz[1];
  399. } __attribute__((packed));
  400. /**
  401. * struct cam_isp_tfe_csid_clock_config - CSID clock
  402. * configuration
  403. *
  404. * @csid_clock CSID clock
  405. * @csi_phy_clock Phy clock valid if tpg is selected
  406. */
  407. struct cam_isp_tfe_csid_clock_config {
  408. __u64 csid_clock;
  409. __u64 phy_clock;
  410. } __attribute__((packed));
  411. /**
  412. * struct cam_isp_tfe_bw_config_v2 - Bandwidth configuration
  413. *
  414. * @usage_type: Usage type (Single/Dual)
  415. * @num_paths: Number of axi data paths
  416. * @axi_path Per path vote info
  417. */
  418. struct cam_isp_tfe_bw_config_v2 {
  419. __u32 usage_type;
  420. __u32 num_paths;
  421. struct cam_axi_per_path_bw_vote axi_path[1];
  422. } __attribute__((packed));
  423. /**
  424. * struct cam_isp_acquire_hw_info - ISP TFE acquire HW params
  425. *
  426. * @common_info_version : Version of common info struct used
  427. * @common_info_size : Size of common info struct used
  428. * @common_info_offset : Offset of common info from start of data
  429. * @num_inputs : Number of inputs
  430. * @input_info_version : Version of input info struct used
  431. * @input_info_size : Size of input info struct used
  432. * @input_info_offset : Offset of input info from start of data
  433. * @data : Data pointer to point the cam_isp_tfe_in_port_info
  434. * structure
  435. */
  436. struct cam_isp_tfe_acquire_hw_info {
  437. __u16 common_info_version;
  438. __u16 common_info_size;
  439. __u32 common_info_offset;
  440. __u32 num_inputs;
  441. __u32 input_info_version;
  442. __u32 input_info_size;
  443. __u32 input_info_offset;
  444. __u64 data;
  445. };
  446. /**
  447. * struct cam_isp_tfe_wm_bw_limiter_config - ISP TFE write master
  448. * BW limter config
  449. *
  450. *
  451. * @res_type : output resource type defined in file cam_isp_tfe.h
  452. * @enable_limiter : 0 for disable else enabled
  453. * @counter_limit : Max counter value
  454. */
  455. struct cam_isp_tfe_wm_bw_limiter_config {
  456. __u32 res_type;
  457. __u32 enable_limiter;
  458. __u32 counter_limit[CAM_PACKET_MAX_PLANES];
  459. };
  460. /**
  461. * struct cam_isp_tfe_out_rsrc_bw_limiter_config - ISP TFE out rsrc BW limiter config
  462. *
  463. * Configure BW limiter for ISP TFE WMs
  464. *
  465. * @version : Version field
  466. * @num_ports : Number of ports
  467. * @bw_limit_config : WM BW limiter config
  468. */
  469. struct cam_isp_tfe_out_rsrc_bw_limiter_config {
  470. __u32 version;
  471. __u32 num_ports;
  472. struct cam_isp_tfe_wm_bw_limiter_config bw_limiter_config[1];
  473. };
  474. #define CAM_TFE_ACQUIRE_COMMON_VER0 0x1000
  475. #define CAM_TFE_ACQUIRE_COMMON_SIZE_VER0 0x0
  476. #define CAM_TFE_ACQUIRE_INPUT_VER0 0x2000
  477. #define CAM_TFE_ACQUIRE_INPUT_SIZE_VER0 sizeof(struct cam_isp_tfe_in_port_info)
  478. #define CAM_TFE_ACQUIRE_OUT_VER0 0x3000
  479. #define CAM_TFE_ACQUIRE_OUT_SIZE_VER0 sizeof(struct cam_isp_tfe_out_port_info)
  480. #endif /* __UAPI_CAM_TFE_H__ */