@@ -274,7 +274,9 @@ void app_main(void)
274274 }
275275
276276 ESP_ERROR_CHECK (esp_cam_ctlr_enable (handle ));
277- //---------------ISP Init------------------//
277+ /*---------------------------------------------------------------
278+ ISP Init
279+ ---------------------------------------------------------------*/
278280 isp_proc_handle_t isp_proc = NULL ;
279281 esp_isp_processor_cfg_t isp_config = {
280282 .clk_hz = 80 * 1000 * 1000 ,
@@ -289,6 +291,9 @@ void app_main(void)
289291 ESP_ERROR_CHECK (esp_isp_new_processor (& isp_config , & isp_proc ));
290292 ESP_ERROR_CHECK (esp_isp_enable (isp_proc ));
291293
294+ /*---------------------------------------------------------------
295+ BF
296+ ---------------------------------------------------------------*/
292297 esp_isp_bf_config_t bf_config = {
293298 .denoising_level = 5 ,
294299 .padding_mode = ISP_BF_EDGE_PADDING_MODE_SRND_DATA ,
@@ -303,6 +308,9 @@ void app_main(void)
303308 ESP_ERROR_CHECK (esp_isp_bf_configure (isp_proc , & bf_config ));
304309 ESP_ERROR_CHECK (esp_isp_bf_enable (isp_proc ));
305310
311+ /*---------------------------------------------------------------
312+ BLC
313+ ---------------------------------------------------------------*/
306314#if CONFIG_ESP32P4_REV_MIN_FULL >= 300
307315 /**
308316 * This piece of BLC code is to show how to use the BLC related APIs.
@@ -346,6 +354,9 @@ void app_main(void)
346354 ESP_ERROR_CHECK (esp_isp_blc_set_correction_offset (isp_proc , & blc_offset ));
347355#endif
348356
357+ /*---------------------------------------------------------------
358+ DEMOSAIC
359+ ---------------------------------------------------------------*/
349360 esp_isp_demosaic_config_t demosaic_config = {
350361 .grad_ratio = {
351362 .integer = 2 ,
@@ -355,13 +366,48 @@ void app_main(void)
355366 ESP_ERROR_CHECK (esp_isp_demosaic_configure (isp_proc , & demosaic_config ));
356367 ESP_ERROR_CHECK (esp_isp_demosaic_enable (isp_proc ));
357368
369+ /*---------------------------------------------------------------
370+ CCM
371+ ---------------------------------------------------------------*/
372+ /**
373+ * CCM is used for color correction and white balance adjustment.
374+ * It should be configured after demosaic and before gamma correction.
375+ *
376+ * The matrix format is:
377+ * [R_out] [RR RG RB] [R_in]
378+ * [G_out] = [GR GG GB] [G_in]
379+ * [B_out] [BR BG BB] [B_in]
380+ *
381+ * For ESP32P4 ECO5:
382+ * - Matrix coefficients range: ±15.996 (4-bit integer + 8-bit fraction)
383+ * - For earlier versions: ±3.999 (2-bit integer + 10-bit fraction)
384+ */
385+ esp_isp_ccm_config_t ccm_config = {
386+ .matrix = {
387+ // Default identity matrix (no color correction)
388+ {1.0 , 0.0 , 0.0 }, // R channel: R = 1.0*R + 0.0*G + 0.0*B
389+ {0.0 , 1.0 , 0.0 }, // G channel: G = 0.0*R + 1.0*G + 0.0*B
390+ {0.0 , 0.0 , 1.0 } // B channel: B = 0.0*R + 0.0*G + 1.0*B
391+ },
392+ .saturation = false // Don't use saturation for out-of-range values
393+ };
394+
395+ ESP_ERROR_CHECK (esp_isp_ccm_configure (isp_proc , & ccm_config ));
396+ ESP_ERROR_CHECK (esp_isp_ccm_enable (isp_proc ));
397+
398+ /*---------------------------------------------------------------
399+ GAMMA
400+ ---------------------------------------------------------------*/
358401 isp_gamma_curve_points_t pts = {};
359402 ESP_ERROR_CHECK (esp_isp_gamma_fill_curve_points (s_gamma_correction_curve , & pts ));
360403 ESP_ERROR_CHECK (esp_isp_gamma_configure (isp_proc , COLOR_COMPONENT_R , & pts ));
361404 ESP_ERROR_CHECK (esp_isp_gamma_configure (isp_proc , COLOR_COMPONENT_G , & pts ));
362405 ESP_ERROR_CHECK (esp_isp_gamma_configure (isp_proc , COLOR_COMPONENT_B , & pts ));
363406 ESP_ERROR_CHECK (esp_isp_gamma_enable (isp_proc ));
364407
408+ /*---------------------------------------------------------------
409+ SHARPEN
410+ ---------------------------------------------------------------*/
365411 esp_isp_sharpen_config_t sharpen_config = {
366412 .h_freq_coeff = {
367413 .integer = 2 ,
@@ -385,6 +431,9 @@ void app_main(void)
385431 ESP_ERROR_CHECK (esp_isp_sharpen_configure (isp_proc , & sharpen_config ));
386432 ESP_ERROR_CHECK (esp_isp_sharpen_enable (isp_proc ));
387433
434+ /*---------------------------------------------------------------
435+ COLOR
436+ ---------------------------------------------------------------*/
388437 esp_isp_color_config_t color_config = {
389438 .color_contrast = {
390439 .integer = 1 ,
@@ -401,6 +450,9 @@ void app_main(void)
401450 ESP_ERROR_CHECK (esp_isp_color_enable (isp_proc ));
402451
403452#if CONFIG_ESP32P4_REV_MIN_FULL >= 100
453+ /*---------------------------------------------------------------
454+ LSC
455+ ---------------------------------------------------------------*/
404456 esp_isp_lsc_gain_array_t gain_array = {};
405457 esp_isp_lsc_config_t lsc_config = {
406458 .gain_array = & gain_array ,
0 commit comments