@@ -532,13 +532,28 @@ void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,
}
auto config = params->block<BlockType::Lsc>();
- config.setEnabled(frameContext.lsc.enabled);
-
- if (!frameContext.lsc.enabled)
- return;
+ /*
+ * ISP lockups were observed when toggling the LSC enable bit
+ * repeatedly. There is no known kernel side fix. Workaround the issue
+ * by leaving lsc enabled all the time and setting the gain values to
+ * 1.0 in case lsc should be disabled.
+ */
+ config.setEnabled(true);
setParameters(*config);
+ if (!frameContext.lsc.enabled) {
+ for (int i = 0; i < RKISP1_CIF_ISP_LSC_SAMPLES_MAX; i++) {
+ for (int j = 0; j < RKISP1_CIF_ISP_LSC_SAMPLES_MAX; j++) {
+ config->r_data_tbl[i][j] = 1024;
+ config->gr_data_tbl[i][j] = 1024;
+ config->gb_data_tbl[i][j] = 1024;
+ config->b_data_tbl[i][j] = 1024;
+ }
+ }
+ return;
+ }
+
const Components &set = sets_.getInterpolated(quantizedCt);
copyTable(*config, set);
ISP stalls were observed by repeatedly toggling the LSC enable bit. The probability of a lockup is quite high and easily reproducible by manually toggling the LensShadingCorrectionEnable control in camshark. As no fix proper kernel side fix could be found, workaround the issue by keeping LSC enabled and writing 1.0 to the gain table. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> --- Hi all, The intention of this patch is merely to document the issue. A proper fix on the kernel side would definitely be preferable. But although I spent some time debugging the kernel interrupt handling I wasn't able to come up with a fix. It looks like enabling the LSC module is somehow racy. One thing I was wondering but didn't spent the time to test: In the driver the order of events is: RKISP1_CIF_ISP_FRAME -> rkisp1_params_isr() -> ... -> rkisp1_ext_params_lsc() -> "write lsc tables" and then shortly after, the next frame starts with RKISP1_CIF_ISP_V_START. I didn't test if writing the lsc tables actually overlapped with the V_START signal. Should we possibly write the LSC tables after the V_START interrupt, as these are ping pong maps anyways? Best regards, Stefan --- src/ipa/rkisp1/algorithms/lsc.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)