Skip to content

Commit 34587f3

Browse files
committed
Merge branch 'feat/isp_shadow_reg_v6.0' into 'release/v6.0'
isp: added shadow reg settings (v6.0) See merge request espressif/esp-idf!43374
2 parents e6a622a + 35f050a commit 34587f3

File tree

10 files changed

+248
-2
lines changed

10 files changed

+248
-2
lines changed

components/esp_driver_isp/src/isp_bf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ esp_err_t esp_isp_bf_configure(isp_proc_handle_t proc, const esp_isp_bf_config_t
4343
isp_hal_bf_config(&(proc->hal), NULL);
4444
}
4545

46+
bool valid = isp_ll_shadow_update_bf(proc->hal.hw);
47+
ESP_RETURN_ON_FALSE_ISR(valid, ESP_ERR_INVALID_STATE, TAG, "failed to update bf shadow register");
48+
4649
return ESP_OK;
4750
}
4851

components/esp_driver_isp/src/isp_blc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ esp_err_t esp_isp_blc_configure(isp_proc_handle_t isp_proc, const esp_isp_blc_co
5858
// Configure stretch enable for each channel
5959
isp_ll_blc_enable_stretch(isp_proc->hal.hw, config->stretch.top_left_chan_stretch_en, config->stretch.top_right_chan_stretch_en, config->stretch.bottom_left_chan_stretch_en, config->stretch.bottom_right_chan_stretch_en);
6060

61+
bool valid = isp_ll_shadow_update_blc(isp_proc->hal.hw);
62+
ESP_RETURN_ON_FALSE_ISR(valid, ESP_ERR_INVALID_STATE, TAG, "failed to update blc shadow register");
63+
6164
return ESP_OK;
6265
}
6366

components/esp_driver_isp/src/isp_ccm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ esp_err_t esp_isp_ccm_configure(isp_proc_handle_t proc, const esp_isp_ccm_config
3333
}
3434

3535
bool ret = true;
36+
bool valid = false;
3637
portENTER_CRITICAL(&proc->spinlock);
3738
isp_ll_ccm_set_clk_ctrl_mode(proc->hal.hw, ISP_LL_PIPELINE_CLK_CTRL_AUTO);
3839
ret = isp_hal_ccm_set_matrix(&proc->hal, ccm_cfg->saturation, ccm_cfg->matrix);
40+
valid = isp_ll_shadow_update_ccm(proc->hal.hw);
3941
portEXIT_CRITICAL(&proc->spinlock);
4042
ESP_RETURN_ON_FALSE(ret, ESP_ERR_INVALID_ARG, TAG, "invalid argument: ccm matrix contain NaN or out of range");
43+
ESP_RETURN_ON_FALSE(valid, ESP_ERR_INVALID_STATE, TAG, "failed to update ccm shadow register");
4144

4245
return ESP_OK;
4346
}

components/esp_driver_isp/src/isp_color.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ esp_err_t esp_isp_color_configure(isp_proc_handle_t proc, const esp_isp_color_co
4343
isp_hal_color_config(&(proc->hal), NULL);
4444
}
4545

46+
bool valid = isp_ll_shadow_update_color(proc->hal.hw);
47+
ESP_RETURN_ON_FALSE_ISR(valid, ESP_ERR_INVALID_STATE, TAG, "failed to update color shadow register");
48+
4649
return ESP_OK;
4750
}
4851

components/esp_driver_isp/src/isp_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ esp_err_t esp_isp_new_processor(const esp_isp_processor_cfg_t *proc_config, isp_
178178
isp_ll_set_byte_swap(proc->hal.hw, true);
179179
}
180180

181+
isp_ll_shadow_set_mode(proc->hal.hw, ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC);
182+
181183
proc->in_color_format = in_color_format;
182184
proc->out_color_format = out_color_format;
183185
proc->h_res = proc_config->h_res;

components/esp_driver_isp/src/isp_sharpen.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ esp_err_t esp_isp_sharpen_configure(isp_proc_handle_t proc, const esp_isp_sharpe
4545
isp_hal_sharpen_config(&(proc->hal), NULL);
4646
}
4747

48+
bool valid = isp_ll_shadow_update_sharpen(proc->hal.hw);
49+
ESP_RETURN_ON_FALSE_ISR(valid, ESP_ERR_INVALID_STATE, TAG, "failed to update sharp shadow register");
50+
4851
return ESP_OK;
4952
}
5053

components/esp_driver_isp/src/isp_wbg.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ esp_err_t esp_isp_wbg_set_wb_gain(isp_proc_handle_t isp_proc, isp_wbg_gain_t gai
6161
// Set WBG gain
6262
isp_ll_awb_set_wb_gain(isp_proc->hal.hw, gain);
6363

64+
bool valid = isp_ll_shadow_update_wbg(isp_proc->hal.hw);
65+
ESP_RETURN_ON_FALSE_ISR(valid, ESP_ERR_INVALID_STATE, TAG, "failed to update wbg shadow register");
66+
6467
return ESP_OK;
6568
}
6669

components/hal/esp32p4/include/hal/isp_ll.h

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@ typedef enum {
197197
ISP_LL_PIPELINE_CLK_CTRL_ALWAYS_ON, ///< Always on
198198
} isp_ll_pipeline_clk_ctrl_t;
199199

200+
/**
201+
* @brief Shadow mode
202+
*/
203+
typedef enum {
204+
ISP_SHADOW_MODE_DISABLE,
205+
ISP_SHADOW_MODE_UPDATE_EVERY_VSYNC,
206+
ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC,
207+
} isp_ll_shadow_mode_t;
200208

201209
/*---------------------------------------------------------------
202210
Clock
@@ -1852,6 +1860,224 @@ static inline void isp_ll_demosaic_set_padding_line_tail_valid_end_pixel(isp_dev
18521860
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->demosaic_matrix_ctrl, demosaic_tail_pixen_pulse_th, end_pixel);
18531861
}
18541862

1863+
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
1864+
/*---------------------------------------------------------------
1865+
Shadow
1866+
---------------------------------------------------------------*/
1867+
/**
1868+
* @brief Shadow mode
1869+
*
1870+
* @param[in] hw Hardware instance address
1871+
* @param[in] mode 'isp_ll_shadow_mode_t`
1872+
*/
1873+
static inline void isp_ll_shadow_set_mode(isp_dev_t *hw, isp_ll_shadow_mode_t mode)
1874+
{
1875+
hw->shadow_reg_ctrl.shadow_update_sel = mode;
1876+
}
1877+
1878+
/**
1879+
* @brief Update BLC shadow register
1880+
*
1881+
* @param[in] hw Hardware instance address
1882+
* @return
1883+
* - True if update is successful, False otherwise
1884+
*/
1885+
static inline bool isp_ll_shadow_update_blc(isp_dev_t *hw)
1886+
{
1887+
//only valid when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
1888+
HAL_ASSERT(hw->shadow_reg_ctrl.shadow_update_sel == ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC);
1889+
1890+
if (hw->shadow_reg_ctrl.blc_update == 1) {
1891+
return false;
1892+
}
1893+
1894+
//self clear when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
1895+
hw->shadow_reg_ctrl.blc_update = 1;
1896+
1897+
return true;
1898+
}
1899+
1900+
/**
1901+
* @brief Update DPC shadow register
1902+
*
1903+
* @param[in] hw Hardware instance address
1904+
* @return
1905+
* - True if update is successful, False otherwise
1906+
*/
1907+
static inline bool isp_ll_shadow_update_dpc(isp_dev_t *hw)
1908+
{
1909+
//only valid when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
1910+
HAL_ASSERT(hw->shadow_reg_ctrl.shadow_update_sel == ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC);
1911+
1912+
if (hw->shadow_reg_ctrl.dpc_update == 1) {
1913+
return false;
1914+
}
1915+
1916+
//self clear when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
1917+
hw->shadow_reg_ctrl.dpc_update = 1;
1918+
1919+
return true;
1920+
}
1921+
1922+
/**
1923+
* @brief Update BF shadow register
1924+
*
1925+
* @param[in] hw Hardware instance address
1926+
* @return
1927+
* - True if update is successful, False otherwise
1928+
*/
1929+
static inline bool isp_ll_shadow_update_bf(isp_dev_t *hw)
1930+
{
1931+
//only valid when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
1932+
HAL_ASSERT(hw->shadow_reg_ctrl.shadow_update_sel == ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC);
1933+
1934+
if (hw->shadow_reg_ctrl.bf_update == 1) {
1935+
return false;
1936+
}
1937+
1938+
//self clear when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
1939+
hw->shadow_reg_ctrl.bf_update = 1;
1940+
1941+
return true;
1942+
}
1943+
1944+
/**
1945+
* @brief Update WBG shadow register
1946+
*
1947+
* @param[in] hw Hardware instance address
1948+
* @return
1949+
* - True if update is successful, False otherwise
1950+
*/
1951+
static inline bool isp_ll_shadow_update_wbg(isp_dev_t *hw)
1952+
{
1953+
//only valid when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
1954+
HAL_ASSERT(hw->shadow_reg_ctrl.shadow_update_sel == ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC);
1955+
1956+
if (hw->shadow_reg_ctrl.wbg_update == 1) {
1957+
return false;
1958+
}
1959+
1960+
//self clear when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
1961+
hw->shadow_reg_ctrl.wbg_update = 1;
1962+
1963+
return true;
1964+
}
1965+
1966+
/**
1967+
* @brief Update CCM shadow register
1968+
*
1969+
* @param[in] hw Hardware instance address
1970+
* @return
1971+
* - True if update is successful, False otherwise
1972+
*/
1973+
static inline bool isp_ll_shadow_update_ccm(isp_dev_t *hw)
1974+
{
1975+
//only valid when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
1976+
HAL_ASSERT(hw->shadow_reg_ctrl.shadow_update_sel == ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC);
1977+
1978+
if (hw->shadow_reg_ctrl.ccm_update == 1) {
1979+
return false;
1980+
}
1981+
1982+
//self clear when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
1983+
hw->shadow_reg_ctrl.ccm_update = 1;
1984+
1985+
return true;
1986+
}
1987+
1988+
/**
1989+
* @brief Update Sharpen shadow register
1990+
*
1991+
* @param[in] hw Hardware instance address
1992+
* @return
1993+
* - True if update is successful, False otherwise
1994+
*/
1995+
static inline bool isp_ll_shadow_update_sharpen(isp_dev_t *hw)
1996+
{
1997+
//only valid when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
1998+
HAL_ASSERT(hw->shadow_reg_ctrl.shadow_update_sel == ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC);
1999+
2000+
if (hw->shadow_reg_ctrl.sharp_update == 1) {
2001+
return false;
2002+
}
2003+
2004+
//self clear when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
2005+
hw->shadow_reg_ctrl.sharp_update = 1;
2006+
2007+
return true;
2008+
}
2009+
2010+
/**
2011+
* @brief Update Color shadow register
2012+
*
2013+
* @param[in] hw Hardware instance address
2014+
* @return
2015+
* - True if update is successful, False otherwise
2016+
*/
2017+
static inline bool isp_ll_shadow_update_color(isp_dev_t *hw)
2018+
{
2019+
//only valid when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
2020+
HAL_ASSERT(hw->shadow_reg_ctrl.shadow_update_sel == ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC);
2021+
2022+
if (hw->shadow_reg_ctrl.color_update == 1) {
2023+
return false;
2024+
}
2025+
2026+
//self clear when ISP_SHADOW_MODE_UPDATE_ONLY_NEXT_VSYNC
2027+
hw->shadow_reg_ctrl.color_update = 1;
2028+
2029+
return true;
2030+
}
2031+
2032+
#else
2033+
static inline void isp_ll_shadow_set_mode(isp_dev_t *hw, isp_ll_shadow_mode_t mode)
2034+
{
2035+
//for compatibility
2036+
}
2037+
2038+
static inline bool isp_ll_shadow_update_blc(isp_dev_t *hw)
2039+
{
2040+
//for compatibility
2041+
return true;
2042+
}
2043+
2044+
static inline bool isp_ll_shadow_update_dpc(isp_dev_t *hw)
2045+
{
2046+
//for compatibility
2047+
return true;
2048+
}
2049+
2050+
static inline bool isp_ll_shadow_update_bf(isp_dev_t *hw)
2051+
{
2052+
//for compatibility
2053+
return true;
2054+
}
2055+
2056+
static inline bool isp_ll_shadow_update_wbg(isp_dev_t *hw)
2057+
{
2058+
//for compatibility
2059+
return true;
2060+
}
2061+
2062+
static inline bool isp_ll_shadow_update_ccm(isp_dev_t *hw)
2063+
{
2064+
//for compatibility
2065+
return true;
2066+
}
2067+
2068+
static inline bool isp_ll_shadow_update_sharpen(isp_dev_t *hw)
2069+
{
2070+
//for compatibility
2071+
return true;
2072+
}
2073+
2074+
static inline bool isp_ll_shadow_update_color(isp_dev_t *hw)
2075+
{
2076+
//for compatibility
2077+
return true;
2078+
}
2079+
#endif
2080+
18552081
/*---------------------------------------------------------------
18562082
Sharpen
18572083
---------------------------------------------------------------*/

docs/en/api-reference/peripherals/isp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ Calling :cpp:func:`esp_isp_demosaic_configure` to configure Demosaic function, y
723723
...
724724
};
725725
726-
ESP_ERROR_CHECK(esp_isp_demosaic_configure(isp_proc, &sharpen_config));
726+
ESP_ERROR_CHECK(esp_isp_demosaic_configure(isp_proc, &demosaic_config));
727727
ESP_ERROR_CHECK(esp_isp_demosaic_enable(isp_proc));
728728
729729
After calling :cpp:func:`esp_isp_demosaic_configure`, you need to enable the ISP Demosaic controller, by calling :cpp:func:`esp_isp_demosaic_enable`. This function:

docs/zh_CN/api-reference/peripherals/isp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ ISP 去马赛克控制器
724724
...
725725
};
726726
727-
ESP_ERROR_CHECK(esp_isp_demosaic_configure(isp_proc, &sharpen_config));
727+
ESP_ERROR_CHECK(esp_isp_demosaic_configure(isp_proc, &demosaic_config));
728728
ESP_ERROR_CHECK(esp_isp_demosaic_enable(isp_proc));
729729
730730
调用 :cpp:func:`esp_isp_demosaic_configure` 后,需要通过调用 :cpp:func:`esp_isp_demosaic_enable` 来启用 ISP 去马赛克控制器。此函数:

0 commit comments

Comments
 (0)