1 /* 2 * Copyright 2019-2020 NXP 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef _FSL_DPR_H_ 9 #define _FSL_DPR_H_ 10 11 #include "fsl_common.h" 12 13 /*! 14 * @addtogroup dpr 15 * @{ 16 */ 17 18 /******************************************************************************* 19 * Definitions 20 ******************************************************************************/ 21 /*! @brief Driver version. */ 22 #define FSL_DPR_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) 23 24 /*! 25 * @brief Data type of the frame buffer. 26 */ 27 typedef enum _dpr_data_type 28 { 29 kDPR_DataType16Bpp = 1U, /*!< 16 bits per pixel. */ 30 kDPR_DataType32Bpp = 2U, /*!< 32 bits per pixel. */ 31 } dpr_data_type_t; 32 33 /*! 34 * @brief Frame buffer configuration. 35 */ 36 typedef struct _dpr_buffer_config 37 { 38 uint16_t width; /*!< Frame buffer width, how many pixels per line. */ 39 uint16_t height; /*!< Frame buffer height. */ 40 uint16_t strideBytes; /*!< Stride in bytes. */ 41 dpr_data_type_t dataType; /*!< Data type. */ 42 } dpr_buffer_config_t; 43 44 /******************************************************************************* 45 * API 46 ******************************************************************************/ 47 48 #if defined(__cplusplus) 49 extern "C" { 50 #endif 51 52 /*! 53 * @brief Enables and configures the DPR peripheral module. 54 * 55 * @param base DPR peripheral address. 56 */ 57 void DPR_Init(DPR_Type *base); 58 59 /*! 60 * @brief Disables the DPR peripheral module. 61 * 62 * @param base DPR peripheral address. 63 */ 64 void DPR_Deinit(DPR_Type *base); 65 66 /*! 67 * @brief Set the input frame buffer configuration. 68 * 69 * @param base DPR peripheral address. 70 * @param config Pointer to the configuration. 71 */ 72 void DPR_SetBufferConfig(DPR_Type *base, const dpr_buffer_config_t *config); 73 74 /*! 75 * @brief Get the input frame buffer default configuration. 76 * 77 * The default configuration is 78 * @code 79 config->width = 1080U; 80 config->height = 1920U; 81 config->strideBytes = 4U * 1080U; 82 config->dataType = kDPR_DataType32Bpp; 83 @endcode 84 * 85 * @param config Pointer to the configuration. 86 */ 87 void DPR_BufferGetDefaultConfig(dpr_buffer_config_t *config); 88 89 /*! 90 * @brief Starts the DPR 91 * 92 * This function trigers the DPR to load the new configuration and start 93 * processing the next frame. It should be called before display started. 94 * 95 * @param base DPR peripheral address. 96 */ DPR_Start(DPR_Type * base)97static inline void DPR_Start(DPR_Type *base) 98 { 99 base->SYSTEM_CTRL0.RW = DPR_SYSTEM_CTRL0_SW_SHADOW_LOAD_SEL_MASK | DPR_SYSTEM_CTRL0_SHADOW_LOAD_EN_MASK; 100 101 base->SYSTEM_CTRL0.RW = 102 DPR_SYSTEM_CTRL0_SW_SHADOW_LOAD_SEL_MASK | DPR_SYSTEM_CTRL0_SHADOW_LOAD_EN_MASK | DPR_SYSTEM_CTRL0_RUN_EN_MASK; 103 } 104 105 /*! 106 * @brief Starts the DPR to run repeatly. 107 * 108 * This function should be called after display started. The display signal trigers 109 * the new configuration loading repeatly. 110 * 111 * @param base DPR peripheral address. 112 */ DPR_StartRepeat(DPR_Type * base)113static inline void DPR_StartRepeat(DPR_Type *base) 114 { 115 base->SYSTEM_CTRL0.RW = 116 DPR_SYSTEM_CTRL0_REPEAT_EN_MASK | DPR_SYSTEM_CTRL0_SHADOW_LOAD_EN_MASK | DPR_SYSTEM_CTRL0_RUN_EN_MASK; 117 } 118 119 /*! 120 * @brief Stops the DPR 121 * 122 * @param base DPR peripheral address. 123 */ DPR_Stop(DPR_Type * base)124static inline void DPR_Stop(DPR_Type *base) 125 { 126 base->SYSTEM_CTRL0.RW = DPR_SYSTEM_CTRL0_SW_SHADOW_LOAD_SEL_MASK | DPR_SYSTEM_CTRL0_SHADOW_LOAD_EN_MASK; 127 } 128 129 /*! 130 * @brief Set the frame buffer address. 131 * 132 * @param base DPR peripheral address. 133 * @param addr Frame buffer address. 134 */ DPR_SetBufferAddr(DPR_Type * base,uint32_t addr)135static inline void DPR_SetBufferAddr(DPR_Type *base, uint32_t addr) 136 { 137 base->FRAME_1P_BASE_ADDR_CTRL0.RW = addr; 138 } 139 140 #if defined(__cplusplus) 141 } 142 #endif 143 144 /*! 145 * @} 146 */ 147 #endif /* _FSL_DPR_H_ */ 148