no-OS
Loading...
Searching...
No Matches
gmsl_common.h
Go to the documentation of this file.
1/*******************************************************************************
2 * @file gmsl_common.h
3 * @brief Header file of gmsl common interface
4 * @author Automotive Software and Systems team, Bangalore, India
5********************************************************************************
6 * Copyright 2025(c) Analog Devices, Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 *
18 * 3. Neither the name of Analog Devices, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. "AS IS" AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
25 * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32******************************************************************************/
33
34#ifndef GMSL_COMMON_H
35#define GMSL_COMMON_H
36
37#include <stdint.h>
38#include <stdbool.h>
39#include "gmsl_reg_access.h"
40
41#define FLAG_DIAG_ERR(err_cond, current_diag_err, diag_err) {\
42 if(err_cond) {\
43 diag_err = true;\
44 current_diag_err = true;\
45 }\
46 else {\
47 current_diag_err = false;\
48 }\
49}
50
51#define VALBITFIELD(reg_val, bitfield) \
52 ((reg_val) & bitfield##_MASK) >> bitfield##_POS
53
54#ifndef BIT
55#define BIT(x) (1U << (x))
56#endif
57
58#ifndef ARRAY_SIZE
59#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
60#endif
61
62#ifndef BITS_PER_LONG
63#define BITS_PER_LONG (64U)
64#endif
65
66#ifndef UL
67#define UL(v) v##UL
68#endif
69
70#ifndef GENMASK
71#define GENMASK(high, low) (((1 << ((high) - (low) + 1)) - 1) << (low))
72#endif
73
74#define MASK_0xFF 0xFFU
75
86
97
102
109
120
131
143
153
159struct gmsl_dev {
160 uint8_t index;
161 uint16_t part_id;
162 uint8_t rev_id;
163 char dev_name[50];
164 struct no_os_i2c_desc
166 struct gmsl_dev
168 void *dev_cap;
170 void *dev_state;
171 void *dev_diag;
172};
173
182
193
202
212
221
230
239
248
259 int32_t (*diag_check_device_id)(struct gmsl_dev *dev, void *dev_id,
260 bool *diag_err); /* GMSL_DIAG_PART_DEV_ID */
261 int32_t (*diag_check_device_rev)(struct gmsl_dev *dev, void *dev_rev,
262 bool *diag_err); /* GMSL_DIAG_PART_DEV_REV */
263 int32_t (*diag_check_part_config)(struct gmsl_dev *dev, void *part_cfg_sts,
264 bool *diag_err); /* GMSL_DIAG_PART_CFG */
265 int32_t (*diag_check_link_lock_status)(struct gmsl_dev *dev,
266 void *link_lock_status, bool
267 *diag_err); /* GMSL_DIAG_LINK_LOCK */
269 void *decode_err_status,
270 bool *diag_err); /* GMSL_DIAG_LINK_DECODE */
271 int32_t (*diag_check_idle_err_status)(struct gmsl_dev *dev, void *idle_err_sts,
272 bool *diag_err); /* GMSL_DIAG_LINK_IDLE */
274 void *max_retrans_sts, bool
275 *diag_err); /* GMSL_DIAG_LINK_MAX_RETRANS */
277 void *line_fault_status,
278 bool *diag_err); /* GMSL_DIAG_LINK_LINE_FAULT */
279 int32_t (*diag_check_fec_status)(struct gmsl_dev *dev, void *fec_status,
280 bool *diag_err); /* GMSL_DIAG_LINK_FEC */
281 int32_t (*diag_check_eom_status)(struct gmsl_dev *dev, void *eom_status,
282 bool *diag_err); /* GMSL_DIAG_LINK_EOM */
283 int32_t (*diag_check_overflow_status)(struct gmsl_dev *dev,
284 void *vid_tx_overflow_sts,
285 bool *diag_err); /* GMSL_DIAG_VIDEO_OVERFLOW */
286 int32_t (*diag_check_pclk_lost_status)(struct gmsl_dev *dev, void *pclk_det_sts,
287 bool *diag_err); /* GMSL_DIAG_VIDEO_PCLK_LOST */
288 int32_t (*diag_check_drift_status)(struct gmsl_dev *dev,
289 void *vid_tx_pclk_drift_err_sts,
290 bool *diag_err); /* GMSL_DIAG_VIDEO_DRIFT */
292 void *vid_line_crc_enabled_sts, bool *diag_err); /* GMSL_DIAG_VIDEO_CRC */
293 int32_t (*diag_check_stream_id_status)(struct gmsl_dev *dev,
294 void *stream_id_sts, bool
295 *diag_err); /* GMSL_DIAG_VIDEO_STREAM_ID */
296 int32_t (*diag_check_parameter_status)(struct gmsl_dev *dev,
297 void *vid_param_sts, bool
298 *diag_err); /* GMSL_DIAG_VIDEO_PARAMETER */
299 int32_t (*diag_check_pps_status)(struct gmsl_dev *dev, void *pps_value_sts,
300 bool *diag_err); /* GMSL_DIAG_VIDEO_PPS */
302 void *vid_stream_dsc_comp_sts,
303 bool *diag_err); /* GMSL_DIAG_VIDEO_STREAM_DSC_COMPRESSION */
304 int32_t (*diag_check_dp_fec_support)(struct gmsl_dev *dev,
305 void *pb_is_fec_running,
306 bool *diag_err); /* GMSL_DIAG_DP_FEC_SUPPORT */
307 int32_t (*diag_check_hdcp_status)(struct gmsl_dev *dev, void *hdcp_status,
308 bool *diag_err); /* GMSL_DIAG_HDCP_STATUS */
310 void *link_training_sts,
311 bool *diag_err); /* GMSL_DIAG_LINK_TRAINING */
313 void *mipi_rx_err_status,
314 bool *diag_err); /* GMSL_DIAG_MIPI_RX */
316 void *mem_ecc_2b_err_status,
317 bool *diag_err); /* GMSL_DIAG_MEM_ECC_2BIT_ERROR */
319 void* vid_line_crc_error_sts,
320 bool* diag_err); /* GMSL_DIAG_VIDEO_CRC_ERROR_STATUS */
322 void* vid_error_sts, bool*
323 diag_err); /* GMSL_VIDEO_ERROR STATUS*/
325 struct gmsl_dev* dev, void* psm_error_sts,
326 bool* diag_err); /* GMSL_PSM_ERROR STATUS*/
328 void *video_lock_sts, bool
329 *diag_err); /* GMSL_DIAG_VIDEO_LOCK */
330 int32_t (*diag_check_mipi_status)(struct gmsl_dev* dev, void* mipi_sts,
331 bool* diag_err); /* GMSL_DIAG_MIPI_STATUS */
333 void* lp_err_status, bool*
334 diag_err); /* GMSL_DIAG_PHY_LOW_POWER_ERR */
335 int32_t (*diag_check_lmo_status)(struct gmsl_dev* dev, void* lmo_sts,
336 bool* diag_err); /* GMSL_DIAG_LMO_STATUS */
338 void* vid_timing_sts, bool*
339 diag_err); /* GMSL_DIAG_VIDEO_TIMING */
340 int32_t(*diag_check_get_dp_link_rate)(struct gmsl_dev* dev, void* dp_link_rate,
341 bool* diag_err); /* GMSL_DIAG_DP_LINK_RATE */
343 void* dp_lane_count, bool*
344 diag_err); /* GMSL_DIAG_DP_LANE_COUNT */
345 int32_t(*diag_check_remote_err)(struct gmsl_dev* dev, void* rom_err_flg,
346 bool* diag_err); /* GMSL_DIAG_REMOTE_ERROR_FLAG */
348 void* video_block_length_err,
349 bool* diag_err); /* GMSL_DIAG_VID_BLK_LENGTH_ERROR */
350 int32_t(*diag_check_infofr_cc_status)(struct gmsl_dev* dev, void* infofr_cc_sts,
351 bool* diag_err); /* GMSL_DIAG_INFOFR_CC */
352};
353
354#endif /* GMSL_COMMON_H */
dev_id
Definition ad9361.h:3322
gmsl_link_mode
Enumerates GMSL link mode.
Definition gmsl_common.h:198
@ GMSL_LINK_MODE_GMSL3_PAM4
Definition gmsl_common.h:200
@ GMSL_LINK_MODE_GMSL2_NRZ
Definition gmsl_common.h:199
gmsl_pipe
Enumerates the video pipes for the GMSL device.
Definition gmsl_common.h:103
@ GMSL_PIPE_X
Definition gmsl_common.h:104
@ GMSL_PIPE_U
Definition gmsl_common.h:107
@ GMSL_PIPE_Y
Definition gmsl_common.h:105
@ GMSL_PIPE_Z
Definition gmsl_common.h:106
gmsl_link_mipi_csi_controller
Enumerates the CSI controllers for the GMSL device.
Definition gmsl_common.h:114
@ GMSL_LINK_MIPI_CSI_CTRLR_1
Definition gmsl_common.h:116
@ GMSL_LINK_MIPI_CSI_CTRLR_3
Definition gmsl_common.h:118
@ GMSL_LINK_MIPI_CSI_CTRLR_2
Definition gmsl_common.h:117
@ GMSL_LINK_MIPI_CSI_CTRLR_0
Definition gmsl_common.h:115
gmsl_link
Enumerates GMSL Camera Deserializer Phy/Link.
Definition gmsl_common.h:80
@ GMSL_LINK_C
Definition gmsl_common.h:83
@ GMSL_LINK_D
Definition gmsl_common.h:84
@ GMSL_LINK_B
Definition gmsl_common.h:82
@ GMSL_LINK_A
Definition gmsl_common.h:81
gmsl_link_phy_rate
Enumerates PHY rate of SerDes.
Definition gmsl_common.h:187
@ GMSL_LINK_PHY_RATE_6G
Definition gmsl_common.h:190
@ GMSL_LINK_PHY_RATE_12G
Definition gmsl_common.h:191
@ GMSL_LINK_PHY_RATE_3G
Definition gmsl_common.h:189
@ GMSL_LINK_PHY_RATE_187M5
Definition gmsl_common.h:188
gmsl_link_cable_type
Definition gmsl_common.h:178
@ GMSL_LINK_CABLE_TYPE_STP
Definition gmsl_common.h:179
@ GMSL_LINK_CABLE_TYPE_COAX
Definition gmsl_common.h:180
gmsl_link_cfg
Enumerates the link configuration options for the GMSL device.
Definition gmsl_common.h:148
@ GMSL_LINK_B_LINK_CFG
Definition gmsl_common.h:150
@ GMSL_BOTH_LINKS_CFG
Definition gmsl_common.h:151
@ GMSL_LINK_A_LINK_CFG
Definition gmsl_common.h:149
gmsl_part_num
Enumerates the part numbers for the GMSL device.
Definition gmsl_common.h:136
@ GMSL_PART_NUM_MAX96714
Definition gmsl_common.h:138
@ GMSL_PART_NUM_MAX96724
Definition gmsl_common.h:137
@ GMSL_PART_NUM_MAX96793
Definition gmsl_common.h:140
@ GMSL_PART_NUM_MAX96762
Definition gmsl_common.h:141
@ GMSL_PART_NUM_MAX96981
Definition gmsl_common.h:139
gmsl_link_mipi_phy
Enumerates the MIPI PHYs for the GMSL device.
Definition gmsl_common.h:125
@ GMSL_LINK_MIPI_CSI_PHY_3
Definition gmsl_common.h:129
@ GMSL_LINK_MIPI_CSI_PHY_2
Definition gmsl_common.h:128
@ GMSL_LINK_MIPI_CSI_PHY_0
Definition gmsl_common.h:126
@ GMSL_LINK_MIPI_CSI_PHY_1
Definition gmsl_common.h:127
gmsl_lf_enable
Enumerates the line fault monitor enable options for the GMSL device.
Definition gmsl_common.h:90
@ GMSL_LF0_ENABLE
Definition gmsl_common.h:91
@ GMSL_LF3_ENABLE
Definition gmsl_common.h:94
@ GMSL_LF1_ENABLE
Definition gmsl_common.h:92
@ GMSL_LF_ALL_ENABLE
Definition gmsl_common.h:95
@ GMSL_LF2_ENABLE
Definition gmsl_common.h:93
A structure that contains diagnostic operation function pointers for a GMSL device.
Definition gmsl_common.h:258
int32_t(* diag_check_drift_status)(struct gmsl_dev *dev, void *vid_tx_pclk_drift_err_sts, bool *diag_err)
Definition gmsl_common.h:288
int32_t(* diag_check_infofr_cc_status)(struct gmsl_dev *dev, void *infofr_cc_sts, bool *diag_err)
Definition gmsl_common.h:350
int32_t(* diag_check_remote_err)(struct gmsl_dev *dev, void *rom_err_flg, bool *diag_err)
Definition gmsl_common.h:345
int32_t(* diag_check_video_stream_dsc_compression)(struct gmsl_dev *dev, void *vid_stream_dsc_comp_sts, bool *diag_err)
Definition gmsl_common.h:301
int32_t(* diag_check_link_training_status)(struct gmsl_dev *dev, void *link_training_sts, bool *diag_err)
Definition gmsl_common.h:309
int32_t(* diag_check_get_dp_link_rate)(struct gmsl_dev *dev, void *dp_link_rate, bool *diag_err)
Definition gmsl_common.h:340
int32_t(* diag_check_video_block_length_err)(struct gmsl_dev *dev, void *video_block_length_err, bool *diag_err)
Definition gmsl_common.h:347
int32_t(* diag_check_eom_status)(struct gmsl_dev *dev, void *eom_status, bool *diag_err)
Definition gmsl_common.h:281
int32_t(* diag_check_video_error_status)(struct gmsl_dev *dev, void *vid_error_sts, bool *diag_err)
Definition gmsl_common.h:321
int32_t(* diag_check_decode_error_status)(struct gmsl_dev *dev, void *decode_err_status, bool *diag_err)
Definition gmsl_common.h:268
int32_t(* diag_check_lmo_status)(struct gmsl_dev *dev, void *lmo_sts, bool *diag_err)
Definition gmsl_common.h:335
int32_t(* diag_check_overflow_status)(struct gmsl_dev *dev, void *vid_tx_overflow_sts, bool *diag_err)
Definition gmsl_common.h:283
int32_t(* diag_check_video_timing_detect_status)(struct gmsl_dev *dev, void *vid_timing_sts, bool *diag_err)
Definition gmsl_common.h:337
int32_t(* diag_check_programmable_state_machine_error_status)(struct gmsl_dev *dev, void *psm_error_sts, bool *diag_err)
Definition gmsl_common.h:324
int32_t(* diag_check_idle_err_status)(struct gmsl_dev *dev, void *idle_err_sts, bool *diag_err)
Definition gmsl_common.h:271
int32_t(* diag_check_stream_id_status)(struct gmsl_dev *dev, void *stream_id_sts, bool *diag_err)
Definition gmsl_common.h:293
int32_t(* diag_check_phy_low_power_err_status)(struct gmsl_dev *dev, void *lp_err_status, bool *diag_err)
Definition gmsl_common.h:332
int32_t(* diag_check_device_rev)(struct gmsl_dev *dev, void *dev_rev, bool *diag_err)
Definition gmsl_common.h:261
int32_t(* diag_check_get_is_video_line_crc_enabled)(struct gmsl_dev *dev, void *vid_line_crc_enabled_sts, bool *diag_err)
Definition gmsl_common.h:291
int32_t(* diag_check_dp_fec_support)(struct gmsl_dev *dev, void *pb_is_fec_running, bool *diag_err)
Definition gmsl_common.h:304
int32_t(* diag_check_fec_status)(struct gmsl_dev *dev, void *fec_status, bool *diag_err)
Definition gmsl_common.h:279
int32_t(* diag_check_hdcp_status)(struct gmsl_dev *dev, void *hdcp_status, bool *diag_err)
Definition gmsl_common.h:307
int32_t(* diag_check_get_is_video_line_crc_error_status)(struct gmsl_dev *dev, void *vid_line_crc_error_sts, bool *diag_err)
Definition gmsl_common.h:318
int32_t(* diag_check_pclk_lost_status)(struct gmsl_dev *dev, void *pclk_det_sts, bool *diag_err)
Definition gmsl_common.h:286
int32_t(* diag_check_link_lock_status)(struct gmsl_dev *dev, void *link_lock_status, bool *diag_err)
Definition gmsl_common.h:265
int32_t(* diag_check_line_fault_status)(struct gmsl_dev *dev, void *line_fault_status, bool *diag_err)
Definition gmsl_common.h:276
int32_t(* diag_check_mipi_rx_err_status)(struct gmsl_dev *dev, void *mipi_rx_err_status, bool *diag_err)
Definition gmsl_common.h:312
int32_t(* diag_check_pps_status)(struct gmsl_dev *dev, void *pps_value_sts, bool *diag_err)
Definition gmsl_common.h:299
int32_t(* diag_check_get_dp_lane_count)(struct gmsl_dev *dev, void *dp_lane_count, bool *diag_err)
Definition gmsl_common.h:342
int32_t(* diag_check_mem_ecc_2b_err_status)(struct gmsl_dev *dev, void *mem_ecc_2b_err_status, bool *diag_err)
Definition gmsl_common.h:315
int32_t(* diag_check_mipi_status)(struct gmsl_dev *dev, void *mipi_sts, bool *diag_err)
Definition gmsl_common.h:330
int32_t(* diag_check_video_lock_status)(struct gmsl_dev *dev, void *video_lock_sts, bool *diag_err)
Definition gmsl_common.h:327
int32_t(* diag_check_device_id)(struct gmsl_dev *dev, void *dev_id, bool *diag_err)
Definition gmsl_common.h:259
int32_t(* diag_check_parameter_status)(struct gmsl_dev *dev, void *vid_param_sts, bool *diag_err)
Definition gmsl_common.h:296
int32_t(* diag_check_max_retrans_status)(struct gmsl_dev *dev, void *max_retrans_sts, bool *diag_err)
Definition gmsl_common.h:273
int32_t(* diag_check_part_config)(struct gmsl_dev *dev, void *part_cfg_sts, bool *diag_err)
Definition gmsl_common.h:263
Structure representing a GMSL device handle, containing configuration parameters and diagnostic opera...
Definition gmsl_common.h:159
struct no_os_i2c_desc * i2c_desc
Definition gmsl_common.h:164
uint8_t index
Definition gmsl_common.h:160
void * dev_diag
Definition gmsl_common.h:171
char dev_name[50]
Definition gmsl_common.h:163
void * dev_config
Definition gmsl_common.h:169
void * dev_cap
Definition gmsl_common.h:168
struct gmsl_dev * linked_devs[4]
Definition gmsl_common.h:166
uint16_t part_id
Definition gmsl_common.h:161
void * dev_state
Definition gmsl_common.h:170
uint8_t rev_id
Definition gmsl_common.h:162
Structure holding I2C address descriptor.
Definition no_os_i2c.h:89