<div dir="ltr"><div dir="ltr">Hi David,<div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 14 Apr 2021 at 11:30, David Plowman <<a href="mailto:david.plowman@raspberrypi.com">david.plowman@raspberrypi.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Some sensors may require the V4L2_RED/BLUE_BALANCE to be set. These<br>
will require a ColourGainCode method in the CamHelper, analogous to<br>
the GainCode method, but which converts the red and blue gains to the<br>
codes that the driver will want.<br>
<br>
Most sensors don't require these values so it's helpful to provide a<br>
default method - noting that it should then never be called.<br>
<br>
Signed-off-by: David Plowman <<a href="mailto:david.plowman@raspberrypi.com" target="_blank">david.plowman@raspberrypi.com</a>><br>
Reviewed-by: Kieran Bingham <<a href="mailto:kieran.bingham@ideasonboard.com" target="_blank">kieran.bingham@ideasonboard.com</a>><br></blockquote><div><br></div><div>Reviewed-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com">naush@raspberrypi.com</a>></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
src/ipa/raspberrypi/cam_helper.cpp | 18 ++++++++++++++++++<br>
src/ipa/raspberrypi/cam_helper.hpp | 4 +++-<br>
2 files changed, 21 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp<br>
index 0ae0baa0..ad344d29 100644<br>
--- a/src/ipa/raspberrypi/cam_helper.cpp<br>
+++ b/src/ipa/raspberrypi/cam_helper.cpp<br>
@@ -17,6 +17,11 @@<br>
#include "md_parser.hpp"<br>
<br>
using namespace RPiController;<br>
+using namespace libcamera;<br>
+<br>
+namespace libcamera {<br>
+LOG_DECLARE_CATEGORY(IPARPI)<br>
+}<br>
<br>
static std::map<std::string, CamHelperCreateFunc> cam_helpers;<br>
<br>
@@ -57,6 +62,19 @@ double CamHelper::Exposure(uint32_t exposure_lines) const<br>
return exposure_lines * mode_.line_length / 1000.0;<br>
}<br>
<br>
+uint32_t CamHelper::ColourGainCode([[maybe_unused]] double gain) const<br>
+{<br>
+ /*<br>
+ * This is only used when the sensor has RED/BLUE_BALANCE controls.<br>
+ * Most do not, so supplying a default is helpful - though no one<br>
+ * should be calling it.<br>
+ */<br>
+ LOG(IPARPI, Fatal)<br>
+ << "Sensor is requesting RED/BLUE gains so a proper "<br>
+ << "implementation of ColourGainCode must be provided";<br>
+ return 0;<br>
+}<br>
+<br>
uint32_t CamHelper::GetVBlanking(double &exposure, double minFrameDuration,<br>
double maxFrameDuration) const<br>
{<br>
diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp<br>
index 4053a870..a0b6b987 100644<br>
--- a/src/ipa/raspberrypi/cam_helper.hpp<br>
+++ b/src/ipa/raspberrypi/cam_helper.hpp<br>
@@ -26,7 +26,8 @@ namespace RPiController {<br>
//<br>
// The ability to convert between number of lines of exposure and actual<br>
// exposure time, and to convert between the sensor's gain codes and actual<br>
-// gains.<br>
+// gains. Some sensors like to be told the colour (red and blue) gains, so<br>
+// there's a method for converting these to gain codes too.<br>
//<br>
// A method to return the number of frames of delay between updating exposure,<br>
// analogue gain and vblanking, and for the changes to take effect. For many<br>
@@ -72,6 +73,7 @@ public:<br>
double maxFrameDuration) const;<br>
virtual uint32_t GainCode(double gain) const = 0;<br>
virtual double Gain(uint32_t gain_code) const = 0;<br>
+ virtual uint32_t ColourGainCode(double gain) const;<br>
virtual void GetDelays(int &exposure_delay, int &gain_delay,<br>
int &vblank_delay) const;<br>
virtual bool SensorEmbeddedDataPresent() const;<br>
-- <br>
2.20.1<br>
<br>
_______________________________________________<br>
libcamera-devel mailing list<br>
<a href="mailto:libcamera-devel@lists.libcamera.org" target="_blank">libcamera-devel@lists.libcamera.org</a><br>
<a href="https://lists.libcamera.org/listinfo/libcamera-devel" rel="noreferrer" target="_blank">https://lists.libcamera.org/listinfo/libcamera-devel</a><br>
</blockquote></div></div>