<div dir="ltr"><div dir="ltr">Hi David,<div><br></div><div>Sorry, I realised this was not tagged by me so...</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 15 Jun 2021 at 11:51, David Plowman <<a href="mailto:david.plowman@raspberrypi.com">david.plowman@raspberrypi.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This commit adds support for monochrome (greyscale) raw sensors. These<br>
are sensors that have no colour filter array, so all pixels are the<br>
same and there are no distinct colour channels.<br>
<br>
These sensors still require many of an ISP's processing stages, such<br>
as denoise, tone mapping, but not those that involve colours (such as<br>
demosaic, or colour matrices).<br>
<br>
Signed-off-by: David Plowman <<a href="mailto:david.plowman@raspberrypi.com" target="_blank">david.plowman@raspberrypi.com</a>><br></blockquote><div><br></div><div>The mono case is a bit awkward, but really we must deal with it.</div><div><br></div><div>Reviewed-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com">naush@raspberrypi.com</a>></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
 include/libcamera/internal/bayer_format.h |  3 ++-<br>
 src/libcamera/bayer_format.cpp            | 14 ++++++++++++--<br>
 src/libcamera/camera_sensor.cpp           |  3 +++<br>
 src/libcamera/property_ids.yaml           |  4 ++++<br>
 4 files changed, 21 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h<br>
index 5b8c1dc9..723382d4 100644<br>
--- a/include/libcamera/internal/bayer_format.h<br>
+++ b/include/libcamera/internal/bayer_format.h<br>
@@ -23,7 +23,8 @@ public:<br>
                BGGR = 0,<br>
                GBRG = 1,<br>
                GRBG = 2,<br>
-               RGGB = 3<br>
+               RGGB = 3,<br>
+               MONO = 4<br>
        };<br>
<br>
        enum Packing : uint16_t {<br>
diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp<br>
index ed61202c..11355f14 100644<br>
--- a/src/libcamera/bayer_format.cpp<br>
+++ b/src/libcamera/bayer_format.cpp<br>
@@ -45,6 +45,8 @@ namespace libcamera {<br>
  * \brief G then R on the first row, B then G on the second row.<br>
  * \var BayerFormat::RGGB<br>
  * \brief R then G on the first row, G then B on the second row.<br>
+ * \var BayerFormat::MONO<br>
+ * \brief Monochrome image data, there is no colour filter array.<br>
  */<br>
<br>
 /**<br>
@@ -111,6 +113,8 @@ const std::map<BayerFormat, V4L2PixelFormat, BayerFormatComparator> bayerToV4l2{<br>
        { { BayerFormat::GBRG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) },<br>
        { { BayerFormat::GRBG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) },<br>
        { { BayerFormat::RGGB, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) },<br>
+       { { BayerFormat::MONO, 8, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_GREY) },<br>
+       { { BayerFormat::MONO, 10, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) },<br>
 };<br>
<br>
 const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{<br>
@@ -146,6 +150,8 @@ const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{<br>
        { MEDIA_BUS_FMT_SGBRG16_1X16, { BayerFormat::GBRG, 16, BayerFormat::None } },<br>
        { MEDIA_BUS_FMT_SGRBG16_1X16, { BayerFormat::GRBG, 16, BayerFormat::None } },<br>
        { MEDIA_BUS_FMT_SRGGB16_1X16, { BayerFormat::RGGB, 16, BayerFormat::None } },<br>
+       { MEDIA_BUS_FMT_Y8_1X8, { BayerFormat::MONO, 8, BayerFormat::None } },<br>
+       { MEDIA_BUS_FMT_Y10_1X10, { BayerFormat::MONO, 10, BayerFormat::None } },<br>
 };<br>
<br>
 } /* namespace */<br>
@@ -198,9 +204,10 @@ std::string BayerFormat::toString() const<br>
                "BGGR",<br>
                "GBRG",<br>
                "GRBG",<br>
-               "RGGB"<br>
+               "RGGB",<br>
+               "MONO"<br>
        };<br>
-       if (isValid() && order <= RGGB)<br>
+       if (isValid() && order <= MONO)<br>
                result = orderStrings[order];<br>
        else<br>
                return "INVALID";<br>
@@ -280,6 +287,9 @@ BayerFormat BayerFormat::transform(Transform t) const<br>
 {<br>
        BayerFormat result = *this;<br>
<br>
+       if (order == MONO)<br>
+               return result;<br>
+<br>
        /*<br>
         * Observe that flipping bit 0 of the Order enum performs a horizontal<br>
         * mirror on the Bayer pattern (e.g. RGGB goes to GRBG). Similarly,<br>
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp<br>
index 3e135353..fb67c15a 100644<br>
--- a/src/libcamera/camera_sensor.cpp<br>
+++ b/src/libcamera/camera_sensor.cpp<br>
@@ -427,6 +427,9 @@ int CameraSensor::initProperties()<br>
                case BayerFormat::RGGB:<br>
                        cfa = properties::draft::RGGB;<br>
                        break;<br>
+               case BayerFormat::MONO:<br>
+                       cfa = properties::draft::MONO;<br>
+                       break;<br>
                }<br>
<br>
                properties_.set(properties::draft::ColorFilterArrangement, cfa);<br>
diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml<br>
index 104e9aaf..87be68f7 100644<br>
--- a/src/libcamera/property_ids.yaml<br>
+++ b/src/libcamera/property_ids.yaml<br>
@@ -706,5 +706,9 @@ controls:<br>
           description: |<br>
             Sensor is not Bayer; output has 3 16-bit values for each pixel,<br>
             instead of just 1 16-bit value per pixel.<br>
+        - name: MONO<br>
+          value: 5<br>
+          description: |<br>
+            Sensor is not Bayer; output consits of a single colour channel.<br>
<br>
 ...<br>
-- <br>
2.20.1<br>
<br>
</blockquote></div></div>