Skip to content

Commit 4875518

Browse files
committed
Merge branch 'refactor/ppa_dma2d_fourcc' into 'master'
refactor(ppa): use fourcc for dma2d and ppa color formats Closes IDF-14234 See merge request espressif/esp-idf!43435
2 parents 3865eb1 + fe8ace8 commit 4875518

File tree

24 files changed

+274
-332
lines changed

24 files changed

+274
-332
lines changed

components/esp_driver_jpeg/include/driver/jpeg_types.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ extern "C" {
1919
* @brief Enumeration for jpeg output format.
2020
*/
2121
typedef enum {
22-
JPEG_DECODE_OUT_FORMAT_RGB888 = ESP_COLOR_FOURCC_RGB24, /*!< output RGB888 format */
23-
JPEG_DECODE_OUT_FORMAT_RGB565 = ESP_COLOR_FOURCC_RGB16_BE, /*!< output RGB565 format */
22+
JPEG_DECODE_OUT_FORMAT_RGB888 = ESP_COLOR_FOURCC_BGR24, /*!< output RGB888 format */
23+
JPEG_DECODE_OUT_FORMAT_RGB565 = ESP_COLOR_FOURCC_RGB16, /*!< output RGB565 format */
2424
JPEG_DECODE_OUT_FORMAT_GRAY = ESP_COLOR_FOURCC_GREY, /*!< output the gray picture */
2525
JPEG_DECODE_OUT_FORMAT_YUV444 = ESP_COLOR_FOURCC_YUV, /*!< output yuv444 format */
2626
JPEG_DECODE_OUT_FORMAT_YUV422 = ESP_COLOR_FOURCC_YVYU, /*!< output yuv422 format */
@@ -55,8 +55,8 @@ typedef enum {
5555
* @brief Enumeration for jpeg input format.
5656
*/
5757
typedef enum {
58-
JPEG_ENCODE_IN_FORMAT_RGB888 = ESP_COLOR_FOURCC_RGB24, /*!< input RGB888 format */
59-
JPEG_ENCODE_IN_FORMAT_RGB565 = ESP_COLOR_FOURCC_RGB16_BE, /*!< input RGB565 format */
58+
JPEG_ENCODE_IN_FORMAT_RGB888 = ESP_COLOR_FOURCC_BGR24, /*!< input RGB888 format */
59+
JPEG_ENCODE_IN_FORMAT_RGB565 = ESP_COLOR_FOURCC_RGB16, /*!< input RGB565 format */
6060
JPEG_ENCODE_IN_FORMAT_GRAY = ESP_COLOR_FOURCC_GREY, /*!< input GRAY format */
6161
JPEG_ENCODE_IN_FORMAT_YUV422 = ESP_COLOR_FOURCC_YVYU, /*!< input YUV422 format */
6262
#if !(CONFIG_ESP_REV_MIN_FULL < 300 && SOC_IS(ESP32P4)) // Invisible for unsupported chips

components/esp_driver_jpeg/jpeg_decode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ static esp_err_t jpeg_dec_config_dma_descriptor(jpeg_decoder_handle_t decoder_en
439439
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);
440440

441441
// Configure rx link descriptor
442-
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);
442+
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);
443443

444444
return ESP_OK;
445445
}

components/esp_driver_jpeg/jpeg_encode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ esp_err_t jpeg_encoder_process(jpeg_encoder_handle_t encoder_engine, const jpeg_
245245

246246
// 2D direction
247247
memset(encoder_engine->txlink, 0, sizeof(dma2d_descriptor_t));
248-
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);
248+
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);
249249

250250
ret = esp_cache_msync((void*)raw_buffer, inbuf_size, ESP_CACHE_MSYNC_FLAG_DIR_C2M | ESP_CACHE_MSYNC_FLAG_UNALIGNED);
251251
assert(ret == ESP_OK);

components/esp_driver_ppa/include/driver/ppa.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ typedef struct {
127127
};
128128
ppa_color_range_t yuv_range; /*!< When the color mode is any YUV color space, this field is to describe its color range */
129129
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 */
130-
color_yuv422_pack_order_t yuv422_pack_order; /*!< When the color mode is YUV422, this field is to describe its data pack order */
131130
} ppa_in_pic_blk_config_t;
132131

133132
/**

components/esp_driver_ppa/src/ppa_blend.c

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ bool ppa_blend_transaction_on_picked(uint32_t num_chans, const dma2d_trans_chann
4646
}
4747
assert(dma2d_tx_bg_chan && dma2d_tx_fg_chan && dma2d_rx_chan);
4848

49-
color_space_pixel_format_t in_bg_pixel_format = {
50-
.color_type_id = blend_trans_desc->in_bg.blend_cm,
51-
};
52-
color_space_pixel_format_t in_fg_pixel_format = {
53-
.color_type_id = blend_trans_desc->in_fg.blend_cm,
54-
};
55-
color_space_pixel_format_t out_pixel_format = {
56-
.color_type_id = blend_trans_desc->out.blend_cm,
57-
};
58-
5949
// Fill 2D-DMA descriptors
6050
blend_engine->dma_tx_bg_desc->vb_size = blend_trans_desc->in_bg.block_h;
6151
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
6555
blend_engine->dma_tx_bg_desc->owner = DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA;
6656
blend_engine->dma_tx_bg_desc->va_size = blend_trans_desc->in_bg.pic_h;
6757
blend_engine->dma_tx_bg_desc->ha_length = blend_trans_desc->in_bg.pic_w;
68-
blend_engine->dma_tx_bg_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value(in_bg_pixel_format);
58+
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);
6959
blend_engine->dma_tx_bg_desc->y = blend_trans_desc->in_bg.block_offset_y;
7060
blend_engine->dma_tx_bg_desc->x = blend_trans_desc->in_bg.block_offset_x;
7161
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
8070
blend_engine->dma_tx_fg_desc->owner = DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA;
8171
blend_engine->dma_tx_fg_desc->va_size = blend_trans_desc->in_fg.pic_h;
8272
blend_engine->dma_tx_fg_desc->ha_length = blend_trans_desc->in_fg.pic_w;
83-
blend_engine->dma_tx_fg_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value(in_fg_pixel_format);
73+
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);
8474
blend_engine->dma_tx_fg_desc->y = blend_trans_desc->in_fg.block_offset_y;
8575
blend_engine->dma_tx_fg_desc->x = blend_trans_desc->in_fg.block_offset_x;
8676
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
9585
blend_engine->dma_rx_desc->owner = DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA;
9686
blend_engine->dma_rx_desc->va_size = blend_trans_desc->out.pic_h;
9787
blend_engine->dma_rx_desc->ha_length = blend_trans_desc->out.pic_w;
98-
blend_engine->dma_rx_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value(out_pixel_format);
88+
blend_engine->dma_rx_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value((esp_color_fourcc_t)blend_trans_desc->out.blend_cm);
9989
blend_engine->dma_rx_desc->y = blend_trans_desc->out.block_offset_y;
10090
blend_engine->dma_rx_desc->x = blend_trans_desc->out.block_offset_x;
10191
blend_engine->dma_rx_desc->mode = DMA2D_DESCRIPTOR_BLOCK_RW_MODE_SINGLE;
@@ -140,27 +130,24 @@ bool ppa_blend_transaction_on_picked(uint32_t num_chans, const dma2d_trans_chann
140130

141131
// Configure PPA Blending engine
142132
ppa_ll_blend_set_rx_bg_color_mode(platform->hal.dev, blend_trans_desc->in_bg.blend_cm);
143-
if (COLOR_SPACE_TYPE((uint32_t)blend_trans_desc->in_bg.blend_cm) == COLOR_SPACE_YUV) {
133+
if (PPA_IS_CM_YUV(blend_trans_desc->in_bg.blend_cm)) {
144134
ppa_ll_blend_set_rx_bg_yuv_range(platform->hal.dev, blend_trans_desc->in_bg.yuv_range);
145135
ppa_ll_blend_set_rx_bg_yuv2rgb_std(platform->hal.dev, blend_trans_desc->in_bg.yuv_std);
146136
}
147-
if ((uint32_t)blend_trans_desc->in_bg.blend_cm == PPA_BLEND_COLOR_MODE_YUV422) {
148-
ppa_ll_blend_set_rx_bg_yuv422_pack_order(platform->hal.dev, blend_trans_desc->in_bg.yuv422_pack_order);
149-
}
150137
ppa_ll_blend_enable_rx_bg_byte_swap(platform->hal.dev, blend_trans_desc->bg_byte_swap);
151138
ppa_ll_blend_enable_rx_bg_rgb_swap(platform->hal.dev, blend_trans_desc->bg_rgb_swap);
152139
ppa_ll_blend_configure_rx_bg_alpha(platform->hal.dev, blend_trans_desc->bg_alpha_update_mode, blend_trans_desc->bg_alpha_value);
153140

154141
ppa_ll_blend_set_rx_fg_color_mode(platform->hal.dev, blend_trans_desc->in_fg.blend_cm);
155-
if (COLOR_SPACE_TYPE((uint32_t)blend_trans_desc->in_fg.blend_cm) == COLOR_SPACE_ALPHA) {
142+
if (PPA_IS_CM_ALPHA(blend_trans_desc->in_fg.blend_cm)) {
156143
ppa_ll_blend_set_rx_fg_fix_rgb(platform->hal.dev, &blend_trans_desc->fg_fix_rgb_val);
157144
}
158145
ppa_ll_blend_enable_rx_fg_byte_swap(platform->hal.dev, blend_trans_desc->fg_byte_swap);
159146
ppa_ll_blend_enable_rx_fg_rgb_swap(platform->hal.dev, blend_trans_desc->fg_rgb_swap);
160147
ppa_ll_blend_configure_rx_fg_alpha(platform->hal.dev, blend_trans_desc->fg_alpha_update_mode, blend_trans_desc->fg_alpha_value);
161148

162149
ppa_ll_blend_set_tx_color_mode(platform->hal.dev, blend_trans_desc->out.blend_cm);
163-
if (COLOR_SPACE_TYPE((uint32_t)blend_trans_desc->out.blend_cm) == COLOR_SPACE_YUV) {
150+
if (PPA_IS_CM_YUV(blend_trans_desc->out.blend_cm)) {
164151
ppa_ll_blend_set_tx_yuv_range(platform->hal.dev, blend_trans_desc->out.yuv_range);
165152
ppa_ll_blend_set_tx_rgb2yuv_std(platform->hal.dev, blend_trans_desc->out.yuv_std);
166153
}
@@ -201,7 +188,7 @@ esp_err_t ppa_do_blend(ppa_client_handle_t ppa_client, const ppa_blend_oper_conf
201188
config->in_bg.block_h % 2 == 0 && config->in_bg.block_w % 2 == 0 &&
202189
config->in_bg.block_offset_x % 2 == 0 && config->in_bg.block_offset_y % 2 == 0,
203190
ESP_ERR_INVALID_ARG, TAG, "YUV420 input does not support odd h/w/offset_x/offset_y");
204-
} else if (config->in_bg.blend_cm == PPA_BLEND_COLOR_MODE_YUV422) {
191+
} else if (PPA_IS_CM_YUV422(config->in_bg.blend_cm)) {
205192
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,
206193
ESP_ERR_INVALID_ARG, TAG, "YUV422 input does not support odd w/offset_x");
207194
}
@@ -218,7 +205,7 @@ esp_err_t ppa_do_blend(ppa_client_handle_t ppa_client, const ppa_blend_oper_conf
218205
ESP_RETURN_ON_FALSE(config->out.pic_h % 2 == 0 && config->out.pic_w % 2 == 0 &&
219206
config->out.block_offset_x % 2 == 0 && config->out.block_offset_y % 2 == 0,
220207
ESP_ERR_INVALID_ARG, TAG, "YUV420 output does not support odd h/w/offset_x/offset_y");
221-
} else if (config->out.blend_cm == PPA_BLEND_COLOR_MODE_YUV422) {
208+
} else if (PPA_IS_CM_YUV422(config->out.blend_cm)) {
222209
ESP_RETURN_ON_FALSE(config->out.pic_w % 2 == 0 && config->out.block_offset_x % 2 == 0,
223210
ESP_ERR_INVALID_ARG, TAG, "YUV422 output does not support odd w/offset_x");
224211
}
@@ -228,10 +215,7 @@ esp_err_t ppa_do_blend(ppa_client_handle_t ppa_client, const ppa_blend_oper_conf
228215
ESP_RETURN_ON_FALSE(config->in_fg.block_w <= (config->in_fg.pic_w - config->in_fg.block_offset_x) &&
229216
config->in_fg.block_h <= (config->in_fg.pic_h - config->in_fg.block_offset_y),
230217
ESP_ERR_INVALID_ARG, TAG, "in_fg.block_w/h + in_fg.block_offset_x/y does not fit in the in pic");
231-
color_space_pixel_format_t out_pixel_format = {
232-
.color_type_id = config->out.blend_cm,
233-
};
234-
uint32_t out_pixel_depth = color_hal_pixel_format_get_bit_depth(out_pixel_format); // bits
218+
uint32_t out_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)config->out.blend_cm); // bits
235219
uint32_t out_pic_len = config->out.pic_w * config->out.pic_h * out_pixel_depth / 8;
236220
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");
237221
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,21 +255,15 @@ esp_err_t ppa_do_blend(ppa_client_handle_t ppa_client, const ppa_blend_oper_conf
271255

272256
// Write back and invalidate necessary data (note that the window content is not continuous in the buffer)
273257
// Write back in_bg_buffer, in_fg_buffer extended windows (alignment not necessary on C2M direction)
274-
color_space_pixel_format_t in_bg_pixel_format = {
275-
.color_type_id = config->in_bg.blend_cm,
276-
};
277-
uint32_t in_bg_pixel_depth = color_hal_pixel_format_get_bit_depth(in_bg_pixel_format); // bits
258+
uint32_t in_bg_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)config->in_bg.blend_cm); // bits
278259
// 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
279260
// While M2C direction manual alignment is L2-cacheline-size alignment for mem->L2->L1
280261
// Mismatching writeback and invalidate data size could cause synchronization error if in_bg/fg_buffer and out_buffer are the same one
281262
uint32_t in_bg_ext_window = (uint32_t)config->in_bg.buffer + config->in_bg.block_offset_y * config->in_bg.pic_w * in_bg_pixel_depth / 8;
282263
uint32_t in_bg_ext_window_aligned = PPA_ALIGN_DOWN(in_bg_ext_window, buf_alignment_size);
283264
uint32_t in_bg_ext_window_len = config->in_bg.pic_w * config->in_bg.block_h * in_bg_pixel_depth / 8;
284265
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);
285-
color_space_pixel_format_t in_fg_pixel_format = {
286-
.color_type_id = config->in_fg.blend_cm,
287-
};
288-
uint32_t in_fg_pixel_depth = color_hal_pixel_format_get_bit_depth(in_fg_pixel_format); // bits
266+
uint32_t in_fg_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)config->in_fg.blend_cm); // bits
289267
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;
290268
// Same for fg_buffer msync, do manual alignment
291269
uint32_t in_fg_ext_window_aligned = PPA_ALIGN_DOWN(in_fg_ext_window, buf_alignment_size);

components/esp_driver_ppa/src/ppa_fill.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ bool ppa_fill_transaction_on_picked(uint32_t num_chans, const dma2d_trans_channe
3232
assert(dma2d_chans[0].dir == DMA2D_CHANNEL_DIRECTION_RX);
3333
dma2d_channel_handle_t dma2d_rx_chan = dma2d_chans[0].chan;
3434

35-
color_space_pixel_format_t out_pixel_format = {
36-
.color_type_id = fill_trans_desc->out.fill_cm,
37-
};
38-
3935
// Fill 2D-DMA descriptors
4036
blend_engine->dma_rx_desc->vb_size = fill_trans_desc->fill_block_h;
4137
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
4541
blend_engine->dma_rx_desc->owner = DMA2D_DESCRIPTOR_BUFFER_OWNER_DMA;
4642
blend_engine->dma_rx_desc->va_size = fill_trans_desc->out.pic_h;
4743
blend_engine->dma_rx_desc->ha_length = fill_trans_desc->out.pic_w;
48-
blend_engine->dma_rx_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value(out_pixel_format);
44+
blend_engine->dma_rx_desc->pbyte = dma2d_desc_pixel_format_to_pbyte_value((esp_color_fourcc_t)fill_trans_desc->out.fill_cm);
4945
blend_engine->dma_rx_desc->y = fill_trans_desc->out.block_offset_y;
5046
blend_engine->dma_rx_desc->x = fill_trans_desc->out.block_offset_x;
5147
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
104100
// config->out.block_offset_x % 2 == 0 && config->out.block_offset_y % 2 == 0,
105101
// ESP_ERR_INVALID_ARG, TAG, "YUV420 output does not support odd h/w/offset_x/offset_y");
106102
// } else
107-
if (config->out.fill_cm == PPA_FILL_COLOR_MODE_YUV422) {
103+
if (config->out.fill_cm == PPA_FILL_COLOR_MODE_YUV422_UYVY) {
108104
ESP_RETURN_ON_FALSE(config->out.pic_w % 2 == 0 && config->out.block_offset_x % 2 == 0,
109105
ESP_ERR_INVALID_ARG, TAG, "YUV422 output does not support odd w/offset_x");
110106
}
111-
color_space_pixel_format_t out_pixel_format = {
112-
.color_type_id = config->out.fill_cm,
113-
};
114-
uint32_t out_pixel_depth = color_hal_pixel_format_get_bit_depth(out_pixel_format);
107+
uint32_t out_pixel_depth = color_hal_pixel_format_fourcc_get_bit_depth((esp_color_fourcc_t)config->out.fill_cm);
115108
uint32_t out_pic_len = config->out.pic_w * config->out.pic_h * out_pixel_depth / 8;
116109
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");
117110
ESP_RETURN_ON_FALSE(config->fill_block_w <= (config->out.pic_w - config->out.block_offset_x) &&

components/esp_driver_ppa/src/ppa_priv.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,23 @@ extern "C" {
2828
#define PPA_PM_LOCK_NAME_LEN_MAX 16
2929

3030
#define PPA_CHECK_CM_SUPPORT_BYTE_SWAP(str, color_type_id) \
31-
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), \
31+
ESP_RETURN_ON_FALSE((color_type_id == ESP_COLOR_FOURCC_BGRA32) || (color_type_id == ESP_COLOR_FOURCC_RGB16), \
3232
ESP_ERR_INVALID_ARG, TAG, str "_cm does not support byte_swap");
3333

3434
#define PPA_CHECK_CM_SUPPORT_RGB_SWAP(str, color_type_id) \
35-
ESP_RETURN_ON_FALSE(COLOR_SPACE_TYPE(color_type_id) == COLOR_SPACE_ARGB || COLOR_SPACE_TYPE(color_type_id) == COLOR_SPACE_RGB, \
35+
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), \
3636
ESP_ERR_INVALID_ARG, TAG, str "_cm does not support rgb_swap");
3737

38+
#define PPA_IS_CM_YUV422(color_type_id) \
39+
(color_type_id == ESP_COLOR_FOURCC_UYVY || color_type_id == ESP_COLOR_FOURCC_VYUY || \
40+
color_type_id == ESP_COLOR_FOURCC_YUYV || color_type_id == ESP_COLOR_FOURCC_YVYU)
41+
42+
#define PPA_IS_CM_YUV(color_type_id) \
43+
(color_type_id == ESP_COLOR_FOURCC_OUYY_EVYY || color_type_id == ESP_COLOR_FOURCC_YUV || PPA_IS_CM_YUV422(color_type_id))
44+
45+
#define PPA_IS_CM_ALPHA(color_type_id) \
46+
(color_type_id == ESP_COLOR_FOURCC_ALPHA8 || color_type_id == ESP_COLOR_FOURCC_ALPHA4)
47+
3848
#define PPA_ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
3949
#define PPA_ALIGN_DOWN(num, align) ((num) & ~((align) - 1))
4050

0 commit comments

Comments
 (0)