cam_tfe.h 20 KB

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