[{"id":25150,"web_url":"https://patchwork.libcamera.org/comment/25150/","msgid":"<20220928072150.esnrnpgas6k62a5h@uno.localdomain>","date":"2022-09-28T07:21:50","subject":"Re: [libcamera-devel] [PATCH v1 2/4] pipeline: raspberrypi: Update\n\tnaming convention for tuning files","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"On Mon, Sep 26, 2022 at 01:29:09PM +0100, Naushir Patuck via libcamera-devel wrote:\n> Append \"_mono\" to the sensor name when generating the tuning filename for\n> monochrome sensor variants. So the new naming convention is as follows:\n>\n> <sensor_name>.json - Standard colour sensor variant\n> <sensor_name>_mono.json - Monochrom sensor variant\n>\n> Rename the existing imx296.json file to imx296_mono.json as this tuning file\n> is based on the monochrome variant of the IMX296.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  .../data/{imx296.json => imx296_mono.json}    |  0\n>  src/ipa/raspberrypi/data/meson.build          |  2 +-\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 19 +++++++++++++++----\n>  3 files changed, 16 insertions(+), 5 deletions(-)\n>  rename src/ipa/raspberrypi/data/{imx296.json => imx296_mono.json} (100%)\n>\n> diff --git a/src/ipa/raspberrypi/data/imx296.json b/src/ipa/raspberrypi/data/imx296_mono.json\n> similarity index 100%\n> rename from src/ipa/raspberrypi/data/imx296.json\n> rename to src/ipa/raspberrypi/data/imx296_mono.json\n> diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> index 211811cfa915..465a7a17ce6f 100644\n> --- a/src/ipa/raspberrypi/data/meson.build\n> +++ b/src/ipa/raspberrypi/data/meson.build\n> @@ -4,7 +4,7 @@ conf_files = files([\n>      'imx219.json',\n>      'imx219_noir.json',\n>      'imx290.json',\n> -    'imx296.json',\n> +    'imx296_mono.json',\n>      'imx378.json',\n>      'imx477.json',\n>      'imx477_noir.json',\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index dcd81650c32d..c068b07b31fe 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -67,6 +67,14 @@ SensorFormats populateSensorFormats(std::unique_ptr<CameraSensor> &sensor)\n>  \treturn formats;\n>  }\n>\n> +bool isMonoSensor(std::unique_ptr<CameraSensor> &sensor)\n> +{\n> +\tunsigned int mbusCode = sensor->mbusCodes()[0];\n> +\tBayerFormat bayer = BayerFormat::fromMbusCode(mbusCode);\n\nconst Bayerformat &bayer ?\n\n> +\n> +\treturn bayer.order == BayerFormat::Order::MONO;\n> +}\n> +\n>  PixelFormat mbusCodeToPixelFormat(unsigned int mbus_code,\n>  \t\t\t\t  BayerFormat::Packing packingReq)\n>  {\n> @@ -1551,10 +1559,13 @@ int RPiCameraData::loadIPA(ipa::RPi::IPAInitResult *result)\n>  \t */\n>  \tstd::string configurationFile;\n>  \tchar const *configFromEnv = utils::secure_getenv(\"LIBCAMERA_RPI_TUNING_FILE\");\n> -\tif (!configFromEnv || *configFromEnv == '\\0')\n> -\t\tconfigurationFile = ipa_->configurationFile(sensor_->model() + \".json\");\n> -\telse\n> -\t\tconfigurationFile = std::string(configFromEnv);\n> +\tstd::string sensorStr = sensor_->model();\n\nconst std::string &sensorStr =\n\nand maybe s/sensorStr/model ?\n\n\n> +\tif (!configFromEnv || *configFromEnv == '\\0') {\n> +\t\tif (isMonoSensor(sensor_))\n> +\t\t\tconfigurationFile += \"_mono\";\n> +\t\tconfigurationFile = ipa_->configurationFile(sensorStr + \".json\");\n> +\t} else\n> +\t\tconfigurationFile = sensorStr;\n\nDon't you need to append \"_mono\" in this case ?\n\nAlso the else branch needs braces too\n\n>\n>  \tIPASettings settings(configurationFile, sensor_->model());\n\nAs you now get a reference to sensor_->model() you can avoid the\nfunction call and reuse sensorStr (or 'model' if you like the rename).\n\nThanks\n  j\n\n>\n> --\n> 2.25.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 ABB19BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 28 Sep 2022 07:21:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 19FFF62296;\n\tWed, 28 Sep 2022 09:21:55 +0200 (CEST)","from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BEA6061F7A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 28 Sep 2022 09:21:53 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 2B46E240010;\n\tWed, 28 Sep 2022 07:21:52 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664349715;\n\tbh=Y8WQBW0cl0FqeJfBiVlnSJYepN8WNxqmEj7C384Nfjc=;\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=TIvOXb7E4ehVFmaro9GYhtmazkof+cITW98NyFsJ2N2uK6eW2PSoQc9tEYiy4xQsN\n\ttKUKjmP2mnCKCJ5ZOu6NGzh8voJ0S0Evw0u/DlHg2LEtwTyW+7GxZI49yXTQ+dnNV+\n\t3sW0G0zNdWjL05PWcep+BjVGMt7kvjlUoU1ALAb/5zoAfdf3/aL7xeITg4cHfYiY1Z\n\t4WiX0FTME3I7Lgh/5/a7bnYzFnHyi/CJoFIlmtueOOQVLC3nX12z3JaqW5BwmGXCCJ\n\tjlBCxTXU5aKpTjKmlG4Oopbz7/vu/GZBNiwtk6h/WvY1N4Cuhz6MXYFSdc+vOTAhIi\n\tZqbFgf8OkDaiw==","Date":"Wed, 28 Sep 2022 09:21:50 +0200","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<20220928072150.esnrnpgas6k62a5h@uno.localdomain>","References":"<20220926122911.13412-1-naush@raspberrypi.com>\n\t<20220926122911.13412-3-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220926122911.13412-3-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v1 2/4] pipeline: raspberrypi: Update\n\tnaming convention for tuning files","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@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":25154,"web_url":"https://patchwork.libcamera.org/comment/25154/","msgid":"<CAEmqJPrubcuMUSzUmXD2D2dipY9e5uPDpkXdG9w7JDuQ4oGO6w@mail.gmail.com>","date":"2022-09-28T07:52:57","subject":"Re: [libcamera-devel] [PATCH v1 2/4] pipeline: raspberrypi: Update\n\tnaming convention for tuning files","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Jacopo,\n\nThank you for the review.\n\n\nOn Wed, 28 Sept 2022 at 08:21, Jacopo Mondi <jacopo@jmondi.org> wrote:\n\n> On Mon, Sep 26, 2022 at 01:29:09PM +0100, Naushir Patuck via\n> libcamera-devel wrote:\n> > Append \"_mono\" to the sensor name when generating the tuning filename for\n> > monochrome sensor variants. So the new naming convention is as follows:\n> >\n> > <sensor_name>.json - Standard colour sensor variant\n> > <sensor_name>_mono.json - Monochrom sensor variant\n> >\n> > Rename the existing imx296.json file to imx296_mono.json as this tuning\n> file\n> > is based on the monochrome variant of the IMX296.\n> >\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > ---\n> >  .../data/{imx296.json => imx296_mono.json}    |  0\n> >  src/ipa/raspberrypi/data/meson.build          |  2 +-\n> >  .../pipeline/raspberrypi/raspberrypi.cpp      | 19 +++++++++++++++----\n> >  3 files changed, 16 insertions(+), 5 deletions(-)\n> >  rename src/ipa/raspberrypi/data/{imx296.json => imx296_mono.json} (100%)\n> >\n> > diff --git a/src/ipa/raspberrypi/data/imx296.json\n> b/src/ipa/raspberrypi/data/imx296_mono.json\n> > similarity index 100%\n> > rename from src/ipa/raspberrypi/data/imx296.json\n> > rename to src/ipa/raspberrypi/data/imx296_mono.json\n> > diff --git a/src/ipa/raspberrypi/data/meson.build\n> b/src/ipa/raspberrypi/data/meson.build\n> > index 211811cfa915..465a7a17ce6f 100644\n> > --- a/src/ipa/raspberrypi/data/meson.build\n> > +++ b/src/ipa/raspberrypi/data/meson.build\n> > @@ -4,7 +4,7 @@ conf_files = files([\n> >      'imx219.json',\n> >      'imx219_noir.json',\n> >      'imx290.json',\n> > -    'imx296.json',\n> > +    'imx296_mono.json',\n> >      'imx378.json',\n> >      'imx477.json',\n> >      'imx477_noir.json',\n> > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > index dcd81650c32d..c068b07b31fe 100644\n> > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > @@ -67,6 +67,14 @@ SensorFormats\n> populateSensorFormats(std::unique_ptr<CameraSensor> &sensor)\n> >       return formats;\n> >  }\n> >\n> > +bool isMonoSensor(std::unique_ptr<CameraSensor> &sensor)\n> > +{\n> > +     unsigned int mbusCode = sensor->mbusCodes()[0];\n> > +     BayerFormat bayer = BayerFormat::fromMbusCode(mbusCode);\n>\n> const Bayerformat &bayer ?\n>\n> > +\n> > +     return bayer.order == BayerFormat::Order::MONO;\n> > +}\n> > +\n> >  PixelFormat mbusCodeToPixelFormat(unsigned int mbus_code,\n> >                                 BayerFormat::Packing packingReq)\n> >  {\n> > @@ -1551,10 +1559,13 @@ int\n> RPiCameraData::loadIPA(ipa::RPi::IPAInitResult *result)\n> >        */\n> >       std::string configurationFile;\n> >       char const *configFromEnv =\n> utils::secure_getenv(\"LIBCAMERA_RPI_TUNING_FILE\");\n> > -     if (!configFromEnv || *configFromEnv == '\\0')\n> > -             configurationFile =\n> ipa_->configurationFile(sensor_->model() + \".json\");\n> > -     else\n> > -             configurationFile = std::string(configFromEnv);\n> > +     std::string sensorStr = sensor_->model();\n>\n> const std::string &sensorStr =\n>\n> and maybe s/sensorStr/model ?\n>\n>\n> > +     if (!configFromEnv || *configFromEnv == '\\0') {\n> > +             if (isMonoSensor(sensor_))\n> > +                     configurationFile += \"_mono\";\n> > +             configurationFile = ipa_->configurationFile(sensorStr +\n> \".json\");\n> > +     } else\n> > +             configurationFile = sensorStr;\n>\n> Don't you need to append \"_mono\" in this case ?\n>\n\nI don't want to append _mono here as I want to load the user specified\nfile without any modifications to the name.  It's up to the user/app to\nget this right if they want to override the tuning file :)\n\n\n>\n> Also the else branch needs braces too\n>\n> >\n> >       IPASettings settings(configurationFile, sensor_->model());\n>\n> As you now get a reference to sensor_->model() you can avoid the\n> function call and reuse sensorStr (or 'model' if you like the rename).\n>\n\nI'll apply your suggestions for the next revision.\n\nThanks!\nNaush\n\n\n>\n> Thanks\n>   j\n>\n> >\n> > --\n> > 2.25.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 C379FC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 28 Sep 2022 07:53:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1DE8E6229C;\n\tWed, 28 Sep 2022 09:53:15 +0200 (CEST)","from mail-lf1-x132.google.com (mail-lf1-x132.google.com\n\t[IPv6:2a00:1450:4864:20::132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9D41761F7A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 28 Sep 2022 09:53:13 +0200 (CEST)","by mail-lf1-x132.google.com with SMTP id j16so19182253lfg.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 28 Sep 2022 00:53:13 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664351595;\n\tbh=297xXxtfuEGFDHphTxtfRJ34ds6ecG349KTBiQwfsjE=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=iayuZ2C6S16mjzulJ834SBh/szF8O28nJCQpeH0j4VK6OCVPMlaauxV5w4lPdn2cO\n\tUY1wQR8DeJVSPGUMjOfylWEvy41SjIqAaWcsyNBboX6qwYCRFuqLGDYb2chaSabLmo\n\tCX752+6AqZKPd41X20iOwsxMFd/B8qR2p1QUf5RrwIyVRhV+6147kE9quM7LQKPBly\n\td2nmGKZ8NQqeT7KkGwdO+8GVGTYLMMsSdf4sN1jXN1p0iTbIq7/C+RqB9/rTHZ4yu2\n\tS1A3o8ZoN6PfeAp0SAzUOGUQ+Adu12zBf4Fgfecj+nWfPp3Q2/fxvFw9ya2mbUe7w0\n\t2GFk6k/6jS6mg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date;\n\tbh=u5mKP7/fevBcvGjIkxUn0KQ80tF3En7L1Gj5EpdLooU=;\n\tb=XTjB98NMw51S3qggtA/pq2YPUbnHI6XhtB9TQLdS2tK3xZoZyTVvhuc3z7fWcfgxar\n\tX2E+mvglP+ItLwGKV8+pyQoEebJGIVI3+hxHyMCRKfj3hxoCeXvzko0zeQp0M2geGwds\n\t6/l3KoUF/GsRl0pM1BpmfvDQTYUKQ9fkPoJCcCxCgvuDpZMLATMjJjmxJNoxLMGiRHvP\n\tgL/oOIH9IdUZFvizNjXPdnbKLUJtF6UbOC2g5Ug4ms95OI0G8QJGAq5IQgApUoWX6Jvw\n\tkQjZaNsL9JGMHyYs9jUlXmSl9EVcQPqmJRvnDrdmHXkF/CFnLG+RGz6B19LuBq66E/Ti\n\t++dw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"XTjB98NM\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date;\n\tbh=u5mKP7/fevBcvGjIkxUn0KQ80tF3En7L1Gj5EpdLooU=;\n\tb=XaepGW8MCmGP3rCrUJG7GXXLYOuqa07FtoDMbRezle91/4+3PbaT71ZJmCmlMCTz3T\n\tRlihqPr1CbjSscU2hehl4z7Cq1YuaPJgxjIH1mnESTAhm/yWrz6kqH8sE1mhWAuuEy0m\n\tUqXw/pNO3Sd4cLQFdwXM8MHYKQdSLnClZIz8auTEXlynPnNjHLEhxlQxrjXP7zI+y+v5\n\tj+yTAWdAagZRSRJVNfZBiKvTvIZ+qYiEz/kQYNcq4IYmQxsS6KTxKS1nnACneCszIdtz\n\tkJJr+PsH8YsswjmTHgjggFLppJ7g/vnQZwu7oWokSrCv8MnzITIyzx4y5O3f4xlOprMa\n\t0fNw==","X-Gm-Message-State":"ACrzQf0xjI8mjuJIbHMFOGINPwXyUnOSYDhNLOwsqcVip3RfrU2OlMsN\n\t5XXps93phpazIsUsYfSf1gkKmQBypmZKjSS6n4ji5w==","X-Google-Smtp-Source":"AMsMyM4/xgKS0LefNxJq+HnRHAHeFlBUMxH8J2fwNxG86BoHMNIe+RKFjtUTFUK6FjPBGi3ij3W3iIUlhAMGpKgbnAI=","X-Received":"by 2002:a05:6512:3409:b0:499:faa6:edb0 with SMTP id\n\ti9-20020a056512340900b00499faa6edb0mr12070108lfr.682.1664351592904;\n\tWed, 28 Sep 2022 00:53:12 -0700 (PDT)","MIME-Version":"1.0","References":"<20220926122911.13412-1-naush@raspberrypi.com>\n\t<20220926122911.13412-3-naush@raspberrypi.com>\n\t<20220928072150.esnrnpgas6k62a5h@uno.localdomain>","In-Reply-To":"<20220928072150.esnrnpgas6k62a5h@uno.localdomain>","Date":"Wed, 28 Sep 2022 08:52:57 +0100","Message-ID":"<CAEmqJPrubcuMUSzUmXD2D2dipY9e5uPDpkXdG9w7JDuQ4oGO6w@mail.gmail.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Content-Type":"multipart/alternative; boundary=\"0000000000007a0da105e9b80d06\"","Subject":"Re: [libcamera-devel] [PATCH v1 2/4] pipeline: raspberrypi: Update\n\tnaming convention for tuning files","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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]