1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (C) 2013--2024 Intel Corporation */
4 #ifndef IPU6_ISYS_CSI2_H
5 #define IPU6_ISYS_CSI2_H
7 #include <linux/container_of.h>
9 #include "ipu6-isys-subdev.h"
10 #include "ipu6-isys-video.h"
13 struct v4l2_mbus_frame_desc_entry
;
15 struct ipu6_isys_video
;
17 struct ipu6_isys_csi2_pdata
;
18 struct ipu6_isys_stream
;
20 #define NR_OF_CSI2_VC 16
21 #define INVALID_VC_ID -1
22 #define NR_OF_CSI2_SINK_PADS 1
23 #define CSI2_PAD_SINK 0
24 #define NR_OF_CSI2_SRC_PADS 8
25 #define CSI2_PAD_SRC 1
26 #define NR_OF_CSI2_PADS (NR_OF_CSI2_SINK_PADS + NR_OF_CSI2_SRC_PADS)
28 #define CSI2_CSI_RX_DLY_CNT_TERMEN_CLANE_A 0
29 #define CSI2_CSI_RX_DLY_CNT_TERMEN_CLANE_B 0
30 #define CSI2_CSI_RX_DLY_CNT_SETTLE_CLANE_A 95
31 #define CSI2_CSI_RX_DLY_CNT_SETTLE_CLANE_B -8
33 #define CSI2_CSI_RX_DLY_CNT_TERMEN_DLANE_A 0
34 #define CSI2_CSI_RX_DLY_CNT_TERMEN_DLANE_B 0
35 #define CSI2_CSI_RX_DLY_CNT_SETTLE_DLANE_A 85
36 #define CSI2_CSI_RX_DLY_CNT_SETTLE_DLANE_B -2
38 struct ipu6_isys_csi2
{
39 struct ipu6_isys_subdev asd
;
40 struct ipu6_isys_csi2_pdata
*pdata
;
41 struct ipu6_isys
*isys
;
42 struct ipu6_isys_video av
[NR_OF_CSI2_SRC_PADS
];
50 struct ipu6_isys_csi2_timing
{
57 struct ipu6_csi2_error
{
58 const char *error_string
;
62 #define ipu6_isys_subdev_to_csi2(__sd) \
63 container_of(__sd, struct ipu6_isys_csi2, asd)
65 #define to_ipu6_isys_csi2(__asd) container_of(__asd, struct ipu6_isys_csi2, asd)
67 s64
ipu6_isys_csi2_get_link_freq(struct ipu6_isys_csi2
*csi2
);
68 int ipu6_isys_csi2_init(struct ipu6_isys_csi2
*csi2
, struct ipu6_isys
*isys
,
69 void __iomem
*base
, unsigned int index
);
70 void ipu6_isys_csi2_cleanup(struct ipu6_isys_csi2
*csi2
);
71 void ipu6_isys_csi2_sof_event_by_stream(struct ipu6_isys_stream
*stream
);
72 void ipu6_isys_csi2_eof_event_by_stream(struct ipu6_isys_stream
*stream
);
73 void ipu6_isys_register_errors(struct ipu6_isys_csi2
*csi2
);
74 void ipu6_isys_csi2_error(struct ipu6_isys_csi2
*csi2
);
75 int ipu6_isys_csi2_get_remote_desc(u32 source_stream
,
76 struct ipu6_isys_csi2
*csi2
,
77 struct media_entity
*source_entity
,
78 struct v4l2_mbus_frame_desc_entry
*entry
);
80 #endif /* IPU6_ISYS_CSI2_H */