{"id":17304,"url":"https://patchwork.libcamera.org/api/1.1/patches/17304/?format=json","web_url":"https://patchwork.libcamera.org/patch/17304/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20220905164600.31629-1-laurent.pinchart@ideasonboard.com>","date":"2022-09-05T16:46:00","name":"[libcamera-devel] libcamera: v4l2_subdevice: Silence warning for unknown metadata formats","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"93acbc02ddedf42296b7a783effbbb8aad813beb","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17304/mbox/","series":[{"id":3472,"url":"https://patchwork.libcamera.org/api/1.1/series/3472/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3472","date":"2022-09-05T16:46:00","name":"[libcamera-devel] libcamera: v4l2_subdevice: Silence warning for unknown metadata formats","version":1,"mbox":"https://patchwork.libcamera.org/series/3472/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17304/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17304/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 035E5C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  5 Sep 2022 16:46:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DC42662070;\n\tMon,  5 Sep 2022 18:46:17 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D4E061F9B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  5 Sep 2022 18:46:16 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CB5CE6BC;\n\tMon,  5 Sep 2022 18:46:15 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662396377;\n\tbh=sX+SW364UOIb7hY51DBBrAkECF0kgay59qUwzGuH7Ks=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=NJ2E7oRakEcNrk3BqgzDY/ekhWKEsU/2tbeQbilkas2selBYYXgm5LP8+7bUVE5Vr\n\teU6GYU2/9ihVyqt2LrX+f1uOTpPtFk9fWe0w71lEZKF0R85sKP09m95fl8aFR7qqtv\n\tx65hlmjyDk1zYLZbxY6wsmJkTt7G0kMpThC5Y+jepvlth03Igy2aMoemXw5y5m8ahC\n\tQGH1LNU9Nk1gJQbEKHtiNR2Eeim5PA0zF4x9lc1lulfLznxnJBKwC8QQZ5HNeLCPZj\n\t+xJPb33mHbnwFfUEnOUiaV81LtvH5wDwzzkcRQiO8KPyB9/FjkeTKCL97cTP9LW6kE\n\t2JM7m6Ll+0pQg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662396376;\n\tbh=sX+SW364UOIb7hY51DBBrAkECF0kgay59qUwzGuH7Ks=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=KZpzdgZUuyA0S8kQVixjy24PCxBevjWsEpJnmbx+XLlLpCsSy10PDytGtEpmeO+2w\n\tB55NCqUpPkaq6ZOsb/+7J0kCAaKRi2uKBgK45wkzlYPJTunyqgQNSMRpUEAT68NCiU\n\tuo6HJzZZmexq1VfTri9CSJP8sadwmCaeiZN/Gfik="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"KZpzdgZU\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Mon,  5 Sep 2022 19:46:00 +0300","Message-Id":"<20220905164600.31629-1-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] libcamera: v4l2_subdevice: Silence\n\twarning for unknown metadata formats","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Commit e297673e7686 (\"libcamera: v4l2_device: Adjust colorspace based on\npixel format\") has introduced a warning when trying to convert a color\nspace from V4L2 to libcamera if the media bus code is unknown. This was\nmeant to catch unknown image formats, but turned out to be also\ntriggered for metadata formats.\n\nColor spaces are not applicable to metadata formats, there should thus\nbe no warning. Fix it by skipping the color space translation and\nreturning std::nullopt directly if the kernel reports\nV4L2_COLORSPACE_DEFAULT. This doesn't introduce any change in behaviour\nother than getting rid of the warning, as the V4L2Device::toColorSpace()\nfunction returns std::nullopt alread in that case.\n\nFixes: e297673e7686 (\"libcamera: v4l2_device: Adjust colorspace based on pixel format\")\nReported-by: Naushir Patuck <naush@raspberrypi.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/v4l2_subdevice.h |  3 ++\n src/libcamera/v4l2_subdevice.cpp            | 51 ++++++++++-----------\n 2 files changed, 26 insertions(+), 28 deletions(-)\n\n\nbase-commit: da9bb8dea6821edcfd3464e8cba37ad4a91087d6","diff":"diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\nindex 00be17bb1465..69862de0585a 100644\n--- a/include/libcamera/internal/v4l2_subdevice.h\n+++ b/include/libcamera/internal/v4l2_subdevice.h\n@@ -101,6 +101,9 @@ protected:\n private:\n \tLIBCAMERA_DISABLE_COPY(V4L2Subdevice)\n \n+\tstd::optional<ColorSpace>\n+\ttoColorSpace(const v4l2_mbus_framefmt &format) const;\n+\n \tstd::vector<unsigned int> enumPadCodes(unsigned int pad);\n \tstd::vector<SizeRange> enumPadSizes(unsigned int pad,\n \t\t\t\t\t    unsigned int code);\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex 95bfde340d8c..f3a9a0096c6c 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -477,6 +477,27 @@ V4L2Subdevice::Formats V4L2Subdevice::formats(unsigned int pad)\n \treturn formats;\n }\n \n+std::optional<ColorSpace> V4L2Subdevice::toColorSpace(const v4l2_mbus_framefmt &format) const\n+{\n+\tif (format.colorspace == V4L2_COLORSPACE_DEFAULT)\n+\t\treturn std::nullopt;\n+\n+\tPixelFormatInfo::ColourEncoding colourEncoding;\n+\tauto iter = formatInfoMap.find(format.code);\n+\tif (iter != formatInfoMap.end()) {\n+\t\tcolourEncoding = iter->second.colourEncoding;\n+\t} else {\n+\t\tLOG(V4L2, Warning)\n+\t\t\t<< \"Unknown subdev format \"\n+\t\t\t<< utils::hex(format.code, 4)\n+\t\t\t<< \", defaulting to RGB encoding\";\n+\n+\t\tcolourEncoding = PixelFormatInfo::ColourEncodingRGB;\n+\t}\n+\n+\treturn V4L2Device::toColorSpace(format, colourEncoding);\n+}\n+\n /**\n  * \\brief Retrieve the image format set on one of the V4L2 subdevice pads\n  * \\param[in] pad The 0-indexed pad number the format is to be retrieved from\n@@ -503,20 +524,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-\n-\tPixelFormatInfo::ColourEncoding colourEncoding;\n-\tauto iter = formatInfoMap.find(subdevFmt.format.code);\n-\tif (iter != formatInfoMap.end()) {\n-\t\tcolourEncoding = iter->second.colourEncoding;\n-\t} else {\n-\t\tLOG(V4L2, Warning)\n-\t\t\t<< \"Unknown subdev format \"\n-\t\t\t<< utils::hex(subdevFmt.format.code, 4)\n-\t\t\t<< \", defaulting to RGB encoding\";\n-\n-\t\tcolourEncoding = PixelFormatInfo::ColourEncodingRGB;\n-\t}\n-\tformat->colorSpace = toColorSpace(subdevFmt.format, colourEncoding);\n+\tformat->colorSpace = toColorSpace(subdevFmt.format);\n \n \treturn 0;\n }\n@@ -562,20 +570,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-\n-\tPixelFormatInfo::ColourEncoding colourEncoding;\n-\tauto iter = formatInfoMap.find(subdevFmt.format.code);\n-\tif (iter != formatInfoMap.end()) {\n-\t\tcolourEncoding = iter->second.colourEncoding;\n-\t} else {\n-\t\tLOG(V4L2, Warning)\n-\t\t\t<< \"Unknown subdev format \"\n-\t\t\t<< utils::hex(subdevFmt.format.code, 4)\n-\t\t\t<< \", defaulting to RGB encoding\";\n-\n-\t\tcolourEncoding = PixelFormatInfo::ColourEncodingRGB;\n-\t}\n-\tformat->colorSpace = toColorSpace(subdevFmt.format, colourEncoding);\n+\tformat->colorSpace = toColorSpace(subdevFmt.format);\n \n \treturn 0;\n }\n","prefixes":["libcamera-devel"]}