From patchwork Fri Oct 13 07:48:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19138 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0DCB5C32BF for ; Fri, 13 Oct 2023 07:49:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7EF1A629AD; Fri, 13 Oct 2023 09:49:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1697183345; bh=7l6NP7L67GZaRoxAF4LGABUZZ0aXJk6H7Yf/x8c+BeE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=tBnTyZHjpMf43DjZt/9KvL/EzSUByY4C3ZxIj0Gv9qOtiHy5mpxYwsR6YiLFnVvWD G/DXXl1/Q8rTkq+2EnN7/6OZmwh9aqc8HayEkr5QqJbblw2zRtSc+s1nZKpDwoiy3e dzjNcad9Repp0HHVhEnyyh5JX84whMRyYxegT0WskuzDXi0UoRTdYG1AMCXGwv+/4/ FzwkuBn8xLj3hnev+BfwaSvw1EFMt3SHT6G9USfHrZ7/PRWZhIYwFoBOaXwHAhxyoD KUGnA9SyzwXnWvxuqtofsmyMhER4zJc5zPKsRq2Wk7nbLw8n6LZXi/cn+D8WNPpCAT Kn8uIIkpkNL/A== Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6218962996 for ; Fri, 13 Oct 2023 09:48:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="phGEV+a9"; dkim-atps=neutral Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-53e07db272cso2583096a12.3 for ; Fri, 13 Oct 2023 00:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1697183336; x=1697788136; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=63ebRbhpy61ExuOGtyPGxJ72VDfar8BgQdTJMUJHTGA=; b=phGEV+a9+E9uNi6TcOXycUdMw/V1rzoSLs1lmarBoxBp16QcIaQR1TlRbWpwUHtU4A duAaMVHC0HhoOvlQVjOi4PZTAe2R661gVjDKy0RQFHIfHpK3HPGoKkzg0gsysC6OGee+ tyBhqVV9v9E3Pf7WGqffvZLg8TtPP9a0SvgmExYrbBVZEyZekk/Gmn+VEuesy95sm4b3 zT0n1ovTICHULWNs7TUGjam1M2w6JnacuJern3ubePMzDwnK5JDKs0fp138OKpGosQPM grcR8XHprvBM6RFN8FrS0TursTahdYH00lTICrACzIie+/13neHkGmwP432kXrhUSHKY ppcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697183336; x=1697788136; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=63ebRbhpy61ExuOGtyPGxJ72VDfar8BgQdTJMUJHTGA=; b=j8jLbGFJPYZ++1dxULAVyTk0V59NMNWcBPyikGBqYOpO1XsGCMmpL2Kk+SrOrgPWew Nou4nI8Ht1UuUslKn6An0Gcqqk30uAkw262mn4tV8csOOChuleT4hOIonOyJboe28g9T wE3zvX0VidjdJYL0OyQ8wbtqNnxZQPOOpmHTTPwKmcWou2h83S19W+KKRfHClmAx4TZP UBL8lHkFJ1DUBrHshQCHpJ3T8Ll4CEe7Gd96G7T4+oWLZj7DidmkcblHzAoK0+FOLHuU tCNYLmgLsB7y3RQmjYaKWHn9mbY6+tYbv5nFMtG1Wus1oCJ8xtWvEs7S4kh62kJAmqpT IDeg== X-Gm-Message-State: AOJu0Yyygg5yGnI87L3JTvmwaM+HuC2FXtUQ9ndTFNYMRvhZnFUtep79 khPa8smIryPZZMNov72sBGre6pv4qtUvdswcxCqMhw== X-Google-Smtp-Source: AGHT+IGg3FNEK1LMdMpe/D7KHmPVr0i1sISg+6F0gH0q6bDwSJEv2Azac70ii/Fa6erPbGRh4KDW2g== X-Received: by 2002:a17:907:2e19:b0:994:4095:3abf with SMTP id ig25-20020a1709072e1900b0099440953abfmr23095951ejc.14.1697183336654; Fri, 13 Oct 2023 00:48:56 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id m16-20020a7bca50000000b003fee6e170f9sm1791890wml.45.2023.10.13.00.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 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 Subject: [libcamera-devel] [PATCH v2 14/20] pipeline: rpi: Move flip handling validation code X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Move the handling of Bayer order changes due to flips to run before platformValidate(). This removes the need for this code to be split between platformValidate() and validate() as it is right now. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/rpi/common/pipeline_base.cpp | 43 +++++++++++++------ src/libcamera/pipeline/rpi/vc4/vc4.cpp | 14 +----- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 825eae80d014..7c88b87e0608 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -231,16 +231,12 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() } } - /* Do any platform specific fixups. */ - status = data_->platformValidate(this); - if (status == Invalid) - return Invalid; - - /* Further fixups on the RAW streams. */ + /* Start with some initial generic RAW stream adjustments. */ for (auto &raw : rawStreams_) { - int ret = raw.dev->tryFormat(&raw.format); - if (ret) - return Invalid; + StreamConfiguration *rawStream = raw.cfg; + + /* Adjust the RAW stream to match the computed sensor format. */ + BayerFormat sensorBayer = BayerFormat::fromMbusCode(sensorFormat_.mbus_code); /* * Some sensors change their Bayer order when they are h-flipped @@ -249,12 +245,33 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * Note how we must fetch the "native" (i.e. untransformed) Bayer * order, because the sensor may currently be flipped! */ - BayerFormat bayer = BayerFormat::fromPixelFormat(raw.cfg->pixelFormat); if (data_->flipsAlterBayerOrder_) { - bayer.order = data_->nativeBayerOrder_; - bayer = bayer.transform(combinedTransform_); + sensorBayer.order = data_->nativeBayerOrder_; + sensorBayer = sensorBayer.transform(combinedTransform_); + } + + /* Apply the sensor adjusted Bayer order to the user request. */ + BayerFormat cfgBayer = BayerFormat::fromPixelFormat(rawStream->pixelFormat); + cfgBayer.order = sensorBayer.order; + + if (rawStream->pixelFormat != cfgBayer.toPixelFormat()) { + rawStream->pixelFormat = cfgBayer.toPixelFormat(); + status = Adjusted; } - raw.cfg->pixelFormat = bayer.toPixelFormat(); + } + + /* Do any platform specific fixups. */ + Status st = data_->platformValidate(this); + if (st == Invalid) + return Invalid; + else if (st == Adjusted) + status = Adjusted; + + /* Further fixups on the RAW streams. */ + for (auto &raw : rawStreams_) { + int ret = raw.dev->tryFormat(&raw.format); + if (ret) + return Invalid; if (RPi::PipelineHandlerBase::updateStreamConfig(raw.cfg, raw.format)) status = Adjusted; diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index 233473e2fe2b..cf7b45985738 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -409,21 +409,9 @@ CameraConfiguration::Status Vc4CameraData::platformValidate(RPi::RPiCameraConfig /* Adjust the RAW stream to match the computed sensor format. */ StreamConfiguration *rawStream = rawStreams[0].cfg; - BayerFormat rawBayer = BayerFormat::fromMbusCode(rpiConfig->sensorFormat_.mbus_code); - /* Handle flips to make sure to match the RAW stream format. */ - if (flipsAlterBayerOrder_) - rawBayer = rawBayer.transform(rpiConfig->combinedTransform_); - - /* Apply the user requested packing. */ - rawBayer.packing = BayerFormat::fromPixelFormat(rawStream->pixelFormat).packing; - PixelFormat rawFormat = rawBayer.toPixelFormat(); - - if (rawStream->pixelFormat != rawFormat || - rawStream->size != rpiConfig->sensorFormat_.size) { - rawStream->pixelFormat = rawFormat; + if (rawStream->size != rpiConfig->sensorFormat_.size) { rawStream->size = rpiConfig->sensorFormat_.size; - status = CameraConfiguration::Adjusted; }