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