aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/components/video/display
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/components/video/display')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/adv7535/driver_display-adv7535.cmake23
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/adv7535/fsl_adv7535.c274
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/adv7535/fsl_adv7535.h63
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/driver_dbi.cmake15
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/flexio/driver_dbi_flexio_edma.cmake18
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/flexio/fsl_dbi_flexio_edma.c175
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/flexio/fsl_dbi_flexio_edma.h131
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/fsl_dbi.h70
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/driver_dc-fb-common.cmake24
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/elcdif/driver_dc-fb-elcdif.cmake17
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/elcdif/fsl_dc_fb_elcdif.c263
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/elcdif/fsl_dc_fb_elcdif.h101
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/fsl_dc_fb.h80
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/driver_display-common.cmake21
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/fsl_display.h126
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/it6263/driver_display-it6263.cmake18
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/it6263/fsl_it6263.c371
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/it6263/fsl_it6263.h63
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/mipi_dsi_cmd/driver_display-mipi-dsi-cmd.cmake23
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/mipi_dsi_cmd/fsl_mipi_dsi_cmd.c273
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/mipi_dsi_cmd/fsl_mipi_dsi_cmd.h278
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/rm67191/driver_display-rm67191.cmake17
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/rm67191/fsl_rm67191.c167
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/display/rm67191/fsl_rm67191.h120
24 files changed, 2731 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/adv7535/driver_display-adv7535.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/adv7535/driver_display-adv7535.cmake
new file mode 100644
index 000000000..6c9425aba
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/adv7535/driver_display-adv7535.cmake
@@ -0,0 +1,23 @@
1if(NOT DRIVER_DISPLAY-ADV7535_INCLUDED)
2
3 set(DRIVER_DISPLAY-ADV7535_INCLUDED true CACHE BOOL "driver_display-adv7535 component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 ${CMAKE_CURRENT_LIST_DIR}/fsl_adv7535.c
7 )
8
9 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
10 ${CMAKE_CURRENT_LIST_DIR}/.
11 )
12
13 #OR Logic component
14 if(${MCUX_DEVICE} STREQUAL "MIMX8QM6_cm4_core1")
15 include(driver_video-i2c)
16 endif()
17 if(${MCUX_DEVICE} STREQUAL "MIMX8QX6")
18 include(driver_video-i2c)
19 endif()
20
21 include(driver_common)
22
23endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/adv7535/fsl_adv7535.c b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/adv7535/fsl_adv7535.c
new file mode 100644
index 000000000..40b81c25d
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/adv7535/fsl_adv7535.c
@@ -0,0 +1,274 @@
1/*
2 * Copyright 2017-2018, 2020 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#include "fsl_video_common.h"
10#include "fsl_display.h"
11#include "fsl_adv7535.h"
12
13/*******************************************************************************
14 * Definitions
15 ******************************************************************************/
16#define ADV7535_CHIP_REVISION 0x14U
17
18#define ADV7535_DSI_CEC_ADDR (0x78U >> 1)
19
20#define ADV7535_I2C_WriteReg(handle, addr, reg, value) \
21 VIDEO_I2C_WriteReg(addr, kVIDEO_RegAddr8Bit, (reg), kVIDEO_RegWidth8Bit, (value), \
22 ((const adv7535_resource_t *)((handle)->resource))->i2cSendFunc)
23
24#define ADV7535_I2C_ReadReg(handle, addr, reg, value) \
25 VIDEO_I2C_ReadReg(addr, kVIDEO_RegAddr8Bit, (reg), kVIDEO_RegWidth8Bit, (value), \
26 ((const adv7535_resource_t *)((handle)->resource))->i2cReceiveFunc)
27
28#define ADV7535_I2C_ModifyReg(handle, addr, reg, mask, value) \
29 VIDEO_I2C_ModifyReg(addr, kVIDEO_RegAddr8Bit, (reg), kVIDEO_RegWidth8Bit, mask, (value), \
30 ((const adv7535_resource_t *)((handle)->resource))->i2cReceiveFunc, \
31 ((const adv7535_resource_t *)((handle)->resource))->i2cSendFunc)
32
33#define ADV7535_CHECK_RET(x) \
34 do \
35 { \
36 status = (x); \
37 if (kStatus_Success != status) \
38 { \
39 return status; \
40 } \
41 } while (false)
42
43typedef struct _adv7533_reg_val
44{
45 uint8_t reg; /* Register index. */
46 uint8_t mask; /* Mask of the value. */
47 uint8_t value; /* Register value. */
48} adv7533_reg_val_t;
49
50/*******************************************************************************
51 * Variables
52 ******************************************************************************/
53static const adv7533_reg_val_t s_adv7533FixedRegs[] = {
54 /* Fixed registers that must be set on power up. */
55 /* 0x16[5:1] = 0b10000 */
56 {0x16U, (0x1FU << 1U), (0x10U << 1)},
57
58 /* 0x9A = 0xE0 */
59 {0x9AU, 0xFF, 0x0E},
60
61 /* 0xBA[7:3] = 0b01110 */
62 {0xBAU, (0x1FU << 3U), (0x0EU << 3U)},
63
64 /* 0xDE = 0x82 */
65 {0xDEU, 0xFF, 0x82},
66
67 /* 0xE4[6] = 1 */
68 {0xE4U, (1 << 6), (1 << 6)},
69
70 /* 0xE5 = 0x80 */
71 {0xE5U, 0xFF, 0x80},
72};
73
74static const adv7533_reg_val_t s_adv7533CecFixedRegs[] = {
75 /* CEC memory 0x15[5:4] = 1 */
76 {0x15U, (3U << 4U), (1 << 4)},
77
78 /* CEC memory 0x17[7:4] = 0b1101 */
79 {0x17U, (0xFU << 4U), (0x0D << 4U)},
80
81 /* CEC memory 0x24[4] = 0 */
82 {0x24U, (1 << 4U), (0x0 << 4U)},
83
84 /* CEC memory 0x57[0] = 1 */
85 {0x57U, (1 << 0U), (0x1 << 0U)},
86
87 /* CEC memory 0x57[4] = 1 */
88 {0x57U, (1 << 4U), (0x1 << 4U)},
89};
90
91const display_operations_t adv7535_ops = {
92 .init = ADV7535_Init,
93 .deinit = ADV7535_Deinit,
94 .start = ADV7535_Start,
95 .stop = ADV7535_Stop,
96};
97
98/*******************************************************************************
99 * Code
100 ******************************************************************************/
101
102static status_t ADV7535_I2C_ModifyRegs(display_handle_t *handle,
103 uint8_t i2cAddr,
104 const adv7533_reg_val_t values[],
105 uint32_t len)
106{
107 status_t status = kStatus_Success;
108
109 for (uint32_t i = 0; i < len; i++)
110 {
111 status = ADV7535_I2C_ModifyReg(handle, i2cAddr, values[i].reg, values[i].mask, values[i].value);
112
113 if (kStatus_Success != status)
114 {
115 return status;
116 }
117 }
118
119 return status;
120}
121
122status_t ADV7535_Init(display_handle_t *handle, const display_config_t *config)
123{
124 uint8_t chipRevision = 0U;
125 uint8_t mainI2cAddr = (((const adv7535_resource_t *)(handle->resource))->i2cAddr);
126 status_t status;
127
128 uint8_t lanes = config->dsiLanes;
129 uint16_t total_width, total_height;
130
131 if ((lanes <= 1U) || (lanes > 4U))
132 {
133 return kStatus_InvalidArgument;
134 }
135
136 /* Identify the device. */
137 status = ADV7535_I2C_ReadReg(handle, mainI2cAddr, 0x00, &chipRevision);
138
139 if (kStatus_Success != status)
140 {
141 return status;
142 }
143
144 if (ADV7535_CHIP_REVISION != chipRevision)
145 {
146 return kStatus_Fail;
147 }
148
149 /* -------- Power up sequence. -------- */
150 /* 0x41[6] - HDMI Power-down (Power Up = 0 HPD Must be High). */
151 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, mainI2cAddr, 0x41, (0x01U << 6U), 0U << 6));
152
153 /* 0xD6[6] - HPD Override (Override = 1). */
154 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, mainI2cAddr, 0xD6, (0x01U << 6U), 1U << 6));
155
156 /*
157 * DSI and CEC Map: 0x03[1] - Gate DSI LP Oscillator and DSI Bias Clock Powerdown, set to 0
158 * to enable normal operation
159 */
160 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, ADV7535_DSI_CEC_ADDR, 0x03, (0x01U << 1U), 0U << 1));
161
162 ADV7535_CHECK_RET(ADV7535_I2C_ModifyRegs(handle, mainI2cAddr, s_adv7533FixedRegs, ARRAY_SIZE(s_adv7533FixedRegs)));
163
164 status =
165 ADV7535_I2C_ModifyRegs(handle, ADV7535_DSI_CEC_ADDR, s_adv7533CecFixedRegs, ARRAY_SIZE(s_adv7533CecFixedRegs));
166 if (kStatus_Success != status)
167 {
168 return status;
169 }
170
171 /* -------- Configure the video timing. --------*/
172
173 /* Mute the HDMI. */
174 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, mainI2cAddr, 0xd5, 1U << 0, 1U << 0));
175
176 /* Use automatic pixel clock divider: 0x16[2] = 0 */
177 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, ADV7535_DSI_CEC_ADDR, 0x16, (0x01U << 2U), 0U << 2));
178
179 /* MIPI DSI lanes: 0x1c[4:6]. */
180 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, ADV7535_DSI_CEC_ADDR, 0x1c, (0x07U << 4U), (uint32_t)lanes << 4));
181
182 /* Use internal timing generator, first disable it then configure: 0x27[7] = 1 */
183 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, ADV7535_DSI_CEC_ADDR, 0x27, (0x01U << 7U), 1U << 7));
184
185 /* Total width. */
186 total_width = FSL_VIDEO_EXTRACT_WIDTH(config->resolution) + config->hfp + config->hbp + config->hsw;
187 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x28, (uint8_t)(total_width >> 4U)));
188 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x29, (uint8_t)(total_width << 4U)));
189
190 /* HSW. */
191 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x2A, (uint8_t)(config->hsw >> 4U)));
192 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x2B, (uint8_t)(config->hsw << 4U)));
193
194 /* HFP. */
195 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x2C, (uint8_t)(config->hfp >> 4U)));
196 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x2D, (uint8_t)(config->hfp << 4U)));
197
198 /* HBP. */
199 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x2E, (uint8_t)(config->hbp >> 4U)));
200 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x2F, (uint8_t)(config->hbp << 4U)));
201
202 /* Total height. */
203 total_height = FSL_VIDEO_EXTRACT_HEIGHT(config->resolution) + config->vfp + config->vbp + config->vsw;
204 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x30, (uint8_t)(total_height >> 4U)));
205 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x31, (uint8_t)(total_height << 4U)));
206
207 /* VSW. */
208 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x32, (uint8_t)(config->vsw >> 4U)));
209 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x33, (uint8_t)(config->vsw << 4U)));
210
211 /* VFP. */
212 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x34, (uint8_t)(config->vfp >> 4U)));
213 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x35, (uint8_t)(config->vfp << 4U)));
214
215 /* VBP. */
216 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x36, (uint8_t)(config->vbp >> 4U)));
217 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x37, (uint8_t)(config->vbp << 4U)));
218
219 /* Toggle the 0x27[6] to use the new timing parameter. */
220 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, ADV7535_DSI_CEC_ADDR, 0x27, (0x01U << 6U), 1U << 6));
221 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, ADV7535_DSI_CEC_ADDR, 0x27, (0x01U << 6U), 0U << 6));
222 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, ADV7535_DSI_CEC_ADDR, 0x27, (0x01U << 6U), 1U << 6));
223
224 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, mainI2cAddr, 0xd5, 1U << 0, 0U << 0));
225
226 /* ----------- HDMI output. ----------- */
227 /* 0xAF[1] - HDMI/DVI Mode Select (HDMI = 1) */
228 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, mainI2cAddr, 0xAF, (0x01U << 1U), 1U << 1));
229
230 /* Disable the test pattern. */
231 ADV7535_CHECK_RET(ADV7535_I2C_WriteReg(handle, ADV7535_DSI_CEC_ADDR, 0x55, 0x00));
232
233 /* 0x40[7] - GC Packet Enable (Enable = 1) */
234 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, mainI2cAddr, 0x40, (0x01U << 7U), 1U << 7));
235
236 /*
237 * 0x4C[3:0] Color depth of video to RX.
238 * 0000 = color depth not indicated
239 * 0100 = 24 bits per pixel
240 * 0101 = 30 bits per pixel
241 * 0110 = 36 bits per pixel
242 *
243 * Here use 24 bpp
244 */
245 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, mainI2cAddr, 0x4C, (0x0FU << 0U), 4U << 0));
246
247 /* 0x49[1:0] - Down Dither Output Color Depth (12 bits = 0b10) */
248 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, mainI2cAddr, 0x49, (0x03U << 0U), 2U << 0));
249
250 /* DSI and CEC Map: 0x03[7] - HDMI Output Enable (Enable = 1) */
251 ADV7535_CHECK_RET(ADV7535_I2C_ModifyReg(handle, ADV7535_DSI_CEC_ADDR, 0x03, (0x01U << 7U), 1U << 7));
252
253 return kStatus_Success;
254}
255
256status_t ADV7535_Deinit(display_handle_t *handle)
257{
258 uint8_t mainI2cAddr = (((const adv7535_resource_t *)(handle->resource))->i2cAddr);
259
260 /* 0x41[6] - HDMI Power-down */
261 return ADV7535_I2C_ModifyReg(handle, mainI2cAddr, 0x41, (0x01U << 6U), 1U << 6);
262}
263
264status_t ADV7535_Start(display_handle_t *handle)
265{
266 /* DSI and CEC Map: 0x03[7] - HDMI Output Enable (Enable = 1) */
267 return ADV7535_I2C_ModifyReg(handle, ADV7535_DSI_CEC_ADDR, 0x03, (0x01U << 7U), 1U << 7);
268}
269
270status_t ADV7535_Stop(display_handle_t *handle)
271{
272 /* DSI and CEC Map: 0x03[7] - HDMI Output Enable (Enable = 1) */
273 return ADV7535_I2C_ModifyReg(handle, ADV7535_DSI_CEC_ADDR, 0x03, (0x01U << 7U), 0U << 7);
274}
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/adv7535/fsl_adv7535.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/adv7535/fsl_adv7535.h
new file mode 100644
index 000000000..d84c762bf
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/adv7535/fsl_adv7535.h
@@ -0,0 +1,63 @@
1/*
2 * Copyright 2017-2018, 2020 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_ADV7535_H_
10#define _FSL_ADV7535_H_
11
12#include "fsl_common.h"
13#include "fsl_video_i2c.h"
14
15/*
16 * Change log:
17 *
18 * 1.0.1
19 * - Fix MISRA-C 2012 issues.
20 *
21 * 1.0.0
22 * - Initial version
23 */
24
25/*******************************************************************************
26 * Definitions
27 ******************************************************************************/
28
29/*!
30 * @brief ADV7535 resource.
31 *
32 * The I2C instance should be initialized before calling @ref ADV7535_Init.
33 */
34typedef struct _adv7535_resource
35{
36 video_i2c_send_func_t i2cSendFunc; /* I2C send function. */
37 video_i2c_receive_func_t i2cReceiveFunc; /* I2C receive function. */
38 uint8_t i2cAddr; /* I2C address for the main memory. */
39} adv7535_resource_t;
40
41extern const display_operations_t adv7535_ops;
42
43/*******************************************************************************
44 * API
45 ******************************************************************************/
46
47#if defined(__cplusplus)
48extern "C" {
49#endif
50
51status_t ADV7535_Init(display_handle_t *handle, const display_config_t *config);
52
53status_t ADV7535_Deinit(display_handle_t *handle);
54
55status_t ADV7535_Start(display_handle_t *handle);
56
57status_t ADV7535_Stop(display_handle_t *handle);
58
59#if defined(__cplusplus)
60}
61#endif
62
63#endif /* _FSL_ADV7535_H_ */
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/driver_dbi.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/driver_dbi.cmake
new file mode 100644
index 000000000..b8a281e6a
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/driver_dbi.cmake
@@ -0,0 +1,15 @@
1if(NOT DRIVER_DBI_INCLUDED)
2
3 set(DRIVER_DBI_INCLUDED true CACHE BOOL "driver_dbi component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 )
7
8 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
9 ${CMAKE_CURRENT_LIST_DIR}/.
10 )
11
12
13 include(driver_common)
14
15endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/flexio/driver_dbi_flexio_edma.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/flexio/driver_dbi_flexio_edma.cmake
new file mode 100644
index 000000000..e49fa15ca
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/flexio/driver_dbi_flexio_edma.cmake
@@ -0,0 +1,18 @@
1if(NOT DRIVER_DBI_FLEXIO_EDMA_INCLUDED)
2
3 set(DRIVER_DBI_FLEXIO_EDMA_INCLUDED true CACHE BOOL "driver_dbi_flexio_edma component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 ${CMAKE_CURRENT_LIST_DIR}/fsl_dbi_flexio_edma.c
7 )
8
9 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
10 ${CMAKE_CURRENT_LIST_DIR}/.
11 )
12
13
14 include(driver_flexio_mculcd)
15 include(driver_flexio_mculcd_edma)
16 include(driver_dbi)
17
18endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/flexio/fsl_dbi_flexio_edma.c b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/flexio/fsl_dbi_flexio_edma.c
new file mode 100644
index 000000000..b75761471
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/flexio/fsl_dbi_flexio_edma.c
@@ -0,0 +1,175 @@
1/*
2 * Copyright 2019-2020 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#include "fsl_dbi.h"
9#include "fsl_dbi_flexio_edma.h"
10
11/*******************************************************************************
12 * Definitions
13 ******************************************************************************/
14
15/*******************************************************************************
16 * Prototypes
17 ******************************************************************************/
18/*!
19 * @brief FLEXIO DBI bus transfer complete callback function.
20 */
21static void DBI_FLEXIO_EDMA_TransferCompletedCallback(FLEXIO_MCULCD_Type *base,
22 flexio_mculcd_edma_handle_t *handle,
23 status_t status,
24 void *userData);
25
26/*******************************************************************************
27 * Variables
28 ******************************************************************************/
29const dbi_xfer_ops_t g_dbiFlexioEdmaXferOps = {
30 .writeCommand = DBI_FLEXIO_EDMA_WriteCommand,
31 .writeData = DBI_FLEXIO_EDMA_WriteData,
32 .writeMemory = DBI_FLEXIO_EDMA_WriteMemory,
33 .readMemory = DBI_FLEXIO_EDMA_ReadMemory,
34 .setMemoryDoneCallback = DBI_FLEXIO_EDMA_SetMemoryDoneCallback,
35};
36
37/*******************************************************************************
38 * Code
39 ******************************************************************************/
40static void DBI_FLEXIO_EDMA_TransferCompletedCallback(FLEXIO_MCULCD_Type *base,
41 flexio_mculcd_edma_handle_t *handle,
42 status_t status,
43 void *userData)
44{
45 dbi_flexio_edma_xfer_handle_t *xferHandle = (dbi_flexio_edma_xfer_handle_t *)userData;
46
47 if (kStatus_FLEXIO_MCULCD_Idle == status)
48 {
49 status = kStatus_Success;
50 }
51
52 xferHandle->memDoneCallback(status, xferHandle->userData);
53}
54
55void DBI_FLEXIO_EDMA_SetMemoryDoneCallback(void *dbiXferHandle, dbi_mem_done_callback_t callback, void *userData)
56{
57 dbi_flexio_edma_xfer_handle_t *xferHandle = (dbi_flexio_edma_xfer_handle_t *)dbiXferHandle;
58
59 xferHandle->memDoneCallback = callback;
60 xferHandle->userData = userData;
61}
62
63status_t DBI_FLEXIO_EDMA_CreateXferHandle(dbi_flexio_edma_xfer_handle_t *dbiXferHandle,
64 FLEXIO_MCULCD_Type *flexioLCD,
65 edma_handle_t *txDmaHandle,
66 edma_handle_t *rxDmaHandle)
67{
68 (void)memset(dbiXferHandle, 0, sizeof(dbi_flexio_edma_xfer_handle_t));
69
70 return FLEXIO_MCULCD_TransferCreateHandleEDMA(flexioLCD, &dbiXferHandle->flexioHandle,
71 DBI_FLEXIO_EDMA_TransferCompletedCallback, dbiXferHandle, txDmaHandle,
72 rxDmaHandle);
73}
74
75status_t DBI_FLEXIO_EDMA_WriteCommand(void *dbiXferHandle, uint32_t command)
76{
77 dbi_flexio_edma_xfer_handle_t *xferHandle = (dbi_flexio_edma_xfer_handle_t *)dbiXferHandle;
78
79 FLEXIO_MCULCD_Type *flexioLCD = xferHandle->flexioHandle.base;
80
81 FLEXIO_MCULCD_StartTransfer(flexioLCD);
82 FLEXIO_MCULCD_WriteCommandBlocking(flexioLCD, command);
83 FLEXIO_MCULCD_StopTransfer(flexioLCD);
84
85 return kStatus_Success;
86}
87
88status_t DBI_FLEXIO_EDMA_WriteData(void *dbiXferHandle, void *data, uint32_t len_byte)
89{
90 dbi_flexio_edma_xfer_handle_t *xferHandle = (dbi_flexio_edma_xfer_handle_t *)dbiXferHandle;
91
92 FLEXIO_MCULCD_Type *flexioLCD = xferHandle->flexioHandle.base;
93
94 FLEXIO_MCULCD_StartTransfer(flexioLCD);
95 FLEXIO_MCULCD_WriteDataArrayBlocking(flexioLCD, data, len_byte);
96 FLEXIO_MCULCD_StopTransfer(flexioLCD);
97
98 return kStatus_Success;
99}
100
101status_t DBI_FLEXIO_EDMA_WriteMemory(void *dbiXferHandle, uint32_t command, const void *data, uint32_t len_byte)
102{
103 status_t status;
104
105 flexio_mculcd_transfer_t xfer;
106
107 dbi_flexio_edma_xfer_handle_t *xferHandle = (dbi_flexio_edma_xfer_handle_t *)dbiXferHandle;
108
109 /* Callback is necessary to notify user. */
110 assert(NULL != xferHandle->memDoneCallback);
111
112 FLEXIO_MCULCD_Type *flexioLCD = xferHandle->flexioHandle.base;
113
114 if (NULL != xferHandle->flexioHandle.txDmaHandle)
115 {
116 xfer.command = command;
117 xfer.mode = kFLEXIO_MCULCD_WriteArray;
118 xfer.dataAddrOrSameValue = (uint32_t)(const uint8_t *)data;
119 xfer.dataSize = len_byte;
120
121 status = FLEXIO_MCULCD_TransferEDMA(flexioLCD, &xferHandle->flexioHandle, &xfer);
122 }
123 else
124 {
125 /* If DMA not enabled, use the blocking method. */
126 FLEXIO_MCULCD_StartTransfer(flexioLCD);
127 FLEXIO_MCULCD_WriteCommandBlocking(flexioLCD, command);
128 FLEXIO_MCULCD_WriteDataArrayBlocking(flexioLCD, (const void *)data, (size_t)len_byte);
129 FLEXIO_MCULCD_StopTransfer(flexioLCD);
130
131 xferHandle->memDoneCallback(kStatus_Success, xferHandle->userData);
132
133 status = kStatus_Success;
134 }
135
136 return status;
137}
138
139status_t DBI_FLEXIO_EDMA_ReadMemory(void *dbiXferHandle, uint32_t command, void *data, uint32_t len_byte)
140{
141 status_t status;
142
143 flexio_mculcd_transfer_t xfer;
144
145 dbi_flexio_edma_xfer_handle_t *xferHandle = (dbi_flexio_edma_xfer_handle_t *)dbiXferHandle;
146
147 /* Callback is necessary to notify user. */
148 assert(NULL != xferHandle->memDoneCallback);
149
150 FLEXIO_MCULCD_Type *flexioLCD = xferHandle->flexioHandle.base;
151
152 if (NULL != xferHandle->flexioHandle.rxDmaHandle)
153 {
154 xfer.command = command;
155 xfer.mode = kFLEXIO_MCULCD_ReadArray;
156 xfer.dataAddrOrSameValue = (uint32_t)(uint8_t *)data;
157 xfer.dataSize = len_byte;
158
159 status = FLEXIO_MCULCD_TransferEDMA(flexioLCD, &xferHandle->flexioHandle, &xfer);
160 }
161 else
162 {
163 /* If DMA not enabled, use the blocking method. */
164 FLEXIO_MCULCD_StartTransfer(flexioLCD);
165 FLEXIO_MCULCD_WriteCommandBlocking(flexioLCD, command);
166 FLEXIO_MCULCD_ReadDataArrayBlocking(flexioLCD, data, (size_t)len_byte);
167 FLEXIO_MCULCD_StopTransfer(flexioLCD);
168
169 xferHandle->memDoneCallback(kStatus_Success, xferHandle->userData);
170
171 status = kStatus_Success;
172 }
173
174 return status;
175}
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/flexio/fsl_dbi_flexio_edma.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/flexio/fsl_dbi_flexio_edma.h
new file mode 100644
index 000000000..b8b3fb4af
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/flexio/fsl_dbi_flexio_edma.h
@@ -0,0 +1,131 @@
1/*
2 * Copyright 2019-2020 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#ifndef _FSL_DBI_FLEXIO_EDMA_H_
9#define _FSL_DBI_FLEXIO_EDMA_H_
10
11#include "fsl_dbi.h"
12#include "fsl_flexio_mculcd.h"
13#include "fsl_flexio_mculcd_edma.h"
14
15/*
16 * Change log:
17 *
18 * 1.0.1
19 * - Fix MISRA-C 2012 issues.
20 *
21 * 1.0.0
22 * - Initial version
23 */
24
25/*!
26 * @addtogroup dbi_flexio_edma
27 * @{
28 */
29
30/*******************************************************************************
31 * Definitions
32 ******************************************************************************/
33/*! @brief FLEXIO DBI interface (MCU LCD) transfer operation. */
34typedef struct _dbi_flexio_edma_xfer_handle
35{
36 dbi_xfer_ops_t *xferOps; /*!< Transfer operations. */
37 flexio_mculcd_edma_handle_t flexioHandle; /*!< FLEXIO DMA transfer handle. */
38 dbi_mem_done_callback_t memDoneCallback; /*!< The callback function when video memory access done. */
39 void *userData; /*!< Parameter of @ref memDoneCallback */
40} dbi_flexio_edma_xfer_handle_t;
41
42/*! @brief FLEXIO DBI interface (MCU LCD) transfer operation. */
43extern const dbi_xfer_ops_t g_dbiFlexioEdmaXferOps;
44
45/*******************************************************************************
46 * API
47 ******************************************************************************/
48#if defined(__cplusplus)
49extern "C" {
50#endif
51
52/*!
53 * @brief Create FLEXIO DBI transfer handle.
54 *
55 * @param[out] dbiXferHandle Pointer the handle that will be created.
56 * @param[in] flexioLCD Pointer FLEXIO LCD structure.
57 * @param[in] txDmaHandle Pointer to the DMA TX transfer handle, if you don't
58 * want to use the function @ref DBI_FLEXIO_EDMA_WriteMemory, this could be NULL.
59 * When this is NULL, the blocking method will be used instead of DMA method.
60 * @param[in] txDmaHandle Pointer to the DMA RX transfer handle, if you don't
61 * want to use the function @ref DBI_FLEXIO_EDMA_ReadMemory, this could be NULL.
62 * When this is NULL, the blocking method will be used instead of DMA method.
63 * @return Return true if success, otherwise return error code.
64 */
65status_t DBI_FLEXIO_EDMA_CreateXferHandle(dbi_flexio_edma_xfer_handle_t *dbiXferHandle,
66 FLEXIO_MCULCD_Type *flexioLCD,
67 edma_handle_t *txDmaHandle,
68 edma_handle_t *rxDmaHandle);
69
70/*!
71 * @brief Write command through DBI.
72 *
73 * @param[in] dbiXferHandle Pointer the handle that created by @ref DBI_FLEXIO_EDMA_CreateXferHandle.
74 * @param[in] command The command to send.
75 * @return Return true if success, otherwise return error code.
76 */
77status_t DBI_FLEXIO_EDMA_WriteCommand(void *dbiXferHandle, uint32_t command);
78
79/*!
80 * @brief Write data through DBI.
81 *
82 * @param[in] dbiXferHandle Pointer the handle that created by @ref DBI_FLEXIO_EDMA_CreateXferHandle.
83 * @param[in] data The data to send.
84 * @param[in] len_byte The length of the data in bytes.
85 * @return Return true if success, otherwise return error code.
86 */
87status_t DBI_FLEXIO_EDMA_WriteData(void *dbiXferHandle, void *data, uint32_t len_byte);
88
89/*!
90 * @brief Write data to the video memory through DBI.
91 *
92 * This function is faster than @ref DBI_FLEXIO_EDMA_WriteData because DMA is involved.
93 *
94 * @param[in] dbiXferHandle Pointer the handle that created by @ref DBI_FLEXIO_EDMA_CreateXferHandle.
95 * @param[in] command The command sent before writing data.
96 * @param[in] data The data to send.
97 * @param[in] len_byte The length of the data in bytes.
98 * @return Return true if success, otherwise return error code.
99 */
100status_t DBI_FLEXIO_EDMA_WriteMemory(void *dbiXferHandle, uint32_t command, const void *data, uint32_t len_byte);
101
102/*!
103 * @brief Read data from the video memory through DBI.
104 *
105 * @param[in] dbiXferHandle Pointer the handle that created by @ref DBI_FLEXIO_EDMA_CreateXferHandle.
106 * @param[in] command The command sent before reading data.
107 * @param[out] data The buffer to receive the data.
108 * @param[in] len_byte The length of the data in bytes.
109 * @return Return true if success, otherwise return error code.
110 */
111status_t DBI_FLEXIO_EDMA_ReadMemory(void *dbiXferHandle, uint32_t command, void *data, uint32_t len_byte);
112
113/*!
114 * @brief Register the callback function called when memory function done.
115 *
116 * The memory read and write functions are non-blocking function, when transaction
117 * finished, callback is called to inform higher layer.
118 *
119 * @param[in] dbiXferHandle Pointer the handle that created by @ref DBI_FLEXIO_EDMA_CreateXferHandle.
120 * @param[in] callback The callback when memory read or write finished.
121 * @param[in] userData Parameter of the callback.
122 */
123void DBI_FLEXIO_EDMA_SetMemoryDoneCallback(void *dbiXferHandle, dbi_mem_done_callback_t callback, void *userData);
124
125#if defined(__cplusplus)
126}
127#endif
128
129/*! @} */
130
131#endif /* _FSL_DBI_FLEXIO_EDMA_H_ */
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/fsl_dbi.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/fsl_dbi.h
new file mode 100644
index 000000000..549e2ffaa
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dbi/fsl_dbi.h
@@ -0,0 +1,70 @@
1/*
2 * Copyright 2019 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#ifndef _FSL_DBI_H_
9#define _FSL_DBI_H_
10
11#include "fsl_common.h"
12
13/*!
14 * @addtogroup dbi
15 * @{
16 */
17
18/*******************************************************************************
19 * Definitions
20 ******************************************************************************/
21/*!
22 * @brief Callback function when the writeMemory or readMemory finished.
23 *
24 * If transfer done successfully, the @p status is kStatus_Success.
25 */
26typedef void (*dbi_mem_done_callback_t)(status_t status, void *userData);
27
28/*!
29 * @brief DBI interface (MCU LCD) transfer operation.
30 *
31 * The API @ref writeCommand and @ref writeData are blocking method, they returns
32 * only when transfer finished. They are usually used to transfer small data, for
33 * example, sending the cofigurations.
34 *
35 * The API @ref writeMemory and @ref readMemory are non-blocking method, they are
36 * used to write or read the LCD contoller video memory. These APIs start transfer
37 * and return directly, upper layer could be notified by callback when transfer
38 * done. The callback function is set by @ref setMemoryDoneCallback.
39 */
40typedef struct _dbi_xfer_ops
41{
42 status_t (*writeCommand)(void *dbiXferHandle, uint32_t command); /*!< Write command. */
43 status_t (*writeData)(void *dbiXferHandle, void *data, uint32_t len_byte); /*!< Write data. */
44 status_t (*writeMemory)(void *dbiXferHandle,
45 uint32_t command,
46 const void *data,
47 uint32_t len_byte); /*!< Write to the memory. */
48 status_t (*readMemory)(void *dbiXferHandle,
49 uint32_t command,
50 void *data,
51 uint32_t len_byte); /*!< Read from the memory. */
52 void (*setMemoryDoneCallback)(void *dbiXferHandle,
53 dbi_mem_done_callback_t callback,
54 void *userData); /*!< Set the memory access done callback. */
55} dbi_xfer_ops_t;
56
57/*******************************************************************************
58 * API
59 ******************************************************************************/
60#if defined(__cplusplus)
61extern "C" {
62#endif
63
64#if defined(__cplusplus)
65}
66#endif
67
68/*! @} */
69
70#endif /* _FSL_DBI_H_ */
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/driver_dc-fb-common.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/driver_dc-fb-common.cmake
new file mode 100644
index 000000000..49fcb137d
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/driver_dc-fb-common.cmake
@@ -0,0 +1,24 @@
1if(NOT DRIVER_DC-FB-COMMON_INCLUDED)
2
3 set(DRIVER_DC-FB-COMMON_INCLUDED true CACHE BOOL "driver_dc-fb-common component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 )
7
8 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
9 ${CMAKE_CURRENT_LIST_DIR}/.
10 )
11
12 #OR Logic component
13 if(${MCUX_DEVICE} STREQUAL "MIMXRT1052")
14 include(driver_video-common)
15 endif()
16 if(${MCUX_DEVICE} STREQUAL "MIMXRT1064")
17 include(driver_video-common)
18 endif()
19 if(${MCUX_DEVICE} STREQUAL "MIMXRT1062")
20 include(driver_video-common)
21 endif()
22
23
24endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/elcdif/driver_dc-fb-elcdif.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/elcdif/driver_dc-fb-elcdif.cmake
new file mode 100644
index 000000000..d39ac25f6
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/elcdif/driver_dc-fb-elcdif.cmake
@@ -0,0 +1,17 @@
1if(NOT DRIVER_DC-FB-ELCDIF_INCLUDED)
2
3 set(DRIVER_DC-FB-ELCDIF_INCLUDED true CACHE BOOL "driver_dc-fb-elcdif component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 ${CMAKE_CURRENT_LIST_DIR}/fsl_dc_fb_elcdif.c
7 )
8
9 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
10 ${CMAKE_CURRENT_LIST_DIR}/.
11 )
12
13
14 include(driver_dc-fb-common)
15 include(driver_elcdif)
16
17endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/elcdif/fsl_dc_fb_elcdif.c b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/elcdif/fsl_dc_fb_elcdif.c
new file mode 100644
index 000000000..17faf688f
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/elcdif/fsl_dc_fb_elcdif.c
@@ -0,0 +1,263 @@
1/*
2 * Copyright 2019-2020 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#include "fsl_dc_fb_elcdif.h"
9
10/*******************************************************************************
11 * Definitions
12 ******************************************************************************/
13const dc_fb_ops_t g_dcFbOpsElcdif = {
14 .init = DC_FB_ELCDIF_Init,
15 .deinit = DC_FB_ELCDIF_Deinit,
16 .enableLayer = DC_FB_ELCDIF_EnableLayer,
17 .disableLayer = DC_FB_ELCDIF_DisableLayer,
18 .setLayerConfig = DC_FB_ELCDIF_SetLayerConfig,
19 .getLayerDefaultConfig = DC_FB_ELCDIF_GetLayerDefaultConfig,
20 .setFrameBuffer = DC_FB_ELCDIF_SetFrameBuffer,
21 .getProperty = DC_FB_ELCDIF_GetProperty,
22 .setCallback = DC_FB_ELCDIF_SetCallback,
23};
24
25typedef struct
26{
27 video_pixel_format_t videoFormat;
28 elcdif_pixel_format_t elcdifFormat;
29} dc_fb_elcdif_pixel_foramt_map_t;
30
31/*******************************************************************************
32 * Prototypes
33 ******************************************************************************/
34static status_t DC_FB_ELCDIF_GetPixelFormat(video_pixel_format_t input, elcdif_pixel_format_t *output);
35
36/*******************************************************************************
37 * Variables
38 ******************************************************************************/
39static const dc_fb_elcdif_pixel_foramt_map_t s_elcdifPixelFormatMap[] = {
40 {kVIDEO_PixelFormatRGB565, kELCDIF_PixelFormatRGB565},
41 {
42 kVIDEO_PixelFormatXRGB8888,
43 kELCDIF_PixelFormatXRGB8888,
44 },
45 {
46 kVIDEO_PixelFormatRGB888,
47 kELCDIF_PixelFormatRGB888,
48 }};
49
50/*******************************************************************************
51 * Code
52 ******************************************************************************/
53static status_t DC_FB_ELCDIF_GetPixelFormat(video_pixel_format_t input, elcdif_pixel_format_t *output)
54{
55 uint8_t i;
56
57 for (i = 0; i < ARRAY_SIZE(s_elcdifPixelFormatMap); i++)
58 {
59 if (s_elcdifPixelFormatMap[i].videoFormat == input)
60 {
61 *output = s_elcdifPixelFormatMap[i].elcdifFormat;
62 return kStatus_Success;
63 }
64 }
65
66 return kStatus_InvalidArgument;
67}
68
69status_t DC_FB_ELCDIF_Init(const dc_fb_t *dc)
70{
71 const dc_fb_elcdif_config_t *dcConfig;
72 elcdif_rgb_mode_config_t elcdifConfig = {0};
73
74 dc_fb_elcdif_handle_t *dcHandle = dc->prvData;
75
76 if (0U == dcHandle->initTimes++)
77 {
78 dcConfig = (const dc_fb_elcdif_config_t *)(dc->config);
79
80 elcdifConfig.panelWidth = dcConfig->width;
81 elcdifConfig.panelHeight = dcConfig->height;
82 elcdifConfig.hsw = (uint8_t)dcConfig->hsw;
83 elcdifConfig.hfp = (uint8_t)dcConfig->hfp;
84 elcdifConfig.hbp = (uint8_t)dcConfig->hbp;
85 elcdifConfig.vsw = (uint8_t)dcConfig->vsw;
86 elcdifConfig.vfp = (uint8_t)dcConfig->vfp;
87 elcdifConfig.vbp = (uint8_t)dcConfig->vbp;
88 elcdifConfig.bufferAddr = 0;
89 elcdifConfig.dataBus = dcConfig->dataBus;
90 elcdifConfig.pixelFormat = DC_FB_ELCDIF_DEFAULT_PIXEL_FORMAT_ELCDIF;
91 elcdifConfig.polarityFlags = dcConfig->polarityFlags;
92
93 dcHandle->height = dcConfig->height;
94 dcHandle->width = dcConfig->width;
95 dcHandle->elcdif = dcConfig->elcdif;
96
97 ELCDIF_RgbModeInit(dcHandle->elcdif, &elcdifConfig);
98 }
99
100 return kStatus_Success;
101}
102
103status_t DC_FB_ELCDIF_Deinit(const dc_fb_t *dc)
104{
105 dc_fb_elcdif_handle_t *dcHandle = dc->prvData;
106
107 if (dcHandle->initTimes > 0U)
108 {
109 if ((--dcHandle->initTimes) == 0U)
110 {
111 ELCDIF_Deinit(dcHandle->elcdif);
112 }
113 }
114
115 return kStatus_Success;
116}
117
118status_t DC_FB_ELCDIF_EnableLayer(const dc_fb_t *dc, uint8_t layer)
119{
120 assert(layer < DC_FB_ELCDIF_MAX_LAYER);
121
122 status_t status = kStatus_Success;
123 dc_fb_elcdif_handle_t *dcHandle = dc->prvData;
124
125 /* If the layer is already started. */
126 if (!dcHandle->layers[layer].enabled)
127 {
128 /* Must have valid frame buffer to show. */
129 if (dcHandle->layers[layer].activeBuffer == NULL)
130 {
131 status = kStatus_Fail;
132 }
133 else
134 {
135 ELCDIF_RgbModeStart(dcHandle->elcdif);
136 dcHandle->layers[layer].enabled = true;
137 ELCDIF_EnableInterrupts(dcHandle->elcdif, (uint32_t)kELCDIF_CurFrameDoneInterruptEnable);
138 }
139 }
140
141 return status;
142}
143
144status_t DC_FB_ELCDIF_DisableLayer(const dc_fb_t *dc, uint8_t layer)
145{
146 assert(layer < DC_FB_ELCDIF_MAX_LAYER);
147
148 dc_fb_elcdif_handle_t *dcHandle = dc->prvData;
149
150 if (dcHandle->layers[layer].enabled)
151 {
152 ELCDIF_RgbModeStop(dcHandle->elcdif);
153 dcHandle->layers[layer].enabled = false;
154 ELCDIF_DisableInterrupts(dcHandle->elcdif, (uint32_t)kELCDIF_CurFrameDoneInterruptEnable);
155 }
156
157 return kStatus_Success;
158}
159
160status_t DC_FB_ELCDIF_SetLayerConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo)
161{
162 assert(layer < DC_FB_ELCDIF_MAX_LAYER);
163
164 elcdif_pixel_format_t pixelFormat;
165 status_t status;
166
167 dc_fb_elcdif_handle_t *dcHandle = (dc_fb_elcdif_handle_t *)(dc->prvData);
168
169 assert(fbInfo->startX == 0U);
170 assert(fbInfo->startY == 0U);
171 assert(fbInfo->width == dcHandle->width);
172 assert(fbInfo->height == dcHandle->height);
173 assert(fbInfo->strideBytes == VIDEO_GetPixelSizeBits(fbInfo->pixelFormat) * dcHandle->width / 8U);
174
175 status = DC_FB_ELCDIF_GetPixelFormat(fbInfo->pixelFormat, &pixelFormat);
176 if (kStatus_Success != status)
177 {
178 return status;
179 }
180
181 ELCDIF_RgbModeSetPixelFormat(dcHandle->elcdif, pixelFormat);
182
183 return kStatus_Success;
184}
185
186status_t DC_FB_ELCDIF_GetLayerDefaultConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo)
187{
188 assert(layer < DC_FB_ELCDIF_MAX_LAYER);
189
190 dc_fb_elcdif_handle_t *dcHandle = (dc_fb_elcdif_handle_t *)(dc->prvData);
191
192 fbInfo->startX = 0;
193 fbInfo->startY = 0;
194 fbInfo->width = dcHandle->width;
195 fbInfo->height = dcHandle->height;
196 fbInfo->strideBytes = 2U * dcHandle->width;
197 fbInfo->pixelFormat = DC_FB_ELCDIF_DEFAULT_PIXEL_FORMAT;
198
199 return kStatus_Success;
200}
201
202status_t DC_FB_ELCDIF_SetFrameBuffer(const dc_fb_t *dc, uint8_t layer, void *frameBuffer)
203{
204 assert(layer < DC_FB_ELCDIF_MAX_LAYER);
205 dc_fb_elcdif_handle_t *dcHandle = dc->prvData;
206
207 ELCDIF_SetNextBufferAddr(dcHandle->elcdif, (uint32_t)(uint8_t *)frameBuffer);
208 dcHandle->layers[layer].inactiveBuffer = frameBuffer;
209
210 /*
211 * If the layer is not started, set the current buffer and next buffer to
212 * new frame buffer, there is not pending frame.
213 * If the layer already started, only set the next buffer, and the new frameBuffer
214 * is pending until current buffer switched out.
215 */
216 if (!dcHandle->layers[layer].enabled)
217 {
218 dcHandle->elcdif->CUR_BUF = (uint32_t)(uint8_t *)frameBuffer;
219 dcHandle->layers[layer].activeBuffer = frameBuffer;
220 }
221 else
222 {
223 dcHandle->layers[layer].framePending = true;
224 }
225
226 return kStatus_Success;
227}
228
229void DC_FB_ELCDIF_SetCallback(const dc_fb_t *dc, uint8_t layer, dc_fb_callback_t callback, void *param)
230{
231 assert(layer < DC_FB_ELCDIF_MAX_LAYER);
232 dc_fb_elcdif_handle_t *dcHandle = dc->prvData;
233
234 dcHandle->layers[layer].callback = callback;
235 dcHandle->layers[layer].cbParam = param;
236}
237
238uint32_t DC_FB_ELCDIF_GetProperty(const dc_fb_t *dc)
239{
240 return (uint32_t)kDC_FB_ReserveFrameBuffer;
241}
242
243void DC_FB_ELCDIF_IRQHandler(const dc_fb_t *dc)
244{
245 dc_fb_elcdif_handle_t *dcHandle = dc->prvData;
246 dc_fb_elcdif_layer_t *layer;
247 void *oldActiveBuffer;
248 ELCDIF_ClearInterruptStatus(dcHandle->elcdif, (uint32_t)kELCDIF_CurFrameDone);
249
250 for (uint8_t i = 0; i < DC_FB_ELCDIF_MAX_LAYER; i++)
251 {
252 if (dcHandle->layers[i].framePending)
253 {
254 layer = &dcHandle->layers[i];
255
256 oldActiveBuffer = layer->activeBuffer;
257 layer->activeBuffer = layer->inactiveBuffer;
258 dcHandle->layers[i].framePending = false;
259
260 layer->callback(layer->cbParam, oldActiveBuffer);
261 }
262 }
263}
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/elcdif/fsl_dc_fb_elcdif.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/elcdif/fsl_dc_fb_elcdif.h
new file mode 100644
index 000000000..09be21405
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/elcdif/fsl_dc_fb_elcdif.h
@@ -0,0 +1,101 @@
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. */
38typedef 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. */
49typedef 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. */
59typedef 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
74extern const dc_fb_ops_t g_dcFbOpsElcdif;
75
76/*******************************************************************************
77 * API
78 ******************************************************************************/
79
80#if defined(__cplusplus)
81extern "C" {
82#endif
83
84status_t DC_FB_ELCDIF_Init(const dc_fb_t *dc);
85status_t DC_FB_ELCDIF_Deinit(const dc_fb_t *dc);
86status_t DC_FB_ELCDIF_EnableLayer(const dc_fb_t *dc, uint8_t layer);
87status_t DC_FB_ELCDIF_DisableLayer(const dc_fb_t *dc, uint8_t layer);
88status_t DC_FB_ELCDIF_SetLayerConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo);
89status_t DC_FB_ELCDIF_GetLayerDefaultConfig(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo);
90status_t DC_FB_ELCDIF_SetFrameBuffer(const dc_fb_t *dc, uint8_t layer, void *frameBuffer);
91uint32_t DC_FB_ELCDIF_GetProperty(const dc_fb_t *dc);
92void DC_FB_ELCDIF_SetCallback(const dc_fb_t *dc, uint8_t layer, dc_fb_callback_t callback, void *param);
93void 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_ */
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/fsl_dc_fb.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/fsl_dc_fb.h
new file mode 100644
index 000000000..a81b15b93
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/dc/fsl_dc_fb.h
@@ -0,0 +1,80 @@
1/*
2 * Copyright 2019 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#ifndef _FSL_DC_FB_H_
9#define _FSL_DC_FB_H_
10
11#include "fsl_video_common.h"
12
13/*!
14 * @addtogroup dc_fb
15 * @{
16 */
17
18/*******************************************************************************
19 * Definitions
20 ******************************************************************************/
21/*! @brief frame buffer information. */
22typedef struct _dc_fb_info
23{
24 uint16_t startX; /*!< The start position in the panel. */
25 uint16_t startY; /*!< The start position in the panel. */
26 uint16_t width; /*!< How many pixels in one line of the frame buffer.*/
27 uint16_t height; /*!< How many lines in one frame buffer. */
28 uint16_t strideBytes; /*!< Stride of the frame buffer */
29 video_pixel_format_t pixelFormat; /*!< Pixel format of the frame buffer */
30} dc_fb_info_t;
31
32/*! @brief Display controller frame callback. */
33typedef void (*dc_fb_callback_t)(void *param, void *inactiveBuffer);
34
35/*! @brief Display controller. */
36typedef struct _dc_fb dc_fb_t;
37
38/*! @brief Display controller operations. */
39typedef struct _dc_fb_ops
40{
41 status_t (*init)(const dc_fb_t *dc);
42 status_t (*deinit)(const dc_fb_t *dc);
43 status_t (*enableLayer)(const dc_fb_t *dc, uint8_t layer);
44 status_t (*disableLayer)(const dc_fb_t *dc, uint8_t layer);
45 status_t (*setLayerConfig)(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo);
46 status_t (*getLayerDefaultConfig)(const dc_fb_t *dc, uint8_t layer, dc_fb_info_t *fbInfo);
47 status_t (*setFrameBuffer)(const dc_fb_t *dc, uint8_t layer, void *frameBuffer);
48 uint32_t (*getProperty)(const dc_fb_t *dc);
49 void (*setCallback)(const dc_fb_t *dc, uint8_t layer, dc_fb_callback_t callback, void *param);
50} dc_fb_ops_t;
51
52/*! @brief Display controller property. */
53enum _dc_fb_property
54{
55 kDC_FB_ReserveFrameBuffer = (1 << 0), /*< One frame buffer is always used as the DC active buffer. */
56};
57
58/*! @brief Display controller driver handle. */
59struct _dc_fb
60{
61 const dc_fb_ops_t *ops; /* Display controller operations. */
62 void *prvData; /* Private data for the display controller. */
63 const void *config; /* Configuration for the display controller. */
64};
65
66/*******************************************************************************
67 * API
68 ******************************************************************************/
69
70#if defined(__cplusplus)
71extern "C" {
72#endif
73
74#if defined(__cplusplus)
75}
76#endif
77
78/*! @} */
79
80#endif /* _FSL_DC_FB_H_ */
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/driver_display-common.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/driver_display-common.cmake
new file mode 100644
index 000000000..e83abbab6
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/driver_display-common.cmake
@@ -0,0 +1,21 @@
1if(NOT DRIVER_DISPLAY-COMMON_INCLUDED)
2
3 set(DRIVER_DISPLAY-COMMON_INCLUDED true CACHE BOOL "driver_display-common component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 )
7
8 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
9 ${CMAKE_CURRENT_LIST_DIR}/.
10 )
11
12 #OR Logic component
13 if(${MCUX_DEVICE} STREQUAL "MIMX8QM6_cm4_core1")
14 include(driver_video-common)
15 endif()
16 if(${MCUX_DEVICE} STREQUAL "MIMX8QX6")
17 include(driver_video-common)
18 endif()
19
20
21endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/fsl_display.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/fsl_display.h
new file mode 100644
index 000000000..64d2e7f1c
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/fsl_display.h
@@ -0,0 +1,126 @@
1/*
2 * Copyright 2017-2018 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_DISPLAY_H_
10#define _FSL_DISPLAY_H_
11
12#include "fsl_video_common.h"
13
14/*******************************************************************************
15 * Definitions
16 ******************************************************************************/
17
18/*! @brief Display control flags. */
19enum _display_flags
20{
21 kDISPLAY_VsyncActiveLow = 0U, /*!< VSYNC active low. */
22 kDISPLAY_VsyncActiveHigh = (1U << 0U), /*!< VSYNC active high. */
23 kDISPLAY_HsyncActiveLow = 0U, /*!< HSYNC active low. */
24 kDISPLAY_HsyncActiveHigh = (1U << 1U), /*!< HSYNC active high. */
25 kDISPLAY_DataEnableActiveHigh = 0U, /*!< Data enable line active high. */
26 kDISPLAY_DataEnableActiveLow = (1U << 2U), /*!< Data enable line active low. */
27 kDISPLAY_DataLatchOnRisingEdge = 0U, /*!< Latch data on rising clock edge. */
28 kDISPLAY_DataLatchOnFallingEdge = (1U << 3U), /*!< Latch data on falling clock edge. */
29};
30
31/*! @brief Display configuration. */
32typedef struct _display_config
33{
34 uint32_t resolution; /*!< Resolution, see @ref video_resolution_t and @ref FSL_VIDEO_RESOLUTION. */
35 uint16_t hsw; /*!< HSYNC pulse width. */
36 uint16_t hfp; /*!< Horizontal front porch. */
37 uint16_t hbp; /*!< Horizontal back porch. */
38 uint16_t vsw; /*!< VSYNC pulse width. */
39 uint16_t vfp; /*!< Vrtical front porch. */
40 uint16_t vbp; /*!< Vertical back porch. */
41 uint32_t controlFlags; /*!< Control flags, OR'ed value of @ref _display_flags. */
42 uint8_t dsiLanes; /*!< MIPI DSI data lanes number. */
43 uint32_t pixelClock_Hz; /*!< Pixel clock in Hz. */
44 video_pixel_format_t pixelFormat; /*!< Pixel format. */
45} display_config_t;
46
47typedef struct _display_handle display_handle_t;
48
49/*! @brief Display device operations. */
50typedef struct _display_operations
51{
52 status_t (*init)(display_handle_t *handle, const display_config_t *config); /*!< Init the device. */
53 status_t (*deinit)(display_handle_t *handle); /*!< Deinit the device. */
54 status_t (*start)(display_handle_t *handle); /*!< Start the device. */
55 status_t (*stop)(display_handle_t *handle); /*!< Stop the device. */
56} display_operations_t;
57
58/*! @brief Display handle. */
59struct _display_handle
60{
61 const void *resource;
62 const display_operations_t *ops;
63 uint16_t width;
64 uint16_t height;
65 video_pixel_format_t pixelFormat;
66};
67
68/*******************************************************************************
69 * API
70 ******************************************************************************/
71
72#if defined(__cplusplus)
73extern "C" {
74#endif
75
76/*!
77 * @brief Initializes the display device with user defined configuration.
78 *
79 * @param handle Display device handle.
80 * @param config Pointer to the user-defined configuration structure.
81 * @return Returns @ref kStatus_Success if initialize success, otherwise returns
82 * error code.
83 */
84static inline status_t DISPLAY_Init(display_handle_t *handle, const display_config_t *config)
85{
86 return handle->ops->init(handle, config);
87}
88
89/*!
90 * @brief Deinitialize the display device.
91 *
92 * @param handle Display device handle.
93 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
94 */
95static inline status_t DISPLAY_Deinit(display_handle_t *handle)
96{
97 return handle->ops->deinit(handle);
98}
99
100/*!
101 * @brief Start the display device.
102 *
103 * @param handle Display device handle.
104 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
105 */
106static inline status_t DISPLAY_Start(display_handle_t *handle)
107{
108 return handle->ops->start(handle);
109}
110
111/*!
112 * @brief Stop the display device.
113 *
114 * @param handle Display device handle.
115 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
116 */
117static inline status_t DISPLAY_Stop(display_handle_t *handle)
118{
119 return handle->ops->stop(handle);
120}
121
122#if defined(__cplusplus)
123}
124#endif
125
126#endif /* _FSL_DISPLAY_H_ */
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/it6263/driver_display-it6263.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/it6263/driver_display-it6263.cmake
new file mode 100644
index 000000000..16f4f3dbc
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/it6263/driver_display-it6263.cmake
@@ -0,0 +1,18 @@
1if(NOT DRIVER_DISPLAY-IT6263_INCLUDED)
2
3 set(DRIVER_DISPLAY-IT6263_INCLUDED true CACHE BOOL "driver_display-it6263 component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 ${CMAKE_CURRENT_LIST_DIR}/fsl_it6263.c
7 )
8
9 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
10 ${CMAKE_CURRENT_LIST_DIR}/.
11 )
12
13
14 include(driver_video-common)
15 include(driver_display-common)
16 include(driver_video-i2c)
17
18endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/it6263/fsl_it6263.c b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/it6263/fsl_it6263.c
new file mode 100644
index 000000000..23e515498
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/it6263/fsl_it6263.c
@@ -0,0 +1,371 @@
1/*
2 * Copyright 2018, 2020 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#include "fsl_video_common.h"
9#include "fsl_display.h"
10#include "fsl_it6263.h"
11
12/*******************************************************************************
13 * Definitions
14 ******************************************************************************/
15#define IT6263_LVDS_ID (0x66U / 2U)
16
17#define IT6263_HDMI_VENDER_ID 0x01ca1376U
18#define IT6263_LVDS_VENDER_ID 0x15ca6162U
19
20#define IT6263_I2C_WriteReg(handle, addr, reg, value) \
21 VIDEO_I2C_WriteReg(addr, kVIDEO_RegAddr8Bit, (reg), kVIDEO_RegWidth8Bit, (value), \
22 ((const it6263_resource_t *)((handle)->resource))->i2cSendFunc)
23
24#define IT6263_I2C_ReadReg(handle, addr, reg, value) \
25 VIDEO_I2C_ReadReg(addr, kVIDEO_RegAddr8Bit, (reg), kVIDEO_RegWidth8Bit, (value), \
26 ((const it6263_resource_t *)((handle)->resource))->i2cReceiveFunc)
27
28#define IT6263_I2C_ModifyReg(handle, addr, reg, mask, value) \
29 VIDEO_I2C_ModifyReg(addr, kVIDEO_RegAddr8Bit, (reg), kVIDEO_RegWidth8Bit, mask, (value), \
30 ((const it6263_resource_t *)((handle)->resource))->i2cReceiveFunc, \
31 ((const it6263_resource_t *)((handle)->resource))->i2cSendFunc)
32
33#define IT6263_I2C_ReadRegs(handle, addr, reg, value, len) \
34 VIDEO_I2C_ReadReg(addr, kVIDEO_RegAddr8Bit, (reg), (video_reg_width_t)len, (value), \
35 ((const it6263_resource_t *)((handle)->resource))->i2cReceiveFunc)
36
37#define IT6263_SET_LVDS_ID_REG 0x1DU
38#define IT6263_ENABLE_LVDS_ID_REG 0x1EU
39
40#define IT6263_HDMI_VENDER_ID_REG 0
41#define IT6263_LVDS_VENDER_ID_REG 0
42
43#define IT6263_LVDS_COLOR_DEPTH(x) ((x) << 0U)
44#define IT6263_LVDS_COLOR_DEPTH_MASK (3U << 0U)
45#define IT6263_LVDS_MAP(x) ((x) << 4U)
46#define IT6263_LVDS_MAP_MASK (1U << 4U)
47#define IT6263_LVDS_DUAL_MODE(x) ((x) << 7U)
48#define IT6263_LVDS_DUAL_MODE_MASK (1U << 7U)
49
50/* Color depth. */
51#define IT6263_LVDS_COLOR_6BIT IT6263_LVDS_COLOR_DEPTH(0U)
52#define IT6263_LVDS_COLOR_8BIT IT6263_LVDS_COLOR_DEPTH(1U)
53#define IT6263_LVDS_COLOR_10BIT IT6263_LVDS_COLOR_DEPTH(2U)
54#define IT6263_LVDS_COLOR_12BIT IT6263_LVDS_COLOR_DEPTH(3U)
55
56/* Pixel map. */
57#define IT6263_LVDS_JEIDA IT6263_LVDS_MAP(0U)
58#define IT6263_LVDS_VESA IT6263_LVDS_MAP(1U)
59
60/* Dual mode. */
61#define IT6263_LVDS_DISO IT6263_LVDS_DUAL_MODE(1U) /* Dual In / Single Out */
62#define IT6263_LVDS_DIRECT IT6263_LVDS_DUAL_MODE(0U) /* Single In / Single Out or Dual In / Dual Out */
63
64/* HDMI register 0x04. */
65#define HDMI_REG_SW_RST 0x04U
66#define IT6263_HDMI_04_SOFTREFRST_MASK (1U << 5U)
67#define IT6263_HDMI_04_SOFTARST_MASK (1U << 4U)
68#define IT6263_HDMI_04_SOFTVRST_MASK (1U << 3U)
69#define IT6263_HDMI_04_AUDRST_MASK (1U << 2U)
70#define IT6263_HDMI_04_HDCPRST_MASK (1U << 0U)
71#define IT6263_HDMI_04_ALLRST_MASK ((1U << 5U) | (1U << 4U) | (1U << 3U) | (1U << 2U) | (1U << 0U))
72
73/* HDMI register 0x61. */
74#define IT6263_HDMI_61_DRV_PWD_MASK (1U << 5U)
75#define IT6263_HDMI_61_DRV_RST_MASK (1U << 4U)
76
77/* HDMI register 0xC1. */
78#define IT6263_HDMI_C1_AVMUTE_MASK (1U << 0U)
79
80/* HDMI register 0xC6. */
81#define IT6263_HDMI_C6_PKTGENCTRLRPT_MASK (1U << 1U)
82#define IT6263_HDMI_C6_PKTGENCTRLEN_MASK (1U << 0U)
83
84/* LVDS register 0x05. */
85#define IT6263_LVDS_05_SOFTREFRST_MASK (1U << 0U)
86#define IT6263_LVDS_05_SOFTRST_MASK (1U << 1U)
87
88#define IT6263_CHECK_RET(x) \
89 do \
90 { \
91 status = (x); \
92 if (kStatus_Success != status) \
93 { \
94 return status; \
95 } \
96 } while (false)
97
98/*******************************************************************************
99 * Variables
100 ******************************************************************************/
101const display_operations_t it6263_ops = {
102 .init = IT6263_Init,
103 .deinit = IT6263_Deinit,
104 .start = IT6263_Start,
105 .stop = IT6263_Stop,
106};
107
108/*******************************************************************************
109 * Code
110 ******************************************************************************/
111
112static void IT6263_HardwareReset(display_handle_t *handle)
113{
114 const it6263_resource_t *resource = (const it6263_resource_t *)(handle->resource);
115
116 resource->pullResetPin(true);
117
118 VIDEO_DelayMs(1);
119
120 resource->pullResetPin(false);
121
122 VIDEO_DelayMs(40);
123
124 resource->pullResetPin(true);
125
126 VIDEO_DelayMs(10);
127}
128
129static status_t IT6263_LVDSReset(display_handle_t *handle)
130{
131 status_t status;
132
133 /* Reset the AFE PLL. */
134 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, IT6263_LVDS_ID, 0x3C, 0x1, 0x0));
135 VIDEO_DelayMs(1);
136 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, IT6263_LVDS_ID, 0x3C, 0x1, 0x1));
137
138 /* Reset the PCLK. */
139 status =
140 IT6263_I2C_ModifyReg(handle, IT6263_LVDS_ID, 0x05, IT6263_LVDS_05_SOFTRST_MASK, IT6263_LVDS_05_SOFTRST_MASK);
141 if (kStatus_Success != status)
142 {
143 return status;
144 }
145
146 VIDEO_DelayMs(1);
147 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, IT6263_LVDS_ID, 0x05, IT6263_LVDS_05_SOFTRST_MASK, 0));
148
149 VIDEO_DelayMs(1);
150
151 return kStatus_Success;
152}
153
154static status_t IT6263_InitLVDS_ID(display_handle_t *handle)
155{
156 status_t status;
157
158 uint8_t i2cAddr = (((const it6263_resource_t *)(handle->resource))->i2cAddr) / 2U;
159
160 status = IT6263_I2C_WriteReg(handle, i2cAddr, IT6263_SET_LVDS_ID_REG, IT6263_LVDS_ID * 2U);
161
162 if (kStatus_Success == status)
163 {
164 status = IT6263_I2C_WriteReg(handle, i2cAddr, IT6263_ENABLE_LVDS_ID_REG, 1);
165 }
166
167 return status;
168}
169
170static status_t IT6263_Identify(display_handle_t *handle)
171{
172 status_t status;
173 uint32_t hdmiVendorID = 0U;
174 uint32_t lvdsVendorID = 0U;
175
176 uint8_t i2cAddr = (((const it6263_resource_t *)(handle->resource))->i2cAddr) / 2U;
177
178 status = IT6263_I2C_ReadRegs(handle, i2cAddr, IT6263_HDMI_VENDER_ID_REG, &hdmiVendorID, sizeof(hdmiVendorID));
179 if (kStatus_Success != status)
180 {
181 return status;
182 }
183
184 status =
185 IT6263_I2C_ReadRegs(handle, IT6263_LVDS_ID, IT6263_LVDS_VENDER_ID_REG, &lvdsVendorID, sizeof(lvdsVendorID));
186 if (kStatus_Success != status)
187 {
188 return status;
189 }
190
191 if ((hdmiVendorID != IT6263_HDMI_VENDER_ID) || (lvdsVendorID != IT6263_LVDS_VENDER_ID))
192 {
193 return kStatus_Fail;
194 }
195 else
196 {
197 return kStatus_Success;
198 }
199}
200
201static status_t IT6263_InitLVDS(display_handle_t *handle)
202{
203 status_t status;
204 uint8_t mask;
205 uint8_t val;
206
207 /* Configure LVDS. */
208 mask = IT6263_LVDS_COLOR_DEPTH_MASK | IT6263_LVDS_MAP_MASK | IT6263_LVDS_DUAL_MODE_MASK;
209 val = IT6263_LVDS_COLOR_8BIT | IT6263_LVDS_JEIDA | IT6263_LVDS_DIRECT;
210
211 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, IT6263_LVDS_ID, 0x2C, mask, val));
212
213 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, IT6263_LVDS_ID, 0x52, 0x02, 0x00));
214
215 /* AFE */
216 IT6263_CHECK_RET(IT6263_I2C_WriteReg(handle, IT6263_LVDS_ID, 0x3E, 0xAA));
217 IT6263_CHECK_RET(IT6263_I2C_WriteReg(handle, IT6263_LVDS_ID, 0x3F, 0x02));
218 IT6263_CHECK_RET(IT6263_I2C_WriteReg(handle, IT6263_LVDS_ID, 0x47, 0xAA));
219 IT6263_CHECK_RET(IT6263_I2C_WriteReg(handle, IT6263_LVDS_ID, 0x48, 0x02));
220 IT6263_CHECK_RET(IT6263_I2C_WriteReg(handle, IT6263_LVDS_ID, 0x4F, 0x11));
221
222 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, IT6263_LVDS_ID, 0x3C, 0x07, 0));
223
224 return kStatus_Success;
225}
226
227status_t IT6263_Init(display_handle_t *handle, const display_config_t *config)
228{
229 assert(handle);
230
231 status_t status;
232
233 uint8_t i2cAddr = ((const it6263_resource_t *)(handle->resource))->i2cAddr / 2U;
234
235 IT6263_HardwareReset(handle);
236
237 /* Software reset. */
238 status = IT6263_I2C_WriteReg(handle, i2cAddr, 0x04, IT6263_HDMI_04_ALLRST_MASK);
239 if (kStatus_Success != status)
240 {
241 return status;
242 }
243
244 VIDEO_DelayMs(1);
245
246 status = IT6263_InitLVDS_ID(handle);
247 if (kStatus_Success != status)
248 {
249 return status;
250 }
251
252 status = IT6263_Identify(handle);
253 if (kStatus_Success != status)
254 {
255 return status;
256 }
257
258 IT6263_CHECK_RET(IT6263_LVDSReset(handle));
259
260 IT6263_CHECK_RET(IT6263_InitLVDS(handle));
261
262 /*
263 * Set color:
264 * 0 RGB
265 * 1 YUV422
266 * 2 YUV444
267 */
268 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, i2cAddr, 0x70, 0x03U << 6U, 0));
269
270 /*
271 * No color space conversion.
272 * 0: No conversion
273 * 1: RGB -> YUV
274 * 2: YUV -> RGB
275 */
276 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, i2cAddr, 0x72, 0x03U << 0U, 0));
277
278 /*
279 * HDMI color dpeth:
280 * 000 - color depth is not indicate (as 8bit)
281 * 100 - 8/8/8 bit color
282 * 101 - 10/10/10 bit color
283 * 110 - 12/12/12 bit color)
284 */
285 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, i2cAddr, 0xC1, 0x07U << 4U, 0x04U << 0U));
286
287 /* Select HDMI. */
288 IT6263_CHECK_RET(IT6263_I2C_WriteReg(handle, i2cAddr, 0xC0, 0x01));
289
290 /* Set AFE */
291 if (config->pixelClock_Hz > 80000000U)
292 {
293 IT6263_CHECK_RET(IT6263_I2C_WriteReg(handle, i2cAddr, 0x62, 0x88));
294 IT6263_CHECK_RET(IT6263_I2C_WriteReg(handle, i2cAddr, 0x64, 0x84));
295 }
296 else
297 {
298 IT6263_CHECK_RET(IT6263_I2C_WriteReg(handle, i2cAddr, 0x62, 0x18));
299 IT6263_CHECK_RET(IT6263_I2C_WriteReg(handle, i2cAddr, 0x64, 0x0C));
300 }
301 IT6263_CHECK_RET(IT6263_I2C_WriteReg(handle, i2cAddr, 0x63, 0x10));
302
303 /*
304 * Output Color Mode
305 * 00 - RGB444 mode
306 * 01 - YCbCr422 mode
307 * 10 - YCbCr444 mode
308 */
309 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, i2cAddr, 0x0F, 0x03U << 0U, 0x01U << 0U)); /* Bank 0 */
310 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, i2cAddr, 0x58, 0x03U << 5U, 0x00U << 5U));
311 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, i2cAddr, 0x0F, 0x03U << 0U, 0x00U << 0U)); /* Bank 1 */
312
313 /* software video reset */
314 status = IT6263_I2C_ModifyReg(handle, i2cAddr, 0x04, IT6263_HDMI_04_SOFTVRST_MASK, IT6263_HDMI_04_SOFTVRST_MASK);
315 if (kStatus_Success != status)
316 {
317 return status;
318 }
319
320 VIDEO_DelayMs(100);
321
322 return kStatus_Success;
323}
324
325status_t IT6263_Deinit(display_handle_t *handle)
326{
327 const it6263_resource_t *resource = (const it6263_resource_t *)(handle->resource);
328
329 resource->pullResetPin(false);
330
331 return kStatus_Success;
332}
333
334status_t IT6263_Start(display_handle_t *handle)
335{
336 status_t status;
337
338 uint8_t i2cAddr = ((const it6263_resource_t *)(handle->resource))->i2cAddr / 2U;
339
340 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, i2cAddr, 0x04, IT6263_HDMI_04_SOFTVRST_MASK, 0));
341 IT6263_CHECK_RET(IT6263_I2C_WriteReg(handle, i2cAddr, 0x61, 0));
342 IT6263_CHECK_RET(IT6263_I2C_ModifyReg(handle, i2cAddr, 0xC1, IT6263_HDMI_C1_AVMUTE_MASK, 0));
343 return IT6263_I2C_WriteReg(handle, i2cAddr, 0xc6,
344 IT6263_HDMI_C6_PKTGENCTRLRPT_MASK | IT6263_HDMI_C6_PKTGENCTRLEN_MASK);
345}
346
347status_t IT6263_Stop(display_handle_t *handle)
348{
349 status_t status;
350 uint8_t i2cAddr = ((const it6263_resource_t *)(handle->resource))->i2cAddr / 2U;
351
352 status = IT6263_I2C_ModifyReg(handle, i2cAddr, 0xC1, IT6263_HDMI_C1_AVMUTE_MASK, IT6263_HDMI_C1_AVMUTE_MASK);
353
354 if (kStatus_Success == status)
355 {
356 status = IT6263_I2C_WriteReg(handle, i2cAddr, 0xC6, 0);
357 }
358
359 if (kStatus_Success == status)
360 {
361 status =
362 IT6263_I2C_ModifyReg(handle, i2cAddr, 0x04, IT6263_HDMI_04_SOFTVRST_MASK, IT6263_HDMI_04_SOFTVRST_MASK);
363 }
364
365 if (kStatus_Success == status)
366 {
367 status = IT6263_I2C_WriteReg(handle, i2cAddr, 0x61, IT6263_HDMI_61_DRV_PWD_MASK | IT6263_HDMI_61_DRV_RST_MASK);
368 }
369
370 return status;
371}
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/it6263/fsl_it6263.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/it6263/fsl_it6263.h
new file mode 100644
index 000000000..d27503965
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/it6263/fsl_it6263.h
@@ -0,0 +1,63 @@
1/*
2 * Copyright 2018, 2020 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#ifndef _FSL_IT6263_H_
9#define _FSL_IT6263_H_
10
11#include "fsl_common.h"
12#include "fsl_video_i2c.h"
13
14/*
15 * Change log:
16 *
17 * 1.0.1
18 * - Fix MISRA-C 2012 issues.
19 *
20 * 1.0.0
21 * - Initial version
22 */
23
24/*******************************************************************************
25 * Definitions
26 ******************************************************************************/
27
28/*!
29 * @brief IT6263 resource.
30 *
31 * The I2C instance should be initialized before calling @ref IT6263_Init.
32 */
33typedef struct _it6263_resource
34{
35 video_i2c_send_func_t i2cSendFunc; /* I2C send function. */
36 video_i2c_receive_func_t i2cReceiveFunc; /* I2C receive function. */
37 void (*pullResetPin)(bool pullUp); /* Function to pull reset pin high or low. */
38 uint8_t i2cAddr; /* I2C address, 0x98 or 0x9A. */
39} it6263_resource_t;
40
41extern const display_operations_t it6263_ops;
42
43/*******************************************************************************
44 * API
45 ******************************************************************************/
46
47#if defined(__cplusplus)
48extern "C" {
49#endif
50
51status_t IT6263_Init(display_handle_t *handle, const display_config_t *config);
52
53status_t IT6263_Deinit(display_handle_t *handle);
54
55status_t IT6263_Start(display_handle_t *handle);
56
57status_t IT6263_Stop(display_handle_t *handle);
58
59#if defined(__cplusplus)
60}
61#endif
62
63#endif /* _FSL_IT6263_H_ */
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/mipi_dsi_cmd/driver_display-mipi-dsi-cmd.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/mipi_dsi_cmd/driver_display-mipi-dsi-cmd.cmake
new file mode 100644
index 000000000..f722fd648
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/mipi_dsi_cmd/driver_display-mipi-dsi-cmd.cmake
@@ -0,0 +1,23 @@
1if(NOT DRIVER_DISPLAY-MIPI-DSI-CMD_INCLUDED)
2
3 set(DRIVER_DISPLAY-MIPI-DSI-CMD_INCLUDED true CACHE BOOL "driver_display-mipi-dsi-cmd component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 ${CMAKE_CURRENT_LIST_DIR}/fsl_mipi_dsi_cmd.c
7 )
8
9 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
10 ${CMAKE_CURRENT_LIST_DIR}/.
11 )
12
13 #OR Logic component
14 if(${MCUX_DEVICE} STREQUAL "MIMX8QM6_cm4_core1")
15 include(driver_mipi_dsi)
16 endif()
17 if(${MCUX_DEVICE} STREQUAL "MIMX8QX6")
18 include(driver_mipi_dsi)
19 endif()
20
21 include(driver_common)
22
23endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/mipi_dsi_cmd/fsl_mipi_dsi_cmd.c b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/mipi_dsi_cmd/fsl_mipi_dsi_cmd.c
new file mode 100644
index 000000000..780b992a3
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/mipi_dsi_cmd/fsl_mipi_dsi_cmd.c
@@ -0,0 +1,273 @@
1/*
2 * Copyright 2017-2020 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#include "fsl_mipi_dsi_cmd.h"
10
11/*******************************************************************************
12 * Definitions
13 ******************************************************************************/
14
15/*******************************************************************************
16 * Variables
17 ******************************************************************************/
18
19/*******************************************************************************
20 * Code
21 ******************************************************************************/
22status_t MIPI_DSI_DCS_SoftReset(mipi_dsi_device_t *device)
23{
24 dsi_transfer_t dsiXfer = {0};
25 uint8_t txData = (uint8_t)kMIPI_DCS_SoftReset;
26
27 dsiXfer.virtualChannel = device->virtualChannel;
28 dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam;
29 dsiXfer.txDataSize = 1;
30 dsiXfer.txData = &txData;
31
32 return device->xferFunc(&dsiXfer);
33}
34
35status_t MIPI_DSI_DCS_SetDisplayOn(mipi_dsi_device_t *device, bool on)
36{
37 dsi_transfer_t dsiXfer = {0};
38 uint8_t txData;
39
40 dsiXfer.virtualChannel = device->virtualChannel;
41 dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam;
42 dsiXfer.txDataSize = 1;
43 dsiXfer.txData = &txData;
44
45 if (on)
46 {
47 txData = (uint8_t)kMIPI_DCS_SetDisplayOn;
48 }
49 else
50 {
51 txData = (uint8_t)kMIPI_DCS_SetDisplayOff;
52 }
53
54 return device->xferFunc(&dsiXfer);
55}
56
57status_t MIPI_DSI_DCS_SetPixelFormat(mipi_dsi_device_t *device,
58 mipi_dsc_pixel_format_t dbiFormat,
59 mipi_dsc_pixel_format_t dpiFormat)
60{
61 dsi_transfer_t dsiXfer = {0};
62 uint8_t txData[2];
63
64 dsiXfer.virtualChannel = device->virtualChannel;
65 dsiXfer.txDataType = kDSI_TxDataDcsShortWrOneParam;
66 dsiXfer.txDataSize = 2;
67 dsiXfer.txData = txData;
68
69 txData[0] = (uint8_t)kMIPI_DCS_SetPixelFormat;
70 txData[1] = ((uint8_t)dbiFormat << 0U) | ((uint8_t)dpiFormat << 4U);
71
72 return device->xferFunc(&dsiXfer);
73}
74
75status_t MIPI_DSI_DCS_EnterSleepMode(mipi_dsi_device_t *device, bool enter)
76{
77 dsi_transfer_t dsiXfer = {0};
78 uint8_t txData;
79
80 dsiXfer.virtualChannel = device->virtualChannel;
81 dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam;
82 dsiXfer.txDataSize = 1;
83 dsiXfer.txData = &txData;
84
85 if (enter)
86 {
87 txData = (uint8_t)kMIPI_DCS_EnterSleepMode;
88 }
89 else
90 {
91 txData = (uint8_t)kMIPI_DCS_ExitSleepMode;
92 }
93
94 return device->xferFunc(&dsiXfer);
95}
96
97status_t MIPI_DSI_DCS_EnterPartialMode(mipi_dsi_device_t *device, bool enter)
98{
99 dsi_transfer_t dsiXfer = {0};
100 uint8_t txData;
101
102 dsiXfer.virtualChannel = device->virtualChannel;
103 dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam;
104 dsiXfer.txDataSize = 1;
105 dsiXfer.txData = &txData;
106
107 if (enter)
108 {
109 txData = (uint8_t)kMIPI_DCS_EnterPartialMode;
110 }
111 else
112 {
113 txData = (uint8_t)kMIPI_DCS_EnterNormalMode;
114 }
115
116 return device->xferFunc(&dsiXfer);
117}
118
119status_t MIPI_DSI_DCS_EnterInvertMode(mipi_dsi_device_t *device, bool enter)
120{
121 dsi_transfer_t dsiXfer = {0};
122 uint8_t txData;
123
124 dsiXfer.virtualChannel = device->virtualChannel;
125 dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam;
126 dsiXfer.txDataSize = 1;
127 dsiXfer.txData = &txData;
128
129 if (enter)
130 {
131 txData = (uint8_t)kMIPI_DCS_EnterInvertMode;
132 }
133 else
134 {
135 txData = (uint8_t)kMIPI_DCS_ExitInvertMode;
136 }
137
138 return device->xferFunc(&dsiXfer);
139}
140
141status_t MIPI_DSI_DCS_EnterIdleMode(mipi_dsi_device_t *device, bool enter)
142{
143 dsi_transfer_t dsiXfer = {0};
144 uint8_t txData;
145
146 dsiXfer.virtualChannel = device->virtualChannel;
147 dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam;
148 dsiXfer.txDataSize = 1;
149 dsiXfer.txData = &txData;
150
151 if (enter)
152 {
153 txData = (uint8_t)kMIPI_DCS_EnterIdleMode;
154 }
155 else
156 {
157 txData = (uint8_t)kMIPI_DCS_ExitIdleMode;
158 }
159
160 return device->xferFunc(&dsiXfer);
161}
162
163status_t MIPI_DSI_DCS_Write(mipi_dsi_device_t *device, const uint8_t *txData, int32_t txDataSize)
164{
165 dsi_transfer_t dsiXfer = {0};
166
167 dsiXfer.virtualChannel = device->virtualChannel;
168 dsiXfer.txDataSize = (uint16_t)txDataSize;
169 dsiXfer.txData = txData;
170
171 if (0 == txDataSize)
172 {
173 /* For DSC command, the data size should not be 0. */
174 return kStatus_InvalidArgument;
175 }
176 else if (1 == txDataSize)
177 {
178 dsiXfer.txDataType = kDSI_TxDataDcsShortWrNoParam;
179 }
180 else if (2 == txDataSize)
181 {
182 dsiXfer.txDataType = kDSI_TxDataDcsShortWrOneParam;
183 }
184 else
185 {
186 dsiXfer.txDataType = kDSI_TxDataDcsLongWr;
187 }
188
189 return device->xferFunc(&dsiXfer);
190}
191
192status_t MIPI_DSI_GenericWrite(mipi_dsi_device_t *device, const uint8_t *txData, int32_t txDataSize)
193{
194 dsi_transfer_t dsiXfer = {0};
195
196 dsiXfer.virtualChannel = device->virtualChannel;
197 dsiXfer.txDataSize = (uint16_t)txDataSize;
198 dsiXfer.txData = txData;
199
200 if (0 == txDataSize)
201 {
202 dsiXfer.txDataType = kDSI_TxDataGenShortWrNoParam;
203 }
204 else if (1 == txDataSize)
205 {
206 dsiXfer.txDataType = kDSI_TxDataGenShortWrOneParam;
207 }
208 else if (2 == txDataSize)
209 {
210 dsiXfer.txDataType = kDSI_TxDataGenShortWrTwoParam;
211 }
212 else
213 {
214 dsiXfer.txDataType = kDSI_TxDataGenLongWr;
215 }
216
217 return device->xferFunc(&dsiXfer);
218}
219
220status_t MIPI_DSI_SelectArea(mipi_dsi_device_t *device, uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY)
221{
222 status_t status;
223 dsi_transfer_t dsiXfer = {0};
224 uint8_t txData[4];
225
226 dsiXfer.virtualChannel = device->virtualChannel;
227 dsiXfer.txDataType = kDSI_TxDataDcsLongWr;
228 dsiXfer.txDataSize = 4;
229 dsiXfer.txData = txData;
230 dsiXfer.sendDscCmd = true;
231 dsiXfer.dscCmd = (uint8_t)kMIPI_DCS_SetColumnAddress;
232
233 txData[0] = (uint8_t)((startX >> 8U) & 0xFFU);
234 txData[1] = (uint8_t)(startX & 0xFFU);
235 txData[2] = (uint8_t)((endX >> 8U) & 0xFFU);
236 txData[3] = (uint8_t)(endX & 0xFFU);
237
238 status = device->xferFunc(&dsiXfer);
239
240 if (kStatus_Success != status)
241 {
242 return status;
243 }
244
245 dsiXfer.dscCmd = (uint8_t)kMIPI_DCS_SetPageAddress;
246 txData[0] = (uint8_t)((startY >> 8U) & 0xFFU);
247 txData[1] = (uint8_t)(startY & 0xFFU);
248 txData[2] = (uint8_t)((endY >> 8U) & 0xFFU);
249 txData[3] = (uint8_t)(endY & 0xFFU);
250
251 return device->xferFunc(&dsiXfer);
252}
253
254status_t MIPI_DSI_WriteMemory(mipi_dsi_device_t *device, const uint8_t *data, uint32_t length)
255{
256 return device->memWriteFunc(device->virtualChannel, data, length);
257}
258
259void MIPI_DSI_SetMemoryDoneCallback(mipi_dsi_device_t *device, mipi_dsi_mem_done_callback_t callback, void *userData)
260{
261 device->callback = callback;
262 device->userData = userData;
263}
264
265void MIPI_DSI_MemoryDoneDriverCallback(status_t status, void *userData)
266{
267 mipi_dsi_device_t *device = (mipi_dsi_device_t *)userData;
268
269 if (NULL != device->callback)
270 {
271 device->callback(status, device->userData);
272 }
273}
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/mipi_dsi_cmd/fsl_mipi_dsi_cmd.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/mipi_dsi_cmd/fsl_mipi_dsi_cmd.h
new file mode 100644
index 000000000..3cef6211a
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/mipi_dsi_cmd/fsl_mipi_dsi_cmd.h
@@ -0,0 +1,278 @@
1/*
2 * Copyright 2017-2020 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_MIPI_DSI_CMD_H_
10#define _FSL_MIPI_DSI_CMD_H_
11
12#include "fsl_common.h"
13#include "fsl_mipi_dsi.h"
14
15/*
16 * Change log:
17 *
18 * 1.0.2
19 * - Fix MISRA-C 2012 issues.
20 *
21 * 1.0.1
22 * - Add more functions for panel works in command mode.
23 *
24 * 1.0.0
25 * - Initial version
26 */
27
28/*******************************************************************************
29 * Definitions
30 ******************************************************************************/
31
32enum _mipi_dsc
33{
34 kMIPI_DCS_Nop = 0x00,
35 kMIPI_DCS_SoftReset = 0x01,
36 kMIPI_DCS_GetRedChannel = 0x06,
37 kMIPI_DCS_GetGreenChannel = 0x07,
38 kMIPI_DCS_GetBlueChannel = 0x08,
39 kMIPI_DCS_GetPowerMode = 0x0A,
40 kMIPI_DCS_GetAddressMode = 0x0B,
41 kMIPI_DCS_GetPixelFormat = 0x0C,
42 kMIPI_DCS_GetDisplayMode = 0x0D,
43 kMIPI_DCS_GetSignalMode = 0x0E,
44 kMIPI_DCS_GetDiagnosticResult = 0x0F,
45 kMIPI_DCS_EnterSleepMode = 0x10,
46 kMIPI_DCS_ExitSleepMode = 0x11,
47 kMIPI_DCS_EnterPartialMode = 0x12,
48 kMIPI_DCS_EnterNormalMode = 0x13,
49 kMIPI_DCS_ExitInvertMode = 0x20,
50 kMIPI_DCS_EnterInvertMode = 0x21,
51 kMIPI_DCS_SetGammaCurve = 0x26,
52 kMIPI_DCS_SetDisplayOff = 0x28,
53 kMIPI_DCS_SetDisplayOn = 0x29,
54 kMIPI_DCS_SetColumnAddress = 0x2a,
55 kMIPI_DCS_SetPageAddress = 0x2b,
56 kMIPI_DCS_WriteMemoryStart = 0x2C,
57 kMIPI_DCS_WriteLUT = 0x2D,
58 kMIPI_DCS_ReadMemoryStart = 0x2E,
59 kMIPI_DCS_SetPartialRows = 0x30,
60 kMIPI_DCS_SetPartialColumns = 0x31,
61 kMIPI_DCS_SetScrollArea = 0x33,
62 kMIPI_DCS_SetTearOff = 0x34,
63 kMIPI_DCS_SetTearOn = 0x35,
64 kMIPI_DCS_SetAddressMode = 0x36,
65 kMIPI_DCS_SetScrollStart = 0x37,
66 kMIPI_DCS_ExitIdleMode = 0x38,
67 kMIPI_DCS_EnterIdleMode = 0x39,
68 kMIPI_DCS_SetPixelFormat = 0x3A,
69 kMIPI_DCS_WriteMemoryContinue = 0x3C,
70 kMIPI_DCS_Set3DControl = 0x3D,
71 kMIPI_DCS_ReadMemoryContinue = 0x3E,
72 kMIPI_DCS_Get3DControl = 0x3F,
73 kMIPI_DCS_SetVsyncTiming = 0x40,
74 kMIPI_DCS_SetTearScanline = 0x44,
75 kMIPI_DCS_GetScanline = 0x45,
76 kMIPI_DCS_SetDisplayBrightness = 0x51,
77 kMIPI_DCS_GetDisplayBrightness = 0x52,
78 kMIPI_DCS_WriteControlDisplay = 0x53,
79 kMIPI_DCS_GetControlDisplay = 0x54,
80 kMIPI_DCS_WritePowerSave = 0x55,
81 kMIPI_DCS_GetPowerSave = 0x56,
82 kMIPI_DCS_SetCABCMinBrightness = 0x5E,
83 kMIPI_DCS_GetCABCMinBrightness = 0x5F,
84 kMIPI_DCS_ReadDDBStart = 0xA1,
85 kMIPI_DCS_ReadDDBContinue = 0xA8,
86};
87
88/*!
89 * @brief Pixel format used by DSC command.
90 */
91typedef enum _mipi_dsc_pixel_format
92{
93 kMIPI_DCS_Pixel3Bits = 1U, /*!< 3-bit per pixel. */
94 kMIPI_DCS_Pixel8Bits = 2U, /*!< 8-bit per pixel. */
95 kMIPI_DCS_Pixel12Bits = 3U, /*!< 12-bit per pixel. */
96 kMIPI_DCS_Pixel16Bits = 5U, /*!< 16-bit per pixel. */
97 kMIPI_DCS_Pixel18Bits = 6U, /*!< 18-bit per pixel. */
98 kMIPI_DCS_Pixel24Bits = 7U, /*!< 24-bit per pixel. */
99} mipi_dsc_pixel_format_t;
100
101/*!
102 * @brief Callback function when the write memory finished.
103 *
104 * If transfer done successfully, the @p status is kStatus_Success.
105 */
106typedef void (*mipi_dsi_mem_done_callback_t)(status_t status, void *userData);
107
108/*! @brief MIPI DSI transfer function. */
109typedef status_t (*mipi_dsi_transfer_func_t)(dsi_transfer_t *xfer);
110
111/*! @brief MIPI DSI memory write function. */
112typedef status_t (*mipi_dsi_mem_write_func_t)(uint8_t virtualChannel, const uint8_t *data, uint32_t length);
113
114/*! @brief MIPI DSI device. */
115typedef struct _mipi_dsi_device
116{
117 uint8_t virtualChannel;
118 mipi_dsi_transfer_func_t xferFunc;
119 mipi_dsi_mem_write_func_t memWriteFunc; /*!< Function to write display memory,
120 it should be non-blocking function and
121 notify upper layer using callback when finished.
122 Not used when panel works in video mode. */
123 mipi_dsi_mem_done_callback_t callback; /*!< The callback function to notify upper layer
124 that memory write done. Not used when panel
125 works in video mode. */
126 void *userData; /*!< Parameter for the memory write done callback.
127 not used when panel works in video mode. */
128} mipi_dsi_device_t;
129
130/*******************************************************************************
131 * API
132 ******************************************************************************/
133
134#if defined(__cplusplus)
135extern "C" {
136#endif
137
138/*!
139 * @brief Send software reset to MIPI DSI device.
140 *
141 * @param device The MIPI DSI device.
142 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
143 */
144status_t MIPI_DSI_DCS_SoftReset(mipi_dsi_device_t *device);
145
146/*!
147 * @brief Set display on or off.
148 *
149 * @param device The MIPI DSI device.
150 * @param on Set true to turn on, false to turn off.
151 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
152 */
153status_t MIPI_DSI_DCS_SetDisplayOn(mipi_dsi_device_t *device, bool on);
154
155/*!
156 * @brief Enter or exit sleep mode.
157 *
158 * @param device The MIPI DSI device.
159 * @param enter Set true to enter sleep mode, false to exit.
160 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
161 */
162status_t MIPI_DSI_DCS_EnterSleepMode(mipi_dsi_device_t *device, bool enter);
163
164/*!
165 * @brief Enter or exit partial mode.
166 *
167 * @param device The MIPI DSI device.
168 * @param enter Set true to enter partial mode, false to exit.
169 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
170 */
171status_t MIPI_DSI_DCS_EnterPartialMode(mipi_dsi_device_t *device, bool enter);
172
173/*!
174 * @brief Enter or exit invert mode.
175 *
176 * @param device The MIPI DSI device.
177 * @param enter Set true to enter invert mode, false to exit.
178 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
179 */
180status_t MIPI_DSI_DCS_EnterInvertMode(mipi_dsi_device_t *device, bool enter);
181
182/*!
183 * @brief Enter or exit idle mode.
184 *
185 * @param device The MIPI DSI device.
186 * @param enter Set true to enter idle mode, false to exit.
187 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
188 */
189status_t MIPI_DSI_DCS_EnterIdleMode(mipi_dsi_device_t *device, bool enter);
190
191/*!
192 * @brief Send DCS command.
193 *
194 * @param device The MIPI DSI device.
195 * @param txData The data to send.
196 * @param txDataSize Size of the data to send (in bytes).
197 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
198 */
199status_t MIPI_DSI_DCS_Write(mipi_dsi_device_t *device, const uint8_t *txData, int32_t txDataSize);
200
201/*!
202 * @brief Send generic data.
203 *
204 * @param device The MIPI DSI device.
205 * @param txData The data to send.
206 * @param txDataSize Size of the data to send (in bytes).
207 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
208 */
209status_t MIPI_DSI_GenericWrite(mipi_dsi_device_t *device, const uint8_t *txData, int32_t txDataSize);
210
211/*!
212 * @brief Set the panel pixel format.
213 *
214 * @param device The MIPI DSI device.
215 * @param dbiFormat The DBI interface pixel format.
216 * @param dpiFormat The DPI interface pixel format.
217 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
218 */
219status_t MIPI_DSI_DCS_SetPixelFormat(mipi_dsi_device_t *device,
220 mipi_dsc_pixel_format_t dbiFormat,
221 mipi_dsc_pixel_format_t dpiFormat);
222
223/*!
224 * @brief Select area to write or read pixels.
225 *
226 * @param device The MIPI DSI device.
227 * @param startX Start point X coordination.
228 * @param startY Start point Y coordination.
229 * @param endX End point X coordination.
230 * @param endY End point Y coordination.
231 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
232 */
233status_t MIPI_DSI_SelectArea(mipi_dsi_device_t *device, uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY);
234
235/*!
236 * @brief Send pixel data to the display controller's frame memory.
237 *
238 * The pixels will be shown in the region selected by @ref MIPI_DSI_SelectArea.
239 * This function is non-blocking function, user should install callback function
240 * using @ref MIPI_DSI_SetMemoryDoneCallback to get informed when write finished.
241 *
242 * @param device The MIPI DSI device.
243 * @param data The pixel data to send.
244 * @param length Length of the data in byte.
245 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
246 */
247status_t MIPI_DSI_WriteMemory(mipi_dsi_device_t *device, const uint8_t *data, uint32_t length);
248
249/*!
250 * @brief Install the callback called when write memory finished.
251 *
252 * Upper layer should install callback function using this function to
253 * get memory write done notification.
254 *
255 * @param device The MIPI DSI device.
256 * @param callback The callback function to inform upper layer that memory write done.
257 * @param userData Parameter used by the callback.
258 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
259 */
260void MIPI_DSI_SetMemoryDoneCallback(mipi_dsi_device_t *device, mipi_dsi_mem_done_callback_t callback, void *userData);
261
262/*!
263 * @brief The callback function lower layer should call when write memory finished.
264 *
265 * When implement the @ref mipi_dsi_device_t, this function should be called when
266 * the memory writing finished. The parameter @p userData should be pointer to the
267 * @ref mipi_dsi_device_t.
268 *
269 * @param status The memory writing result. @ref kStatus_Success if success.
270 * @param userData Must be pointer to the @ref mipi_dsi_device_t instance.
271 */
272void MIPI_DSI_MemoryDoneDriverCallback(status_t status, void *userData);
273
274#if defined(__cplusplus)
275}
276#endif
277
278#endif /* _FSL_MIPI_DSI_CMD_H_ */
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/rm67191/driver_display-rm67191.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/rm67191/driver_display-rm67191.cmake
new file mode 100644
index 000000000..4c0d9ec5a
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/rm67191/driver_display-rm67191.cmake
@@ -0,0 +1,17 @@
1if(NOT DRIVER_DISPLAY-RM67191_INCLUDED)
2
3 set(DRIVER_DISPLAY-RM67191_INCLUDED true CACHE BOOL "driver_display-rm67191 component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 ${CMAKE_CURRENT_LIST_DIR}/fsl_rm67191.c
7 )
8
9 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
10 ${CMAKE_CURRENT_LIST_DIR}/.
11 )
12
13
14 include(driver_display-mipi-dsi-cmd)
15 include(driver_display-common)
16
17endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/rm67191/fsl_rm67191.c b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/rm67191/fsl_rm67191.c
new file mode 100644
index 000000000..6e87db96a
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/rm67191/fsl_rm67191.c
@@ -0,0 +1,167 @@
1/*
2 * Copyright 2017, 2020 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#include "fsl_display.h"
10#include "fsl_rm67191.h"
11
12/*******************************************************************************
13 * Definitions
14 ******************************************************************************/
15#define RM67191_DelayMs VIDEO_DelayMs
16
17/*******************************************************************************
18 * Variables
19 ******************************************************************************/
20static const uint8_t lcmInitSetting[][2] = {
21 {0xFE, 0x0B}, {0x28, 0x40}, {0x29, 0x4F}, {0xFE, 0x0E}, {0x4B, 0x00}, {0x4C, 0x0F}, {0x4D, 0x20}, {0x4E, 0x40},
22 {0x4F, 0x60}, {0x50, 0xA0}, {0x51, 0xC0}, {0x52, 0xE0}, {0x53, 0xFF}, {0xFE, 0x0D}, {0x18, 0x08}, {0x42, 0x00},
23 {0x08, 0x41}, {0x46, 0x02}, {0x72, 0x09}, {0xFE, 0x0A}, {0x24, 0x17}, {0x04, 0x07}, {0x1A, 0x0C}, {0x0F, 0x44},
24 {0xFE, 0x04}, {0x00, 0x0C}, {0x05, 0x08}, {0x06, 0x08}, {0x08, 0x08}, {0x09, 0x08}, {0x0A, 0xE6}, {0x0B, 0x8C},
25 {0x1A, 0x12}, {0x1E, 0xE0}, {0x29, 0x93}, {0x2A, 0x93}, {0x2F, 0x02}, {0x31, 0x02}, {0x33, 0x05}, {0x37, 0x2D},
26 {0x38, 0x2D}, {0x3A, 0x1E}, {0x3B, 0x1E}, {0x3D, 0x27}, {0x3F, 0x80}, {0x40, 0x40}, {0x41, 0xE0}, {0x4F, 0x2F},
27 {0x50, 0x1E}, {0xFE, 0x06}, {0x00, 0xCC}, {0x05, 0x05}, {0x07, 0xA2}, {0x08, 0xCC}, {0x0D, 0x03}, {0x0F, 0xA2},
28 {0x32, 0xCC}, {0x37, 0x05}, {0x39, 0x83}, {0x3A, 0xCC}, {0x41, 0x04}, {0x43, 0x83}, {0x44, 0xCC}, {0x49, 0x05},
29 {0x4B, 0xA2}, {0x4C, 0xCC}, {0x51, 0x03}, {0x53, 0xA2}, {0x75, 0xCC}, {0x7A, 0x03}, {0x7C, 0x83}, {0x7D, 0xCC},
30 {0x82, 0x02}, {0x84, 0x83}, {0x85, 0xEC}, {0x86, 0x0F}, {0x87, 0xFF}, {0x88, 0x00}, {0x8A, 0x02}, {0x8C, 0xA2},
31 {0x8D, 0xEA}, {0x8E, 0x01}, {0x8F, 0xE8}, {0xFE, 0x06}, {0x90, 0x0A}, {0x92, 0x06}, {0x93, 0xA0}, {0x94, 0xA8},
32 {0x95, 0xEC}, {0x96, 0x0F}, {0x97, 0xFF}, {0x98, 0x00}, {0x9A, 0x02}, {0x9C, 0xA2}, {0xAC, 0x04}, {0xFE, 0x06},
33 {0xB1, 0x12}, {0xB2, 0x17}, {0xB3, 0x17}, {0xB4, 0x17}, {0xB5, 0x17}, {0xB6, 0x11}, {0xB7, 0x08}, {0xB8, 0x09},
34 {0xB9, 0x06}, {0xBA, 0x07}, {0xBB, 0x17}, {0xBC, 0x17}, {0xBD, 0x17}, {0xBE, 0x17}, {0xBF, 0x17}, {0xC0, 0x17},
35 {0xC1, 0x17}, {0xC2, 0x17}, {0xC3, 0x17}, {0xC4, 0x0F}, {0xC5, 0x0E}, {0xC6, 0x00}, {0xC7, 0x01}, {0xC8, 0x10},
36 {0xFE, 0x0D}, {0x95, 0xEC}, {0x8D, 0xEE}, {0x44, 0xEC}, {0x4C, 0xEC}, {0x32, 0xEC}, {0x3A, 0xEC}, {0x7D, 0xEC},
37 {0x75, 0xEC}, {0x00, 0xEC}, {0x08, 0xEC}, {0x85, 0xEC}, {0xA6, 0x21}, {0xA7, 0x05}, {0xA9, 0x06}, {0x82, 0x06},
38 {0x41, 0x06}, {0x7A, 0x07}, {0x37, 0x07}, {0x05, 0x06}, {0x49, 0x06}, {0x0D, 0x04}, {0x51, 0x04},
39};
40
41const display_operations_t rm67191_ops = {
42 .init = RM67191_Init,
43 .deinit = RM67191_Deinit,
44 .start = RM67191_Start,
45 .stop = RM67191_Stop,
46};
47
48/*******************************************************************************
49 * Code
50 ******************************************************************************/
51
52status_t RM67191_Init(display_handle_t *handle, const display_config_t *config)
53{
54 uint32_t i;
55 status_t status = kStatus_Success;
56 const rm67191_resource_t *resource = (const rm67191_resource_t *)(handle->resource);
57 mipi_dsi_device_t *dsiDevice = resource->dsiDevice;
58
59 /* Perform reset. */
60 resource->pullResetPin(true);
61
62 RM67191_DelayMs(10);
63
64 resource->pullResetPin(false);
65
66 RM67191_DelayMs(5);
67
68 resource->pullResetPin(true);
69 RM67191_DelayMs(20);
70
71 /* Set the LCM init settings. */
72 for (i = 0; i < ARRAY_SIZE(lcmInitSetting); i++)
73 {
74 status = MIPI_DSI_GenericWrite(dsiDevice, lcmInitSetting[i], 2);
75
76 if (kStatus_Success != status)
77 {
78 return status;
79 }
80 }
81
82 /* Change to send user command. */
83 const uint8_t rm67191UserCmdEntry[] = {RM67191_WRMAUCCTR, 0x00};
84 status = MIPI_DSI_GenericWrite(dsiDevice, rm67191UserCmdEntry, (int32_t)ARRAY_SIZE(rm67191UserCmdEntry));
85 if (kStatus_Success != status)
86 {
87 return status;
88 }
89
90 /* Software reset */
91 status = MIPI_DSI_DCS_SoftReset(dsiDevice);
92 if (kStatus_Success != status)
93 {
94 return status;
95 }
96
97 RM67191_DelayMs(100);
98
99 /* Set DSI mode */
100 const uint8_t rm67191DsiMode[] = {RM67191_SETDSIMODE, 0x03};
101 status = MIPI_DSI_GenericWrite(dsiDevice, rm67191DsiMode, (int32_t)ARRAY_SIZE(rm67191DsiMode));
102 if (kStatus_Success != status)
103 {
104 return status;
105 }
106
107 /* Brightness. */
108 const uint8_t rm67191Brightness[] = {RM67191_WRDISBV, 0xff};
109 status = MIPI_DSI_GenericWrite(dsiDevice, rm67191Brightness, (int32_t)ARRAY_SIZE(rm67191Brightness));
110 if (kStatus_Success != status)
111 {
112 return status;
113 }
114
115 /* Exit sleep mode */
116 status = MIPI_DSI_DCS_EnterSleepMode(dsiDevice, false);
117 if (kStatus_Success != status)
118 {
119 return status;
120 }
121
122 RM67191_DelayMs(120);
123
124 /* Set display on. */
125 status = MIPI_DSI_DCS_SetDisplayOn(dsiDevice, true);
126 if (kStatus_Success != status)
127 {
128 return status;
129 }
130
131 RM67191_DelayMs(100);
132
133 return kStatus_Success;
134}
135
136status_t RM67191_Deinit(display_handle_t *handle)
137{
138 status_t status;
139 const rm67191_resource_t *resource = (const rm67191_resource_t *)(handle->resource);
140 mipi_dsi_device_t *dsiDevice = resource->dsiDevice;
141
142 status = MIPI_DSI_DCS_EnterSleepMode(dsiDevice, true);
143 if (kStatus_Success != status)
144 {
145 return status;
146 }
147
148 resource->pullResetPin(false);
149
150 return kStatus_Success;
151}
152
153status_t RM67191_Start(display_handle_t *handle)
154{
155 const rm67191_resource_t *resource = (const rm67191_resource_t *)(handle->resource);
156 mipi_dsi_device_t *dsiDevice = resource->dsiDevice;
157
158 return MIPI_DSI_DCS_SetDisplayOn(dsiDevice, true);
159}
160
161status_t RM67191_Stop(display_handle_t *handle)
162{
163 const rm67191_resource_t *resource = (const rm67191_resource_t *)(handle->resource);
164 mipi_dsi_device_t *dsiDevice = resource->dsiDevice;
165
166 return MIPI_DSI_DCS_SetDisplayOn(dsiDevice, false);
167}
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/display/rm67191/fsl_rm67191.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/rm67191/fsl_rm67191.h
new file mode 100644
index 000000000..ccc928186
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/display/rm67191/fsl_rm67191.h
@@ -0,0 +1,120 @@
1/*
2 * Copyright 2017, 2020 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_RM67191_H_
10#define _FSL_RM67191_H_
11
12#include "fsl_display.h"
13#include "fsl_mipi_dsi_cmd.h"
14
15/*
16 * Change log:
17 *
18 * 1.1.0
19 * - Fix MISRA-C 2012 issues.
20 * - Change rm67191_resource_t structure.
21 *
22 * 1.0.0
23 * - Initial version
24 */
25
26/*******************************************************************************
27 * Definitions
28 ******************************************************************************/
29#define RM67191_NOP (0x00)
30#define RM67191_SWRESET (0x01)
31#define RM67191_RDDID (0x04)
32#define RM67191_RDNUMED (0x05)
33#define RM67191_RDDPM (0x0A)
34#define RM67191_RDDMADCTR (0x0B)
35#define RM67191_RDDCOLMOD (0x0C)
36#define RM67191_RDDIM (0x0D)
37#define RM67191_RDDSM (0x0E)
38#define RM67191_RDDSDR (0x0F)
39#define RM67191_SLPIN (0x10)
40#define RM67191_SLPOUT (0x11)
41#define RM67191_INVOFF (0x20)
42#define RM67191_INVON (0x21)
43#define RM67191_ALLPOFF (0x22)
44#define RM67191_ALLPON (0x23)
45#define RM67191_DISPOFF (0x28)
46#define RM67191_DISPON (0x29)
47#define RM67191_RAMWR (0x2C)
48#define RM67191_TEOFF (0x34)
49#define RM67191_TEON (0x35)
50#define RM67191_MADCTR (0x36)
51#define RM67191_IDMOFF (0x38)
52#define RM67191_IDMON (0x39)
53#define RM67191_COLMOD (0x3A)
54#define RM67191_RAMWRC (0x3C)
55#define RM67191_STES (0x44)
56#define RM67191_GSL (0x45)
57#define RM67191_DSTBON (0x4F)
58#define RM67191_WRDISBV (0x51)
59#define RM67191_RDDISBV (0x52)
60#define RM67191_WRCTRLD (0x53)
61#define RM67191_RDCTRLD (0x54)
62#define RM67191_WRRADACL (0x55)
63#define RM67191_RDRADACL (0x56)
64#define RM67191_WRCE (0x58)
65#define RM67191_RDCE (0x59)
66#define RM67191_WRCE1 (0x5A)
67#define RM67191_RDCE1 (0x5B)
68#define RM67191_WRCE2 (0x5C)
69#define RM67191_RDCE2 (0x5D)
70#define RM67191_WRTMR (0x62)
71#define RM67191_RDTMR (0x63)
72#define RM67191_WRPA (0x64)
73#define RM67191_RDPA (0x65)
74#define RM67191_WRWB (0x66)
75#define RM67191_RDWB (0x67)
76#define RM67191_WRCEMODE (0x68)
77#define RM67191_RDCEMODE (0x69)
78#define RM67191_RDDDBS (0xA1)
79#define RM67191_RDDDBC (0xA8)
80#define RM67191_RDFC (0xAA)
81#define RM67191_RDCC (0xAF)
82#define RM67191_SETDSIMODE (0xC2)
83#define RM67191_RDCTRLD1 (0xDA)
84#define RM67191_RDCTRLD2 (0xDB)
85#define RM67191_RDCTRLD3 (0xDC)
86#define RM67191_WRMAUCCTR (0xFE)
87#define RM67191_RDMAUCCTR (0xFF)
88
89/*!
90 * @brief RM67191 resource.
91 */
92typedef struct _rm67191_resource
93{
94 mipi_dsi_device_t *dsiDevice; /*!< MIPI DSI device. */
95 void (*pullResetPin)(bool pullUp); /*!< Function to pull reset pin high or low. */
96} rm67191_resource_t;
97
98extern const display_operations_t rm67191_ops;
99
100/*******************************************************************************
101 * API
102 ******************************************************************************/
103
104#if defined(__cplusplus)
105extern "C" {
106#endif
107
108status_t RM67191_Init(display_handle_t *handle, const display_config_t *config);
109
110status_t RM67191_Deinit(display_handle_t *handle);
111
112status_t RM67191_Start(display_handle_t *handle);
113
114status_t RM67191_Stop(display_handle_t *handle);
115
116#if defined(__cplusplus)
117}
118#endif
119
120#endif /* _FSL_RM67191_H_ */