From d8685a579ccf3246b11eef404786cdd9f19f087e Mon Sep 17 00:00:00 2001 From: Naushir Patuck Date: Mon, 27 Mar 2023 13:20:26 +0100 Subject: ipa: raspberrypi: Generalise the contrast algorithm Generalise the contrast algorithm code by removing any hard-coded assumptions about the target hardware platform. Instead, the algorithm code creates a generic Pwl that gets returned to the IPA, where it gets converted to the bcm2835 hardware specific lookup table. As a drive-by, remove an unused mutex. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Jacopo Mondi Signed-off-by: Kieran Bingham --- src/ipa/raspberrypi/raspberrypi.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/ipa/raspberrypi/raspberrypi.cpp') diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index c74558f1..e2662938 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1593,14 +1593,21 @@ void IPARPi::applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls) void IPARPi::applyGamma(const struct ContrastStatus *contrastStatus, ControlList &ctrls) { + const unsigned int numGammaPoints = controller_.getHardwareConfig().numGammaPoints; struct bcm2835_isp_gamma gamma; - gamma.enabled = 1; - for (unsigned int i = 0; i < ContrastNumPoints; i++) { - gamma.x[i] = contrastStatus->points[i].x; - gamma.y[i] = contrastStatus->points[i].y; + for (unsigned int i = 0; i < numGammaPoints - 1; i++) { + int x = i < 16 ? i * 1024 + : (i < 24 ? (i - 16) * 2048 + 16384 + : (i - 24) * 4096 + 32768); + gamma.x[i] = x; + gamma.y[i] = std::min(65535, contrastStatus->gammaCurve.eval(x)); } + gamma.x[numGammaPoints - 1] = 65535; + gamma.y[numGammaPoints - 1] = 65535; + gamma.enabled = 1; + ControlValue c(Span{ reinterpret_cast(&gamma), sizeof(gamma) }); ctrls.set(V4L2_CID_USER_BCM2835_ISP_GAMMA, c); -- cgit v1.2.1