feat(ppa): add PPA driver support for ESP32P4

Separate callback registration to individual API
Fix YUV420 output
Separate source files into operations
This commit is contained in:
Song Ruo Jing
2024-05-23 16:40:56 +08:00
parent fd1a718f62
commit 01bc7dcc56
8 changed files with 1300 additions and 1204 deletions
+35 -3
View File
@@ -15,6 +15,7 @@
#include "esp_private/dma2d.h"
#include "hal/dma2d_types.h"
#include "hal/ppa_types.h"
#include "hal/ppa_hal.h"
#include "esp_pm.h"
#ifdef __cplusplus
@@ -33,12 +34,15 @@ extern "C" {
ESP_RETURN_ON_FALSE(COLOR_SPACE_TYPE(color_type_id) == COLOR_SPACE_ARGB || COLOR_SPACE_TYPE(color_type_id) == COLOR_SPACE_RGB, \
ESP_ERR_INVALID_ARG, TAG, str "_cm does not support rgb_swap");
typedef struct ppa_platform_t ppa_platform_t;
/******************************** ENGINE *************************************/
// PPA module contains SRM engine and Blending engine
typedef struct ppa_engine_t ppa_engine_t;
struct ppa_engine_t {
ppa_platform_t *platform; // PPA driver platform
ppa_engine_type_t type; // Type of the PPA engine
portMUX_TYPE spinlock; // Engine level spinlock
SemaphoreHandle_t sem; // Semaphore for whether the engine is processing a transaction
@@ -81,7 +85,7 @@ struct ppa_client_t {
/****************************** OPERATION ************************************/
// The elements in this structure listed first are identical to the elements in structure `ppa_srm_oper_trans_config_t`
// The elements in this structure listed first are identical to the elements in structure `ppa_srm_oper_config_t`
// With adding a few extra elements in the end
// This allows memcpy
typedef struct {
@@ -111,9 +115,9 @@ typedef struct {
uint32_t scale_y_frag;
} ppa_srm_oper_t;
typedef ppa_blend_oper_trans_config_t ppa_blend_oper_t;
typedef ppa_blend_oper_config_t ppa_blend_oper_t;
typedef ppa_fill_oper_trans_config_t ppa_fill_oper_t;
typedef ppa_fill_oper_config_t ppa_fill_oper_t;
/***************************** TRANSACTION ***********************************/
@@ -139,6 +143,34 @@ typedef struct {
dma2d_trigger_peripheral_t trigger_periph; // The 2D-DMA trigger peripheral
} ppa_dma2d_trans_on_picked_config_t;
bool ppa_srm_transaction_on_picked(uint32_t num_chans, const dma2d_trans_channel_info_t *dma2d_chans, void *user_config);
bool ppa_blend_transaction_on_picked(uint32_t num_chans, const dma2d_trans_channel_info_t *dma2d_chans, void *user_config);
bool ppa_fill_transaction_on_picked(uint32_t num_chans, const dma2d_trans_channel_info_t *dma2d_chans, void *user_config);
esp_err_t ppa_do_operation(ppa_client_handle_t ppa_client, ppa_engine_t *ppa_engine_base, ppa_trans_t *trans_elm, ppa_trans_mode_t mode);
bool ppa_transaction_done_cb(dma2d_channel_handle_t dma2d_chan, dma2d_event_data_t *event_data, void *user_data);
bool ppa_recycle_transaction(ppa_client_handle_t ppa_client, ppa_trans_t *trans_elm);
/****************************** PPA DRIVER ***********************************/
struct ppa_platform_t {
_lock_t mutex; // Platform level mutex lock to protect the ppa_engine_acquire/ppa_engine_release process
portMUX_TYPE spinlock; // Platform level spinlock
ppa_hal_context_t hal; // PPA HAL context
dma2d_pool_handle_t dma2d_pool_handle; // Pointer to the acquired 2D-DMA pool
ppa_srm_engine_t *srm; // Pointer to the PPA SRM engine
ppa_blend_engine_t *blending; // Pointer to the PPA blending engine
uint32_t srm_engine_ref_count; // Reference count used to protect PPA SRM engine acquire and release
uint32_t blend_engine_ref_count; // Reference count used to protect PPA blending engine acquire and release
size_t buf_alignment_size; // Alignment requirement for the outgoing buffer addr and size to satisfy cache line size
uint32_t dma_desc_mem_size; // Alignment requirement for the 2D-DMA descriptor to satisfy cache line size
#if CONFIG_PM_ENABLE
esp_pm_lock_handle_t pm_lock; // Power management lock
#endif
};
#ifdef __cplusplus
}
#endif