forked from espressif/esp-idf
feat(ppa): add PPA driver support for ESP32P4
Add out_buffer_size field to all oper_config_t Add strict check for out buffer addr and size alignment
This commit is contained in:
@@ -85,7 +85,8 @@ typedef struct {
|
|||||||
uint32_t in_block_offset_x; \
|
uint32_t in_block_offset_x; \
|
||||||
uint32_t in_block_offset_y; \
|
uint32_t in_block_offset_y; \
|
||||||
\
|
\
|
||||||
void *out_buffer; /*!< TODO: alignment restriction */ \
|
void *out_buffer; \
|
||||||
|
uint32_t out_buffer_size; \
|
||||||
uint32_t out_pic_w; \
|
uint32_t out_pic_w; \
|
||||||
uint32_t out_pic_h; \
|
uint32_t out_pic_h; \
|
||||||
uint32_t out_block_offset_x; \
|
uint32_t out_block_offset_x; \
|
||||||
@@ -103,7 +104,7 @@ typedef struct {
|
|||||||
color_conv_std_rgb_yuv_t yuv_std; \
|
color_conv_std_rgb_yuv_t yuv_std; \
|
||||||
bool rgb_swap; \
|
bool rgb_swap; \
|
||||||
bool byte_swap; \
|
bool byte_swap; \
|
||||||
ppa_alpha_mode_t alpha_mode; \
|
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)
|
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 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 */ \
|
When other alpha modes are selected, this field is not used */ \
|
||||||
@@ -153,6 +154,7 @@ typedef struct {
|
|||||||
uint32_t in_bg_fg_block_h;
|
uint32_t in_bg_fg_block_h;
|
||||||
|
|
||||||
void *out_buffer;
|
void *out_buffer;
|
||||||
|
uint32_t out_buffer_size;
|
||||||
uint32_t out_pic_w;
|
uint32_t out_pic_w;
|
||||||
uint32_t out_pic_h;
|
uint32_t out_pic_h;
|
||||||
uint32_t out_block_offset_x;
|
uint32_t out_block_offset_x;
|
||||||
@@ -162,7 +164,7 @@ typedef struct {
|
|||||||
ppa_blend_color_mode_t mode;
|
ppa_blend_color_mode_t mode;
|
||||||
bool rgb_swap;
|
bool rgb_swap;
|
||||||
bool byte_swap;
|
bool byte_swap;
|
||||||
ppa_alpha_mode_t alpha_mode;
|
ppa_alpha_update_mode_t alpha_update_mode;
|
||||||
uint32_t alpha_value;
|
uint32_t alpha_value;
|
||||||
bool ck_en;
|
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_low_thres; /*!< In RGB888 format (R[23:16], G[15: 8], B[7:0]) */
|
||||||
@@ -173,7 +175,7 @@ typedef struct {
|
|||||||
ppa_blend_color_mode_t mode;
|
ppa_blend_color_mode_t mode;
|
||||||
bool rgb_swap;
|
bool rgb_swap;
|
||||||
bool byte_swap;
|
bool byte_swap;
|
||||||
ppa_alpha_mode_t alpha_mode;
|
ppa_alpha_update_mode_t alpha_update_mode;
|
||||||
uint32_t alpha_value;
|
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]). */
|
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;
|
bool ck_en;
|
||||||
@@ -209,6 +211,7 @@ 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])) */
|
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;
|
void *out_buffer;
|
||||||
|
uint32_t out_buffer_size;
|
||||||
uint32_t out_pic_w;
|
uint32_t out_pic_w;
|
||||||
uint32_t out_pic_h;
|
uint32_t out_pic_h;
|
||||||
uint32_t out_block_offset_x;
|
uint32_t out_block_offset_x;
|
||||||
|
@@ -916,20 +916,9 @@ static bool ppa_srm_transaction_on_picked(uint32_t num_chans, const dma2d_trans_
|
|||||||
dma2d_channel_handle_t dma2d_tx_chan = dma2d_chans[dma2d_tx_chan_idx].chan;
|
dma2d_channel_handle_t dma2d_tx_chan = dma2d_chans[dma2d_tx_chan_idx].chan;
|
||||||
dma2d_channel_handle_t dma2d_rx_chan = dma2d_chans[dma2d_rx_chan_idx].chan;
|
dma2d_channel_handle_t dma2d_rx_chan = dma2d_chans[dma2d_rx_chan_idx].chan;
|
||||||
|
|
||||||
// Write back and invalidate are performed on the entire picture (the window content is not continuous in the buffer)
|
|
||||||
// Write back in_buffer
|
|
||||||
color_space_pixel_format_t in_pixel_format = {
|
color_space_pixel_format_t in_pixel_format = {
|
||||||
.color_type_id = srm_trans_desc->in_color.mode,
|
.color_type_id = srm_trans_desc->in_color.mode,
|
||||||
};
|
};
|
||||||
uint32_t in_buffer_len = srm_trans_desc->in_pic_w * srm_trans_desc->in_pic_h * color_hal_pixel_format_get_bit_depth(in_pixel_format) / 8;
|
|
||||||
esp_cache_msync(srm_trans_desc->in_buffer, in_buffer_len, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
|
||||||
// Invalidate out_buffer
|
|
||||||
color_space_pixel_format_t out_pixel_format = {
|
|
||||||
.color_type_id = srm_trans_desc->out_color.mode,
|
|
||||||
};
|
|
||||||
uint32_t out_buffer_len = srm_trans_desc->out_pic_w * srm_trans_desc->out_pic_h * color_hal_pixel_format_get_bit_depth(out_pixel_format) / 8;
|
|
||||||
out_buffer_len = ALIGN_UP(out_buffer_len, s_platform.buf_alignment_size);
|
|
||||||
esp_cache_msync(srm_trans_desc->out_buffer, out_buffer_len, ESP_CACHE_MSYNC_FLAG_DIR_M2C);
|
|
||||||
|
|
||||||
// Fill 2D-DMA descriptors
|
// Fill 2D-DMA descriptors
|
||||||
srm_engine->dma_tx_desc->vb_size = srm_trans_desc->in_block_h;
|
srm_engine->dma_tx_desc->vb_size = srm_trans_desc->in_block_h;
|
||||||
@@ -1037,7 +1026,7 @@ static bool ppa_srm_transaction_on_picked(uint32_t num_chans, const dma2d_trans_
|
|||||||
}
|
}
|
||||||
ppa_ll_srm_enable_rx_byte_swap(s_platform.hal.dev, srm_trans_desc->in_color.byte_swap);
|
ppa_ll_srm_enable_rx_byte_swap(s_platform.hal.dev, srm_trans_desc->in_color.byte_swap);
|
||||||
ppa_ll_srm_enable_rx_rgb_swap(s_platform.hal.dev, srm_trans_desc->in_color.rgb_swap);
|
ppa_ll_srm_enable_rx_rgb_swap(s_platform.hal.dev, srm_trans_desc->in_color.rgb_swap);
|
||||||
ppa_ll_srm_configure_rx_alpha(s_platform.hal.dev, srm_trans_desc->in_color.alpha_mode, srm_trans_desc->in_color.alpha_value);
|
ppa_ll_srm_configure_rx_alpha(s_platform.hal.dev, srm_trans_desc->in_color.alpha_update_mode, srm_trans_desc->in_color.alpha_value);
|
||||||
|
|
||||||
ppa_ll_srm_set_tx_color_mode(s_platform.hal.dev, ppa_out_color_mode);
|
ppa_ll_srm_set_tx_color_mode(s_platform.hal.dev, ppa_out_color_mode);
|
||||||
if (COLOR_SPACE_TYPE(ppa_out_color_mode) == COLOR_SPACE_YUV) {
|
if (COLOR_SPACE_TYPE(ppa_out_color_mode) == COLOR_SPACE_YUV) {
|
||||||
@@ -1066,9 +1055,15 @@ esp_err_t ppa_do_scale_rotate_mirror(ppa_invoker_handle_t ppa_invoker, const ppa
|
|||||||
ESP_RETURN_ON_FALSE(trans_config->mode <= PPA_TRANS_MODE_NON_BLOCKING, ESP_ERR_INVALID_ARG, TAG, "invalid mode");
|
ESP_RETURN_ON_FALSE(trans_config->mode <= PPA_TRANS_MODE_NON_BLOCKING, ESP_ERR_INVALID_ARG, TAG, "invalid mode");
|
||||||
// in_buffer could be anywhere (ram, flash, psram), out_buffer ptr cannot in flash region
|
// in_buffer could be anywhere (ram, flash, psram), out_buffer ptr cannot in flash region
|
||||||
ESP_RETURN_ON_FALSE(esp_ptr_internal(oper_config->out_buffer) || esp_ptr_external_ram(oper_config->out_buffer), ESP_ERR_INVALID_ARG, TAG, "invalid out_buffer addr");
|
ESP_RETURN_ON_FALSE(esp_ptr_internal(oper_config->out_buffer) || esp_ptr_external_ram(oper_config->out_buffer), ESP_ERR_INVALID_ARG, TAG, "invalid out_buffer addr");
|
||||||
ESP_RETURN_ON_FALSE((uintptr_t)oper_config->out_buffer % s_platform.buf_alignment_size == 0, ESP_ERR_INVALID_ARG, TAG, "out_buffer not aligned to cache line size");
|
ESP_RETURN_ON_FALSE((uintptr_t)oper_config->out_buffer % s_platform.buf_alignment_size == 0 && oper_config->out_buffer_size % s_platform.buf_alignment_size == 0,
|
||||||
// Any restrictions on in/out buffer address? alignment? alignment restriction comes from cache, its addr and size need to be aligned to cache line size on 912!
|
ESP_ERR_INVALID_ARG, TAG, "out_buffer addr or size not aligned to cache line size");
|
||||||
|
color_space_pixel_format_t out_pixel_format = {
|
||||||
|
.color_type_id = oper_config->out_color.mode,
|
||||||
|
};
|
||||||
|
uint32_t out_pic_len = oper_config->out_pic_w * oper_config->out_pic_h * color_hal_pixel_format_get_bit_depth(out_pixel_format) / 8;
|
||||||
|
ESP_RETURN_ON_FALSE(out_pic_len <= oper_config->out_buffer_size, ESP_ERR_INVALID_ARG, TAG, "out_pic_w/h mismatch with out_buffer_size");
|
||||||
// buffer on stack/heap
|
// buffer on stack/heap
|
||||||
|
// check scale w/ (out_pic_w/h - out_pic_offset_x/y)?
|
||||||
// ESP_RETURN_ON_FALSE(config->rotation_angle)
|
// ESP_RETURN_ON_FALSE(config->rotation_angle)
|
||||||
// ESP_RETURN_ON_FALSE(config->in/out_color_mode)
|
// ESP_RETURN_ON_FALSE(config->in/out_color_mode)
|
||||||
// what if in_color is YUV420, out is RGB, what is out RGB range? Full range?
|
// what if in_color is YUV420, out is RGB, what is out RGB range? Full range?
|
||||||
@@ -1079,7 +1074,15 @@ esp_err_t ppa_do_scale_rotate_mirror(ppa_invoker_handle_t ppa_invoker, const ppa
|
|||||||
|
|
||||||
// YUV420: in desc, ha/hb/va/vb/x/y must be even number
|
// YUV420: in desc, ha/hb/va/vb/x/y must be even number
|
||||||
|
|
||||||
// TODO: Maybe do buffer writeback and invalidation here, instead of in on_picked?
|
// Write back and invalidate are performed on the entire picture (the window content is not continuous in the buffer)
|
||||||
|
// Write back in_buffer
|
||||||
|
color_space_pixel_format_t in_pixel_format = {
|
||||||
|
.color_type_id = oper_config->in_color.mode,
|
||||||
|
};
|
||||||
|
uint32_t in_pic_len = oper_config->in_pic_w * oper_config->in_pic_h * color_hal_pixel_format_get_bit_depth(in_pixel_format) / 8;
|
||||||
|
esp_cache_msync(oper_config->in_buffer, in_pic_len, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
||||||
|
// Invalidate out_buffer
|
||||||
|
esp_cache_msync(oper_config->out_buffer, oper_config->out_buffer_size, ESP_CACHE_MSYNC_FLAG_DIR_M2C);
|
||||||
|
|
||||||
ppa_trans_t *trans_elm = NULL;
|
ppa_trans_t *trans_elm = NULL;
|
||||||
esp_err_t ret = ppa_prepare_trans_elm(ppa_invoker, ppa_invoker->srm_engine, PPA_OPERATION_SRM, (void *)oper_config, trans_config->mode, &trans_elm);
|
esp_err_t ret = ppa_prepare_trans_elm(ppa_invoker, ppa_invoker->srm_engine, PPA_OPERATION_SRM, (void *)oper_config, trans_config->mode, &trans_elm);
|
||||||
@@ -1132,25 +1135,15 @@ static bool ppa_blend_transaction_on_picked(uint32_t num_chans, const dma2d_tran
|
|||||||
}
|
}
|
||||||
assert(dma2d_tx_bg_chan && dma2d_tx_fg_chan && dma2d_rx_chan);
|
assert(dma2d_tx_bg_chan && dma2d_tx_fg_chan && dma2d_rx_chan);
|
||||||
|
|
||||||
// Write back and invalidate are performed on the entire picture (the window content is not continuous in the buffer)
|
|
||||||
// Write back in_bg_buffer, in_fg_buffer
|
|
||||||
color_space_pixel_format_t in_bg_pixel_format = {
|
color_space_pixel_format_t in_bg_pixel_format = {
|
||||||
.color_type_id = blend_trans_desc->in_bg_color.mode,
|
.color_type_id = blend_trans_desc->in_bg_color.mode,
|
||||||
};
|
};
|
||||||
uint32_t in_bg_buffer_len = blend_trans_desc->in_bg_pic_w * blend_trans_desc->in_bg_pic_h * color_hal_pixel_format_get_bit_depth(in_bg_pixel_format) / 8;
|
|
||||||
esp_cache_msync(blend_trans_desc->in_bg_buffer, in_bg_buffer_len, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
|
||||||
color_space_pixel_format_t in_fg_pixel_format = {
|
color_space_pixel_format_t in_fg_pixel_format = {
|
||||||
.color_type_id = blend_trans_desc->in_fg_color.mode,
|
.color_type_id = blend_trans_desc->in_fg_color.mode,
|
||||||
};
|
};
|
||||||
uint32_t in_fg_buffer_len = blend_trans_desc->in_fg_pic_w * blend_trans_desc->in_fg_pic_h * color_hal_pixel_format_get_bit_depth(in_fg_pixel_format) / 8;
|
|
||||||
esp_cache_msync(blend_trans_desc->in_fg_buffer, in_fg_buffer_len, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
|
||||||
// Invalidate out_buffer
|
|
||||||
color_space_pixel_format_t out_pixel_format = {
|
color_space_pixel_format_t out_pixel_format = {
|
||||||
.color_type_id = blend_trans_desc->out_color.mode,
|
.color_type_id = blend_trans_desc->out_color.mode,
|
||||||
};
|
};
|
||||||
uint32_t out_buffer_len = blend_trans_desc->out_pic_w * blend_trans_desc->out_pic_h * color_hal_pixel_format_get_bit_depth(out_pixel_format) / 8;
|
|
||||||
out_buffer_len = ALIGN_UP(out_buffer_len, s_platform.buf_alignment_size);
|
|
||||||
esp_cache_msync(blend_trans_desc->out_buffer, out_buffer_len, ESP_CACHE_MSYNC_FLAG_DIR_M2C);
|
|
||||||
|
|
||||||
// Fill 2D-DMA descriptors
|
// Fill 2D-DMA descriptors
|
||||||
blend_engine->dma_tx_bg_desc->vb_size = blend_trans_desc->in_bg_fg_block_h;
|
blend_engine->dma_tx_bg_desc->vb_size = blend_trans_desc->in_bg_fg_block_h;
|
||||||
@@ -1244,7 +1237,7 @@ static bool ppa_blend_transaction_on_picked(uint32_t num_chans, const dma2d_tran
|
|||||||
ppa_ll_blend_set_rx_bg_color_mode(s_platform.hal.dev, blend_trans_desc->in_bg_color.mode);
|
ppa_ll_blend_set_rx_bg_color_mode(s_platform.hal.dev, blend_trans_desc->in_bg_color.mode);
|
||||||
ppa_ll_blend_enable_rx_bg_byte_swap(s_platform.hal.dev, blend_trans_desc->in_bg_color.byte_swap);
|
ppa_ll_blend_enable_rx_bg_byte_swap(s_platform.hal.dev, blend_trans_desc->in_bg_color.byte_swap);
|
||||||
ppa_ll_blend_enable_rx_bg_rgb_swap(s_platform.hal.dev, blend_trans_desc->in_bg_color.rgb_swap);
|
ppa_ll_blend_enable_rx_bg_rgb_swap(s_platform.hal.dev, blend_trans_desc->in_bg_color.rgb_swap);
|
||||||
ppa_ll_blend_configure_rx_bg_alpha(s_platform.hal.dev, blend_trans_desc->in_bg_color.alpha_mode, blend_trans_desc->in_bg_color.alpha_value);
|
ppa_ll_blend_configure_rx_bg_alpha(s_platform.hal.dev, blend_trans_desc->in_bg_color.alpha_update_mode, blend_trans_desc->in_bg_color.alpha_value);
|
||||||
|
|
||||||
ppa_ll_blend_set_rx_fg_color_mode(s_platform.hal.dev, blend_trans_desc->in_fg_color.mode);
|
ppa_ll_blend_set_rx_fg_color_mode(s_platform.hal.dev, blend_trans_desc->in_fg_color.mode);
|
||||||
if (COLOR_SPACE_TYPE(blend_trans_desc->in_fg_color.mode) == COLOR_SPACE_ALPHA) {
|
if (COLOR_SPACE_TYPE(blend_trans_desc->in_fg_color.mode) == COLOR_SPACE_ALPHA) {
|
||||||
@@ -1252,7 +1245,7 @@ static bool ppa_blend_transaction_on_picked(uint32_t num_chans, const dma2d_tran
|
|||||||
}
|
}
|
||||||
ppa_ll_blend_enable_rx_fg_byte_swap(s_platform.hal.dev, blend_trans_desc->in_fg_color.byte_swap);
|
ppa_ll_blend_enable_rx_fg_byte_swap(s_platform.hal.dev, blend_trans_desc->in_fg_color.byte_swap);
|
||||||
ppa_ll_blend_enable_rx_fg_rgb_swap(s_platform.hal.dev, blend_trans_desc->in_fg_color.rgb_swap);
|
ppa_ll_blend_enable_rx_fg_rgb_swap(s_platform.hal.dev, blend_trans_desc->in_fg_color.rgb_swap);
|
||||||
ppa_ll_blend_configure_rx_fg_alpha(s_platform.hal.dev, blend_trans_desc->in_fg_color.alpha_mode, blend_trans_desc->in_fg_color.alpha_value);
|
ppa_ll_blend_configure_rx_fg_alpha(s_platform.hal.dev, blend_trans_desc->in_fg_color.alpha_update_mode, blend_trans_desc->in_fg_color.alpha_value);
|
||||||
|
|
||||||
ppa_ll_blend_set_tx_color_mode(s_platform.hal.dev, blend_trans_desc->out_color.mode);
|
ppa_ll_blend_set_tx_color_mode(s_platform.hal.dev, blend_trans_desc->out_color.mode);
|
||||||
|
|
||||||
@@ -1279,12 +1272,30 @@ esp_err_t ppa_do_blend(ppa_invoker_handle_t ppa_invoker, const ppa_blend_operati
|
|||||||
ESP_RETURN_ON_FALSE(trans_config->mode <= PPA_TRANS_MODE_NON_BLOCKING, ESP_ERR_INVALID_ARG, TAG, "invalid mode");
|
ESP_RETURN_ON_FALSE(trans_config->mode <= PPA_TRANS_MODE_NON_BLOCKING, ESP_ERR_INVALID_ARG, TAG, "invalid mode");
|
||||||
// in_buffer could be anywhere (ram, flash, psram), out_buffer ptr cannot in flash region
|
// in_buffer could be anywhere (ram, flash, psram), out_buffer ptr cannot in flash region
|
||||||
ESP_RETURN_ON_FALSE(esp_ptr_internal(oper_config->out_buffer) || esp_ptr_external_ram(oper_config->out_buffer), ESP_ERR_INVALID_ARG, TAG, "invalid out_buffer addr");
|
ESP_RETURN_ON_FALSE(esp_ptr_internal(oper_config->out_buffer) || esp_ptr_external_ram(oper_config->out_buffer), ESP_ERR_INVALID_ARG, TAG, "invalid out_buffer addr");
|
||||||
ESP_RETURN_ON_FALSE((uintptr_t)oper_config->out_buffer % s_platform.buf_alignment_size == 0, ESP_ERR_INVALID_ARG, TAG, "out_buffer not aligned to cache line size");
|
ESP_RETURN_ON_FALSE((uintptr_t)oper_config->out_buffer % s_platform.buf_alignment_size == 0 && oper_config->out_buffer_size % s_platform.buf_alignment_size == 0,
|
||||||
// TODO: Check out_buffer size alignment to cacheline? Since invalidate cannot use ESP_CACHE_MSYNC_FLAG_UNALIGNED.
|
ESP_ERR_INVALID_ARG, TAG, "out_buffer addr or size not aligned to cache line size");
|
||||||
|
color_space_pixel_format_t out_pixel_format = {
|
||||||
|
.color_type_id = oper_config->out_color.mode,
|
||||||
|
};
|
||||||
|
uint32_t out_pic_len = oper_config->out_pic_w * oper_config->out_pic_h * color_hal_pixel_format_get_bit_depth(out_pixel_format) / 8;
|
||||||
|
ESP_RETURN_ON_FALSE(out_pic_len <= oper_config->out_buffer_size, ESP_ERR_INVALID_ARG, TAG, "out_pic_w/h mismatch with out_buffer_size");
|
||||||
// TODO: ARG CHECK
|
// TODO: ARG CHECK
|
||||||
// 当输入类型为 L4、A4 时,图像块的尺寸 hb 以及在图像中的偏移 x 必须为偶数
|
// 当输入类型为 L4、A4 时,图像块的尺寸 hb 以及在图像中的偏移 x 必须为偶数
|
||||||
|
|
||||||
// TODO: Maybe do buffer writeback and invalidation here, instead of in on_picked?
|
// Write back and invalidate are performed on the entire picture (the window content is not continuous in the buffer)
|
||||||
|
// Write back in_bg_buffer, in_fg_buffer
|
||||||
|
color_space_pixel_format_t in_bg_pixel_format = {
|
||||||
|
.color_type_id = oper_config->in_bg_color.mode,
|
||||||
|
};
|
||||||
|
uint32_t in_bg_pic_len = oper_config->in_bg_pic_w * oper_config->in_bg_pic_h * color_hal_pixel_format_get_bit_depth(in_bg_pixel_format) / 8;
|
||||||
|
esp_cache_msync(oper_config->in_bg_buffer, in_bg_pic_len, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
||||||
|
color_space_pixel_format_t in_fg_pixel_format = {
|
||||||
|
.color_type_id = oper_config->in_fg_color.mode,
|
||||||
|
};
|
||||||
|
uint32_t in_fg_pic_len = oper_config->in_fg_pic_w * oper_config->in_fg_pic_h * color_hal_pixel_format_get_bit_depth(in_fg_pixel_format) / 8;
|
||||||
|
esp_cache_msync(oper_config->in_fg_buffer, in_fg_pic_len, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
||||||
|
// Invalidate out_buffer
|
||||||
|
esp_cache_msync(oper_config->out_buffer, oper_config->out_buffer_size, ESP_CACHE_MSYNC_FLAG_DIR_M2C);
|
||||||
|
|
||||||
ppa_trans_t *trans_elm = NULL;
|
ppa_trans_t *trans_elm = NULL;
|
||||||
esp_err_t ret = ppa_prepare_trans_elm(ppa_invoker, ppa_invoker->blending_engine, PPA_OPERATION_BLEND, (void *)oper_config, trans_config->mode, &trans_elm);
|
esp_err_t ret = ppa_prepare_trans_elm(ppa_invoker, ppa_invoker->blending_engine, PPA_OPERATION_BLEND, (void *)oper_config, trans_config->mode, &trans_elm);
|
||||||
@@ -1315,14 +1326,9 @@ static bool ppa_fill_transaction_on_picked(uint32_t num_chans, const dma2d_trans
|
|||||||
assert(dma2d_chans[0].dir == DMA2D_CHANNEL_DIRECTION_RX);
|
assert(dma2d_chans[0].dir == DMA2D_CHANNEL_DIRECTION_RX);
|
||||||
dma2d_channel_handle_t dma2d_rx_chan = dma2d_chans[0].chan;
|
dma2d_channel_handle_t dma2d_rx_chan = dma2d_chans[0].chan;
|
||||||
|
|
||||||
// Invalidate is performed on the entire picture (the window content is not continuous in the buffer)
|
|
||||||
color_space_pixel_format_t out_pixel_format = {
|
color_space_pixel_format_t out_pixel_format = {
|
||||||
.color_type_id = fill_trans_desc->out_color.mode,
|
.color_type_id = fill_trans_desc->out_color.mode,
|
||||||
};
|
};
|
||||||
uint32_t out_buffer_len = fill_trans_desc->out_pic_w * fill_trans_desc->out_pic_h * color_hal_pixel_format_get_bit_depth(out_pixel_format) / 8;
|
|
||||||
esp_cache_msync(fill_trans_desc->out_buffer, out_buffer_len, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
|
||||||
out_buffer_len = ALIGN_UP(out_buffer_len, s_platform.buf_alignment_size);
|
|
||||||
esp_cache_msync(fill_trans_desc->out_buffer, out_buffer_len, ESP_CACHE_MSYNC_FLAG_DIR_M2C);
|
|
||||||
|
|
||||||
// Fill 2D-DMA descriptors
|
// Fill 2D-DMA descriptors
|
||||||
blend_engine->dma_rx_desc->vb_size = fill_trans_desc->fill_block_h;
|
blend_engine->dma_rx_desc->vb_size = fill_trans_desc->fill_block_h;
|
||||||
@@ -1383,11 +1389,18 @@ esp_err_t ppa_do_fill(ppa_invoker_handle_t ppa_invoker, const ppa_fill_operation
|
|||||||
ESP_RETURN_ON_FALSE(trans_config->mode <= PPA_TRANS_MODE_NON_BLOCKING, ESP_ERR_INVALID_ARG, TAG, "invalid mode");
|
ESP_RETURN_ON_FALSE(trans_config->mode <= PPA_TRANS_MODE_NON_BLOCKING, ESP_ERR_INVALID_ARG, TAG, "invalid mode");
|
||||||
// out_buffer ptr cannot in flash region
|
// out_buffer ptr cannot in flash region
|
||||||
ESP_RETURN_ON_FALSE(esp_ptr_internal(oper_config->out_buffer) || esp_ptr_external_ram(oper_config->out_buffer), ESP_ERR_INVALID_ARG, TAG, "invalid out_buffer addr");
|
ESP_RETURN_ON_FALSE(esp_ptr_internal(oper_config->out_buffer) || esp_ptr_external_ram(oper_config->out_buffer), ESP_ERR_INVALID_ARG, TAG, "invalid out_buffer addr");
|
||||||
ESP_RETURN_ON_FALSE((uintptr_t)oper_config->out_buffer % s_platform.buf_alignment_size == 0, ESP_ERR_INVALID_ARG, TAG, "out_buffer not aligned to cache line size");
|
ESP_RETURN_ON_FALSE((uintptr_t)oper_config->out_buffer % s_platform.buf_alignment_size == 0 && oper_config->out_buffer_size % s_platform.buf_alignment_size == 0,
|
||||||
|
ESP_ERR_INVALID_ARG, TAG, "out_buffer addr or size not aligned to cache line size");
|
||||||
|
color_space_pixel_format_t out_pixel_format = {
|
||||||
|
.color_type_id = oper_config->out_color.mode,
|
||||||
|
};
|
||||||
|
uint32_t out_pic_len = oper_config->out_pic_w * oper_config->out_pic_h * color_hal_pixel_format_get_bit_depth(out_pixel_format) / 8;
|
||||||
|
ESP_RETURN_ON_FALSE(out_pic_len <= oper_config->out_buffer_size, ESP_ERR_INVALID_ARG, TAG, "out_pic_w/h mismatch with out_buffer_size");
|
||||||
// TODO: ARG CHECK
|
// TODO: ARG CHECK
|
||||||
// fill_block_w <= PPA_BLEND_HB_V, fill_block_h <= PPA_BLEND_VB_V
|
// fill_block_w <= PPA_BLEND_HB_V, fill_block_h <= PPA_BLEND_VB_V
|
||||||
|
|
||||||
// TODO: Maybe do buffer writeback and invalidation here, instead of in on_picked?
|
// Write back and invalidate are performed on the entire picture (the window content is not continuous in the buffer)
|
||||||
|
esp_cache_msync(oper_config->out_buffer, oper_config->out_buffer_size, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_INVALIDATE);
|
||||||
|
|
||||||
ppa_trans_t *trans_elm = NULL;
|
ppa_trans_t *trans_elm = NULL;
|
||||||
esp_err_t ret = ppa_prepare_trans_elm(ppa_invoker, ppa_invoker->blending_engine, PPA_OPERATION_FILL, (void *)oper_config, trans_config->mode, &trans_elm);
|
esp_err_t ret = ppa_prepare_trans_elm(ppa_invoker, ppa_invoker->blending_engine, PPA_OPERATION_FILL, (void *)oper_config, trans_config->mode, &trans_elm);
|
||||||
|
@@ -332,15 +332,15 @@ static inline void ppa_ll_srm_enable_rx_byte_swap(ppa_dev_t *dev, bool enable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Configure PPA SRM alpha value transformation mode
|
* @brief Configure PPA SRM alpha value update mode
|
||||||
*
|
*
|
||||||
* @param dev Peripheral instance address
|
* @param dev Peripheral instance address
|
||||||
* @param mode Alpha value transformation mode, one of the values in ppa_alpha_mode_t
|
* @param mode Alpha value update mode, one of the values in ppa_alpha_update_mode_t
|
||||||
* @param val When PPA_ALPHA_FIX_VALUE mode is selected, val is the alpha value to be replaced with (output_alpha = val)
|
* @param val When PPA_ALPHA_FIX_VALUE mode is selected, val is the alpha value to be replaced with (output_alpha = val)
|
||||||
* When PPA_ALPHA_SCALE mode is selected, val/256 is the multiplier to the input alpha value (output_alpha = input_alpha * val / 256)
|
* When PPA_ALPHA_SCALE mode is selected, val/256 is the multiplier to the input alpha value (output_alpha = input_alpha * val / 256)
|
||||||
* When other modes are selected, this field is not used
|
* When other modes are selected, this field is not used
|
||||||
*/
|
*/
|
||||||
static inline void ppa_ll_srm_configure_rx_alpha(ppa_dev_t *dev, ppa_alpha_mode_t mode, uint32_t val)
|
static inline void ppa_ll_srm_configure_rx_alpha(ppa_dev_t *dev, ppa_alpha_update_mode_t mode, uint32_t val)
|
||||||
{
|
{
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case PPA_ALPHA_NO_CHANGE:
|
case PPA_ALPHA_NO_CHANGE:
|
||||||
@@ -362,7 +362,7 @@ static inline void ppa_ll_srm_configure_rx_alpha(ppa_dev_t *dev, ppa_alpha_mode_
|
|||||||
dev->sr_fix_alpha.sr_rx_alpha_inv = 1;
|
dev->sr_fix_alpha.sr_rx_alpha_inv = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Unsupported alpha transformation mode
|
// Unsupported alpha update mode
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -561,15 +561,15 @@ static inline void ppa_ll_blend_enable_rx_fg_byte_swap(ppa_dev_t *dev, bool enab
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Configure PPA blending input background alpha value transformation mode
|
* @brief Configure PPA blending input background alpha value update mode
|
||||||
*
|
*
|
||||||
* @param dev Peripheral instance address
|
* @param dev Peripheral instance address
|
||||||
* @param mode Alpha value transformation mode, one of the values in ppa_alpha_mode_t
|
* @param mode Alpha value update mode, one of the values in ppa_alpha_update_mode_t
|
||||||
* @param val When PPA_ALPHA_FIX_VALUE mode is selected, val is the alpha value to be replaced with (output_alpha = val)
|
* @param val When PPA_ALPHA_FIX_VALUE mode is selected, val is the alpha value to be replaced with (output_alpha = val)
|
||||||
* When PPA_ALPHA_SCALE mode is selected, val/256 is the multiplier to the input alpha value (output_alpha = input_alpha * val / 256)
|
* When PPA_ALPHA_SCALE mode is selected, val/256 is the multiplier to the input alpha value (output_alpha = input_alpha * val / 256)
|
||||||
* When other modes are selected, this field is not used
|
* When other modes are selected, this field is not used
|
||||||
*/
|
*/
|
||||||
static inline void ppa_ll_blend_configure_rx_bg_alpha(ppa_dev_t *dev, ppa_alpha_mode_t mode, uint32_t val)
|
static inline void ppa_ll_blend_configure_rx_bg_alpha(ppa_dev_t *dev, ppa_alpha_update_mode_t mode, uint32_t val)
|
||||||
{
|
{
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case PPA_ALPHA_NO_CHANGE:
|
case PPA_ALPHA_NO_CHANGE:
|
||||||
@@ -591,21 +591,21 @@ static inline void ppa_ll_blend_configure_rx_bg_alpha(ppa_dev_t *dev, ppa_alpha_
|
|||||||
dev->blend_fix_alpha.blend0_rx_alpha_inv = 1;
|
dev->blend_fix_alpha.blend0_rx_alpha_inv = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Unsupported alpha transformation mode
|
// Unsupported alpha update mode
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Configure PPA blending input foreground alpha value transformation mode
|
* @brief Configure PPA blending input foreground alpha value update mode
|
||||||
*
|
*
|
||||||
* @param dev Peripheral instance address
|
* @param dev Peripheral instance address
|
||||||
* @param mode Alpha value transformation mode, one of the values in ppa_alpha_mode_t
|
* @param mode Alpha value update mode, one of the values in ppa_alpha_update_mode_t
|
||||||
* @param val When PPA_ALPHA_FIX_VALUE mode is selected, val is the alpha value to be replaced with (output_alpha = val)
|
* @param val When PPA_ALPHA_FIX_VALUE mode is selected, val is the alpha value to be replaced with (output_alpha = val)
|
||||||
* When PPA_ALPHA_SCALE mode is selected, val/256 is the multiplier to the input alpha value (output_alpha = input_alpha * val / 256)
|
* When PPA_ALPHA_SCALE mode is selected, val/256 is the multiplier to the input alpha value (output_alpha = input_alpha * val / 256)
|
||||||
* When other modes are selected, this field is not used
|
* When other modes are selected, this field is not used
|
||||||
*/
|
*/
|
||||||
static inline void ppa_ll_blend_configure_rx_fg_alpha(ppa_dev_t *dev, ppa_alpha_mode_t mode, uint32_t val)
|
static inline void ppa_ll_blend_configure_rx_fg_alpha(ppa_dev_t *dev, ppa_alpha_update_mode_t mode, uint32_t val)
|
||||||
{
|
{
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case PPA_ALPHA_NO_CHANGE:
|
case PPA_ALPHA_NO_CHANGE:
|
||||||
@@ -627,7 +627,7 @@ static inline void ppa_ll_blend_configure_rx_fg_alpha(ppa_dev_t *dev, ppa_alpha_
|
|||||||
dev->blend_fix_alpha.blend1_rx_alpha_inv = 1;
|
dev->blend_fix_alpha.blend1_rx_alpha_inv = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Unsupported alpha transformation mode
|
// Unsupported alpha update mode
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -60,14 +60,14 @@ typedef enum {
|
|||||||
} ppa_blend_color_mode_t;
|
} ppa_blend_color_mode_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enumeration of PPA alpha compositing mode
|
* @brief Enumeration of PPA alpha compositing update mode
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PPA_ALPHA_NO_CHANGE = 0, /*!< Do not replace alpha value. If input format does not contain alpha info, alpha value 255 will be used. */
|
PPA_ALPHA_NO_CHANGE = 0, /*!< Do not replace alpha value. If input format does not contain alpha info, alpha value 255 will be used. */
|
||||||
PPA_ALPHA_FIX_VALUE, /*!< Replace the alpha value in received pixel with a new, fixed alpha value */
|
PPA_ALPHA_FIX_VALUE, /*!< Replace the alpha value in received pixel with a new, fixed alpha value */
|
||||||
PPA_ALPHA_SCALE, /*!< Scale the alpha value in received pixel to be a new alpha value */
|
PPA_ALPHA_SCALE, /*!< Scale the alpha value in received pixel to be a new alpha value */
|
||||||
PPA_ALPHA_INVERT, /*!< Invert the alpha value in received pixel */
|
PPA_ALPHA_INVERT, /*!< Invert the alpha value in received pixel */
|
||||||
} ppa_alpha_mode_t;
|
} ppa_alpha_update_mode_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user