mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
refactor(ppa): use fourcc for dma2d and ppa color formats
This commit is contained in:
@@ -19,8 +19,8 @@ extern "C" {
|
||||
* @brief Enumeration for jpeg output format.
|
||||
*/
|
||||
typedef enum {
|
||||
JPEG_DECODE_OUT_FORMAT_RGB888 = ESP_COLOR_FOURCC_RGB24, /*!< output RGB888 format */
|
||||
JPEG_DECODE_OUT_FORMAT_RGB565 = ESP_COLOR_FOURCC_RGB16_BE, /*!< output RGB565 format */
|
||||
JPEG_DECODE_OUT_FORMAT_RGB888 = ESP_COLOR_FOURCC_BGR24, /*!< output RGB888 format */
|
||||
JPEG_DECODE_OUT_FORMAT_RGB565 = ESP_COLOR_FOURCC_RGB16, /*!< output RGB565 format */
|
||||
JPEG_DECODE_OUT_FORMAT_GRAY = ESP_COLOR_FOURCC_GREY, /*!< output the gray picture */
|
||||
JPEG_DECODE_OUT_FORMAT_YUV444 = ESP_COLOR_FOURCC_YUV, /*!< output yuv444 format */
|
||||
JPEG_DECODE_OUT_FORMAT_YUV422 = ESP_COLOR_FOURCC_YVYU, /*!< output yuv422 format */
|
||||
@@ -55,8 +55,8 @@ typedef enum {
|
||||
* @brief Enumeration for jpeg input format.
|
||||
*/
|
||||
typedef enum {
|
||||
JPEG_ENCODE_IN_FORMAT_RGB888 = ESP_COLOR_FOURCC_RGB24, /*!< input RGB888 format */
|
||||
JPEG_ENCODE_IN_FORMAT_RGB565 = ESP_COLOR_FOURCC_RGB16_BE, /*!< input RGB565 format */
|
||||
JPEG_ENCODE_IN_FORMAT_RGB888 = ESP_COLOR_FOURCC_BGR24, /*!< input RGB888 format */
|
||||
JPEG_ENCODE_IN_FORMAT_RGB565 = ESP_COLOR_FOURCC_RGB16, /*!< input RGB565 format */
|
||||
JPEG_ENCODE_IN_FORMAT_GRAY = ESP_COLOR_FOURCC_GREY, /*!< input GRAY format */
|
||||
JPEG_ENCODE_IN_FORMAT_YUV422 = ESP_COLOR_FOURCC_YVYU, /*!< input YUV422 format */
|
||||
#if !(CONFIG_ESP_REV_MIN_FULL < 300 && SOC_IS(ESP32P4)) // Invisible for unsupported chips
|
||||
|
||||
@@ -439,7 +439,7 @@ static esp_err_t jpeg_dec_config_dma_descriptor(jpeg_decoder_handle_t decoder_en
|
||||
cfg_desc(decoder_engine, decoder_engine->txlink, JPEG_DMA2D_2D_DISABLE, DMA2D_DESCRIPTOR_BLOCK_RW_MODE_SINGLE, decoder_engine->header_info->buffer_left & JPEG_DMA2D_MAX_SIZE, decoder_engine->header_info->buffer_left & JPEG_DMA2D_MAX_SIZE, JPEG_DMA2D_EOF_NOT_LAST, 1, DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA, (decoder_engine->header_info->buffer_left >> JPEG_DMA2D_1D_HIGH_14BIT), (decoder_engine->header_info->buffer_left >> JPEG_DMA2D_1D_HIGH_14BIT), decoder_engine->header_info->buffer_offset, NULL);
|
||||
|
||||
// Configure rx link descriptor
|
||||
cfg_desc(decoder_engine, decoder_engine->rxlink, JPEG_DMA2D_2D_ENABLE, DMA2D_DESCRIPTOR_BLOCK_RW_MODE_MULTIPLE, dma_vb, dma_hb, JPEG_DMA2D_EOF_NOT_LAST, dma2d_desc_pixel_format_to_pbyte_value_fourcc(decoder_engine->output_format), DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA, decoder_engine->header_info->process_v, decoder_engine->header_info->process_h, decoder_engine->decoded_buf, NULL);
|
||||
cfg_desc(decoder_engine, decoder_engine->rxlink, JPEG_DMA2D_2D_ENABLE, DMA2D_DESCRIPTOR_BLOCK_RW_MODE_MULTIPLE, dma_vb, dma_hb, JPEG_DMA2D_EOF_NOT_LAST, dma2d_desc_pixel_format_to_pbyte_value(decoder_engine->output_format), DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA, decoder_engine->header_info->process_v, decoder_engine->header_info->process_h, decoder_engine->decoded_buf, NULL);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
|
||||
|
||||
// 2D direction
|
||||
memset(encoder_engine->txlink, 0, sizeof(dma2d_descriptor_t));
|
||||
s_cfg_desc(encoder_engine, encoder_engine->txlink, JPEG_DMA2D_2D_ENABLE, DMA2D_DESCRIPTOR_BLOCK_RW_MODE_MULTIPLE, dma_vb, dma_hb, JPEG_DMA2D_EOF_NOT_LAST, dma2d_desc_pixel_format_to_pbyte_value_fourcc(encoder_engine->picture_format), DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA, encoder_engine->header_info->origin_v, encoder_engine->header_info->origin_h, raw_buffer, NULL);
|
||||
s_cfg_desc(encoder_engine, encoder_engine->txlink, JPEG_DMA2D_2D_ENABLE, DMA2D_DESCRIPTOR_BLOCK_RW_MODE_MULTIPLE, dma_vb, dma_hb, JPEG_DMA2D_EOF_NOT_LAST, dma2d_desc_pixel_format_to_pbyte_value(encoder_engine->picture_format), DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA, encoder_engine->header_info->origin_v, encoder_engine->header_info->origin_h, raw_buffer, NULL);
|
||||
|
||||
ret = esp_cache_msync((void*)raw_buffer, inbuf_size, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
||||
assert(ret == ESP_OK);
|
||||
|
||||
@@ -127,7 +127,6 @@ typedef struct {
|
||||
};
|
||||
ppa_color_range_t yuv_range; /*!< When the color mode is any YUV color space, this field is to describe its color range */
|
||||
ppa_color_conv_std_rgb_yuv_t yuv_std; /*!< When the color mode is any YUV color space, this field is to describe its YUV<->RGB conversion standard */
|
||||
color_yuv422_pack_order_t yuv422_pack_order; /*!< When the color mode is YUV422, this field is to describe its data pack order */
|
||||
} ppa_in_pic_blk_config_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,16 +46,6 @@ bool ppa_blend_transaction_on_picked(uint32_t num_chans, const dma2d_trans_chann
|
||||
}
|
||||
assert(dma2d_tx_bg_chan && dma2d_tx_fg_chan && dma2d_rx_chan);
|
||||
|
||||
color_space_pixel_format_t in_bg_pixel_format = {
|
||||
.color_type_id = blend_trans_desc->in_bg.blend_cm,
|
||||
};
|
||||
color_space_pixel_format_t in_fg_pixel_format = {
|
||||
.color_type_id = blend_trans_desc->in_fg.blend_cm,
|
||||
};
|
||||
color_space_pixel_format_t out_pixel_format = {
|
||||
.color_type_id = blend_trans_desc->out.blend_cm,
|
||||
};
|
||||
|
||||
// Fill 2D-DMA descriptors
|
||||
blend_engine->dma_tx_bg_desc->vb_size = blend_trans_desc->in_bg.block_h;
|
||||
blend_engine->dma_tx_bg_desc->hb_length = blend_trans_desc->in_bg.block_w;
|
||||
@@ -65,7 +55,7 @@ bool ppa_blend_transaction_on_picked(uint32_t num_chans, const dma2d_trans_chann
|
||||
blend_engine->dma_tx_bg_desc->owner = DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA;
|
||||
blend_engine->dma_tx_bg_desc->va_size = blend_trans_desc->in_bg.pic_h;
|
||||
blend_engine->dma_tx_bg_desc->ha_length = blend_trans_desc->in_bg.pic_w;
|
||||
blend_engine->dma_tx_bg_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value(in_bg_pixel_format);
|
||||
blend_engine->dma_tx_bg_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value((esp_color_fourcc_t)blend_trans_desc->in_bg.blend_cm);
|
||||
blend_engine->dma_tx_bg_desc->y = blend_trans_desc->in_bg.block_offset_y;
|
||||
blend_engine->dma_tx_bg_desc->x = blend_trans_desc->in_bg.block_offset_x;
|
||||
blend_engine->dma_tx_bg_desc->mode = DMA2D_DESCRIPTOR_BLOCK_RW_MODE_SINGLE;
|
||||
@@ -80,7 +70,7 @@ bool ppa_blend_transaction_on_picked(uint32_t num_chans, const dma2d_trans_chann
|
||||
blend_engine->dma_tx_fg_desc->owner = DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA;
|
||||
blend_engine->dma_tx_fg_desc->va_size = blend_trans_desc->in_fg.pic_h;
|
||||
blend_engine->dma_tx_fg_desc->ha_length = blend_trans_desc->in_fg.pic_w;
|
||||
blend_engine->dma_tx_fg_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value(in_fg_pixel_format);
|
||||
blend_engine->dma_tx_fg_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value((esp_color_fourcc_t)blend_trans_desc->in_fg.blend_cm);
|
||||
blend_engine->dma_tx_fg_desc->y = blend_trans_desc->in_fg.block_offset_y;
|
||||
blend_engine->dma_tx_fg_desc->x = blend_trans_desc->in_fg.block_offset_x;
|
||||
blend_engine->dma_tx_fg_desc->mode = DMA2D_DESCRIPTOR_BLOCK_RW_MODE_SINGLE;
|
||||
@@ -95,7 +85,7 @@ bool ppa_blend_transaction_on_picked(uint32_t num_chans, const dma2d_trans_chann
|
||||
blend_engine->dma_rx_desc->owner = DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA;
|
||||
blend_engine->dma_rx_desc->va_size = blend_trans_desc->out.pic_h;
|
||||
blend_engine->dma_rx_desc->ha_length = blend_trans_desc->out.pic_w;
|
||||
blend_engine->dma_rx_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value(out_pixel_format);
|
||||
blend_engine->dma_rx_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value((esp_color_fourcc_t)blend_trans_desc->out.blend_cm);
|
||||
blend_engine->dma_rx_desc->y = blend_trans_desc->out.block_offset_y;
|
||||
blend_engine->dma_rx_desc->x = blend_trans_desc->out.block_offset_x;
|
||||
blend_engine->dma_rx_desc->mode = DMA2D_DESCRIPTOR_BLOCK_RW_MODE_SINGLE;
|
||||
@@ -140,19 +130,16 @@ bool ppa_blend_transaction_on_picked(uint32_t num_chans, const dma2d_trans_chann
|
||||
|
||||
// Configure PPA Blending engine
|
||||
ppa_ll_blend_set_rx_bg_color_mode(platform->hal.dev, blend_trans_desc->in_bg.blend_cm);
|
||||
if (COLOR_SPACE_TYPE((uint32_t)blend_trans_desc->in_bg.blend_cm) == COLOR_SPACE_YUV) {
|
||||
if (PPA_IS_CM_YUV(blend_trans_desc->in_bg.blend_cm)) {
|
||||
ppa_ll_blend_set_rx_bg_yuv_range(platform->hal.dev, blend_trans_desc->in_bg.yuv_range);
|
||||
ppa_ll_blend_set_rx_bg_yuv2rgb_std(platform->hal.dev, blend_trans_desc->in_bg.yuv_std);
|
||||
}
|
||||
if ((uint32_t)blend_trans_desc->in_bg.blend_cm == PPA_BLEND_COLOR_MODE_YUV422) {
|
||||
ppa_ll_blend_set_rx_bg_yuv422_pack_order(platform->hal.dev, blend_trans_desc->in_bg.yuv422_pack_order);
|
||||
}
|
||||
ppa_ll_blend_enable_rx_bg_byte_swap(platform->hal.dev, blend_trans_desc->bg_byte_swap);
|
||||
ppa_ll_blend_enable_rx_bg_rgb_swap(platform->hal.dev, blend_trans_desc->bg_rgb_swap);
|
||||
ppa_ll_blend_configure_rx_bg_alpha(platform->hal.dev, blend_trans_desc->bg_alpha_update_mode, blend_trans_desc->bg_alpha_value);
|
||||
|
||||
ppa_ll_blend_set_rx_fg_color_mode(platform->hal.dev, blend_trans_desc->in_fg.blend_cm);
|
||||
if (COLOR_SPACE_TYPE((uint32_t)blend_trans_desc->in_fg.blend_cm) == COLOR_SPACE_ALPHA) {
|
||||
if (PPA_IS_CM_ALPHA(blend_trans_desc->in_fg.blend_cm)) {
|
||||
ppa_ll_blend_set_rx_fg_fix_rgb(platform->hal.dev, &blend_trans_desc->fg_fix_rgb_val);
|
||||
}
|
||||
ppa_ll_blend_enable_rx_fg_byte_swap(platform->hal.dev, blend_trans_desc->fg_byte_swap);
|
||||
@@ -160,7 +147,7 @@ bool ppa_blend_transaction_on_picked(uint32_t num_chans, const dma2d_trans_chann
|
||||
ppa_ll_blend_configure_rx_fg_alpha(platform->hal.dev, blend_trans_desc->fg_alpha_update_mode, blend_trans_desc->fg_alpha_value);
|
||||
|
||||
ppa_ll_blend_set_tx_color_mode(platform->hal.dev, blend_trans_desc->out.blend_cm);
|
||||
if (COLOR_SPACE_TYPE((uint32_t)blend_trans_desc->out.blend_cm) == COLOR_SPACE_YUV) {
|
||||
if (PPA_IS_CM_YUV(blend_trans_desc->out.blend_cm)) {
|
||||
ppa_ll_blend_set_tx_yuv_range(platform->hal.dev, blend_trans_desc->out.yuv_range);
|
||||
ppa_ll_blend_set_tx_rgb2yuv_std(platform->hal.dev, blend_trans_desc->out.yuv_std);
|
||||
}
|
||||
@@ -201,7 +188,7 @@ esp_err_t ppa_do_blend(ppa_client_handle_t ppa_client, const ppa_blend_oper_conf
|
||||
config->in_bg.block_h % 2 == 0 && config->in_bg.block_w % 2 == 0 &&
|
||||
config->in_bg.block_offset_x % 2 == 0 && config->in_bg.block_offset_y % 2 == 0,
|
||||
ESP_ERR_INVALID_ARG, TAG, "YUV420 input does not support odd h/w/offset_x/offset_y");
|
||||
} else if (config->in_bg.blend_cm == PPA_BLEND_COLOR_MODE_YUV422) {
|
||||
} else if (PPA_IS_CM_YUV422(config->in_bg.blend_cm)) {
|
||||
ESP_RETURN_ON_FALSE(config->in_bg.pic_w % 2 == 0 && config->in_bg.block_w % 2 == 0 && config->in_bg.block_offset_x % 2 == 0,
|
||||
ESP_ERR_INVALID_ARG, TAG, "YUV422 input does not support odd w/offset_x");
|
||||
}
|
||||
@@ -218,7 +205,7 @@ esp_err_t ppa_do_blend(ppa_client_handle_t ppa_client, const ppa_blend_oper_conf
|
||||
ESP_RETURN_ON_FALSE(config->out.pic_h % 2 == 0 && config->out.pic_w % 2 == 0 &&
|
||||
config->out.block_offset_x % 2 == 0 && config->out.block_offset_y % 2 == 0,
|
||||
ESP_ERR_INVALID_ARG, TAG, "YUV420 output does not support odd h/w/offset_x/offset_y");
|
||||
} else if (config->out.blend_cm == PPA_BLEND_COLOR_MODE_YUV422) {
|
||||
} else if (PPA_IS_CM_YUV422(config->out.blend_cm)) {
|
||||
ESP_RETURN_ON_FALSE(config->out.pic_w % 2 == 0 && config->out.block_offset_x % 2 == 0,
|
||||
ESP_ERR_INVALID_ARG, TAG, "YUV422 output does not support odd w/offset_x");
|
||||
}
|
||||
@@ -228,10 +215,7 @@ esp_err_t ppa_do_blend(ppa_client_handle_t ppa_client, const ppa_blend_oper_conf
|
||||
ESP_RETURN_ON_FALSE(config->in_fg.block_w <= (config->in_fg.pic_w - config->in_fg.block_offset_x) &&
|
||||
config->in_fg.block_h <= (config->in_fg.pic_h - config->in_fg.block_offset_y),
|
||||
ESP_ERR_INVALID_ARG, TAG, "in_fg.block_w/h + in_fg.block_offset_x/y does not fit in the in pic");
|
||||
color_space_pixel_format_t out_pixel_format = {
|
||||
.color_type_id = config->out.blend_cm,
|
||||
};
|
||||
uint32_t out_pixel_depth = color_hal_pixel_format_get_bit_depth(out_pixel_format); // bits
|
||||
uint32_t out_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)config->out.blend_cm); // bits
|
||||
uint32_t out_pic_len = config->out.pic_w * config->out.pic_h * out_pixel_depth / 8;
|
||||
ESP_RETURN_ON_FALSE(out_pic_len <= config->out.buffer_size, ESP_ERR_INVALID_ARG, TAG, "out.pic_w/h mismatch with out.buffer_size");
|
||||
ESP_RETURN_ON_FALSE(config->in_bg.block_w == config->in_fg.block_w && config->in_bg.block_h == config->in_fg.block_h,
|
||||
@@ -271,10 +255,7 @@ esp_err_t ppa_do_blend(ppa_client_handle_t ppa_client, const ppa_blend_oper_conf
|
||||
|
||||
// Write back and invalidate necessary data (note that the window content is not continuous in the buffer)
|
||||
// Write back in_bg_buffer, in_fg_buffer extended windows (alignment not necessary on C2M direction)
|
||||
color_space_pixel_format_t in_bg_pixel_format = {
|
||||
.color_type_id = config->in_bg.blend_cm,
|
||||
};
|
||||
uint32_t in_bg_pixel_depth = color_hal_pixel_format_get_bit_depth(in_bg_pixel_format); // bits
|
||||
uint32_t in_bg_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)config->in_bg.blend_cm); // bits
|
||||
// Usually C2M can let the msync do alignment internally, however, it only do L1-cacheline-size alignment for L1->L2, and then L2-cacheline-size alignment for L2->mem
|
||||
// While M2C direction manual alignment is L2-cacheline-size alignment for mem->L2->L1
|
||||
// Mismatching writeback and invalidate data size could cause synchronization error if in_bg/fg_buffer and out_buffer are the same one
|
||||
@@ -282,10 +263,7 @@ esp_err_t ppa_do_blend(ppa_client_handle_t ppa_client, const ppa_blend_oper_conf
|
||||
uint32_t in_bg_ext_window_aligned = PPA_ALIGN_DOWN(in_bg_ext_window, buf_alignment_size);
|
||||
uint32_t in_bg_ext_window_len = config->in_bg.pic_w * config->in_bg.block_h * in_bg_pixel_depth / 8;
|
||||
esp_cache_msync((void *)in_bg_ext_window_aligned, PPA_ALIGN_UP(in_bg_ext_window_len + (in_bg_ext_window - in_bg_ext_window_aligned), buf_alignment_size), ESP_CACHE_MSYNC_FLAG_DIR_C2M);
|
||||
color_space_pixel_format_t in_fg_pixel_format = {
|
||||
.color_type_id = config->in_fg.blend_cm,
|
||||
};
|
||||
uint32_t in_fg_pixel_depth = color_hal_pixel_format_get_bit_depth(in_fg_pixel_format); // bits
|
||||
uint32_t in_fg_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)config->in_fg.blend_cm); // bits
|
||||
uint32_t in_fg_ext_window = (uint32_t)config->in_fg.buffer + config->in_fg.block_offset_y * config->in_fg.pic_w * in_fg_pixel_depth / 8;
|
||||
// Same for fg_buffer msync, do manual alignment
|
||||
uint32_t in_fg_ext_window_aligned = PPA_ALIGN_DOWN(in_fg_ext_window, buf_alignment_size);
|
||||
|
||||
@@ -32,10 +32,6 @@ bool ppa_fill_transaction_on_picked(uint32_t num_chans, const dma2d_trans_channe
|
||||
assert(dma2d_chans[0].dir == DMA2D_CHANNEL_DIRECTION_RX);
|
||||
dma2d_channel_handle_t dma2d_rx_chan = dma2d_chans[0].chan;
|
||||
|
||||
color_space_pixel_format_t out_pixel_format = {
|
||||
.color_type_id = fill_trans_desc->out.fill_cm,
|
||||
};
|
||||
|
||||
// Fill 2D-DMA descriptors
|
||||
blend_engine->dma_rx_desc->vb_size = fill_trans_desc->fill_block_h;
|
||||
blend_engine->dma_rx_desc->hb_length = fill_trans_desc->fill_block_w;
|
||||
@@ -45,7 +41,7 @@ bool ppa_fill_transaction_on_picked(uint32_t num_chans, const dma2d_trans_channe
|
||||
blend_engine->dma_rx_desc->owner = DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA;
|
||||
blend_engine->dma_rx_desc->va_size = fill_trans_desc->out.pic_h;
|
||||
blend_engine->dma_rx_desc->ha_length = fill_trans_desc->out.pic_w;
|
||||
blend_engine->dma_rx_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value(out_pixel_format);
|
||||
blend_engine->dma_rx_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value((esp_color_fourcc_t)fill_trans_desc->out.fill_cm);
|
||||
blend_engine->dma_rx_desc->y = fill_trans_desc->out.block_offset_y;
|
||||
blend_engine->dma_rx_desc->x = fill_trans_desc->out.block_offset_x;
|
||||
blend_engine->dma_rx_desc->mode = DMA2D_DESCRIPTOR_BLOCK_RW_MODE_SINGLE;
|
||||
@@ -104,14 +100,11 @@ esp_err_t ppa_do_fill(ppa_client_handle_t ppa_client, const ppa_fill_oper_config
|
||||
// config->out.block_offset_x % 2 == 0 && config->out.block_offset_y % 2 == 0,
|
||||
// ESP_ERR_INVALID_ARG, TAG, "YUV420 output does not support odd h/w/offset_x/offset_y");
|
||||
// } else
|
||||
if (config->out.fill_cm == PPA_FILL_COLOR_MODE_YUV422) {
|
||||
if (config->out.fill_cm == PPA_FILL_COLOR_MODE_YUV422_UYVY) {
|
||||
ESP_RETURN_ON_FALSE(config->out.pic_w % 2 == 0 && config->out.block_offset_x % 2 == 0,
|
||||
ESP_ERR_INVALID_ARG, TAG, "YUV422 output does not support odd w/offset_x");
|
||||
}
|
||||
color_space_pixel_format_t out_pixel_format = {
|
||||
.color_type_id = config->out.fill_cm,
|
||||
};
|
||||
uint32_t out_pixel_depth = color_hal_pixel_format_get_bit_depth(out_pixel_format);
|
||||
uint32_t out_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)config->out.fill_cm);
|
||||
uint32_t out_pic_len = config->out.pic_w * config->out.pic_h * out_pixel_depth / 8;
|
||||
ESP_RETURN_ON_FALSE(out_pic_len <= config->out.buffer_size, ESP_ERR_INVALID_ARG, TAG, "out.pic_w/h mismatch with out.buffer_size");
|
||||
ESP_RETURN_ON_FALSE(config->fill_block_w <= (config->out.pic_w - config->out.block_offset_x) &&
|
||||
|
||||
@@ -28,13 +28,23 @@ extern "C" {
|
||||
#define PPA_PM_LOCK_NAME_LEN_MAX 16
|
||||
|
||||
#define PPA_CHECK_CM_SUPPORT_BYTE_SWAP(str, color_type_id) \
|
||||
ESP_RETURN_ON_FALSE(color_type_id == COLOR_TYPE_ID(COLOR_SPACE_ARGB, COLOR_PIXEL_ARGB8888) || color_type_id == COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB565), \
|
||||
ESP_RETURN_ON_FALSE((color_type_id == ESP_COLOR_FOURCC_BGRA32) || (color_type_id == ESP_COLOR_FOURCC_RGB16), \
|
||||
ESP_ERR_INVALID_ARG, TAG, str "_cm does not support byte_swap");
|
||||
|
||||
#define PPA_CHECK_CM_SUPPORT_RGB_SWAP(str, color_type_id) \
|
||||
ESP_RETURN_ON_FALSE(COLOR_SPACE_TYPE(color_type_id) == COLOR_SPACE_ARGB || COLOR_SPACE_TYPE(color_type_id) == COLOR_SPACE_RGB, \
|
||||
ESP_RETURN_ON_FALSE((color_type_id == ESP_COLOR_FOURCC_BGRA32) || (color_type_id == ESP_COLOR_FOURCC_BGR24) || (color_type_id == ESP_COLOR_FOURCC_RGB16), \
|
||||
ESP_ERR_INVALID_ARG, TAG, str "_cm does not support rgb_swap");
|
||||
|
||||
#define PPA_IS_CM_YUV422(color_type_id) \
|
||||
(color_type_id == ESP_COLOR_FOURCC_UYVY || color_type_id == ESP_COLOR_FOURCC_VYUY || \
|
||||
color_type_id == ESP_COLOR_FOURCC_YUYV || color_type_id == ESP_COLOR_FOURCC_YVYU)
|
||||
|
||||
#define PPA_IS_CM_YUV(color_type_id) \
|
||||
(color_type_id == ESP_COLOR_FOURCC_OUYY_EVYY || color_type_id == ESP_COLOR_FOURCC_YUV || PPA_IS_CM_YUV422(color_type_id))
|
||||
|
||||
#define PPA_IS_CM_ALPHA(color_type_id) \
|
||||
(color_type_id == ESP_COLOR_FOURCC_ALPHA8 || color_type_id == ESP_COLOR_FOURCC_ALPHA4)
|
||||
|
||||
#define PPA_ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
|
||||
#define PPA_ALIGN_DOWN(num, align) ((num) & ~((align) - 1))
|
||||
|
||||
|
||||
@@ -41,10 +41,6 @@ bool ppa_srm_transaction_on_picked(uint32_t num_chans, const dma2d_trans_channel
|
||||
}
|
||||
assert(dma2d_tx_chan && dma2d_rx_chan);
|
||||
|
||||
color_space_pixel_format_t in_pixel_format = {
|
||||
.color_type_id = srm_trans_desc->in.srm_cm,
|
||||
};
|
||||
|
||||
// Fill 2D-DMA descriptors
|
||||
srm_engine->dma_tx_desc->vb_size = srm_trans_desc->in.block_h;
|
||||
srm_engine->dma_tx_desc->hb_length = srm_trans_desc->in.block_w;
|
||||
@@ -54,7 +50,7 @@ bool ppa_srm_transaction_on_picked(uint32_t num_chans, const dma2d_trans_channel
|
||||
srm_engine->dma_tx_desc->owner = DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA;
|
||||
srm_engine->dma_tx_desc->va_size = srm_trans_desc->in.pic_h;
|
||||
srm_engine->dma_tx_desc->ha_length = srm_trans_desc->in.pic_w;
|
||||
srm_engine->dma_tx_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value(in_pixel_format);
|
||||
srm_engine->dma_tx_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value((esp_color_fourcc_t)srm_trans_desc->in.srm_cm);
|
||||
srm_engine->dma_tx_desc->y = srm_trans_desc->in.block_offset_y;
|
||||
srm_engine->dma_tx_desc->x = srm_trans_desc->in.block_offset_x;
|
||||
srm_engine->dma_tx_desc->mode = DMA2D_DESCRIPTOR_BLOCK_RW_MODE_SINGLE;
|
||||
@@ -136,19 +132,16 @@ bool ppa_srm_transaction_on_picked(uint32_t num_chans, const dma2d_trans_channel
|
||||
|
||||
// Configure PPA SRM engine
|
||||
ppa_ll_srm_set_rx_color_mode(platform->hal.dev, ppa_in_color_mode);
|
||||
if (COLOR_SPACE_TYPE((uint32_t)ppa_in_color_mode) == COLOR_SPACE_YUV) {
|
||||
if (PPA_IS_CM_YUV(ppa_in_color_mode)) {
|
||||
ppa_ll_srm_set_rx_yuv_range(platform->hal.dev, srm_trans_desc->in.yuv_range);
|
||||
ppa_ll_srm_set_rx_yuv2rgb_std(platform->hal.dev, srm_trans_desc->in.yuv_std);
|
||||
}
|
||||
if ((uint32_t)ppa_in_color_mode == COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422)) {
|
||||
ppa_ll_srm_set_rx_yuv422_pack_order(platform->hal.dev, srm_trans_desc->in.yuv422_pack_order);
|
||||
}
|
||||
ppa_ll_srm_enable_rx_byte_swap(platform->hal.dev, srm_trans_desc->byte_swap);
|
||||
ppa_ll_srm_enable_rx_rgb_swap(platform->hal.dev, srm_trans_desc->rgb_swap);
|
||||
ppa_ll_srm_configure_rx_alpha(platform->hal.dev, srm_trans_desc->alpha_update_mode, srm_trans_desc->alpha_value);
|
||||
|
||||
ppa_ll_srm_set_tx_color_mode(platform->hal.dev, ppa_out_color_mode);
|
||||
if (COLOR_SPACE_TYPE((uint32_t)ppa_out_color_mode) == COLOR_SPACE_YUV) {
|
||||
if (PPA_IS_CM_YUV(ppa_out_color_mode)) {
|
||||
ppa_ll_srm_set_tx_yuv_range(platform->hal.dev, srm_trans_desc->out.yuv_range);
|
||||
ppa_ll_srm_set_tx_rgb2yuv_std(platform->hal.dev, srm_trans_desc->out.yuv_std);
|
||||
}
|
||||
@@ -169,10 +162,7 @@ bool ppa_srm_transaction_on_picked(uint32_t num_chans, const dma2d_trans_channel
|
||||
h_in_left = (h_in_left == 0) ? h_mb : h_in_left;
|
||||
uint32_t h_left = h_in_left * srm_trans_desc->scale_y_int + h_in_left * srm_trans_desc->scale_y_frag / PPA_LL_SRM_SCALING_FRAG_MAX;
|
||||
const uint32_t dma2d_fifo_depth_bits = 12 * 128;
|
||||
color_space_pixel_format_t out_pixel_format = {
|
||||
.color_type_id = ppa_out_color_mode,
|
||||
};
|
||||
uint32_t out_pixel_depth = color_hal_pixel_format_get_bit_depth(out_pixel_format);
|
||||
uint32_t out_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)ppa_out_color_mode);
|
||||
bool bypass_mb_order = false;
|
||||
if (((w_out > w_divisor) || (srm_trans_desc->in.block_h > h_mb)) && // will be cut into more than one trans unit
|
||||
((w_left * h_left * out_pixel_depth) < dma2d_fifo_depth_bits)
|
||||
@@ -207,7 +197,7 @@ esp_err_t ppa_do_scale_rotate_mirror(ppa_client_handle_t ppa_client, const ppa_s
|
||||
config->in.block_h % 2 == 0 && config->in.block_w % 2 == 0 &&
|
||||
config->in.block_offset_x % 2 == 0 && config->in.block_offset_y % 2 == 0,
|
||||
ESP_ERR_INVALID_ARG, TAG, "YUV420 input does not support odd h/w/offset_x/offset_y");
|
||||
} else if (config->in.srm_cm == PPA_SRM_COLOR_MODE_YUV422) {
|
||||
} else if (PPA_IS_CM_YUV422(config->in.srm_cm)) {
|
||||
ESP_RETURN_ON_FALSE(config->in.pic_w % 2 == 0 && config->in.block_w % 2 == 0 && config->in.block_offset_x % 2 == 0,
|
||||
ESP_ERR_INVALID_ARG, TAG, "YUV422 input does not support odd w/offset_x");
|
||||
}
|
||||
@@ -215,17 +205,14 @@ esp_err_t ppa_do_scale_rotate_mirror(ppa_client_handle_t ppa_client, const ppa_s
|
||||
ESP_RETURN_ON_FALSE(config->out.pic_h % 2 == 0 && config->out.pic_w % 2 == 0 &&
|
||||
config->out.block_offset_x % 2 == 0 && config->out.block_offset_y % 2 == 0,
|
||||
ESP_ERR_INVALID_ARG, TAG, "YUV420 output does not support odd h/w/offset_x/offset_y");
|
||||
} else if (config->out.srm_cm == PPA_SRM_COLOR_MODE_YUV422) {
|
||||
} else if (PPA_IS_CM_YUV422(config->out.srm_cm)) {
|
||||
ESP_RETURN_ON_FALSE(config->out.pic_w % 2 == 0 && config->out.block_offset_x % 2 == 0,
|
||||
ESP_ERR_INVALID_ARG, TAG, "YUV422 output does not support odd w/offset_x");
|
||||
}
|
||||
ESP_RETURN_ON_FALSE(config->in.block_w <= (config->in.pic_w - config->in.block_offset_x) &&
|
||||
config->in.block_h <= (config->in.pic_h - config->in.block_offset_y),
|
||||
ESP_ERR_INVALID_ARG, TAG, "in.block_w/h + in.block_offset_x/y does not fit in the in pic");
|
||||
color_space_pixel_format_t out_pixel_format = {
|
||||
.color_type_id = config->out.srm_cm,
|
||||
};
|
||||
uint32_t out_pixel_depth = color_hal_pixel_format_get_bit_depth(out_pixel_format); // bits
|
||||
uint32_t out_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)config->out.srm_cm); // bits
|
||||
uint32_t out_pic_len = config->out.pic_w * config->out.pic_h * out_pixel_depth / 8;
|
||||
ESP_RETURN_ON_FALSE(out_pic_len <= config->out.buffer_size, ESP_ERR_INVALID_ARG, TAG, "out.pic_w/h mismatch with out.buffer_size");
|
||||
ESP_RETURN_ON_FALSE(config->scale_x < PPA_LL_SRM_SCALING_INT_MAX && config->scale_x >= (1.0 / PPA_LL_SRM_SCALING_FRAG_MAX) &&
|
||||
@@ -261,10 +248,7 @@ esp_err_t ppa_do_scale_rotate_mirror(ppa_client_handle_t ppa_client, const ppa_s
|
||||
|
||||
// Write back and invalidate necessary data (note that the window content is not continuous in the buffer)
|
||||
// Write back in_buffer extended window (alignment not necessary on C2M direction)
|
||||
color_space_pixel_format_t in_pixel_format = {
|
||||
.color_type_id = config->in.srm_cm,
|
||||
};
|
||||
uint32_t in_pixel_depth = color_hal_pixel_format_get_bit_depth(in_pixel_format); // bits
|
||||
uint32_t in_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)config->in.srm_cm); // bits
|
||||
uint32_t in_ext_window = (uint32_t)config->in.buffer + config->in.block_offset_y * config->in.pic_w * in_pixel_depth / 8;
|
||||
uint32_t in_ext_window_len = config->in.pic_w * config->in.block_h * in_pixel_depth / 8;
|
||||
esp_cache_msync((void *)in_ext_window, in_ext_window_len, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
|
||||
@@ -295,7 +279,7 @@ esp_err_t ppa_do_scale_rotate_mirror(ppa_client_handle_t ppa_client, const ppa_s
|
||||
if (config->out.srm_cm == PPA_SRM_COLOR_MODE_YUV420) {
|
||||
srm_trans_desc->scale_x_frag = srm_trans_desc->scale_x_frag & ~1;
|
||||
srm_trans_desc->scale_y_frag = srm_trans_desc->scale_y_frag & ~1;
|
||||
} else if (config->out.srm_cm == PPA_SRM_COLOR_MODE_YUV422) {
|
||||
} else if (PPA_IS_CM_YUV422(config->out.srm_cm)) {
|
||||
srm_trans_desc->scale_x_frag = srm_trans_desc->scale_x_frag & ~1;
|
||||
}
|
||||
srm_trans_desc->alpha_value = new_alpha_value;
|
||||
|
||||
@@ -26,18 +26,11 @@ TEST_CASE("ppa_client_do_ppa_operation", "[PPA]")
|
||||
{
|
||||
const uint32_t w = 480;
|
||||
const uint32_t h = 480;
|
||||
const uint32_t buf_1_color_type_id = COLOR_TYPE_ID(COLOR_SPACE_ARGB, COLOR_PIXEL_ARGB8888);
|
||||
const uint32_t buf_2_color_type_id = COLOR_TYPE_ID(COLOR_SPACE_ARGB, COLOR_PIXEL_ARGB8888);
|
||||
const esp_color_fourcc_t buf_1_color_type_id = ESP_COLOR_FOURCC_BGRA32;
|
||||
const esp_color_fourcc_t buf_2_color_type_id = ESP_COLOR_FOURCC_BGRA32;
|
||||
|
||||
color_space_pixel_format_t buf_1_cm = {
|
||||
.color_type_id = buf_1_color_type_id,
|
||||
};
|
||||
color_space_pixel_format_t buf_2_cm = {
|
||||
.color_type_id = buf_2_color_type_id,
|
||||
};
|
||||
|
||||
uint32_t buf_1_size = ALIGN_UP(w * h * color_hal_pixel_format_get_bit_depth(buf_1_cm) / 8, 64);
|
||||
uint32_t buf_2_size = ALIGN_UP(w * h * color_hal_pixel_format_get_bit_depth(buf_2_cm) / 8, 64);
|
||||
uint32_t buf_1_size = ALIGN_UP(w * h * color_hal_pixel_format_fourcc_get_bit_depth(buf_1_color_type_id) / 8, 64);
|
||||
uint32_t buf_2_size = ALIGN_UP(w * h * color_hal_pixel_format_fourcc_get_bit_depth(buf_2_color_type_id) / 8, 64);
|
||||
uint8_t *buf_1 = heap_caps_aligned_calloc(4, buf_1_size, sizeof(uint8_t), MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA); // cache alignment is implicited by MALLOC_CAP_DMA
|
||||
TEST_ASSERT_NOT_NULL(buf_1);
|
||||
uint8_t *buf_2 = heap_caps_aligned_calloc(4, buf_2_size, sizeof(uint8_t), MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA);
|
||||
@@ -169,18 +162,11 @@ TEST_CASE("ppa_pending_transactions_in_queue", "[PPA]")
|
||||
// A big picture block takes longer time to process, desired for this test case
|
||||
const uint32_t w = 1920;
|
||||
const uint32_t h = 1080;
|
||||
const uint32_t buf_1_color_type_id = COLOR_TYPE_ID(COLOR_SPACE_ARGB, COLOR_PIXEL_ARGB8888);
|
||||
const uint32_t buf_2_color_type_id = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420);
|
||||
const esp_color_fourcc_t buf_1_color_type_id = ESP_COLOR_FOURCC_BGRA32;
|
||||
const esp_color_fourcc_t buf_2_color_type_id = ESP_COLOR_FOURCC_OUYY_EVYY;
|
||||
|
||||
color_space_pixel_format_t buf_1_cm = {
|
||||
.color_type_id = buf_1_color_type_id,
|
||||
};
|
||||
color_space_pixel_format_t buf_2_cm = {
|
||||
.color_type_id = buf_2_color_type_id,
|
||||
};
|
||||
|
||||
uint32_t buf_1_size = w * h * color_hal_pixel_format_get_bit_depth(buf_1_cm) / 8;
|
||||
uint32_t buf_2_size = ALIGN_UP(w * h * color_hal_pixel_format_get_bit_depth(buf_2_cm) / 8, 64);
|
||||
uint32_t buf_1_size = w * h * color_hal_pixel_format_fourcc_get_bit_depth(buf_1_color_type_id) / 8;
|
||||
uint32_t buf_2_size = ALIGN_UP(w * h * color_hal_pixel_format_fourcc_get_bit_depth(buf_2_color_type_id) / 8, 64);
|
||||
uint8_t *buf_1 = heap_caps_aligned_calloc(4, buf_1_size, sizeof(uint8_t), MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA);
|
||||
TEST_ASSERT_NOT_NULL(buf_1);
|
||||
uint8_t *buf_2 = heap_caps_aligned_calloc(4, buf_2_size, sizeof(uint8_t), MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA);
|
||||
@@ -279,10 +265,7 @@ TEST_CASE("ppa_srm_basic_data_correctness_check", "[PPA]")
|
||||
const float scale_x = 1.0;
|
||||
const float scale_y = 1.0;
|
||||
|
||||
color_space_pixel_format_t buf_cm = {
|
||||
.color_type_id = cm,
|
||||
};
|
||||
const uint32_t buf_len = w * h * color_hal_pixel_format_get_bit_depth(buf_cm) / 8; // 32
|
||||
const uint32_t buf_len = w * h * color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)cm) / 8; // 32
|
||||
uint32_t out_buf_size = ALIGN_UP(buf_len, 64);
|
||||
uint8_t *out_buf = heap_caps_aligned_calloc(4, out_buf_size, sizeof(uint8_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT | MALLOC_CAP_DMA);
|
||||
TEST_ASSERT_NOT_NULL(out_buf);
|
||||
@@ -402,14 +385,8 @@ TEST_CASE("ppa_blend_basic_data_correctness_check", "[PPA]")
|
||||
const ppa_blend_color_mode_t in_fg_cm = PPA_BLEND_COLOR_MODE_ARGB8888;
|
||||
const ppa_blend_color_mode_t out_cm = PPA_BLEND_COLOR_MODE_ARGB8888;
|
||||
|
||||
color_space_pixel_format_t bg_buf_cm = {
|
||||
.color_type_id = in_bg_cm,
|
||||
};
|
||||
const uint32_t bg_buf_len __attribute__((unused)) = w * h * color_hal_pixel_format_get_bit_depth(bg_buf_cm) / 8; // 12
|
||||
color_space_pixel_format_t fg_buf_cm = {
|
||||
.color_type_id = in_fg_cm,
|
||||
};
|
||||
const uint32_t fg_buf_len __attribute__((unused)) = w * h * color_hal_pixel_format_get_bit_depth(fg_buf_cm) / 8; // 16
|
||||
const uint32_t bg_buf_len __attribute__((unused)) = w * h * color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)in_bg_cm) / 8; // 12
|
||||
const uint32_t fg_buf_len __attribute__((unused)) = w * h * color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)in_fg_cm) / 8; // 16
|
||||
const uint32_t out_buf_len = fg_buf_len; // 16
|
||||
// We will make the output write to the in_fg_buffer, therefore, it has cache line alignment requirement
|
||||
const uint32_t out_buf_size = 64;
|
||||
@@ -517,11 +494,7 @@ TEST_CASE("ppa_fill_basic_data_correctness_check", "[PPA]")
|
||||
const ppa_fill_color_mode_t out_cm = PPA_FILL_COLOR_MODE_RGB565;
|
||||
const color_pixel_argb8888_data_t fill_color = {.a = 0x80, .r = 0xFF, .g = 0x55, .b = 0xAA};
|
||||
|
||||
color_space_pixel_format_t out_pixel_format = {
|
||||
.color_type_id = out_cm,
|
||||
};
|
||||
|
||||
uint32_t out_pixel_depth = color_hal_pixel_format_get_bit_depth(out_pixel_format); // bits
|
||||
uint32_t out_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)out_cm); // bits
|
||||
uint32_t out_buf_len = w * h * out_pixel_depth / 8;
|
||||
uint32_t out_buf_size = ALIGN_UP(out_buf_len, 64);
|
||||
uint8_t *out_buf = heap_caps_aligned_calloc(4, out_buf_size, sizeof(uint8_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT | MALLOC_CAP_DMA);
|
||||
@@ -563,11 +536,10 @@ TEST_CASE("ppa_fill_basic_data_correctness_check", "[PPA]")
|
||||
|
||||
#if !(CONFIG_IDF_TARGET_ESP32P4 && CONFIG_ESP32P4_SELECTS_REV_LESS_V3)
|
||||
// Test a yuv color fill
|
||||
oper_config.out.fill_cm = PPA_FILL_COLOR_MODE_YUV422; // output YUV422 is with YVYU packed order
|
||||
oper_config.out.fill_cm = PPA_FILL_COLOR_MODE_YUV422_UYVY; // output YUV422 is with UYVY packed order
|
||||
const color_macroblock_yuv_data_t fill_yuv_color = {.y = 0xFF, .u = 0x55, .v = 0xAA};
|
||||
oper_config.fill_yuv_color = fill_yuv_color;
|
||||
out_pixel_format.color_type_id = PPA_FILL_COLOR_MODE_YUV422;
|
||||
out_pixel_depth = color_hal_pixel_format_get_bit_depth(out_pixel_format); // bits
|
||||
out_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)PPA_FILL_COLOR_MODE_YUV422_UYVY); // bits
|
||||
TEST_ESP_OK(ppa_do_fill(ppa_client_handle, &oper_config));
|
||||
|
||||
// Check result (2 pixels per macro pixel)
|
||||
@@ -604,15 +576,8 @@ TEST_CASE("ppa_srm_performance", "[PPA]")
|
||||
const float scale_x = 1.0;
|
||||
const float scale_y = 1.0;
|
||||
|
||||
color_space_pixel_format_t in_pixel_format = {
|
||||
.color_type_id = in_cm,
|
||||
};
|
||||
color_space_pixel_format_t out_pixel_format = {
|
||||
.color_type_id = out_cm,
|
||||
};
|
||||
|
||||
uint32_t in_buf_size = w * h * color_hal_pixel_format_get_bit_depth(in_pixel_format) / 8;
|
||||
uint32_t out_buf_size = ALIGN_UP(w * h * color_hal_pixel_format_get_bit_depth(out_pixel_format) / 8, 64);
|
||||
uint32_t in_buf_size = w * h * color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)in_cm) / 8;
|
||||
uint32_t out_buf_size = ALIGN_UP(w * h * color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)out_cm) / 8, 64);
|
||||
uint8_t *out_buf = heap_caps_aligned_calloc(4, out_buf_size, sizeof(uint8_t), MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA);
|
||||
TEST_ASSERT_NOT_NULL(out_buf);
|
||||
uint8_t *in_buf = heap_caps_aligned_calloc(4, in_buf_size, sizeof(uint8_t), MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA);
|
||||
@@ -690,19 +655,9 @@ TEST_CASE("ppa_blend_performance", "[PPA]")
|
||||
const ppa_blend_color_mode_t in_fg_cm = PPA_BLEND_COLOR_MODE_ARGB8888;
|
||||
const ppa_blend_color_mode_t out_cm = PPA_BLEND_COLOR_MODE_ARGB8888;
|
||||
|
||||
color_space_pixel_format_t in_bg_pixel_format = {
|
||||
.color_type_id = in_bg_cm,
|
||||
};
|
||||
color_space_pixel_format_t in_fg_pixel_format = {
|
||||
.color_type_id = in_fg_cm,
|
||||
};
|
||||
color_space_pixel_format_t out_pixel_format = {
|
||||
.color_type_id = out_cm,
|
||||
};
|
||||
|
||||
uint32_t in_bg_buf_size = w * h * color_hal_pixel_format_get_bit_depth(in_bg_pixel_format) / 8;
|
||||
uint32_t in_fg_buf_size = w * h * color_hal_pixel_format_get_bit_depth(in_fg_pixel_format) / 8;
|
||||
uint32_t out_buf_size = ALIGN_UP(w * h * color_hal_pixel_format_get_bit_depth(out_pixel_format) / 8, 64);
|
||||
uint32_t in_bg_buf_size = w * h * color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)in_bg_cm) / 8;
|
||||
uint32_t in_fg_buf_size = w * h * color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)in_fg_cm) / 8;
|
||||
uint32_t out_buf_size = ALIGN_UP(w * h * color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)out_cm) / 8, 64);
|
||||
uint8_t *out_buf = heap_caps_aligned_calloc(4, out_buf_size, sizeof(uint8_t), MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA);
|
||||
TEST_ASSERT_NOT_NULL(out_buf);
|
||||
uint8_t *in_bg_buf = heap_caps_aligned_calloc(4, in_bg_buf_size, sizeof(uint8_t), MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA);
|
||||
@@ -788,11 +743,7 @@ TEST_CASE("ppa_fill_performance", "[PPA]")
|
||||
const uint32_t block_h = 480;
|
||||
const ppa_fill_color_mode_t out_cm = PPA_FILL_COLOR_MODE_RGB565;
|
||||
|
||||
color_space_pixel_format_t out_pixel_format = {
|
||||
.color_type_id = out_cm,
|
||||
};
|
||||
|
||||
uint32_t out_buf_size = ALIGN_UP(w * h * color_hal_pixel_format_get_bit_depth(out_pixel_format) / 8, 64);
|
||||
uint32_t out_buf_size = ALIGN_UP(w * h * color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)out_cm) / 8, 64);
|
||||
uint8_t *out_buf = heap_caps_aligned_calloc(4, out_buf_size, sizeof(uint8_t), MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA);
|
||||
TEST_ASSERT_NOT_NULL(out_buf);
|
||||
|
||||
@@ -850,15 +801,8 @@ TEST_CASE("ppa_srm_stress_test", "[PPA]")
|
||||
const float scale_x = 1.0;
|
||||
const float scale_y = 1.0;
|
||||
|
||||
color_space_pixel_format_t in_pixel_format = {
|
||||
.color_type_id = in_cm,
|
||||
};
|
||||
color_space_pixel_format_t out_pixel_format = {
|
||||
.color_type_id = out_cm,
|
||||
};
|
||||
|
||||
uint32_t in_buf_size = w * h * color_hal_pixel_format_get_bit_depth(in_pixel_format) / 8;
|
||||
uint32_t out_buf_size = ALIGN_UP(w * h * color_hal_pixel_format_get_bit_depth(out_pixel_format) / 8, 64);
|
||||
uint32_t in_buf_size = w * h * color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)in_cm) / 8;
|
||||
uint32_t out_buf_size = ALIGN_UP(w * h * color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)out_cm) / 8, 64);
|
||||
uint8_t *out_buf = heap_caps_aligned_calloc(4, out_buf_size, sizeof(uint8_t), MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA);
|
||||
TEST_ASSERT_NOT_NULL(out_buf);
|
||||
uint8_t *in_buf = heap_caps_aligned_calloc(4, in_buf_size, sizeof(uint8_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT | MALLOC_CAP_DMA);
|
||||
|
||||
@@ -75,9 +75,9 @@ typedef enum {
|
||||
* @brief JPEG encoder source formats.
|
||||
*/
|
||||
typedef enum {
|
||||
JPEG_ENC_SRC_RGB888 = ESP_COLOR_FOURCC_RGB24, /*!< JPEG encoder source RGB888 */
|
||||
JPEG_ENC_SRC_RGB888 = ESP_COLOR_FOURCC_BGR24, /*!< JPEG encoder source RGB888 */
|
||||
JPEG_ENC_SRC_YUV422 = ESP_COLOR_FOURCC_YVYU, /*!< JPEG encoder source YUV422 */
|
||||
JPEG_ENC_SRC_RGB565 = ESP_COLOR_FOURCC_RGB16_BE, /*!< JPEG encoder source RGB565 */
|
||||
JPEG_ENC_SRC_RGB565 = ESP_COLOR_FOURCC_RGB16, /*!< JPEG encoder source RGB565 */
|
||||
JPEG_ENC_SRC_YUV444 = ESP_COLOR_FOURCC_YUV, /*!< JPEG encoder source YUV444 */
|
||||
JPEG_ENC_SRC_YUV420 = ESP_COLOR_FOURCC_OUYY_EVYY, /*!< JPEG encoder source YUV420 */
|
||||
JPEG_ENC_SRC_GRAY = ESP_COLOR_FOURCC_GREY, /*!< JPEG encoder source GRAY */
|
||||
|
||||
@@ -36,8 +36,8 @@ typedef enum {
|
||||
*/
|
||||
typedef enum {
|
||||
LCD_COLOR_FMT_GRAY8 = ESP_COLOR_FOURCC_GREY, ///< 8-bit gray scale
|
||||
LCD_COLOR_FMT_RGB565 = ESP_COLOR_FOURCC_RGB16_BE, ///< RGB565
|
||||
LCD_COLOR_FMT_RGB888 = ESP_COLOR_FOURCC_RGB24, ///< RGB888
|
||||
LCD_COLOR_FMT_RGB565 = ESP_COLOR_FOURCC_RGB16, ///< RGB565
|
||||
LCD_COLOR_FMT_RGB888 = ESP_COLOR_FOURCC_BGR24, ///< RGB888
|
||||
LCD_COLOR_FMT_YUV422_YUYV = ESP_COLOR_FOURCC_YUYV, ///< YUV422 packed in YUYV order
|
||||
LCD_COLOR_FMT_YUV422_YVYU = ESP_COLOR_FOURCC_YVYU, ///< YUV422 packed in YVYU order
|
||||
LCD_COLOR_FMT_YUV422_VYUY = ESP_COLOR_FOURCC_VYUY, ///< YUV422 packed in VYUY order
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -317,10 +317,7 @@ TEST_CASE("DMA2D_M2M_1D_RGB565_to_RGB888", "[DMA2D]")
|
||||
TEST_CASE("DMA2D_M2M_2D_basic", "[DMA2D]")
|
||||
{
|
||||
// Test a 128 x 128 pixel data block (one byte per pixel - assume A8)
|
||||
const color_space_pixel_format_t pixel_format = {
|
||||
.color_space = COLOR_SPACE_ALPHA,
|
||||
.pixel_format = COLOR_PIXEL_A8,
|
||||
};
|
||||
const esp_color_fourcc_t pixel_format = ESP_COLOR_FOURCC_ALPHA8;
|
||||
const uint32_t stripe_size = 128; // unit: bytes
|
||||
|
||||
memset(m2m_trans_config, 0, M2M_TRANS_TIMES * sizeof(dma2d_m2m_trans_config_t));
|
||||
@@ -452,14 +449,8 @@ static int rgb888_to_rgb565_and_cmp(void *__rgb888, void *__rgb565, int pix)
|
||||
TEST_CASE("DMA2D_M2M_2D_RGB888_to_RGB565", "[DMA2D]")
|
||||
{
|
||||
// Test a 64 x 64 pixel data block (original pixel in RGB888 format, convert to RGB565 format)
|
||||
const color_space_pixel_format_t in_pixel_format = {
|
||||
.color_space = COLOR_SPACE_RGB,
|
||||
.pixel_format = COLOR_PIXEL_RGB888,
|
||||
};
|
||||
const color_space_pixel_format_t out_pixel_format = {
|
||||
.color_space = COLOR_SPACE_RGB,
|
||||
.pixel_format = COLOR_PIXEL_RGB565,
|
||||
};
|
||||
const esp_color_fourcc_t in_pixel_format = ESP_COLOR_FOURCC_BGR24;
|
||||
const esp_color_fourcc_t out_pixel_format = ESP_COLOR_FOURCC_RGB16;
|
||||
const uint32_t stripe_pixel_size = 64; // unit: pixel
|
||||
|
||||
memset(m2m_trans_config, 0, M2M_TRANS_TIMES * sizeof(dma2d_m2m_trans_config_t));
|
||||
@@ -572,10 +563,7 @@ TEST_CASE("DMA2D_M2M_2D_RGB888_to_RGB565", "[DMA2D]")
|
||||
TEST_CASE("DMA2D_M2M_2D_window", "[DMA2D]")
|
||||
{
|
||||
// Test 2D memcpy to a 2 x 2 block at (2, 4) in a 8 x 8 picture (pixel in RGB565 format)
|
||||
const color_space_pixel_format_t pixel_format = {
|
||||
.color_space = COLOR_SPACE_RGB,
|
||||
.pixel_format = COLOR_PIXEL_RGB565,
|
||||
};
|
||||
const esp_color_fourcc_t pixel_format = ESP_COLOR_FOURCC_RGB16;
|
||||
const uint32_t va = 8, ha = 8; // Define picture height and width (unit: pixel)
|
||||
const uint32_t vb = 2, hb = 2; // Define block height and width (unit: pixel)
|
||||
const uint32_t x_offset = 2, y_offset = 4; // Define block location in the picture (unit: pixel)
|
||||
|
||||
@@ -60,7 +60,7 @@ typedef struct {
|
||||
size_t dst_offset_y; /*!< Copy action will start from this offset in destination buffer in the y direction, offset count in the number of pixels */
|
||||
size_t copy_size_x; /*!< Copy size in the x direction, size count in the number of pixels */
|
||||
size_t copy_size_y; /*!< Copy size in the y direction, size count in the number of pixels */
|
||||
uint32_t pixel_format_fourcc_id; /*!< Pixel format unique ID */
|
||||
esp_color_fourcc_t pixel_format_fourcc_id; /*!< Pixel format unique ID */
|
||||
} esp_async_fbcpy_trans_desc_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -101,7 +101,7 @@ static void async_memcpy_setup_dma2d_descriptor(esp_async_fbcpy_context_t* mcp_c
|
||||
dma2d_descriptor_t* tx_desc = mcp_ctx->tx_desc;
|
||||
dma2d_descriptor_t* rx_desc = mcp_ctx->rx_desc;
|
||||
size_t dma_desc_size = mcp_ctx->dma_desc_size;
|
||||
uint8_t dma2d_pbyte = dma2d_desc_pixel_format_to_pbyte_value_fourcc(transaction->pixel_format_fourcc_id);
|
||||
uint8_t dma2d_pbyte = dma2d_desc_pixel_format_to_pbyte_value(transaction->pixel_format_fourcc_id);
|
||||
|
||||
tx_desc->buffer = (void*)transaction->src_buffer;
|
||||
tx_desc->next = NULL;
|
||||
|
||||
@@ -43,9 +43,12 @@ uint32_t color_hal_pixel_format_get_bit_depth(color_space_pixel_format_t format)
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t color_hal_pixel_format_fourcc_get_bit_depth(uint32_t four_character_code)
|
||||
uint32_t color_hal_pixel_format_fourcc_get_bit_depth(esp_color_fourcc_t four_character_code)
|
||||
{
|
||||
switch (four_character_code) {
|
||||
case ESP_COLOR_FOURCC_ALPHA4:
|
||||
return 4;
|
||||
case ESP_COLOR_FOURCC_ALPHA8:
|
||||
case ESP_COLOR_FOURCC_GREY:
|
||||
return 8;
|
||||
case ESP_COLOR_FOURCC_OUYY_EVYY:
|
||||
@@ -54,11 +57,13 @@ uint32_t color_hal_pixel_format_fourcc_get_bit_depth(uint32_t four_character_cod
|
||||
case ESP_COLOR_FOURCC_UYVY:
|
||||
case ESP_COLOR_FOURCC_YVYU:
|
||||
case ESP_COLOR_FOURCC_VYUY:
|
||||
case ESP_COLOR_FOURCC_RGB16_BE:
|
||||
case ESP_COLOR_FOURCC_RGB16:
|
||||
return 16;
|
||||
case ESP_COLOR_FOURCC_RGB24:
|
||||
case ESP_COLOR_FOURCC_BGR24:
|
||||
case ESP_COLOR_FOURCC_YUV:
|
||||
return 24;
|
||||
case ESP_COLOR_FOURCC_BGRA32:
|
||||
return 32;
|
||||
default:
|
||||
// Unknown color space pixel format, unknown bit depth
|
||||
HAL_ASSERT(false);
|
||||
|
||||
@@ -205,6 +205,38 @@ static inline void ppa_ll_srm_start(ppa_dev_t *dev)
|
||||
dev->sr_scal_rotate.scal_rotate_start = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PPA SRM input side YUV422 data format packing order
|
||||
*
|
||||
* @param dev Peripheral instance address
|
||||
* @param color_mode One of the values in ppa_srm_color_mode_t
|
||||
*/
|
||||
static inline void ppa_ll_srm_set_rx_yuv422_pack_order(ppa_dev_t *dev, ppa_srm_color_mode_t color_mode)
|
||||
{
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
|
||||
switch (color_mode) {
|
||||
case PPA_SRM_COLOR_MODE_YUV422_YVYU:
|
||||
dev->sr_color_mode.yuv422_rx_byte_order = 3;
|
||||
break;
|
||||
case PPA_SRM_COLOR_MODE_YUV422_YUYV:
|
||||
dev->sr_color_mode.yuv422_rx_byte_order = 2;
|
||||
break;
|
||||
case PPA_SRM_COLOR_MODE_YUV422_VYUY:
|
||||
dev->sr_color_mode.yuv422_rx_byte_order = 1;
|
||||
break;
|
||||
case PPA_SRM_COLOR_MODE_YUV422_UYVY:
|
||||
dev->sr_color_mode.yuv422_rx_byte_order = 0;
|
||||
break;
|
||||
default:
|
||||
// Unsupported YUV422 pack order
|
||||
abort();
|
||||
}
|
||||
#else
|
||||
// YUV422 not supported by PPA SRM hardware before P4 ECO5
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the given color mode is supported by PPA SRM engine
|
||||
*
|
||||
@@ -220,7 +252,10 @@ static inline bool ppa_ll_srm_is_color_mode_supported(ppa_srm_color_mode_t color
|
||||
case PPA_SRM_COLOR_MODE_YUV420:
|
||||
case PPA_SRM_COLOR_MODE_YUV444: // YUV444 not supported by PPA hardware, but can be converted by 2D-DMA before PPA, and not supported as output color mode
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
|
||||
case PPA_SRM_COLOR_MODE_YUV422:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_UYVY:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_VYUY:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_YUYV:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_YVYU:
|
||||
case PPA_SRM_COLOR_MODE_GRAY8:
|
||||
#endif
|
||||
return true;
|
||||
@@ -238,6 +273,7 @@ static inline bool ppa_ll_srm_is_color_mode_supported(ppa_srm_color_mode_t color
|
||||
static inline void ppa_ll_srm_set_rx_color_mode(ppa_dev_t *dev, ppa_srm_color_mode_t color_mode)
|
||||
{
|
||||
uint32_t val = 0;
|
||||
bool is_yuv422 __attribute__ ((unused)) = false;
|
||||
switch (color_mode) {
|
||||
case PPA_SRM_COLOR_MODE_ARGB8888:
|
||||
val = 0;
|
||||
@@ -252,8 +288,12 @@ static inline void ppa_ll_srm_set_rx_color_mode(ppa_dev_t *dev, ppa_srm_color_mo
|
||||
val = 8;
|
||||
break;
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
|
||||
case PPA_SRM_COLOR_MODE_YUV422:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_UYVY:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_VYUY:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_YUYV:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_YVYU:
|
||||
val = 9;
|
||||
is_yuv422 = true;
|
||||
break;
|
||||
case PPA_SRM_COLOR_MODE_GRAY8:
|
||||
val = 12;
|
||||
@@ -264,6 +304,13 @@ static inline void ppa_ll_srm_set_rx_color_mode(ppa_dev_t *dev, ppa_srm_color_mo
|
||||
abort();
|
||||
}
|
||||
dev->sr_color_mode.sr_rx_cm = val;
|
||||
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
|
||||
// set YUV422 packing order
|
||||
if (is_yuv422) {
|
||||
ppa_ll_srm_set_rx_yuv422_pack_order(dev, color_mode);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,7 +336,7 @@ static inline void ppa_ll_srm_set_tx_color_mode(ppa_dev_t *dev, ppa_srm_color_mo
|
||||
val = 8;
|
||||
break;
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
|
||||
case PPA_SRM_COLOR_MODE_YUV422:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_UYVY:
|
||||
val = 9;
|
||||
break;
|
||||
case PPA_SRM_COLOR_MODE_GRAY8:
|
||||
@@ -387,38 +434,6 @@ static inline void ppa_ll_srm_set_tx_yuv_range(ppa_dev_t *dev, ppa_color_range_t
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PPA SRM input side YUV422 data format packing order
|
||||
*
|
||||
* @param dev Peripheral instance address
|
||||
* @param pack_order One of the pack order options in color_yuv422_pack_order_t
|
||||
*/
|
||||
static inline void ppa_ll_srm_set_rx_yuv422_pack_order(ppa_dev_t *dev, color_yuv422_pack_order_t pack_order)
|
||||
{
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
|
||||
switch (pack_order) {
|
||||
case COLOR_YUV422_PACK_ORDER_YVYU:
|
||||
dev->sr_color_mode.yuv422_rx_byte_order = 0;
|
||||
break;
|
||||
case COLOR_YUV422_PACK_ORDER_YUYV:
|
||||
dev->sr_color_mode.yuv422_rx_byte_order = 1;
|
||||
break;
|
||||
case COLOR_YUV422_PACK_ORDER_VYUY:
|
||||
dev->sr_color_mode.yuv422_rx_byte_order = 2;
|
||||
break;
|
||||
case COLOR_YUV422_PACK_ORDER_UYVY:
|
||||
dev->sr_color_mode.yuv422_rx_byte_order = 3;
|
||||
break;
|
||||
default:
|
||||
// Unsupported YUV422 pack order
|
||||
abort();
|
||||
}
|
||||
#else
|
||||
// YUV422 not supported by PPA SRM hardware before P4 ECO5
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable PPA SRM input data swap in RGB (e.g. ARGB becomes BGRA, RGB becomes BGR)
|
||||
*
|
||||
@@ -543,7 +558,10 @@ static inline void ppa_ll_srm_get_dma_dscr_port_mode_block_size(ppa_dev_t *dev,
|
||||
*block_h = 20;
|
||||
*block_v = 18;
|
||||
break;
|
||||
case PPA_SRM_COLOR_MODE_YUV422:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_UYVY:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_VYUY:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_YUYV:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_YVYU:
|
||||
*block_h = 20;
|
||||
*block_v = 20;
|
||||
break;
|
||||
@@ -567,7 +585,10 @@ static inline void ppa_ll_srm_get_dma_dscr_port_mode_block_size(ppa_dev_t *dev,
|
||||
*block_h = 36;
|
||||
*block_v = 34;
|
||||
break;
|
||||
case PPA_SRM_COLOR_MODE_YUV422:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_UYVY:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_VYUY:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_YUYV:
|
||||
case PPA_SRM_COLOR_MODE_YUV422_YVYU:
|
||||
*block_h = 36;
|
||||
*block_v = 36;
|
||||
break;
|
||||
@@ -645,6 +666,38 @@ static inline void ppa_ll_blend_start(ppa_dev_t *dev, ppa_ll_blend_trans_mode_t
|
||||
dev->blend_trans_mode.blend_trans_mode_update = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PPA blending source image background YUV422 data format packing order
|
||||
*
|
||||
* @param dev Peripheral instance address
|
||||
* @param color_mode One of the values in ppa_blend_color_mode_t
|
||||
*/
|
||||
static inline void ppa_ll_blend_set_rx_bg_yuv422_pack_order(ppa_dev_t *dev, ppa_blend_color_mode_t color_mode)
|
||||
{
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
|
||||
switch (color_mode) {
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_YVYU:
|
||||
dev->blend_color_mode.blend0_rx_yuv422_byte_order = 3;
|
||||
break;
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_YUYV:
|
||||
dev->blend_color_mode.blend0_rx_yuv422_byte_order = 2;
|
||||
break;
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_VYUY:
|
||||
dev->blend_color_mode.blend0_rx_yuv422_byte_order = 1;
|
||||
break;
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_UYVY:
|
||||
dev->blend_color_mode.blend0_rx_yuv422_byte_order = 0;
|
||||
break;
|
||||
default:
|
||||
// Unsupported YUV422 pack order
|
||||
abort();
|
||||
}
|
||||
#else
|
||||
// YUV422 not supported by PPA blending hardware before P4 ECO5
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the given color mode is supported by PPA blending engine
|
||||
*
|
||||
@@ -663,7 +716,10 @@ static inline bool ppa_ll_blend_is_color_mode_supported(ppa_blend_color_mode_t c
|
||||
// case PPA_BLEND_COLOR_MODE_L4:
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
|
||||
case PPA_BLEND_COLOR_MODE_YUV420:
|
||||
case PPA_BLEND_COLOR_MODE_YUV422:
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_UYVY:
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_VYUY:
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_YUYV:
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_YVYU:
|
||||
case PPA_BLEND_COLOR_MODE_GRAY8:
|
||||
#endif
|
||||
return true;
|
||||
@@ -681,6 +737,7 @@ static inline bool ppa_ll_blend_is_color_mode_supported(ppa_blend_color_mode_t c
|
||||
static inline void ppa_ll_blend_set_rx_bg_color_mode(ppa_dev_t *dev, ppa_blend_color_mode_t color_mode)
|
||||
{
|
||||
uint32_t val = 0;
|
||||
bool is_yuv422 __attribute__ ((unused)) = false;
|
||||
switch (color_mode) {
|
||||
case PPA_BLEND_COLOR_MODE_ARGB8888:
|
||||
val = 0;
|
||||
@@ -701,8 +758,12 @@ static inline void ppa_ll_blend_set_rx_bg_color_mode(ppa_dev_t *dev, ppa_blend_c
|
||||
case PPA_BLEND_COLOR_MODE_YUV420:
|
||||
val = 8;
|
||||
break;
|
||||
case PPA_BLEND_COLOR_MODE_YUV422:
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_UYVY:
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_VYUY:
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_YUYV:
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_YVYU:
|
||||
val = 9;
|
||||
is_yuv422 = true;
|
||||
break;
|
||||
case PPA_BLEND_COLOR_MODE_GRAY8:
|
||||
val = 12;
|
||||
@@ -713,6 +774,13 @@ static inline void ppa_ll_blend_set_rx_bg_color_mode(ppa_dev_t *dev, ppa_blend_c
|
||||
abort();
|
||||
}
|
||||
dev->blend_color_mode.blend0_rx_cm = val;
|
||||
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
|
||||
// set YUV422 packing order
|
||||
if (is_yuv422) {
|
||||
ppa_ll_blend_set_rx_bg_yuv422_pack_order(dev, color_mode);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -776,7 +844,7 @@ static inline void ppa_ll_blend_set_tx_color_mode(ppa_dev_t *dev, ppa_blend_colo
|
||||
case PPA_BLEND_COLOR_MODE_YUV420:
|
||||
val = 8;
|
||||
break;
|
||||
case PPA_BLEND_COLOR_MODE_YUV422:
|
||||
case PPA_BLEND_COLOR_MODE_YUV422_UYVY:
|
||||
val = 9;
|
||||
break;
|
||||
case PPA_BLEND_COLOR_MODE_GRAY8:
|
||||
@@ -894,38 +962,6 @@ static inline void ppa_ll_blend_set_tx_yuv_range(ppa_dev_t *dev, ppa_color_range
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PPA blending source image background YUV422 data format packing order
|
||||
*
|
||||
* @param dev Peripheral instance address
|
||||
* @param pack_order One of the pack order options in color_yuv422_pack_order_t
|
||||
*/
|
||||
static inline void ppa_ll_blend_set_rx_bg_yuv422_pack_order(ppa_dev_t *dev, color_yuv422_pack_order_t pack_order)
|
||||
{
|
||||
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
|
||||
switch (pack_order) {
|
||||
case COLOR_YUV422_PACK_ORDER_YVYU:
|
||||
dev->blend_color_mode.blend0_rx_yuv422_byte_order = 0;
|
||||
break;
|
||||
case COLOR_YUV422_PACK_ORDER_YUYV:
|
||||
dev->blend_color_mode.blend0_rx_yuv422_byte_order = 1;
|
||||
break;
|
||||
case COLOR_YUV422_PACK_ORDER_VYUY:
|
||||
dev->blend_color_mode.blend0_rx_yuv422_byte_order = 2;
|
||||
break;
|
||||
case COLOR_YUV422_PACK_ORDER_UYVY:
|
||||
dev->blend_color_mode.blend0_rx_yuv422_byte_order = 3;
|
||||
break;
|
||||
default:
|
||||
// Unsupported YUV422 pack order
|
||||
abort();
|
||||
}
|
||||
#else
|
||||
// YUV422 not supported by PPA blending hardware before P4 ECO5
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable PPA blending input background data wrap in RGB (e.g. ARGB becomes BGRA, RGB becomes BGR)
|
||||
*
|
||||
@@ -1069,7 +1105,7 @@ static inline void ppa_ll_blend_configure_filling_block(ppa_dev_t *dev, ppa_fill
|
||||
case PPA_FILL_COLOR_MODE_GRAY8:
|
||||
fill_color_data = *(uint32_t *)data;
|
||||
break;
|
||||
case PPA_FILL_COLOR_MODE_YUV422: {
|
||||
case PPA_FILL_COLOR_MODE_YUV422_UYVY: {
|
||||
color_macroblock_yuv_data_t *yuv_data = (color_macroblock_yuv_data_t *)data;
|
||||
fill_color_data = ((yuv_data->y) << 24) | ((yuv_data->v) << 16) | ((yuv_data->y) << 8) | (yuv_data->u);
|
||||
break;
|
||||
|
||||
@@ -30,7 +30,7 @@ uint32_t color_hal_pixel_format_get_bit_depth(color_space_pixel_format_t color_t
|
||||
*
|
||||
* @return Number of bits per pixel
|
||||
*/
|
||||
uint32_t color_hal_pixel_format_fourcc_get_bit_depth(uint32_t four_character_code);
|
||||
uint32_t color_hal_pixel_format_fourcc_get_bit_depth(esp_color_fourcc_t four_character_code);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -16,26 +16,42 @@ extern "C" {
|
||||
Four Character Code
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Four Character Code type definition
|
||||
*/
|
||||
typedef uint32_t esp_color_fourcc_t;
|
||||
|
||||
#define ESP_COLOR_FOURCC(a, b, c, d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
|
||||
|
||||
/**
|
||||
* RGB24
|
||||
* BGRA32
|
||||
* Memory Layout:
|
||||
* | bit7 - bit0 |
|
||||
* Byte 2: | B7 - B0 |
|
||||
* Byte 3: | A7 - A0 |
|
||||
* Byte 2: | R7 - R0 |
|
||||
* Byte 1: | G7 - G0 |
|
||||
* Byte 0: | R7 - R0 |
|
||||
* Byte 0: | B7 - B0 |
|
||||
*/
|
||||
#define ESP_COLOR_FOURCC_RGB24 ESP_COLOR_FOURCC('R', 'G', 'B', '3') /* 24 bpp RGB-8-8-8 */
|
||||
#define ESP_COLOR_FOURCC_BGRA32 ESP_COLOR_FOURCC('B', 'A', '2', '4') /* 32 bpp BGRA-8-8-8-8 */
|
||||
|
||||
/**
|
||||
* RGB565_BE
|
||||
* BGR24
|
||||
* Memory Layout:
|
||||
* | bit7 - bit0 |
|
||||
* Byte 2: | R7 - R0 |
|
||||
* Byte 1: | G7 - G0 |
|
||||
* Byte 0: | B7 - B0 |
|
||||
*/
|
||||
#define ESP_COLOR_FOURCC_BGR24 ESP_COLOR_FOURCC('B', 'G', 'R', '3') /* 24 bpp BGR-8-8-8 */
|
||||
|
||||
/**
|
||||
* RGB565
|
||||
* Memory Layout:
|
||||
* | bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 |
|
||||
* Byte 1: | G2 G1 G0 | B4 B3 B2 B1 B0 |
|
||||
* Byte 0: | R4 R3 R2 R1 R0 | G5 G4 G3 |
|
||||
* Byte 1: | R4 R3 R2 R1 R0 | G5 G4 G3 |
|
||||
* Byte 0: | G2 G1 G0 | B4 B3 B2 B1 B0 |
|
||||
*/
|
||||
#define ESP_COLOR_FOURCC_RGB16_BE ESP_COLOR_FOURCC('R', 'G', 'B', 'B') /* 16 bpp RGB-5-6-5, big endian */
|
||||
#define ESP_COLOR_FOURCC_RGB16 ESP_COLOR_FOURCC('R', 'G', 'B', 'L') /* 16 bpp RGB-5-6-5, little endian */
|
||||
|
||||
/**
|
||||
* Grey8
|
||||
@@ -45,6 +61,22 @@ extern "C" {
|
||||
*/
|
||||
#define ESP_COLOR_FOURCC_GREY ESP_COLOR_FOURCC('G', 'R', 'E', 'Y') /* 8 bpp Greyscale */
|
||||
|
||||
/**
|
||||
* ALPHA4 (Alpha 4 bits)
|
||||
* Memory Layout:
|
||||
* Addr0 Addr1 Addr2 Addr3
|
||||
* A0A1 A2A3 A4A5 A6A7
|
||||
*/
|
||||
#define ESP_COLOR_FOURCC_ALPHA4 ESP_COLOR_FOURCC('A', 'L', 'P', '4') /* 4 bpp, an 4-bit alpha-only format */
|
||||
|
||||
/**
|
||||
* ALPHA8 (Alpha 8 bits)
|
||||
* Memory Layout:
|
||||
* Addr0 Addr1 Addr2 Addr3
|
||||
* A0 A1 A2 A3
|
||||
*/
|
||||
#define ESP_COLOR_FOURCC_ALPHA8 ESP_COLOR_FOURCC('A', 'L', 'P', '8') /* 8 bpp, an 8-bit alpha-only format */
|
||||
|
||||
/**
|
||||
* YUV444
|
||||
* Memory Layout:
|
||||
@@ -75,9 +107,9 @@ extern "C" {
|
||||
/**
|
||||
* UYVY422
|
||||
* Memory Layout:
|
||||
* +--+--+--+--+ +--+--+--+--+
|
||||
* |U0|Y0|V0|Y1| |U2|Y2|V2|Y3|
|
||||
* +--+--+--+--+ +--+--+--+--+
|
||||
* +--+--+--+--+ +--+--+--+--+
|
||||
* (lowest byte) |U0|Y0|V0|Y1| |U2|Y2|V2|Y3|
|
||||
* +--+--+--+--+ +--+--+--+--+
|
||||
*/
|
||||
#define ESP_COLOR_FOURCC_UYVY ESP_COLOR_FOURCC('U', 'Y', 'V', 'Y') /* 16 bpp, UYVY 4:2:2 */
|
||||
|
||||
@@ -222,16 +254,6 @@ typedef enum {
|
||||
COLOR_COMPONENT_INVALID, /*!< Invalid color component */
|
||||
} color_component_t;
|
||||
|
||||
/**
|
||||
* @brief The order of the components per pack in the YUV422 format
|
||||
*/
|
||||
typedef enum {
|
||||
COLOR_YUV422_PACK_ORDER_YUYV, /*!< YUYV */
|
||||
COLOR_YUV422_PACK_ORDER_YVYU, /*!< YVYU */
|
||||
COLOR_YUV422_PACK_ORDER_UYVY, /*!< UYVY */
|
||||
COLOR_YUV422_PACK_ORDER_VYUY, /*!< VYUY */
|
||||
} color_yuv422_pack_order_t;
|
||||
|
||||
///< The following values are deprecated, please use the FOURCC values instead, IDF-14284
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
@@ -339,7 +361,6 @@ typedef union {
|
||||
uint32_t color_type_id; ///< Unique type of a certain color pixel format
|
||||
} color_space_pixel_format_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -76,31 +76,9 @@ typedef dma2d_descriptor_align8_t dma2d_descriptor_t;
|
||||
#define DMA2D_DESCRIPTOR_PBYTE_4B0_PER_PIXEL (5) /*!< 2D-DMA descriptor pbyte value when 4 bytes/pixel */
|
||||
|
||||
// Helper function to convert pixel format to 2D-DMA descriptor pbyte value
|
||||
static inline uint32_t dma2d_desc_pixel_format_to_pbyte_value(color_space_pixel_format_t pixel_format)
|
||||
static inline uint32_t dma2d_desc_pixel_format_to_pbyte_value(esp_color_fourcc_t pixel_format)
|
||||
{
|
||||
switch (color_hal_pixel_format_get_bit_depth(pixel_format)) {
|
||||
case 4:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_0B5_PER_PIXEL;
|
||||
case 8:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_1B0_PER_PIXEL;
|
||||
case 12:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_1B5_PER_PIXEL;
|
||||
case 16:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_2B0_PER_PIXEL;
|
||||
case 24:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_3B0_PER_PIXEL;
|
||||
case 32:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_4B0_PER_PIXEL;
|
||||
default:
|
||||
// Unsupported bit depth
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to convert pixel format to 2D-DMA descriptor pbyte value
|
||||
static inline uint32_t dma2d_desc_pixel_format_to_pbyte_value_fourcc(uint32_t four_character_code)
|
||||
{
|
||||
switch (color_hal_pixel_format_fourcc_get_bit_depth(four_character_code)) {
|
||||
switch (color_hal_pixel_format_fourcc_get_bit_depth(pixel_format)) {
|
||||
case 4:
|
||||
return DMA2D_DESCRIPTOR_PBYTE_0B5_PER_PIXEL;
|
||||
case 8:
|
||||
|
||||
@@ -36,44 +36,50 @@ typedef enum {
|
||||
* @brief Enumeration of PPA Scaling-Rotating-Mirroring available color mode
|
||||
*/
|
||||
typedef enum {
|
||||
PPA_SRM_COLOR_MODE_ARGB8888 = COLOR_TYPE_ID(COLOR_SPACE_ARGB, COLOR_PIXEL_ARGB8888), /*!< PPA SRM color mode: ARGB8888 */
|
||||
PPA_SRM_COLOR_MODE_RGB888 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB888), /*!< PPA SRM color mode: RGB888 */
|
||||
PPA_SRM_COLOR_MODE_RGB565 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB565), /*!< PPA SRM color mode: RGB565 */
|
||||
PPA_SRM_COLOR_MODE_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), /*!< PPA SRM color mode: YUV420 */
|
||||
PPA_SRM_COLOR_MODE_YUV444 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV444), /*!< PPA SRM color mode: YUV444 (limited range only and can only be the input color mode)*/
|
||||
PPA_SRM_COLOR_MODE_ARGB8888 = ESP_COLOR_FOURCC_BGRA32, /*!< PPA SRM color mode: ARGB8888 */
|
||||
PPA_SRM_COLOR_MODE_RGB888 = ESP_COLOR_FOURCC_BGR24, /*!< PPA SRM color mode: RGB888 */
|
||||
PPA_SRM_COLOR_MODE_RGB565 = ESP_COLOR_FOURCC_RGB16, /*!< PPA SRM color mode: RGB565 */
|
||||
PPA_SRM_COLOR_MODE_YUV420 = ESP_COLOR_FOURCC_OUYY_EVYY, /*!< PPA SRM color mode: YUV420 */
|
||||
PPA_SRM_COLOR_MODE_YUV444 = ESP_COLOR_FOURCC_YUV, /*!< PPA SRM color mode: YUV444 (limited range only and can only be the input color mode) */
|
||||
// YUV444 not supported by PPA hardware, but we can use 2D-DMA to do conversion before sending into the PPA module
|
||||
// If in_pic is YUV444, then TX DMA channel could do DMA2D_CSC_TX_YUV444_TO_RGB888_601/709, so PPA in_color_mode is RGB888
|
||||
PPA_SRM_COLOR_MODE_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), /*!< PPA SRM color mode: YUV422 (input data pack order all supported, but output data format is fixed to YVYU) */
|
||||
PPA_SRM_COLOR_MODE_GRAY8 = COLOR_TYPE_ID(COLOR_SPACE_GRAY, COLOR_PIXEL_GRAY8), /*!< PPA SRM color mode: GRAY8 */
|
||||
PPA_SRM_COLOR_MODE_YUV422_UYVY = ESP_COLOR_FOURCC_UYVY, /*!< PPA SRM color mode: YUV422 */
|
||||
PPA_SRM_COLOR_MODE_YUV422_VYUY = ESP_COLOR_FOURCC_VYUY, /*!< PPA SRM color mode: YUV422, only available on input */
|
||||
PPA_SRM_COLOR_MODE_YUV422_YUYV = ESP_COLOR_FOURCC_YUYV, /*!< PPA SRM color mode: YUV422, only available on input */
|
||||
PPA_SRM_COLOR_MODE_YUV422_YVYU = ESP_COLOR_FOURCC_YVYU, /*!< PPA SRM color mode: YUV422, only available on input */
|
||||
PPA_SRM_COLOR_MODE_GRAY8 = ESP_COLOR_FOURCC_GREY, /*!< PPA SRM color mode: GRAY8 */
|
||||
} ppa_srm_color_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Enumeration of PPA blend available color mode
|
||||
*/
|
||||
typedef enum {
|
||||
PPA_BLEND_COLOR_MODE_ARGB8888 = COLOR_TYPE_ID(COLOR_SPACE_ARGB, COLOR_PIXEL_ARGB8888), /*!< PPA blend color mode: ARGB8888 */
|
||||
PPA_BLEND_COLOR_MODE_RGB888 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB888), /*!< PPA blend color mode: RGB888 */
|
||||
PPA_BLEND_COLOR_MODE_RGB565 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB565), /*!< PPA blend color mode: RGB565 */
|
||||
PPA_BLEND_COLOR_MODE_A8 = COLOR_TYPE_ID(COLOR_SPACE_ALPHA, COLOR_PIXEL_A8), /*!< PPA blend color mode: A8, only available on blend foreground input */
|
||||
PPA_BLEND_COLOR_MODE_A4 = COLOR_TYPE_ID(COLOR_SPACE_ALPHA, COLOR_PIXEL_A4), /*!< PPA blend color mode: A4, only available on blend foreground input */
|
||||
PPA_BLEND_COLOR_MODE_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), /*!< PPA blend color mode: YUV420, only available on blend background input or on output */
|
||||
PPA_BLEND_COLOR_MODE_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), /*!< PPA blend color mode: YUV422, only available on blend background input (all pack order supported) or on output (fixed to YVYU) */
|
||||
PPA_BLEND_COLOR_MODE_GRAY8 = COLOR_TYPE_ID(COLOR_SPACE_GRAY, COLOR_PIXEL_GRAY8), /*!< PPA blend color mode: GRAY8, only available on blend background input or on output */
|
||||
PPA_BLEND_COLOR_MODE_ARGB8888 = ESP_COLOR_FOURCC_BGRA32, /*!< PPA blend color mode: ARGB8888 */
|
||||
PPA_BLEND_COLOR_MODE_RGB888 = ESP_COLOR_FOURCC_BGR24, /*!< PPA blend color mode: RGB888 */
|
||||
PPA_BLEND_COLOR_MODE_RGB565 = ESP_COLOR_FOURCC_RGB16, /*!< PPA blend color mode: RGB565 */
|
||||
PPA_BLEND_COLOR_MODE_A8 = ESP_COLOR_FOURCC_ALPHA8, /*!< PPA blend color mode: A8, only available on blend foreground input */
|
||||
PPA_BLEND_COLOR_MODE_A4 = ESP_COLOR_FOURCC_ALPHA4, /*!< PPA blend color mode: A4, only available on blend foreground input */
|
||||
PPA_BLEND_COLOR_MODE_YUV420 = ESP_COLOR_FOURCC_OUYY_EVYY, /*!< PPA blend color mode: YUV420, only available on blend background input or on output */
|
||||
PPA_BLEND_COLOR_MODE_YUV422_UYVY = ESP_COLOR_FOURCC_UYVY, /*!< PPA blend color mode: YUV422, only available on blend background input or on output */
|
||||
PPA_BLEND_COLOR_MODE_YUV422_VYUY = ESP_COLOR_FOURCC_VYUY, /*!< PPA blend color mode: YUV422, only available on blend background input */
|
||||
PPA_BLEND_COLOR_MODE_YUV422_YUYV = ESP_COLOR_FOURCC_YUYV, /*!< PPA blend color mode: YUV422, only available on blend background input */
|
||||
PPA_BLEND_COLOR_MODE_YUV422_YVYU = ESP_COLOR_FOURCC_YVYU, /*!< PPA blend color mode: YUV422, only available on blend background input */
|
||||
PPA_BLEND_COLOR_MODE_GRAY8 = ESP_COLOR_FOURCC_GREY, /*!< PPA blend color mode: GRAY8, only available on blend background input or on output */
|
||||
// TODO: Support CLUT to support L4/L8 color mode
|
||||
// PPA_BLEND_COLOR_MODE_L8 = COLOR_TYPE_ID(COLOR_SPACE_CLUT, COLOR_PIXEL_L8), /*!< PPA blend color mode: L8, only available on blend input */
|
||||
// PPA_BLEND_COLOR_MODE_L4 = COLOR_TYPE_ID(COLOR_SPACE_CLUT, COLOR_PIXEL_L4), /*!< PPA blend color mode: L4, only available on blend input */
|
||||
// PPA_BLEND_COLOR_MODE_L8, /*!< PPA blend color mode: L8, only available on blend input */
|
||||
// PPA_BLEND_COLOR_MODE_L4, /*!< PPA blend color mode: L4, only available on blend input */
|
||||
} ppa_blend_color_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Enumeration of PPA fill available color mode
|
||||
*/
|
||||
typedef enum {
|
||||
PPA_FILL_COLOR_MODE_ARGB8888 = COLOR_TYPE_ID(COLOR_SPACE_ARGB, COLOR_PIXEL_ARGB8888), /*!< PPA fill color mode: ARGB8888 */
|
||||
PPA_FILL_COLOR_MODE_RGB888 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB888), /*!< PPA fill color mode: RGB888 */
|
||||
PPA_FILL_COLOR_MODE_RGB565 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB565), /*!< PPA fill color mode: RGB565 */
|
||||
// PPA_FILL_COLOR_MODE_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), /*!< PPA fill color mode: YUV420 */ // Non-typical YUV420, U and V components have to be the same value
|
||||
PPA_FILL_COLOR_MODE_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), /*!< PPA fill color mode: YUV422 (w/ YVYU pack order) */
|
||||
PPA_FILL_COLOR_MODE_GRAY8 = COLOR_TYPE_ID(COLOR_SPACE_GRAY, COLOR_PIXEL_GRAY8), /*!< PPA fill color mode: GRAY8 */
|
||||
PPA_FILL_COLOR_MODE_ARGB8888 = ESP_COLOR_FOURCC_BGRA32, /*!< PPA fill color mode: ARGB8888 */
|
||||
PPA_FILL_COLOR_MODE_RGB888 = ESP_COLOR_FOURCC_BGR24, /*!< PPA fill color mode: RGB888 */
|
||||
PPA_FILL_COLOR_MODE_RGB565 = ESP_COLOR_FOURCC_RGB16, /*!< PPA fill color mode: RGB565 */
|
||||
// PPA_FILL_COLOR_MODE_YUV420, /*!< PPA fill color mode: YUV420 */ // Non-typical YUV420, U and V components have to be the same value
|
||||
PPA_FILL_COLOR_MODE_YUV422_UYVY = ESP_COLOR_FOURCC_UYVY, /*!< PPA fill color mode: YUV422 (w/ UYVY pack order) */
|
||||
PPA_FILL_COLOR_MODE_GRAY8 = ESP_COLOR_FOURCC_GREY, /*!< PPA fill color mode: GRAY8 */
|
||||
} ppa_fill_color_mode_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -287,7 +287,7 @@ extern "C" {
|
||||
#define PPA_RGB2YUV_PROTOCOL_V 0x00000001U
|
||||
#define PPA_RGB2YUV_PROTOCOL_S 11
|
||||
/** PPA_YUV422_RX_BYTE_ORDER : R/W; bitpos: [13:12]; default: 0;
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY (high addr -> low addr)
|
||||
*/
|
||||
#define PPA_YUV422_RX_BYTE_ORDER 0x00000003U
|
||||
#define PPA_YUV422_RX_BYTE_ORDER_M (PPA_YUV422_RX_BYTE_ORDER_V << PPA_YUV422_RX_BYTE_ORDER_S)
|
||||
@@ -351,7 +351,7 @@ extern "C" {
|
||||
#define PPA_BLEND_TX_RGB2YUV_PROTOCOL_V 0x00000001U
|
||||
#define PPA_BLEND_TX_RGB2YUV_PROTOCOL_S 15
|
||||
/** PPA_BLEND0_RX_YUV422_BYTE_ORDER : R/W; bitpos: [17:16]; default: 0;
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY (high addr -> low addr)
|
||||
*/
|
||||
#define PPA_BLEND0_RX_YUV422_BYTE_ORDER 0x00000003U
|
||||
#define PPA_BLEND0_RX_YUV422_BYTE_ORDER_M (PPA_BLEND0_RX_YUV422_BYTE_ORDER_V << PPA_BLEND0_RX_YUV422_BYTE_ORDER_S)
|
||||
|
||||
@@ -116,7 +116,7 @@ typedef union {
|
||||
*/
|
||||
uint32_t rgb2yuv_protocol:1;
|
||||
/** yuv422_rx_byte_order : R/W; bitpos: [13:12]; default: 0;
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY (high addr -> low addr)
|
||||
*/
|
||||
uint32_t yuv422_rx_byte_order:2;
|
||||
uint32_t reserved_14:18;
|
||||
@@ -161,7 +161,7 @@ typedef union {
|
||||
*/
|
||||
uint32_t blend_tx_rgb2yuv_protocol:1;
|
||||
/** blend0_rx_yuv422_byte_order : R/W; bitpos: [17:16]; default: 0;
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY (high addr -> low addr)
|
||||
*/
|
||||
uint32_t blend0_rx_yuv422_byte_order:2;
|
||||
uint32_t reserved_18:14;
|
||||
|
||||
@@ -288,7 +288,7 @@ extern "C" {
|
||||
#define PPA_RGB2YUV_PROTOCAL_V 0x00000001U
|
||||
#define PPA_RGB2YUV_PROTOCAL_S 11
|
||||
/** PPA_YUV422_RX_BYTE_ORDER : R/W; bitpos: [13:12]; default: 0;
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY (high addr -> low addr)
|
||||
*/
|
||||
#define PPA_YUV422_RX_BYTE_ORDER 0x00000003U
|
||||
#define PPA_YUV422_RX_BYTE_ORDER_M (PPA_YUV422_RX_BYTE_ORDER_V << PPA_YUV422_RX_BYTE_ORDER_S)
|
||||
@@ -352,7 +352,7 @@ extern "C" {
|
||||
#define PPA_BLEND_TX_RGB2YUV_PROTOCAL_V 0x00000001U
|
||||
#define PPA_BLEND_TX_RGB2YUV_PROTOCAL_S 15
|
||||
/** PPA_BLEND0_RX_YUV422_BYTE_ORDER : R/W; bitpos: [17:16]; default: 0;
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY (high addr -> low addr)
|
||||
*/
|
||||
#define PPA_BLEND0_RX_YUV422_BYTE_ORDER 0x00000003U
|
||||
#define PPA_BLEND0_RX_YUV422_BYTE_ORDER_M (PPA_BLEND0_RX_YUV422_BYTE_ORDER_V << PPA_BLEND0_RX_YUV422_BYTE_ORDER_S)
|
||||
|
||||
@@ -117,7 +117,7 @@ typedef union {
|
||||
*/
|
||||
uint32_t rgb2yuv_protocal:1;
|
||||
/** yuv422_rx_byte_order : R/W; bitpos: [13:12]; default: 0;
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY (high addr -> low addr)
|
||||
*/
|
||||
uint32_t yuv422_rx_byte_order:2;
|
||||
uint32_t reserved_14:18;
|
||||
@@ -162,7 +162,7 @@ typedef union {
|
||||
*/
|
||||
uint32_t blend_tx_rgb2yuv_protocal:1;
|
||||
/** blend0_rx_yuv422_byte_order : R/W; bitpos: [17:16]; default: 0;
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY
|
||||
* YUV422 input byte order when reg_sr_rx_cm is 4'd9. 0: YVYU, 1:YUYV, 2: VYUY, 3: UYVY (high addr -> low addr)
|
||||
*/
|
||||
uint32_t blend0_rx_yuv422_byte_order:2;
|
||||
uint32_t reserved_18:14;
|
||||
|
||||
Reference in New Issue
Block a user