1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-23 05:40:57 +00:00

feat(core): improve dma2d/gfx_bitblt init/deinit

[no changelog]
This commit is contained in:
cepetr 2024-12-19 13:17:19 +01:00
parent 93707d29cc
commit 02227f3e7a
6 changed files with 27 additions and 1 deletions

View File

@ -25,6 +25,9 @@
// Initializes DMA2D peripheral // Initializes DMA2D peripheral
void dma2d_init(void); void dma2d_init(void);
// Deinitializes DMA2D peripheral
void dma2d_deinit(void);
// Waits until any pending DMA2D operation is finished // Waits until any pending DMA2D operation is finished
void dma2d_wait(void); void dma2d_wait(void);

View File

@ -25,6 +25,12 @@ void gfx_bitblt_init(void) {
#endif #endif
} }
void gfx_bitblt_deinit(void) {
#if defined(USE_DMA2D) && !defined(TREZOR_EMULATOR)
dma2d_deinit();
#endif
}
void gfx_bitblt_wait(void) { void gfx_bitblt_wait(void) {
#if defined(USE_DMA2D) && !defined(TREZOR_EMULATOR) #if defined(USE_DMA2D) && !defined(TREZOR_EMULATOR)
dma2d_wait(); dma2d_wait();

View File

@ -40,7 +40,19 @@ static inline bool dma2d_accessible(const void* ptr) {
#endif #endif
} }
void dma2d_init(void) { __HAL_RCC_DMA2D_CLK_ENABLE(); } void dma2d_init(void) {
__HAL_RCC_DMA2D_FORCE_RESET();
__HAL_RCC_DMA2D_RELEASE_RESET();
__HAL_RCC_DMA2D_CLK_ENABLE();
}
void dma2d_deinit(void) {
__HAL_RCC_DMA2D_CLK_DISABLE();
__HAL_RCC_DMA2D_FORCE_RESET();
__HAL_RCC_DMA2D_RELEASE_RESET();
}
void dma2d_wait(void) { void dma2d_wait(void) {
while (HAL_DMA2D_PollForTransfer(&dma2d_handle, 10) != HAL_OK) while (HAL_DMA2D_PollForTransfer(&dma2d_handle, 10) != HAL_OK)

View File

@ -78,6 +78,9 @@ typedef struct {
// Initializes bitblt operations // Initializes bitblt operations
void gfx_bitblt_init(void); void gfx_bitblt_init(void);
// Deinitializes bitblt operations
void gfx_bitblt_deinit(void);
// If the bitblt operation is asynchronous, waits until it's finished // If the bitblt operation is asynchronous, waits until it's finished
void gfx_bitblt_wait(void); void gfx_bitblt_wait(void);

View File

@ -103,6 +103,7 @@ static void drivers_deinit(void) {
#ifdef FIXED_HW_DEINIT #ifdef FIXED_HW_DEINIT
// TODO // TODO
#endif #endif
gfx_bitblt_deinit();
display_deinit(DISPLAY_JUMP_BEHAVIOR); display_deinit(DISPLAY_JUMP_BEHAVIOR);
#ifdef USE_POWERCTL #ifdef USE_POWERCTL
powerctl_deinit(); powerctl_deinit();

View File

@ -136,6 +136,7 @@ static void drivers_deinit(void) {
#ifdef FIXED_HW_DEINIT #ifdef FIXED_HW_DEINIT
// TODO // TODO
#endif #endif
gfx_bitblt_deinit();
display_deinit(DISPLAY_JUMP_BEHAVIOR); display_deinit(DISPLAY_JUMP_BEHAVIOR);
ensure_compatible_settings(); ensure_compatible_settings();
} }