display_support.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * Copyright 2019-2021, 2023 NXP
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef _DISPLAY_SUPPORT_H_
  8. #define _DISPLAY_SUPPORT_H_
  9. #include <rtthread.h>
  10. #include "fsl_dc_fb.h"
  11. #if defined(DISPLAY_USING_RK055AHD091)
  12. #include "fsl_rm68200.h"
  13. #elif defined(DISPLAY_USING_RK055IQH091)
  14. #include "fsl_rm68191.h"
  15. #elif defined(DISPLAY_USING_RK055MHD091)
  16. #include "fsl_hx8394.h"
  17. #else
  18. #error "Please config lcd panel parameters."
  19. #endif
  20. #include "pin_mux.h"
  21. #include "board.h"
  22. #if defined(BSP_USING_LCDIFV2)
  23. #include "fsl_dc_fb_lcdifv2.h"
  24. #elif defined(BSP_USING_ELCDIF)
  25. #include "fsl_dc_fb_elcdif.h"
  26. #endif
  27. /*******************************************************************************
  28. * Definitions
  29. ******************************************************************************/
  30. /* @TEST_ANCHOR */
  31. #define DEMO_BUFFER_FIXED_ADDRESS 0
  32. #if DEMO_BUFFER_FIXED_ADDRESS
  33. #define DEMO_BUFFER0_ADDR 0x80000000
  34. #define DEMO_BUFFER1_ADDR 0x80200000
  35. #endif
  36. /*
  37. * Use the MIPI dumb panel
  38. */
  39. /* Definitions for the frame buffer. */
  40. #define DEMO_BUFFER_COUNT 2 /* 2 is enough for DPI interface display. */
  41. #ifndef DEMO_USE_XRGB8888
  42. #define DEMO_USE_XRGB8888 0
  43. #endif
  44. /* Use LCDIF LUT (or named color palette) which is 8-bit per-pixel */
  45. #ifndef DEMO_USE_LUT8
  46. #define DEMO_USE_LUT8 0
  47. #endif
  48. #if DEMO_USE_XRGB8888
  49. #define DEMO_BUFFER_PIXEL_FORMAT kVIDEO_PixelFormatXRGB8888
  50. #define DEMO_BUFFER_BYTE_PER_PIXEL 4
  51. #elif DEMO_USE_LUT8
  52. #define DEMO_BUFFER_PIXEL_FORMAT kVIDEO_PixelFormatLUT8
  53. #define DEMO_BUFFER_BYTE_PER_PIXEL 1
  54. #else
  55. #define DEMO_BUFFER_PIXEL_FORMAT kVIDEO_PixelFormatRGB565
  56. #define DEMO_BUFFER_BYTE_PER_PIXEL 2
  57. #endif
  58. #if (defined(DISPLAY_USING_RK055AHD091) || defined(DISPLAY_USING_RK055MHD091))
  59. #define LCD_MIPI_WIDTH (720)
  60. #define LCD_MIPI_HEIGHT (1280)
  61. #elif defined(DISPLAY_USING_RK055IQH091)
  62. #define LCD_MIPI_WIDTH (540)
  63. #define LCD_MIPI_HEIGHT (960)
  64. #endif
  65. #define DEMO_BUFFER_WIDTH LCD_MIPI_WIDTH
  66. #define DEMO_BUFFER_HEIGHT LCD_MIPI_HEIGHT
  67. /* Where the frame buffer is shown in the screen. */
  68. #define DEMO_BUFFER_START_X 0U
  69. #define DEMO_BUFFER_START_Y 0U
  70. #define DEMO_BUFFER_STRIDE_BYTE (DEMO_BUFFER_WIDTH * DEMO_BUFFER_BYTE_PER_PIXEL)
  71. /* There is not frame buffer aligned requirement, consider the 64-bit AXI data
  72. * bus width and 32-byte cache line size, the frame buffer alignment is set to
  73. * 32 byte.
  74. */
  75. #define FRAME_BUFFER_ALIGN 32
  76. /*
  77. * MIPI panel pin
  78. */
  79. #define BOARD_MIPI_PANEL_RST_GPIO GPIO9
  80. #define BOARD_MIPI_PANEL_RST_PIN 1
  81. #define BOARD_MIPI_PANEL_POWER_GPIO GPIO11
  82. #define BOARD_MIPI_PANEL_POWER_PIN 16
  83. /* Back light pin. */
  84. #define BOARD_MIPI_PANEL_BL_GPIO GPIO9
  85. #define BOARD_MIPI_PANEL_BL_PIN 29
  86. /*
  87. * MIPI panel pin for RT-Thread
  88. */
  89. #define GET_PIN(PORTx, PIN) (32 * (PORTx - 1) + (PIN & 31)) /* PORTx:1,2,3,4,5 */
  90. #define LCD_MIPI_RST_GPIO_PORT (3U)
  91. #define LCD_MIPI_RST_GPIO_PIN (1U)
  92. #define LCD_MIPI_RST_PIN GET_PIN(LCD_MIPI_RST_GPIO_PORT, LCD_MIPI_RST_GPIO_PIN)
  93. /* Back light pin. */
  94. #define LCD_MIPI_BL_GPIO_PORT (3U)
  95. #define LCD_MIPI_BL_GPIO_PIN (29U)
  96. #define LCD_MIPI_BL_PIN GET_PIN(LCD_MIPI_BL_GPIO_PORT, LCD_MIPI_BL_GPIO_PIN)
  97. /*
  98. * RK055AHD091 panel
  99. */
  100. #if defined(DISPLAY_USING_RK055AHD091)
  101. #define LCD_MIPI_HSW 8
  102. #define LCD_MIPI_HFP 32
  103. #define LCD_MIPI_HBP 32
  104. #define LCD_MIPI_VSW 2
  105. #define LCD_MIPI_VFP 16
  106. #define LCD_MIPI_VBP 14
  107. #elif defined(DISPLAY_USING_RK055IQH091)
  108. #define LCD_MIPI_HSW 2
  109. #define LCD_MIPI_HFP 32
  110. #define LCD_MIPI_HBP 30
  111. #define LCD_MIPI_VSW 2
  112. #define LCD_MIPI_VFP 16
  113. #define LCD_MIPI_VBP 14
  114. #elif defined(DISPLAY_USING_RK055MHD091)
  115. #define LCD_MIPI_HSW 6
  116. #define LCD_MIPI_HFP 12
  117. #define LCD_MIPI_HBP 24
  118. #define LCD_MIPI_VSW 2
  119. #define LCD_MIPI_VFP 16
  120. #define LCD_MIPI_VBP 14
  121. #endif
  122. #if defined(BSP_USING_LCDIFV2)
  123. #define DEMO_LCDIF_POL_FLAGS \
  124. (kLCDIFV2_DataEnableActiveHigh | kLCDIFV2_VsyncActiveLow | kLCDIFV2_HsyncActiveLow | \
  125. kLCDIFV2_DriveDataOnFallingClkEdge)
  126. #define DEMO_LCDIF LCDIFV2
  127. #elif defined(BSP_USING_ELCDIF)
  128. #define DEMO_LCDIF_POL_FLAGS \
  129. (kELCDIF_DataEnableActiveHigh | kELCDIF_VsyncActiveLow | kELCDIF_HsyncActiveLow | kELCDIF_DriveDataOnFallingClkEdge)
  130. #define DEMO_LCDIF LCDIF
  131. #endif
  132. /* Definitions for MIPI. */
  133. #define DEMO_LCD_MIPI (&g_mipiDsi)
  134. #define DEMO_LCD_MIPI_LANE_NUM 2
  135. extern const dc_fb_t g_dc;
  136. /*******************************************************************************
  137. * API
  138. ******************************************************************************/
  139. #if defined(__cplusplus)
  140. extern "C" {
  141. #endif /* __cplusplus */
  142. status_t BOARD_PrepareDisplayController(void);
  143. #if defined(__cplusplus)
  144. }
  145. #endif /* __cplusplus */
  146. #endif /* _DISPLAY_SUPPORT_H_ */