[{"id":20100,"web_url":"https://patchwork.libcamera.org/comment/20100/","msgid":"<CAEmqJPr_AXB1mLzMDMOZ+b5QTYhYgvT=29SB8W3Lc_ULkKE_hQ@mail.gmail.com>","date":"2021-10-11T07:46:27","subject":"Re: [libcamera-devel] [PATCH] libcamera: ipa: raspberrypi: Add\n\tsupport for imx519 sensor","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi,\n\nThank you for your patch!\n\nOn Mon, 11 Oct 2021 at 05:06, Arducam info <info@arducam.com> wrote:\n\n> The necessary tuning file and CamHelper is added for the imx519 sensor.\n>\n> The imx519 is a 16MP rolling shutter sensor. To enable\n> it, please add\n>\n> dtoverlay=imx519\n>\n> to the /boot/config.txt file and reboot the Pi.\n>\n> Signed-off-by: Lee Jackson <info@arducam.com>\n> ---\n>  src/ipa/raspberrypi/cam_helper_imx519.cpp | 185 +++++++++++++++\n>  src/ipa/raspberrypi/data/imx519.json      | 272 ++++++++++++++++++++++\n>  src/ipa/raspberrypi/data/meson.build      |   1 +\n>  src/ipa/raspberrypi/meson.build           |   1 +\n>  4 files changed, 459 insertions(+)\n>  create mode 100644 src/ipa/raspberrypi/cam_helper_imx519.cpp\n>  create mode 100644 src/ipa/raspberrypi/data/imx519.json\n>\n> diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp\n> b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n> new file mode 100644\n> index 00000000..eaf24982\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n> @@ -0,0 +1,185 @@\n> +/* SPDX-License-Identifier: BSD-2-Clause */\n> +/*\n> + * Based on cam_helper_imx477.cpp\n> + * Copyright (C) 2020, Raspberry Pi (Trading) Limited\n> + *\n> + * cam_helper_imx519.cpp - camera helper for imx519 sensor\n> + * Copyright (C) 2021, Arducam Technology co., Ltd.\n> + */\n> +\n> +#include <assert.h>\n> +#include <cmath>\n> +#include <stddef.h>\n> +#include <stdio.h>\n> +#include <stdlib.h>\n> +\n> +#include <libcamera/base/log.h>\n> +\n> +#include \"cam_helper.hpp\"\n> +#include \"md_parser.hpp\"\n> +\n> +using namespace RPiController;\n> +using namespace libcamera;\n> +using libcamera::utils::Duration;\n> +\n> +namespace libcamera {\n> +LOG_DECLARE_CATEGORY(IPARPI)\n> +}\n> +\n> +/*\n> + * We care about two gain registers and a pair of exposure registers.\n> Their\n> + * I2C addresses from the Sony IMX519 datasheet:\n> + */\n> +constexpr uint32_t expHiReg = 0x0202;\n> +constexpr uint32_t expLoReg = 0x0203;\n> +constexpr uint32_t gainHiReg = 0x0204;\n> +constexpr uint32_t gainLoReg = 0x0205;\n> +constexpr uint32_t frameLengthHiReg = 0x0340;\n> +constexpr uint32_t frameLengthLoReg = 0x0341;\n> +constexpr std::initializer_list<uint32_t> registerList =\n> +       { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg,\n> frameLengthLoReg  };\n> +\n> +class CamHelperImx519 : public CamHelper\n> +{\n> +public:\n> +       CamHelperImx519();\n> +       uint32_t GainCode(double gain) const override;\n> +       double Gain(uint32_t gain_code) const override;\n> +       void Prepare(libcamera::Span<const uint8_t> buffer, Metadata\n> &metadata) override;\n> +       uint32_t GetVBlanking(Duration &exposure, Duration\n> minFrameDuration,\n> +                             Duration maxFrameDuration) const override;\n> +       void GetDelays(int &exposure_delay, int &gain_delay,\n> +                      int &vblank_delay) const override;\n> +       bool SensorEmbeddedDataPresent() const override;\n> +\n> +private:\n> +       /*\n> +        * Smallest difference between the frame length and integration\n> time,\n> +        * in units of lines.\n> +        */\n> +       static constexpr int frameIntegrationDiff = 32;\n> +       /* Maximum frame length allowable for long exposure calculations.\n> */\n> +       static constexpr int frameLengthMax = 0xffdc;\n> +       /* Largest long exposure scale factor given as a left shift on the\n> frame length. */\n> +       static constexpr int longExposureShiftMax = 7;\n> +\n> +       void PopulateMetadata(const MdParser::RegisterMap &registers,\n> +                             Metadata &metadata) const override;\n> +};\n> +\n> +CamHelperImx519::CamHelperImx519()\n> +       : CamHelper(std::make_unique<MdParserSmia>(registerList),\n> frameIntegrationDiff)\n> +{\n> +}\n> +\n> +uint32_t CamHelperImx519::GainCode(double gain) const\n> +{\n> +       return static_cast<uint32_t>(1024 - 1024 / gain);\n> +}\n> +\n> +double CamHelperImx519::Gain(uint32_t gain_code) const\n> +{\n> +       return 1024.0 / (1024 - gain_code);\n> +}\n> +\n> +void CamHelperImx519::Prepare(libcamera::Span<const uint8_t> buffer,\n> Metadata &metadata)\n> +{\n> +       MdParser::RegisterMap registers;\n> +       DeviceStatus deviceStatus;\n> +\n> +       if (metadata.Get(\"device.status\", deviceStatus)) {\n> +               LOG(IPARPI, Error) << \"DeviceStatus not found from\n> DelayedControls\";\n> +               return;\n> +       }\n> +\n> +       parseEmbeddedData(buffer, metadata);\n> +\n> +       /*\n> +        * The DeviceStatus struct is first populated with values obtained\n> from\n> +        * DelayedControls. If this reports frame length is >\n> frameLengthMax,\n> +        * it means we are using a long exposure mode. Since the long\n> exposure\n> +        * scale factor is not returned back through embedded data, we\n> must rely\n> +        * on the existing exposure lines and frame length values returned\n> by\n> +        * DelayedControls.\n> +        *\n> +        * Otherwise, all values are updated with what is reported in the\n> +        * embedded data.\n> +        */\n> +       if (deviceStatus.frame_length > frameLengthMax) {\n> +               DeviceStatus parsedDeviceStatus;\n> +\n> +               metadata.Get(\"device.status\", parsedDeviceStatus);\n> +               parsedDeviceStatus.shutter_speed =\n> deviceStatus.shutter_speed;\n> +               parsedDeviceStatus.frame_length =\n> deviceStatus.frame_length;\n> +               metadata.Set(\"device.status\", parsedDeviceStatus);\n> +\n> +               LOG(IPARPI, Debug) << \"Metadata updated for long exposure:\n> \"\n> +                                  << parsedDeviceStatus;\n> +       }\n> +}\n> +\n> +uint32_t CamHelperImx519::GetVBlanking(Duration &exposure,\n> +                                      Duration minFrameDuration,\n> +                                      Duration maxFrameDuration) const\n> +{\n> +       uint32_t frameLength, exposureLines;\n> +       unsigned int shift = 0;\n> +\n> +       frameLength = mode_.height + CamHelper::GetVBlanking(exposure,\n> minFrameDuration,\n> +\n> maxFrameDuration);\n> +       /*\n> +        * Check if the frame length calculated needs to be setup for long\n> +        * exposure mode. This will require us to use a long exposure scale\n> +        * factor provided by a shift operation in the sensor.\n> +        */\n> +       while (frameLength > frameLengthMax) {\n> +               if (++shift > longExposureShiftMax) {\n> +                       shift = longExposureShiftMax;\n> +                       frameLength = frameLengthMax;\n> +                       break;\n> +               }\n> +               frameLength >>= 1;\n> +       }\n> +\n> +       if (shift) {\n> +               /* Account for any rounding in the scaled frame length\n> value. */\n> +               frameLength <<= shift;\n> +               exposureLines = ExposureLines(exposure);\n> +               exposureLines = std::min(exposureLines, frameLength -\n> frameIntegrationDiff);\n> +               exposure = Exposure(exposureLines);\n> +       }\n> +\n> +       return frameLength - mode_.height;\n> +}\n>\n\nI have not worked with the imx519, so I just wanted to check - does it\nsupport long\nexposures like the imx477?  If not, the above function should be removed\nalong with\nthe other bits of code associated with long exposure modes.\n\nThanks,\nNaush\n\n\n> +\n> +void CamHelperImx519::GetDelays(int &exposure_delay, int &gain_delay,\n> +                               int &vblank_delay) const\n> +{\n> +       exposure_delay = 2;\n> +       gain_delay = 2;\n> +       vblank_delay = 3;\n> +}\n> +\n> +bool CamHelperImx519::SensorEmbeddedDataPresent() const\n> +{\n> +       return true;\n> +}\n> +\n> +void CamHelperImx519::PopulateMetadata(const MdParser::RegisterMap\n> &registers,\n> +                                      Metadata &metadata) const\n> +{\n> +       DeviceStatus deviceStatus;\n> +\n> +       deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) *\n> 256 + registers.at(expLoReg));\n> +       deviceStatus.analogue_gain = Gain(registers.at(gainHiReg) * 256 +\n> registers.at(gainLoReg));\n> +       deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256\n> + registers.at(frameLengthLoReg);\n> +\n> +       metadata.Set(\"device.status\", deviceStatus);\n> +}\n> +\n> +static CamHelper *Create()\n> +{\n> +       return new CamHelperImx519();\n> +}\n> +\n> +static RegisterCamHelper reg(\"imx519\", &Create);\n> diff --git a/src/ipa/raspberrypi/data/imx519.json\n> b/src/ipa/raspberrypi/data/imx519.json\n> new file mode 100644\n> index 00000000..39e788ad\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/data/imx519.json\n> @@ -0,0 +1,272 @@\n> +{\n> +    \"rpi.black_level\":\n> +    {\n> +        \"black_level\": 4096\n> +    },\n> +    \"rpi.dpc\":\n> +    {\n> +    },\n> +    \"rpi.lux\":\n> +    {\n> +        \"reference_shutter_speed\": 10812,\n> +        \"reference_gain\": 2.0,\n> +        \"reference_aperture\": 1.0,\n> +        \"reference_lux\": 1250,\n> +        \"reference_Y\": 12737\n> +    },\n> +    \"rpi.noise\":\n> +    {\n> +        \"reference_constant\": 0,\n> +        \"reference_slope\": 2.91\n> +    },\n> +    \"rpi.geq\":\n> +    {\n> +        \"offset\": 444,\n> +        \"slope\": 0.00731\n> +    },\n> +    \"rpi.sdn\":\n> +    {\n> +        \"deviation\":3.7,\n> +        \"strength\":0.75\n> +    },\n> +    \"rpi.awb\":\n> +    {\n> +        \"priors\":\n> +        [\n> +            {\n> +                \"lux\": 0, \"prior\":\n> +                [\n> +                    2000, 1.0, 3000, 0.0, 13000, 0.0\n> +                ]\n> +            },\n> +            {\n> +                \"lux\": 800, \"prior\":\n> +                [\n> +                    2000, 0.0, 6000, 2.0, 13000, 2.0\n> +                ]\n> +            },\n> +            {\n> +                \"lux\": 1500, \"prior\":\n> +                [\n> +                    2000, 0.0, 4000, 1.0, 6000, 6.0, 6500, 7.0, 7000,\n> 1.0, 13000, 1.0\n> +                ]\n> +            }\n> +        ],\n> +        \"modes\":\n> +        {\n> +            \"auto\":\n> +            {\n> +                \"lo\": 2500,\n> +                \"hi\": 8000\n> +            },\n> +            \"incandescent\":\n> +            {\n> +                \"lo\": 2500,\n> +                \"hi\": 3000\n> +            },\n> +            \"tungsten\":\n> +            {\n> +                \"lo\": 3000,\n> +                \"hi\": 3500\n> +            },\n> +            \"fluorescent\":\n> +            {\n> +                \"lo\": 4000,\n> +                \"hi\": 4700\n> +            },\n> +            \"indoor\":\n> +            {\n> +                \"lo\": 3000,\n> +                \"hi\": 5000\n> +            },\n> +            \"daylight\":\n> +            {\n> +                \"lo\": 5500,\n> +                \"hi\": 6500\n> +            },\n> +            \"cloudy\":\n> +            {\n> +                \"lo\": 7000,\n> +                \"hi\": 8600\n> +            }\n> +        },\n> +        \"bayes\": 0\n> +\n> +    },\n> +    \"rpi.agc\":\n> +    {\n> +        \"metering_modes\":\n> +        {\n> +            \"centre-weighted\":\n> +            {\n> +                \"weights\":\n> +                [\n> +                    3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0\n> +                ]\n> +            },\n> +            \"spot\":\n> +            {\n> +                \"weights\":\n> +                [\n> +                    2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n> +                ]\n> +            },\n> +            \"matrix\":\n> +            {\n> +                \"weights\":\n> +                [\n> +                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\n> +                ]\n> +            }\n> +        },\n> +        \"exposure_modes\":\n> +        {\n> +            \"normal\":\n> +            {\n> +                \"shutter\":\n> +                [\n> +                    100, 10000, 30000, 60000, 120000\n> +                ],\n> +                \"gain\":\n> +                [\n> +                    1.0, 2.0, 4.0, 6.0, 12.0\n> +                ]\n> +            },\n> +            \"short\":\n> +            {\n> +                \"shutter\":\n> +                [\n> +                    100, 5000, 10000, 20000, 120000\n> +                ],\n> +                \"gain\":\n> +                [\n> +                    1.0, 2.0, 4.0, 6.0, 12.0\n> +                ]\n> +            }\n> +        },\n> +        \"constraint_modes\":\n> +        {\n> +            \"normal\":\n> +            [\n> +                {\n> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0,\n> \"y_target\":\n> +                    [\n> +                        0, 0.5, 1000, 0.5\n> +                    ]\n> +                }\n> +            ],\n> +            \"highlight\":\n> +            [\n> +                {\n> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0,\n> \"y_target\":\n> +                    [\n> +                        0, 0.5, 1000, 0.5\n> +                    ]\n> +                },\n> +                {\n> +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0,\n> \"y_target\":\n> +                    [\n> +                        0, 0.8, 1000, 0.8\n> +                    ]\n> +                }\n> +            ]\n> +        },\n> +        \"y_target\":\n> +        [\n> +            0, 0.16, 1000, 0.165, 10000, 0.17\n> +        ]\n> +    },\n> +    \"rpi.alsc\":\n> +    {\n> +        \"omega\": 1.3,\n> +        \"n_iter\": 100,\n> +        \"luminance_strength\": 0.5,\n> +        \"calibrations_Cr\":\n> +        [\n> +            {\n> +                \"ct\": 6500, \"table\":\n> +                [\n> +                    2.544, 2.541, 2.531, 2.518, 2.506, 2.495, 2.489,\n> 2.489, 2.489, 2.491, 2.502, 2.511, 2.524, 2.534, 2.542, 2.547,\n> +                    2.541, 2.532, 2.521, 2.506, 2.493, 2.479, 2.469,\n> 2.462, 2.462, 2.473, 2.488, 2.502, 2.511, 2.527, 2.536, 2.542,\n> +                    2.531, 2.523, 2.506, 2.492, 2.474, 2.458, 2.444,\n> 2.435, 2.435, 2.446, 2.466, 2.481, 2.498, 2.511, 2.526, 2.536,\n> +                    2.523, 2.513, 2.492, 2.474, 2.458, 2.438, 2.418,\n> 2.408, 2.408, 2.421, 2.443, 2.463, 2.481, 2.498, 2.517, 2.526,\n> +                    2.513, 2.502, 2.481, 2.459, 2.438, 2.418, 2.397,\n> 2.379, 2.379, 2.399, 2.421, 2.443, 2.463, 2.486, 2.506, 2.517,\n> +                    2.506, 2.492, 2.469, 2.445, 2.423, 2.397, 2.377,\n> 2.368, 2.369, 2.379, 2.399, 2.427, 2.451, 2.474, 2.495, 2.511,\n> +                    2.506, 2.492, 2.469, 2.445, 2.423, 2.397, 2.372,\n> 2.364, 2.364, 2.374, 2.399, 2.427, 2.449, 2.474, 2.495, 2.511,\n> +                    2.506, 2.493, 2.474, 2.451, 2.426, 2.401, 2.382,\n> 2.368, 2.369, 2.382, 2.405, 2.431, 2.449, 2.476, 2.497, 2.509,\n> +                    2.504, 2.493, 2.475, 2.452, 2.431, 2.412, 2.401,\n> 2.382, 2.382, 2.403, 2.416, 2.438, 2.457, 2.477, 2.497, 2.505,\n> +                    2.499, 2.492, 2.474, 2.457, 2.441, 2.431, 2.412,\n> 2.404, 2.404, 2.416, 2.432, 2.447, 2.459, 2.478, 2.495, 2.501,\n> +                    2.499, 2.488, 2.473, 2.463, 2.453, 2.441, 2.431,\n> 2.425, 2.425, 2.432, 2.445, 2.459, 2.466, 2.478, 2.491, 2.495,\n> +                    2.499, 2.481, 2.472, 2.466, 2.458, 2.449, 2.441,\n> 2.439, 2.439, 2.444, 2.454, 2.464, 2.469, 2.477, 2.484, 2.491\n> +                ]\n> +            }\n> +        ],\n> +        \"calibrations_Cb\":\n> +        [\n> +            {\n> +                \"ct\": 6500, \"table\":\n> +                [\n> +                    1.352, 1.352, 1.349, 1.348, 1.347, 1.346, 1.347,\n> 1.349, 1.351, 1.351, 1.352, 1.353, 1.353, 1.355, 1.358, 1.359,\n> +                    1.359, 1.355, 1.352, 1.349, 1.348, 1.348, 1.348,\n> 1.351, 1.352, 1.352, 1.352, 1.354, 1.356, 1.358, 1.361, 1.366,\n> +                    1.364, 1.359, 1.355, 1.352, 1.349, 1.349, 1.351,\n> 1.353, 1.353, 1.353, 1.355, 1.356, 1.358, 1.362, 1.366, 1.371,\n> +                    1.371, 1.365, 1.359, 1.355, 1.352, 1.352, 1.353,\n> 1.357, 1.357, 1.356, 1.356, 1.359, 1.362, 1.366, 1.371, 1.377,\n> +                    1.375, 1.371, 1.365, 1.362, 1.359, 1.359, 1.359,\n> 1.364, 1.364, 1.364, 1.364, 1.365, 1.367, 1.371, 1.377, 1.382,\n> +                    1.379, 1.375, 1.371, 1.367, 1.367, 1.367, 1.369,\n> 1.373, 1.374, 1.374, 1.373, 1.373, 1.374, 1.377, 1.382, 1.386,\n> +                    1.383, 1.378, 1.374, 1.372, 1.372, 1.372, 1.373,\n> 1.375, 1.378, 1.379, 1.379, 1.379, 1.379, 1.381, 1.386, 1.389,\n> +                    1.384, 1.379, 1.376, 1.374, 1.373, 1.373, 1.374,\n> 1.379, 1.379, 1.379, 1.379, 1.379, 1.381, 1.382, 1.386, 1.394,\n> +                    1.386, 1.379, 1.376, 1.375, 1.374, 1.374, 1.374,\n> 1.378, 1.378, 1.378, 1.378, 1.379, 1.381, 1.383, 1.386, 1.394,\n> +                    1.385, 1.379, 1.376, 1.375, 1.374, 1.374, 1.375,\n> 1.378, 1.378, 1.378, 1.378, 1.379, 1.381, 1.383, 1.387, 1.393,\n> +                    1.379, 1.378, 1.375, 1.374, 1.373, 1.374, 1.375,\n> 1.377, 1.378, 1.378, 1.378, 1.379, 1.381, 1.382, 1.386, 1.388,\n> +                    1.379, 1.376, 1.374, 1.372, 1.372, 1.374, 1.375,\n> 1.377, 1.378, 1.378, 1.377, 1.378, 1.379, 1.382, 1.384, 1.387\n> +                ]\n> +            }\n> +        ],\n> +        \"luminance_lut\":\n> +        [\n> +            3.257, 3.091, 2.639, 2.301, 2.009, 1.795, 1.742, 1.742,\n> 1.742, 1.742, 1.798, 2.011, 2.309, 2.649, 3.109, 3.251,\n> +            3.091, 2.703, 2.311, 2.059, 1.791, 1.631, 1.529, 1.482,\n> 1.482, 1.533, 1.635, 1.791, 2.068, 2.313, 2.719, 3.109,\n> +            2.707, 2.424, 2.059, 1.791, 1.626, 1.429, 1.329, 1.282,\n> 1.282, 1.333, 1.433, 1.629, 1.791, 2.068, 2.438, 2.719,\n> +            2.555, 2.233, 1.889, 1.626, 1.429, 1.321, 1.176, 1.126,\n> 1.126, 1.181, 1.327, 1.433, 1.629, 1.894, 2.241, 2.538,\n> +            2.482, 2.108, 1.775, 1.518, 1.321, 1.176, 1.112, 1.011,\n> 1.012, 1.122, 1.181, 1.327, 1.523, 1.779, 2.113, 2.462,\n> +            2.478, 2.048, 1.719, 1.465, 1.266, 1.112, 1.009, 1.001,\n> 1.007, 1.012, 1.122, 1.274, 1.469, 1.722, 2.051, 2.454,\n> +            2.478, 2.048, 1.719, 1.465, 1.266, 1.112, 1.004, 1.001,\n> 1.001, 1.011, 1.122, 1.274, 1.469, 1.722, 2.051, 2.454,\n> +            2.478, 2.099, 1.768, 1.511, 1.312, 1.163, 1.108, 1.004,\n> 1.008, 1.112, 1.171, 1.321, 1.515, 1.767, 2.097, 2.454,\n> +            2.541, 2.217, 1.877, 1.614, 1.417, 1.312, 1.163, 1.112,\n> 1.112, 1.171, 1.317, 1.421, 1.616, 1.874, 2.214, 2.516,\n> +            2.686, 2.404, 2.046, 1.779, 1.614, 1.417, 1.317, 1.267,\n> 1.267, 1.319, 1.421, 1.614, 1.773, 2.039, 2.399, 2.669,\n> +            3.063, 2.678, 2.292, 2.046, 1.779, 1.622, 1.521, 1.469,\n> 1.469, 1.519, 1.622, 1.773, 2.038, 2.277, 2.669, 3.049,\n> +            3.224, 3.063, 2.616, 2.285, 1.995, 1.781, 1.725, 1.723,\n> 1.723, 1.723, 1.777, 1.984, 2.271, 2.598, 3.049, 3.187\n> +        ],\n> +        \"sigma\": 0.005,\n> +        \"sigma_Cb\": 0.005\n> +    },\n> +    \"rpi.contrast\":\n> +    {\n> +        \"ce_enable\": 1,\n> +        \"gamma_curve\":\n> +        [\n> +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120,\n> 18051, 6144, 20790, 7168, 23193,\n> +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288,\n> 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n> +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753,\n> 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n> +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954,\n> 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n> +            65535, 65535\n> +        ]\n> +    },\n> +    \"rpi.ccm\":\n> +    {\n> +        \"ccms\":\n> +        [\n> +            {\n> +                \"ct\": 5500, \"ccm\":\n> +                [\n> +                    1.40348, -0.45861, 0.05512, -0.24419, 1.25488,\n> -0.01068, -0.08564, -0.31571, 1.40135\n> +                ]\n> +            }\n> +        ]\n> +    },\n> +    \"rpi.sharpen\":\n> +    {\n> +               \"threshold\":1.5,\n> +               \"strength\":0.5,\n> +               \"limit\":0.2\n> +    }\n> +}\n> diff --git a/src/ipa/raspberrypi/data/meson.build\n> b/src/ipa/raspberrypi/data/meson.build\n> index 2def75cb..e84cd099 100644\n> --- a/src/ipa/raspberrypi/data/meson.build\n> +++ b/src/ipa/raspberrypi/data/meson.build\n> @@ -7,6 +7,7 @@ conf_files = files([\n>      'imx378.json',\n>      'imx477.json',\n>      'imx477_noir.json',\n> +    'imx519.json',\n>      'ov5647.json',\n>      'ov5647_noir.json',\n>      'ov9281.json',\n> diff --git a/src/ipa/raspberrypi/meson.build\n> b/src/ipa/raspberrypi/meson.build\n> index 1af31e4a..176055f4 100644\n> --- a/src/ipa/raspberrypi/meson.build\n> +++ b/src/ipa/raspberrypi/meson.build\n> @@ -22,6 +22,7 @@ rpi_ipa_sources = files([\n>      'cam_helper_imx219.cpp',\n>      'cam_helper_imx290.cpp',\n>      'cam_helper_imx477.cpp',\n> +    'cam_helper_imx519.cpp',\n>      'cam_helper_ov9281.cpp',\n>      'controller/controller.cpp',\n>      'controller/histogram.cpp',\n> --\n> 2.17.1\n>\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A96D5BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 11 Oct 2021 07:46:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F3F2A68F4F;\n\tMon, 11 Oct 2021 09:46:47 +0200 (CEST)","from mail-lf1-x136.google.com (mail-lf1-x136.google.com\n\t[IPv6:2a00:1450:4864:20::136])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 95FBD60502\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Oct 2021 09:46:45 +0200 (CEST)","by mail-lf1-x136.google.com with SMTP id r19so67914033lfe.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Oct 2021 00:46:45 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"Smy6KFGR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=/AmVsGCttQAdaZs+I806dBP3Sb68kbwzbKHE+LsTVHE=;\n\tb=Smy6KFGRGfD2RF1xH0WUbBG0b9xD169PeR5Pv/y+VaGh8lm1GPiCPAROrVSWLD0Ivf\n\t8JdXEyESqj8Pvnx7jvmKxPx0cwZ0xLMmYdc4GF9VEKjJdG0t5HZIpZ9QUVF6a20bM/ws\n\tNKSoMrN4TGrR+m++P/W62SrDaDaQ9eANoTyVs1WlGGeqQr8JwuJf+RnwQHo86CMdEJwm\n\tJvoIjTbKdgVtPNYm95vsYQPesNOcj9knGXoBvyB8ZjPDdpf3XV2QH1h3WqsnqZdw0hoV\n\tLJoeojz9i4bJc497VFilMdSTExl9qr3CPj+Nc8ByybuLMv7e/3CL3ArPV+1wHCvhUv+q\n\tMyEg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=/AmVsGCttQAdaZs+I806dBP3Sb68kbwzbKHE+LsTVHE=;\n\tb=cQY4CrhQrXIc8fasUBWFBOxjqwMDR32qnQi/9GDNH8WXJQr0UMLBSefQ1/FXLc1iYG\n\tKJAMFvz8PfW7PAo1cZEPO/FQmm+NBaG/FTD4KmYs0t4q5tOYvvO3gMxc0G9lyhTpZZgC\n\twLzFEGNuaqGtB+iQACQeCl8PCgv5/ck7BzEUnWGHUCPbFs57A27abLZ2UEfOBzYj1OPv\n\tKp42FXGwPJRGWmxEMVFCoRNsDmt31Sz8WWNH/gdMZxEfQ0LZgAA/v/05IZ8AiiceXAsM\n\tKA1YYwebZonCGmGvbfc6/qDeLTVm/UUjshLRgvH14bEtLVukb267KK/yQcSBgcw2ZknX\n\tAL5Q==","X-Gm-Message-State":"AOAM533vPDCIA/PrfLoajx6zT3LfAf9acuuJvcO2bzKnoPMcZddCoAl7\n\tZzGP15foZ7qaKb04xgw2vTfOuhbIz4bUWuq5umDv7lW+kTs=","X-Google-Smtp-Source":"ABdhPJzaxmPd4euzdx/0LC/y4Bz3PgyLrMJ6+1W5UbOqknPiaWZM9DUEC0HB3Msk26lpAKk2OLAHgJjzJh3884zKtWw=","X-Received":"by 2002:a05:6512:2241:: with SMTP id\n\ti1mr24906674lfu.611.1633938403624; \n\tMon, 11 Oct 2021 00:46:43 -0700 (PDT)","MIME-Version":"1.0","References":"<638360E6-389E-4699-A524-584E7A555C61@arducam.com>","In-Reply-To":"<638360E6-389E-4699-A524-584E7A555C61@arducam.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Mon, 11 Oct 2021 08:46:27 +0100","Message-ID":"<CAEmqJPr_AXB1mLzMDMOZ+b5QTYhYgvT=29SB8W3Lc_ULkKE_hQ@mail.gmail.com>","To":"Arducam info <info@arducam.com>","Content-Type":"multipart/alternative; boundary=\"000000000000221c3405ce0eeed3\"","Subject":"Re: [libcamera-devel] [PATCH] libcamera: ipa: raspberrypi: Add\n\tsupport for imx519 sensor","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":20101,"web_url":"https://patchwork.libcamera.org/comment/20101/","msgid":"<CAHW6GYLsy2_su9t=Fqh=KAJ=dW3YKp6AuqS_AOJtTp6jZDib-w@mail.gmail.com>","date":"2021-10-11T08:16:30","subject":"Re: [libcamera-devel] [PATCH] libcamera: ipa: raspberrypi: Add\n\tsupport for imx519 sensor","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Lee\n\nThank you very much for your contribution, we're very pleased to see\nothers making use of the Pi's camera system in this way!\n\nOn Mon, 11 Oct 2021 at 05:06, Arducam info <info@arducam.com> wrote:\n>\n> The necessary tuning file and CamHelper is added for the imx519 sensor.\n>\n> The imx519 is a 16MP rolling shutter sensor. To enable\n> it, please add\n>\n> dtoverlay=imx519\n>\n> to the /boot/config.txt file and reboot the Pi.\n>\n> Signed-off-by: Lee Jackson <info@arducam.com>\n> ---\n>  src/ipa/raspberrypi/cam_helper_imx519.cpp | 185 +++++++++++++++\n>  src/ipa/raspberrypi/data/imx519.json      | 272 ++++++++++++++++++++++\n>  src/ipa/raspberrypi/data/meson.build      |   1 +\n>  src/ipa/raspberrypi/meson.build           |   1 +\n>  4 files changed, 459 insertions(+)\n>  create mode 100644 src/ipa/raspberrypi/cam_helper_imx519.cpp\n>  create mode 100644 src/ipa/raspberrypi/data/imx519.json\n>\n> diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n> new file mode 100644\n> index 00000000..eaf24982\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n> @@ -0,0 +1,185 @@\n> +/* SPDX-License-Identifier: BSD-2-Clause */\n> +/*\n> + * Based on cam_helper_imx477.cpp\n> + * Copyright (C) 2020, Raspberry Pi (Trading) Limited\n> + *\n> + * cam_helper_imx519.cpp - camera helper for imx519 sensor\n> + * Copyright (C) 2021, Arducam Technology co., Ltd.\n> + */\n> +\n> +#include <assert.h>\n> +#include <cmath>\n> +#include <stddef.h>\n> +#include <stdio.h>\n> +#include <stdlib.h>\n> +\n> +#include <libcamera/base/log.h>\n> +\n> +#include \"cam_helper.hpp\"\n> +#include \"md_parser.hpp\"\n> +\n> +using namespace RPiController;\n> +using namespace libcamera;\n> +using libcamera::utils::Duration;\n> +\n> +namespace libcamera {\n> +LOG_DECLARE_CATEGORY(IPARPI)\n> +}\n> +\n> +/*\n> + * We care about two gain registers and a pair of exposure registers. Their\n> + * I2C addresses from the Sony IMX519 datasheet:\n> + */\n> +constexpr uint32_t expHiReg = 0x0202;\n> +constexpr uint32_t expLoReg = 0x0203;\n> +constexpr uint32_t gainHiReg = 0x0204;\n> +constexpr uint32_t gainLoReg = 0x0205;\n> +constexpr uint32_t frameLengthHiReg = 0x0340;\n> +constexpr uint32_t frameLengthLoReg = 0x0341;\n> +constexpr std::initializer_list<uint32_t> registerList =\n> +       { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg  };\n> +\n> +class CamHelperImx519 : public CamHelper\n> +{\n> +public:\n> +       CamHelperImx519();\n> +       uint32_t GainCode(double gain) const override;\n> +       double Gain(uint32_t gain_code) const override;\n> +       void Prepare(libcamera::Span<const uint8_t> buffer, Metadata &metadata) override;\n> +       uint32_t GetVBlanking(Duration &exposure, Duration minFrameDuration,\n> +                             Duration maxFrameDuration) const override;\n> +       void GetDelays(int &exposure_delay, int &gain_delay,\n> +                      int &vblank_delay) const override;\n> +       bool SensorEmbeddedDataPresent() const override;\n> +\n> +private:\n> +       /*\n> +        * Smallest difference between the frame length and integration time,\n> +        * in units of lines.\n> +        */\n> +       static constexpr int frameIntegrationDiff = 32;\n> +       /* Maximum frame length allowable for long exposure calculations. */\n> +       static constexpr int frameLengthMax = 0xffdc;\n> +       /* Largest long exposure scale factor given as a left shift on the frame length. */\n> +       static constexpr int longExposureShiftMax = 7;\n> +\n> +       void PopulateMetadata(const MdParser::RegisterMap &registers,\n> +                             Metadata &metadata) const override;\n> +};\n> +\n> +CamHelperImx519::CamHelperImx519()\n> +       : CamHelper(std::make_unique<MdParserSmia>(registerList), frameIntegrationDiff)\n> +{\n> +}\n> +\n> +uint32_t CamHelperImx519::GainCode(double gain) const\n> +{\n> +       return static_cast<uint32_t>(1024 - 1024 / gain);\n> +}\n> +\n> +double CamHelperImx519::Gain(uint32_t gain_code) const\n> +{\n> +       return 1024.0 / (1024 - gain_code);\n> +}\n> +\n> +void CamHelperImx519::Prepare(libcamera::Span<const uint8_t> buffer, Metadata &metadata)\n> +{\n> +       MdParser::RegisterMap registers;\n> +       DeviceStatus deviceStatus;\n> +\n> +       if (metadata.Get(\"device.status\", deviceStatus)) {\n> +               LOG(IPARPI, Error) << \"DeviceStatus not found from DelayedControls\";\n> +               return;\n> +       }\n> +\n> +       parseEmbeddedData(buffer, metadata);\n> +\n> +       /*\n> +        * The DeviceStatus struct is first populated with values obtained from\n> +        * DelayedControls. If this reports frame length is > frameLengthMax,\n> +        * it means we are using a long exposure mode. Since the long exposure\n> +        * scale factor is not returned back through embedded data, we must rely\n> +        * on the existing exposure lines and frame length values returned by\n> +        * DelayedControls.\n> +        *\n> +        * Otherwise, all values are updated with what is reported in the\n> +        * embedded data.\n> +        */\n> +       if (deviceStatus.frame_length > frameLengthMax) {\n> +               DeviceStatus parsedDeviceStatus;\n> +\n> +               metadata.Get(\"device.status\", parsedDeviceStatus);\n> +               parsedDeviceStatus.shutter_speed = deviceStatus.shutter_speed;\n> +               parsedDeviceStatus.frame_length = deviceStatus.frame_length;\n> +               metadata.Set(\"device.status\", parsedDeviceStatus);\n> +\n> +               LOG(IPARPI, Debug) << \"Metadata updated for long exposure: \"\n> +                                  << parsedDeviceStatus;\n> +       }\n> +}\n> +\n> +uint32_t CamHelperImx519::GetVBlanking(Duration &exposure,\n> +                                      Duration minFrameDuration,\n> +                                      Duration maxFrameDuration) const\n> +{\n> +       uint32_t frameLength, exposureLines;\n> +       unsigned int shift = 0;\n> +\n> +       frameLength = mode_.height + CamHelper::GetVBlanking(exposure, minFrameDuration,\n> +                                                            maxFrameDuration);\n> +       /*\n> +        * Check if the frame length calculated needs to be setup for long\n> +        * exposure mode. This will require us to use a long exposure scale\n> +        * factor provided by a shift operation in the sensor.\n> +        */\n> +       while (frameLength > frameLengthMax) {\n> +               if (++shift > longExposureShiftMax) {\n> +                       shift = longExposureShiftMax;\n> +                       frameLength = frameLengthMax;\n> +                       break;\n> +               }\n> +               frameLength >>= 1;\n> +       }\n> +\n> +       if (shift) {\n> +               /* Account for any rounding in the scaled frame length value. */\n> +               frameLength <<= shift;\n> +               exposureLines = ExposureLines(exposure);\n> +               exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff);\n> +               exposure = Exposure(exposureLines);\n> +       }\n> +\n> +       return frameLength - mode_.height;\n> +}\n> +\n> +void CamHelperImx519::GetDelays(int &exposure_delay, int &gain_delay,\n> +                               int &vblank_delay) const\n> +{\n> +       exposure_delay = 2;\n> +       gain_delay = 2;\n> +       vblank_delay = 3;\n> +}\n> +\n> +bool CamHelperImx519::SensorEmbeddedDataPresent() const\n> +{\n> +       return true;\n> +}\n> +\n> +void CamHelperImx519::PopulateMetadata(const MdParser::RegisterMap &registers,\n> +                                      Metadata &metadata) const\n> +{\n> +       DeviceStatus deviceStatus;\n> +\n> +       deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg));\n> +       deviceStatus.analogue_gain = Gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg));\n> +       deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg);\n> +\n> +       metadata.Set(\"device.status\", deviceStatus);\n> +}\n> +\n> +static CamHelper *Create()\n> +{\n> +       return new CamHelperImx519();\n> +}\n> +\n> +static RegisterCamHelper reg(\"imx519\", &Create);\n> diff --git a/src/ipa/raspberrypi/data/imx519.json b/src/ipa/raspberrypi/data/imx519.json\n> new file mode 100644\n> index 00000000..39e788ad\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/data/imx519.json\n> @@ -0,0 +1,272 @@\n> +{\n> +    \"rpi.black_level\":\n> +    {\n> +        \"black_level\": 4096\n> +    },\n> +    \"rpi.dpc\":\n> +    {\n> +    },\n> +    \"rpi.lux\":\n> +    {\n> +        \"reference_shutter_speed\": 10812,\n> +        \"reference_gain\": 2.0,\n> +        \"reference_aperture\": 1.0,\n> +        \"reference_lux\": 1250,\n> +        \"reference_Y\": 12737\n> +    },\n> +    \"rpi.noise\":\n> +    {\n> +        \"reference_constant\": 0,\n> +        \"reference_slope\": 2.91\n> +    },\n> +    \"rpi.geq\":\n> +    {\n> +        \"offset\": 444,\n> +        \"slope\": 0.00731\n> +    },\n> +    \"rpi.sdn\":\n> +    {\n> +        \"deviation\":3.7,\n> +        \"strength\":0.75\n> +    },\n> +    \"rpi.awb\":\n> +    {\n> +        \"priors\":\n> +        [\n> +            {\n> +                \"lux\": 0, \"prior\":\n> +                [\n> +                    2000, 1.0, 3000, 0.0, 13000, 0.0\n> +                ]\n> +            },\n> +            {\n> +                \"lux\": 800, \"prior\":\n> +                [\n> +                    2000, 0.0, 6000, 2.0, 13000, 2.0\n> +                ]\n> +            },\n> +            {\n> +                \"lux\": 1500, \"prior\":\n> +                [\n> +                    2000, 0.0, 4000, 1.0, 6000, 6.0, 6500, 7.0, 7000, 1.0, 13000, 1.0\n> +                ]\n> +            }\n> +        ],\n> +        \"modes\":\n> +        {\n> +            \"auto\":\n> +            {\n> +                \"lo\": 2500,\n> +                \"hi\": 8000\n> +            },\n> +            \"incandescent\":\n> +            {\n> +                \"lo\": 2500,\n> +                \"hi\": 3000\n> +            },\n> +            \"tungsten\":\n> +            {\n> +                \"lo\": 3000,\n> +                \"hi\": 3500\n> +            },\n> +            \"fluorescent\":\n> +            {\n> +                \"lo\": 4000,\n> +                \"hi\": 4700\n> +            },\n> +            \"indoor\":\n> +            {\n> +                \"lo\": 3000,\n> +                \"hi\": 5000\n> +            },\n> +            \"daylight\":\n> +            {\n> +                \"lo\": 5500,\n> +                \"hi\": 6500\n> +            },\n> +            \"cloudy\":\n> +            {\n> +                \"lo\": 7000,\n> +                \"hi\": 8600\n> +            }\n> +        },\n> +        \"bayes\": 0\n\nJust a small thing, but if we're going with the simple grey world\nalgorithm it might be worth deleting the other AWB parameters as they\ndon't do anything.\n\nAnd a few final questions:\n\n* Are you planning to upstream an open source driver for the imx519?\nThe preference within libcamera (someone will correct me if I'm\nwrong!) is to support sensors where code and drivers are open.\n\n* If you're planning to open-source the driver we'd be pleased to\nreceive pull requests into our own Raspberry Pi kernel distribution.\n\n* I assume this is a fairly standard Bayer sensor? If you have a\nworking open source driver and can send me a module then I'd be very\nhappy to help you further with the json tuning file.\n\nThanks and best regards\nDavid\n\n> +\n> +    },\n> +    \"rpi.agc\":\n> +    {\n> +        \"metering_modes\":\n> +        {\n> +            \"centre-weighted\":\n> +            {\n> +                \"weights\":\n> +                [\n> +                    3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0\n> +                ]\n> +            },\n> +            \"spot\":\n> +            {\n> +                \"weights\":\n> +                [\n> +                    2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n> +                ]\n> +            },\n> +            \"matrix\":\n> +            {\n> +                \"weights\":\n> +                [\n> +                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\n> +                ]\n> +            }\n> +        },\n> +        \"exposure_modes\":\n> +        {\n> +            \"normal\":\n> +            {\n> +                \"shutter\":\n> +                [\n> +                    100, 10000, 30000, 60000, 120000\n> +                ],\n> +                \"gain\":\n> +                [\n> +                    1.0, 2.0, 4.0, 6.0, 12.0\n> +                ]\n> +            },\n> +            \"short\":\n> +            {\n> +                \"shutter\":\n> +                [\n> +                    100, 5000, 10000, 20000, 120000\n> +                ],\n> +                \"gain\":\n> +                [\n> +                    1.0, 2.0, 4.0, 6.0, 12.0\n> +                ]\n> +            }\n> +        },\n> +        \"constraint_modes\":\n> +        {\n> +            \"normal\":\n> +            [\n> +                {\n> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> +                    [\n> +                        0, 0.5, 1000, 0.5\n> +                    ]\n> +                }\n> +            ],\n> +            \"highlight\":\n> +            [\n> +                {\n> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> +                    [\n> +                        0, 0.5, 1000, 0.5\n> +                    ]\n> +                },\n> +                {\n> +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> +                    [\n> +                        0, 0.8, 1000, 0.8\n> +                    ]\n> +                }\n> +            ]\n> +        },\n> +        \"y_target\":\n> +        [\n> +            0, 0.16, 1000, 0.165, 10000, 0.17\n> +        ]\n> +    },\n> +    \"rpi.alsc\":\n> +    {\n> +        \"omega\": 1.3,\n> +        \"n_iter\": 100,\n> +        \"luminance_strength\": 0.5,\n> +        \"calibrations_Cr\":\n> +        [\n> +            {\n> +                \"ct\": 6500, \"table\":\n> +                [\n> +                    2.544, 2.541, 2.531, 2.518, 2.506, 2.495, 2.489, 2.489, 2.489, 2.491, 2.502, 2.511, 2.524, 2.534, 2.542, 2.547,\n> +                    2.541, 2.532, 2.521, 2.506, 2.493, 2.479, 2.469, 2.462, 2.462, 2.473, 2.488, 2.502, 2.511, 2.527, 2.536, 2.542,\n> +                    2.531, 2.523, 2.506, 2.492, 2.474, 2.458, 2.444, 2.435, 2.435, 2.446, 2.466, 2.481, 2.498, 2.511, 2.526, 2.536,\n> +                    2.523, 2.513, 2.492, 2.474, 2.458, 2.438, 2.418, 2.408, 2.408, 2.421, 2.443, 2.463, 2.481, 2.498, 2.517, 2.526,\n> +                    2.513, 2.502, 2.481, 2.459, 2.438, 2.418, 2.397, 2.379, 2.379, 2.399, 2.421, 2.443, 2.463, 2.486, 2.506, 2.517,\n> +                    2.506, 2.492, 2.469, 2.445, 2.423, 2.397, 2.377, 2.368, 2.369, 2.379, 2.399, 2.427, 2.451, 2.474, 2.495, 2.511,\n> +                    2.506, 2.492, 2.469, 2.445, 2.423, 2.397, 2.372, 2.364, 2.364, 2.374, 2.399, 2.427, 2.449, 2.474, 2.495, 2.511,\n> +                    2.506, 2.493, 2.474, 2.451, 2.426, 2.401, 2.382, 2.368, 2.369, 2.382, 2.405, 2.431, 2.449, 2.476, 2.497, 2.509,\n> +                    2.504, 2.493, 2.475, 2.452, 2.431, 2.412, 2.401, 2.382, 2.382, 2.403, 2.416, 2.438, 2.457, 2.477, 2.497, 2.505,\n> +                    2.499, 2.492, 2.474, 2.457, 2.441, 2.431, 2.412, 2.404, 2.404, 2.416, 2.432, 2.447, 2.459, 2.478, 2.495, 2.501,\n> +                    2.499, 2.488, 2.473, 2.463, 2.453, 2.441, 2.431, 2.425, 2.425, 2.432, 2.445, 2.459, 2.466, 2.478, 2.491, 2.495,\n> +                    2.499, 2.481, 2.472, 2.466, 2.458, 2.449, 2.441, 2.439, 2.439, 2.444, 2.454, 2.464, 2.469, 2.477, 2.484, 2.491\n> +                ]\n> +            }\n> +        ],\n> +        \"calibrations_Cb\":\n> +        [\n> +            {\n> +                \"ct\": 6500, \"table\":\n> +                [\n> +                    1.352, 1.352, 1.349, 1.348, 1.347, 1.346, 1.347, 1.349, 1.351, 1.351, 1.352, 1.353, 1.353, 1.355, 1.358, 1.359,\n> +                    1.359, 1.355, 1.352, 1.349, 1.348, 1.348, 1.348, 1.351, 1.352, 1.352, 1.352, 1.354, 1.356, 1.358, 1.361, 1.366,\n> +                    1.364, 1.359, 1.355, 1.352, 1.349, 1.349, 1.351, 1.353, 1.353, 1.353, 1.355, 1.356, 1.358, 1.362, 1.366, 1.371,\n> +                    1.371, 1.365, 1.359, 1.355, 1.352, 1.352, 1.353, 1.357, 1.357, 1.356, 1.356, 1.359, 1.362, 1.366, 1.371, 1.377,\n> +                    1.375, 1.371, 1.365, 1.362, 1.359, 1.359, 1.359, 1.364, 1.364, 1.364, 1.364, 1.365, 1.367, 1.371, 1.377, 1.382,\n> +                    1.379, 1.375, 1.371, 1.367, 1.367, 1.367, 1.369, 1.373, 1.374, 1.374, 1.373, 1.373, 1.374, 1.377, 1.382, 1.386,\n> +                    1.383, 1.378, 1.374, 1.372, 1.372, 1.372, 1.373, 1.375, 1.378, 1.379, 1.379, 1.379, 1.379, 1.381, 1.386, 1.389,\n> +                    1.384, 1.379, 1.376, 1.374, 1.373, 1.373, 1.374, 1.379, 1.379, 1.379, 1.379, 1.379, 1.381, 1.382, 1.386, 1.394,\n> +                    1.386, 1.379, 1.376, 1.375, 1.374, 1.374, 1.374, 1.378, 1.378, 1.378, 1.378, 1.379, 1.381, 1.383, 1.386, 1.394,\n> +                    1.385, 1.379, 1.376, 1.375, 1.374, 1.374, 1.375, 1.378, 1.378, 1.378, 1.378, 1.379, 1.381, 1.383, 1.387, 1.393,\n> +                    1.379, 1.378, 1.375, 1.374, 1.373, 1.374, 1.375, 1.377, 1.378, 1.378, 1.378, 1.379, 1.381, 1.382, 1.386, 1.388,\n> +                    1.379, 1.376, 1.374, 1.372, 1.372, 1.374, 1.375, 1.377, 1.378, 1.378, 1.377, 1.378, 1.379, 1.382, 1.384, 1.387\n> +                ]\n> +            }\n> +        ],\n> +        \"luminance_lut\":\n> +        [\n> +            3.257, 3.091, 2.639, 2.301, 2.009, 1.795, 1.742, 1.742, 1.742, 1.742, 1.798, 2.011, 2.309, 2.649, 3.109, 3.251,\n> +            3.091, 2.703, 2.311, 2.059, 1.791, 1.631, 1.529, 1.482, 1.482, 1.533, 1.635, 1.791, 2.068, 2.313, 2.719, 3.109,\n> +            2.707, 2.424, 2.059, 1.791, 1.626, 1.429, 1.329, 1.282, 1.282, 1.333, 1.433, 1.629, 1.791, 2.068, 2.438, 2.719,\n> +            2.555, 2.233, 1.889, 1.626, 1.429, 1.321, 1.176, 1.126, 1.126, 1.181, 1.327, 1.433, 1.629, 1.894, 2.241, 2.538,\n> +            2.482, 2.108, 1.775, 1.518, 1.321, 1.176, 1.112, 1.011, 1.012, 1.122, 1.181, 1.327, 1.523, 1.779, 2.113, 2.462,\n> +            2.478, 2.048, 1.719, 1.465, 1.266, 1.112, 1.009, 1.001, 1.007, 1.012, 1.122, 1.274, 1.469, 1.722, 2.051, 2.454,\n> +            2.478, 2.048, 1.719, 1.465, 1.266, 1.112, 1.004, 1.001, 1.001, 1.011, 1.122, 1.274, 1.469, 1.722, 2.051, 2.454,\n> +            2.478, 2.099, 1.768, 1.511, 1.312, 1.163, 1.108, 1.004, 1.008, 1.112, 1.171, 1.321, 1.515, 1.767, 2.097, 2.454,\n> +            2.541, 2.217, 1.877, 1.614, 1.417, 1.312, 1.163, 1.112, 1.112, 1.171, 1.317, 1.421, 1.616, 1.874, 2.214, 2.516,\n> +            2.686, 2.404, 2.046, 1.779, 1.614, 1.417, 1.317, 1.267, 1.267, 1.319, 1.421, 1.614, 1.773, 2.039, 2.399, 2.669,\n> +            3.063, 2.678, 2.292, 2.046, 1.779, 1.622, 1.521, 1.469, 1.469, 1.519, 1.622, 1.773, 2.038, 2.277, 2.669, 3.049,\n> +            3.224, 3.063, 2.616, 2.285, 1.995, 1.781, 1.725, 1.723, 1.723, 1.723, 1.777, 1.984, 2.271, 2.598, 3.049, 3.187\n> +        ],\n> +        \"sigma\": 0.005,\n> +        \"sigma_Cb\": 0.005\n> +    },\n> +    \"rpi.contrast\":\n> +    {\n> +        \"ce_enable\": 1,\n> +        \"gamma_curve\":\n> +        [\n> +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120, 18051, 6144, 20790, 7168, 23193,\n> +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288, 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n> +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753, 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n> +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954, 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n> +            65535, 65535\n> +        ]\n> +    },\n> +    \"rpi.ccm\":\n> +    {\n> +        \"ccms\":\n> +        [\n> +            {\n> +                \"ct\": 5500, \"ccm\":\n> +                [\n> +                    1.40348, -0.45861, 0.05512, -0.24419, 1.25488, -0.01068, -0.08564, -0.31571, 1.40135\n> +                ]\n> +            }\n> +        ]\n> +    },\n> +    \"rpi.sharpen\":\n> +    {\n> +               \"threshold\":1.5,\n> +               \"strength\":0.5,\n> +               \"limit\":0.2\n> +    }\n> +}\n> diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> index 2def75cb..e84cd099 100644\n> --- a/src/ipa/raspberrypi/data/meson.build\n> +++ b/src/ipa/raspberrypi/data/meson.build\n> @@ -7,6 +7,7 @@ conf_files = files([\n>      'imx378.json',\n>      'imx477.json',\n>      'imx477_noir.json',\n> +    'imx519.json',\n>      'ov5647.json',\n>      'ov5647_noir.json',\n>      'ov9281.json',\n> diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> index 1af31e4a..176055f4 100644\n> --- a/src/ipa/raspberrypi/meson.build\n> +++ b/src/ipa/raspberrypi/meson.build\n> @@ -22,6 +22,7 @@ rpi_ipa_sources = files([\n>      'cam_helper_imx219.cpp',\n>      'cam_helper_imx290.cpp',\n>      'cam_helper_imx477.cpp',\n> +    'cam_helper_imx519.cpp',\n>      'cam_helper_ov9281.cpp',\n>      'controller/controller.cpp',\n>      'controller/histogram.cpp',\n> --\n> 2.17.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1A196C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 11 Oct 2021 08:16:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7B8F868F4D;\n\tMon, 11 Oct 2021 10:16:43 +0200 (CEST)","from mail-wr1-x436.google.com (mail-wr1-x436.google.com\n\t[IPv6:2a00:1450:4864:20::436])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B9A0D60502\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Oct 2021 10:16:41 +0200 (CEST)","by mail-wr1-x436.google.com with SMTP id g25so6856638wrb.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Oct 2021 01:16:41 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"qEXzDEj5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=34gM7adjTfZc/Ipyc/GbjAHZxVdnEsFSFnTaQG0mx0Q=;\n\tb=qEXzDEj5EwsGl1S/GL5Hz/5D1CTDV/Z51A7TN+tKcUGWrh5569tLM3wVRvmHhzhtEA\n\tOuLBB/Gt77C/J3Kp+M2OKFHeVEiwdDxuPGfQt0fDuIBXE+BXx3zJ7Fe483SulwIK0tgQ\n\tWZauYyGB4gMAHCByavpHxEhtjaXWFqDWUBllTdPTD7CDquahIhHNMLFVr+YV7KSvaSji\n\t0crN3nr+/+2sdCUKVQMUWUt1rsejDlO27tvlyuo+9Y/K0XYOR68EriXXos2m41kCJiGN\n\tQ3bsRu2K6dtWOQrx/88UliVy4xpWPJ95lrRsvVpYDdrFtVrTG2j4FMjvoBH47tCIhA1l\n\tIn0w==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=34gM7adjTfZc/Ipyc/GbjAHZxVdnEsFSFnTaQG0mx0Q=;\n\tb=Lwfrt0VTPV6UQCb5KUBrRahHMKiw9SNDlc4TuAiZ+lvjBWeN0jiVkKwDMy/Zg1xrUF\n\ttzrQnfwtFXdZVqcZh4Xe9zka0erX5wVCNBpUGZZu60mKwUN41CuG4g9Hd2sw0R2wQviJ\n\tIPRg9Ou2bSd7L8t+Dpy9AmjL6rmVswEprA+8UezE9cx0G4NS9bIw11QEd50hz8ze5bGz\n\tTViT2OZ3n5pQYTCmnZQXo1+rMyj8AMclSriKsRgXS0tytov4Bp2DgIzbYfMfvFt7ijSV\n\tNKu+goWB3KMqQCLSThTWgaTIQ2QnyMgt8CAlTXkaka7qiFpPmcl7raBHSPYlH653Nw1v\n\th8MQ==","X-Gm-Message-State":"AOAM531YNJt8LmWZbX2FBv8Fmpg9RHSs1s8UO7oERHuC4mgZeggLshJm\n\tFucJMb1XpeY8kxkozTbRHo5IqYRrqJv5dKSSbNOWQlql4aXWnQ==","X-Google-Smtp-Source":"ABdhPJzFL+PPKQ/uMVmbuyLUxYZo7qAodFpANDNNKXFlxQyeHxFwte/e1KQYcONIn0LPB8XAKirXQuuC+IloJSzFiBY=","X-Received":"by 2002:a7b:cb82:: with SMTP id\n\tm2mr18816764wmi.171.1633940201038; \n\tMon, 11 Oct 2021 01:16:41 -0700 (PDT)","MIME-Version":"1.0","References":"<638360E6-389E-4699-A524-584E7A555C61@arducam.com>","In-Reply-To":"<638360E6-389E-4699-A524-584E7A555C61@arducam.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Mon, 11 Oct 2021 09:16:30 +0100","Message-ID":"<CAHW6GYLsy2_su9t=Fqh=KAJ=dW3YKp6AuqS_AOJtTp6jZDib-w@mail.gmail.com>","To":"Arducam info <info@arducam.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH] libcamera: ipa: raspberrypi: Add\n\tsupport for imx519 sensor","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":20109,"web_url":"https://patchwork.libcamera.org/comment/20109/","msgid":"<97927250-56E8-480C-97C0-A756A54CF7B4@arducam.com>","date":"2021-10-11T12:11:50","subject":"Re: [libcamera-devel] [PATCH] libcamera: ipa: raspberrypi: Add\n\tsupport for imx519 sensor","submitter":{"id":99,"url":"https://patchwork.libcamera.org/api/people/99/","name":"Arducam info","email":"info@arducam.com"},"content":"Hi David and Naush\nAs you know Arducam keeps working for camera solutions for Raspberry pi for a long time.\nThis new IMX519 camera is the latest open source camera driver and ISP tuned libcamera json config.\nWe have already committed the IMX519 driver source code to RaspberryPi/linux repo with Dave Stevenson weeks ago: https://github.com/raspberrypi/linux/pull/4548/commits <https://github.com/raspberrypi/linux/pull/4548/commits> \n\nAnd this IMX519 also supports the long exposure as the IMX477, check the statement below from the datasheet.\n\nPlease let me know your shipping address and contact phone number, I will send you the first few samples tomorrow with DHL shipping.\nRegards\nLee\n\n\n\n> On 11 Oct 2021, at 4:16 PM, David Plowman <david.plowman@raspberrypi.com> wrote:\n> \n> Hi Lee\n> \n> Thank you very much for your contribution, we're very pleased to see\n> others making use of the Pi's camera system in this way!\n> \n> On Mon, 11 Oct 2021 at 05:06, Arducam info <info@arducam.com <mailto:info@arducam.com>> wrote:\n>> \n>> The necessary tuning file and CamHelper is added for the imx519 sensor.\n>> \n>> The imx519 is a 16MP rolling shutter sensor. To enable\n>> it, please add\n>> \n>> dtoverlay=imx519\n>> \n>> to the /boot/config.txt file and reboot the Pi.\n>> \n>> Signed-off-by: Lee Jackson <info@arducam.com>\n>> ---\n>> src/ipa/raspberrypi/cam_helper_imx519.cpp | 185 +++++++++++++++\n>> src/ipa/raspberrypi/data/imx519.json      | 272 ++++++++++++++++++++++\n>> src/ipa/raspberrypi/data/meson.build      |   1 +\n>> src/ipa/raspberrypi/meson.build           |   1 +\n>> 4 files changed, 459 insertions(+)\n>> create mode 100644 src/ipa/raspberrypi/cam_helper_imx519.cpp\n>> create mode 100644 src/ipa/raspberrypi/data/imx519.json\n>> \n>> diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n>> new file mode 100644\n>> index 00000000..eaf24982\n>> --- /dev/null\n>> +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n>> @@ -0,0 +1,185 @@\n>> +/* SPDX-License-Identifier: BSD-2-Clause */\n>> +/*\n>> + * Based on cam_helper_imx477.cpp\n>> + * Copyright (C) 2020, Raspberry Pi (Trading) Limited\n>> + *\n>> + * cam_helper_imx519.cpp - camera helper for imx519 sensor\n>> + * Copyright (C) 2021, Arducam Technology co., Ltd.\n>> + */\n>> +\n>> +#include <assert.h>\n>> +#include <cmath>\n>> +#include <stddef.h>\n>> +#include <stdio.h>\n>> +#include <stdlib.h>\n>> +\n>> +#include <libcamera/base/log.h>\n>> +\n>> +#include \"cam_helper.hpp\"\n>> +#include \"md_parser.hpp\"\n>> +\n>> +using namespace RPiController;\n>> +using namespace libcamera;\n>> +using libcamera::utils::Duration;\n>> +\n>> +namespace libcamera {\n>> +LOG_DECLARE_CATEGORY(IPARPI)\n>> +}\n>> +\n>> +/*\n>> + * We care about two gain registers and a pair of exposure registers. Their\n>> + * I2C addresses from the Sony IMX519 datasheet:\n>> + */\n>> +constexpr uint32_t expHiReg = 0x0202;\n>> +constexpr uint32_t expLoReg = 0x0203;\n>> +constexpr uint32_t gainHiReg = 0x0204;\n>> +constexpr uint32_t gainLoReg = 0x0205;\n>> +constexpr uint32_t frameLengthHiReg = 0x0340;\n>> +constexpr uint32_t frameLengthLoReg = 0x0341;\n>> +constexpr std::initializer_list<uint32_t> registerList =\n>> +       { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg  };\n>> +\n>> +class CamHelperImx519 : public CamHelper\n>> +{\n>> +public:\n>> +       CamHelperImx519();\n>> +       uint32_t GainCode(double gain) const override;\n>> +       double Gain(uint32_t gain_code) const override;\n>> +       void Prepare(libcamera::Span<const uint8_t> buffer, Metadata &metadata) override;\n>> +       uint32_t GetVBlanking(Duration &exposure, Duration minFrameDuration,\n>> +                             Duration maxFrameDuration) const override;\n>> +       void GetDelays(int &exposure_delay, int &gain_delay,\n>> +                      int &vblank_delay) const override;\n>> +       bool SensorEmbeddedDataPresent() const override;\n>> +\n>> +private:\n>> +       /*\n>> +        * Smallest difference between the frame length and integration time,\n>> +        * in units of lines.\n>> +        */\n>> +       static constexpr int frameIntegrationDiff = 32;\n>> +       /* Maximum frame length allowable for long exposure calculations. */\n>> +       static constexpr int frameLengthMax = 0xffdc;\n>> +       /* Largest long exposure scale factor given as a left shift on the frame length. */\n>> +       static constexpr int longExposureShiftMax = 7;\n>> +\n>> +       void PopulateMetadata(const MdParser::RegisterMap &registers,\n>> +                             Metadata &metadata) const override;\n>> +};\n>> +\n>> +CamHelperImx519::CamHelperImx519()\n>> +       : CamHelper(std::make_unique<MdParserSmia>(registerList), frameIntegrationDiff)\n>> +{\n>> +}\n>> +\n>> +uint32_t CamHelperImx519::GainCode(double gain) const\n>> +{\n>> +       return static_cast<uint32_t>(1024 - 1024 / gain);\n>> +}\n>> +\n>> +double CamHelperImx519::Gain(uint32_t gain_code) const\n>> +{\n>> +       return 1024.0 / (1024 - gain_code);\n>> +}\n>> +\n>> +void CamHelperImx519::Prepare(libcamera::Span<const uint8_t> buffer, Metadata &metadata)\n>> +{\n>> +       MdParser::RegisterMap registers;\n>> +       DeviceStatus deviceStatus;\n>> +\n>> +       if (metadata.Get(\"device.status\", deviceStatus)) {\n>> +               LOG(IPARPI, Error) << \"DeviceStatus not found from DelayedControls\";\n>> +               return;\n>> +       }\n>> +\n>> +       parseEmbeddedData(buffer, metadata);\n>> +\n>> +       /*\n>> +        * The DeviceStatus struct is first populated with values obtained from\n>> +        * DelayedControls. If this reports frame length is > frameLengthMax,\n>> +        * it means we are using a long exposure mode. Since the long exposure\n>> +        * scale factor is not returned back through embedded data, we must rely\n>> +        * on the existing exposure lines and frame length values returned by\n>> +        * DelayedControls.\n>> +        *\n>> +        * Otherwise, all values are updated with what is reported in the\n>> +        * embedded data.\n>> +        */\n>> +       if (deviceStatus.frame_length > frameLengthMax) {\n>> +               DeviceStatus parsedDeviceStatus;\n>> +\n>> +               metadata.Get(\"device.status\", parsedDeviceStatus);\n>> +               parsedDeviceStatus.shutter_speed = deviceStatus.shutter_speed;\n>> +               parsedDeviceStatus.frame_length = deviceStatus.frame_length;\n>> +               metadata.Set(\"device.status\", parsedDeviceStatus);\n>> +\n>> +               LOG(IPARPI, Debug) << \"Metadata updated for long exposure: \"\n>> +                                  << parsedDeviceStatus;\n>> +       }\n>> +}\n>> +\n>> +uint32_t CamHelperImx519::GetVBlanking(Duration &exposure,\n>> +                                      Duration minFrameDuration,\n>> +                                      Duration maxFrameDuration) const\n>> +{\n>> +       uint32_t frameLength, exposureLines;\n>> +       unsigned int shift = 0;\n>> +\n>> +       frameLength = mode_.height + CamHelper::GetVBlanking(exposure, minFrameDuration,\n>> +                                                            maxFrameDuration);\n>> +       /*\n>> +        * Check if the frame length calculated needs to be setup for long\n>> +        * exposure mode. This will require us to use a long exposure scale\n>> +        * factor provided by a shift operation in the sensor.\n>> +        */\n>> +       while (frameLength > frameLengthMax) {\n>> +               if (++shift > longExposureShiftMax) {\n>> +                       shift = longExposureShiftMax;\n>> +                       frameLength = frameLengthMax;\n>> +                       break;\n>> +               }\n>> +               frameLength >>= 1;\n>> +       }\n>> +\n>> +       if (shift) {\n>> +               /* Account for any rounding in the scaled frame length value. */\n>> +               frameLength <<= shift;\n>> +               exposureLines = ExposureLines(exposure);\n>> +               exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff);\n>> +               exposure = Exposure(exposureLines);\n>> +       }\n>> +\n>> +       return frameLength - mode_.height;\n>> +}\n>> +\n>> +void CamHelperImx519::GetDelays(int &exposure_delay, int &gain_delay,\n>> +                               int &vblank_delay) const\n>> +{\n>> +       exposure_delay = 2;\n>> +       gain_delay = 2;\n>> +       vblank_delay = 3;\n>> +}\n>> +\n>> +bool CamHelperImx519::SensorEmbeddedDataPresent() const\n>> +{\n>> +       return true;\n>> +}\n>> +\n>> +void CamHelperImx519::PopulateMetadata(const MdParser::RegisterMap &registers,\n>> +                                      Metadata &metadata) const\n>> +{\n>> +       DeviceStatus deviceStatus;\n>> +\n>> +       deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg));\n>> +       deviceStatus.analogue_gain = Gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg));\n>> +       deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg);\n>> +\n>> +       metadata.Set(\"device.status\", deviceStatus);\n>> +}\n>> +\n>> +static CamHelper *Create()\n>> +{\n>> +       return new CamHelperImx519();\n>> +}\n>> +\n>> +static RegisterCamHelper reg(\"imx519\", &Create);\n>> diff --git a/src/ipa/raspberrypi/data/imx519.json b/src/ipa/raspberrypi/data/imx519.json\n>> new file mode 100644\n>> index 00000000..39e788ad\n>> --- /dev/null\n>> +++ b/src/ipa/raspberrypi/data/imx519.json\n>> @@ -0,0 +1,272 @@\n>> +{\n>> +    \"rpi.black_level\":\n>> +    {\n>> +        \"black_level\": 4096\n>> +    },\n>> +    \"rpi.dpc\":\n>> +    {\n>> +    },\n>> +    \"rpi.lux\":\n>> +    {\n>> +        \"reference_shutter_speed\": 10812,\n>> +        \"reference_gain\": 2.0,\n>> +        \"reference_aperture\": 1.0,\n>> +        \"reference_lux\": 1250,\n>> +        \"reference_Y\": 12737\n>> +    },\n>> +    \"rpi.noise\":\n>> +    {\n>> +        \"reference_constant\": 0,\n>> +        \"reference_slope\": 2.91\n>> +    },\n>> +    \"rpi.geq\":\n>> +    {\n>> +        \"offset\": 444,\n>> +        \"slope\": 0.00731\n>> +    },\n>> +    \"rpi.sdn\":\n>> +    {\n>> +        \"deviation\":3.7,\n>> +        \"strength\":0.75\n>> +    },\n>> +    \"rpi.awb\":\n>> +    {\n>> +        \"priors\":\n>> +        [\n>> +            {\n>> +                \"lux\": 0, \"prior\":\n>> +                [\n>> +                    2000, 1.0, 3000, 0.0, 13000, 0.0\n>> +                ]\n>> +            },\n>> +            {\n>> +                \"lux\": 800, \"prior\":\n>> +                [\n>> +                    2000, 0.0, 6000, 2.0, 13000, 2.0\n>> +                ]\n>> +            },\n>> +            {\n>> +                \"lux\": 1500, \"prior\":\n>> +                [\n>> +                    2000, 0.0, 4000, 1.0, 6000, 6.0, 6500, 7.0, 7000, 1.0, 13000, 1.0\n>> +                ]\n>> +            }\n>> +        ],\n>> +        \"modes\":\n>> +        {\n>> +            \"auto\":\n>> +            {\n>> +                \"lo\": 2500,\n>> +                \"hi\": 8000\n>> +            },\n>> +            \"incandescent\":\n>> +            {\n>> +                \"lo\": 2500,\n>> +                \"hi\": 3000\n>> +            },\n>> +            \"tungsten\":\n>> +            {\n>> +                \"lo\": 3000,\n>> +                \"hi\": 3500\n>> +            },\n>> +            \"fluorescent\":\n>> +            {\n>> +                \"lo\": 4000,\n>> +                \"hi\": 4700\n>> +            },\n>> +            \"indoor\":\n>> +            {\n>> +                \"lo\": 3000,\n>> +                \"hi\": 5000\n>> +            },\n>> +            \"daylight\":\n>> +            {\n>> +                \"lo\": 5500,\n>> +                \"hi\": 6500\n>> +            },\n>> +            \"cloudy\":\n>> +            {\n>> +                \"lo\": 7000,\n>> +                \"hi\": 8600\n>> +            }\n>> +        },\n>> +        \"bayes\": 0\n> \n> Just a small thing, but if we're going with the simple grey world\n> algorithm it might be worth deleting the other AWB parameters as they\n> don't do anything.\n> \n> And a few final questions:\n> \n> * Are you planning to upstream an open source driver for the imx519?\n> The preference within libcamera (someone will correct me if I'm\n> wrong!) is to support sensors where code and drivers are open.\n> \n> * If you're planning to open-source the driver we'd be pleased to\n> receive pull requests into our own Raspberry Pi kernel distribution.\n> \n> * I assume this is a fairly standard Bayer sensor? If you have a\n> working open source driver and can send me a module then I'd be very\n> happy to help you further with the json tuning file.\n> \n> Thanks and best regards\n> David\n> \n>> +\n>> +    },\n>> +    \"rpi.agc\":\n>> +    {\n>> +        \"metering_modes\":\n>> +        {\n>> +            \"centre-weighted\":\n>> +            {\n>> +                \"weights\":\n>> +                [\n>> +                    3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0\n>> +                ]\n>> +            },\n>> +            \"spot\":\n>> +            {\n>> +                \"weights\":\n>> +                [\n>> +                    2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n>> +                ]\n>> +            },\n>> +            \"matrix\":\n>> +            {\n>> +                \"weights\":\n>> +                [\n>> +                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\n>> +                ]\n>> +            }\n>> +        },\n>> +        \"exposure_modes\":\n>> +        {\n>> +            \"normal\":\n>> +            {\n>> +                \"shutter\":\n>> +                [\n>> +                    100, 10000, 30000, 60000, 120000\n>> +                ],\n>> +                \"gain\":\n>> +                [\n>> +                    1.0, 2.0, 4.0, 6.0, 12.0\n>> +                ]\n>> +            },\n>> +            \"short\":\n>> +            {\n>> +                \"shutter\":\n>> +                [\n>> +                    100, 5000, 10000, 20000, 120000\n>> +                ],\n>> +                \"gain\":\n>> +                [\n>> +                    1.0, 2.0, 4.0, 6.0, 12.0\n>> +                ]\n>> +            }\n>> +        },\n>> +        \"constraint_modes\":\n>> +        {\n>> +            \"normal\":\n>> +            [\n>> +                {\n>> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n>> +                    [\n>> +                        0, 0.5, 1000, 0.5\n>> +                    ]\n>> +                }\n>> +            ],\n>> +            \"highlight\":\n>> +            [\n>> +                {\n>> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n>> +                    [\n>> +                        0, 0.5, 1000, 0.5\n>> +                    ]\n>> +                },\n>> +                {\n>> +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n>> +                    [\n>> +                        0, 0.8, 1000, 0.8\n>> +                    ]\n>> +                }\n>> +            ]\n>> +        },\n>> +        \"y_target\":\n>> +        [\n>> +            0, 0.16, 1000, 0.165, 10000, 0.17\n>> +        ]\n>> +    },\n>> +    \"rpi.alsc\":\n>> +    {\n>> +        \"omega\": 1.3,\n>> +        \"n_iter\": 100,\n>> +        \"luminance_strength\": 0.5,\n>> +        \"calibrations_Cr\":\n>> +        [\n>> +            {\n>> +                \"ct\": 6500, \"table\":\n>> +                [\n>> +                    2.544, 2.541, 2.531, 2.518, 2.506, 2.495, 2.489, 2.489, 2.489, 2.491, 2.502, 2.511, 2.524, 2.534, 2.542, 2.547,\n>> +                    2.541, 2.532, 2.521, 2.506, 2.493, 2.479, 2.469, 2.462, 2.462, 2.473, 2.488, 2.502, 2.511, 2.527, 2.536, 2.542,\n>> +                    2.531, 2.523, 2.506, 2.492, 2.474, 2.458, 2.444, 2.435, 2.435, 2.446, 2.466, 2.481, 2.498, 2.511, 2.526, 2.536,\n>> +                    2.523, 2.513, 2.492, 2.474, 2.458, 2.438, 2.418, 2.408, 2.408, 2.421, 2.443, 2.463, 2.481, 2.498, 2.517, 2.526,\n>> +                    2.513, 2.502, 2.481, 2.459, 2.438, 2.418, 2.397, 2.379, 2.379, 2.399, 2.421, 2.443, 2.463, 2.486, 2.506, 2.517,\n>> +                    2.506, 2.492, 2.469, 2.445, 2.423, 2.397, 2.377, 2.368, 2.369, 2.379, 2.399, 2.427, 2.451, 2.474, 2.495, 2.511,\n>> +                    2.506, 2.492, 2.469, 2.445, 2.423, 2.397, 2.372, 2.364, 2.364, 2.374, 2.399, 2.427, 2.449, 2.474, 2.495, 2.511,\n>> +                    2.506, 2.493, 2.474, 2.451, 2.426, 2.401, 2.382, 2.368, 2.369, 2.382, 2.405, 2.431, 2.449, 2.476, 2.497, 2.509,\n>> +                    2.504, 2.493, 2.475, 2.452, 2.431, 2.412, 2.401, 2.382, 2.382, 2.403, 2.416, 2.438, 2.457, 2.477, 2.497, 2.505,\n>> +                    2.499, 2.492, 2.474, 2.457, 2.441, 2.431, 2.412, 2.404, 2.404, 2.416, 2.432, 2.447, 2.459, 2.478, 2.495, 2.501,\n>> +                    2.499, 2.488, 2.473, 2.463, 2.453, 2.441, 2.431, 2.425, 2.425, 2.432, 2.445, 2.459, 2.466, 2.478, 2.491, 2.495,\n>> +                    2.499, 2.481, 2.472, 2.466, 2.458, 2.449, 2.441, 2.439, 2.439, 2.444, 2.454, 2.464, 2.469, 2.477, 2.484, 2.491\n>> +                ]\n>> +            }\n>> +        ],\n>> +        \"calibrations_Cb\":\n>> +        [\n>> +            {\n>> +                \"ct\": 6500, \"table\":\n>> +                [\n>> +                    1.352, 1.352, 1.349, 1.348, 1.347, 1.346, 1.347, 1.349, 1.351, 1.351, 1.352, 1.353, 1.353, 1.355, 1.358, 1.359,\n>> +                    1.359, 1.355, 1.352, 1.349, 1.348, 1.348, 1.348, 1.351, 1.352, 1.352, 1.352, 1.354, 1.356, 1.358, 1.361, 1.366,\n>> +                    1.364, 1.359, 1.355, 1.352, 1.349, 1.349, 1.351, 1.353, 1.353, 1.353, 1.355, 1.356, 1.358, 1.362, 1.366, 1.371,\n>> +                    1.371, 1.365, 1.359, 1.355, 1.352, 1.352, 1.353, 1.357, 1.357, 1.356, 1.356, 1.359, 1.362, 1.366, 1.371, 1.377,\n>> +                    1.375, 1.371, 1.365, 1.362, 1.359, 1.359, 1.359, 1.364, 1.364, 1.364, 1.364, 1.365, 1.367, 1.371, 1.377, 1.382,\n>> +                    1.379, 1.375, 1.371, 1.367, 1.367, 1.367, 1.369, 1.373, 1.374, 1.374, 1.373, 1.373, 1.374, 1.377, 1.382, 1.386,\n>> +                    1.383, 1.378, 1.374, 1.372, 1.372, 1.372, 1.373, 1.375, 1.378, 1.379, 1.379, 1.379, 1.379, 1.381, 1.386, 1.389,\n>> +                    1.384, 1.379, 1.376, 1.374, 1.373, 1.373, 1.374, 1.379, 1.379, 1.379, 1.379, 1.379, 1.381, 1.382, 1.386, 1.394,\n>> +                    1.386, 1.379, 1.376, 1.375, 1.374, 1.374, 1.374, 1.378, 1.378, 1.378, 1.378, 1.379, 1.381, 1.383, 1.386, 1.394,\n>> +                    1.385, 1.379, 1.376, 1.375, 1.374, 1.374, 1.375, 1.378, 1.378, 1.378, 1.378, 1.379, 1.381, 1.383, 1.387, 1.393,\n>> +                    1.379, 1.378, 1.375, 1.374, 1.373, 1.374, 1.375, 1.377, 1.378, 1.378, 1.378, 1.379, 1.381, 1.382, 1.386, 1.388,\n>> +                    1.379, 1.376, 1.374, 1.372, 1.372, 1.374, 1.375, 1.377, 1.378, 1.378, 1.377, 1.378, 1.379, 1.382, 1.384, 1.387\n>> +                ]\n>> +            }\n>> +        ],\n>> +        \"luminance_lut\":\n>> +        [\n>> +            3.257, 3.091, 2.639, 2.301, 2.009, 1.795, 1.742, 1.742, 1.742, 1.742, 1.798, 2.011, 2.309, 2.649, 3.109, 3.251,\n>> +            3.091, 2.703, 2.311, 2.059, 1.791, 1.631, 1.529, 1.482, 1.482, 1.533, 1.635, 1.791, 2.068, 2.313, 2.719, 3.109,\n>> +            2.707, 2.424, 2.059, 1.791, 1.626, 1.429, 1.329, 1.282, 1.282, 1.333, 1.433, 1.629, 1.791, 2.068, 2.438, 2.719,\n>> +            2.555, 2.233, 1.889, 1.626, 1.429, 1.321, 1.176, 1.126, 1.126, 1.181, 1.327, 1.433, 1.629, 1.894, 2.241, 2.538,\n>> +            2.482, 2.108, 1.775, 1.518, 1.321, 1.176, 1.112, 1.011, 1.012, 1.122, 1.181, 1.327, 1.523, 1.779, 2.113, 2.462,\n>> +            2.478, 2.048, 1.719, 1.465, 1.266, 1.112, 1.009, 1.001, 1.007, 1.012, 1.122, 1.274, 1.469, 1.722, 2.051, 2.454,\n>> +            2.478, 2.048, 1.719, 1.465, 1.266, 1.112, 1.004, 1.001, 1.001, 1.011, 1.122, 1.274, 1.469, 1.722, 2.051, 2.454,\n>> +            2.478, 2.099, 1.768, 1.511, 1.312, 1.163, 1.108, 1.004, 1.008, 1.112, 1.171, 1.321, 1.515, 1.767, 2.097, 2.454,\n>> +            2.541, 2.217, 1.877, 1.614, 1.417, 1.312, 1.163, 1.112, 1.112, 1.171, 1.317, 1.421, 1.616, 1.874, 2.214, 2.516,\n>> +            2.686, 2.404, 2.046, 1.779, 1.614, 1.417, 1.317, 1.267, 1.267, 1.319, 1.421, 1.614, 1.773, 2.039, 2.399, 2.669,\n>> +            3.063, 2.678, 2.292, 2.046, 1.779, 1.622, 1.521, 1.469, 1.469, 1.519, 1.622, 1.773, 2.038, 2.277, 2.669, 3.049,\n>> +            3.224, 3.063, 2.616, 2.285, 1.995, 1.781, 1.725, 1.723, 1.723, 1.723, 1.777, 1.984, 2.271, 2.598, 3.049, 3.187\n>> +        ],\n>> +        \"sigma\": 0.005,\n>> +        \"sigma_Cb\": 0.005\n>> +    },\n>> +    \"rpi.contrast\":\n>> +    {\n>> +        \"ce_enable\": 1,\n>> +        \"gamma_curve\":\n>> +        [\n>> +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120, 18051, 6144, 20790, 7168, 23193,\n>> +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288, 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n>> +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753, 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n>> +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954, 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n>> +            65535, 65535\n>> +        ]\n>> +    },\n>> +    \"rpi.ccm\":\n>> +    {\n>> +        \"ccms\":\n>> +        [\n>> +            {\n>> +                \"ct\": 5500, \"ccm\":\n>> +                [\n>> +                    1.40348, -0.45861, 0.05512, -0.24419, 1.25488, -0.01068, -0.08564, -0.31571, 1.40135\n>> +                ]\n>> +            }\n>> +        ]\n>> +    },\n>> +    \"rpi.sharpen\":\n>> +    {\n>> +               \"threshold\":1.5,\n>> +               \"strength\":0.5,\n>> +               \"limit\":0.2\n>> +    }\n>> +}\n>> diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n>> index 2def75cb..e84cd099 100644\n>> --- a/src/ipa/raspberrypi/data/meson.build\n>> +++ b/src/ipa/raspberrypi/data/meson.build\n>> @@ -7,6 +7,7 @@ conf_files = files([\n>>     'imx378.json',\n>>     'imx477.json',\n>>     'imx477_noir.json',\n>> +    'imx519.json',\n>>     'ov5647.json',\n>>     'ov5647_noir.json',\n>>     'ov9281.json',\n>> diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n>> index 1af31e4a..176055f4 100644\n>> --- a/src/ipa/raspberrypi/meson.build\n>> +++ b/src/ipa/raspberrypi/meson.build\n>> @@ -22,6 +22,7 @@ rpi_ipa_sources = files([\n>>     'cam_helper_imx219.cpp',\n>>     'cam_helper_imx290.cpp',\n>>     'cam_helper_imx477.cpp',\n>> +    'cam_helper_imx519.cpp',\n>>     'cam_helper_ov9281.cpp',\n>>     'controller/controller.cpp',\n>>     'controller/histogram.cpp',\n>> --\n>> 2.17.1","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id CC733C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 11 Oct 2021 12:12:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5625F68F50;\n\tMon, 11 Oct 2021 14:12:08 +0200 (CEST)","from out29-171.mail.aliyun.com (out29-171.mail.aliyun.com\n\t[115.124.29.171])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4ADBF6012B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Oct 2021 14:12:01 +0200 (CEST)","from 127.0.0.1(mailfrom:info@arducam.com\n\tfp:SMTPD_---.LXGFRk8_1633954312)\n\tby smtp.aliyun-inc.com(10.147.42.202);\n\tMon, 11 Oct 2021 20:11:56 +0800"],"X-Alimail-AntiSpam":"AC=CONTINUE; BC=0.06875215|-1; CH=blue;\n\tDM=|OVERLOAD|false|; \n\tDS=CONTINUE|ham_system_inform|0.00656924-0.000803059-0.992628;\n\tFP=0|0|0|0|0|-1|-1|-1; HT=ay29a033018047208; MF=info@arducam.com; NM=1;\n\tPH=DS; \n\tRN=4; RT=4; SR=0; TI=SMTPD_---.LXGFRk8_1633954312; ","From":"Arducam info <info@arducam.com>","Message-Id":"<97927250-56E8-480C-97C0-A756A54CF7B4@arducam.com>","Content-Type":"multipart/alternative;\n\tboundary=\"Apple-Mail=_0CE66D14-6BA7-4661-9BD5-15E32FD481DB\"","Mime-Version":"1.0 (Mac OS X Mail 14.0 \\(3654.60.0.2.21\\))","Date":"Mon, 11 Oct 2021 20:11:50 +0800","In-Reply-To":"<CAHW6GYLsy2_su9t=Fqh=KAJ=dW3YKp6AuqS_AOJtTp6jZDib-w@mail.gmail.com>","To":"David Plowman <david.plowman@raspberrypi.com>","References":"<638360E6-389E-4699-A524-584E7A555C61@arducam.com>\n\t<CAHW6GYLsy2_su9t=Fqh=KAJ=dW3YKp6AuqS_AOJtTp6jZDib-w@mail.gmail.com>","X-Mailer":"Apple Mail (2.3654.60.0.2.21)","Subject":"Re: [libcamera-devel] [PATCH] libcamera: ipa: raspberrypi: Add\n\tsupport for imx519 sensor","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>,\n\tArducam info <info@arducam.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":20112,"web_url":"https://patchwork.libcamera.org/comment/20112/","msgid":"<CAHW6GYL__WG9=LhgFi3j=Cz4NbZW=X+KKsUhw0cK5deG2Ua_1w@mail.gmail.com>","date":"2021-10-11T12:59:29","subject":"Re: [libcamera-devel] [PATCH] libcamera: ipa: raspberrypi: Add\n\tsupport for imx519 sensor","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi again Lee\n\nThanks for the information. I've PMed you my shipping details and phone\nnumber. If you're happy for me to do so I will then take the samples, run\nthem through the tuning tool and submit a more complete colour tuning.\n\nBest regards\nDavid\n\nOn Mon, 11 Oct 2021 at 13:12, Arducam info <info@arducam.com> wrote:\n\n> Hi David and Naush\n> As you know Arducam keeps working for camera solutions for Raspberry pi\n> for a long time.\n> This new IMX519 camera is the latest open source camera driver and ISP\n> tuned libcamera json config.\n> We have already committed the IMX519 driver source code to\n> RaspberryPi/linux repo with Dave Stevenson weeks ago:\n> https://github.com/raspberrypi/linux/pull/4548/commits\n>\n> And this IMX519 also supports the long exposure as the IMX477, check the\n> statement below from the datasheet.\n>\n> Please let me know your shipping address and contact phone number, I will\n> send you the first few samples tomorrow with DHL shipping.\n> Regards\n> Lee\n>\n>\n>\n> On 11 Oct 2021, at 4:16 PM, David Plowman <david.plowman@raspberrypi.com>\n> wrote:\n>\n> Hi Lee\n>\n> Thank you very much for your contribution, we're very pleased to see\n> others making use of the Pi's camera system in this way!\n>\n> On Mon, 11 Oct 2021 at 05:06, Arducam info <info@arducam.com> wrote:\n>\n>\n> The necessary tuning file and CamHelper is added for the imx519 sensor.\n>\n> The imx519 is a 16MP rolling shutter sensor. To enable\n> it, please add\n>\n> dtoverlay=imx519\n>\n> to the /boot/config.txt file and reboot the Pi.\n>\n> Signed-off-by: Lee Jackson <info@arducam.com>\n> ---\n> src/ipa/raspberrypi/cam_helper_imx519.cpp | 185 +++++++++++++++\n> src/ipa/raspberrypi/data/imx519.json      | 272 ++++++++++++++++++++++\n> src/ipa/raspberrypi/data/meson.build      |   1 +\n> src/ipa/raspberrypi/meson.build           |   1 +\n> 4 files changed, 459 insertions(+)\n> create mode 100644 src/ipa/raspberrypi/cam_helper_imx519.cpp\n> create mode 100644 src/ipa/raspberrypi/data/imx519.json\n>\n> diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp\n> b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n> new file mode 100644\n> index 00000000..eaf24982\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n> @@ -0,0 +1,185 @@\n> +/* SPDX-License-Identifier: BSD-2-Clause */\n> +/*\n> + * Based on cam_helper_imx477.cpp\n> + * Copyright (C) 2020, Raspberry Pi (Trading) Limited\n> + *\n> + * cam_helper_imx519.cpp - camera helper for imx519 sensor\n> + * Copyright (C) 2021, Arducam Technology co., Ltd.\n> + */\n> +\n> +#include <assert.h>\n> +#include <cmath>\n> +#include <stddef.h>\n> +#include <stdio.h>\n> +#include <stdlib.h>\n> +\n> +#include <libcamera/base/log.h>\n> +\n> +#include \"cam_helper.hpp\"\n> +#include \"md_parser.hpp\"\n> +\n> +using namespace RPiController;\n> +using namespace libcamera;\n> +using libcamera::utils::Duration;\n> +\n> +namespace libcamera {\n> +LOG_DECLARE_CATEGORY(IPARPI)\n> +}\n> +\n> +/*\n> + * We care about two gain registers and a pair of exposure registers.\n> Their\n> + * I2C addresses from the Sony IMX519 datasheet:\n> + */\n> +constexpr uint32_t expHiReg = 0x0202;\n> +constexpr uint32_t expLoReg = 0x0203;\n> +constexpr uint32_t gainHiReg = 0x0204;\n> +constexpr uint32_t gainLoReg = 0x0205;\n> +constexpr uint32_t frameLengthHiReg = 0x0340;\n> +constexpr uint32_t frameLengthLoReg = 0x0341;\n> +constexpr std::initializer_list<uint32_t> registerList =\n> +       { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg,\n> frameLengthLoReg  };\n> +\n> +class CamHelperImx519 : public CamHelper\n> +{\n> +public:\n> +       CamHelperImx519();\n> +       uint32_t GainCode(double gain) const override;\n> +       double Gain(uint32_t gain_code) const override;\n> +       void Prepare(libcamera::Span<const uint8_t> buffer, Metadata\n> &metadata) override;\n> +       uint32_t GetVBlanking(Duration &exposure, Duration\n> minFrameDuration,\n> +                             Duration maxFrameDuration) const override;\n> +       void GetDelays(int &exposure_delay, int &gain_delay,\n> +                      int &vblank_delay) const override;\n> +       bool SensorEmbeddedDataPresent() const override;\n> +\n> +private:\n> +       /*\n> +        * Smallest difference between the frame length and integration\n> time,\n> +        * in units of lines.\n> +        */\n> +       static constexpr int frameIntegrationDiff = 32;\n> +       /* Maximum frame length allowable for long exposure calculations.\n> */\n> +       static constexpr int frameLengthMax = 0xffdc;\n> +       /* Largest long exposure scale factor given as a left shift on the\n> frame length. */\n> +       static constexpr int longExposureShiftMax = 7;\n> +\n> +       void PopulateMetadata(const MdParser::RegisterMap &registers,\n> +                             Metadata &metadata) const override;\n> +};\n> +\n> +CamHelperImx519::CamHelperImx519()\n> +       : CamHelper(std::make_unique<MdParserSmia>(registerList),\n> frameIntegrationDiff)\n> +{\n> +}\n> +\n> +uint32_t CamHelperImx519::GainCode(double gain) const\n> +{\n> +       return static_cast<uint32_t>(1024 - 1024 / gain);\n> +}\n> +\n> +double CamHelperImx519::Gain(uint32_t gain_code) const\n> +{\n> +       return 1024.0 / (1024 - gain_code);\n> +}\n> +\n> +void CamHelperImx519::Prepare(libcamera::Span<const uint8_t> buffer,\n> Metadata &metadata)\n> +{\n> +       MdParser::RegisterMap registers;\n> +       DeviceStatus deviceStatus;\n> +\n> +       if (metadata.Get(\"device.status\", deviceStatus)) {\n> +               LOG(IPARPI, Error) << \"DeviceStatus not found from\n> DelayedControls\";\n> +               return;\n> +       }\n> +\n> +       parseEmbeddedData(buffer, metadata);\n> +\n> +       /*\n> +        * The DeviceStatus struct is first populated with values obtained\n> from\n> +        * DelayedControls. If this reports frame length is >\n> frameLengthMax,\n> +        * it means we are using a long exposure mode. Since the long\n> exposure\n> +        * scale factor is not returned back through embedded data, we\n> must rely\n> +        * on the existing exposure lines and frame length values returned\n> by\n> +        * DelayedControls.\n> +        *\n> +        * Otherwise, all values are updated with what is reported in the\n> +        * embedded data.\n> +        */\n> +       if (deviceStatus.frame_length > frameLengthMax) {\n> +               DeviceStatus parsedDeviceStatus;\n> +\n> +               metadata.Get(\"device.status\", parsedDeviceStatus);\n> +               parsedDeviceStatus.shutter_speed =\n> deviceStatus.shutter_speed;\n> +               parsedDeviceStatus.frame_length =\n> deviceStatus.frame_length;\n> +               metadata.Set(\"device.status\", parsedDeviceStatus);\n> +\n> +               LOG(IPARPI, Debug) << \"Metadata updated for long exposure:\n> \"\n> +                                  << parsedDeviceStatus;\n> +       }\n> +}\n> +\n> +uint32_t CamHelperImx519::GetVBlanking(Duration &exposure,\n> +                                      Duration minFrameDuration,\n> +                                      Duration maxFrameDuration) const\n> +{\n> +       uint32_t frameLength, exposureLines;\n> +       unsigned int shift = 0;\n> +\n> +       frameLength = mode_.height + CamHelper::GetVBlanking(exposure,\n> minFrameDuration,\n> +\n>                                                            maxFrameDuration);\n> +       /*\n> +        * Check if the frame length calculated needs to be setup for long\n> +        * exposure mode. This will require us to use a long exposure scale\n> +        * factor provided by a shift operation in the sensor.\n> +        */\n> +       while (frameLength > frameLengthMax) {\n> +               if (++shift > longExposureShiftMax) {\n> +                       shift = longExposureShiftMax;\n> +                       frameLength = frameLengthMax;\n> +                       break;\n> +               }\n> +               frameLength >>= 1;\n> +       }\n> +\n> +       if (shift) {\n> +               /* Account for any rounding in the scaled frame length\n> value. */\n> +               frameLength <<= shift;\n> +               exposureLines = ExposureLines(exposure);\n> +               exposureLines = std::min(exposureLines, frameLength -\n> frameIntegrationDiff);\n> +               exposure = Exposure(exposureLines);\n> +       }\n> +\n> +       return frameLength - mode_.height;\n> +}\n> +\n> +void CamHelperImx519::GetDelays(int &exposure_delay, int &gain_delay,\n> +                               int &vblank_delay) const\n> +{\n> +       exposure_delay = 2;\n> +       gain_delay = 2;\n> +       vblank_delay = 3;\n> +}\n> +\n> +bool CamHelperImx519::SensorEmbeddedDataPresent() const\n> +{\n> +       return true;\n> +}\n> +\n> +void CamHelperImx519::PopulateMetadata(const MdParser::RegisterMap\n> &registers,\n> +                                      Metadata &metadata) const\n> +{\n> +       DeviceStatus deviceStatus;\n> +\n> +       deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) *\n> 256 + registers.at(expLoReg));\n> +       deviceStatus.analogue_gain = Gain(registers.at(gainHiReg) * 256 +\n> registers.at(gainLoReg));\n> +       deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256\n> + registers.at(frameLengthLoReg);\n> +\n> +       metadata.Set(\"device.status\", deviceStatus);\n> +}\n> +\n> +static CamHelper *Create()\n> +{\n> +       return new CamHelperImx519();\n> +}\n> +\n> +static RegisterCamHelper reg(\"imx519\", &Create);\n> diff --git a/src/ipa/raspberrypi/data/imx519.json\n> b/src/ipa/raspberrypi/data/imx519.json\n> new file mode 100644\n> index 00000000..39e788ad\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/data/imx519.json\n> @@ -0,0 +1,272 @@\n> +{\n> +    \"rpi.black_level\":\n> +    {\n> +        \"black_level\": 4096\n> +    },\n> +    \"rpi.dpc\":\n> +    {\n> +    },\n> +    \"rpi.lux\":\n> +    {\n> +        \"reference_shutter_speed\": 10812,\n> +        \"reference_gain\": 2.0,\n> +        \"reference_aperture\": 1.0,\n> +        \"reference_lux\": 1250,\n> +        \"reference_Y\": 12737\n> +    },\n> +    \"rpi.noise\":\n> +    {\n> +        \"reference_constant\": 0,\n> +        \"reference_slope\": 2.91\n> +    },\n> +    \"rpi.geq\":\n> +    {\n> +        \"offset\": 444,\n> +        \"slope\": 0.00731\n> +    },\n> +    \"rpi.sdn\":\n> +    {\n> +        \"deviation\":3.7,\n> +        \"strength\":0.75\n> +    },\n> +    \"rpi.awb\":\n> +    {\n> +        \"priors\":\n> +        [\n> +            {\n> +                \"lux\": 0, \"prior\":\n> +                [\n> +                    2000, 1.0, 3000, 0.0, 13000, 0.0\n> +                ]\n> +            },\n> +            {\n> +                \"lux\": 800, \"prior\":\n> +                [\n> +                    2000, 0.0, 6000, 2.0, 13000, 2.0\n> +                ]\n> +            },\n> +            {\n> +                \"lux\": 1500, \"prior\":\n> +                [\n> +                    2000, 0.0, 4000, 1.0, 6000, 6.0, 6500, 7.0, 7000,\n> 1.0, 13000, 1.0\n> +                ]\n> +            }\n> +        ],\n> +        \"modes\":\n> +        {\n> +            \"auto\":\n> +            {\n> +                \"lo\": 2500,\n> +                \"hi\": 8000\n> +            },\n> +            \"incandescent\":\n> +            {\n> +                \"lo\": 2500,\n> +                \"hi\": 3000\n> +            },\n> +            \"tungsten\":\n> +            {\n> +                \"lo\": 3000,\n> +                \"hi\": 3500\n> +            },\n> +            \"fluorescent\":\n> +            {\n> +                \"lo\": 4000,\n> +                \"hi\": 4700\n> +            },\n> +            \"indoor\":\n> +            {\n> +                \"lo\": 3000,\n> +                \"hi\": 5000\n> +            },\n> +            \"daylight\":\n> +            {\n> +                \"lo\": 5500,\n> +                \"hi\": 6500\n> +            },\n> +            \"cloudy\":\n> +            {\n> +                \"lo\": 7000,\n> +                \"hi\": 8600\n> +            }\n> +        },\n> +        \"bayes\": 0\n>\n>\n> Just a small thing, but if we're going with the simple grey world\n> algorithm it might be worth deleting the other AWB parameters as they\n> don't do anything.\n>\n> And a few final questions:\n>\n> * Are you planning to upstream an open source driver for the imx519?\n> The preference within libcamera (someone will correct me if I'm\n> wrong!) is to support sensors where code and drivers are open.\n>\n> * If you're planning to open-source the driver we'd be pleased to\n> receive pull requests into our own Raspberry Pi kernel distribution.\n>\n> * I assume this is a fairly standard Bayer sensor? If you have a\n> working open source driver and can send me a module then I'd be very\n> happy to help you further with the json tuning file.\n>\n> Thanks and best regards\n> David\n>\n> +\n> +    },\n> +    \"rpi.agc\":\n> +    {\n> +        \"metering_modes\":\n> +        {\n> +            \"centre-weighted\":\n> +            {\n> +                \"weights\":\n> +                [\n> +                    3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0\n> +                ]\n> +            },\n> +            \"spot\":\n> +            {\n> +                \"weights\":\n> +                [\n> +                    2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n> +                ]\n> +            },\n> +            \"matrix\":\n> +            {\n> +                \"weights\":\n> +                [\n> +                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\n> +                ]\n> +            }\n> +        },\n> +        \"exposure_modes\":\n> +        {\n> +            \"normal\":\n> +            {\n> +                \"shutter\":\n> +                [\n> +                    100, 10000, 30000, 60000, 120000\n> +                ],\n> +                \"gain\":\n> +                [\n> +                    1.0, 2.0, 4.0, 6.0, 12.0\n> +                ]\n> +            },\n> +            \"short\":\n> +            {\n> +                \"shutter\":\n> +                [\n> +                    100, 5000, 10000, 20000, 120000\n> +                ],\n> +                \"gain\":\n> +                [\n> +                    1.0, 2.0, 4.0, 6.0, 12.0\n> +                ]\n> +            }\n> +        },\n> +        \"constraint_modes\":\n> +        {\n> +            \"normal\":\n> +            [\n> +                {\n> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0,\n> \"y_target\":\n> +                    [\n> +                        0, 0.5, 1000, 0.5\n> +                    ]\n> +                }\n> +            ],\n> +            \"highlight\":\n> +            [\n> +                {\n> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0,\n> \"y_target\":\n> +                    [\n> +                        0, 0.5, 1000, 0.5\n> +                    ]\n> +                },\n> +                {\n> +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0,\n> \"y_target\":\n> +                    [\n> +                        0, 0.8, 1000, 0.8\n> +                    ]\n> +                }\n> +            ]\n> +        },\n> +        \"y_target\":\n> +        [\n> +            0, 0.16, 1000, 0.165, 10000, 0.17\n> +        ]\n> +    },\n> +    \"rpi.alsc\":\n> +    {\n> +        \"omega\": 1.3,\n> +        \"n_iter\": 100,\n> +        \"luminance_strength\": 0.5,\n> +        \"calibrations_Cr\":\n> +        [\n> +            {\n> +                \"ct\": 6500, \"table\":\n> +                [\n> +                    2.544, 2.541, 2.531, 2.518, 2.506, 2.495, 2.489,\n> 2.489, 2.489, 2.491, 2.502, 2.511, 2.524, 2.534, 2.542, 2.547,\n> +                    2.541, 2.532, 2.521, 2.506, 2.493, 2.479, 2.469,\n> 2.462, 2.462, 2.473, 2.488, 2.502, 2.511, 2.527, 2.536, 2.542,\n> +                    2.531, 2.523, 2.506, 2.492, 2.474, 2.458, 2.444,\n> 2.435, 2.435, 2.446, 2.466, 2.481, 2.498, 2.511, 2.526, 2.536,\n> +                    2.523, 2.513, 2.492, 2.474, 2.458, 2.438, 2.418,\n> 2.408, 2.408, 2.421, 2.443, 2.463, 2.481, 2.498, 2.517, 2.526,\n> +                    2.513, 2.502, 2.481, 2.459, 2.438, 2.418, 2.397,\n> 2.379, 2.379, 2.399, 2.421, 2.443, 2.463, 2.486, 2.506, 2.517,\n> +                    2.506, 2.492, 2.469, 2.445, 2.423, 2.397, 2.377,\n> 2.368, 2.369, 2.379, 2.399, 2.427, 2.451, 2.474, 2.495, 2.511,\n> +                    2.506, 2.492, 2.469, 2.445, 2.423, 2.397, 2.372,\n> 2.364, 2.364, 2.374, 2.399, 2.427, 2.449, 2.474, 2.495, 2.511,\n> +                    2.506, 2.493, 2.474, 2.451, 2.426, 2.401, 2.382,\n> 2.368, 2.369, 2.382, 2.405, 2.431, 2.449, 2.476, 2.497, 2.509,\n> +                    2.504, 2.493, 2.475, 2.452, 2.431, 2.412, 2.401,\n> 2.382, 2.382, 2.403, 2.416, 2.438, 2.457, 2.477, 2.497, 2.505,\n> +                    2.499, 2.492, 2.474, 2.457, 2.441, 2.431, 2.412,\n> 2.404, 2.404, 2.416, 2.432, 2.447, 2.459, 2.478, 2.495, 2.501,\n> +                    2.499, 2.488, 2.473, 2.463, 2.453, 2.441, 2.431,\n> 2.425, 2.425, 2.432, 2.445, 2.459, 2.466, 2.478, 2.491, 2.495,\n> +                    2.499, 2.481, 2.472, 2.466, 2.458, 2.449, 2.441,\n> 2.439, 2.439, 2.444, 2.454, 2.464, 2.469, 2.477, 2.484, 2.491\n> +                ]\n> +            }\n> +        ],\n> +        \"calibrations_Cb\":\n> +        [\n> +            {\n> +                \"ct\": 6500, \"table\":\n> +                [\n> +                    1.352, 1.352, 1.349, 1.348, 1.347, 1.346, 1.347,\n> 1.349, 1.351, 1.351, 1.352, 1.353, 1.353, 1.355, 1.358, 1.359,\n> +                    1.359, 1.355, 1.352, 1.349, 1.348, 1.348, 1.348,\n> 1.351, 1.352, 1.352, 1.352, 1.354, 1.356, 1.358, 1.361, 1.366,\n> +                    1.364, 1.359, 1.355, 1.352, 1.349, 1.349, 1.351,\n> 1.353, 1.353, 1.353, 1.355, 1.356, 1.358, 1.362, 1.366, 1.371,\n> +                    1.371, 1.365, 1.359, 1.355, 1.352, 1.352, 1.353,\n> 1.357, 1.357, 1.356, 1.356, 1.359, 1.362, 1.366, 1.371, 1.377,\n> +                    1.375, 1.371, 1.365, 1.362, 1.359, 1.359, 1.359,\n> 1.364, 1.364, 1.364, 1.364, 1.365, 1.367, 1.371, 1.377, 1.382,\n> +                    1.379, 1.375, 1.371, 1.367, 1.367, 1.367, 1.369,\n> 1.373, 1.374, 1.374, 1.373, 1.373, 1.374, 1.377, 1.382, 1.386,\n> +                    1.383, 1.378, 1.374, 1.372, 1.372, 1.372, 1.373,\n> 1.375, 1.378, 1.379, 1.379, 1.379, 1.379, 1.381, 1.386, 1.389,\n> +                    1.384, 1.379, 1.376, 1.374, 1.373, 1.373, 1.374,\n> 1.379, 1.379, 1.379, 1.379, 1.379, 1.381, 1.382, 1.386, 1.394,\n> +                    1.386, 1.379, 1.376, 1.375, 1.374, 1.374, 1.374,\n> 1.378, 1.378, 1.378, 1.378, 1.379, 1.381, 1.383, 1.386, 1.394,\n> +                    1.385, 1.379, 1.376, 1.375, 1.374, 1.374, 1.375,\n> 1.378, 1.378, 1.378, 1.378, 1.379, 1.381, 1.383, 1.387, 1.393,\n> +                    1.379, 1.378, 1.375, 1.374, 1.373, 1.374, 1.375,\n> 1.377, 1.378, 1.378, 1.378, 1.379, 1.381, 1.382, 1.386, 1.388,\n> +                    1.379, 1.376, 1.374, 1.372, 1.372, 1.374, 1.375,\n> 1.377, 1.378, 1.378, 1.377, 1.378, 1.379, 1.382, 1.384, 1.387\n> +                ]\n> +            }\n> +        ],\n> +        \"luminance_lut\":\n> +        [\n> +            3.257, 3.091, 2.639, 2.301, 2.009, 1.795, 1.742, 1.742,\n> 1.742, 1.742, 1.798, 2.011, 2.309, 2.649, 3.109, 3.251,\n> +            3.091, 2.703, 2.311, 2.059, 1.791, 1.631, 1.529, 1.482,\n> 1.482, 1.533, 1.635, 1.791, 2.068, 2.313, 2.719, 3.109,\n> +            2.707, 2.424, 2.059, 1.791, 1.626, 1.429, 1.329, 1.282,\n> 1.282, 1.333, 1.433, 1.629, 1.791, 2.068, 2.438, 2.719,\n> +            2.555, 2.233, 1.889, 1.626, 1.429, 1.321, 1.176, 1.126,\n> 1.126, 1.181, 1.327, 1.433, 1.629, 1.894, 2.241, 2.538,\n> +            2.482, 2.108, 1.775, 1.518, 1.321, 1.176, 1.112, 1.011,\n> 1.012, 1.122, 1.181, 1.327, 1.523, 1.779, 2.113, 2.462,\n> +            2.478, 2.048, 1.719, 1.465, 1.266, 1.112, 1.009, 1.001,\n> 1.007, 1.012, 1.122, 1.274, 1.469, 1.722, 2.051, 2.454,\n> +            2.478, 2.048, 1.719, 1.465, 1.266, 1.112, 1.004, 1.001,\n> 1.001, 1.011, 1.122, 1.274, 1.469, 1.722, 2.051, 2.454,\n> +            2.478, 2.099, 1.768, 1.511, 1.312, 1.163, 1.108, 1.004,\n> 1.008, 1.112, 1.171, 1.321, 1.515, 1.767, 2.097, 2.454,\n> +            2.541, 2.217, 1.877, 1.614, 1.417, 1.312, 1.163, 1.112,\n> 1.112, 1.171, 1.317, 1.421, 1.616, 1.874, 2.214, 2.516,\n> +            2.686, 2.404, 2.046, 1.779, 1.614, 1.417, 1.317, 1.267,\n> 1.267, 1.319, 1.421, 1.614, 1.773, 2.039, 2.399, 2.669,\n> +            3.063, 2.678, 2.292, 2.046, 1.779, 1.622, 1.521, 1.469,\n> 1.469, 1.519, 1.622, 1.773, 2.038, 2.277, 2.669, 3.049,\n> +            3.224, 3.063, 2.616, 2.285, 1.995, 1.781, 1.725, 1.723,\n> 1.723, 1.723, 1.777, 1.984, 2.271, 2.598, 3.049, 3.187\n> +        ],\n> +        \"sigma\": 0.005,\n> +        \"sigma_Cb\": 0.005\n> +    },\n> +    \"rpi.contrast\":\n> +    {\n> +        \"ce_enable\": 1,\n> +        \"gamma_curve\":\n> +        [\n> +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120,\n> 18051, 6144, 20790, 7168, 23193,\n> +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288,\n> 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n> +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753,\n> 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n> +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954,\n> 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n> +            65535, 65535\n> +        ]\n> +    },\n> +    \"rpi.ccm\":\n> +    {\n> +        \"ccms\":\n> +        [\n> +            {\n> +                \"ct\": 5500, \"ccm\":\n> +                [\n> +                    1.40348, -0.45861, 0.05512, -0.24419, 1.25488,\n> -0.01068, -0.08564, -0.31571, 1.40135\n> +                ]\n> +            }\n> +        ]\n> +    },\n> +    \"rpi.sharpen\":\n> +    {\n> +               \"threshold\":1.5,\n> +               \"strength\":0.5,\n> +               \"limit\":0.2\n> +    }\n> +}\n> diff --git a/src/ipa/raspberrypi/data/meson.build\n> b/src/ipa/raspberrypi/data/meson.build\n> index 2def75cb..e84cd099 100644\n> --- a/src/ipa/raspberrypi/data/meson.build\n> +++ b/src/ipa/raspberrypi/data/meson.build\n> @@ -7,6 +7,7 @@ conf_files = files([\n>     'imx378.json',\n>     'imx477.json',\n>     'imx477_noir.json',\n> +    'imx519.json',\n>     'ov5647.json',\n>     'ov5647_noir.json',\n>     'ov9281.json',\n> diff --git a/src/ipa/raspberrypi/meson.build\n> b/src/ipa/raspberrypi/meson.build\n> index 1af31e4a..176055f4 100644\n> --- a/src/ipa/raspberrypi/meson.build\n> +++ b/src/ipa/raspberrypi/meson.build\n> @@ -22,6 +22,7 @@ rpi_ipa_sources = files([\n>     'cam_helper_imx219.cpp',\n>     'cam_helper_imx290.cpp',\n>     'cam_helper_imx477.cpp',\n> +    'cam_helper_imx519.cpp',\n>     'cam_helper_ov9281.cpp',\n>     'controller/controller.cpp',\n>     'controller/histogram.cpp',\n> --\n> 2.17.1\n>\n>\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 3EACDBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 11 Oct 2021 12:59:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 805A968F50;\n\tMon, 11 Oct 2021 14:59:42 +0200 (CEST)","from mail-wr1-x433.google.com (mail-wr1-x433.google.com\n\t[IPv6:2a00:1450:4864:20::433])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 268446012B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Oct 2021 14:59:41 +0200 (CEST)","by mail-wr1-x433.google.com with SMTP id k7so55830865wrd.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Oct 2021 05:59:41 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"LkMeZmbj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=PDXvN9DKsh8+KhhexaJL7TnrTFthge5I2YPOvlwp9sA=;\n\tb=LkMeZmbjFmPO+AgxcnbEsQfRqO/nuuty9O8RgcKBiL8QJ8QROJ6le7dzQ5zZO/INVQ\n\tbZrg1yoJHGIbtaX2czIYngqr2jst05WRTj0Ad3PtzxJdSn/QOzuC2mLn/c3H+iRAZzPc\n\tqKbQcsVQXdcLgtdYjJAa7xlqkPVhL55sHbR+pTQVkGazOsDs8pMYv3NQ5vJtc12l3lKM\n\t+FhZQwjzKXmDTZj/AaOiNOEhCOx1QmDgpUUTIUEXLwynAk6Gr/Bu68DRnjDAPQRclnhB\n\tDuVsdlbqSuKN5EqW8yEFAMf4IoEoQToVryxBsspnf+lBKdkYcmqQQpT2eY2vOo6cKJLg\n\tSBew==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=PDXvN9DKsh8+KhhexaJL7TnrTFthge5I2YPOvlwp9sA=;\n\tb=7WBcxHBqTzH5au5BAR7NZFj+c8409lA/68qysU0VBsJFCRACg4Eam9a+gVjueLLTCm\n\t0Rqx6Bexqos0qtiGDPIVZSuDKlui3y+o97ROeHUgoG98ZtAmzcGDQKAGF4oNauuk52AW\n\tVD95eR80xJUyf+rxbdfJAKSLj979TsorO59Q8DGCW4dqUlqoKdRdstbyaDgGMaJ0rSPi\n\tcs0x8flI+zLQ+a2sKAF1LDh5+JYjvNV4PTTJeQLXipAeDjtC9GsPoxdKB4MIX7xWy2wc\n\tMNWKvA5LsFPIa01D9XCEBKcUWIChcoxzSGp+0GvWc7JQTfC8+AM8j1JvL0+anm07CRmT\n\thFvg==","X-Gm-Message-State":"AOAM5322ZVh0G8zDOJ2eY7Otyira2avowqy7V6sMUqXI+rsgsgzoWBl1\n\tx1DevRJsgF1pS0uBik9T3ixWQ4c2QzoQ7x11KxKnr5I0LPp2Zw==","X-Google-Smtp-Source":"ABdhPJzk3E6+ecYUlU2PCjZFruH6mTEKqoSQVIShmdkdp2u03+G7dsZF4wXjH282axjPlwV1yvhyA7C9sojjKzApG7w=","X-Received":"by 2002:adf:fb0a:: with SMTP id\n\tc10mr25868735wrr.354.1633957180352; \n\tMon, 11 Oct 2021 05:59:40 -0700 (PDT)","MIME-Version":"1.0","References":"<638360E6-389E-4699-A524-584E7A555C61@arducam.com>\n\t<CAHW6GYLsy2_su9t=Fqh=KAJ=dW3YKp6AuqS_AOJtTp6jZDib-w@mail.gmail.com>\n\t<97927250-56E8-480C-97C0-A756A54CF7B4@arducam.com>","In-Reply-To":"<97927250-56E8-480C-97C0-A756A54CF7B4@arducam.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Mon, 11 Oct 2021 13:59:29 +0100","Message-ID":"<CAHW6GYL__WG9=LhgFi3j=Cz4NbZW=X+KKsUhw0cK5deG2Ua_1w@mail.gmail.com>","To":"Arducam info <info@arducam.com>","Content-Type":"multipart/related; boundary=\"00000000000050bb1405ce134d9f\"","Subject":"Re: [libcamera-devel] [PATCH] libcamera: ipa: raspberrypi: Add\n\tsupport for imx519 sensor","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":20128,"web_url":"https://patchwork.libcamera.org/comment/20128/","msgid":"<CAHW6GY+SzO4QJExOuOY-CeeZe31g33nXo2XEhRLUOK+ZMotrbw@mail.gmail.com>","date":"2021-10-12T08:44:08","subject":"Re: [libcamera-devel] [PATCH] libcamera: ipa: raspberrypi: Add\n\tsupport for imx519 sensor","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Lee\n\nOn Mon, 11 Oct 2021 at 13:12, Arducam info <info@arducam.com> wrote:\n>\n> Hi David and Naush\n> As you know Arducam keeps working for camera solutions for Raspberry pi for a long time.\n> This new IMX519 camera is the latest open source camera driver and ISP tuned libcamera json config.\n> We have already committed the IMX519 driver source code to RaspberryPi/linux repo with Dave Stevenson weeks ago: https://github.com/raspberrypi/linux/pull/4548/commits\n>\n> And this IMX519 also supports the long exposure as the IMX477, check the statement below from the datasheet.\n>\n> Please let me know your shipping address and contact phone number, I will send you the first few samples tomorrow with DHL shipping.\n> Regards\n> Lee\n>\n>\n>\n> On 11 Oct 2021, at 4:16 PM, David Plowman <david.plowman@raspberrypi.com> wrote:\n>\n> Hi Lee\n>\n> Thank you very much for your contribution, we're very pleased to see\n> others making use of the Pi's camera system in this way!\n>\n> On Mon, 11 Oct 2021 at 05:06, Arducam info <info@arducam.com> wrote:\n>\n>\n> The necessary tuning file and CamHelper is added for the imx519 sensor.\n>\n> The imx519 is a 16MP rolling shutter sensor. To enable\n> it, please add\n>\n> dtoverlay=imx519\n>\n> to the /boot/config.txt file and reboot the Pi.\n>\n> Signed-off-by: Lee Jackson <info@arducam.com>\n> ---\n> src/ipa/raspberrypi/cam_helper_imx519.cpp | 185 +++++++++++++++\n> src/ipa/raspberrypi/data/imx519.json      | 272 ++++++++++++++++++++++\n> src/ipa/raspberrypi/data/meson.build      |   1 +\n> src/ipa/raspberrypi/meson.build           |   1 +\n> 4 files changed, 459 insertions(+)\n> create mode 100644 src/ipa/raspberrypi/cam_helper_imx519.cpp\n> create mode 100644 src/ipa/raspberrypi/data/imx519.json\n>\n> diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n> new file mode 100644\n> index 00000000..eaf24982\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n> @@ -0,0 +1,185 @@\n> +/* SPDX-License-Identifier: BSD-2-Clause */\n> +/*\n> + * Based on cam_helper_imx477.cpp\n> + * Copyright (C) 2020, Raspberry Pi (Trading) Limited\n> + *\n> + * cam_helper_imx519.cpp - camera helper for imx519 sensor\n> + * Copyright (C) 2021, Arducam Technology co., Ltd.\n> + */\n> +\n> +#include <assert.h>\n> +#include <cmath>\n> +#include <stddef.h>\n> +#include <stdio.h>\n> +#include <stdlib.h>\n> +\n> +#include <libcamera/base/log.h>\n> +\n> +#include \"cam_helper.hpp\"\n> +#include \"md_parser.hpp\"\n> +\n> +using namespace RPiController;\n> +using namespace libcamera;\n> +using libcamera::utils::Duration;\n> +\n> +namespace libcamera {\n> +LOG_DECLARE_CATEGORY(IPARPI)\n> +}\n> +\n> +/*\n> + * We care about two gain registers and a pair of exposure registers. Their\n> + * I2C addresses from the Sony IMX519 datasheet:\n> + */\n> +constexpr uint32_t expHiReg = 0x0202;\n> +constexpr uint32_t expLoReg = 0x0203;\n> +constexpr uint32_t gainHiReg = 0x0204;\n> +constexpr uint32_t gainLoReg = 0x0205;\n> +constexpr uint32_t frameLengthHiReg = 0x0340;\n> +constexpr uint32_t frameLengthLoReg = 0x0341;\n> +constexpr std::initializer_list<uint32_t> registerList =\n> +       { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg  };\n> +\n> +class CamHelperImx519 : public CamHelper\n> +{\n> +public:\n> +       CamHelperImx519();\n> +       uint32_t GainCode(double gain) const override;\n> +       double Gain(uint32_t gain_code) const override;\n> +       void Prepare(libcamera::Span<const uint8_t> buffer, Metadata &metadata) override;\n> +       uint32_t GetVBlanking(Duration &exposure, Duration minFrameDuration,\n> +                             Duration maxFrameDuration) const override;\n> +       void GetDelays(int &exposure_delay, int &gain_delay,\n> +                      int &vblank_delay) const override;\n> +       bool SensorEmbeddedDataPresent() const override;\n> +\n> +private:\n> +       /*\n> +        * Smallest difference between the frame length and integration time,\n> +        * in units of lines.\n> +        */\n> +       static constexpr int frameIntegrationDiff = 32;\n> +       /* Maximum frame length allowable for long exposure calculations. */\n> +       static constexpr int frameLengthMax = 0xffdc;\n> +       /* Largest long exposure scale factor given as a left shift on the frame length. */\n> +       static constexpr int longExposureShiftMax = 7;\n> +\n> +       void PopulateMetadata(const MdParser::RegisterMap &registers,\n> +                             Metadata &metadata) const override;\n> +};\n> +\n> +CamHelperImx519::CamHelperImx519()\n> +       : CamHelper(std::make_unique<MdParserSmia>(registerList), frameIntegrationDiff)\n> +{\n> +}\n> +\n> +uint32_t CamHelperImx519::GainCode(double gain) const\n> +{\n> +       return static_cast<uint32_t>(1024 - 1024 / gain);\n> +}\n> +\n> +double CamHelperImx519::Gain(uint32_t gain_code) const\n> +{\n> +       return 1024.0 / (1024 - gain_code);\n> +}\n> +\n> +void CamHelperImx519::Prepare(libcamera::Span<const uint8_t> buffer, Metadata &metadata)\n> +{\n> +       MdParser::RegisterMap registers;\n> +       DeviceStatus deviceStatus;\n> +\n> +       if (metadata.Get(\"device.status\", deviceStatus)) {\n> +               LOG(IPARPI, Error) << \"DeviceStatus not found from DelayedControls\";\n> +               return;\n> +       }\n> +\n> +       parseEmbeddedData(buffer, metadata);\n> +\n> +       /*\n> +        * The DeviceStatus struct is first populated with values obtained from\n> +        * DelayedControls. If this reports frame length is > frameLengthMax,\n> +        * it means we are using a long exposure mode. Since the long exposure\n> +        * scale factor is not returned back through embedded data, we must rely\n> +        * on the existing exposure lines and frame length values returned by\n> +        * DelayedControls.\n> +        *\n> +        * Otherwise, all values are updated with what is reported in the\n> +        * embedded data.\n> +        */\n> +       if (deviceStatus.frame_length > frameLengthMax) {\n> +               DeviceStatus parsedDeviceStatus;\n> +\n> +               metadata.Get(\"device.status\", parsedDeviceStatus);\n> +               parsedDeviceStatus.shutter_speed = deviceStatus.shutter_speed;\n> +               parsedDeviceStatus.frame_length = deviceStatus.frame_length;\n> +               metadata.Set(\"device.status\", parsedDeviceStatus);\n> +\n> +               LOG(IPARPI, Debug) << \"Metadata updated for long exposure: \"\n> +                                  << parsedDeviceStatus;\n> +       }\n> +}\n> +\n> +uint32_t CamHelperImx519::GetVBlanking(Duration &exposure,\n> +                                      Duration minFrameDuration,\n> +                                      Duration maxFrameDuration) const\n> +{\n> +       uint32_t frameLength, exposureLines;\n> +       unsigned int shift = 0;\n> +\n> +       frameLength = mode_.height + CamHelper::GetVBlanking(exposure, minFrameDuration,\n> +                                                            maxFrameDuration);\n> +       /*\n> +        * Check if the frame length calculated needs to be setup for long\n> +        * exposure mode. This will require us to use a long exposure scale\n> +        * factor provided by a shift operation in the sensor.\n> +        */\n> +       while (frameLength > frameLengthMax) {\n> +               if (++shift > longExposureShiftMax) {\n> +                       shift = longExposureShiftMax;\n> +                       frameLength = frameLengthMax;\n> +                       break;\n> +               }\n> +               frameLength >>= 1;\n> +       }\n> +\n> +       if (shift) {\n> +               /* Account for any rounding in the scaled frame length value. */\n> +               frameLength <<= shift;\n> +               exposureLines = ExposureLines(exposure);\n> +               exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff);\n> +               exposure = Exposure(exposureLines);\n> +       }\n> +\n> +       return frameLength - mode_.height;\n> +}\n> +\n> +void CamHelperImx519::GetDelays(int &exposure_delay, int &gain_delay,\n> +                               int &vblank_delay) const\n> +{\n> +       exposure_delay = 2;\n> +       gain_delay = 2;\n> +       vblank_delay = 3;\n> +}\n> +\n> +bool CamHelperImx519::SensorEmbeddedDataPresent() const\n> +{\n> +       return true;\n> +}\n> +\n> +void CamHelperImx519::PopulateMetadata(const MdParser::RegisterMap &registers,\n> +                                      Metadata &metadata) const\n> +{\n> +       DeviceStatus deviceStatus;\n> +\n> +       deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg));\n> +       deviceStatus.analogue_gain = Gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg));\n> +       deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg);\n> +\n> +       metadata.Set(\"device.status\", deviceStatus);\n> +}\n> +\n> +static CamHelper *Create()\n> +{\n> +       return new CamHelperImx519();\n> +}\n> +\n> +static RegisterCamHelper reg(\"imx519\", &Create);\n> diff --git a/src/ipa/raspberrypi/data/imx519.json b/src/ipa/raspberrypi/data/imx519.json\n> new file mode 100644\n> index 00000000..39e788ad\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/data/imx519.json\n> @@ -0,0 +1,272 @@\n> +{\n> +    \"rpi.black_level\":\n> +    {\n> +        \"black_level\": 4096\n> +    },\n> +    \"rpi.dpc\":\n> +    {\n> +    },\n> +    \"rpi.lux\":\n> +    {\n> +        \"reference_shutter_speed\": 10812,\n> +        \"reference_gain\": 2.0,\n> +        \"reference_aperture\": 1.0,\n> +        \"reference_lux\": 1250,\n> +        \"reference_Y\": 12737\n> +    },\n> +    \"rpi.noise\":\n> +    {\n> +        \"reference_constant\": 0,\n> +        \"reference_slope\": 2.91\n> +    },\n> +    \"rpi.geq\":\n> +    {\n> +        \"offset\": 444,\n> +        \"slope\": 0.00731\n> +    },\n> +    \"rpi.sdn\":\n> +    {\n> +        \"deviation\":3.7,\n> +        \"strength\":0.75\n> +    },\n> +    \"rpi.awb\":\n> +    {\n> +        \"priors\":\n> +        [\n> +            {\n> +                \"lux\": 0, \"prior\":\n> +                [\n> +                    2000, 1.0, 3000, 0.0, 13000, 0.0\n> +                ]\n> +            },\n> +            {\n> +                \"lux\": 800, \"prior\":\n> +                [\n> +                    2000, 0.0, 6000, 2.0, 13000, 2.0\n> +                ]\n> +            },\n> +            {\n> +                \"lux\": 1500, \"prior\":\n> +                [\n> +                    2000, 0.0, 4000, 1.0, 6000, 6.0, 6500, 7.0, 7000, 1.0, 13000, 1.0\n> +                ]\n> +            }\n> +        ],\n> +        \"modes\":\n> +        {\n> +            \"auto\":\n> +            {\n> +                \"lo\": 2500,\n> +                \"hi\": 8000\n> +            },\n> +            \"incandescent\":\n> +            {\n> +                \"lo\": 2500,\n> +                \"hi\": 3000\n> +            },\n> +            \"tungsten\":\n> +            {\n> +                \"lo\": 3000,\n> +                \"hi\": 3500\n> +            },\n> +            \"fluorescent\":\n> +            {\n> +                \"lo\": 4000,\n> +                \"hi\": 4700\n> +            },\n> +            \"indoor\":\n> +            {\n> +                \"lo\": 3000,\n> +                \"hi\": 5000\n> +            },\n> +            \"daylight\":\n> +            {\n> +                \"lo\": 5500,\n> +                \"hi\": 6500\n> +            },\n> +            \"cloudy\":\n> +            {\n> +                \"lo\": 7000,\n> +                \"hi\": 8600\n> +            }\n> +        },\n> +        \"bayes\": 0\n>\n>\n> Just a small thing, but if we're going with the simple grey world\n> algorithm it might be worth deleting the other AWB parameters as they\n> don't do anything.\n>\n> And a few final questions:\n>\n> * Are you planning to upstream an open source driver for the imx519?\n> The preference within libcamera (someone will correct me if I'm\n> wrong!) is to support sensors where code and drivers are open.\n>\n> * If you're planning to open-source the driver we'd be pleased to\n> receive pull requests into our own Raspberry Pi kernel distribution.\n>\n> * I assume this is a fairly standard Bayer sensor? If you have a\n> working open source driver and can send me a module then I'd be very\n> happy to help you further with the json tuning file.\n>\n> Thanks and best regards\n> David\n\nBased on the discussions we've had this seems fine to me.\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nOnce I have some modules I'll try and do a more complete colour tuning\nand then I'll submit that.\n\nThanks!\nDavid\n\n>\n> +\n> +    },\n> +    \"rpi.agc\":\n> +    {\n> +        \"metering_modes\":\n> +        {\n> +            \"centre-weighted\":\n> +            {\n> +                \"weights\":\n> +                [\n> +                    3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0\n> +                ]\n> +            },\n> +            \"spot\":\n> +            {\n> +                \"weights\":\n> +                [\n> +                    2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n> +                ]\n> +            },\n> +            \"matrix\":\n> +            {\n> +                \"weights\":\n> +                [\n> +                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\n> +                ]\n> +            }\n> +        },\n> +        \"exposure_modes\":\n> +        {\n> +            \"normal\":\n> +            {\n> +                \"shutter\":\n> +                [\n> +                    100, 10000, 30000, 60000, 120000\n> +                ],\n> +                \"gain\":\n> +                [\n> +                    1.0, 2.0, 4.0, 6.0, 12.0\n> +                ]\n> +            },\n> +            \"short\":\n> +            {\n> +                \"shutter\":\n> +                [\n> +                    100, 5000, 10000, 20000, 120000\n> +                ],\n> +                \"gain\":\n> +                [\n> +                    1.0, 2.0, 4.0, 6.0, 12.0\n> +                ]\n> +            }\n> +        },\n> +        \"constraint_modes\":\n> +        {\n> +            \"normal\":\n> +            [\n> +                {\n> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> +                    [\n> +                        0, 0.5, 1000, 0.5\n> +                    ]\n> +                }\n> +            ],\n> +            \"highlight\":\n> +            [\n> +                {\n> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> +                    [\n> +                        0, 0.5, 1000, 0.5\n> +                    ]\n> +                },\n> +                {\n> +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> +                    [\n> +                        0, 0.8, 1000, 0.8\n> +                    ]\n> +                }\n> +            ]\n> +        },\n> +        \"y_target\":\n> +        [\n> +            0, 0.16, 1000, 0.165, 10000, 0.17\n> +        ]\n> +    },\n> +    \"rpi.alsc\":\n> +    {\n> +        \"omega\": 1.3,\n> +        \"n_iter\": 100,\n> +        \"luminance_strength\": 0.5,\n> +        \"calibrations_Cr\":\n> +        [\n> +            {\n> +                \"ct\": 6500, \"table\":\n> +                [\n> +                    2.544, 2.541, 2.531, 2.518, 2.506, 2.495, 2.489, 2.489, 2.489, 2.491, 2.502, 2.511, 2.524, 2.534, 2.542, 2.547,\n> +                    2.541, 2.532, 2.521, 2.506, 2.493, 2.479, 2.469, 2.462, 2.462, 2.473, 2.488, 2.502, 2.511, 2.527, 2.536, 2.542,\n> +                    2.531, 2.523, 2.506, 2.492, 2.474, 2.458, 2.444, 2.435, 2.435, 2.446, 2.466, 2.481, 2.498, 2.511, 2.526, 2.536,\n> +                    2.523, 2.513, 2.492, 2.474, 2.458, 2.438, 2.418, 2.408, 2.408, 2.421, 2.443, 2.463, 2.481, 2.498, 2.517, 2.526,\n> +                    2.513, 2.502, 2.481, 2.459, 2.438, 2.418, 2.397, 2.379, 2.379, 2.399, 2.421, 2.443, 2.463, 2.486, 2.506, 2.517,\n> +                    2.506, 2.492, 2.469, 2.445, 2.423, 2.397, 2.377, 2.368, 2.369, 2.379, 2.399, 2.427, 2.451, 2.474, 2.495, 2.511,\n> +                    2.506, 2.492, 2.469, 2.445, 2.423, 2.397, 2.372, 2.364, 2.364, 2.374, 2.399, 2.427, 2.449, 2.474, 2.495, 2.511,\n> +                    2.506, 2.493, 2.474, 2.451, 2.426, 2.401, 2.382, 2.368, 2.369, 2.382, 2.405, 2.431, 2.449, 2.476, 2.497, 2.509,\n> +                    2.504, 2.493, 2.475, 2.452, 2.431, 2.412, 2.401, 2.382, 2.382, 2.403, 2.416, 2.438, 2.457, 2.477, 2.497, 2.505,\n> +                    2.499, 2.492, 2.474, 2.457, 2.441, 2.431, 2.412, 2.404, 2.404, 2.416, 2.432, 2.447, 2.459, 2.478, 2.495, 2.501,\n> +                    2.499, 2.488, 2.473, 2.463, 2.453, 2.441, 2.431, 2.425, 2.425, 2.432, 2.445, 2.459, 2.466, 2.478, 2.491, 2.495,\n> +                    2.499, 2.481, 2.472, 2.466, 2.458, 2.449, 2.441, 2.439, 2.439, 2.444, 2.454, 2.464, 2.469, 2.477, 2.484, 2.491\n> +                ]\n> +            }\n> +        ],\n> +        \"calibrations_Cb\":\n> +        [\n> +            {\n> +                \"ct\": 6500, \"table\":\n> +                [\n> +                    1.352, 1.352, 1.349, 1.348, 1.347, 1.346, 1.347, 1.349, 1.351, 1.351, 1.352, 1.353, 1.353, 1.355, 1.358, 1.359,\n> +                    1.359, 1.355, 1.352, 1.349, 1.348, 1.348, 1.348, 1.351, 1.352, 1.352, 1.352, 1.354, 1.356, 1.358, 1.361, 1.366,\n> +                    1.364, 1.359, 1.355, 1.352, 1.349, 1.349, 1.351, 1.353, 1.353, 1.353, 1.355, 1.356, 1.358, 1.362, 1.366, 1.371,\n> +                    1.371, 1.365, 1.359, 1.355, 1.352, 1.352, 1.353, 1.357, 1.357, 1.356, 1.356, 1.359, 1.362, 1.366, 1.371, 1.377,\n> +                    1.375, 1.371, 1.365, 1.362, 1.359, 1.359, 1.359, 1.364, 1.364, 1.364, 1.364, 1.365, 1.367, 1.371, 1.377, 1.382,\n> +                    1.379, 1.375, 1.371, 1.367, 1.367, 1.367, 1.369, 1.373, 1.374, 1.374, 1.373, 1.373, 1.374, 1.377, 1.382, 1.386,\n> +                    1.383, 1.378, 1.374, 1.372, 1.372, 1.372, 1.373, 1.375, 1.378, 1.379, 1.379, 1.379, 1.379, 1.381, 1.386, 1.389,\n> +                    1.384, 1.379, 1.376, 1.374, 1.373, 1.373, 1.374, 1.379, 1.379, 1.379, 1.379, 1.379, 1.381, 1.382, 1.386, 1.394,\n> +                    1.386, 1.379, 1.376, 1.375, 1.374, 1.374, 1.374, 1.378, 1.378, 1.378, 1.378, 1.379, 1.381, 1.383, 1.386, 1.394,\n> +                    1.385, 1.379, 1.376, 1.375, 1.374, 1.374, 1.375, 1.378, 1.378, 1.378, 1.378, 1.379, 1.381, 1.383, 1.387, 1.393,\n> +                    1.379, 1.378, 1.375, 1.374, 1.373, 1.374, 1.375, 1.377, 1.378, 1.378, 1.378, 1.379, 1.381, 1.382, 1.386, 1.388,\n> +                    1.379, 1.376, 1.374, 1.372, 1.372, 1.374, 1.375, 1.377, 1.378, 1.378, 1.377, 1.378, 1.379, 1.382, 1.384, 1.387\n> +                ]\n> +            }\n> +        ],\n> +        \"luminance_lut\":\n> +        [\n> +            3.257, 3.091, 2.639, 2.301, 2.009, 1.795, 1.742, 1.742, 1.742, 1.742, 1.798, 2.011, 2.309, 2.649, 3.109, 3.251,\n> +            3.091, 2.703, 2.311, 2.059, 1.791, 1.631, 1.529, 1.482, 1.482, 1.533, 1.635, 1.791, 2.068, 2.313, 2.719, 3.109,\n> +            2.707, 2.424, 2.059, 1.791, 1.626, 1.429, 1.329, 1.282, 1.282, 1.333, 1.433, 1.629, 1.791, 2.068, 2.438, 2.719,\n> +            2.555, 2.233, 1.889, 1.626, 1.429, 1.321, 1.176, 1.126, 1.126, 1.181, 1.327, 1.433, 1.629, 1.894, 2.241, 2.538,\n> +            2.482, 2.108, 1.775, 1.518, 1.321, 1.176, 1.112, 1.011, 1.012, 1.122, 1.181, 1.327, 1.523, 1.779, 2.113, 2.462,\n> +            2.478, 2.048, 1.719, 1.465, 1.266, 1.112, 1.009, 1.001, 1.007, 1.012, 1.122, 1.274, 1.469, 1.722, 2.051, 2.454,\n> +            2.478, 2.048, 1.719, 1.465, 1.266, 1.112, 1.004, 1.001, 1.001, 1.011, 1.122, 1.274, 1.469, 1.722, 2.051, 2.454,\n> +            2.478, 2.099, 1.768, 1.511, 1.312, 1.163, 1.108, 1.004, 1.008, 1.112, 1.171, 1.321, 1.515, 1.767, 2.097, 2.454,\n> +            2.541, 2.217, 1.877, 1.614, 1.417, 1.312, 1.163, 1.112, 1.112, 1.171, 1.317, 1.421, 1.616, 1.874, 2.214, 2.516,\n> +            2.686, 2.404, 2.046, 1.779, 1.614, 1.417, 1.317, 1.267, 1.267, 1.319, 1.421, 1.614, 1.773, 2.039, 2.399, 2.669,\n> +            3.063, 2.678, 2.292, 2.046, 1.779, 1.622, 1.521, 1.469, 1.469, 1.519, 1.622, 1.773, 2.038, 2.277, 2.669, 3.049,\n> +            3.224, 3.063, 2.616, 2.285, 1.995, 1.781, 1.725, 1.723, 1.723, 1.723, 1.777, 1.984, 2.271, 2.598, 3.049, 3.187\n> +        ],\n> +        \"sigma\": 0.005,\n> +        \"sigma_Cb\": 0.005\n> +    },\n> +    \"rpi.contrast\":\n> +    {\n> +        \"ce_enable\": 1,\n> +        \"gamma_curve\":\n> +        [\n> +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120, 18051, 6144, 20790, 7168, 23193,\n> +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288, 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n> +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753, 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n> +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954, 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n> +            65535, 65535\n> +        ]\n> +    },\n> +    \"rpi.ccm\":\n> +    {\n> +        \"ccms\":\n> +        [\n> +            {\n> +                \"ct\": 5500, \"ccm\":\n> +                [\n> +                    1.40348, -0.45861, 0.05512, -0.24419, 1.25488, -0.01068, -0.08564, -0.31571, 1.40135\n> +                ]\n> +            }\n> +        ]\n> +    },\n> +    \"rpi.sharpen\":\n> +    {\n> +               \"threshold\":1.5,\n> +               \"strength\":0.5,\n> +               \"limit\":0.2\n> +    }\n> +}\n> diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> index 2def75cb..e84cd099 100644\n> --- a/src/ipa/raspberrypi/data/meson.build\n> +++ b/src/ipa/raspberrypi/data/meson.build\n> @@ -7,6 +7,7 @@ conf_files = files([\n>     'imx378.json',\n>     'imx477.json',\n>     'imx477_noir.json',\n> +    'imx519.json',\n>     'ov5647.json',\n>     'ov5647_noir.json',\n>     'ov9281.json',\n> diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> index 1af31e4a..176055f4 100644\n> --- a/src/ipa/raspberrypi/meson.build\n> +++ b/src/ipa/raspberrypi/meson.build\n> @@ -22,6 +22,7 @@ rpi_ipa_sources = files([\n>     'cam_helper_imx219.cpp',\n>     'cam_helper_imx290.cpp',\n>     'cam_helper_imx477.cpp',\n> +    'cam_helper_imx519.cpp',\n>     'cam_helper_ov9281.cpp',\n>     'controller/controller.cpp',\n>     'controller/histogram.cpp',\n> --\n> 2.17.1\n>\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id A3A39C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 12 Oct 2021 08:44:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0388968F4D;\n\tTue, 12 Oct 2021 10:44:21 +0200 (CEST)","from mail-wr1-x430.google.com (mail-wr1-x430.google.com\n\t[IPv6:2a00:1450:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 72A2D6381D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Oct 2021 10:44:19 +0200 (CEST)","by mail-wr1-x430.google.com with SMTP id v17so64447760wrv.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Oct 2021 01:44:19 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"YqXIJ7Vm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=dNtKTdpsPUoE1SRmvObaHlZw50YZTjGLAOgmOzFweWc=;\n\tb=YqXIJ7VmmPI6Ry4/jb3joNkeZ0yqLGzowj3Falx5TrI93HTnHjK48+c7Krb1xphEcd\n\tLQ3ARD3ibEQcQcUqjPWWnsyM5lcUluLxqn8MwdZi1LaqYozhnlWWs8V1fXnNxpupFAlx\n\tbEPAXQzvNN0Q91LyRW9hXcvJDtDeIyis5lwkyYdv4Pjgwp+Fhc/RfIA9tfiRt82T7bNv\n\tJ4y+iH2HSIcYv6ByLVFdgVbiIt5NACX5gLF4yWgDEKejqx3ge+PVfoLg9t9TsAoHgXDu\n\tD+E0tmHcEej54yPCsyhRFEpnFXewKzTile2Sb5cFpyEnhhrgVGyZenTzln6AnrI+t37c\n\thHMg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=dNtKTdpsPUoE1SRmvObaHlZw50YZTjGLAOgmOzFweWc=;\n\tb=jeC4hMjJSo+pzdKFoigmTvXJRv7TKS2AfEsD/PKu95jzecJjy6cwnESexG1NOhWOvb\n\tD9G0ccgWlaeWE7VF8UPQDLWtHkLfNl9UTgadwvdgg9IYxSc39uo02j9u3GTBuAkt1dDT\n\tzhtuvIu3ezR3OgCo/8dC3K+hiK7jVCthUUDQRq2cJBo+abXK9W2q0r8GZ/cfVA5vHXCt\n\tflwV12s53oUNfCICwAwnJowbr3FL564y+EsntcvQJIGyvOppO4bVvleHDH0e7JhWr9IH\n\tCmulh0RXHt5Aiy/xfHiBIDwTrphgpjHepFtwwIitw5eHXgeY/3ihkLmvbgoCHxG1u+BL\n\tJbcg==","X-Gm-Message-State":"AOAM5305mhx5PZ2147ilpIZ3hlssBRfpq2FOzTXIA3TjcAOxbtA/IyWl\n\thvBA7szGf0PMmoz2lHGrT1qUN2+m/i4W6HzBXdkXPA==","X-Google-Smtp-Source":"ABdhPJyMhkzKAftCcitgED6yVIZtb7SMtcsEVoKMbUJIyeuuC32WWKjJAWuWQhVG+MMcUBYl0s+cLrh2n2nS9iaQT+8=","X-Received":"by 2002:a05:600c:154a:: with SMTP id\n\tf10mr4029907wmg.184.1634028258673; \n\tTue, 12 Oct 2021 01:44:18 -0700 (PDT)","MIME-Version":"1.0","References":"<638360E6-389E-4699-A524-584E7A555C61@arducam.com>\n\t<CAHW6GYLsy2_su9t=Fqh=KAJ=dW3YKp6AuqS_AOJtTp6jZDib-w@mail.gmail.com>\n\t<97927250-56E8-480C-97C0-A756A54CF7B4@arducam.com>","In-Reply-To":"<97927250-56E8-480C-97C0-A756A54CF7B4@arducam.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Tue, 12 Oct 2021 09:44:08 +0100","Message-ID":"<CAHW6GY+SzO4QJExOuOY-CeeZe31g33nXo2XEhRLUOK+ZMotrbw@mail.gmail.com>","To":"Arducam info <info@arducam.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH] libcamera: ipa: raspberrypi: Add\n\tsupport for imx519 sensor","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":20129,"web_url":"https://patchwork.libcamera.org/comment/20129/","msgid":"<94681989-4DAB-4325-BB59-048BF3322455@arducam.com>","date":"2021-10-12T09:30:05","subject":"Re: [libcamera-devel] [PATCH] libcamera: ipa: raspberrypi: Add\n\tsupport for imx519 sensor","submitter":{"id":99,"url":"https://patchwork.libcamera.org/api/people/99/","name":"Arducam info","email":"info@arducam.com"},"content":"Hi David\nThanks.\nWe have shipped the samples this afternoon, the shipping waybill is DHL：9758185076\nHope you can get them soon.\nRegards\nLee\n\n\n> On 12 Oct 2021, at 4:44 PM, David Plowman <david.plowman@raspberrypi.com> wrote:\n> \n> Hi Lee\n> \n> On Mon, 11 Oct 2021 at 13:12, Arducam info <info@arducam.com <mailto:info@arducam.com>> wrote:\n>> \n>> Hi David and Naush\n>> As you know Arducam keeps working for camera solutions for Raspberry pi for a long time.\n>> This new IMX519 camera is the latest open source camera driver and ISP tuned libcamera json config.\n>> We have already committed the IMX519 driver source code to RaspberryPi/linux repo with Dave Stevenson weeks ago: https://github.com/raspberrypi/linux/pull/4548/commits\n>> \n>> And this IMX519 also supports the long exposure as the IMX477, check the statement below from the datasheet.\n>> \n>> Please let me know your shipping address and contact phone number, I will send you the first few samples tomorrow with DHL shipping.\n>> Regards\n>> Lee\n>> \n>> \n>> \n>> On 11 Oct 2021, at 4:16 PM, David Plowman <david.plowman@raspberrypi.com> wrote:\n>> \n>> Hi Lee\n>> \n>> Thank you very much for your contribution, we're very pleased to see\n>> others making use of the Pi's camera system in this way!\n>> \n>> On Mon, 11 Oct 2021 at 05:06, Arducam info <info@arducam.com> wrote:\n>> \n>> \n>> The necessary tuning file and CamHelper is added for the imx519 sensor.\n>> \n>> The imx519 is a 16MP rolling shutter sensor. To enable\n>> it, please add\n>> \n>> dtoverlay=imx519\n>> \n>> to the /boot/config.txt file and reboot the Pi.\n>> \n>> Signed-off-by: Lee Jackson <info@arducam.com>\n>> ---\n>> src/ipa/raspberrypi/cam_helper_imx519.cpp | 185 +++++++++++++++\n>> src/ipa/raspberrypi/data/imx519.json      | 272 ++++++++++++++++++++++\n>> src/ipa/raspberrypi/data/meson.build      |   1 +\n>> src/ipa/raspberrypi/meson.build           |   1 +\n>> 4 files changed, 459 insertions(+)\n>> create mode 100644 src/ipa/raspberrypi/cam_helper_imx519.cpp\n>> create mode 100644 src/ipa/raspberrypi/data/imx519.json\n>> \n>> diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n>> new file mode 100644\n>> index 00000000..eaf24982\n>> --- /dev/null\n>> +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp\n>> @@ -0,0 +1,185 @@\n>> +/* SPDX-License-Identifier: BSD-2-Clause */\n>> +/*\n>> + * Based on cam_helper_imx477.cpp\n>> + * Copyright (C) 2020, Raspberry Pi (Trading) Limited\n>> + *\n>> + * cam_helper_imx519.cpp - camera helper for imx519 sensor\n>> + * Copyright (C) 2021, Arducam Technology co., Ltd.\n>> + */\n>> +\n>> +#include <assert.h>\n>> +#include <cmath>\n>> +#include <stddef.h>\n>> +#include <stdio.h>\n>> +#include <stdlib.h>\n>> +\n>> +#include <libcamera/base/log.h>\n>> +\n>> +#include \"cam_helper.hpp\"\n>> +#include \"md_parser.hpp\"\n>> +\n>> +using namespace RPiController;\n>> +using namespace libcamera;\n>> +using libcamera::utils::Duration;\n>> +\n>> +namespace libcamera {\n>> +LOG_DECLARE_CATEGORY(IPARPI)\n>> +}\n>> +\n>> +/*\n>> + * We care about two gain registers and a pair of exposure registers. Their\n>> + * I2C addresses from the Sony IMX519 datasheet:\n>> + */\n>> +constexpr uint32_t expHiReg = 0x0202;\n>> +constexpr uint32_t expLoReg = 0x0203;\n>> +constexpr uint32_t gainHiReg = 0x0204;\n>> +constexpr uint32_t gainLoReg = 0x0205;\n>> +constexpr uint32_t frameLengthHiReg = 0x0340;\n>> +constexpr uint32_t frameLengthLoReg = 0x0341;\n>> +constexpr std::initializer_list<uint32_t> registerList =\n>> +       { expHiReg, expLoReg, gainHiReg, gainLoReg, frameLengthHiReg, frameLengthLoReg  };\n>> +\n>> +class CamHelperImx519 : public CamHelper\n>> +{\n>> +public:\n>> +       CamHelperImx519();\n>> +       uint32_t GainCode(double gain) const override;\n>> +       double Gain(uint32_t gain_code) const override;\n>> +       void Prepare(libcamera::Span<const uint8_t> buffer, Metadata &metadata) override;\n>> +       uint32_t GetVBlanking(Duration &exposure, Duration minFrameDuration,\n>> +                             Duration maxFrameDuration) const override;\n>> +       void GetDelays(int &exposure_delay, int &gain_delay,\n>> +                      int &vblank_delay) const override;\n>> +       bool SensorEmbeddedDataPresent() const override;\n>> +\n>> +private:\n>> +       /*\n>> +        * Smallest difference between the frame length and integration time,\n>> +        * in units of lines.\n>> +        */\n>> +       static constexpr int frameIntegrationDiff = 32;\n>> +       /* Maximum frame length allowable for long exposure calculations. */\n>> +       static constexpr int frameLengthMax = 0xffdc;\n>> +       /* Largest long exposure scale factor given as a left shift on the frame length. */\n>> +       static constexpr int longExposureShiftMax = 7;\n>> +\n>> +       void PopulateMetadata(const MdParser::RegisterMap &registers,\n>> +                             Metadata &metadata) const override;\n>> +};\n>> +\n>> +CamHelperImx519::CamHelperImx519()\n>> +       : CamHelper(std::make_unique<MdParserSmia>(registerList), frameIntegrationDiff)\n>> +{\n>> +}\n>> +\n>> +uint32_t CamHelperImx519::GainCode(double gain) const\n>> +{\n>> +       return static_cast<uint32_t>(1024 - 1024 / gain);\n>> +}\n>> +\n>> +double CamHelperImx519::Gain(uint32_t gain_code) const\n>> +{\n>> +       return 1024.0 / (1024 - gain_code);\n>> +}\n>> +\n>> +void CamHelperImx519::Prepare(libcamera::Span<const uint8_t> buffer, Metadata &metadata)\n>> +{\n>> +       MdParser::RegisterMap registers;\n>> +       DeviceStatus deviceStatus;\n>> +\n>> +       if (metadata.Get(\"device.status\", deviceStatus)) {\n>> +               LOG(IPARPI, Error) << \"DeviceStatus not found from DelayedControls\";\n>> +               return;\n>> +       }\n>> +\n>> +       parseEmbeddedData(buffer, metadata);\n>> +\n>> +       /*\n>> +        * The DeviceStatus struct is first populated with values obtained from\n>> +        * DelayedControls. If this reports frame length is > frameLengthMax,\n>> +        * it means we are using a long exposure mode. Since the long exposure\n>> +        * scale factor is not returned back through embedded data, we must rely\n>> +        * on the existing exposure lines and frame length values returned by\n>> +        * DelayedControls.\n>> +        *\n>> +        * Otherwise, all values are updated with what is reported in the\n>> +        * embedded data.\n>> +        */\n>> +       if (deviceStatus.frame_length > frameLengthMax) {\n>> +               DeviceStatus parsedDeviceStatus;\n>> +\n>> +               metadata.Get(\"device.status\", parsedDeviceStatus);\n>> +               parsedDeviceStatus.shutter_speed = deviceStatus.shutter_speed;\n>> +               parsedDeviceStatus.frame_length = deviceStatus.frame_length;\n>> +               metadata.Set(\"device.status\", parsedDeviceStatus);\n>> +\n>> +               LOG(IPARPI, Debug) << \"Metadata updated for long exposure: \"\n>> +                                  << parsedDeviceStatus;\n>> +       }\n>> +}\n>> +\n>> +uint32_t CamHelperImx519::GetVBlanking(Duration &exposure,\n>> +                                      Duration minFrameDuration,\n>> +                                      Duration maxFrameDuration) const\n>> +{\n>> +       uint32_t frameLength, exposureLines;\n>> +       unsigned int shift = 0;\n>> +\n>> +       frameLength = mode_.height + CamHelper::GetVBlanking(exposure, minFrameDuration,\n>> +                                                            maxFrameDuration);\n>> +       /*\n>> +        * Check if the frame length calculated needs to be setup for long\n>> +        * exposure mode. This will require us to use a long exposure scale\n>> +        * factor provided by a shift operation in the sensor.\n>> +        */\n>> +       while (frameLength > frameLengthMax) {\n>> +               if (++shift > longExposureShiftMax) {\n>> +                       shift = longExposureShiftMax;\n>> +                       frameLength = frameLengthMax;\n>> +                       break;\n>> +               }\n>> +               frameLength >>= 1;\n>> +       }\n>> +\n>> +       if (shift) {\n>> +               /* Account for any rounding in the scaled frame length value. */\n>> +               frameLength <<= shift;\n>> +               exposureLines = ExposureLines(exposure);\n>> +               exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff);\n>> +               exposure = Exposure(exposureLines);\n>> +       }\n>> +\n>> +       return frameLength - mode_.height;\n>> +}\n>> +\n>> +void CamHelperImx519::GetDelays(int &exposure_delay, int &gain_delay,\n>> +                               int &vblank_delay) const\n>> +{\n>> +       exposure_delay = 2;\n>> +       gain_delay = 2;\n>> +       vblank_delay = 3;\n>> +}\n>> +\n>> +bool CamHelperImx519::SensorEmbeddedDataPresent() const\n>> +{\n>> +       return true;\n>> +}\n>> +\n>> +void CamHelperImx519::PopulateMetadata(const MdParser::RegisterMap &registers,\n>> +                                      Metadata &metadata) const\n>> +{\n>> +       DeviceStatus deviceStatus;\n>> +\n>> +       deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg));\n>> +       deviceStatus.analogue_gain = Gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg));\n>> +       deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg);\n>> +\n>> +       metadata.Set(\"device.status\", deviceStatus);\n>> +}\n>> +\n>> +static CamHelper *Create()\n>> +{\n>> +       return new CamHelperImx519();\n>> +}\n>> +\n>> +static RegisterCamHelper reg(\"imx519\", &Create);\n>> diff --git a/src/ipa/raspberrypi/data/imx519.json b/src/ipa/raspberrypi/data/imx519.json\n>> new file mode 100644\n>> index 00000000..39e788ad\n>> --- /dev/null\n>> +++ b/src/ipa/raspberrypi/data/imx519.json\n>> @@ -0,0 +1,272 @@\n>> +{\n>> +    \"rpi.black_level\":\n>> +    {\n>> +        \"black_level\": 4096\n>> +    },\n>> +    \"rpi.dpc\":\n>> +    {\n>> +    },\n>> +    \"rpi.lux\":\n>> +    {\n>> +        \"reference_shutter_speed\": 10812,\n>> +        \"reference_gain\": 2.0,\n>> +        \"reference_aperture\": 1.0,\n>> +        \"reference_lux\": 1250,\n>> +        \"reference_Y\": 12737\n>> +    },\n>> +    \"rpi.noise\":\n>> +    {\n>> +        \"reference_constant\": 0,\n>> +        \"reference_slope\": 2.91\n>> +    },\n>> +    \"rpi.geq\":\n>> +    {\n>> +        \"offset\": 444,\n>> +        \"slope\": 0.00731\n>> +    },\n>> +    \"rpi.sdn\":\n>> +    {\n>> +        \"deviation\":3.7,\n>> +        \"strength\":0.75\n>> +    },\n>> +    \"rpi.awb\":\n>> +    {\n>> +        \"priors\":\n>> +        [\n>> +            {\n>> +                \"lux\": 0, \"prior\":\n>> +                [\n>> +                    2000, 1.0, 3000, 0.0, 13000, 0.0\n>> +                ]\n>> +            },\n>> +            {\n>> +                \"lux\": 800, \"prior\":\n>> +                [\n>> +                    2000, 0.0, 6000, 2.0, 13000, 2.0\n>> +                ]\n>> +            },\n>> +            {\n>> +                \"lux\": 1500, \"prior\":\n>> +                [\n>> +                    2000, 0.0, 4000, 1.0, 6000, 6.0, 6500, 7.0, 7000, 1.0, 13000, 1.0\n>> +                ]\n>> +            }\n>> +        ],\n>> +        \"modes\":\n>> +        {\n>> +            \"auto\":\n>> +            {\n>> +                \"lo\": 2500,\n>> +                \"hi\": 8000\n>> +            },\n>> +            \"incandescent\":\n>> +            {\n>> +                \"lo\": 2500,\n>> +                \"hi\": 3000\n>> +            },\n>> +            \"tungsten\":\n>> +            {\n>> +                \"lo\": 3000,\n>> +                \"hi\": 3500\n>> +            },\n>> +            \"fluorescent\":\n>> +            {\n>> +                \"lo\": 4000,\n>> +                \"hi\": 4700\n>> +            },\n>> +            \"indoor\":\n>> +            {\n>> +                \"lo\": 3000,\n>> +                \"hi\": 5000\n>> +            },\n>> +            \"daylight\":\n>> +            {\n>> +                \"lo\": 5500,\n>> +                \"hi\": 6500\n>> +            },\n>> +            \"cloudy\":\n>> +            {\n>> +                \"lo\": 7000,\n>> +                \"hi\": 8600\n>> +            }\n>> +        },\n>> +        \"bayes\": 0\n>> \n>> \n>> Just a small thing, but if we're going with the simple grey world\n>> algorithm it might be worth deleting the other AWB parameters as they\n>> don't do anything.\n>> \n>> And a few final questions:\n>> \n>> * Are you planning to upstream an open source driver for the imx519?\n>> The preference within libcamera (someone will correct me if I'm\n>> wrong!) is to support sensors where code and drivers are open.\n>> \n>> * If you're planning to open-source the driver we'd be pleased to\n>> receive pull requests into our own Raspberry Pi kernel distribution.\n>> \n>> * I assume this is a fairly standard Bayer sensor? If you have a\n>> working open source driver and can send me a module then I'd be very\n>> happy to help you further with the json tuning file.\n>> \n>> Thanks and best regards\n>> David\n> \n> Based on the discussions we've had this seems fine to me.\n> \n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com <mailto:david.plowman@raspberrypi.com>>\n> \n> Once I have some modules I'll try and do a more complete colour tuning\n> and then I'll submit that.\n> \n> Thanks!\n> David\n> \n>> \n>> +\n>> +    },\n>> +    \"rpi.agc\":\n>> +    {\n>> +        \"metering_modes\":\n>> +        {\n>> +            \"centre-weighted\":\n>> +            {\n>> +                \"weights\":\n>> +                [\n>> +                    3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0\n>> +                ]\n>> +            },\n>> +            \"spot\":\n>> +            {\n>> +                \"weights\":\n>> +                [\n>> +                    2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n>> +                ]\n>> +            },\n>> +            \"matrix\":\n>> +            {\n>> +                \"weights\":\n>> +                [\n>> +                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\n>> +                ]\n>> +            }\n>> +        },\n>> +        \"exposure_modes\":\n>> +        {\n>> +            \"normal\":\n>> +            {\n>> +                \"shutter\":\n>> +                [\n>> +                    100, 10000, 30000, 60000, 120000\n>> +                ],\n>> +                \"gain\":\n>> +                [\n>> +                    1.0, 2.0, 4.0, 6.0, 12.0\n>> +                ]\n>> +            },\n>> +            \"short\":\n>> +            {\n>> +                \"shutter\":\n>> +                [\n>> +                    100, 5000, 10000, 20000, 120000\n>> +                ],\n>> +                \"gain\":\n>> +                [\n>> +                    1.0, 2.0, 4.0, 6.0, 12.0\n>> +                ]\n>> +            }\n>> +        },\n>> +        \"constraint_modes\":\n>> +        {\n>> +            \"normal\":\n>> +            [\n>> +                {\n>> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n>> +                    [\n>> +                        0, 0.5, 1000, 0.5\n>> +                    ]\n>> +                }\n>> +            ],\n>> +            \"highlight\":\n>> +            [\n>> +                {\n>> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n>> +                    [\n>> +                        0, 0.5, 1000, 0.5\n>> +                    ]\n>> +                },\n>> +                {\n>> +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n>> +                    [\n>> +                        0, 0.8, 1000, 0.8\n>> +                    ]\n>> +                }\n>> +            ]\n>> +        },\n>> +        \"y_target\":\n>> +        [\n>> +            0, 0.16, 1000, 0.165, 10000, 0.17\n>> +        ]\n>> +    },\n>> +    \"rpi.alsc\":\n>> +    {\n>> +        \"omega\": 1.3,\n>> +        \"n_iter\": 100,\n>> +        \"luminance_strength\": 0.5,\n>> +        \"calibrations_Cr\":\n>> +        [\n>> +            {\n>> +                \"ct\": 6500, \"table\":\n>> +                [\n>> +                    2.544, 2.541, 2.531, 2.518, 2.506, 2.495, 2.489, 2.489, 2.489, 2.491, 2.502, 2.511, 2.524, 2.534, 2.542, 2.547,\n>> +                    2.541, 2.532, 2.521, 2.506, 2.493, 2.479, 2.469, 2.462, 2.462, 2.473, 2.488, 2.502, 2.511, 2.527, 2.536, 2.542,\n>> +                    2.531, 2.523, 2.506, 2.492, 2.474, 2.458, 2.444, 2.435, 2.435, 2.446, 2.466, 2.481, 2.498, 2.511, 2.526, 2.536,\n>> +                    2.523, 2.513, 2.492, 2.474, 2.458, 2.438, 2.418, 2.408, 2.408, 2.421, 2.443, 2.463, 2.481, 2.498, 2.517, 2.526,\n>> +                    2.513, 2.502, 2.481, 2.459, 2.438, 2.418, 2.397, 2.379, 2.379, 2.399, 2.421, 2.443, 2.463, 2.486, 2.506, 2.517,\n>> +                    2.506, 2.492, 2.469, 2.445, 2.423, 2.397, 2.377, 2.368, 2.369, 2.379, 2.399, 2.427, 2.451, 2.474, 2.495, 2.511,\n>> +                    2.506, 2.492, 2.469, 2.445, 2.423, 2.397, 2.372, 2.364, 2.364, 2.374, 2.399, 2.427, 2.449, 2.474, 2.495, 2.511,\n>> +                    2.506, 2.493, 2.474, 2.451, 2.426, 2.401, 2.382, 2.368, 2.369, 2.382, 2.405, 2.431, 2.449, 2.476, 2.497, 2.509,\n>> +                    2.504, 2.493, 2.475, 2.452, 2.431, 2.412, 2.401, 2.382, 2.382, 2.403, 2.416, 2.438, 2.457, 2.477, 2.497, 2.505,\n>> +                    2.499, 2.492, 2.474, 2.457, 2.441, 2.431, 2.412, 2.404, 2.404, 2.416, 2.432, 2.447, 2.459, 2.478, 2.495, 2.501,\n>> +                    2.499, 2.488, 2.473, 2.463, 2.453, 2.441, 2.431, 2.425, 2.425, 2.432, 2.445, 2.459, 2.466, 2.478, 2.491, 2.495,\n>> +                    2.499, 2.481, 2.472, 2.466, 2.458, 2.449, 2.441, 2.439, 2.439, 2.444, 2.454, 2.464, 2.469, 2.477, 2.484, 2.491\n>> +                ]\n>> +            }\n>> +        ],\n>> +        \"calibrations_Cb\":\n>> +        [\n>> +            {\n>> +                \"ct\": 6500, \"table\":\n>> +                [\n>> +                    1.352, 1.352, 1.349, 1.348, 1.347, 1.346, 1.347, 1.349, 1.351, 1.351, 1.352, 1.353, 1.353, 1.355, 1.358, 1.359,\n>> +                    1.359, 1.355, 1.352, 1.349, 1.348, 1.348, 1.348, 1.351, 1.352, 1.352, 1.352, 1.354, 1.356, 1.358, 1.361, 1.366,\n>> +                    1.364, 1.359, 1.355, 1.352, 1.349, 1.349, 1.351, 1.353, 1.353, 1.353, 1.355, 1.356, 1.358, 1.362, 1.366, 1.371,\n>> +                    1.371, 1.365, 1.359, 1.355, 1.352, 1.352, 1.353, 1.357, 1.357, 1.356, 1.356, 1.359, 1.362, 1.366, 1.371, 1.377,\n>> +                    1.375, 1.371, 1.365, 1.362, 1.359, 1.359, 1.359, 1.364, 1.364, 1.364, 1.364, 1.365, 1.367, 1.371, 1.377, 1.382,\n>> +                    1.379, 1.375, 1.371, 1.367, 1.367, 1.367, 1.369, 1.373, 1.374, 1.374, 1.373, 1.373, 1.374, 1.377, 1.382, 1.386,\n>> +                    1.383, 1.378, 1.374, 1.372, 1.372, 1.372, 1.373, 1.375, 1.378, 1.379, 1.379, 1.379, 1.379, 1.381, 1.386, 1.389,\n>> +                    1.384, 1.379, 1.376, 1.374, 1.373, 1.373, 1.374, 1.379, 1.379, 1.379, 1.379, 1.379, 1.381, 1.382, 1.386, 1.394,\n>> +                    1.386, 1.379, 1.376, 1.375, 1.374, 1.374, 1.374, 1.378, 1.378, 1.378, 1.378, 1.379, 1.381, 1.383, 1.386, 1.394,\n>> +                    1.385, 1.379, 1.376, 1.375, 1.374, 1.374, 1.375, 1.378, 1.378, 1.378, 1.378, 1.379, 1.381, 1.383, 1.387, 1.393,\n>> +                    1.379, 1.378, 1.375, 1.374, 1.373, 1.374, 1.375, 1.377, 1.378, 1.378, 1.378, 1.379, 1.381, 1.382, 1.386, 1.388,\n>> +                    1.379, 1.376, 1.374, 1.372, 1.372, 1.374, 1.375, 1.377, 1.378, 1.378, 1.377, 1.378, 1.379, 1.382, 1.384, 1.387\n>> +                ]\n>> +            }\n>> +        ],\n>> +        \"luminance_lut\":\n>> +        [\n>> +            3.257, 3.091, 2.639, 2.301, 2.009, 1.795, 1.742, 1.742, 1.742, 1.742, 1.798, 2.011, 2.309, 2.649, 3.109, 3.251,\n>> +            3.091, 2.703, 2.311, 2.059, 1.791, 1.631, 1.529, 1.482, 1.482, 1.533, 1.635, 1.791, 2.068, 2.313, 2.719, 3.109,\n>> +            2.707, 2.424, 2.059, 1.791, 1.626, 1.429, 1.329, 1.282, 1.282, 1.333, 1.433, 1.629, 1.791, 2.068, 2.438, 2.719,\n>> +            2.555, 2.233, 1.889, 1.626, 1.429, 1.321, 1.176, 1.126, 1.126, 1.181, 1.327, 1.433, 1.629, 1.894, 2.241, 2.538,\n>> +            2.482, 2.108, 1.775, 1.518, 1.321, 1.176, 1.112, 1.011, 1.012, 1.122, 1.181, 1.327, 1.523, 1.779, 2.113, 2.462,\n>> +            2.478, 2.048, 1.719, 1.465, 1.266, 1.112, 1.009, 1.001, 1.007, 1.012, 1.122, 1.274, 1.469, 1.722, 2.051, 2.454,\n>> +            2.478, 2.048, 1.719, 1.465, 1.266, 1.112, 1.004, 1.001, 1.001, 1.011, 1.122, 1.274, 1.469, 1.722, 2.051, 2.454,\n>> +            2.478, 2.099, 1.768, 1.511, 1.312, 1.163, 1.108, 1.004, 1.008, 1.112, 1.171, 1.321, 1.515, 1.767, 2.097, 2.454,\n>> +            2.541, 2.217, 1.877, 1.614, 1.417, 1.312, 1.163, 1.112, 1.112, 1.171, 1.317, 1.421, 1.616, 1.874, 2.214, 2.516,\n>> +            2.686, 2.404, 2.046, 1.779, 1.614, 1.417, 1.317, 1.267, 1.267, 1.319, 1.421, 1.614, 1.773, 2.039, 2.399, 2.669,\n>> +            3.063, 2.678, 2.292, 2.046, 1.779, 1.622, 1.521, 1.469, 1.469, 1.519, 1.622, 1.773, 2.038, 2.277, 2.669, 3.049,\n>> +            3.224, 3.063, 2.616, 2.285, 1.995, 1.781, 1.725, 1.723, 1.723, 1.723, 1.777, 1.984, 2.271, 2.598, 3.049, 3.187\n>> +        ],\n>> +        \"sigma\": 0.005,\n>> +        \"sigma_Cb\": 0.005\n>> +    },\n>> +    \"rpi.contrast\":\n>> +    {\n>> +        \"ce_enable\": 1,\n>> +        \"gamma_curve\":\n>> +        [\n>> +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120, 18051, 6144, 20790, 7168, 23193,\n>> +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288, 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n>> +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753, 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n>> +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954, 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n>> +            65535, 65535\n>> +        ]\n>> +    },\n>> +    \"rpi.ccm\":\n>> +    {\n>> +        \"ccms\":\n>> +        [\n>> +            {\n>> +                \"ct\": 5500, \"ccm\":\n>> +                [\n>> +                    1.40348, -0.45861, 0.05512, -0.24419, 1.25488, -0.01068, -0.08564, -0.31571, 1.40135\n>> +                ]\n>> +            }\n>> +        ]\n>> +    },\n>> +    \"rpi.sharpen\":\n>> +    {\n>> +               \"threshold\":1.5,\n>> +               \"strength\":0.5,\n>> +               \"limit\":0.2\n>> +    }\n>> +}\n>> diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n>> index 2def75cb..e84cd099 100644\n>> --- a/src/ipa/raspberrypi/data/meson.build\n>> +++ b/src/ipa/raspberrypi/data/meson.build\n>> @@ -7,6 +7,7 @@ conf_files = files([\n>>    'imx378.json',\n>>    'imx477.json',\n>>    'imx477_noir.json',\n>> +    'imx519.json',\n>>    'ov5647.json',\n>>    'ov5647_noir.json',\n>>    'ov9281.json',\n>> diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n>> index 1af31e4a..176055f4 100644\n>> --- a/src/ipa/raspberrypi/meson.build\n>> +++ b/src/ipa/raspberrypi/meson.build\n>> @@ -22,6 +22,7 @@ rpi_ipa_sources = files([\n>>    'cam_helper_imx219.cpp',\n>>    'cam_helper_imx290.cpp',\n>>    'cam_helper_imx477.cpp',\n>> +    'cam_helper_imx519.cpp',\n>>    'cam_helper_ov9281.cpp',\n>>    'controller/controller.cpp',\n>>    'controller/histogram.cpp',\n>> --\n>> 2.17.1","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 95870BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 12 Oct 2021 09:30:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F19A368F51;\n\tTue, 12 Oct 2021 11:30:13 +0200 (CEST)","from out28-145.mail.aliyun.com (out28-145.mail.aliyun.com\n\t[115.124.28.145])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E61266381D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Oct 2021 11:30:09 +0200 (CEST)","from 192.168.0.57(mailfrom:info@arducam.com\n\tfp:SMTPD_---.LXlywJt_1634031005)\n\tby smtp.aliyun-inc.com(10.147.42.241);\n\tTue, 12 Oct 2021 17:30:05 +0800"],"X-Alimail-AntiSpam":"AC=CONTINUE; BC=0.06875215|-1; CH=green;\n\tDM=|CONTINUE|false|;\n\tDS=CONTINUE|ham_system_inform|0.00470303-0.000853356-0.994444;\n\tFP=5319168536435361251|1|1|2|0|-1|-1|-1; HT=ay29a033018047199;\n\tMF=info@arducam.com; NM=1; PH=DS; RN=4; RT=4; SR=0;\n\tTI=SMTPD_---.LXlywJt_1634031005; ","From":"Arducam info <info@arducam.com>","Message-Id":"<94681989-4DAB-4325-BB59-048BF3322455@arducam.com>","Content-Type":"multipart/alternative;\n\tboundary=\"Apple-Mail=_56653F5E-3FAC-4FDE-BEB0-6ABC65AA131C\"","Mime-Version":"1.0 (Mac OS X Mail 14.0 \\(3654.60.0.2.21\\))","Date":"Tue, 12 Oct 2021 17:30:05 +0800","In-Reply-To":"<CAHW6GY+SzO4QJExOuOY-CeeZe31g33nXo2XEhRLUOK+ZMotrbw@mail.gmail.com>","To":"David Plowman <david.plowman@raspberrypi.com>","References":"<638360E6-389E-4699-A524-584E7A555C61@arducam.com>\n\t<CAHW6GYLsy2_su9t=Fqh=KAJ=dW3YKp6AuqS_AOJtTp6jZDib-w@mail.gmail.com>\n\t<97927250-56E8-480C-97C0-A756A54CF7B4@arducam.com>\n\t<CAHW6GY+SzO4QJExOuOY-CeeZe31g33nXo2XEhRLUOK+ZMotrbw@mail.gmail.com>","X-Mailer":"Apple Mail (2.3654.60.0.2.21)","Subject":"Re: [libcamera-devel] [PATCH] libcamera: ipa: raspberrypi: Add\n\tsupport for imx519 sensor","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>,\n\tArducam info <info@arducam.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]