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_SSD1963_H_
9 #define _FSL_DC_FB_SSD1963_H_
10 
11 #include "fsl_dc_fb.h"
12 #include "fsl_ssd1963.h"
13 
14 /*
15  * Change log:
16  *
17  *   1.0.2
18  *     - Set default backlight level to 255.
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_ssd1963
29  * @{
30  */
31 
32 /*******************************************************************************
33  * Definitions
34  ******************************************************************************/
35 
36 /* Only support one layer. To support multiple layers, the DBI transfer should
37  * be protected. If writing to a layer is in progress, the writing to another layer
38  * should be blocked until previous layer operation finished.
39  */
40 #define DC_FB_SSD1963_MAX_LAYER 1U
41 
42 /* If the data bus is 16bit, only support RGB565/BGR565,
43    if the data bus is 8bit, only support RGB888/BGR888.
44  */
45 #if (16 == SSD1963_DATA_WITDH)
46 #define DC_FB_SSD1963_DEFAULT_PIXEL_FORMAT         kVIDEO_PixelFormatRGB565
47 #define DC_FB_SSD1963_DEFAULT_PIXEL_FORMAT_SSD1963 kSSD1963_RGB565
48 #define DC_FB_SSD1963_DEFAULT_PIXEL_BYTES          2U
49 #else
50 #define DC_FB_SSD1963_DEFAULT_PIXEL_FORMAT         kVIDEO_PixelFormatRGB888
51 #define DC_FB_SSD1963_DEFAULT_PIXEL_FORMAT_SSD1963 kSSD1963_RGB888
52 #define DC_FB_SSD1963_DEFAULT_PIXEL_BYTES          3U
53 #endif
54 
55 /*! @brief Data for SSD1963 display controller layer. */
56 typedef struct _dc_fb_ssd1963_layer
57 {
58     bool enabled;              /*!< The layer is enabled. */
59     dc_fb_info_t fbInfo;       /*!< Frame buffer info. */
60     void *frameBuffer;         /*!< Frame buffer sent currently. */
61     dc_fb_callback_t callback; /*!< Callback for buffer switch off. */
62     void *cbParam;             /*!< Callback parameter. */
63 } dc_fb_ssd1963_layer_t;
64 
65 /*! @brief Data for SSD1963 display controller driver handle. */
66 typedef struct _dc_fb_ssd1963_handle
67 {
68     ssd1963_handle_t ssd1963;                              /*!< The SSD1963 handle. */
69     uint8_t initTimes;                                     /*!< How many times the DC is initialized. */
70     uint8_t enabledLayerCount;                             /*!< How many times layers are enabled. */
71     dc_fb_ssd1963_layer_t layers[DC_FB_SSD1963_MAX_LAYER]; /*!< Information of the layer. */
72 } dc_fb_ssd1963_handle_t;
73 
74 /*! @brief Configuration for SSD1963 display controller driver handle. */
75 typedef struct _dc_fb_ssd1963_config
76 {
77     const ssd1963_config_t ssd1963Config; /*!< SSD1963 configuration. */
78     const dbi_xfer_ops_t *xferOps;        /*!< DBI bus operations used for SSD1963. */
79     void *xferOpsData;                    /*!< Data used by @ref xferOps */
80     uint32_t srcClock_Hz;                 /*!< The external reference clock frequency. */
81 } dc_fb_ssd1963_config_t;
82 
83 extern const dc_fb_ops_t g_dcFbOpsSSD1963;
84 
85 /*******************************************************************************
86  * API
87  ******************************************************************************/
88 
89 #if defined(__cplusplus)
90 extern "C" {
91 #endif
92 
93 status_t DC_FB_SSD1963_Init(const dc_fb_t *dc);
94 status_t DC_FB_SSD1963_Deinit(const dc_fb_t *dc);
95 status_t DC_FB_SSD1963_EnableLayer(const dc_fb_t *dc, uint8_t layer);
96 status_t DC_FB_SSD1963_DisableLayer(const dc_fb_t *dc, uint8_t layer);
97 status_t DC_FB_SSD1963_SetLayerConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo);
98 status_t DC_FB_SSD1963_GetLayerDefaultConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo);
99 status_t DC_FB_SSD1963_SetFrameBuffer(const dc_fb_t *dc, uint8_t layer, void *frameBuffer);
100 uint32_t DC_FB_SSD1963_GetProperty(const dc_fb_t *dc);
101 void DC_FB_SSD1963_SetCallback(const dc_fb_t *dc, uint8_t layer, dc_fb_callback_t callback, void *param);
102 
103 #if defined(__cplusplus)
104 }
105 #endif
106 
107 /*! @} */
108 
109 #endif /* _FSL_DC_FB_SSD1963_H_ */
110