{"id":17191,"url":"https://patchwork.libcamera.org/api/1.1/patches/17191/?format=json","web_url":"https://patchwork.libcamera.org/patch/17191/","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":"<20220823174314.14881-6-laurent.pinchart@ideasonboard.com>","date":"2022-08-23T17:43:13","name":"[libcamera-devel,5/6] libcamera: pipeline: rkisp1: Implement color space support","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"b62aef9876660a4d3d825b49af94f1a566425aef","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/17191/mbox/","series":[{"id":3432,"url":"https://patchwork.libcamera.org/api/1.1/series/3432/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3432","date":"2022-08-23T17:43:08","name":"libcamera: Add support for color spaces to rkisp1 pipeline handler","version":1,"mbox":"https://patchwork.libcamera.org/series/3432/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17191/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17191/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 63407C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 23 Aug 2022 17:43:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1A4DC61FD1;\n\tTue, 23 Aug 2022 19:43:32 +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 9301761FCC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Aug 2022 19:43:27 +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 20C582B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Aug 2022 19:43:27 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661276612;\n\tbh=+6ArkC7GrHsJp2uUZyWEqLadtOPYde0OPIZ9tIyl2+E=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Aphodrp7w+srTrscdwLEG5LQPssde7oY8ywsfySbuDtQiaDVXVOiftTtIhWJEOeM2\n\tvbOAOPAgrYlp9sQQxS2Nqa4fWlzTJ1fj0nbcuW8ggYchk2FZYUiDXLvstscvSM9JZU\n\tFXU647RhGTccFSLsNNIJs+RZ7ccY79bj2/qJLvVt1eLbV60gMxCv+zT7I5p0BPbVwk\n\trAyAnyK+5u0q4AxaAPsR1yscmA1Um8NBxJl6oFfySnDjG6/UkvKgpLeMbw5+WHV/Ym\n\td3uDSDHNuiEzGH/I7KivGr6628eP2hYnJzJFxZTrTc7or/bBAJrfCt7jPk1uIsjvsx\n\tLAIY2iGjFjgtA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661276607;\n\tbh=+6ArkC7GrHsJp2uUZyWEqLadtOPYde0OPIZ9tIyl2+E=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=F87uVHOWRH1sxJ03eS8F2H+BBrNVZFAR/QkZtIUvTFGmASZ/ar5/vdnpnYWFTxEZY\n\tZMcxN/73lQ43vzCHPG+A+FsuDDUcrRkzB+Y2vI2OLmZA5GhSWiu/vlZ3f4F068K+TC\n\txj8nDe6WvfRXEPKUlN4h/nC348VOXGUq1gFVK/xE="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"F87uVHOW\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 23 Aug 2022 20:43:13 +0300","Message-Id":"<20220823174314.14881-6-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220823174314.14881-1-laurent.pinchart@ideasonboard.com>","References":"<20220823174314.14881-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 5/6] libcamera: pipeline: rkisp1:\n\tImplement color space support","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":"Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 38 ++++++++++++++++++++----\n 1 file changed, 33 insertions(+), 5 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 03bbe6b467ae..25fbf9f1a0a9 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -18,6 +18,7 @@\n #include <libcamera/base/utils.h>\n \n #include <libcamera/camera.h>\n+#include <libcamera/color_space.h>\n #include <libcamera/control_ids.h>\n #include <libcamera/formats.h>\n #include <libcamera/framebuffer.h>\n@@ -416,11 +417,13 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n {\n \tconst CameraSensor *sensor = data_->sensor_.get();\n \tunsigned int pathCount = data_->selfPath_ ? 2 : 1;\n-\tStatus status = Valid;\n+\tStatus status;\n \n \tif (config_.empty())\n \t\treturn Invalid;\n \n+\tstatus = validateColorSpaces(ColorSpaceFlag::StreamsShareColorSpace);\n+\n \tif (transform != Transform::Identity) {\n \t\ttransform = Transform::Identity;\n \t\tstatus = Adjusted;\n@@ -547,21 +550,44 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera\n \tif (roles.empty())\n \t\treturn config;\n \n+\t/*\n+\t * As the ISP can't output different color spaces for the main and self\n+\t * path, pick a sensible default color space based on the role of the\n+\t * first stream and use it for all streams.\n+\t */\n+\tstd::optional<ColorSpace> colorSpace;\n+\n \tbool mainPathAvailable = true;\n \tbool selfPathAvailable = data->selfPath_;\n+\n \tfor (const StreamRole role : roles) {\n \t\tbool useMainPath;\n \n \t\tswitch (role) {\n-\t\tcase StreamRole::StillCapture: {\n+\t\tcase StreamRole::StillCapture:\n \t\t\tuseMainPath = mainPathAvailable;\n+\t\t\t/* JPEG encoders typically expect sYCC. */\n+\t\t\tif (!colorSpace)\n+\t\t\t\tcolorSpace = ColorSpace::Sycc;\n \t\t\tbreak;\n-\t\t}\n+\n \t\tcase StreamRole::Viewfinder:\n-\t\tcase StreamRole::VideoRecording: {\n \t\t\tuseMainPath = !selfPathAvailable;\n+\t\t\t/*\n+\t\t\t * sYCC is the YCbCr encoding of sRGB, which is commonly\n+\t\t\t * used by displays.\n+\t\t\t */\n+\t\t\tif (!colorSpace)\n+\t\t\t\tcolorSpace = ColorSpace::Sycc;\n \t\t\tbreak;\n-\t\t}\n+\n+\t\tcase StreamRole::VideoRecording:\n+\t\t\tuseMainPath = !selfPathAvailable;\n+\t\t\t/* Rec. 709 is a good default for HD video recording. */\n+\t\t\tif (!colorSpace)\n+\t\t\t\tcolorSpace = ColorSpace::Rec709;\n+\t\t\tbreak;\n+\n \t\tdefault:\n \t\t\tLOG(RkISP1, Warning)\n \t\t\t\t<< \"Requested stream role not supported: \" << role;\n@@ -580,6 +606,7 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera\n \t\t\tselfPathAvailable = false;\n \t\t}\n \n+\t\tcfg.colorSpace = colorSpace;\n \t\tconfig->addConfiguration(cfg);\n \t}\n \n@@ -642,6 +669,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n \tif (ret < 0)\n \t\treturn ret;\n \n+\tformat.colorSpace = config->at(0).colorSpace;\n \tret = isp_->setFormat(2, &format);\n \tif (ret < 0)\n \t\treturn ret;\n","prefixes":["libcamera-devel","5/6"]}