mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
ports/stm32/jpeg: Add missing speculative read invalidates.
This commit is contained in:
parent
4110022e5d
commit
ddc1de8fb9
@ -81,6 +81,11 @@ static void jpeg_compress_get_data(JPEG_HandleTypeDef *hjpeg, uint32_t NbDecoded
|
||||
}
|
||||
|
||||
static void jpeg_compress_data_ready(JPEG_HandleTypeDef *hjpeg, uint8_t *pDataOut, uint32_t OutDataLength) {
|
||||
if ((!(((uint32_t) pDataOut) % __SCB_DCACHE_LINE_SIZE)) && (OutDataLength == JPEG_OUTPUT_CHUNK_SIZE)) {
|
||||
// Ensure any cached reads are dropped.
|
||||
SCB_InvalidateDCache_by_Addr((uint32_t *) pDataOut, JPEG_OUTPUT_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
// We have received this much data.
|
||||
JPEG_state.out_data_len += OutDataLength;
|
||||
|
||||
@ -96,7 +101,7 @@ static void jpeg_compress_data_ready(JPEG_HandleTypeDef *hjpeg, uint8_t *pDataOu
|
||||
// image in randomly aligned chunks. We only want to invalidate the cache of the output
|
||||
// buffer for the initial DMA chunks. So, this code below will do that and then only
|
||||
// invalidate aligned regions when the processor is moving the final parts of the image.
|
||||
if (!(((uint32_t) new_pDataOut) % __SCB_DCACHE_LINE_SIZE)) {
|
||||
if ((!(((uint32_t) new_pDataOut) % __SCB_DCACHE_LINE_SIZE)) && (OutDataLength == JPEG_OUTPUT_CHUNK_SIZE)) {
|
||||
SCB_InvalidateDCache_by_Addr((uint32_t *) new_pDataOut, JPEG_OUTPUT_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
@ -506,7 +511,7 @@ void jpeg_decompress(image_t *dst, image_t *src) {
|
||||
HAL_DMA2D_Init(&DMA2D_Handle);
|
||||
HAL_DMA2D_ConfigLayer(&DMA2D_Handle, 1);
|
||||
|
||||
// Invalidate the dst image for DMA2D.
|
||||
// Ensure any cached writes are dropped.
|
||||
SCB_InvalidateDCache_by_Addr((uint32_t *) dst->data, image_size(dst));
|
||||
}
|
||||
} else if (JPEG_state.jpeg_descr.Conf.ColorSpace == JPEG_CMYK_COLORSPACE) {
|
||||
@ -565,6 +570,9 @@ void jpeg_decompress(image_t *dst, image_t *src) {
|
||||
HAL_JPEG_Resume(&JPEG_state.jpeg_descr, JPEG_PAUSE_RESUME_OUTPUT);
|
||||
}
|
||||
|
||||
// Ensure any cached reads are dropped.
|
||||
SCB_InvalidateDCache_by_Addr((uint32_t *) this_mcu_row_buffer_ptr, dst_w_mcus_bytes);
|
||||
|
||||
if (JPEG_state.jpeg_descr.Conf.ColorSpace == JPEG_GRAYSCALE_COLORSPACE) {
|
||||
for (int x_offset = 0; x_offset < src->w; x_offset += JPEG_MCU_W) {
|
||||
uint8_t *Y0 = this_mcu_row_buffer_ptr + (x_offset * JPEG_MCU_H);
|
||||
@ -709,7 +717,6 @@ void jpeg_decompress(image_t *dst, image_t *src) {
|
||||
}
|
||||
case PIXFORMAT_RGB565: {
|
||||
uint16_t *rp = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(dst, y_offset);
|
||||
SCB_InvalidateDCache_by_Addr((uint32_t *) rp, dst->w * dy * sizeof(uint16_t));
|
||||
HAL_DMA2D_Start(&DMA2D_Handle, (uint32_t) this_mcu_row_buffer_ptr, (uint32_t) rp, dst->w, dy);
|
||||
HAL_DMA2D_PollForTransfer(&DMA2D_Handle, JPEG_CODEC_TIMEOUT);
|
||||
break;
|
||||
@ -744,6 +751,9 @@ exit_cleanup:
|
||||
|
||||
if ((JPEG_state.jpeg_descr.Conf.ColorSpace == JPEG_YCBCR_COLORSPACE) && dst->is_color) {
|
||||
HAL_DMA2D_DeInit(&DMA2D_Handle);
|
||||
|
||||
// Ensure any cached reads are dropped.
|
||||
SCB_InvalidateDCache_by_Addr((uint32_t *) dst->data, image_size(dst));
|
||||
}
|
||||
|
||||
if (((uint32_t) src->data) % __SCB_DCACHE_LINE_SIZE) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user