1 /*
2  * Copyright (c) 2019-2021 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef _FSL_DC_FB_LCDIFV2_H_
9 #define _FSL_DC_FB_LCDIFV2_H_
10 
11 #include "fsl_dc_fb.h"
12 #include "fsl_lcdifv2.h"
13 
14 /*
15  * Change log:
16  *
17  *   1.0.2
18  *     - Add more pixel format support.
19  *
20  *   1.0.1
21  *     - Fix MISRA-C 2012 issues.
22  *
23  *   1.0.0
24  *     - Initial version
25  */
26 
27 /*!
28  * @addtogroup dc_fb_lcdifv2
29  * @{
30  */
31 
32 /*******************************************************************************
33  * Definitions
34  ******************************************************************************/
35 
36 #define DC_FB_LCDIFV2_MAX_LAYER                    ((uint32_t)LCDIFV2_LAYER_COUNT)
37 #define DC_FB_LCDIFV2_DEFAULT_BUF_PER_LAYER        3U
38 #define DC_FB_LCDIFV2_DEFAULT_PIXEL_FORMAT         kVIDEO_PixelFormatRGB565
39 #define DC_FB_LCDIFV2_DEFAULT_PIXEL_FORMAT_LCDIFV2 kLCDIFV2_PixelFormatRGB565
40 #define DC_FB_LCDIFV2_DEFAULT_BYTE_PER_PIXEL       2U
41 
42 /*! @brief Data for LCDIFV2 display controller layer. */
43 typedef struct _dc_fb_lcdifv2_layer
44 {
45     bool enabled;                    /*!< The layer is enabled. */
46     volatile bool framePending;      /*!< New frame pending. */
47     volatile bool shadowLoadPending; /*!< Shadow load pending. */
48     void *activeBuffer;              /*!< The frame buffer which is shown. */
49     void *inactiveBuffer;            /*!< The frame buffer which will be shown. */
50     dc_fb_callback_t callback;       /*!< Callback for buffer switch off. */
51     void *cbParam;                   /*!< Callback parameter. */
52 } dc_fb_lcdifv2_layer_t;
53 
54 /*! @brief Data for LCDIFV2 display controller driver handle. */
55 typedef struct _dc_fb_lcdifv2_handle
56 {
57     LCDIFV2_Type *lcdifv2;                                 /*!< LCDIFV2 peripheral. */
58     uint8_t initTimes;                                     /*!< How many times the DC is initialized. */
59     uint16_t height;                                       /*!< Panel height. */
60     uint16_t width;                                        /*!< Panel width. */
61     uint8_t domain;                                        /*!< Domain used for interrupt. */
62     dc_fb_lcdifv2_layer_t layers[DC_FB_LCDIFV2_MAX_LAYER]; /*!< Information of the layer. */
63 } dc_fb_lcdifv2_handle_t;
64 
65 /*! @brief Configuration for LCDIFV2 display controller driver handle. */
66 typedef struct _dc_fb_lcdifv2_config
67 {
68     LCDIFV2_Type *lcdifv2;          /*!< LCDIFV2 peripheral. */
69     uint16_t width;                 /*!< Width of the panel. */
70     uint16_t height;                /*!< Height of the panel. */
71     uint16_t hsw;                   /*!< HSYNC pulse width. */
72     uint16_t hfp;                   /*!< Horizontal front porch. */
73     uint16_t hbp;                   /*!< Horizontal back porch. */
74     uint16_t vsw;                   /*!< VSYNC pulse width. */
75     uint16_t vfp;                   /*!< Vertical front porch. */
76     uint16_t vbp;                   /*!< Vertical back porch. */
77     uint32_t polarityFlags;         /*!< Control flags, OR'ed value of @ref _lcdifv2_polarity_flags. */
78     lcdifv2_line_order_t lineOrder; /*!< Line order. */
79     uint8_t domain;                 /*!< Domain used to for interrupt. */
80 } dc_fb_lcdifv2_config_t;
81 
82 extern const dc_fb_ops_t g_dcFbOpsLcdifv2;
83 
84 /*******************************************************************************
85  * API
86  ******************************************************************************/
87 
88 #if defined(__cplusplus)
89 extern "C" {
90 #endif
91 
92 status_t DC_FB_LCDIFV2_Init(const dc_fb_t *dc);
93 status_t DC_FB_LCDIFV2_Deinit(const dc_fb_t *dc);
94 status_t DC_FB_LCDIFV2_EnableLayer(const dc_fb_t *dc, uint8_t layer);
95 status_t DC_FB_LCDIFV2_DisableLayer(const dc_fb_t *dc, uint8_t layer);
96 status_t DC_FB_LCDIFV2_SetLayerConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo);
97 status_t DC_FB_LCDIFV2_GetLayerDefaultConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo);
98 status_t DC_FB_LCDIFV2_SetFrameBuffer(const dc_fb_t *dc, uint8_t layer, void *frameBuffer);
99 uint32_t DC_FB_LCDIFV2_GetProperty(const dc_fb_t *dc);
100 void DC_FB_LCDIFV2_SetCallback(const dc_fb_t *dc, uint8_t layer, dc_fb_callback_t callback, void *param);
101 void DC_FB_LCDIFV2_IRQHandler(const dc_fb_t *dc);
102 
103 #if defined(__cplusplus)
104 }
105 #endif
106 
107 /*! @} */
108 
109 #endif /* _FSL_DC_FB_LCDIFV2_H_ */
110