1 /*
2  * Copyright (c) 2019-2020,2023 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef _FSL_DC_FB_LCDIF_H_
8 #define _FSL_DC_FB_LCDIF_H_
9 
10 #include "fsl_dc_fb.h"
11 #include "fsl_lcdif.h"
12 
13 /*
14  * Change log:
15  *
16  *   1.0.1
17  *     - Fix MISRA-C 2012 issues.
18  *
19  *   1.0.0
20  *     - Initial version
21  */
22 
23 /*!
24  * @addtogroup dc_fb_lcdif
25  * @{
26  */
27 
28 /*******************************************************************************
29  * Definitions
30  ******************************************************************************/
31 #if defined(FSL_FEATURE_LCDIF_VERSION_DC8000) && FSL_FEATURE_LCDIF_VERSION_DC8000
32 #define DC_FB_LCDIF_MAX_LAYER 3U
33 #else
34 #define DC_FB_LCDIF_MAX_LAYER 1U /* Only support one layer currently. */
35 #endif
36 #define DC_FB_LCDIF_DEFAULT_PIXEL_FORMAT       kVIDEO_PixelFormatRGB565
37 #define DC_FB_LCDIF_DEFAULT_PIXEL_FORMAT_LCDIF kLCDIF_PixelFormatRGB565
38 #define DC_FB_LCDIF_DEFAULT_BYTE_PER_PIXEL     2U
39 
40 /*! @brief Data for LCDIF display controller layer. */
41 typedef struct _dc_fb_lcdif_layer
42 {
43     bool enabled;               /*!< The layer is enabled. */
44     volatile bool framePending; /*!< New frame pending. */
45     void *activeBuffer;         /*!< The frame buffer which is shown. */
46     void *inactiveBuffer;       /*!< The frame buffer which will be shown. */
47     lcdif_fb_config_t fbConfig; /*!< Frame buffer configuration. */
48     dc_fb_callback_t callback;  /*!< Callback for buffer switch off. */
49     void *cbParam;              /*!< Callback parameter. */
50 } dc_fb_lcdif_layer_t;
51 
52 /*! @brief Data for LCDIF display controller driver handle. */
53 typedef struct _dc_fb_lcdif_handle
54 {
55     LCDIF_Type *lcdif;                                 /*!< eLCDIF peripheral. */
56     uint8_t initTimes;                                 /*!< How many times the DC is initialized. */
57     uint16_t height;                                   /*!< Panel height. */
58     uint16_t width;                                    /*!< Panel width. */
59     dc_fb_lcdif_layer_t layers[DC_FB_LCDIF_MAX_LAYER]; /*!< Information of the layer. */
60 } dc_fb_lcdif_handle_t;
61 
62 /*! @brief Configuration for LCDIF display controller driver handle. */
63 typedef struct _dc_fb_lcdif_config
64 {
65     LCDIF_Type *lcdif;                  /*!< LCDIF peripheral. */
66     uint16_t width;                     /*!< Width of the panel. */
67     uint16_t height;                    /*!< Height of the panel. */
68     uint16_t hsw;                       /*!< HSYNC pulse width. */
69     uint16_t hfp;                       /*!< Horizontal front porch. */
70     uint16_t hbp;                       /*!< Horizontal back porch. */
71     uint16_t vsw;                       /*!< VSYNC pulse width. */
72     uint16_t vfp;                       /*!< Vertical front porch. */
73     uint16_t vbp;                       /*!< Vertical back porch. */
74     uint32_t polarityFlags;             /*!< Control flags, OR'ed value of @ref _lcdif_polarity_flags. */
75     lcdif_output_format_t outputFormat; /*!< DPI output format. */
76 } dc_fb_lcdif_config_t;
77 
78 extern const dc_fb_ops_t g_dcFbOpsLcdif;
79 
80 /*******************************************************************************
81  * API
82  ******************************************************************************/
83 
84 #if defined(__cplusplus)
85 extern "C" {
86 #endif
87 
88 status_t DC_FB_LCDIF_Init(const dc_fb_t *dc);
89 status_t DC_FB_LCDIF_Deinit(const dc_fb_t *dc);
90 status_t DC_FB_LCDIF_EnableLayer(const dc_fb_t *dc, uint8_t layer);
91 status_t DC_FB_LCDIF_DisableLayer(const dc_fb_t *dc, uint8_t layer);
92 status_t DC_FB_LCDIF_SetLayerConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo);
93 status_t DC_FB_LCDIF_GetLayerDefaultConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo);
94 status_t DC_FB_LCDIF_SetFrameBuffer(const dc_fb_t *dc, uint8_t layer, void *frameBuffer);
95 uint32_t DC_FB_LCDIF_GetProperty(const dc_fb_t *dc);
96 void DC_FB_LCDIF_SetCallback(const dc_fb_t *dc, uint8_t layer, dc_fb_callback_t callback, void *param);
97 void DC_FB_LCDIF_IRQHandler(const dc_fb_t *dc);
98 
99 #if defined(__cplusplus)
100 }
101 #endif
102 
103 /*! @} */
104 
105 #endif /* _FSL_DC_FB_LCDIF_H_ */
106