[{"id":4413,"web_url":"https://patchwork.libcamera.org/comment/4413/","msgid":"<20200407232941.GC1716317@oden.dyn.berto.se>","date":"2020-04-07T23:29:41","subject":"Re: [libcamera-devel] [RFCv2 2/2] libcamera: camera_sensor: Add\n\tmethod to get sensor info","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-03-27 12:31:52 +0100, Jacopo Mondi wrote:\n> Add method to retrieve the CameraSensorInfo to the CameraSensor class.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/camera_sensor.cpp       | 127 ++++++++++++++++++++++++++\n>  src/libcamera/include/camera_sensor.h |   1 +\n>  2 files changed, 128 insertions(+)\n> \n> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> index df1d82d29f74..23204b05d062 100644\n> --- a/src/libcamera/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor.cpp\n> @@ -11,10 +11,13 @@\n>  #include <float.h>\n>  #include <iomanip>\n>  #include <limits.h>\n> +#include <map>\n>  #include <math.h>\n>  #include <memory>\n>  #include <string.h>\n>  \n> +#include <linux/v4l2-mediabus.h>\n> +\n>  #include <libcamera/property_ids.h>\n>  \n>  #include \"formats.h\"\n> @@ -30,6 +33,101 @@ namespace libcamera {\n>  \n>  LOG_DEFINE_CATEGORY(CameraSensor);\n>  \n> +namespace {\n> +\n> +const std::map<uint32_t, uint8_t> mbusToBppMap = {\n> +\t{ V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE, 16 },\n> +\t{ V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE, 16 },\n> +\t{ V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, 16 },\n> +\t{ V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, 16 },\n> +\t{ V4L2_MBUS_FMT_BGR565_2X8_BE, 16 },\n> +\t{ V4L2_MBUS_FMT_BGR565_2X8_LE, 16 },\n> +\t{ V4L2_MBUS_FMT_RGB565_2X8_BE, 16 },\n> +\t{ V4L2_MBUS_FMT_RGB565_2X8_LE, 16 },\n> +\t{ V4L2_MBUS_FMT_RGB666_1X18, 18 },\n> +\t{ V4L2_MBUS_FMT_RGB888_1X24, 24 },\n> +\t{ V4L2_MBUS_FMT_RGB888_2X12_BE, 24 },\n> +\t{ V4L2_MBUS_FMT_RGB888_2X12_LE, 24 },\n> +\t{ V4L2_MBUS_FMT_ARGB8888_1X32, 32 },\n> +\t{ V4L2_MBUS_FMT_Y8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_UV8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_UYVY8_1_5X8, 40 },\n> +\t{ V4L2_MBUS_FMT_VYUY8_1_5X8, 40 },\n> +\t{ V4L2_MBUS_FMT_YUYV8_1_5X8, 40 },\n> +\t{ V4L2_MBUS_FMT_YVYU8_1_5X8, 40 },\n> +\t{ V4L2_MBUS_FMT_UYVY8_2X8, 16 },\n> +\t{ V4L2_MBUS_FMT_VYUY8_2X8, 16 },\n> +\t{ V4L2_MBUS_FMT_YUYV8_2X8, 16 },\n> +\t{ V4L2_MBUS_FMT_YVYU8_2X8, 16 },\n> +\t{ V4L2_MBUS_FMT_Y10_1X10, 10 },\n> +\t{ V4L2_MBUS_FMT_UYVY10_2X10, 20 },\n> +\t{ V4L2_MBUS_FMT_VYUY10_2X10, 20 },\n> +\t{ V4L2_MBUS_FMT_YUYV10_2X10, 20 },\n> +\t{ V4L2_MBUS_FMT_YVYU10_2X10, 20 },\n> +\t{ V4L2_MBUS_FMT_Y12_1X12, 12 },\n> +\t{ V4L2_MBUS_FMT_UYVY8_1X16, 16 },\n> +\t{ V4L2_MBUS_FMT_VYUY8_1X16, 16 },\n> +\t{ V4L2_MBUS_FMT_YUYV8_1X16, 16 },\n> +\t{ V4L2_MBUS_FMT_YVYU8_1X16, 16 },\n> +\t{ V4L2_MBUS_FMT_YDYUYDYV8_1X16, 16 },\n> +\t{ V4L2_MBUS_FMT_UYVY10_1X20, 20 },\n> +\t{ V4L2_MBUS_FMT_VYUY10_1X20, 20 },\n> +\t{ V4L2_MBUS_FMT_YUYV10_1X20, 20 },\n> +\t{ V4L2_MBUS_FMT_YVYU10_1X20, 20 },\n> +\t{ V4L2_MBUS_FMT_YUV10_1X30, 30 },\n> +\t{ V4L2_MBUS_FMT_AYUV8_1X32, 32 },\n> +\t{ V4L2_MBUS_FMT_UYVY12_2X12, 24 },\n> +\t{ V4L2_MBUS_FMT_VYUY12_2X12, 24 },\n> +\t{ V4L2_MBUS_FMT_YUYV12_2X12, 24 },\n> +\t{ V4L2_MBUS_FMT_YVYU12_2X12, 24 },\n> +\t{ V4L2_MBUS_FMT_UYVY12_1X24, 24 },\n> +\t{ V4L2_MBUS_FMT_VYUY12_1X24, 24 },\n> +\t{ V4L2_MBUS_FMT_YUYV12_1X24, 24 },\n> +\t{ V4L2_MBUS_FMT_YVYU12_1X24, 24 },\n> +\t{ V4L2_MBUS_FMT_SBGGR8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_SGBRG8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_SGRBG8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_SRGGB8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_SBGGR10_ALAW8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_SGBRG10_ALAW8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_SRGGB10_ALAW8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE, 16 },\n> +\t{ V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, 16 },\n> +\t{ V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE, 16 },\n> +\t{ V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE, 16 },\n> +\t{ V4L2_MBUS_FMT_SBGGR10_1X10, 10 },\n> +\t{ V4L2_MBUS_FMT_SGBRG10_1X10, 10 },\n> +\t{ V4L2_MBUS_FMT_SGRBG10_1X10, 10 },\n> +\t{ V4L2_MBUS_FMT_SRGGB10_1X10, 10 },\n> +\t{ V4L2_MBUS_FMT_SBGGR12_1X12, 24 },\n> +\t{ V4L2_MBUS_FMT_SGBRG12_1X12, 24 },\n> +\t{ V4L2_MBUS_FMT_SGRBG12_1X12, 24 },\n> +\t{ V4L2_MBUS_FMT_SRGGB12_1X12, 24 },\n> +\t{ V4L2_MBUS_FMT_JPEG_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_S5C_UYVY_JPEG_1X8, 8 },\n> +\t{ V4L2_MBUS_FMT_AHSV8888_1X32, 32 },\n> +};\n> +\n> +uint8_t mbusToBpp(uint32_t mbus_code)\n> +{\n> +\tconst auto it = mbusToBppMap.find(mbus_code);\n> +\tif (it == mbusToBppMap.end()) {\n> +\t\tLOG(CameraSensor, Error) << \"Unsupported media bus format: \"\n> +\t\t\t\t\t << mbus_code;\n> +\t\t/* Return 8 to avoid divisions by 0. */\n> +\t\treturn 8;\n> +\t}\n> +\n> +\treturn it->second;\n> +}\n> +\n> +}; /* namespace */\n\nFor the same reason we have the pixel format lookup functions as static \nmembers of V4L2VideoDevice shall we try to keep this V4L2 specific stuff \nin the V4L2 related classes / files ?\n\nApart from this I like this patch.\n\n> +\n>  /**\n>   * \\struct CameraSensorInfo\n>   * \\brief Report the image sensor characteristics\n> @@ -482,6 +580,35 @@ int CameraSensor::setControls(ControlList *ctrls)\n>   * \\return The list of camera sensor properties\n>   */\n>  \n> +/**\n> + * \\brief Assemble and return the camera sensor info\n> + *\n> + * This method is meant to be overridden by CameraSensor specialized sub-classes\n> + * to report more detailed information about the camera sensor configuration.\n> + *\n> + * The base class implementation provides a stub implementation to support\n> + * camera sensor without an associated sub-class specialization.\n> + *\n> + * \\return An instance of CameraSensorInfo describing the sensor configuration\n> + */\n> +CameraSensorInfo CameraSensor::sensorInfo() const\n> +{\n> +\tCameraSensorInfo info{};\n> +\n> +\t/* Get format on pad #0 by default for generic camera sensor. */\n> +\tV4L2SubdeviceFormat format{};\n> +\tint ret = subdev_->getFormat(0, &format);\n> +\tif (ret)\n> +\t\treturn {};\n> +\n> +\tinfo.name = \"generic_sensor\";\n> +\tinfo.bitsPerPixel = mbusToBpp(format.mbus_code);\n> +\tinfo.outputSize.width = format.size.width;\n> +\tinfo.outputSize.height = format.size.height;\n> +\n> +\treturn info;\n> +}\n> +\n>  std::string CameraSensor::logPrefix() const\n>  {\n>  \treturn \"'\" + subdev_->entity()->name() + \"'\";\n> diff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h\n> index acc6022cf0e8..94374a4d01dd 100644\n> --- a/src/libcamera/include/camera_sensor.h\n> +++ b/src/libcamera/include/camera_sensor.h\n> @@ -69,6 +69,7 @@ public:\n>  \tint setControls(ControlList *ctrls);\n>  \n>  \tconst ControlList &properties() const { return properties_; }\n> +\tvirtual CameraSensorInfo sensorInfo() const;\n>  \n>  protected:\n>  \tstd::string logPrefix() const;\n> -- \n> 2.25.1\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x129.google.com (mail-lf1-x129.google.com\n\t[IPv6:2a00:1450:4864:20::129])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 20585600F3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Apr 2020 01:29:43 +0200 (CEST)","by mail-lf1-x129.google.com with SMTP id s13so3709609lfb.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 07 Apr 2020 16:29:43 -0700 (PDT)","from localhost (h-200-138.A463.priv.bahnhof.se. [176.10.200.138])\n\tby smtp.gmail.com with ESMTPSA id\n\tk4sm13829415lfo.47.2020.04.07.16.29.41\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 07 Apr 2020 16:29:41 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com header.b=\"oZlQ/LXm\"; \n\tdkim-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=Y3gSf/64NobHRX8iBT5m3EMfYUUQOEB9TE8+XWHUlLM=;\n\tb=oZlQ/LXm0nzHfjGQT8WV22rY6F0nWKS+jAuNlCxAugeU4qy+0R2TdLiW0n6r3iku5c\n\t+yxpF0PFdO8IWMuX8Lapf5NzVuOH+aSfPET2UDnOBiPaAl/EWlWpYh7JnBl1AmO4QnPs\n\t1sSJg6lXZ4i9zRDxIrOS6CGdbcm4b3WER2cNmQdtotgk2ryTYIEdLy4Rt2XBtcJULvQk\n\tYvy8xcpzjBzBrxwerLMJKO4awYPr7XQNH1/+3LUDJQSeayKyWXieD3OI/B6aDFl37doX\n\t4By5QZNwsCUoicMCbx9+CvDk0xhX7Sy8qHpMNtRow3OK1vtJvusFDycLSEcNPn3yjpV4\n\tXUYw==","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=Y3gSf/64NobHRX8iBT5m3EMfYUUQOEB9TE8+XWHUlLM=;\n\tb=bSPqNJGjWPavwWWBJE94MKJBgwIBe2UUASOL2oZGWpGCbPyYPAIDkBCgb3HvpF/c3n\n\tORSkm4qLBat7gElAM8aRINaCZYqfeb1evvDic7ESkF2B649YuAV/RI5sjwZjW8S/NbNL\n\t/ZzAWAXXCL5Gg23LQcjJf2IL0btmdUYoIxGn9qxt/WdSaBBRsgA87xLQkVrqi68GpTsG\n\thtS0nHzD+bF4cLBECQHscVr5wUkLg1cTvOLngxkyx3hd0Ny1oZEmqwJ8A3avzQQOVxDB\n\tmPF/+l67v2RuTZRPMAMcq8hOL3UZnIAMy4xEiFOtUIQfXwt7FiRR4YCkbg/rIsgzlFmf\n\tjt2A==","X-Gm-Message-State":"AGi0PuYsswLw7Lov3mT3Ay1v//1VZeRtS5rdFfA5qTJElBB+3uh5aX8O\n\tOrHzlYxcbM7o2Z9c3MhxBDU994qLPEA=","X-Google-Smtp-Source":"APiQypJb7ClSRMfLFqKwdNvNdxX87T+pexJU0CZTRPiKWfaY8Mo40xTelWrULftTK91do4kB31dEHg==","X-Received":"by 2002:ac2:58ec:: with SMTP id\n\tv12mr2782777lfo.215.1586302182521; \n\tTue, 07 Apr 2020 16:29:42 -0700 (PDT)","Date":"Wed, 8 Apr 2020 01:29:41 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200407232941.GC1716317@oden.dyn.berto.se>","References":"<20200327113152.348570-1-jacopo@jmondi.org>\n\t<20200327113152.348570-3-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200327113152.348570-3-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [RFCv2 2/2] libcamera: camera_sensor: Add\n\tmethod to get sensor info","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>","X-List-Received-Date":"Tue, 07 Apr 2020 23:29:43 -0000"}},{"id":4425,"web_url":"https://patchwork.libcamera.org/comment/4425/","msgid":"<20200408123527.thdxb6g4r72yuufw@uno.localdomain>","date":"2020-04-08T12:35:27","subject":"Re: [libcamera-devel] [RFCv2 2/2] libcamera: camera_sensor: Add\n\tmethod to get sensor info","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n\nOn Wed, Apr 08, 2020 at 01:29:41AM +0200, Niklas Söderlund wrote:\n> Hi Jacopo,\n>\n> Thanks for your work.\n>\n> On 2020-03-27 12:31:52 +0100, Jacopo Mondi wrote:\n> > Add method to retrieve the CameraSensorInfo to the CameraSensor class.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  src/libcamera/camera_sensor.cpp       | 127 ++++++++++++++++++++++++++\n> >  src/libcamera/include/camera_sensor.h |   1 +\n> >  2 files changed, 128 insertions(+)\n> >\n> > diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> > index df1d82d29f74..23204b05d062 100644\n> > --- a/src/libcamera/camera_sensor.cpp\n> > +++ b/src/libcamera/camera_sensor.cpp\n> > @@ -11,10 +11,13 @@\n> >  #include <float.h>\n> >  #include <iomanip>\n> >  #include <limits.h>\n> > +#include <map>\n> >  #include <math.h>\n> >  #include <memory>\n> >  #include <string.h>\n> >\n> > +#include <linux/v4l2-mediabus.h>\n> > +\n> >  #include <libcamera/property_ids.h>\n> >\n> >  #include \"formats.h\"\n> > @@ -30,6 +33,101 @@ namespace libcamera {\n> >\n> >  LOG_DEFINE_CATEGORY(CameraSensor);\n> >\n> > +namespace {\n> > +\n> > +const std::map<uint32_t, uint8_t> mbusToBppMap = {\n> > +\t{ V4L2_MBUS_FMT_RGB444_2X8_PADHI_BE, 16 },\n> > +\t{ V4L2_MBUS_FMT_RGB444_2X8_PADHI_LE, 16 },\n> > +\t{ V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE, 16 },\n> > +\t{ V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, 16 },\n> > +\t{ V4L2_MBUS_FMT_BGR565_2X8_BE, 16 },\n> > +\t{ V4L2_MBUS_FMT_BGR565_2X8_LE, 16 },\n> > +\t{ V4L2_MBUS_FMT_RGB565_2X8_BE, 16 },\n> > +\t{ V4L2_MBUS_FMT_RGB565_2X8_LE, 16 },\n> > +\t{ V4L2_MBUS_FMT_RGB666_1X18, 18 },\n> > +\t{ V4L2_MBUS_FMT_RGB888_1X24, 24 },\n> > +\t{ V4L2_MBUS_FMT_RGB888_2X12_BE, 24 },\n> > +\t{ V4L2_MBUS_FMT_RGB888_2X12_LE, 24 },\n> > +\t{ V4L2_MBUS_FMT_ARGB8888_1X32, 32 },\n> > +\t{ V4L2_MBUS_FMT_Y8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_UV8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_UYVY8_1_5X8, 40 },\n> > +\t{ V4L2_MBUS_FMT_VYUY8_1_5X8, 40 },\n> > +\t{ V4L2_MBUS_FMT_YUYV8_1_5X8, 40 },\n> > +\t{ V4L2_MBUS_FMT_YVYU8_1_5X8, 40 },\n> > +\t{ V4L2_MBUS_FMT_UYVY8_2X8, 16 },\n> > +\t{ V4L2_MBUS_FMT_VYUY8_2X8, 16 },\n> > +\t{ V4L2_MBUS_FMT_YUYV8_2X8, 16 },\n> > +\t{ V4L2_MBUS_FMT_YVYU8_2X8, 16 },\n> > +\t{ V4L2_MBUS_FMT_Y10_1X10, 10 },\n> > +\t{ V4L2_MBUS_FMT_UYVY10_2X10, 20 },\n> > +\t{ V4L2_MBUS_FMT_VYUY10_2X10, 20 },\n> > +\t{ V4L2_MBUS_FMT_YUYV10_2X10, 20 },\n> > +\t{ V4L2_MBUS_FMT_YVYU10_2X10, 20 },\n> > +\t{ V4L2_MBUS_FMT_Y12_1X12, 12 },\n> > +\t{ V4L2_MBUS_FMT_UYVY8_1X16, 16 },\n> > +\t{ V4L2_MBUS_FMT_VYUY8_1X16, 16 },\n> > +\t{ V4L2_MBUS_FMT_YUYV8_1X16, 16 },\n> > +\t{ V4L2_MBUS_FMT_YVYU8_1X16, 16 },\n> > +\t{ V4L2_MBUS_FMT_YDYUYDYV8_1X16, 16 },\n> > +\t{ V4L2_MBUS_FMT_UYVY10_1X20, 20 },\n> > +\t{ V4L2_MBUS_FMT_VYUY10_1X20, 20 },\n> > +\t{ V4L2_MBUS_FMT_YUYV10_1X20, 20 },\n> > +\t{ V4L2_MBUS_FMT_YVYU10_1X20, 20 },\n> > +\t{ V4L2_MBUS_FMT_YUV10_1X30, 30 },\n> > +\t{ V4L2_MBUS_FMT_AYUV8_1X32, 32 },\n> > +\t{ V4L2_MBUS_FMT_UYVY12_2X12, 24 },\n> > +\t{ V4L2_MBUS_FMT_VYUY12_2X12, 24 },\n> > +\t{ V4L2_MBUS_FMT_YUYV12_2X12, 24 },\n> > +\t{ V4L2_MBUS_FMT_YVYU12_2X12, 24 },\n> > +\t{ V4L2_MBUS_FMT_UYVY12_1X24, 24 },\n> > +\t{ V4L2_MBUS_FMT_VYUY12_1X24, 24 },\n> > +\t{ V4L2_MBUS_FMT_YUYV12_1X24, 24 },\n> > +\t{ V4L2_MBUS_FMT_YVYU12_1X24, 24 },\n> > +\t{ V4L2_MBUS_FMT_SBGGR8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_SGBRG8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_SGRBG8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_SRGGB8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_SBGGR10_ALAW8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_SGBRG10_ALAW8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_SGRBG10_ALAW8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_SRGGB10_ALAW8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_SBGGR10_DPCM8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_SGBRG10_DPCM8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_SRGGB10_DPCM8_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE, 16 },\n> > +\t{ V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, 16 },\n> > +\t{ V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE, 16 },\n> > +\t{ V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE, 16 },\n> > +\t{ V4L2_MBUS_FMT_SBGGR10_1X10, 10 },\n> > +\t{ V4L2_MBUS_FMT_SGBRG10_1X10, 10 },\n> > +\t{ V4L2_MBUS_FMT_SGRBG10_1X10, 10 },\n> > +\t{ V4L2_MBUS_FMT_SRGGB10_1X10, 10 },\n> > +\t{ V4L2_MBUS_FMT_SBGGR12_1X12, 24 },\n> > +\t{ V4L2_MBUS_FMT_SGBRG12_1X12, 24 },\n> > +\t{ V4L2_MBUS_FMT_SGRBG12_1X12, 24 },\n> > +\t{ V4L2_MBUS_FMT_SRGGB12_1X12, 24 },\n> > +\t{ V4L2_MBUS_FMT_JPEG_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_S5C_UYVY_JPEG_1X8, 8 },\n> > +\t{ V4L2_MBUS_FMT_AHSV8888_1X32, 32 },\n> > +};\n> > +\n> > +uint8_t mbusToBpp(uint32_t mbus_code)\n> > +{\n> > +\tconst auto it = mbusToBppMap.find(mbus_code);\n> > +\tif (it == mbusToBppMap.end()) {\n> > +\t\tLOG(CameraSensor, Error) << \"Unsupported media bus format: \"\n> > +\t\t\t\t\t << mbus_code;\n> > +\t\t/* Return 8 to avoid divisions by 0. */\n> > +\t\treturn 8;\n> > +\t}\n> > +\n> > +\treturn it->second;\n> > +}\n> > +\n> > +}; /* namespace */\n>\n> For the same reason we have the pixel format lookup functions as static\n> members of V4L2VideoDevice shall we try to keep this V4L2 specific stuff\n> in the V4L2 related classes / files ?\n\nIndeed, in my long due new version all of this has been moved to\nV4L2Subdevice.\n\nTo be precise, I have moved the table to v4l2_subdevice.cpp and\naugmented V4L2SubdeviceFormat class with a .bitsPerPixel() method, so\nthe table is not exposed outside and the bit depth is expressed as a\nproeprty of the format.\n\n>\n> Apart from this I like this patch.\n>\n\nThanks, will send v1 somewhen soon\n\n> > +\n> >  /**\n> >   * \\struct CameraSensorInfo\n> >   * \\brief Report the image sensor characteristics\n> > @@ -482,6 +580,35 @@ int CameraSensor::setControls(ControlList *ctrls)\n> >   * \\return The list of camera sensor properties\n> >   */\n> >\n> > +/**\n> > + * \\brief Assemble and return the camera sensor info\n> > + *\n> > + * This method is meant to be overridden by CameraSensor specialized sub-classes\n> > + * to report more detailed information about the camera sensor configuration.\n> > + *\n> > + * The base class implementation provides a stub implementation to support\n> > + * camera sensor without an associated sub-class specialization.\n> > + *\n> > + * \\return An instance of CameraSensorInfo describing the sensor configuration\n> > + */\n> > +CameraSensorInfo CameraSensor::sensorInfo() const\n> > +{\n> > +\tCameraSensorInfo info{};\n> > +\n> > +\t/* Get format on pad #0 by default for generic camera sensor. */\n> > +\tV4L2SubdeviceFormat format{};\n> > +\tint ret = subdev_->getFormat(0, &format);\n> > +\tif (ret)\n> > +\t\treturn {};\n> > +\n> > +\tinfo.name = \"generic_sensor\";\n> > +\tinfo.bitsPerPixel = mbusToBpp(format.mbus_code);\n> > +\tinfo.outputSize.width = format.size.width;\n> > +\tinfo.outputSize.height = format.size.height;\n> > +\n> > +\treturn info;\n> > +}\n> > +\n> >  std::string CameraSensor::logPrefix() const\n> >  {\n> >  \treturn \"'\" + subdev_->entity()->name() + \"'\";\n> > diff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h\n> > index acc6022cf0e8..94374a4d01dd 100644\n> > --- a/src/libcamera/include/camera_sensor.h\n> > +++ b/src/libcamera/include/camera_sensor.h\n> > @@ -69,6 +69,7 @@ public:\n> >  \tint setControls(ControlList *ctrls);\n> >\n> >  \tconst ControlList &properties() const { return properties_; }\n> > +\tvirtual CameraSensorInfo sensorInfo() const;\n> >\n> >  protected:\n> >  \tstd::string logPrefix() const;\n> > --\n> > 2.25.1\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":"<jacopo@jmondi.org>","Received":["from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A89246279B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Apr 2020 14:32:25 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id 03F4E200003;\n\tWed,  8 Apr 2020 12:32:24 +0000 (UTC)"],"Date":"Wed, 8 Apr 2020 14:35:27 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200408123527.thdxb6g4r72yuufw@uno.localdomain>","References":"<20200327113152.348570-1-jacopo@jmondi.org>\n\t<20200327113152.348570-3-jacopo@jmondi.org>\n\t<20200407232941.GC1716317@oden.dyn.berto.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200407232941.GC1716317@oden.dyn.berto.se>","Subject":"Re: [libcamera-devel] [RFCv2 2/2] libcamera: camera_sensor: Add\n\tmethod to get sensor info","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>","X-List-Received-Date":"Wed, 08 Apr 2020 12:32:25 -0000"}}]