1 #ifndef __UAPI_CAM_ICP_H__
2 #define __UAPI_CAM_ICP_H__
3 
4 #include "cam_defs.h"
5 
6 /* icp, ipe, bps, cdm(ipe/bps) are used in querycap */
7 #define CAM_ICP_DEV_TYPE_A5      1
8 #define CAM_ICP_DEV_TYPE_IPE     2
9 #define CAM_ICP_DEV_TYPE_BPS     3
10 #define CAM_ICP_DEV_TYPE_IPE_CDM 4
11 #define CAM_ICP_DEV_TYPE_BPS_CDM 5
12 #define CAM_ICP_DEV_TYPE_MAX     5
13 
14 /* definitions needed for icp aquire device */
15 #define CAM_ICP_RES_TYPE_BPS        1
16 #define CAM_ICP_RES_TYPE_IPE_RT     2
17 #define CAM_ICP_RES_TYPE_IPE        3
18 #define CAM_ICP_RES_TYPE_MAX        4
19 
20 /* packet opcode types */
21 #define CAM_ICP_OPCODE_IPE_UPDATE   0
22 #define CAM_ICP_OPCODE_BPS_UPDATE   1
23 #define CAM_ICP_OPCODE_IPE_SETTINGS 2
24 #define CAM_ICP_OPCODE_BPS_SETTINGS 3
25 
26 
27 /* IPE input port resource type */
28 #define CAM_ICP_IPE_INPUT_IMAGE_FULL            0x0
29 #define CAM_ICP_IPE_INPUT_IMAGE_DS4             0x1
30 #define CAM_ICP_IPE_INPUT_IMAGE_DS16            0x2
31 #define CAM_ICP_IPE_INPUT_IMAGE_DS64            0x3
32 #define CAM_ICP_IPE_INPUT_IMAGE_FULL_REF        0x4
33 #define CAM_ICP_IPE_INPUT_IMAGE_DS4_REF         0x5
34 #define CAM_ICP_IPE_INPUT_IMAGE_DS16_REF        0x6
35 #define CAM_ICP_IPE_INPUT_IMAGE_DS64_REF        0x7
36 
37 /* IPE output port resource type */
38 #define CAM_ICP_IPE_OUTPUT_IMAGE_DISPLAY        0x8
39 #define CAM_ICP_IPE_OUTPUT_IMAGE_VIDEO          0x9
40 #define CAM_ICP_IPE_OUTPUT_IMAGE_FULL_REF       0xA
41 #define CAM_ICP_IPE_OUTPUT_IMAGE_DS4_REF        0xB
42 #define CAM_ICP_IPE_OUTPUT_IMAGE_DS16_REF       0xC
43 #define CAM_ICP_IPE_OUTPUT_IMAGE_DS64_REF       0xD
44 
45 #define CAM_ICP_IPE_IMAGE_MAX                   0xE
46 
47 /* BPS input port resource type */
48 #define CAM_ICP_BPS_INPUT_IMAGE                 0x0
49 
50 /* BPS output port resource type */
51 #define CAM_ICP_BPS_OUTPUT_IMAGE_FULL           0x1
52 #define CAM_ICP_BPS_OUTPUT_IMAGE_DS4            0x2
53 #define CAM_ICP_BPS_OUTPUT_IMAGE_DS16           0x3
54 #define CAM_ICP_BPS_OUTPUT_IMAGE_DS64           0x4
55 #define CAM_ICP_BPS_OUTPUT_IMAGE_STATS_BG       0x5
56 #define CAM_ICP_BPS_OUTPUT_IMAGE_STATS_BHIST    0x6
57 #define CAM_ICP_BPS_OUTPUT_IMAGE_REG1           0x7
58 #define CAM_ICP_BPS_OUTPUT_IMAGE_REG2           0x8
59 
60 #define CAM_ICP_BPS_IO_IMAGES_MAX               0x9
61 
62 /* Command meta types */
63 #define CAM_ICP_CMD_META_GENERIC_BLOB           0x1
64 
65 /* Generic blob types */
66 #define CAM_ICP_CMD_GENERIC_BLOB_CLK            0x1
67 #define CAM_ICP_CMD_GENERIC_BLOB_CFG_IO         0x2
68 #define CAM_ICP_CMD_GENERIC_BLOB_FW_MEM_MAP     0x3
69 #define CAM_ICP_CMD_GENERIC_BLOB_FW_MEM_UNMAP   0x4
70 
71 /**
72  * struct cam_icp_clk_bw_request
73  *
74  * @budget_ns: Time required to process frame
75  * @frame_cycles: Frame cycles needed to process the frame
76  * @rt_flag: Flag to indicate real time stream
77  * @uncompressed_bw: Bandwidth required to process frame
78  * @compressed_bw: Compressed bandwidth to process frame
79  */
80 struct cam_icp_clk_bw_request {
81 	uint64_t budget_ns;
82 	uint32_t frame_cycles;
83 	uint32_t rt_flag;
84 	uint64_t uncompressed_bw;
85 	uint64_t compressed_bw;
86 };
87 
88 /**
89  * struct cam_icp_dev_ver - Device information for particular hw type
90  *
91  * This is used to get device version info of
92  * ICP, IPE, BPS and CDM related IPE and BPS from firmware
93  * and use this info in CAM_QUERY_CAP IOCTL
94  *
95  * @dev_type: hardware type for the cap info(icp, ipe, bps, cdm(ipe/bps))
96  * @reserved: reserved field
97  * @hw_ver: major, minor and incr values of a device version
98  */
99 struct cam_icp_dev_ver {
100 	uint32_t dev_type;
101 	uint32_t reserved;
102 	struct cam_hw_version hw_ver;
103 };
104 
105 /**
106  * struct cam_icp_ver - ICP version info
107  *
108  * This strcuture is used for fw and api version
109  * this is used to get firmware version and api version from firmware
110  * and use this info in CAM_QUERY_CAP IOCTL
111  *
112  * @major: FW version major
113  * @minor: FW version minor
114  * @revision: FW version increment
115  */
116 struct cam_icp_ver {
117 	uint32_t major;
118 	uint32_t minor;
119 	uint32_t revision;
120 	uint32_t reserved;
121 };
122 
123 /**
124  * struct cam_icp_query_cap_cmd - ICP query device capability payload
125  *
126  * @dev_iommu_handle: icp iommu handles for secure/non secure modes
127  * @cdm_iommu_handle: iommu handles for secure/non secure modes
128  * @fw_version: firmware version info
129  * @api_version: api version info
130  * @num_ipe: number of ipes
131  * @num_bps: number of bps
132  * @dev_ver: returned device capability array
133  */
134 struct cam_icp_query_cap_cmd {
135 	struct cam_iommu_handle dev_iommu_handle;
136 	struct cam_iommu_handle cdm_iommu_handle;
137 	struct cam_icp_ver fw_version;
138 	struct cam_icp_ver api_version;
139 	uint32_t num_ipe;
140 	uint32_t num_bps;
141 	struct cam_icp_dev_ver dev_ver[CAM_ICP_DEV_TYPE_MAX];
142 };
143 
144 /**
145  * struct cam_icp_res_info - ICP output resource info
146  *
147  * @format: format of the resource
148  * @width:  width in pixels
149  * @height: height in lines
150  * @fps:  fps
151  */
152 struct cam_icp_res_info {
153 	uint32_t format;
154 	uint32_t width;
155 	uint32_t height;
156 	uint32_t fps;
157 };
158 
159 /**
160  * struct cam_icp_acquire_dev_info - An ICP device info
161  *
162  * @scratch_mem_size: Output param - size of scratch memory
163  * @dev_type: device type (IPE_RT/IPE_NON_RT/BPS)
164  * @io_config_cmd_size: size of IO config command
165  * @io_config_cmd_handle: IO config command for each acquire
166  * @secure_mode: camera mode (secure/non secure)
167  * @chain_info: chaining info of FW device handles
168  * @in_res: resource info used for clock and bandwidth calculation
169  * @num_out_res: number of output resources
170  * @out_res: output resource
171  */
172 struct cam_icp_acquire_dev_info {
173 	uint32_t scratch_mem_size;
174 	uint32_t dev_type;
175 	uint32_t io_config_cmd_size;
176 	int32_t  io_config_cmd_handle;
177 	uint32_t secure_mode;
178 	int32_t chain_info;
179 	struct cam_icp_res_info in_res;
180 	uint32_t num_out_res;
181 	struct cam_icp_res_info out_res[1];
182 } __attribute__((__packed__));
183 
184 #endif /* __UAPI_CAM_ICP_H__ */
185