1 /*
2  * Copyright 2019-2020 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef _FSL_LDB_H_
9 #define _FSL_LDB_H_
10 
11 #include "fsl_common.h"
12 
13 /*!
14  * @addtogroup ldb
15  * @{
16  */
17 
18 /*! @file */
19 
20 /******************************************************************************
21  * Definitions
22  *****************************************************************************/
23 
24 /*! @name Driver version */
25 /*@{*/
26 /*! @brief LDB driver version. */
27 #define FSL_LDB_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
28 /*@}*/
29 
30 typedef MIPI_DSI_LVDS_COMBO_CSR_Type LDB_Type;
31 
32 /*! @brief LDB output bus format. */
33 typedef enum _ldb_output_bus
34 {
35     kLDB_OutputRGB666_7Bit_SPWG = 0U,
36     kLDB_OutputRGB888_7Bit_SPWG = MIPI_DSI_LVDS_COMBO_CSR_PM_CTRL_CH0_DATA_WIDTH_MASK,
37     kLDB_OutputRGB888_7Bit_JEIDA =
38         MIPI_DSI_LVDS_COMBO_CSR_PM_CTRL_CH0_DATA_WIDTH_MASK | MIPI_DSI_LVDS_COMBO_CSR_PM_CTRL_CH0_BIT_MAPPING_MASK,
39 } ldb_output_bus_t;
40 
41 /*! @brief LDB input signal priority. */
42 enum _ldb_input_flag
43 {
44     kLDB_InputVsyncActiveLow         = 0U,       /*!< VSYNC active low. */
45     kLDB_InputVsyncActiveHigh        = 1U << 0U, /*!< VSYNC active high. */
46     kLDB_InputHsyncActiveLow         = 0U,       /*!< HSYNC active low. */
47     kLDB_InputHsyncActiveHigh        = 1U << 1U, /*!< HSYNC active high. */
48     kLDB_InputDataLatchOnFallingEdge = 0U,       /*!< Latch data on falling clock edge. */
49     kLDB_InputDataLatchOnRisingEdge  = 1U << 2U, /*!< Latch data on rising clock edge. */
50 };
51 
52 /*! @brief LDB channel configuration. */
53 typedef struct _ldb_channel_config
54 {
55     ldb_output_bus_t outputBus; /*!< Output bus format.   */
56     uint32_t inputFlag;         /*!< Input flag, OR'ed value of _ldb_input_flag. */
57     uint32_t pixelClock_Hz;     /*!< Pixel clock in HZ.   */
58 } ldb_channel_config_t;
59 
60 /*******************************************************************************
61  * API
62  ******************************************************************************/
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
68 /*!
69  * @brief Initializes the LDB module.
70  *
71  * @param base LDB peripheral base address.
72  */
73 void LDB_Init(LDB_Type *base);
74 
75 /*!
76  * @brief De-initializes the LDB module.
77  *
78  * @param base LDB peripheral base address.
79  */
80 void LDB_Deinit(LDB_Type *base);
81 
82 /*!
83  * @brief Initializes the LDB channel.
84  *
85  * @param base LDB peripheral base address.
86  * @param channel Channel index.
87  * @param config Pointer to the configuration.
88  * @return Return kStatus_Success if success.
89  */
90 status_t LDB_InitChannel(LDB_Type *base, uint8_t channel, const ldb_channel_config_t *config);
91 
92 /*!
93  * @brief De-initializes the LDB channel.
94  *
95  * @param base LDB peripheral base address.
96  * @param channel Channel index.
97  */
98 void LDB_DeinitChannel(LDB_Type *base, uint8_t channel);
99 
100 #if defined(__cplusplus)
101 }
102 #endif /*_cplusplus*/
103 /*@}*/
104 
105 #endif /* _FSL_LDB_H_ */
106