Skip to content

Commit fb4b590

Browse files
committed
refactor(dma)!: remove deprecated functions
1 parent a8bf745 commit fb4b590

File tree

30 files changed

+97
-878
lines changed

30 files changed

+97
-878
lines changed

components/esp_driver_bitscrambler/src/bitscrambler_loopback.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,14 @@ esp_err_t bitscrambler_loopback_run(bitscrambler_handle_t bs, void *buffer_in, s
210210
return ESP_ERR_INVALID_SIZE;
211211
}
212212

213-
int int_mem_cache_line_size = cache_hal_get_cache_line_size(CACHE_LL_LEVEL_INT_MEM, CACHE_TYPE_DATA);
214-
int ext_mem_cache_line_size = cache_hal_get_cache_line_size(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_DATA);
215-
216-
bool need_cache_sync = esp_ptr_internal(buffer_in) ? (int_mem_cache_line_size > 0) : (ext_mem_cache_line_size > 0);
217-
if (need_cache_sync) {
213+
if (esp_cache_get_line_size_by_addr(buffer_in) > 0) {
218214
//Note: we add the ESP_CACHE_MSYNC_FLAG_UNALIGNED flag for now as otherwise esp_cache_msync will complain about
219215
//the size not being aligned... we miss out on a check to see if the address is aligned this way. This needs to
220216
//be improved, but potentially needs a fix in esp_cache_msync not to check the size.
221217
ESP_RETURN_ON_ERROR(esp_cache_msync(buffer_in, length_bytes_in, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED),
222218
TAG, "failed in cache sync for input buffer");
223219
}
224-
need_cache_sync = esp_ptr_internal(buffer_out) ? (int_mem_cache_line_size > 0) : (ext_mem_cache_line_size > 0);
225-
if (need_cache_sync) {
220+
if (esp_cache_get_line_size_by_addr(buffer_out) > 0) {
226221
ESP_RETURN_ON_ERROR(esp_cache_msync(buffer_out, length_bytes_out, ESP_CACHE_MSYNC_FLAG_DIR_M2C),
227222
TAG, "failed in cache sync for output buffer");
228223
}

components/esp_driver_jpeg/jpeg_decode.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,30 @@ esp_err_t jpeg_decoder_get_info(const uint8_t *in_buf, uint32_t inbuf_len, jpeg_
199199
return ESP_OK;
200200
}
201201

202+
static bool _check_buffer_alignment(void *buffer, uint32_t buffer_size, uint32_t alignment)
203+
{
204+
if (alignment == 0) {
205+
alignment = 4; // basic align requirement from DMA
206+
}
207+
if ((uintptr_t)buffer & (alignment - 1)) {
208+
return false;
209+
}
210+
if (buffer_size & (alignment - 1)) {
211+
return false;
212+
}
213+
return true;
214+
}
215+
202216
esp_err_t jpeg_decoder_process(jpeg_decoder_handle_t decoder_engine, const jpeg_decode_cfg_t *decode_cfg, const uint8_t *bit_stream, uint32_t stream_size, uint8_t *decode_outbuf, uint32_t outbuf_size, uint32_t *out_size)
203217
{
204218
ESP_RETURN_ON_FALSE(decoder_engine, ESP_ERR_INVALID_ARG, TAG, "jpeg decode handle is null");
205219
ESP_RETURN_ON_FALSE(decode_cfg, ESP_ERR_INVALID_ARG, TAG, "jpeg decode config is null");
206-
ESP_RETURN_ON_FALSE(decode_outbuf, ESP_ERR_INVALID_ARG, TAG, "jpeg decode picture buffer is null");
207-
esp_dma_mem_info_t dma_mem_info = {
208-
.dma_alignment_bytes = 4,
209-
};
210-
//TODO: IDF-9637
211-
ESP_RETURN_ON_FALSE(esp_dma_is_buffer_alignment_satisfied(decode_outbuf, outbuf_size, dma_mem_info), ESP_ERR_INVALID_ARG, TAG, "jpeg decode decode_outbuf or out_buffer size is not aligned, please use jpeg_alloc_decoder_mem to malloc your buffer");
220+
ESP_RETURN_ON_FALSE(decode_outbuf && outbuf_size, ESP_ERR_INVALID_ARG, TAG, "jpeg decode picture buffer is null");
221+
222+
uint32_t outbuf_cache_line_size = esp_cache_get_line_size_by_addr(decode_outbuf);
223+
// check alignment of the output buffer
224+
ESP_RETURN_ON_FALSE(_check_buffer_alignment(decode_outbuf, outbuf_size, outbuf_cache_line_size), ESP_ERR_INVALID_ARG, TAG,
225+
"jpeg decode decode_outbuf or out_buffer size is not aligned, please use jpeg_alloc_decoder_mem to malloc your buffer");
212226

213227
esp_err_t ret = ESP_OK;
214228

@@ -232,8 +246,10 @@ esp_err_t jpeg_decoder_process(jpeg_decoder_handle_t decoder_engine, const jpeg_
232246
ESP_GOTO_ON_ERROR(jpeg_parse_header_info_to_hw(decoder_engine), err2, TAG, "write header info to hw failed");
233247
ESP_GOTO_ON_ERROR(jpeg_dec_config_dma_descriptor(decoder_engine), err2, TAG, "config dma descriptor failed");
234248

235-
*out_size = decoder_engine->header_info->process_h * decoder_engine->header_info->process_v * decoder_engine->bit_per_pixel / 8;
236-
ESP_GOTO_ON_FALSE((*out_size <= outbuf_size), ESP_ERR_INVALID_ARG, err2, TAG, "Given buffer size % " PRId32 " is smaller than actual jpeg decode output size % " PRId32 "the height and width of output picture size will be adjusted to 16 bytes aligned automatically", outbuf_size, *out_size);
249+
if (out_size) {
250+
*out_size = decoder_engine->header_info->process_h * decoder_engine->header_info->process_v * decoder_engine->bit_per_pixel / 8;
251+
ESP_GOTO_ON_FALSE((*out_size <= outbuf_size), ESP_ERR_INVALID_ARG, err2, TAG, "Given buffer size % " PRId32 " is smaller than actual jpeg decode output size % " PRId32 "the height and width of output picture size will be adjusted to 16 bytes aligned automatically", outbuf_size, *out_size);
252+
}
237253

238254
dma2d_trans_config_t trans_desc = {
239255
.tx_channel_num = 1,
@@ -268,8 +284,10 @@ esp_err_t jpeg_decoder_process(jpeg_decoder_handle_t decoder_engine, const jpeg_
268284
}
269285

270286
if (jpeg_dma2d_event.dma_evt & JPEG_DMA2D_RX_EOF) {
271-
ret = esp_cache_msync((void*)decoder_engine->decoded_buf, outbuf_size, ESP_CACHE_MSYNC_FLAG_DIR_M2C);
272-
assert(ret == ESP_OK);
287+
if (outbuf_cache_line_size > 0) {
288+
ret = esp_cache_msync((void*)decoder_engine->decoded_buf, outbuf_size, ESP_CACHE_MSYNC_FLAG_DIR_M2C);
289+
assert(ret == ESP_OK);
290+
}
273291
break;
274292
}
275293
}

components/esp_driver_parlio/src/parlio_tx.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,16 +636,12 @@ esp_err_t parlio_tx_unit_transmit(parlio_tx_unit_handle_t tx_unit, const void *p
636636
}
637637
#endif // !SOC_PARLIO_TX_SUPPORT_EOF_FROM_DMA
638638

639-
size_t cache_line_size = 0;
640-
size_t alignment = 0;
641-
uint8_t cache_type = 0;
642-
esp_ptr_external_ram(payload) ? (alignment = tx_unit->ext_mem_align, cache_type = CACHE_LL_LEVEL_EXT_MEM) : (alignment = tx_unit->int_mem_align, cache_type = CACHE_LL_LEVEL_INT_MEM);
639+
size_t alignment = esp_ptr_external_ram(payload) ? tx_unit->ext_mem_align : tx_unit->int_mem_align;
643640
// check alignment
644641
ESP_RETURN_ON_FALSE(((uint32_t)payload & (alignment - 1)) == 0, ESP_ERR_INVALID_ARG, TAG, "payload address not aligned");
645642
ESP_RETURN_ON_FALSE((payload_bits & (alignment - 1)) == 0, ESP_ERR_INVALID_ARG, TAG, "payload size not aligned");
646-
cache_line_size = cache_hal_get_cache_line_size(cache_type, CACHE_TYPE_DATA);
647643

648-
if (cache_line_size > 0) {
644+
if (esp_cache_get_line_size_by_addr(payload) > 0) {
649645
// Write back to cache to synchronize the cache before DMA start
650646
ESP_RETURN_ON_ERROR(esp_cache_msync((void *)payload, (payload_bits + 7) / 8,
651647
ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED), TAG, "cache sync failed");

components/esp_driver_sdmmc/legacy/include/driver/sdmmc_default_configs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ extern "C" {
5050
.set_input_delayline = &sdmmc_host_set_input_delayline, \
5151
.dma_aligned_buffer = NULL, \
5252
.pwr_ctrl_handle = NULL, \
53-
.get_dma_info = NULL, \
5453
.check_buffer_alignment = &sdmmc_host_check_buffer_alignment, \
5554
.is_slot_set_to_uhs1 = &sdmmc_host_is_slot_set_to_uhs1, \
5655
}

components/esp_driver_sdmmc/legacy/include/driver/sdmmc_host.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -291,19 +291,6 @@ esp_err_t sdmmc_host_set_input_delay(int slot, sdmmc_delay_phase_t delay_phase);
291291
*/
292292
esp_err_t sdmmc_host_set_input_delayline(int slot, sdmmc_delay_line_t delay_line);
293293

294-
/**
295-
* @brief Get the DMA memory information for the host driver
296-
*
297-
* @deprecated This API is deprecated
298-
*
299-
* @param[in] slot slot number (SDMMC_HOST_SLOT_0 or SDMMC_HOST_SLOT_1)
300-
* @param[out] dma_mem_info DMA memory information structure
301-
* @return
302-
* - ESP_OK: ON success.
303-
* - ESP_ERR_INVALID_ARG: Invalid argument.
304-
*/
305-
esp_err_t sdmmc_host_get_dma_info(int slot, esp_dma_mem_info_t *dma_mem_info) __attribute__((deprecated("This API is deprecated")));
306-
307294
/**
308295
* @brief Check if the buffer meets the alignment requirements
309296
*

components/esp_driver_sdmmc/legacy/src/sdmmc_host.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,6 @@ esp_err_t sdmmc_host_io_int_wait(int slot, TickType_t timeout_ticks)
233233
return ESP_OK;
234234
}
235235

236-
esp_err_t sdmmc_host_get_dma_info(int slot, esp_dma_mem_info_t *dma_mem_info)
237-
{
238-
SLOT_CHECK(slot);
239-
240-
if (dma_mem_info == NULL) {
241-
return ESP_ERR_INVALID_ARG;
242-
}
243-
dma_mem_info->extra_heap_caps = MALLOC_CAP_DMA;
244-
dma_mem_info->dma_alignment_bytes = 4;
245-
return ESP_OK;
246-
}
247-
248236
bool sdmmc_host_check_buffer_alignment(int slot, const void *buf, size_t size)
249237
{
250238
assert(slot == 0 || slot == 1);

components/esp_driver_sdspi/include/driver/sdspi_host.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ typedef int sdspi_dev_handle_t;
6363
.set_input_delayline = NULL, \
6464
.dma_aligned_buffer = NULL, \
6565
.pwr_ctrl_handle = NULL, \
66-
.get_dma_info = NULL, \
6766
.check_buffer_alignment = sdspi_host_check_buffer_alignment, \
6867
.is_slot_set_to_uhs1 = NULL, \
6968
}
@@ -223,19 +222,6 @@ esp_err_t sdspi_host_io_int_enable(sdspi_dev_handle_t handle);
223222
*/
224223
esp_err_t sdspi_host_io_int_wait(sdspi_dev_handle_t handle, TickType_t timeout_ticks);
225224

226-
/**
227-
* @brief Get the DMA memory information for the host driver
228-
*
229-
* @deprecated This API is deprecated
230-
*
231-
* @param[in] slot Not used
232-
* @param[out] dma_mem_info DMA memory information structure
233-
* @return
234-
* - ESP_OK: ON success.
235-
* - ESP_ERR_INVALID_ARG: Invalid argument.
236-
*/
237-
esp_err_t sdspi_host_get_dma_info(int slot, esp_dma_mem_info_t *dma_mem_info) __attribute__((deprecated("This API is deprecated")));
238-
239225
/**
240226
* @brief Check if the buffer meets the alignment requirements
241227
*

components/esp_driver_sdspi/src/sdspi_host.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,14 +1003,6 @@ esp_err_t sdspi_host_io_int_wait(sdspi_dev_handle_t handle, TickType_t timeout_t
10031003
return ESP_OK;
10041004
}
10051005

1006-
esp_err_t sdspi_host_get_dma_info(int slot, esp_dma_mem_info_t *dma_mem_info)
1007-
{
1008-
(void)slot;
1009-
dma_mem_info->extra_heap_caps = MALLOC_CAP_DMA;
1010-
dma_mem_info->dma_alignment_bytes = 4;
1011-
return ESP_OK;
1012-
}
1013-
10141006
bool sdspi_host_check_buffer_alignment(int slot, const void *buf, size_t size)
10151007
{
10161008
//for future-proof

components/esp_hw_support/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ if(NOT non_os_build)
7777
endif()
7878

7979
if(CONFIG_SOC_GDMA_SUPPORTED)
80-
list(APPEND srcs "dma/gdma.c" "deprecated/gdma_legacy.c")
80+
list(APPEND srcs "dma/gdma.c")
8181
if(CONFIG_SOC_GDMA_SUPPORT_SLEEP_RETENTION AND CONFIG_SOC_PAU_SUPPORTED)
8282
list(APPEND srcs "dma/gdma_sleep_retention.c")
8383
endif()

components/esp_hw_support/deprecated/gdma_legacy.c

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)