[{"id":26529,"web_url":"https://patchwork.libcamera.org/comment/26529/","msgid":"<ZACJ1xg6f+AxQ7uP@pyrite.rasen.tech>","date":"2023-03-02T11:34:47","subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: imx8-isi: Break-out\n\tRAW format selection","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Sun, Jan 29, 2023 at 02:58:26PM +0100, Jacopo Mondi via libcamera-devel wrote:\n> The current implementation of the ISI pipeline handler handles\n> translation of PixelFormat to media bus formats from the sensor\n> through a centralized map.\n> \n> As the criteria to select the correct media bus code depend if the\n> output PixelFormat is a RAW Bayer format or not, start by splitting\n> the RAW media bus code procedure selection out by adding a method\n> for such purpose to the ISICameraData class.\n> \n> Add the function to the ISICameraData and not to the\n> ISICameraConfiguration because:\n> - The sensor is a property of CameraData\n> - The same function will be re-used by the ISIPipelineHandler\n>   during CameraConfiguration generation.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nIn the title, s/Break-out/Break out/\n\n> ---\n>  src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 130 +++++++++++++------\n>  1 file changed, 90 insertions(+), 40 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> index 0c67e35dde73..72bc310d80ec 100644\n> --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> @@ -59,6 +59,8 @@ public:\n>  \t\treturn stream - &*streams_.begin();\n>  \t}\n>  \n> +\tunsigned int getRawMediaBusFormat(PixelFormat *pixelFormat) const;\n> +\n>  \tstd::unique_ptr<CameraSensor> sensor_;\n>  \tstd::unique_ptr<V4L2Subdevice> csis_;\n>  \n> @@ -174,6 +176,85 @@ int ISICameraData::init()\n>  \treturn 0;\n>  }\n>  \n> +/*\n> + * Get a RAW Bayer media bus format compatible with the requested pixelFormat.\n> + *\n> + * If the requested pixelFormat cannot be produced by the sensor adjust it to\n> + * the one corresponding to the media bus format with the largest bit-depth.\n> + */\n> +unsigned int ISICameraData::getRawMediaBusFormat(PixelFormat *pixelFormat) const\n\nI'm wondering why you decided to use a pointer instead of a reference. I\nsuppose since we control all the callers it's fine either way, so just\nwondering.\n\nOtherwise, looks good to me.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> +{\n> +\tstd::vector<unsigned int> mbusCodes = sensor_->mbusCodes();\n> +\n> +\tconst std::map<PixelFormat, unsigned int> rawFormats = {\n> +\t\t{ formats::SBGGR8, MEDIA_BUS_FMT_SBGGR8_1X8 },\n> +\t\t{ formats::SGBRG8, MEDIA_BUS_FMT_SGBRG8_1X8 },\n> +\t\t{ formats::SGRBG8, MEDIA_BUS_FMT_SGRBG8_1X8 },\n> +\t\t{ formats::SRGGB8, MEDIA_BUS_FMT_SRGGB8_1X8 },\n> +\t\t{ formats::SBGGR10, MEDIA_BUS_FMT_SBGGR10_1X10 },\n> +\t\t{ formats::SGBRG10, MEDIA_BUS_FMT_SGBRG10_1X10 },\n> +\t\t{ formats::SGRBG10, MEDIA_BUS_FMT_SGRBG10_1X10 },\n> +\t\t{ formats::SRGGB10, MEDIA_BUS_FMT_SRGGB10_1X10 },\n> +\t\t{ formats::SBGGR12, MEDIA_BUS_FMT_SBGGR12_1X12 },\n> +\t\t{ formats::SGBRG12, MEDIA_BUS_FMT_SGBRG12_1X12 },\n> +\t\t{ formats::SGRBG12, MEDIA_BUS_FMT_SGRBG12_1X12 },\n> +\t\t{ formats::SRGGB12, MEDIA_BUS_FMT_SRGGB12_1X12 },\n> +\t};\n> +\n> +\t/*\n> +\t * Make sure the requested PixelFormat is supported in the above\n> +\t * map and the sensor can produce the compatible mbus code.\n> +\t */\n> +\tauto it = rawFormats.find(*pixelFormat);\n> +\tif (it != rawFormats.end() &&\n> +\t    std::count(mbusCodes.begin(), mbusCodes.end(), it->second))\n> +\t\treturn it->second;\n> +\n> +\tif (it == rawFormats.end())\n> +\t\tLOG(ISI, Warning) << pixelFormat\n> +\t\t\t\t  << \" not supported in ISI formats map.\";\n> +\n> +\t/*\n> +\t * The desired pixel format cannot be produced. Adjust it to the one\n> +\t * corresponding to the raw media bus format with the largest bit-depth\n> +\t * the sensor provides.\n> +\t */\n> +\tunsigned int sensorCode = 0;\n> +\tunsigned int maxDepth = 0;\n> +\t*pixelFormat = {};\n> +\n> +\tfor (unsigned int code : mbusCodes) {\n> +\t\t/* Make sure the media bus format is RAW Bayer. */\n> +\t\tconst BayerFormat &bayerFormat = BayerFormat::fromMbusCode(code);\n> +\t\tif (!bayerFormat.isValid())\n> +\t\t\tcontinue;\n> +\n> +\t\t/* Make sure the media format is supported. */\n> +\t\tit = std::find_if(rawFormats.begin(), rawFormats.end(),\n> +\t\t\t\t  [code](auto &rawFormat) {\n> +\t\t\t\t\t  return rawFormat.second == code;\n> +\t\t\t\t  });\n> +\n> +\t\tif (it == rawFormats.end()) {\n> +\t\t\tLOG(ISI, Warning) << bayerFormat\n> +\t\t\t\t\t  << \" not supported in ISI formats map.\";\n> +\t\t\tcontinue;\n> +\t\t}\n> +\n> +\t\t/* Pick the one with the largest bit depth. */\n> +\t\tif (bayerFormat.bitDepth > maxDepth) {\n> +\t\t\tmaxDepth = bayerFormat.bitDepth;\n> +\t\t\t*pixelFormat = it->first;\n> +\t\t\tsensorCode = code;\n> +\t\t}\n> +\t}\n> +\n> +\tif (!pixelFormat->isValid())\n> +\t\tLOG(ISI, Error) << \"Cannot find a supported RAW format\";\n> +\n> +\treturn sensorCode;\n> +}\n> +\n>  /* -----------------------------------------------------------------------------\n>   * Camera Configuration\n>   */\n> @@ -311,50 +392,19 @@ ISICameraConfiguration::validateRaw(std::set<Stream *> &availableStreams,\n>  \t */\n>  \tstd::vector<unsigned int> mbusCodes = data_->sensor_->mbusCodes();\n>  \tStreamConfiguration &rawConfig = config_[0];\n> +\tPixelFormat rawFormat = rawConfig.pixelFormat;\n>  \n> -\tbool supported = false;\n> -\tauto it = formatsMap_.find(rawConfig.pixelFormat);\n> -\tif (it != formatsMap_.end()) {\n> -\t\tunsigned int mbusCode = it->second.sensorCode;\n> -\n> -\t\tif (std::count(mbusCodes.begin(), mbusCodes.end(), mbusCode))\n> -\t\t\tsupported = true;\n> +\tunsigned int sensorCode = data_->getRawMediaBusFormat(&rawFormat);\n> +\tif (!sensorCode) {\n> +\t\tLOG(ISI, Error) << \"Cannot adjust RAW pixelformat \"\n> +\t\t\t\t<< rawConfig.pixelFormat;\n> +\t\treturn Invalid;\n>  \t}\n>  \n> -\tif (!supported) {\n> -\t\t/*\n> -\t\t * Adjust to the first mbus code supported by both the\n> -\t\t * sensor and the pipeline.\n> -\t\t */\n> -\t\tconst FormatMap::value_type *pipeConfig = nullptr;\n> -\t\tfor (unsigned int code : mbusCodes) {\n> -\t\t\tconst BayerFormat &bayerFormat = BayerFormat::fromMbusCode(code);\n> -\t\t\tif (!bayerFormat.isValid())\n> -\t\t\t\tcontinue;\n> -\n> -\t\t\tauto fmt = std::find_if(ISICameraConfiguration::formatsMap_.begin(),\n> -\t\t\t\t\t\tISICameraConfiguration::formatsMap_.end(),\n> -\t\t\t\t\t\t[code](const auto &isiFormat) {\n> -\t\t\t\t\t\t\tconst auto &pipe = isiFormat.second;\n> -\t\t\t\t\t\t\treturn pipe.sensorCode == code;\n> -\t\t\t\t\t\t});\n> -\n> -\t\t\tif (fmt == ISICameraConfiguration::formatsMap_.end())\n> -\t\t\t\tcontinue;\n> -\n> -\t\t\tpipeConfig = &(*fmt);\n> -\t\t\tbreak;\n> -\t\t}\n> -\n> -\t\tif (!pipeConfig) {\n> -\t\t\tLOG(ISI, Error) << \"Cannot adjust RAW format \"\n> -\t\t\t\t\t<< rawConfig.pixelFormat;\n> -\t\t\treturn Invalid;\n> -\t\t}\n> -\n> -\t\trawConfig.pixelFormat = pipeConfig->first;\n> +\tif (rawFormat != rawConfig.pixelFormat) {\n>  \t\tLOG(ISI, Debug) << \"RAW pixelformat adjusted to \"\n> -\t\t\t\t<< pipeConfig->first;\n> +\t\t\t\t<< rawFormat;\n> +\t\trawConfig.pixelFormat = rawFormat;\n>  \t\tstatus = Adjusted;\n>  \t}\n>  \n> -- \n> 2.39.0\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 7E2E3BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Mar 2023 11:34:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A03B9626C6;\n\tThu,  2 Mar 2023 12:34:57 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3CA216267E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Mar 2023 12:34:56 +0100 (CET)","from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ABE7556A;\n\tThu,  2 Mar 2023 12:34:54 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1677756897;\n\tbh=STlruEpvybMArNLlqrWRjQ4YJbJMspRP+F8ESK+kQig=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=c6CHBoFs5fygIqdhyVKbqsrRxsYGRJBMA3y6qAsRR1ijoulN5YB1HyyTBnEnOHnPu\n\tcBQIaJcuqfwTTv14V4SAITnMyGEPfbOq/3kPcTcc/C4F0P2MW7Nkqvwl/Z4PjzDvTe\n\t2MUP8CDwlvHChvupdcvIf/4onq4S3oURaMKfkykZmNeNbM9jVxAnK8w54fme1NGJ9J\n\tTyficBOLNW+XOv8wdumfYFgzeP89/TOKNLhuoWlBwyBfnEAS7+djspAxOC20QwX2ru\n\tr9mKJ5D4Dhbk0o42wdnDnWJ7Rb4pt2RGWBYmeCUEFghzClhCvVJrpeKiKZ2Z6m6htR\n\tArSoJAFXVvVOQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1677756895;\n\tbh=STlruEpvybMArNLlqrWRjQ4YJbJMspRP+F8ESK+kQig=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=lnvp0ZsppeJHXiNqqgrI9f5D6LbJVoAshi+3a27mjE26SLDNMd4G0WBRfEExL8wzS\n\tmi3KcahKfRRarsAGqNrhq4DN95d8K+Nx4JuO3Mxg7Vt2xWqH8FxgWJDRuaShBtaGPb\n\tM/HQHmia7h0qOSrw0Hj5W/4KaSWrDGUF9znqR1F4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"lnvp0Zsp\"; dkim-atps=neutral","Date":"Thu, 2 Mar 2023 20:34:47 +0900","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Message-ID":"<ZACJ1xg6f+AxQ7uP@pyrite.rasen.tech>","References":"<20230129135830.27490-1-jacopo.mondi@ideasonboard.com>\n\t<20230129135830.27490-2-jacopo.mondi@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20230129135830.27490-2-jacopo.mondi@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: imx8-isi: Break-out\n\tRAW format selection","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>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26532,"web_url":"https://patchwork.libcamera.org/comment/26532/","msgid":"<ZACOGZ4YtJgplHna@pyrite.rasen.tech>","date":"2023-03-02T11:52:57","subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: imx8-isi: Break-out\n\tRAW format selection","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Thu, Mar 02, 2023 at 08:34:47PM +0900, Paul Elder via libcamera-devel wrote:\n> On Sun, Jan 29, 2023 at 02:58:26PM +0100, Jacopo Mondi via libcamera-devel wrote:\n> > The current implementation of the ISI pipeline handler handles\n> > translation of PixelFormat to media bus formats from the sensor\n> > through a centralized map.\n> > \n> > As the criteria to select the correct media bus code depend if the\n> > output PixelFormat is a RAW Bayer format or not, start by splitting\n> > the RAW media bus code procedure selection out by adding a method\n> > for such purpose to the ISICameraData class.\n> > \n> > Add the function to the ISICameraData and not to the\n> > ISICameraConfiguration because:\n> > - The sensor is a property of CameraData\n> > - The same function will be re-used by the ISIPipelineHandler\n> >   during CameraConfiguration generation.\n> > \n> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> \n> In the title, s/Break-out/Break out/\n> \n> > ---\n> >  src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 130 +++++++++++++------\n> >  1 file changed, 90 insertions(+), 40 deletions(-)\n> > \n> > diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> > index 0c67e35dde73..72bc310d80ec 100644\n> > --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> > +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> > @@ -59,6 +59,8 @@ public:\n> >  \t\treturn stream - &*streams_.begin();\n> >  \t}\n> >  \n> > +\tunsigned int getRawMediaBusFormat(PixelFormat *pixelFormat) const;\n> > +\n> >  \tstd::unique_ptr<CameraSensor> sensor_;\n> >  \tstd::unique_ptr<V4L2Subdevice> csis_;\n> >  \n> > @@ -174,6 +176,85 @@ int ISICameraData::init()\n> >  \treturn 0;\n> >  }\n> >  \n> > +/*\n> > + * Get a RAW Bayer media bus format compatible with the requested pixelFormat.\n> > + *\n> > + * If the requested pixelFormat cannot be produced by the sensor adjust it to\n> > + * the one corresponding to the media bus format with the largest bit-depth.\n> > + */\n> > +unsigned int ISICameraData::getRawMediaBusFormat(PixelFormat *pixelFormat) const\n> \n> I'm wondering why you decided to use a pointer instead of a reference. I\n> suppose since we control all the callers it's fine either way, so just\n> wondering.\n> \n> Otherwise, looks good to me.\n> \n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> > +{\n> > +\tstd::vector<unsigned int> mbusCodes = sensor_->mbusCodes();\n> > +\n> > +\tconst std::map<PixelFormat, unsigned int> rawFormats = {\n\nOh I forgot, how about making this static?\n\nSame with the one in the next patch.\n\n\nPaul\n\n> > +\t\t{ formats::SBGGR8, MEDIA_BUS_FMT_SBGGR8_1X8 },\n> > +\t\t{ formats::SGBRG8, MEDIA_BUS_FMT_SGBRG8_1X8 },\n> > +\t\t{ formats::SGRBG8, MEDIA_BUS_FMT_SGRBG8_1X8 },\n> > +\t\t{ formats::SRGGB8, MEDIA_BUS_FMT_SRGGB8_1X8 },\n> > +\t\t{ formats::SBGGR10, MEDIA_BUS_FMT_SBGGR10_1X10 },\n> > +\t\t{ formats::SGBRG10, MEDIA_BUS_FMT_SGBRG10_1X10 },\n> > +\t\t{ formats::SGRBG10, MEDIA_BUS_FMT_SGRBG10_1X10 },\n> > +\t\t{ formats::SRGGB10, MEDIA_BUS_FMT_SRGGB10_1X10 },\n> > +\t\t{ formats::SBGGR12, MEDIA_BUS_FMT_SBGGR12_1X12 },\n> > +\t\t{ formats::SGBRG12, MEDIA_BUS_FMT_SGBRG12_1X12 },\n> > +\t\t{ formats::SGRBG12, MEDIA_BUS_FMT_SGRBG12_1X12 },\n> > +\t\t{ formats::SRGGB12, MEDIA_BUS_FMT_SRGGB12_1X12 },\n> > +\t};\n> > +\n> > +\t/*\n> > +\t * Make sure the requested PixelFormat is supported in the above\n> > +\t * map and the sensor can produce the compatible mbus code.\n> > +\t */\n> > +\tauto it = rawFormats.find(*pixelFormat);\n> > +\tif (it != rawFormats.end() &&\n> > +\t    std::count(mbusCodes.begin(), mbusCodes.end(), it->second))\n> > +\t\treturn it->second;\n> > +\n> > +\tif (it == rawFormats.end())\n> > +\t\tLOG(ISI, Warning) << pixelFormat\n> > +\t\t\t\t  << \" not supported in ISI formats map.\";\n> > +\n> > +\t/*\n> > +\t * The desired pixel format cannot be produced. Adjust it to the one\n> > +\t * corresponding to the raw media bus format with the largest bit-depth\n> > +\t * the sensor provides.\n> > +\t */\n> > +\tunsigned int sensorCode = 0;\n> > +\tunsigned int maxDepth = 0;\n> > +\t*pixelFormat = {};\n> > +\n> > +\tfor (unsigned int code : mbusCodes) {\n> > +\t\t/* Make sure the media bus format is RAW Bayer. */\n> > +\t\tconst BayerFormat &bayerFormat = BayerFormat::fromMbusCode(code);\n> > +\t\tif (!bayerFormat.isValid())\n> > +\t\t\tcontinue;\n> > +\n> > +\t\t/* Make sure the media format is supported. */\n> > +\t\tit = std::find_if(rawFormats.begin(), rawFormats.end(),\n> > +\t\t\t\t  [code](auto &rawFormat) {\n> > +\t\t\t\t\t  return rawFormat.second == code;\n> > +\t\t\t\t  });\n> > +\n> > +\t\tif (it == rawFormats.end()) {\n> > +\t\t\tLOG(ISI, Warning) << bayerFormat\n> > +\t\t\t\t\t  << \" not supported in ISI formats map.\";\n> > +\t\t\tcontinue;\n> > +\t\t}\n> > +\n> > +\t\t/* Pick the one with the largest bit depth. */\n> > +\t\tif (bayerFormat.bitDepth > maxDepth) {\n> > +\t\t\tmaxDepth = bayerFormat.bitDepth;\n> > +\t\t\t*pixelFormat = it->first;\n> > +\t\t\tsensorCode = code;\n> > +\t\t}\n> > +\t}\n> > +\n> > +\tif (!pixelFormat->isValid())\n> > +\t\tLOG(ISI, Error) << \"Cannot find a supported RAW format\";\n> > +\n> > +\treturn sensorCode;\n> > +}\n> > +\n> >  /* -----------------------------------------------------------------------------\n> >   * Camera Configuration\n> >   */\n> > @@ -311,50 +392,19 @@ ISICameraConfiguration::validateRaw(std::set<Stream *> &availableStreams,\n> >  \t */\n> >  \tstd::vector<unsigned int> mbusCodes = data_->sensor_->mbusCodes();\n> >  \tStreamConfiguration &rawConfig = config_[0];\n> > +\tPixelFormat rawFormat = rawConfig.pixelFormat;\n> >  \n> > -\tbool supported = false;\n> > -\tauto it = formatsMap_.find(rawConfig.pixelFormat);\n> > -\tif (it != formatsMap_.end()) {\n> > -\t\tunsigned int mbusCode = it->second.sensorCode;\n> > -\n> > -\t\tif (std::count(mbusCodes.begin(), mbusCodes.end(), mbusCode))\n> > -\t\t\tsupported = true;\n> > +\tunsigned int sensorCode = data_->getRawMediaBusFormat(&rawFormat);\n> > +\tif (!sensorCode) {\n> > +\t\tLOG(ISI, Error) << \"Cannot adjust RAW pixelformat \"\n> > +\t\t\t\t<< rawConfig.pixelFormat;\n> > +\t\treturn Invalid;\n> >  \t}\n> >  \n> > -\tif (!supported) {\n> > -\t\t/*\n> > -\t\t * Adjust to the first mbus code supported by both the\n> > -\t\t * sensor and the pipeline.\n> > -\t\t */\n> > -\t\tconst FormatMap::value_type *pipeConfig = nullptr;\n> > -\t\tfor (unsigned int code : mbusCodes) {\n> > -\t\t\tconst BayerFormat &bayerFormat = BayerFormat::fromMbusCode(code);\n> > -\t\t\tif (!bayerFormat.isValid())\n> > -\t\t\t\tcontinue;\n> > -\n> > -\t\t\tauto fmt = std::find_if(ISICameraConfiguration::formatsMap_.begin(),\n> > -\t\t\t\t\t\tISICameraConfiguration::formatsMap_.end(),\n> > -\t\t\t\t\t\t[code](const auto &isiFormat) {\n> > -\t\t\t\t\t\t\tconst auto &pipe = isiFormat.second;\n> > -\t\t\t\t\t\t\treturn pipe.sensorCode == code;\n> > -\t\t\t\t\t\t});\n> > -\n> > -\t\t\tif (fmt == ISICameraConfiguration::formatsMap_.end())\n> > -\t\t\t\tcontinue;\n> > -\n> > -\t\t\tpipeConfig = &(*fmt);\n> > -\t\t\tbreak;\n> > -\t\t}\n> > -\n> > -\t\tif (!pipeConfig) {\n> > -\t\t\tLOG(ISI, Error) << \"Cannot adjust RAW format \"\n> > -\t\t\t\t\t<< rawConfig.pixelFormat;\n> > -\t\t\treturn Invalid;\n> > -\t\t}\n> > -\n> > -\t\trawConfig.pixelFormat = pipeConfig->first;\n> > +\tif (rawFormat != rawConfig.pixelFormat) {\n> >  \t\tLOG(ISI, Debug) << \"RAW pixelformat adjusted to \"\n> > -\t\t\t\t<< pipeConfig->first;\n> > +\t\t\t\t<< rawFormat;\n> > +\t\trawConfig.pixelFormat = rawFormat;\n> >  \t\tstatus = Adjusted;\n> >  \t}\n> >  \n> > -- \n> > 2.39.0\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 65B69BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Mar 2023 11:53:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C36EE6267E;\n\tThu,  2 Mar 2023 12:53:06 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6F71C6267E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Mar 2023 12:53:05 +0100 (CET)","from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D2A5756A;\n\tThu,  2 Mar 2023 12:53:03 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1677757986;\n\tbh=liV+sgjANELKSSEN6IdCo8vdMIKLeHrljafZ5ozh3/Q=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=HxKvfWWer9eXHr9wFEjowZTSjOsNA1eXP00My6nD/2yUYxRQ97Cu64LWfGpbOdTlB\n\tzJ/jPbSDSiD+pOD63zCWrwGy4GGh+8gUJyk5XMq8VVxutuBjt89SwDPXbYTiqBgeUa\n\tKeah1/AydViFFoaNchTeM6Fl2Q/f8b3MWzUnhu2yYPNJ7XsB7h4GLQ3dPujOkV+x3/\n\txx5vDIjYe9wRZx/BFKbmRcws1VD5wBIEhgQEVE8sP11/pwli9ic+zIaC6zv5EiL0wE\n\tQx7nBR4aRSVlfhE54zbgfDprajIJcwV59rQ3yn2S1BfyOZ0pxbhHpuJElywMzy7OzV\n\tpcGS74laGL64g==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1677757985;\n\tbh=liV+sgjANELKSSEN6IdCo8vdMIKLeHrljafZ5ozh3/Q=;\n\th=Date:From:To:Subject:References:In-Reply-To:From;\n\tb=sYflQntQZNftO7gZC9/1Fw48LJXFgXg/KNdtI3lY3nrIfHV82LbBeO0pTOvsuY2oB\n\tlQKaFf+aS3koZYZ2LMSMY8/+9SdYUS3/mS54nWBeVwh8v5M2jW1OgYo7KG7uhuiY7H\n\tiQq7QlvT/LQZew627NVvVUZwms2nFhPoADwWONGk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"sYflQntQ\"; dkim-atps=neutral","Date":"Thu, 2 Mar 2023 20:52:57 +0900","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Message-ID":"<ZACOGZ4YtJgplHna@pyrite.rasen.tech>","References":"<20230129135830.27490-1-jacopo.mondi@ideasonboard.com>\n\t<20230129135830.27490-2-jacopo.mondi@ideasonboard.com>\n\t<ZACJ1xg6f+AxQ7uP@pyrite.rasen.tech>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<ZACJ1xg6f+AxQ7uP@pyrite.rasen.tech>","Subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: imx8-isi: Break-out\n\tRAW format selection","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>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Paul Elder <paul.elder@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26536,"web_url":"https://patchwork.libcamera.org/comment/26536/","msgid":"<20230302124722.ua4cged3lxegqw5f@uno.localdomain>","date":"2023-03-02T12:47:22","subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: imx8-isi: Break-out\n\tRAW format selection","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Paul\n\nOn Thu, Mar 02, 2023 at 08:34:47PM +0900, Paul Elder via libcamera-devel wrote:\n> On Sun, Jan 29, 2023 at 02:58:26PM +0100, Jacopo Mondi via libcamera-devel wrote:\n> > The current implementation of the ISI pipeline handler handles\n> > translation of PixelFormat to media bus formats from the sensor\n> > through a centralized map.\n> >\n> > As the criteria to select the correct media bus code depend if the\n> > output PixelFormat is a RAW Bayer format or not, start by splitting\n> > the RAW media bus code procedure selection out by adding a method\n> > for such purpose to the ISICameraData class.\n> >\n> > Add the function to the ISICameraData and not to the\n> > ISICameraConfiguration because:\n> > - The sensor is a property of CameraData\n> > - The same function will be re-used by the ISIPipelineHandler\n> >   during CameraConfiguration generation.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n>\n> In the title, s/Break-out/Break out/\n>\n> > ---\n> >  src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 130 +++++++++++++------\n> >  1 file changed, 90 insertions(+), 40 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> > index 0c67e35dde73..72bc310d80ec 100644\n> > --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> > +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> > @@ -59,6 +59,8 @@ public:\n> >  \t\treturn stream - &*streams_.begin();\n> >  \t}\n> >\n> > +\tunsigned int getRawMediaBusFormat(PixelFormat *pixelFormat) const;\n> > +\n> >  \tstd::unique_ptr<CameraSensor> sensor_;\n> >  \tstd::unique_ptr<V4L2Subdevice> csis_;\n> >\n> > @@ -174,6 +176,85 @@ int ISICameraData::init()\n> >  \treturn 0;\n> >  }\n> >\n> > +/*\n> > + * Get a RAW Bayer media bus format compatible with the requested pixelFormat.\n> > + *\n> > + * If the requested pixelFormat cannot be produced by the sensor adjust it to\n> > + * the one corresponding to the media bus format with the largest bit-depth.\n> > + */\n> > +unsigned int ISICameraData::getRawMediaBusFormat(PixelFormat *pixelFormat) const\n>\n> I'm wondering why you decided to use a pointer instead of a reference. I\n\npixelFormat is an output parameter and by convention we use references\nfor const input parameters and pointers for parameters that can be\nmodified afaik\n\n> suppose since we control all the callers it's fine either way, so just\n> wondering.\n>\n> Otherwise, looks good to me.\n>\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\nThanks\n  j\n>\n> > +{\n> > +\tstd::vector<unsigned int> mbusCodes = sensor_->mbusCodes();\n> > +\n> > +\tconst std::map<PixelFormat, unsigned int> rawFormats = {\n> > +\t\t{ formats::SBGGR8, MEDIA_BUS_FMT_SBGGR8_1X8 },\n> > +\t\t{ formats::SGBRG8, MEDIA_BUS_FMT_SGBRG8_1X8 },\n> > +\t\t{ formats::SGRBG8, MEDIA_BUS_FMT_SGRBG8_1X8 },\n> > +\t\t{ formats::SRGGB8, MEDIA_BUS_FMT_SRGGB8_1X8 },\n> > +\t\t{ formats::SBGGR10, MEDIA_BUS_FMT_SBGGR10_1X10 },\n> > +\t\t{ formats::SGBRG10, MEDIA_BUS_FMT_SGBRG10_1X10 },\n> > +\t\t{ formats::SGRBG10, MEDIA_BUS_FMT_SGRBG10_1X10 },\n> > +\t\t{ formats::SRGGB10, MEDIA_BUS_FMT_SRGGB10_1X10 },\n> > +\t\t{ formats::SBGGR12, MEDIA_BUS_FMT_SBGGR12_1X12 },\n> > +\t\t{ formats::SGBRG12, MEDIA_BUS_FMT_SGBRG12_1X12 },\n> > +\t\t{ formats::SGRBG12, MEDIA_BUS_FMT_SGRBG12_1X12 },\n> > +\t\t{ formats::SRGGB12, MEDIA_BUS_FMT_SRGGB12_1X12 },\n> > +\t};\n> > +\n> > +\t/*\n> > +\t * Make sure the requested PixelFormat is supported in the above\n> > +\t * map and the sensor can produce the compatible mbus code.\n> > +\t */\n> > +\tauto it = rawFormats.find(*pixelFormat);\n> > +\tif (it != rawFormats.end() &&\n> > +\t    std::count(mbusCodes.begin(), mbusCodes.end(), it->second))\n> > +\t\treturn it->second;\n> > +\n> > +\tif (it == rawFormats.end())\n> > +\t\tLOG(ISI, Warning) << pixelFormat\n> > +\t\t\t\t  << \" not supported in ISI formats map.\";\n> > +\n> > +\t/*\n> > +\t * The desired pixel format cannot be produced. Adjust it to the one\n> > +\t * corresponding to the raw media bus format with the largest bit-depth\n> > +\t * the sensor provides.\n> > +\t */\n> > +\tunsigned int sensorCode = 0;\n> > +\tunsigned int maxDepth = 0;\n> > +\t*pixelFormat = {};\n> > +\n> > +\tfor (unsigned int code : mbusCodes) {\n> > +\t\t/* Make sure the media bus format is RAW Bayer. */\n> > +\t\tconst BayerFormat &bayerFormat = BayerFormat::fromMbusCode(code);\n> > +\t\tif (!bayerFormat.isValid())\n> > +\t\t\tcontinue;\n> > +\n> > +\t\t/* Make sure the media format is supported. */\n> > +\t\tit = std::find_if(rawFormats.begin(), rawFormats.end(),\n> > +\t\t\t\t  [code](auto &rawFormat) {\n> > +\t\t\t\t\t  return rawFormat.second == code;\n> > +\t\t\t\t  });\n> > +\n> > +\t\tif (it == rawFormats.end()) {\n> > +\t\t\tLOG(ISI, Warning) << bayerFormat\n> > +\t\t\t\t\t  << \" not supported in ISI formats map.\";\n> > +\t\t\tcontinue;\n> > +\t\t}\n> > +\n> > +\t\t/* Pick the one with the largest bit depth. */\n> > +\t\tif (bayerFormat.bitDepth > maxDepth) {\n> > +\t\t\tmaxDepth = bayerFormat.bitDepth;\n> > +\t\t\t*pixelFormat = it->first;\n> > +\t\t\tsensorCode = code;\n> > +\t\t}\n> > +\t}\n> > +\n> > +\tif (!pixelFormat->isValid())\n> > +\t\tLOG(ISI, Error) << \"Cannot find a supported RAW format\";\n> > +\n> > +\treturn sensorCode;\n> > +}\n> > +\n> >  /* -----------------------------------------------------------------------------\n> >   * Camera Configuration\n> >   */\n> > @@ -311,50 +392,19 @@ ISICameraConfiguration::validateRaw(std::set<Stream *> &availableStreams,\n> >  \t */\n> >  \tstd::vector<unsigned int> mbusCodes = data_->sensor_->mbusCodes();\n> >  \tStreamConfiguration &rawConfig = config_[0];\n> > +\tPixelFormat rawFormat = rawConfig.pixelFormat;\n> >\n> > -\tbool supported = false;\n> > -\tauto it = formatsMap_.find(rawConfig.pixelFormat);\n> > -\tif (it != formatsMap_.end()) {\n> > -\t\tunsigned int mbusCode = it->second.sensorCode;\n> > -\n> > -\t\tif (std::count(mbusCodes.begin(), mbusCodes.end(), mbusCode))\n> > -\t\t\tsupported = true;\n> > +\tunsigned int sensorCode = data_->getRawMediaBusFormat(&rawFormat);\n> > +\tif (!sensorCode) {\n> > +\t\tLOG(ISI, Error) << \"Cannot adjust RAW pixelformat \"\n> > +\t\t\t\t<< rawConfig.pixelFormat;\n> > +\t\treturn Invalid;\n> >  \t}\n> >\n> > -\tif (!supported) {\n> > -\t\t/*\n> > -\t\t * Adjust to the first mbus code supported by both the\n> > -\t\t * sensor and the pipeline.\n> > -\t\t */\n> > -\t\tconst FormatMap::value_type *pipeConfig = nullptr;\n> > -\t\tfor (unsigned int code : mbusCodes) {\n> > -\t\t\tconst BayerFormat &bayerFormat = BayerFormat::fromMbusCode(code);\n> > -\t\t\tif (!bayerFormat.isValid())\n> > -\t\t\t\tcontinue;\n> > -\n> > -\t\t\tauto fmt = std::find_if(ISICameraConfiguration::formatsMap_.begin(),\n> > -\t\t\t\t\t\tISICameraConfiguration::formatsMap_.end(),\n> > -\t\t\t\t\t\t[code](const auto &isiFormat) {\n> > -\t\t\t\t\t\t\tconst auto &pipe = isiFormat.second;\n> > -\t\t\t\t\t\t\treturn pipe.sensorCode == code;\n> > -\t\t\t\t\t\t});\n> > -\n> > -\t\t\tif (fmt == ISICameraConfiguration::formatsMap_.end())\n> > -\t\t\t\tcontinue;\n> > -\n> > -\t\t\tpipeConfig = &(*fmt);\n> > -\t\t\tbreak;\n> > -\t\t}\n> > -\n> > -\t\tif (!pipeConfig) {\n> > -\t\t\tLOG(ISI, Error) << \"Cannot adjust RAW format \"\n> > -\t\t\t\t\t<< rawConfig.pixelFormat;\n> > -\t\t\treturn Invalid;\n> > -\t\t}\n> > -\n> > -\t\trawConfig.pixelFormat = pipeConfig->first;\n> > +\tif (rawFormat != rawConfig.pixelFormat) {\n> >  \t\tLOG(ISI, Debug) << \"RAW pixelformat adjusted to \"\n> > -\t\t\t\t<< pipeConfig->first;\n> > +\t\t\t\t<< rawFormat;\n> > +\t\trawConfig.pixelFormat = rawFormat;\n> >  \t\tstatus = Adjusted;\n> >  \t}\n> >\n> > --\n> > 2.39.0\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 B7031BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Mar 2023 12:47:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D40306269C;\n\tThu,  2 Mar 2023 13:47:27 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 666386267E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Mar 2023 13:47:26 +0100 (CET)","from ideasonboard.com (host-87-18-61-24.retail.telecomitalia.it\n\t[87.18.61.24])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8EC2F56A;\n\tThu,  2 Mar 2023 13:47:25 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1677761247;\n\tbh=8aav7aEm6xt5Ztmdh1WVs+IJCSqQN+CMjBUIkakCR5A=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=wZHoztirDA7dqRpAlMu7UHS/MUzahiJ4umSRieDSoI/dtPy1kY8HKw4AMGMSN2wGQ\n\tzgo5iJ4xfoE1xI7BhzByhAL3blQMc4cL111TEuB2VOD141807K2EhlmALlEp5bYLnO\n\tOmO4XL4W37GbevJJBrWpK9qOWOK+h3OkRq9ZU7MLkSS7sjWy859uXOpl2pgpXFtlVu\n\tlnKO6ekn8QrEDgw84q0lqrADUosCJWZFs+tYMU8RbNQ105+TKCNOKoI1sXJBFCazs2\n\tviPD0+lpZ7Wg4Xo3yxnSgqMeLANG8d9/PURVqY7hAmwRePGpkzn/zNQK94WbXhpc6o\n\tmpu7HCIRjM6CQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1677761245;\n\tbh=8aav7aEm6xt5Ztmdh1WVs+IJCSqQN+CMjBUIkakCR5A=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=QI9MiQFwlic6SOcycs0efD4fn8Df1kOhY6eO8FFKzYFDuJYVds4yiNlZcJeKIV8FA\n\tM2VdMnODVB12OVlIX2U+vTzLtcKtbcUpKmIsL3Dk0OOMy/l9RdyMTERooz6RekqGs9\n\tPNHer3pPEGbWNJW6k1dHEIbXcinPvyglse2eg9sU="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"QI9MiQFw\"; dkim-atps=neutral","Date":"Thu, 2 Mar 2023 13:47:22 +0100","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<20230302124722.ua4cged3lxegqw5f@uno.localdomain>","References":"<20230129135830.27490-1-jacopo.mondi@ideasonboard.com>\n\t<20230129135830.27490-2-jacopo.mondi@ideasonboard.com>\n\t<ZACJ1xg6f+AxQ7uP@pyrite.rasen.tech>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<ZACJ1xg6f+AxQ7uP@pyrite.rasen.tech>","Subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: imx8-isi: Break-out\n\tRAW format selection","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>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26587,"web_url":"https://patchwork.libcamera.org/comment/26587/","msgid":"<c235e61e-70e9-3536-f506-b9b67cdb5de4@ideasonboard.com>","date":"2023-03-07T14:08:55","subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: imx8-isi: Break-out\n\tRAW format selection","submitter":{"id":156,"url":"https://patchwork.libcamera.org/api/people/156/","name":"Dan Scally","email":"dan.scally@ideasonboard.com"},"content":"Hi Jacopo\n\nOn 29/01/2023 13:58, Jacopo Mondi wrote:\n> The current implementation of the ISI pipeline handler handles\n> translation of PixelFormat to media bus formats from the sensor\n> through a centralized map.\n>\n> As the criteria to select the correct media bus code depend if the\n> output PixelFormat is a RAW Bayer format or not, start by splitting\n> the RAW media bus code procedure selection out by adding a method\n> for such purpose to the ISICameraData class.\n>\n> Add the function to the ISICameraData and not to the\n> ISICameraConfiguration because:\n> - The sensor is a property of CameraData\n> - The same function will be re-used by the ISIPipelineHandler\n>    during CameraConfiguration generation.\n>\n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n\n\nYou can add my tags to the series:\n\n\nReviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\n\nTested-by: Daniel Scally <dan.scally@ideasonboard.com>\n\n\nI tested with an imx219 so no YUV output from the sensor, but it at least identifies that properly \nand falls back to generateRawConfiguration(). Just a couple comments on the other patches which I'll \nreply to directly, but nothing particularly significant.\n\n>   src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 130 +++++++++++++------\n>   1 file changed, 90 insertions(+), 40 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> index 0c67e35dde73..72bc310d80ec 100644\n> --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> @@ -59,6 +59,8 @@ public:\n>   \t\treturn stream - &*streams_.begin();\n>   \t}\n>   \n> +\tunsigned int getRawMediaBusFormat(PixelFormat *pixelFormat) const;\n> +\n>   \tstd::unique_ptr<CameraSensor> sensor_;\n>   \tstd::unique_ptr<V4L2Subdevice> csis_;\n>   \n> @@ -174,6 +176,85 @@ int ISICameraData::init()\n>   \treturn 0;\n>   }\n>   \n> +/*\n> + * Get a RAW Bayer media bus format compatible with the requested pixelFormat.\n> + *\n> + * If the requested pixelFormat cannot be produced by the sensor adjust it to\n> + * the one corresponding to the media bus format with the largest bit-depth.\n> + */\n> +unsigned int ISICameraData::getRawMediaBusFormat(PixelFormat *pixelFormat) const\n> +{\n> +\tstd::vector<unsigned int> mbusCodes = sensor_->mbusCodes();\n> +\n> +\tconst std::map<PixelFormat, unsigned int> rawFormats = {\n> +\t\t{ formats::SBGGR8, MEDIA_BUS_FMT_SBGGR8_1X8 },\n> +\t\t{ formats::SGBRG8, MEDIA_BUS_FMT_SGBRG8_1X8 },\n> +\t\t{ formats::SGRBG8, MEDIA_BUS_FMT_SGRBG8_1X8 },\n> +\t\t{ formats::SRGGB8, MEDIA_BUS_FMT_SRGGB8_1X8 },\n> +\t\t{ formats::SBGGR10, MEDIA_BUS_FMT_SBGGR10_1X10 },\n> +\t\t{ formats::SGBRG10, MEDIA_BUS_FMT_SGBRG10_1X10 },\n> +\t\t{ formats::SGRBG10, MEDIA_BUS_FMT_SGRBG10_1X10 },\n> +\t\t{ formats::SRGGB10, MEDIA_BUS_FMT_SRGGB10_1X10 },\n> +\t\t{ formats::SBGGR12, MEDIA_BUS_FMT_SBGGR12_1X12 },\n> +\t\t{ formats::SGBRG12, MEDIA_BUS_FMT_SGBRG12_1X12 },\n> +\t\t{ formats::SGRBG12, MEDIA_BUS_FMT_SGRBG12_1X12 },\n> +\t\t{ formats::SRGGB12, MEDIA_BUS_FMT_SRGGB12_1X12 },\n> +\t};\n> +\n> +\t/*\n> +\t * Make sure the requested PixelFormat is supported in the above\n> +\t * map and the sensor can produce the compatible mbus code.\n> +\t */\n> +\tauto it = rawFormats.find(*pixelFormat);\n> +\tif (it != rawFormats.end() &&\n> +\t    std::count(mbusCodes.begin(), mbusCodes.end(), it->second))\n> +\t\treturn it->second;\n> +\n> +\tif (it == rawFormats.end())\n> +\t\tLOG(ISI, Warning) << pixelFormat\n> +\t\t\t\t  << \" not supported in ISI formats map.\";\n> +\n> +\t/*\n> +\t * The desired pixel format cannot be produced. Adjust it to the one\n> +\t * corresponding to the raw media bus format with the largest bit-depth\n> +\t * the sensor provides.\n> +\t */\n> +\tunsigned int sensorCode = 0;\n> +\tunsigned int maxDepth = 0;\n> +\t*pixelFormat = {};\n> +\n> +\tfor (unsigned int code : mbusCodes) {\n> +\t\t/* Make sure the media bus format is RAW Bayer. */\n> +\t\tconst BayerFormat &bayerFormat = BayerFormat::fromMbusCode(code);\n> +\t\tif (!bayerFormat.isValid())\n> +\t\t\tcontinue;\n> +\n> +\t\t/* Make sure the media format is supported. */\n> +\t\tit = std::find_if(rawFormats.begin(), rawFormats.end(),\n> +\t\t\t\t  [code](auto &rawFormat) {\n> +\t\t\t\t\t  return rawFormat.second == code;\n> +\t\t\t\t  });\n> +\n> +\t\tif (it == rawFormats.end()) {\n> +\t\t\tLOG(ISI, Warning) << bayerFormat\n> +\t\t\t\t\t  << \" not supported in ISI formats map.\";\n> +\t\t\tcontinue;\n> +\t\t}\n> +\n> +\t\t/* Pick the one with the largest bit depth. */\n> +\t\tif (bayerFormat.bitDepth > maxDepth) {\n> +\t\t\tmaxDepth = bayerFormat.bitDepth;\n> +\t\t\t*pixelFormat = it->first;\n> +\t\t\tsensorCode = code;\n> +\t\t}\n> +\t}\n> +\n> +\tif (!pixelFormat->isValid())\n> +\t\tLOG(ISI, Error) << \"Cannot find a supported RAW format\";\n> +\n> +\treturn sensorCode;\n> +}\n> +\n>   /* -----------------------------------------------------------------------------\n>    * Camera Configuration\n>    */\n> @@ -311,50 +392,19 @@ ISICameraConfiguration::validateRaw(std::set<Stream *> &availableStreams,\n>   \t */\n>   \tstd::vector<unsigned int> mbusCodes = data_->sensor_->mbusCodes();\n>   \tStreamConfiguration &rawConfig = config_[0];\n> +\tPixelFormat rawFormat = rawConfig.pixelFormat;\n>   \n> -\tbool supported = false;\n> -\tauto it = formatsMap_.find(rawConfig.pixelFormat);\n> -\tif (it != formatsMap_.end()) {\n> -\t\tunsigned int mbusCode = it->second.sensorCode;\n> -\n> -\t\tif (std::count(mbusCodes.begin(), mbusCodes.end(), mbusCode))\n> -\t\t\tsupported = true;\n> +\tunsigned int sensorCode = data_->getRawMediaBusFormat(&rawFormat);\n> +\tif (!sensorCode) {\n> +\t\tLOG(ISI, Error) << \"Cannot adjust RAW pixelformat \"\n> +\t\t\t\t<< rawConfig.pixelFormat;\n> +\t\treturn Invalid;\n>   \t}\n>   \n> -\tif (!supported) {\n> -\t\t/*\n> -\t\t * Adjust to the first mbus code supported by both the\n> -\t\t * sensor and the pipeline.\n> -\t\t */\n> -\t\tconst FormatMap::value_type *pipeConfig = nullptr;\n> -\t\tfor (unsigned int code : mbusCodes) {\n> -\t\t\tconst BayerFormat &bayerFormat = BayerFormat::fromMbusCode(code);\n> -\t\t\tif (!bayerFormat.isValid())\n> -\t\t\t\tcontinue;\n> -\n> -\t\t\tauto fmt = std::find_if(ISICameraConfiguration::formatsMap_.begin(),\n> -\t\t\t\t\t\tISICameraConfiguration::formatsMap_.end(),\n> -\t\t\t\t\t\t[code](const auto &isiFormat) {\n> -\t\t\t\t\t\t\tconst auto &pipe = isiFormat.second;\n> -\t\t\t\t\t\t\treturn pipe.sensorCode == code;\n> -\t\t\t\t\t\t});\n> -\n> -\t\t\tif (fmt == ISICameraConfiguration::formatsMap_.end())\n> -\t\t\t\tcontinue;\n> -\n> -\t\t\tpipeConfig = &(*fmt);\n> -\t\t\tbreak;\n> -\t\t}\n> -\n> -\t\tif (!pipeConfig) {\n> -\t\t\tLOG(ISI, Error) << \"Cannot adjust RAW format \"\n> -\t\t\t\t\t<< rawConfig.pixelFormat;\n> -\t\t\treturn Invalid;\n> -\t\t}\n> -\n> -\t\trawConfig.pixelFormat = pipeConfig->first;\n> +\tif (rawFormat != rawConfig.pixelFormat) {\n>   \t\tLOG(ISI, Debug) << \"RAW pixelformat adjusted to \"\n> -\t\t\t\t<< pipeConfig->first;\n> +\t\t\t\t<< rawFormat;\n> +\t\trawConfig.pixelFormat = rawFormat;\n>   \t\tstatus = Adjusted;\n>   \t}\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 EBBE1BDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  7 Mar 2023 14:09:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5D20662693;\n\tTue,  7 Mar 2023 15:09:00 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A4E3B6265E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Mar 2023 15:08:58 +0100 (CET)","from [192.168.0.43]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 321694AD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Mar 2023 15:08:58 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1678198140;\n\tbh=Ic++e2oqc929BToHqhxLTwa+5IKUrRC8BMIWOF+TaBU=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=DPOnpCsRR9Wr4PqGHU+4N/GMorWLkWs9NvRuVG35slkEFaKEuK+/5ELLMBzldjJAX\n\taLcVThh6fB7qdNni8neL7n+0B0s1rHcZb5Hw5i/weCJB29hId4f7zmlkapJsd9fjh6\n\tNlw9BW2HPegGnW4b87pPZ7xpTKtEuWlg9uX7TgxdDUS7nCH3ZlYbfA9HLvlB2xPCpa\n\tg8a0bueAPQRNwESoHSpSxi3W0DeHlJP7DTwWyAuaKIvEtpFAjaLYHUm6Lmhp2v2g/H\n\tzRdT0G9DuyWfRX0XXVAjC916NPSx4KLRLCcUhIw2CFESd2fXyEK0hhhWeUGACAE3iC\n\t2ArhmCtjX9b6g==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1678198138;\n\tbh=Ic++e2oqc929BToHqhxLTwa+5IKUrRC8BMIWOF+TaBU=;\n\th=Date:To:References:From:Subject:In-Reply-To:From;\n\tb=UL88GJIPQN5L2aNr/Jn5/tkIp4oxC4pRPFvoS9d+bENbrriJ10UlF4pIo/EcuwN8I\n\tIYpWksKmHwbcwaple2nKjAYU5chelupgJVcaw4hI4MHe0bTrNV8zVnK/0WsHSKZFNK\n\tUU0Q37FOG2Y0aYycPYlfeDJkARnp4zGe8KYuHfuY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"UL88GJIP\"; dkim-atps=neutral","Message-ID":"<c235e61e-70e9-3536-f506-b9b67cdb5de4@ideasonboard.com>","Date":"Tue, 7 Mar 2023 14:08:55 +0000","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101\n\tThunderbird/102.7.1","Content-Language":"en-US","To":"libcamera-devel@lists.libcamera.org","References":"<20230129135830.27490-1-jacopo.mondi@ideasonboard.com>\n\t<20230129135830.27490-2-jacopo.mondi@ideasonboard.com>","In-Reply-To":"<20230129135830.27490-2-jacopo.mondi@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: imx8-isi: Break-out\n\tRAW format selection","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>","From":"Dan Scally via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Dan Scally <dan.scally@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26639,"web_url":"https://patchwork.libcamera.org/comment/26639/","msgid":"<20230312162344.GY2545@pendragon.ideasonboard.com>","date":"2023-03-12T16:23:44","subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: imx8-isi: Break-out\n\tRAW format selection","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Sun, Jan 29, 2023 at 02:58:26PM +0100, Jacopo Mondi via libcamera-devel wrote:\n> The current implementation of the ISI pipeline handler handles\n> translation of PixelFormat to media bus formats from the sensor\n> through a centralized map.\n> \n> As the criteria to select the correct media bus code depend if the\n\ns/depend/depends on/\n\n> output PixelFormat is a RAW Bayer format or not, start by splitting\n> the RAW media bus code procedure selection out by adding a method\n\ns/method/function/\n\n> for such purpose to the ISICameraData class.\n> \n> Add the function to the ISICameraData and not to the\n> ISICameraConfiguration because:\n> - The sensor is a property of CameraData\n> - The same function will be re-used by the ISIPipelineHandler\n>   during CameraConfiguration generation.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 130 +++++++++++++------\n>  1 file changed, 90 insertions(+), 40 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> index 0c67e35dde73..72bc310d80ec 100644\n> --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n> @@ -59,6 +59,8 @@ public:\n>  \t\treturn stream - &*streams_.begin();\n>  \t}\n>  \n> +\tunsigned int getRawMediaBusFormat(PixelFormat *pixelFormat) const;\n> +\n>  \tstd::unique_ptr<CameraSensor> sensor_;\n>  \tstd::unique_ptr<V4L2Subdevice> csis_;\n>  \n> @@ -174,6 +176,85 @@ int ISICameraData::init()\n>  \treturn 0;\n>  }\n>  \n> +/*\n> + * Get a RAW Bayer media bus format compatible with the requested pixelFormat.\n> + *\n> + * If the requested pixelFormat cannot be produced by the sensor adjust it to\n> + * the one corresponding to the media bus format with the largest bit-depth.\n> + */\n> +unsigned int ISICameraData::getRawMediaBusFormat(PixelFormat *pixelFormat) const\n> +{\n> +\tstd::vector<unsigned int> mbusCodes = sensor_->mbusCodes();\n> +\n> +\tconst std::map<PixelFormat, unsigned int> rawFormats = {\n\nstatic const.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\t{ formats::SBGGR8, MEDIA_BUS_FMT_SBGGR8_1X8 },\n> +\t\t{ formats::SGBRG8, MEDIA_BUS_FMT_SGBRG8_1X8 },\n> +\t\t{ formats::SGRBG8, MEDIA_BUS_FMT_SGRBG8_1X8 },\n> +\t\t{ formats::SRGGB8, MEDIA_BUS_FMT_SRGGB8_1X8 },\n> +\t\t{ formats::SBGGR10, MEDIA_BUS_FMT_SBGGR10_1X10 },\n> +\t\t{ formats::SGBRG10, MEDIA_BUS_FMT_SGBRG10_1X10 },\n> +\t\t{ formats::SGRBG10, MEDIA_BUS_FMT_SGRBG10_1X10 },\n> +\t\t{ formats::SRGGB10, MEDIA_BUS_FMT_SRGGB10_1X10 },\n> +\t\t{ formats::SBGGR12, MEDIA_BUS_FMT_SBGGR12_1X12 },\n> +\t\t{ formats::SGBRG12, MEDIA_BUS_FMT_SGBRG12_1X12 },\n> +\t\t{ formats::SGRBG12, MEDIA_BUS_FMT_SGRBG12_1X12 },\n> +\t\t{ formats::SRGGB12, MEDIA_BUS_FMT_SRGGB12_1X12 },\n> +\t};\n> +\n> +\t/*\n> +\t * Make sure the requested PixelFormat is supported in the above\n> +\t * map and the sensor can produce the compatible mbus code.\n> +\t */\n> +\tauto it = rawFormats.find(*pixelFormat);\n> +\tif (it != rawFormats.end() &&\n> +\t    std::count(mbusCodes.begin(), mbusCodes.end(), it->second))\n> +\t\treturn it->second;\n> +\n> +\tif (it == rawFormats.end())\n> +\t\tLOG(ISI, Warning) << pixelFormat\n> +\t\t\t\t  << \" not supported in ISI formats map.\";\n> +\n> +\t/*\n> +\t * The desired pixel format cannot be produced. Adjust it to the one\n> +\t * corresponding to the raw media bus format with the largest bit-depth\n> +\t * the sensor provides.\n> +\t */\n> +\tunsigned int sensorCode = 0;\n> +\tunsigned int maxDepth = 0;\n> +\t*pixelFormat = {};\n> +\n> +\tfor (unsigned int code : mbusCodes) {\n> +\t\t/* Make sure the media bus format is RAW Bayer. */\n> +\t\tconst BayerFormat &bayerFormat = BayerFormat::fromMbusCode(code);\n> +\t\tif (!bayerFormat.isValid())\n> +\t\t\tcontinue;\n> +\n> +\t\t/* Make sure the media format is supported. */\n> +\t\tit = std::find_if(rawFormats.begin(), rawFormats.end(),\n> +\t\t\t\t  [code](auto &rawFormat) {\n> +\t\t\t\t\t  return rawFormat.second == code;\n> +\t\t\t\t  });\n> +\n> +\t\tif (it == rawFormats.end()) {\n> +\t\t\tLOG(ISI, Warning) << bayerFormat\n> +\t\t\t\t\t  << \" not supported in ISI formats map.\";\n> +\t\t\tcontinue;\n> +\t\t}\n> +\n> +\t\t/* Pick the one with the largest bit depth. */\n> +\t\tif (bayerFormat.bitDepth > maxDepth) {\n> +\t\t\tmaxDepth = bayerFormat.bitDepth;\n> +\t\t\t*pixelFormat = it->first;\n> +\t\t\tsensorCode = code;\n> +\t\t}\n> +\t}\n> +\n> +\tif (!pixelFormat->isValid())\n> +\t\tLOG(ISI, Error) << \"Cannot find a supported RAW format\";\n> +\n> +\treturn sensorCode;\n> +}\n> +\n>  /* -----------------------------------------------------------------------------\n>   * Camera Configuration\n>   */\n> @@ -311,50 +392,19 @@ ISICameraConfiguration::validateRaw(std::set<Stream *> &availableStreams,\n>  \t */\n>  \tstd::vector<unsigned int> mbusCodes = data_->sensor_->mbusCodes();\n>  \tStreamConfiguration &rawConfig = config_[0];\n> +\tPixelFormat rawFormat = rawConfig.pixelFormat;\n>  \n> -\tbool supported = false;\n> -\tauto it = formatsMap_.find(rawConfig.pixelFormat);\n> -\tif (it != formatsMap_.end()) {\n> -\t\tunsigned int mbusCode = it->second.sensorCode;\n> -\n> -\t\tif (std::count(mbusCodes.begin(), mbusCodes.end(), mbusCode))\n> -\t\t\tsupported = true;\n> +\tunsigned int sensorCode = data_->getRawMediaBusFormat(&rawFormat);\n> +\tif (!sensorCode) {\n> +\t\tLOG(ISI, Error) << \"Cannot adjust RAW pixelformat \"\n> +\t\t\t\t<< rawConfig.pixelFormat;\n> +\t\treturn Invalid;\n>  \t}\n>  \n> -\tif (!supported) {\n> -\t\t/*\n> -\t\t * Adjust to the first mbus code supported by both the\n> -\t\t * sensor and the pipeline.\n> -\t\t */\n> -\t\tconst FormatMap::value_type *pipeConfig = nullptr;\n> -\t\tfor (unsigned int code : mbusCodes) {\n> -\t\t\tconst BayerFormat &bayerFormat = BayerFormat::fromMbusCode(code);\n> -\t\t\tif (!bayerFormat.isValid())\n> -\t\t\t\tcontinue;\n> -\n> -\t\t\tauto fmt = std::find_if(ISICameraConfiguration::formatsMap_.begin(),\n> -\t\t\t\t\t\tISICameraConfiguration::formatsMap_.end(),\n> -\t\t\t\t\t\t[code](const auto &isiFormat) {\n> -\t\t\t\t\t\t\tconst auto &pipe = isiFormat.second;\n> -\t\t\t\t\t\t\treturn pipe.sensorCode == code;\n> -\t\t\t\t\t\t});\n> -\n> -\t\t\tif (fmt == ISICameraConfiguration::formatsMap_.end())\n> -\t\t\t\tcontinue;\n> -\n> -\t\t\tpipeConfig = &(*fmt);\n> -\t\t\tbreak;\n> -\t\t}\n> -\n> -\t\tif (!pipeConfig) {\n> -\t\t\tLOG(ISI, Error) << \"Cannot adjust RAW format \"\n> -\t\t\t\t\t<< rawConfig.pixelFormat;\n> -\t\t\treturn Invalid;\n> -\t\t}\n> -\n> -\t\trawConfig.pixelFormat = pipeConfig->first;\n> +\tif (rawFormat != rawConfig.pixelFormat) {\n>  \t\tLOG(ISI, Debug) << \"RAW pixelformat adjusted to \"\n> -\t\t\t\t<< pipeConfig->first;\n> +\t\t\t\t<< rawFormat;\n> +\t\trawConfig.pixelFormat = rawFormat;\n>  \t\tstatus = Adjusted;\n>  \t}\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 1014FBD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 12 Mar 2023 16:23:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7A4F262709;\n\tSun, 12 Mar 2023 17:23:44 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D0F0062705\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 12 Mar 2023 17:23:43 +0100 (CET)","from pendragon.ideasonboard.com (85-76-21-162-nat.elisa-mobile.fi\n\t[85.76.21.162])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 79BE5D5F;\n\tSun, 12 Mar 2023 17:23:42 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1678638224;\n\tbh=BPL1lraY3POnpXVTNqMbqz1CtdzVl9agS/RZv/E42A0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=xR4wlKXIbbiUaROEUB+IlxGyP1qVm7d5Ow2vcqLZUTUa1icZXiydrKNTBQ5rTsJPE\n\tkvrzD6h+yfSMFbp0Wrv1EYItdiR26HJzxYJ0gpVyuUvWiFqmJa+TkDb/CG5HIqx2b+\n\tYsujHsgmWWI04f2ZkeUrPxEGzIHmNPNYV3KBYsVXh6byoIFvrqmBb0T2ikc1AIPaGl\n\tL9Q4iLq7R8nXQ/ciRPnn7KYdMVEoXgvhXx3h04iUMzyniNnYDY5bOxM/wbev//ggF5\n\tOcbusILsrKuHZM7YtSDQgmhav6/JhFbYWwCnjwXo2cH9/tGmTRk6rdoubVoA2rip7H\n\tI/YkrUZ3vUTcQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1678638223;\n\tbh=BPL1lraY3POnpXVTNqMbqz1CtdzVl9agS/RZv/E42A0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=HnVBN4IctCYeflwfmNfamoEHDvZpXYeK9A+aL2mo2NSgLT0zExJY/5Hq3Ib0hgoZz\n\tXZx9+3RhzzolE/+KIEkGQpwdiW1X+0LJWgviTgoV3svyN2ixM503WoZ3VpspBgla3+\n\t8ugYotxpDMijZK3CQ6l+6CCiyc7tXRpE7gVVfo7I="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"HnVBN4Ic\"; dkim-atps=neutral","Date":"Sun, 12 Mar 2023 18:23:44 +0200","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Message-ID":"<20230312162344.GY2545@pendragon.ideasonboard.com>","References":"<20230129135830.27490-1-jacopo.mondi@ideasonboard.com>\n\t<20230129135830.27490-2-jacopo.mondi@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20230129135830.27490-2-jacopo.mondi@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: imx8-isi: Break-out\n\tRAW format selection","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]