Skip to content

Commit 7761485

Browse files
authored
fix jpeg decode && redraw ui loader (#349)
* Revert "Revert "disable D-Cache during jpeg decoding. (#340)" (#341)" This reverts commit 7ebd207. * fix(jpeg): resolve issues caused by input cache during decoding. * feat(ui): draw progress bar using LVGL components. * fix(btc-only): correct command response error.
1 parent a17f57a commit 7761485

File tree

6 files changed

+247
-342
lines changed

6 files changed

+247
-342
lines changed

core/embed/extmod/modtrezorui/mipi_lcd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ void display_fp(uint16_t x, uint16_t y, uint16_t w, uint16_t h,
707707
int lcd_ltdc_busy(void) {
708708
hlcd_ltdc.Instance = LTDC;
709709
// low is busy
710-
return hlcd_ltdc.Instance->CDSR & 0x01 ? 0 : 1;
710+
return hlcd_ltdc.Instance->CDSR & LTDC_CDSR_VSYNCS ? 0 : 1;
711711
}
712712

713713
void lcd_ltdc_dsi_disable(void) {

core/embed/lvgl/lv_jpeg_stm32.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ static lv_res_t decoder_open(lv_img_decoder_t *decoder,
184184
strncmp(lv_fs_get_ext(fn), "jpeg", strlen("jpeg")) == 0) {
185185
/*Check the extension*/
186186
jpeg_decode_init(FMC_SDRAM_JPEG_OUTPUT_DATA_BUFFER_ADDRESS);
187-
188187
/* Start JPEG decoding with DMA method */
189188
if (jpeg_decode_start(fn) != 0) {
190189
return LV_RES_INV;
@@ -205,6 +204,17 @@ static lv_res_t decoder_open(lv_img_decoder_t *decoder,
205204
(uint32_t *)FMC_SDRAM_JPEG_OUTPUT_DATA_BUFFER_ADDRESS,
206205
(uint32_t *)img_data, width, height, subsampling);
207206

207+
// uint32_t addr = (uint32_t)img_data;
208+
// uint32_t end = addr + width * height * 2;
209+
210+
// #define L1C_LINE_SIZE 32
211+
212+
// uint32_t aligned_addr = addr & ~(L1C_LINE_SIZE - 1U);
213+
// uint32_t aligned_end = (end + L1C_LINE_SIZE - 1U) & ~(L1C_LINE_SIZE -
214+
// 1U); uint32_t aligned_size = aligned_end - aligned_addr;
215+
216+
// SCB_InvalidateDCache_by_Addr((uint32_t *)aligned_addr, aligned_size);
217+
208218
dsc->img_data = img_data;
209219
return LV_RES_OK; /*The image is fully decoded. Return with its pointer*/
210220
}

core/embed/trezorhal/jpeg_dma.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ int jpeg_decode_start(const char *path) {
276276
if (indata_len > CHUNK_SIZE_IN) {
277277
indata_len = CHUNK_SIZE_IN;
278278
}
279+
280+
SCB_CleanDCache_by_Addr((uint32_t *)g_inputJpegBuffer, MAX_JPEG_SIZE);
279281
HAL_JPEG_Decode_DMA(&JPEG_Handle, g_inputJpegBuffer, indata_len,
280282
g_outputBuffer, CHUNK_SIZE_OUT);
281283

core/src/apps/workflow_handlers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,12 @@ def find_message_handler_module(msg_type: int) -> str:
106106
return "apps.misc.cipher_key_value"
107107
if msg_type == MessageType.GetFirmwareHash:
108108
return "apps.misc.get_firmware_hash"
109-
if msg_type == MessageType.BatchGetPublickeys:
110-
return "apps.misc.batch_get_pubkeys"
111109

112110
if not utils.BITCOIN_ONLY:
111+
112+
if msg_type == MessageType.BatchGetPublickeys:
113+
return "apps.misc.batch_get_pubkeys"
114+
113115
if msg_type == MessageType.SetU2FCounter:
114116
return "apps.management.set_u2f_counter"
115117
if msg_type == MessageType.GetNextU2FCounter:

0 commit comments

Comments
 (0)