[{"id":14353,"web_url":"https://patchwork.libcamera.org/comment/14353/","msgid":"<X+hsLu4cCBJW9Frm@wyvern>","date":"2020-12-27T11:12:46","subject":"Re: [libcamera-devel] [PATCH 4/6] libcamera: camera_sensor:\n\tRegister ColorFilterArrangement","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your work.\n\nOn 2020-12-23 18:47:07 +0100, Jacopo Mondi wrote:\n> Inspect the list of media bus codes supported by the camera sensor\n> in order to deduce the color filter arrangement and register the\n> ColorFilterArrangement draft property.\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/camera_sensor.cpp | 38 +++++++++++++++++++++++++++++----\n>  1 file changed, 34 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> index 1628ba9c892b..bdf4415fda0e 100644\n> --- a/src/libcamera/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor.cpp\n> @@ -17,6 +17,7 @@\n>  \n>  #include <libcamera/property_ids.h>\n>  \n> +#include \"libcamera/internal/bayer_format.h\"\n>  #include \"libcamera/internal/formats.h\"\n>  #include \"libcamera/internal/sysfs.h\"\n>  #include \"libcamera/internal/utils.h\"\n> @@ -178,10 +179,6 @@ int CameraSensor::init()\n>  \tif (ret < 0)\n>  \t\treturn ret;\n>  \n> -\tret = initProperties();\n> -\tif (ret)\n> -\t\treturn ret;\n> -\n>  \t/* Enumerate, sort and cache media bus codes and sizes. */\n>  \tformats_ = subdev_->formats(pad_);\n>  \tif (formats_.empty()) {\n> @@ -210,6 +207,10 @@ int CameraSensor::init()\n>  \t */\n>  \tresolution_ = sizes_.back();\n>  \n> +\tret = initProperties();\n> +\tif (ret)\n> +\t\treturn ret;\n> +\n>  \treturn 0;\n>  }\n>  \n> @@ -307,6 +308,35 @@ int CameraSensor::initProperties()\n>  \t\tproperties_.set(properties::PixelArrayActiveAreas, { crop });\n>  \t}\n>  \n> +\t/* Color filter array pattern, register only for RAW sensors. */\n> +\tfor (const auto &format : formats_) {\n> +\t\tunsigned int mbusCode = format.first;\n> +\t\tBayerFormat bayerFormat = BayerFormat::fromMbusCode(mbusCode);\n> +\t\tif (!bayerFormat.isValid())\n> +\t\t\tcontinue;\n> +\n> +\t\tint32_t cfa = -1;\n> +\t\tswitch (bayerFormat.order) {\n> +\t\tcase BayerFormat::BGGR:\n> +\t\t\tcfa = properties::draft::BGGR;\n> +\t\t\tbreak;\n> +\t\tcase BayerFormat::GBRG:\n> +\t\t\tcfa = properties::draft::GBRG;\n> +\t\t\tbreak;\n> +\t\tcase BayerFormat::GRBG:\n> +\t\t\tcfa = properties::draft::GRBG;\n> +\t\t\tbreak;\n> +\t\tcase BayerFormat::RGGB:\n> +\t\t\tcfa = properties::draft::RGGB;\n> +\t\t\tbreak;\n> +\t\tdefault:\n> +\t\t\tcontinue;\n\nnit: Would it make sens to have a fatal error here? It should not happen \nbut if we ever add a new Bayer filter arrangement it could easily be \nmissed to also add support for it here.\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> +\t\t}\n> +\n> +\t\tproperties_.set(properties::draft::ColorFilterArrangement, cfa);\n> +\t\tbreak;\n> +\t}\n> +\n>  \treturn 0;\n>  }\n>  \n> -- \n> 2.29.2\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 B5CDBC0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 27 Dec 2020 11:12:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 331C661FFA;\n\tSun, 27 Dec 2020 12:12:51 +0100 (CET)","from mail-lf1-x141.google.com (mail-lf1-x141.google.com\n\t[IPv6:2a00:1450:4864:20::141])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D7B3615B1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Dec 2020 12:12:49 +0100 (CET)","by mail-lf1-x141.google.com with SMTP id x20so18015967lfe.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Dec 2020 03:12:49 -0800 (PST)","from localhost ([185.224.57.161]) by smtp.gmail.com with ESMTPSA id\n\ts2sm4992280lfs.2.2020.12.27.03.12.47\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 27 Dec 2020 03:12:48 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"WltLnSVZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=g+iX99MCfpQgTlYIaB1/wU73gH8EjMuWVebiIjCN2f8=;\n\tb=WltLnSVZ8Vj3mFtaCJJvLbrg8KkZ5yNCAHNOBFB/NvBtjYdSxnrjHCYjt+vU7hry1w\n\t2oVMMq2iq8WVTlLmV9SFdJwwxeDr27ad+L1/No2fcvTUs1PBZW9neRHBe63SbjbF/pQZ\n\tu3azRiMtPCZG0tktiOAAloEin0Wu+gEEhWQ3T2l2KLDymYTgCSJgM+C/Tk1ecF/P5YWl\n\tDxi6NnMFy7Fnao8JCXmOATnkAPthn+SI0xffIkrFgmJhLT/uU1ja6Tg2R2FUyHweNXff\n\tgXFLTvqlTPioJVXmNajNBLiL/2siKZUXLtORsJmDZEwxt77VGN+JZ4q38FwHG3L9Sdxr\n\tayag==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=g+iX99MCfpQgTlYIaB1/wU73gH8EjMuWVebiIjCN2f8=;\n\tb=r1UYVGDtNnYQKLS2y1j4y5WwYy3vJFNKEuLvKJS4AhPToXVan3CM6YqR89IlZmFNm1\n\tfkkBpdHAQp8bDjuRz3vGzX5Qmmf1TTaox8aY3uIuiw79aAHRAShSO8EjSRnt8dvBswnY\n\twyg9PWKYS+1q3ERUgjCYmmqABHphpUyqCcHLBQinJ5ieyN6HxnINH494RSl2kHiXMnn+\n\t0AhpgbEbpbgWUIUfSqlBUBo9qeKVE9pZNEuxAjmFa3i+IRxO13fHlajHgn2ZHIZEO820\n\tSAotAJmAqz0DjDG1hwRNDLWNaaSIicNyi5NWT2d3CHWUMCMBhDH6DkkrjmqAIf97gtGV\n\tZCaA==","X-Gm-Message-State":"AOAM530zg31FpVqtHy/G5pq1fSY0bqPNLYXMefwXubOflYss9DpP7+gm\n\tLdWiI7YD5wlnXo966yD8dxKoae568B+hbw==","X-Google-Smtp-Source":"ABdhPJwUksHefNAkJZHlJ9PaL3m2s5pelxyMpwTPb7Ptl5S/shrHhL/uLppGjOG8W+06YqwIMMR5Nw==","X-Received":"by 2002:a2e:3a17:: with SMTP id\n\th23mr19968002lja.435.1609067568957; \n\tSun, 27 Dec 2020 03:12:48 -0800 (PST)","Date":"Sun, 27 Dec 2020 12:12:46 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<X+hsLu4cCBJW9Frm@wyvern>","References":"<20201223174709.45457-1-jacopo@jmondi.org>\n\t<20201223174709.45457-5-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201223174709.45457-5-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH 4/6] libcamera: camera_sensor:\n\tRegister ColorFilterArrangement","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@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":14377,"web_url":"https://patchwork.libcamera.org/comment/14377/","msgid":"<20201228101224.yxhryb4jwypiusbz@uno.localdomain>","date":"2020-12-28T10:12:24","subject":"Re: [libcamera-devel] [PATCH 4/6] libcamera: camera_sensor:\n\tRegister ColorFilterArrangement","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n\nOn Sun, Dec 27, 2020 at 12:12:46PM +0100, Niklas Söderlund wrote:\n> Hi Jacopo,\n>\n> Thanks for your work.\n>\n> On 2020-12-23 18:47:07 +0100, Jacopo Mondi wrote:\n> > Inspect the list of media bus codes supported by the camera sensor\n> > in order to deduce the color filter arrangement and register the\n> > ColorFilterArrangement draft property.\n> >\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  src/libcamera/camera_sensor.cpp | 38 +++++++++++++++++++++++++++++----\n> >  1 file changed, 34 insertions(+), 4 deletions(-)\n> >\n> > diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> > index 1628ba9c892b..bdf4415fda0e 100644\n> > --- a/src/libcamera/camera_sensor.cpp\n> > +++ b/src/libcamera/camera_sensor.cpp\n> > @@ -17,6 +17,7 @@\n> >\n> >  #include <libcamera/property_ids.h>\n> >\n> > +#include \"libcamera/internal/bayer_format.h\"\n> >  #include \"libcamera/internal/formats.h\"\n> >  #include \"libcamera/internal/sysfs.h\"\n> >  #include \"libcamera/internal/utils.h\"\n> > @@ -178,10 +179,6 @@ int CameraSensor::init()\n> >  \tif (ret < 0)\n> >  \t\treturn ret;\n> >\n> > -\tret = initProperties();\n> > -\tif (ret)\n> > -\t\treturn ret;\n> > -\n> >  \t/* Enumerate, sort and cache media bus codes and sizes. */\n> >  \tformats_ = subdev_->formats(pad_);\n> >  \tif (formats_.empty()) {\n> > @@ -210,6 +207,10 @@ int CameraSensor::init()\n> >  \t */\n> >  \tresolution_ = sizes_.back();\n> >\n> > +\tret = initProperties();\n> > +\tif (ret)\n> > +\t\treturn ret;\n> > +\n> >  \treturn 0;\n> >  }\n> >\n> > @@ -307,6 +308,35 @@ int CameraSensor::initProperties()\n> >  \t\tproperties_.set(properties::PixelArrayActiveAreas, { crop });\n> >  \t}\n> >\n> > +\t/* Color filter array pattern, register only for RAW sensors. */\n> > +\tfor (const auto &format : formats_) {\n> > +\t\tunsigned int mbusCode = format.first;\n> > +\t\tBayerFormat bayerFormat = BayerFormat::fromMbusCode(mbusCode);\n> > +\t\tif (!bayerFormat.isValid())\n> > +\t\t\tcontinue;\n> > +\n> > +\t\tint32_t cfa = -1;\n> > +\t\tswitch (bayerFormat.order) {\n> > +\t\tcase BayerFormat::BGGR:\n> > +\t\t\tcfa = properties::draft::BGGR;\n> > +\t\t\tbreak;\n> > +\t\tcase BayerFormat::GBRG:\n> > +\t\t\tcfa = properties::draft::GBRG;\n> > +\t\t\tbreak;\n> > +\t\tcase BayerFormat::GRBG:\n> > +\t\t\tcfa = properties::draft::GRBG;\n> > +\t\t\tbreak;\n> > +\t\tcase BayerFormat::RGGB:\n> > +\t\t\tcfa = properties::draft::RGGB;\n> > +\t\t\tbreak;\n> > +\t\tdefault:\n> > +\t\t\tcontinue;\n>\n> nit: Would it make sens to have a fatal error here? It should not happen\n> but if we ever add a new Bayer filter arrangement it could easily be\n> missed to also add support for it here.\n\nIt shouldn't happen, but we would indeed lose it if it does, you're right.\n\nActually, if we add a new bayer ordering (as in a new\nBayerFormat::Order entry) and I drop the default, we can rely on the\ncompiler's -Wswitch flag that complains if we don't handle all\npossible values in an enumeration inside a switch. I could drop the\ndefault case, and remove the 'cfa' variable intialization, which was\nnot required in first place.\n\nThanks\n  j\n\n>\n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n>\n> > +\t\t}\n> > +\n> > +\t\tproperties_.set(properties::draft::ColorFilterArrangement, cfa);\n> > +\t\tbreak;\n> > +\t}\n> > +\n> >  \treturn 0;\n> >  }\n> >\n> > --\n> > 2.29.2\n> >\n> > _______________________________________________\n> > libcamera-devel mailing list\n> > libcamera-devel@lists.libcamera.org\n> > https://lists.libcamera.org/listinfo/libcamera-devel\n>\n> --\n> Regards,\n> Niklas Söderlund","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 A72E3C0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Dec 2020 10:12:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0FD89615B2;\n\tMon, 28 Dec 2020 11:12:12 +0100 (CET)","from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3759F60525\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Dec 2020 11:12:11 +0100 (CET)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 9B2C91BF203;\n\tMon, 28 Dec 2020 10:12:10 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Mon, 28 Dec 2020 11:12:24 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Message-ID":"<20201228101224.yxhryb4jwypiusbz@uno.localdomain>","References":"<20201223174709.45457-1-jacopo@jmondi.org>\n\t<20201223174709.45457-5-jacopo@jmondi.org>\n\t<X+hsLu4cCBJW9Frm@wyvern>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<X+hsLu4cCBJW9Frm@wyvern>","Subject":"Re: [libcamera-devel] [PATCH 4/6] libcamera: camera_sensor:\n\tRegister ColorFilterArrangement","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@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]