1 /*
2  * Copyright 2019-2020 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef _FSL_DC_FB_ELCDIF_H_
9 #define _FSL_DC_FB_ELCDIF_H_
10 
11 #include "fsl_dc_fb.h"
12 #include "fsl_elcdif.h"
13 
14 /*
15  * Change log:
16  *
17  *   1.0.1
18  *     - Fixed MISRA-C 2012 issues.
19  *
20  *   1.0.0
21  *     - Initial version
22  */
23 
24 /*!
25  * @addtogroup dc_fb_elcdif
26  * @{
27  */
28 
29 /*******************************************************************************
30  * Definitions
31  ******************************************************************************/
32 
33 #define DC_FB_ELCDIF_MAX_LAYER                   1U /* Only support one layer currently. */
34 #define DC_FB_ELCDIF_DEFAULT_PIXEL_FORMAT        kVIDEO_PixelFormatRGB565
35 #define DC_FB_ELCDIF_DEFAULT_PIXEL_FORMAT_ELCDIF kELCDIF_PixelFormatRGB565
36 
37 /*! @brief Data for ELCDIF display controller layer. */
38 typedef struct _dc_fb_elcdif_layer
39 {
40     bool enabled;               /*!< The layer is enabled. */
41     volatile bool framePending; /*!< New frame pending. */
42     void *activeBuffer;         /*!< The frame buffer which is shown. */
43     void *inactiveBuffer;       /*!< The frame buffer which will be shown. */
44     dc_fb_callback_t callback;  /*!< Callback for buffer switch off. */
45     void *cbParam;              /*!< Callback parameter. */
46 } dc_fb_elcdif_layer_t;
47 
48 /*! @brief Data for ELCDIF display controller driver handle. */
49 typedef struct _dc_fb_elcdif_handle
50 {
51     LCDIF_Type *elcdif;                                  /*!< eLCDIF peripheral. */
52     uint8_t initTimes;                                   /*!< How many times the DC is initialized. */
53     uint16_t height;                                     /*!< Panel height. */
54     uint16_t width;                                      /*!< Panel width. */
55     dc_fb_elcdif_layer_t layers[DC_FB_ELCDIF_MAX_LAYER]; /*!< Information of the layer. */
56 } dc_fb_elcdif_handle_t;
57 
58 /*! @brief Configuration for ELCDIF display controller driver handle. */
59 typedef struct _dc_fb_elcdif_config
60 {
61     LCDIF_Type *elcdif;            /*!< ELCDIF peripheral. */
62     uint16_t width;                /*!< Width of the panel. */
63     uint16_t height;               /*!< Height of the panel. */
64     uint16_t hsw;                  /*!< HSYNC pulse width. */
65     uint16_t hfp;                  /*!< Horizontal front porch. */
66     uint16_t hbp;                  /*!< Horizontal back porch. */
67     uint16_t vsw;                  /*!< VSYNC pulse width. */
68     uint16_t vfp;                  /*!< Vertical front porch. */
69     uint16_t vbp;                  /*!< Vertical back porch. */
70     uint32_t polarityFlags;        /*!< Control flags, OR'ed value of @ref _elcdif_polarity_flags. */
71     elcdif_lcd_data_bus_t dataBus; /*!< LCD data bus. */
72 } dc_fb_elcdif_config_t;
73 
74 extern const dc_fb_ops_t g_dcFbOpsElcdif;
75 
76 /*******************************************************************************
77  * API
78  ******************************************************************************/
79 
80 #if defined(__cplusplus)
81 extern "C" {
82 #endif
83 
84 status_t DC_FB_ELCDIF_Init(const dc_fb_t *dc);
85 status_t DC_FB_ELCDIF_Deinit(const dc_fb_t *dc);
86 status_t DC_FB_ELCDIF_EnableLayer(const dc_fb_t *dc, uint8_t layer);
87 status_t DC_FB_ELCDIF_DisableLayer(const dc_fb_t *dc, uint8_t layer);
88 status_t DC_FB_ELCDIF_SetLayerConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo);
89 status_t DC_FB_ELCDIF_GetLayerDefaultConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo);
90 status_t DC_FB_ELCDIF_SetFrameBuffer(const dc_fb_t *dc, uint8_t layer, void *frameBuffer);
91 uint32_t DC_FB_ELCDIF_GetProperty(const dc_fb_t *dc);
92 void DC_FB_ELCDIF_SetCallback(const dc_fb_t *dc, uint8_t layer, dc_fb_callback_t callback, void *param);
93 void DC_FB_ELCDIF_IRQHandler(const dc_fb_t *dc);
94 
95 #if defined(__cplusplus)
96 }
97 #endif
98 
99 /*! @} */
100 
101 #endif /* _FSL_DC_FB_ELCDIF_H_ */
102