{"id":14801,"url":"https://patchwork.libcamera.org/api/patches/14801/?format=json","web_url":"https://patchwork.libcamera.org/patch/14801/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211126104045.4756-6-david.plowman@raspberrypi.com>","date":"2021-11-26T10:40:43","name":"[libcamera-devel,v7,5/7] libcamera: Support passing ColorSpaces to V4L2 subdevices","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"5e2083c1093f9a5c68b6905cf25f7277bdda780a","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14801/mbox/","series":[{"id":2761,"url":"https://patchwork.libcamera.org/api/series/2761/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2761","date":"2021-11-26T10:40:38","name":"Colour spaces","version":7,"mbox":"https://patchwork.libcamera.org/series/2761/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14801/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14801/checks/","tags":{},"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 3F64EBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Nov 2021 10:41:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EC98B60560;\n\tFri, 26 Nov 2021 11:41:12 +0100 (CET)","from mail-wr1-x429.google.com (mail-wr1-x429.google.com\n\t[IPv6:2a00:1450:4864:20::429])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C9CA604FB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Nov 2021 11:41:03 +0100 (CET)","by mail-wr1-x429.google.com with SMTP id s13so17706795wrb.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Nov 2021 02:41:03 -0800 (PST)","from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:e4a2:3070:eea4:e434])\n\tby smtp.gmail.com with ESMTPSA id\n\ty7sm5106795wrw.55.2021.11.26.02.41.02\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 26 Nov 2021 02:41:02 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"iZQrRgiR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=KwV+6mm5K3RAv5gTOEBbnCQylbB+KekglD21a7BiaKQ=;\n\tb=iZQrRgiR6ZrFPCS4p7NQbtEK41ZZf0ZAjqSrTf/khxdhBGpiyI4Wu9AO95rv5qGSBM\n\taEnyCCda+ykfsE/HwcKLVs44sQXgHmsJwPy9OkWBO6qTxbFz1BKK6mJ8cGah8XyOh74q\n\tmqTNrATMcJQegMqGqVx491N7rafzIA9dLhxDjhzVHL+spBRGxOCBcpxjUT9bAnsvKhEH\n\tudkqxqyDqKJVwlw78fqLuJQ12jg3qwgGBfBs1pG3w23rlSMqIzDFdpEQrs2R863y50mX\n\toGsWdeia4r73/AM/TQJvkjmK+CIRA8mK+1AAbtur0XnhznAIzRZNP7r9lTJ87JJ7rXWr\n\tKEhQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=KwV+6mm5K3RAv5gTOEBbnCQylbB+KekglD21a7BiaKQ=;\n\tb=CqoRQHVgmlPmU2FhVZoS9IXpffaUEZlsweCSOTGnITgUejbcFgFj4vNeENudrw9FKV\n\t7SRbAoeitm7CTBlXZxZ1gQBdDDD21Wh9OkwBuh3nJQKZM+MBhPf3/+DoYZW7npfW4Jox\n\tL9nlrdG3II38km9t6zI10TShxMF2dHwy0IBdfuz7u46Ror5xxlKBZBF9u+SgDH6DHbNL\n\tfZcsW5nMCQZpM2YyYBp/nIARVVzl9wA0zIS+VYlu9ZAu0UiH//2TlVu7x6Ja/5uYXPxH\n\tD4D/38+pbHd65RTAsxU/8hIe0yBei17aS9afgOxRMpaPA0EqdND4O1yJ0Wdf/yEfrzkX\n\tGdVA==","X-Gm-Message-State":"AOAM530aVwJNT6ckGJp+sBKj/WNHw+h1U7ATe7oJhyLsNm/G8p9d2Jha\n\t/v4LKoyTvUYPZlC25pf3GCbktw==","X-Google-Smtp-Source":"ABdhPJyMAgCYmxR1GKOQsnsmklzTRbU83Azk+bUxn0GRtZPmZLxJYmCl+ydIc9T+g365++vkn2dmlQ==","X-Received":"by 2002:adf:f990:: with SMTP id\n\tf16mr12778876wrr.128.1637923262920; \n\tFri, 26 Nov 2021 02:41:02 -0800 (PST)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tHans Verkuil <hverkuil-cisco@xs4all.nl>, Tomasz Figa <tfiga@google.com>, \n\tJacopo Mondi <jacopo@jmondi.org>,\n\tNaushir Patuck <naush@raspberrypi.com>, \n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 26 Nov 2021 10:40:43 +0000","Message-Id":"<20211126104045.4756-6-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.30.2","In-Reply-To":"<20211126104045.4756-1-david.plowman@raspberrypi.com>","References":"<20211126104045.4756-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v7 5/7] libcamera: Support passing\n\tColorSpaces to V4L2 subdevices","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The ColorSpace from the StreamConfiguration is now handled\nappropriately in the V4L2Subdevice.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n include/libcamera/internal/v4l2_subdevice.h |  2 ++\n src/libcamera/camera_sensor.cpp             |  1 +\n src/libcamera/v4l2_subdevice.cpp            | 25 ++++++++++++++++++++-\n 3 files changed, 27 insertions(+), 1 deletion(-)","diff":"diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\nindex 484fcfdd..e6fa451b 100644\n--- a/include/libcamera/internal/v4l2_subdevice.h\n+++ b/include/libcamera/internal/v4l2_subdevice.h\n@@ -14,6 +14,7 @@\n #include <libcamera/base/class.h>\n #include <libcamera/base/log.h>\n \n+#include <libcamera/color_space.h>\n #include <libcamera/geometry.h>\n \n #include \"libcamera/internal/formats.h\"\n@@ -27,6 +28,7 @@ class MediaDevice;\n struct V4L2SubdeviceFormat {\n \tuint32_t mbus_code;\n \tSize size;\n+\tstd::optional<ColorSpace> colorSpace;\n \n \tconst std::string toString() const;\n \tuint8_t bitsPerPixel() const;\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 9fdb8c09..6fcd1c1d 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -613,6 +613,7 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu\n \tV4L2SubdeviceFormat format{\n \t\t.mbus_code = bestCode,\n \t\t.size = *bestSize,\n+\t\t.colorSpace = ColorSpace::Raw,\n \t};\n \n \treturn format;\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex 023e2328..ee450c31 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -168,6 +168,21 @@ const std::map<uint32_t, V4L2SubdeviceFormatInfo> formatInfoMap = {\n  * \\brief The image size in pixels\n  */\n \n+/**\n+ * \\var V4L2SubdeviceFormat::colorSpace\n+ * \\brief The color space of the pixels\n+ *\n+ * The color space of the image. When setting the format this may be\n+ * unset, in which case the driver gets to use its default color space.\n+ * After being set, this value should contain the color space that\n+ * was actually used. If this value is unset, then the color space chosen\n+ * by the driver could not be represented by the ColorSpace class (and\n+ * should probably be added).\n+ *\n+ * It is up to the pipeline handler or application to check if the\n+ * resulting color space is acceptable.\n+ */\n+\n /**\n  * \\brief Assemble and return a string describing the format\n  * \\return A string describing the V4L2SubdeviceFormat\n@@ -399,6 +414,7 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n \tformat->size.width = subdevFmt.format.width;\n \tformat->size.height = subdevFmt.format.height;\n \tformat->mbus_code = subdevFmt.format.code;\n+\tformat->colorSpace = toColorSpace(subdevFmt.format);\n \n \treturn 0;\n }\n@@ -427,7 +443,13 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n \tsubdevFmt.format.code = format->mbus_code;\n \tsubdevFmt.format.field = V4L2_FIELD_NONE;\n \n-\tint ret = ioctl(VIDIOC_SUBDEV_S_FMT, &subdevFmt);\n+\tint ret = fromColorSpace(format->colorSpace, subdevFmt.format);\n+\tif (ret < 0)\n+\t\tLOG(V4L2, Warning)\n+\t\t\t<< \"Setting color space unrecognised by V4L2: \"\n+\t\t\t<< ColorSpace::toString(format->colorSpace);\n+\n+\tret = ioctl(VIDIOC_SUBDEV_S_FMT, &subdevFmt);\n \tif (ret) {\n \t\tLOG(V4L2, Error)\n \t\t\t<< \"Unable to set format on pad \" << pad\n@@ -438,6 +460,7 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n \tformat->size.width = subdevFmt.format.width;\n \tformat->size.height = subdevFmt.format.height;\n \tformat->mbus_code = subdevFmt.format.code;\n+\tformat->colorSpace = toColorSpace(subdevFmt.format);\n \n \treturn 0;\n }\n","prefixes":["libcamera-devel","v7","5/7"]}