cam_tfe.h 19 KB

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