@@ -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 );
0 commit comments