{"id":19138,"url":"https://patchwork.libcamera.org/api/1.1/patches/19138/?format=json","web_url":"https://patchwork.libcamera.org/patch/19138/","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":"<20231013074841.16972-15-naush@raspberrypi.com>","date":"2023-10-13T07:48:35","name":"[libcamera-devel,v2,14/20] pipeline: rpi: Move flip handling validation code","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"a9d271c908e219c316d7508d1de73bea7e14c628","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19138/mbox/","series":[{"id":4049,"url":"https://patchwork.libcamera.org/api/1.1/series/4049/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4049","date":"2023-10-13T07:48:21","name":"Raspberry Pi: Preliminary PiSP support","version":2,"mbox":"https://patchwork.libcamera.org/series/4049/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19138/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19138/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 0DCB5C32BF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Oct 2023 07:49:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7EF1A629AD;\n\tFri, 13 Oct 2023 09:49:05 +0200 (CEST)","from mail-ed1-x529.google.com (mail-ed1-x529.google.com\n\t[IPv6:2a00:1450:4864:20::529])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6218962996\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 09:48:57 +0200 (CEST)","by mail-ed1-x529.google.com with SMTP id\n\t4fb4d7f45d1cf-53e07db272cso2583096a12.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 00:48:57 -0700 (PDT)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tm16-20020a7bca50000000b003fee6e170f9sm1791890wml.45.2023.10.13.00.48.55\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 13 Oct 2023 00:48:56 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1697183345;\n\tbh=7l6NP7L67GZaRoxAF4LGABUZZ0aXJk6H7Yf/x8c+BeE=;\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=tBnTyZHjpMf43DjZt/9KvL/EzSUByY4C3ZxIj0Gv9qOtiHy5mpxYwsR6YiLFnVvWD\n\tG/DXXl1/Q8rTkq+2EnN7/6OZmwh9aqc8HayEkr5QqJbblw2zRtSc+s1nZKpDwoiy3e\n\tdzjNcad9Repp0HHVhEnyyh5JX84whMRyYxegT0WskuzDXi0UoRTdYG1AMCXGwv+/4/\n\tFzwkuBn8xLj3hnev+BfwaSvw1EFMt3SHT6G9USfHrZ7/PRWZhIYwFoBOaXwHAhxyoD\n\tKUGnA9SyzwXnWvxuqtofsmyMhER4zJc5zPKsRq2Wk7nbLw8n6LZXi/cn+D8WNPpCAT\n\tKn8uIIkpkNL/A==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1697183336; x=1697788136;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=63ebRbhpy61ExuOGtyPGxJ72VDfar8BgQdTJMUJHTGA=;\n\tb=phGEV+a9+E9uNi6TcOXycUdMw/V1rzoSLs1lmarBoxBp16QcIaQR1TlRbWpwUHtU4A\n\tduAaMVHC0HhoOvlQVjOi4PZTAe2R661gVjDKy0RQFHIfHpK3HPGoKkzg0gsysC6OGee+\n\ttyBhqVV9v9E3Pf7WGqffvZLg8TtPP9a0SvgmExYrbBVZEyZekk/Gmn+VEuesy95sm4b3\n\tzT0n1ovTICHULWNs7TUGjam1M2w6JnacuJern3ubePMzDwnK5JDKs0fp138OKpGosQPM\n\tgrcR8XHprvBM6RFN8FrS0TursTahdYH00lTICrACzIie+/13neHkGmwP432kXrhUSHKY\n\tppcA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"phGEV+a9\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1697183336; x=1697788136;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=63ebRbhpy61ExuOGtyPGxJ72VDfar8BgQdTJMUJHTGA=;\n\tb=j8jLbGFJPYZ++1dxULAVyTk0V59NMNWcBPyikGBqYOpO1XsGCMmpL2Kk+SrOrgPWew\n\tNou4nI8Ht1UuUslKn6An0Gcqqk30uAkw262mn4tV8csOOChuleT4hOIonOyJboe28g9T\n\twE3zvX0VidjdJYL0OyQ8wbtqNnxZQPOOpmHTTPwKmcWou2h83S19W+KKRfHClmAx4TZP\n\tUBL8lHkFJ1DUBrHshQCHpJ3T8Ll4CEe7Gd96G7T4+oWLZj7DidmkcblHzAoK0+FOLHuU\n\ttCNYLmgLsB7y3RQmjYaKWHn9mbY6+tYbv5nFMtG1Wus1oCJ8xtWvEs7S4kh62kJAmqpT\n\tIDeg==","X-Gm-Message-State":"AOJu0Yyygg5yGnI87L3JTvmwaM+HuC2FXtUQ9ndTFNYMRvhZnFUtep79\n\tkhPa8smIryPZZMNov72sBGre6pv4qtUvdswcxCqMhw==","X-Google-Smtp-Source":"AGHT+IGg3FNEK1LMdMpe/D7KHmPVr0i1sISg+6F0gH0q6bDwSJEv2Azac70ii/Fa6erPbGRh4KDW2g==","X-Received":"by 2002:a17:907:2e19:b0:994:4095:3abf with SMTP id\n\tig25-20020a1709072e1900b0099440953abfmr23095951ejc.14.1697183336654; \n\tFri, 13 Oct 2023 00:48:56 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 13 Oct 2023 08:48:35 +0100","Message-Id":"<20231013074841.16972-15-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20231013074841.16972-1-naush@raspberrypi.com>","References":"<20231013074841.16972-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 14/20] pipeline: rpi: Move flip\n\thandling validation code","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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Move the handling of Bayer order changes due to flips to run before\nplatformValidate(). This removes the need for this code to be split\nbetween platformValidate() and validate() as it is right now.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n .../pipeline/rpi/common/pipeline_base.cpp     | 43 +++++++++++++------\n src/libcamera/pipeline/rpi/vc4/vc4.cpp        | 14 +-----\n 2 files changed, 31 insertions(+), 26 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex 825eae80d014..7c88b87e0608 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -231,16 +231,12 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\t}\n \t}\n \n-\t/* Do any platform specific fixups. */\n-\tstatus = data_->platformValidate(this);\n-\tif (status == Invalid)\n-\t\treturn Invalid;\n-\n-\t/* Further fixups on the RAW streams. */\n+\t/* Start with some initial generic RAW stream adjustments. */\n \tfor (auto &raw : rawStreams_) {\n-\t\tint ret = raw.dev->tryFormat(&raw.format);\n-\t\tif (ret)\n-\t\t\treturn Invalid;\n+\t\tStreamConfiguration *rawStream = raw.cfg;\n+\n+\t\t/* Adjust the RAW stream to match the computed sensor format. */\n+\t\tBayerFormat sensorBayer = BayerFormat::fromMbusCode(sensorFormat_.mbus_code);\n \n \t\t/*\n \t\t * Some sensors change their Bayer order when they are h-flipped\n@@ -249,12 +245,33 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\t * Note how we must fetch the \"native\" (i.e. untransformed) Bayer\n \t\t * order, because the sensor may currently be flipped!\n \t\t */\n-\t\tBayerFormat bayer = BayerFormat::fromPixelFormat(raw.cfg->pixelFormat);\n \t\tif (data_->flipsAlterBayerOrder_) {\n-\t\t\tbayer.order = data_->nativeBayerOrder_;\n-\t\t\tbayer = bayer.transform(combinedTransform_);\n+\t\t\tsensorBayer.order = data_->nativeBayerOrder_;\n+\t\t\tsensorBayer = sensorBayer.transform(combinedTransform_);\n+\t\t}\n+\n+\t\t/* Apply the sensor adjusted Bayer order to the user request. */\n+\t\tBayerFormat cfgBayer = BayerFormat::fromPixelFormat(rawStream->pixelFormat);\n+\t\tcfgBayer.order = sensorBayer.order;\n+\n+\t\tif (rawStream->pixelFormat != cfgBayer.toPixelFormat()) {\n+\t\t\trawStream->pixelFormat = cfgBayer.toPixelFormat();\n+\t\t\tstatus = Adjusted;\n \t\t}\n-\t\traw.cfg->pixelFormat = bayer.toPixelFormat();\n+\t}\n+\n+\t/* Do any platform specific fixups. */\n+\tStatus st = data_->platformValidate(this);\n+\tif (st == Invalid)\n+\t\treturn Invalid;\n+\telse if (st == Adjusted)\n+\t\tstatus = Adjusted;\n+\n+\t/* Further fixups on the RAW streams. */\n+\tfor (auto &raw : rawStreams_) {\n+\t\tint ret = raw.dev->tryFormat(&raw.format);\n+\t\tif (ret)\n+\t\t\treturn Invalid;\n \n \t\tif (RPi::PipelineHandlerBase::updateStreamConfig(raw.cfg, raw.format))\n \t\t\tstatus = Adjusted;\ndiff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\nindex 233473e2fe2b..cf7b45985738 100644\n--- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n+++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n@@ -409,21 +409,9 @@ CameraConfiguration::Status Vc4CameraData::platformValidate(RPi::RPiCameraConfig\n \n \t\t/* Adjust the RAW stream to match the computed sensor format. */\n \t\tStreamConfiguration *rawStream = rawStreams[0].cfg;\n-\t\tBayerFormat rawBayer = BayerFormat::fromMbusCode(rpiConfig->sensorFormat_.mbus_code);\n \n-\t\t/* Handle flips to make sure to match the RAW stream format. */\n-\t\tif (flipsAlterBayerOrder_)\n-\t\t\trawBayer = rawBayer.transform(rpiConfig->combinedTransform_);\n-\n-\t\t/* Apply the user requested packing. */\n-\t\trawBayer.packing = BayerFormat::fromPixelFormat(rawStream->pixelFormat).packing;\n-\t\tPixelFormat rawFormat = rawBayer.toPixelFormat();\n-\n-\t\tif (rawStream->pixelFormat != rawFormat ||\n-\t\t    rawStream->size != rpiConfig->sensorFormat_.size) {\n-\t\t\trawStream->pixelFormat = rawFormat;\n+\t\tif (rawStream->size != rpiConfig->sensorFormat_.size) {\n \t\t\trawStream->size = rpiConfig->sensorFormat_.size;\n-\n \t\t\tstatus = CameraConfiguration::Adjusted;\n \t\t}\n \n","prefixes":["libcamera-devel","v2","14/20"]}