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