fsl_display.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright 2017-2018 NXP
  3. * All rights reserved.
  4. *
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef _FSL_DISPLAY_H_
  9. #define _FSL_DISPLAY_H_
  10. #include "fsl_video_common.h"
  11. /*******************************************************************************
  12. * Definitions
  13. ******************************************************************************/
  14. /*! @brief Display common configuration. */
  15. typedef struct _display_common_cfg_t
  16. {
  17. uint16_t width;
  18. uint16_t height;
  19. uint16_t hsw; /*!< HSYNC pulse width. */
  20. uint16_t hfp; /*!< Horizontal front porch. */
  21. uint16_t hbp; /*!< Horizontal back porch. */
  22. uint16_t vsw; /*!< VSYNC pulse width. */
  23. uint16_t vfp; /*!< Vrtical front porch. */
  24. uint16_t vbp; /*!< Vertical back porch. */
  25. uint32_t clock; /* !< pixecl clock in kHz>. */
  26. } display_common_cfg;
  27. /*! @brief Display control flags. */
  28. enum _display_flags
  29. {
  30. kDISPLAY_VsyncActiveLow = 0U, /*!< VSYNC active low. */
  31. kDISPLAY_VsyncActiveHigh = (1U << 0U), /*!< VSYNC active high. */
  32. kDISPLAY_HsyncActiveLow = 0U, /*!< HSYNC active low. */
  33. kDISPLAY_HsyncActiveHigh = (1U << 1U), /*!< HSYNC active high. */
  34. kDISPLAY_DataEnableActiveHigh = 0U, /*!< Data enable line active high. */
  35. kDISPLAY_DataEnableActiveLow = (1U << 2U), /*!< Data enable line active low. */
  36. kDISPLAY_DataLatchOnRisingEdge = 0U, /*!< Latch data on rising clock edge. */
  37. kDISPLAY_DataLatchOnFallingEdge = (1U << 3U), /*!< Latch data on falling clock edge. */
  38. };
  39. /*! @brief Display configuration. */
  40. typedef struct _display_config
  41. {
  42. uint32_t resolution; /*!< Resolution, see @ref video_resolution_t and @ref FSL_VIDEO_RESOLUTION. */
  43. uint16_t hsw; /*!< HSYNC pulse width. */
  44. uint16_t hfp; /*!< Horizontal front porch. */
  45. uint16_t hbp; /*!< Horizontal back porch. */
  46. uint16_t vsw; /*!< VSYNC pulse width. */
  47. uint16_t vfp; /*!< Vrtical front porch. */
  48. uint16_t vbp; /*!< Vertical back porch. */
  49. uint32_t controlFlags; /*!< Control flags, OR'ed value of @ref _display_flags. */
  50. uint8_t dsiLanes; /*!< MIPI DSI data lanes number. */
  51. uint32_t pixelClock_Hz; /*!< Pixel clock in Hz. */
  52. video_pixel_format_t pixelFormat; /*!< Pixel format. */
  53. } display_config_t;
  54. typedef struct _display_handle display_handle_t;
  55. /*! @brief Display device operations. */
  56. typedef struct _display_operations
  57. {
  58. status_t (*init)(display_handle_t *handle, const display_config_t *config); /*!< Init the device. */
  59. status_t (*deinit)(display_handle_t *handle); /*!< Deinit the device. */
  60. status_t (*start)(display_handle_t *handle); /*!< Start the device. */
  61. status_t (*stop)(display_handle_t *handle); /*!< Stop the device. */
  62. } display_operations_t;
  63. /*! @brief Display handle. */
  64. struct _display_handle
  65. {
  66. const void *resource;
  67. const display_operations_t *ops;
  68. uint16_t width;
  69. uint16_t height;
  70. video_pixel_format_t pixelFormat;
  71. };
  72. /*******************************************************************************
  73. * API
  74. ******************************************************************************/
  75. #if defined(__cplusplus)
  76. extern "C" {
  77. #endif
  78. /*!
  79. * @brief Initializes the display device with user defined configuration.
  80. *
  81. * @param handle Display device handle.
  82. * @param config Pointer to the user-defined configuration structure.
  83. * @return Returns @ref kStatus_Success if initialize success, otherwise returns
  84. * error code.
  85. */
  86. static inline status_t DISPLAY_Init(display_handle_t *handle, const display_config_t *config)
  87. {
  88. return handle->ops->init(handle, config);
  89. }
  90. /*!
  91. * @brief Deinitialize the display device.
  92. *
  93. * @param handle Display device handle.
  94. * @return Returns @ref kStatus_Success if success, otherwise returns error code.
  95. */
  96. static inline status_t DISPLAY_Deinit(display_handle_t *handle)
  97. {
  98. return handle->ops->deinit(handle);
  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. */
  106. static inline status_t DISPLAY_Start(display_handle_t *handle)
  107. {
  108. return handle->ops->start(handle);
  109. }
  110. /*!
  111. * @brief Stop the display device.
  112. *
  113. * @param handle Display device handle.
  114. * @return Returns @ref kStatus_Success if success, otherwise returns error code.
  115. */
  116. static inline status_t DISPLAY_Stop(display_handle_t *handle)
  117. {
  118. return handle->ops->stop(handle);
  119. }
  120. #if defined(__cplusplus)
  121. }
  122. #endif
  123. #endif /* _FSL_DISPLAY_H_ */