cam_tfe.h 21 KB

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