mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-07 17:08:49 +00:00
feat(ppa): add PPA driver support for ESP32P4
Modified API operation configuration structure Rename invoker to client Support YUV420 color mode for SRM Move PPA srm/blending engine reset ahead of any 2D-DMA channel configurations
This commit is contained in:
@@ -25,9 +25,9 @@ typedef enum {
|
||||
} ppa_operation_t;
|
||||
|
||||
/**
|
||||
* @brief Type of PPA invoker handle
|
||||
* @brief Type of PPA client handle
|
||||
*/
|
||||
typedef struct ppa_invoker_t *ppa_invoker_handle_t;
|
||||
typedef struct ppa_client_t *ppa_client_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Type of PPA transaction handle
|
||||
@@ -44,48 +44,48 @@ typedef struct {
|
||||
/**
|
||||
* @brief Type of PPA event callback
|
||||
*
|
||||
* @param ppa_invoker PPA invoker handle
|
||||
* @param ppa_client PPA client handle
|
||||
* @param event_data PPA event data
|
||||
* @param user_data User registered data from calling `ppa_do_xxx` to perform an operation
|
||||
*
|
||||
* @return Whether a task switch is needed after the callback function returns, this is usually due to the callback
|
||||
* wakes up some high priority task.
|
||||
*/
|
||||
typedef bool (*ppa_event_callback_t)(ppa_invoker_handle_t ppa_invoker, ppa_event_data_t *event_data, void *user_data);
|
||||
typedef bool (*ppa_event_callback_t)(ppa_client_handle_t ppa_client, ppa_event_data_t *event_data, void *user_data);
|
||||
|
||||
/**
|
||||
* @brief A collection of configuration items that used for registering a PPA invoker
|
||||
* @brief A collection of configuration items that used for registering a PPA client
|
||||
*/
|
||||
typedef struct {
|
||||
ppa_operation_t oper_type; /*!< The desired PPA operation for the invoker */
|
||||
ppa_operation_t oper_type; /*!< The desired PPA operation for the client */
|
||||
ppa_event_callback_t done_cb; /*!< Callback function to be executed when a PPA transaction finishes */
|
||||
uint32_t max_pending_trans_num; /*!< The maximum number of pending transactions for the invoker.
|
||||
uint32_t max_pending_trans_num; /*!< The maximum number of pending transactions for the client.
|
||||
By default, it will be 1, which is sufficient if all transactions are performed with `PPA_TRANS_MODE_BLOCKING` */
|
||||
} ppa_invoker_config_t;
|
||||
} ppa_client_config_t;
|
||||
|
||||
/**
|
||||
* @brief Register a PPA invoker to do a specific PPA operation
|
||||
* @brief Register a PPA client to do a specific PPA operation
|
||||
*
|
||||
* @param[in] config Pointer to a collection of configurations for the invoker
|
||||
* @param[out] ret_invoker Returned invoker handle
|
||||
* @param[in] config Pointer to a collection of configurations for the client
|
||||
* @param[out] ret_client Returned client handle
|
||||
* @return
|
||||
* - ESP_OK: Register the PPA invoker successfully
|
||||
* - ESP_ERR_INVALID_ARG: Register the PPA invoker failed because of invalid argument
|
||||
* - ESP_ERR_NO_MEM: Register the PPA invoker failed because out of memory
|
||||
* - ESP_FAIL: Register the PPA invoker failed because of other error
|
||||
* - ESP_OK: Register the PPA client successfully
|
||||
* - ESP_ERR_INVALID_ARG: Register the PPA client failed because of invalid argument
|
||||
* - ESP_ERR_NO_MEM: Register the PPA client failed because out of memory
|
||||
* - ESP_FAIL: Register the PPA client failed because of other error
|
||||
*/
|
||||
esp_err_t ppa_register_invoker(const ppa_invoker_config_t *config, ppa_invoker_handle_t *ret_invoker);
|
||||
esp_err_t ppa_register_client(const ppa_client_config_t *config, ppa_client_handle_t *ret_client);
|
||||
|
||||
/**
|
||||
* @brief Unregister a PPA invoker
|
||||
* @brief Unregister a PPA client
|
||||
*
|
||||
* @param[in] ppa_invoker PPA invoker handle, allocated by `ppa_register_invoker`
|
||||
* @param[in] ppa_client PPA client handle, allocated by `ppa_register_client`
|
||||
* @return
|
||||
* - ESP_OK: Unregister the PPA invoker successfully
|
||||
* - ESP_ERR_INVALID_ARG: Unregister the PPA invoker failed because of invalid argument
|
||||
* - ESP_ERR_INVALID_STATE: Unregister the PPA invoker failed because there are unfinished transactions
|
||||
* - ESP_OK: Unregister the PPA client successfully
|
||||
* - ESP_ERR_INVALID_ARG: Unregister the PPA client failed because of invalid argument
|
||||
* - ESP_ERR_INVALID_STATE: Unregister the PPA client failed because there are unfinished transactions
|
||||
*/
|
||||
esp_err_t ppa_unregister_invoker(ppa_invoker_handle_t ppa_invoker);
|
||||
esp_err_t ppa_unregister_client(ppa_client_handle_t ppa_client);
|
||||
|
||||
/**
|
||||
* @brief A collection of configuration items for an input picture and the target block inside the picture
|
||||
@@ -158,77 +158,22 @@ typedef struct {
|
||||
When other alpha modes are selected, this field is not used */
|
||||
|
||||
ppa_trans_mode_t mode; /*!< Determines whether to block inside the operation functions, see `ppa_trans_mode_t` */
|
||||
// uint32_t timeout;
|
||||
void *user_data; /*!< User registered data to be passed into `done_cb` callback function */
|
||||
} ppa_srm_oper_trans_config_t;
|
||||
|
||||
/**
|
||||
* @brief A collection of configuration items to perform a PPA transaction
|
||||
*/
|
||||
typedef struct {
|
||||
ppa_trans_mode_t mode; /*!< Determines whether to block inside the operation functions, see `ppa_trans_mode_t` */
|
||||
void *user_data; /*!< User registered data to be passed into `done_cb` callback function */
|
||||
} ppa_trans_config_t;
|
||||
|
||||
/**
|
||||
* @brief A collection of configuration items to perform a PPA SRM operation
|
||||
*/
|
||||
typedef struct {
|
||||
void *in_buffer; /*!< TODO: could be a buffer list, link descriptors together, process a batch
|
||||
uint32_t batch_num; However, is it necessary? psram can not store too many pictures */
|
||||
uint32_t in_pic_w;
|
||||
uint32_t in_pic_h;
|
||||
uint32_t in_block_w;
|
||||
uint32_t in_block_h;
|
||||
uint32_t in_block_offset_x;
|
||||
uint32_t in_block_offset_y;
|
||||
|
||||
void *out_buffer;
|
||||
uint32_t out_buffer_size;
|
||||
uint32_t out_pic_w;
|
||||
uint32_t out_pic_h;
|
||||
uint32_t out_block_offset_x;
|
||||
uint32_t out_block_offset_y;
|
||||
|
||||
ppa_srm_rotation_angle_t rotation_angle;
|
||||
float scale_x;
|
||||
float scale_y;
|
||||
bool mirror_x;
|
||||
bool mirror_y;
|
||||
|
||||
struct {
|
||||
ppa_srm_color_mode_t mode;
|
||||
color_range_t yuv_range;
|
||||
color_conv_std_rgb_yuv_t yuv_std;
|
||||
bool rgb_swap;
|
||||
bool byte_swap;
|
||||
ppa_alpha_update_mode_t alpha_update_mode;
|
||||
uint32_t alpha_value; /*!< When PPA_ALPHA_FIX_VALUE mode is selected, alpha_value is the alpha value to be replaced with (output_alpha = alpha_value)
|
||||
When PPA_ALPHA_SCALE mode is selected, alpha_value/256 is the multiplier to the input alpha value (output_alpha = input_alpha * alpha_value / 256)
|
||||
When other alpha modes are selected, this field is not used */
|
||||
} in_color;
|
||||
|
||||
struct {
|
||||
ppa_srm_color_mode_t mode;
|
||||
color_range_t yuv_range;
|
||||
color_conv_std_rgb_yuv_t yuv_std;
|
||||
} out_color;
|
||||
} ppa_srm_operation_config_t;
|
||||
|
||||
/**
|
||||
* @brief Perform a scaling-rotating-mirroring (SRM) operation to a picture
|
||||
*
|
||||
* @param[in] ppa_invoker PPA invoker handle that has been registered to do SRM operations
|
||||
* @param[in] oper_config Pointer to a collection of configurations for the SRM operation, ppa_srm_operation_config_t
|
||||
* @param[in] trans_config Pointer to a collection of configurations for the transaction, ppa_trans_config_t
|
||||
* @param[in] ppa_client PPA client handle that has been registered to do SRM operations
|
||||
* @param[in] config Pointer to a collection of configurations for the SRM operation transaction, ppa_srm_oper_trans_config_t
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Perform a SRM operation successfully
|
||||
* - ESP_ERR_INVALID_ARG: Perform a SRM operation failed because of invalid argument
|
||||
* - ESP_ERR_NO_MEM: Perform a SRM operation failed because out of memory
|
||||
* - ESP_FAIL: Perform a SRM operation failed because the invoker cannot accept transaction now
|
||||
* - ESP_FAIL: Perform a SRM operation failed because the client cannot accept transaction now
|
||||
*/
|
||||
esp_err_t ppa_do_scale_rotate_mirror(ppa_invoker_handle_t ppa_invoker, const ppa_srm_operation_config_t *oper_config, const ppa_trans_config_t *trans_config);
|
||||
esp_err_t ppa_do_scale_rotate_mirror(ppa_client_handle_t ppa_client, const ppa_srm_oper_trans_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief A collection of configuration items to do a PPA blend operation transaction
|
||||
@@ -269,80 +214,22 @@ typedef struct {
|
||||
bool ck_reverse_bg2fg; /*!< If this bit is set, in color-keying, for the pixel, where its background element is in the color range, but its foreground element is not in the color range, it will output the foreground element instead of the background element */
|
||||
|
||||
ppa_trans_mode_t mode; /*!< Determines whether to block inside the operation functions, see `ppa_trans_mode_t` */
|
||||
// uint32_t timeout;
|
||||
void *user_data; /*!< User registered data to be passed into `done_cb` callback function */
|
||||
} ppa_blend_oper_trans_config_t;
|
||||
|
||||
/**
|
||||
* @brief A collection of configuration items to perform a PPA blend operation
|
||||
*/
|
||||
typedef struct {
|
||||
void *in_bg_buffer;
|
||||
uint32_t in_bg_pic_w;
|
||||
uint32_t in_bg_pic_h;
|
||||
uint32_t in_bg_block_offset_x;
|
||||
uint32_t in_bg_block_offset_y;
|
||||
|
||||
void *in_fg_buffer;
|
||||
uint32_t in_fg_pic_w;
|
||||
uint32_t in_fg_pic_h;
|
||||
uint32_t in_fg_block_offset_x;
|
||||
uint32_t in_fg_block_offset_y;
|
||||
|
||||
uint32_t in_bg_fg_block_w;
|
||||
uint32_t in_bg_fg_block_h;
|
||||
|
||||
void *out_buffer;
|
||||
uint32_t out_buffer_size;
|
||||
uint32_t out_pic_w;
|
||||
uint32_t out_pic_h;
|
||||
uint32_t out_block_offset_x;
|
||||
uint32_t out_block_offset_y;
|
||||
|
||||
struct {
|
||||
ppa_blend_color_mode_t mode;
|
||||
bool rgb_swap;
|
||||
bool byte_swap;
|
||||
ppa_alpha_update_mode_t alpha_update_mode;
|
||||
uint32_t alpha_value;
|
||||
bool ck_en;
|
||||
uint32_t ck_rgb_low_thres; /*!< In RGB888 format (R[23:16], G[15: 8], B[7:0]) */
|
||||
uint32_t ck_rgb_high_thres; /*!< In RGB888 format (R[23:16], G[15: 8], B[7:0]) */
|
||||
} in_bg_color;
|
||||
|
||||
struct {
|
||||
ppa_blend_color_mode_t mode;
|
||||
bool rgb_swap;
|
||||
bool byte_swap;
|
||||
ppa_alpha_update_mode_t alpha_update_mode;
|
||||
uint32_t alpha_value;
|
||||
uint32_t fix_rgb_val; /*!< When in_fg_color.mode is PPA_BLEND_COLOR_MODE_A8/4, this field can be used to set a fixed color for the foreground. In RGB888 format (R[23:16], G[15: 8], B[7:0]). */
|
||||
bool ck_en;
|
||||
uint32_t ck_rgb_low_thres; /*!< In RGB888 format (R[23:16], G[15: 8], B[7:0]) */
|
||||
uint32_t ck_rgb_high_thres; /*!< In RGB888 format (R[23:16], G[15: 8], B[7:0]) */
|
||||
} in_fg_color;
|
||||
|
||||
struct {
|
||||
ppa_blend_color_mode_t mode;
|
||||
uint32_t ck_rgb_default_val; /*!< In RGB888 format (R[23:16], G[15: 8], B[7:0]) */
|
||||
bool ck_reverse_bg2fg; /*!< If this bit is set, in color keying, for the pixel, where its BG element is in the color range, but its FG element is not in the color range, it will output the FG element instead of the BG element */
|
||||
} out_color;
|
||||
} ppa_blend_operation_config_t;
|
||||
|
||||
/**
|
||||
* @brief Perform a blending operation to a picture
|
||||
*
|
||||
* @param[in] ppa_invoker PPA invoker handle that has been registered to do blend operations
|
||||
* @param[in] oper_config Pointer to a collection of configurations for the blend operation, ppa_blend_operation_config_t
|
||||
* @param[in] trans_config Pointer to a collection of configurations for the transaction, ppa_trans_config_t
|
||||
* @param[in] ppa_client PPA client handle that has been registered to do blend operations
|
||||
* @param[in] config Pointer to a collection of configurations for the blend operation transaction, ppa_blend_oper_trans_config_t
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Perform a blend operation successfully
|
||||
* - ESP_ERR_INVALID_ARG: Perform a blend operation failed because of invalid argument
|
||||
* - ESP_ERR_NO_MEM: Perform a blend operation failed because out of memory
|
||||
* - ESP_FAIL: Perform a blend operation failed because the invoker cannot accept transaction now
|
||||
* - ESP_FAIL: Perform a blend operation failed because the client cannot accept transaction now
|
||||
*/
|
||||
esp_err_t ppa_do_blend(ppa_invoker_handle_t ppa_invoker, const ppa_blend_operation_config_t *oper_config, const ppa_trans_config_t *trans_config);
|
||||
esp_err_t ppa_do_blend(ppa_client_handle_t ppa_client, const ppa_blend_oper_trans_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief A collection of configuration items to do a PPA fill operation transaction
|
||||
@@ -355,44 +242,22 @@ typedef struct {
|
||||
uint32_t fill_argb_color; /*!< The color to be filled, in ARGB8888 format ((A[31:24], R[23:16], G[15: 8], B[7:0])) */
|
||||
|
||||
ppa_trans_mode_t mode; /*!< Determines whether to block inside the operation functions, see `ppa_trans_mode_t` */
|
||||
// uint32_t timeout;
|
||||
void *user_data; /*!< User registered data to be passed into `done_cb` callback function */
|
||||
} ppa_fill_oper_trans_config_t;
|
||||
|
||||
/**
|
||||
* @brief A collection of configuration items to perform a PPA fill operation
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t fill_block_w;
|
||||
uint32_t fill_block_h;
|
||||
uint32_t fill_argb_color; /*!< The color to be filled, in ARGB8888 format ((A[31:24], R[23:16], G[15: 8], B[7:0])) */
|
||||
|
||||
void *out_buffer;
|
||||
uint32_t out_buffer_size;
|
||||
uint32_t out_pic_w;
|
||||
uint32_t out_pic_h;
|
||||
uint32_t out_block_offset_x;
|
||||
uint32_t out_block_offset_y;
|
||||
|
||||
struct {
|
||||
ppa_blend_color_mode_t mode;
|
||||
} out_color;
|
||||
} ppa_fill_operation_config_t;
|
||||
|
||||
/**
|
||||
* @brief Perform a filling operation to a picture
|
||||
*
|
||||
* @param[in] ppa_invoker PPA invoker handle that has been registered to do fill operations
|
||||
* @param[in] oper_config Pointer to a collection of configurations for the fill operation, ppa_fill_operation_config_t
|
||||
* @param[in] trans_config Pointer to a collection of configurations for the transaction, ppa_trans_config_t
|
||||
* @param[in] ppa_client PPA client handle that has been registered to do fill operations
|
||||
* @param[in] config Pointer to a collection of configurations for the fill operation transaction, ppa_fill_oper_trans_config_t
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Perform a fill operation successfully
|
||||
* - ESP_ERR_INVALID_ARG: Perform a fill operation failed because of invalid argument
|
||||
* - ESP_ERR_NO_MEM: Perform a fill operation failed because out of memory
|
||||
* - ESP_FAIL: Perform a fill operation failed because the invoker cannot accept transaction now
|
||||
* - ESP_FAIL: Perform a fill operation failed because the client cannot accept transaction now
|
||||
*/
|
||||
esp_err_t ppa_do_fill(ppa_invoker_handle_t ppa_invoker, const ppa_fill_operation_config_t *oper_config, const ppa_trans_config_t *trans_config);
|
||||
esp_err_t ppa_do_fill(ppa_client_handle_t ppa_client, const ppa_fill_oper_trans_config_t *config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user