fix(dma2d): add a dequeue mechanism for dma2d driver

JPEG driver should be able to either dequeue a pending transaction from
a 2D-DMA pool or force end a processing transaction.
This commit is contained in:
Song Ruo Jing
2026-07-08 20:11:08 +08:00
parent 9369102192
commit 4fbbc16ac6
4 changed files with 73 additions and 9 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -152,6 +152,29 @@ typedef struct {
*/
esp_err_t dma2d_enqueue(dma2d_pool_handle_t dma2d_pool, const dma2d_trans_config_t *trans_desc, dma2d_trans_t *trans_placeholder);
/**
* @brief Dequeue a pending 2D-DMA transaction from a 2D-DMA pool
*
* Remove a transaction that was previously enqueued by `dma2d_enqueue` but has not yet been picked up for
* processing (i.e. it is still waiting in the pool's pending queue). This is useful when the upper driver wants
* to cancel a transaction that has not started yet.
*
* @note This API only operates on transactions that are still pending. To end a transaction that is already
* in-flight (its channels have been acquired), use `dma2d_force_end` instead.
*
* @note After this function returns ESP_OK, the upper driver can safely free the transaction placeholder, as the
* `on_job_picked` callback of the transaction will no longer be called.
*
* @param[in] dma2d_pool 2D-DMA pool handle, allocated by `dma2d_acquire_pool`
* @param[in] trans Pointer to the 2D-DMA transaction context
* @return
* - ESP_OK: Dequeue the pending 2D-DMA transaction successfully
* - ESP_ERR_INVALID_ARG: Dequeue failed because of invalid argument
* - ESP_ERR_NOT_FOUND: The transaction is not in the pending queue, because it has already been picked up
* for processing or it was never enqueued to this pool
*/
esp_err_t dma2d_dequeue(dma2d_pool_handle_t dma2d_pool, dma2d_trans_t *trans);
/**
* @brief Force end an in-flight 2D-DMA transaction
*