• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __UAPI_CAM_ISP_H__
2 #define __UAPI_CAM_ISP_H__
3 
4 #include "cam_defs.h"
5 #include "cam_isp_vfe.h"
6 #include "cam_isp_ife.h"
7 
8 
9 /* ISP driver name */
10 #define CAM_ISP_DEV_NAME                        "cam-isp"
11 
12 /* HW type */
13 #define CAM_ISP_HW_BASE                         0
14 #define CAM_ISP_HW_CSID                         1
15 #define CAM_ISP_HW_VFE                          2
16 #define CAM_ISP_HW_IFE                          3
17 #define CAM_ISP_HW_ISPIF                        4
18 #define CAM_ISP_HW_MAX                          5
19 
20 /* Color Pattern */
21 #define CAM_ISP_PATTERN_BAYER_RGRGRG            0
22 #define CAM_ISP_PATTERN_BAYER_GRGRGR            1
23 #define CAM_ISP_PATTERN_BAYER_BGBGBG            2
24 #define CAM_ISP_PATTERN_BAYER_GBGBGB            3
25 #define CAM_ISP_PATTERN_YUV_YCBYCR              4
26 #define CAM_ISP_PATTERN_YUV_YCRYCB              5
27 #define CAM_ISP_PATTERN_YUV_CBYCRY              6
28 #define CAM_ISP_PATTERN_YUV_CRYCBY              7
29 #define CAM_ISP_PATTERN_MAX                     8
30 
31 /* Usage Type */
32 #define CAM_ISP_RES_USAGE_SINGLE                0
33 #define CAM_ISP_RES_USAGE_DUAL                  1
34 #define CAM_ISP_RES_USAGE_MAX                   2
35 
36 /* Resource ID */
37 #define CAM_ISP_RES_ID_PORT                     0
38 #define CAM_ISP_RES_ID_CLK                      1
39 #define CAM_ISP_RES_ID_MAX                      2
40 
41 /* Resource Type - Type of resource for the resource id
42  * defined in cam_isp_vfe.h, cam_isp_ife.h
43  */
44 
45 /* Lane Type in input resource for Port */
46 #define CAM_ISP_LANE_TYPE_DPHY                  0
47 #define CAM_ISP_LANE_TYPE_CPHY                  1
48 #define CAM_ISP_LANE_TYPE_MAX                   2
49 
50 /* ISP Resurce Composite Group ID */
51 #define CAM_ISP_RES_COMP_GROUP_NONE             0
52 #define CAM_ISP_RES_COMP_GROUP_ID_0             1
53 #define CAM_ISP_RES_COMP_GROUP_ID_1             2
54 #define CAM_ISP_RES_COMP_GROUP_ID_2             3
55 #define CAM_ISP_RES_COMP_GROUP_ID_3             4
56 #define CAM_ISP_RES_COMP_GROUP_ID_4             5
57 #define CAM_ISP_RES_COMP_GROUP_ID_5             6
58 #define CAM_ISP_RES_COMP_GROUP_ID_MAX           6
59 
60 /* ISP packet opcode for ISP */
61 #define CAM_ISP_PACKET_OP_BASE                  0
62 #define CAM_ISP_PACKET_INIT_DEV                 1
63 #define CAM_ISP_PACKET_UPDATE_DEV               2
64 #define CAM_ISP_PACKET_OP_MAX                   3
65 
66 /* ISP packet meta_data type for command buffer */
67 #define CAM_ISP_PACKET_META_BASE                0
68 #define CAM_ISP_PACKET_META_LEFT                1
69 #define CAM_ISP_PACKET_META_RIGHT               2
70 #define CAM_ISP_PACKET_META_COMMON              3
71 #define CAM_ISP_PACKET_META_DMI_LEFT            4
72 #define CAM_ISP_PACKET_META_DMI_RIGHT           5
73 #define CAM_ISP_PACKET_META_DMI_COMMON          6
74 #define CAM_ISP_PACKET_META_CLOCK               7
75 #define CAM_ISP_PACKET_META_CSID                8
76 #define CAM_ISP_PACKET_META_DUAL_CONFIG         9
77 #define CAM_ISP_PACKET_META_GENERIC_BLOB_LEFT   10
78 #define CAM_ISP_PACKET_META_GENERIC_BLOB_RIGHT  11
79 #define CAM_ISP_PACKET_META_GENERIC_BLOB_COMMON 12
80 
81 /* DSP mode */
82 #define CAM_ISP_DSP_MODE_NONE                   0
83 #define CAM_ISP_DSP_MODE_ONE_WAY                1
84 #define CAM_ISP_DSP_MODE_ROUND                  2
85 
86 /* ISP Generic Cmd Buffer Blob types */
87 #define CAM_ISP_GENERIC_BLOB_TYPE_HFR_CONFIG          0
88 #define CAM_ISP_GENERIC_BLOB_TYPE_CLOCK_CONFIG        1
89 #define CAM_ISP_GENERIC_BLOB_TYPE_BW_CONFIG           2
90 #define CAM_ISP_GENERIC_BLOB_TYPE_UBWC_CONFIG         3
91 #define CAM_ISP_GENERIC_BLOB_TYPE_CSID_CLOCK_CONFIG   4
92 #define CAM_ISP_GENERIC_BLOB_TYPE_FE_CONFIG           5
93 #define CAM_ISP_GENERIC_BLOB_TYPE_BW_CONFIG_V2        6
94 
95 /* Query devices */
96 /**
97  * struct cam_isp_dev_cap_info - A cap info for particular hw type
98  *
99  * @hw_type:            Hardware type for the cap info
100  * @reserved:           reserved field for alignment
101  * @hw_version:         Hardware version
102  *
103  */
104 struct cam_isp_dev_cap_info {
105 	uint32_t              hw_type;
106 	uint32_t              reserved;
107 	struct cam_hw_version hw_version;
108 };
109 
110 /**
111  * struct cam_isp_query_cap_cmd - ISP query device capability payload
112  *
113  * @device_iommu:               returned iommu handles for device
114  * @cdm_iommu:                  returned iommu handles for cdm
115  * @num_dev:                    returned number of device capabilities
116  * @reserved:                   reserved field for alignment
117  * @dev_caps:                   returned device capability array
118  *
119  */
120 struct cam_isp_query_cap_cmd {
121 	struct cam_iommu_handle       device_iommu;
122 	struct cam_iommu_handle       cdm_iommu;
123 	int32_t                       num_dev;
124 	uint32_t                      reserved;
125 	struct cam_isp_dev_cap_info   dev_caps[CAM_ISP_HW_MAX];
126 };
127 
128 /* Acquire Device */
129 /**
130  * struct cam_isp_out_port_info - An output port resource info
131  *
132  * @res_type:                   output resource type defined in file
133  *                              cam_isp_vfe.h or cam_isp_ife.h
134  * @format:                     output format of the resource
135  * @wdith:                      output width in pixels
136  * @height:                     output height in lines
137  * @comp_grp_id:                composite group id for the resource.
138  * @split_point:                split point in pixels for the dual VFE.
139  * @secure_mode:                flag to tell if output should be run in secure
140  *                              mode or not. See cam_defs.h for definition
141  * @reserved:                   reserved field for alignment
142  *
143  */
144 struct cam_isp_out_port_info {
145 	uint32_t                res_type;
146 	uint32_t                format;
147 	uint32_t                width;
148 	uint32_t                height;
149 	uint32_t                comp_grp_id;
150 	uint32_t                split_point;
151 	uint32_t                secure_mode;
152 	uint32_t                reserved;
153 };
154 
155 /**
156  * struct cam_isp_in_port_info - An input port resource info
157  *
158  * @res_type:                   input resource type define in file
159  *                              cam_isp_vfe.h or cam_isp_ife.h
160  * @lane_type:                  lane type: c-phy or d-phy.
161  * @lane_num:                   active lane number
162  * @lane_cfg:                   lane configurations: 4 bits per lane
163  * @vc:                         input virtual channel number
164  * @dt:                         input data type number
165  * @format:                     input format
166  * @test_pattern:               test pattern for the testgen
167  * @usage_type:                 whether dual vfe is required
168  * @left_start:                 left input start offset in pixels
169  * @left_stop:                  left input stop offset in pixels
170  * @left_width:                 left input width in pixels
171  * @right_start:                right input start offset in pixels.
172  *                              Only for Dual VFE
173  * @right_stop:                 right input stop offset in pixels.
174  *                              Only for Dual VFE
175  * @right_width:                right input width in pixels.
176  *                              Only for dual VFE
177  * @line_start:                 top of the line number
178  * @line_stop:                  bottome of the line number
179  * @height:                     input height in lines
180  * @pixel_clk;                  sensor output clock
181  * @batch_size:                 batch size for HFR mode
182  * @dsp_mode:                   DSP stream mode (Defines as CAM_ISP_DSP_MODE_*)
183  * @hbi_cnt:                    HBI count for the camif input
184  * @reserved:                   Reserved field for alignment
185  * @num_out_res:                number of the output resource associated
186  * @data:                       payload that contains the output resources
187  *
188  */
189 struct cam_isp_in_port_info {
190 	uint32_t                        res_type;
191 	uint32_t                        lane_type;
192 	uint32_t                        lane_num;
193 	uint32_t                        lane_cfg;
194 	uint32_t                        vc;
195 	uint32_t                        dt;
196 	uint32_t                        format;
197 	uint32_t                        test_pattern;
198 	uint32_t                        usage_type;
199 	uint32_t                        left_start;
200 	uint32_t                        left_stop;
201 	uint32_t                        left_width;
202 	uint32_t                        right_start;
203 	uint32_t                        right_stop;
204 	uint32_t                        right_width;
205 	uint32_t                        line_start;
206 	uint32_t                        line_stop;
207 	uint32_t                        height;
208 	uint32_t                        pixel_clk;
209 	uint32_t                        batch_size;
210 	uint32_t                        dsp_mode;
211 	uint32_t                        hbi_cnt;
212 	uint32_t                        reserved;
213 	uint32_t                        num_out_res;
214 	struct cam_isp_out_port_info    data[1];
215 };
216 
217 /**
218  * struct cam_isp_resource - A resource bundle
219  *
220  * @resoruce_id:                resource id for the resource bundle
221  * @length:                     length of the while resource blob
222  * @handle_type:                type of the resource handle
223  * @reserved:                   reserved field for alignment
224  * @res_hdl:                    resource handle that points to the
225  *                                     resource array;
226  *
227  */
228 struct cam_isp_resource {
229 	uint32_t                       resource_id;
230 	uint32_t                       length;
231 	uint32_t                       handle_type;
232 	uint32_t                       reserved;
233 	uint64_t                       res_hdl;
234 };
235 
236 /**
237  * struct cam_isp_port_hfr_config - HFR configuration for this port
238  *
239  * @resource_type:              Resource type
240  * @subsample_pattern:          Subsample pattern. Used in HFR mode. It
241  *                              should be consistent with batchSize and
242  *                              CAMIF programming.
243  * @subsample_period:           Subsample period. Used in HFR mode. It
244  *                              should be consistent with batchSize and
245  *                              CAMIF programming.
246  * @framedrop_pattern:          Framedrop pattern
247  * @framedrop_period:           Framedrop period
248  * @reserved:                   Reserved for alignment
249  */
250 struct cam_isp_port_hfr_config {
251 	uint32_t                       resource_type;
252 	uint32_t                       subsample_pattern;
253 	uint32_t                       subsample_period;
254 	uint32_t                       framedrop_pattern;
255 	uint32_t                       framedrop_period;
256 	uint32_t                       reserved;
257 } __attribute__((packed));
258 
259 /**
260  * struct cam_isp_resource_hfr_config - Resource HFR configuration
261  *
262  * @num_ports:                  Number of ports
263  * @reserved:                   Reserved for alignment
264  * @port_hfr_config:            HFR configuration for each IO port
265  */
266 struct cam_isp_resource_hfr_config {
267 	uint32_t                       num_ports;
268 	uint32_t                       reserved;
269 	struct cam_isp_port_hfr_config port_hfr_config[1];
270 } __attribute__((packed));
271 
272 /**
273  * struct cam_isp_dual_split_params - dual isp spilt parameters
274  *
275  * @split_point:                Split point information x, where (0 < x < width)
276  *                              left ISP's input ends at x + righ padding and
277  *                              Right ISP's input starts at x - left padding
278  * @right_padding:              Padding added past the split point for left
279  *                              ISP's input
280  * @left_padding:               Padding added before split point for right
281  *                              ISP's input
282  * @reserved:                   Reserved filed for alignment
283  *
284  */
285 struct cam_isp_dual_split_params {
286 	uint32_t                       split_point;
287 	uint32_t                       right_padding;
288 	uint32_t                       left_padding;
289 	uint32_t                       reserved;
290 };
291 
292 /**
293  * struct cam_isp_dual_stripe_config - stripe config per bus client
294  *
295  * @offset:                     Start horizontal offset relative to
296  *                              output buffer
297  *                              In UBWC mode, this value indicates the H_INIT
298  *                              value in pixel
299  * @width:                      Width of the stripe in bytes
300  * @tileconfig                  Ubwc meta tile config. Contain the partial
301  *                              tile info
302  * @port_id:                    port id of ISP output
303  *
304  */
305 struct cam_isp_dual_stripe_config {
306 	uint32_t                       offset;
307 	uint32_t                       width;
308 	uint32_t                       tileconfig;
309 	uint32_t                       port_id;
310 };
311 
312 /**
313  * struct cam_isp_dual_config - dual isp configuration
314  *
315  * @num_ports                   Number of isp output ports
316  * @reserved                    Reserved field for alignment
317  * @split_params:               Inpput split parameters
318  * @stripes:                    Stripe information
319  *
320  */
321 struct cam_isp_dual_config {
322 	uint32_t                           num_ports;
323 	uint32_t                           reserved;
324 	struct cam_isp_dual_split_params   split_params;
325 	struct cam_isp_dual_stripe_config  stripes[1];
326 } __attribute__((packed));
327 
328 /**
329  * struct cam_isp_clock_config - Clock configuration
330  *
331  * @usage_type:                 Usage type (Single/Dual)
332  * @num_rdi:                    Number of RDI votes
333  * @left_pix_hz:                Pixel Clock for Left ISP
334  * @right_pix_hz:               Pixel Clock for Right ISP, valid only if Dual
335  * @rdi_hz:                     RDI Clock. ISP clock will be max of RDI and
336  *                              PIX clocks. For a particular context which ISP
337  *                              HW the RDI is allocated to is not known to UMD.
338  *                              Hence pass the clock and let KMD decide.
339  */
340 struct cam_isp_clock_config {
341 	uint32_t                       usage_type;
342 	uint32_t                       num_rdi;
343 	uint64_t                       left_pix_hz;
344 	uint64_t                       right_pix_hz;
345 	uint64_t                       rdi_hz[1];
346 } __attribute__((packed));
347 
348 /**
349  * struct cam_isp_csid_clock_config - CSID clock configuration
350  *
351  * @csid_clock                  CSID clock
352  */
353 struct cam_isp_csid_clock_config {
354 	uint64_t                       csid_clock;
355 } __attribute__((packed));
356 
357 /**
358  * struct cam_isp_bw_vote - Bandwidth vote information
359  *
360  * @resource_id:                Resource ID
361  * @reserved:                   Reserved field for alignment
362  * @cam_bw_bps:                 Bandwidth vote for CAMNOC
363  * @ext_bw_bps:                 Bandwidth vote for path-to-DDR after CAMNOC
364  */
365 
366 struct cam_isp_bw_vote {
367 	uint32_t                       resource_id;
368 	uint32_t                       reserved;
369 	uint64_t                       cam_bw_bps;
370 	uint64_t                       ext_bw_bps;
371 } __attribute__((packed));
372 
373 /**
374  * struct cam_isp_bw_config - Bandwidth configuration
375  *
376  * @usage_type:                 Usage type (Single/Dual)
377  * @num_rdi:                    Number of RDI votes
378  * @left_pix_vote:              Bandwidth vote for left ISP
379  * @right_pix_vote:             Bandwidth vote for right ISP
380  * @rdi_vote:                   RDI bandwidth requirements
381  */
382 
383 struct cam_isp_bw_config {
384 	uint32_t                       usage_type;
385 	uint32_t                       num_rdi;
386 	struct cam_isp_bw_vote         left_pix_vote;
387 	struct cam_isp_bw_vote         right_pix_vote;
388 	struct cam_isp_bw_vote         rdi_vote[1];
389 } __attribute__((packed));
390 
391 
392 /**
393  * struct cam_isp_bw_config_ab - Bandwidth configuration
394  *
395  * @usage_type:                    Usage type (Single/Dual)
396  * @num_rdi:                       Number of RDI votes
397  * @left_pix_vote_ab:              AB Bandwidth vote for left ISP
398  * @right_pix_vote_ab:             AB Bandwidth vote for right ISP
399  * @rdi_vote_ab:                   AB RDI bandwidth requirements
400  */
401 
402 struct cam_isp_bw_config_ab {
403 	uint32_t    usage_type;
404 	uint32_t    num_rdi;
405 	uint64_t    left_pix_vote_ab;
406 	uint64_t    right_pix_vote_ab;
407 	uint64_t    rdi_vote_ab[1];
408 } __attribute__((packed));
409 
410 /**
411  * struct cam_fe_config - Fetch Engine configuration
412  *
413  * @version:                    fetch engine veriosn
414  * @min_vbi:                    require min vbi
415  * @fs_mode:                    indicates if fs mode enabled
416  * @fs_line_sync_en:            frame level sync or line level
417  *                              sync for fetch engine
418  * @hbi_count:                  hbi count
419  * @fs_sync_enable:             indicates if fetch engine working
420  *                              wokring in sync with write engine
421  * @go_cmd_sel:                 softwrae go_cmd or hw go_cmd
422  * @client_enable:              enable read engine
423  * @source_addr:                adrress of buffer to read from
424  * @width:                      buffer width
425  * @height:                     buffer height
426  * @stride:                     buffer stride (here equal to width)
427  * @format:                     format of image in buffer
428  * @unpacker_cfg:               unpacker config type
429  * @latency_buf_size:           latency buffer for read engine
430  */
431 struct cam_fe_config {
432 	uint64_t    version;
433 	uint32_t    min_vbi;
434 	uint32_t    fs_mode;
435 	uint32_t    fs_line_sync_en;
436 	uint32_t    hbi_count;
437 	uint32_t    fs_sync_enable;
438 	uint32_t    go_cmd_sel;
439 	uint32_t    client_enable;
440 	uint32_t    source_addr;
441 	uint32_t    width;
442 	uint32_t    height;
443 	uint32_t    stride;
444 	uint32_t    format;
445 	uint32_t    unpacker_cfg;
446 	uint32_t    latency_buf_size;
447 } __attribute__((packed));
448 
449 /* Acquire Device/HW v2 */
450 
451 /**
452  * struct cam_isp_acquire_hw_info - ISP acquire HW params
453  *
454  * @common_info_version  : Version of common info struct used
455  * @common_info_size     : Size of common info struct used
456  * @common_info_offset   : Offset of common info from start of data
457  * @num_inputs           : Number of inputs
458  * @input_info_version   : Version of input info struct used
459  * @input_info_size      : Size of input info struct used
460  * @input_info_offset    : Offset of input info from start of data
461  * @data                 : Start of data region
462  */
463 struct cam_isp_acquire_hw_info {
464 	uint16_t                common_info_version;
465 	uint16_t                common_info_size;
466 	uint32_t                common_info_offset;
467 	uint32_t                num_inputs;
468 	uint32_t                input_info_version;
469 	uint32_t                input_info_size;
470 	uint32_t                input_info_offset;
471 	uint64_t                data;
472 };
473 
474 #define CAM_ISP_ACQUIRE_COMMON_VER0         0x1000
475 
476 #define CAM_ISP_ACQUIRE_COMMON_SIZE_VER0    0x0
477 
478 #define CAM_ISP_ACQUIRE_INPUT_VER0          0x2000
479 
480 #define CAM_ISP_ACQUIRE_INPUT_SIZE_VER0     sizeof(struct cam_isp_in_port_info)
481 
482 #define CAM_ISP_ACQUIRE_OUT_VER0            0x3000
483 
484 #define CAM_ISP_ACQUIRE_OUT_SIZE_VER0       sizeof(struct cam_isp_out_port_info)
485 
486 #endif /* __UAPI_CAM_ISP_H__ */
487