From patchwork Thu Oct 28 08:46:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14383 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 39AE0C324F for ; Thu, 28 Oct 2021 08:47:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E3772600C9; Thu, 28 Oct 2021 10:47:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="H4oPzJA4"; dkim-atps=neutral Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5103F600C8 for ; Thu, 28 Oct 2021 10:46:58 +0200 (CEST) Received: by mail-wm1-x32b.google.com with SMTP id b82-20020a1c8055000000b0032ccc728d63so4445294wmd.1 for ; Thu, 28 Oct 2021 01:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MDGjX4NwGmjiRyxQlWwLzmvPyGow8IaUSTGp2CloHE0=; b=H4oPzJA4al6m7a3gdf4qFKx7KIgcRE/MAD5bXaiIyErXerMUomjkyBUhBfrXFkXOZM F4pq05fFj9tpWnvEIzZdGu/+wOy12VODmeC81Gy58gnVMne8NzMoP6wYbz9DVw3pnD88 E0Nj98+WNArzcayA7/56Nr2Ki5YjQvEO3Gtw1yRCjvXeewJrpLWL+X4/D/Aj7dv3xIlb PhzsPFM1+BYYACKD4SAqOzocXCEtfbjPSTHbW7Zqq1cMP2gIkkJN5WabVUwg8tbzBHGa VjXrpxUPlAvBUEv02S2trbqLtwisWhm+XsJcneCUtaOt6khFjOVFZpF/KT5Bd0euPK6+ XhAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MDGjX4NwGmjiRyxQlWwLzmvPyGow8IaUSTGp2CloHE0=; b=je4Bq6M0bhPoU0bsARDnWBWVjIHrHaKGG1swSyKNkPo5wyKvcLaUVfsZ6KKV3uuiMe yN/Nag3CEa81tP/q+wJstP8EMX75i1RKCRgrbqYMCNnsfFgiMIr4WIKpxidJlbERmoEm +qysFEY/zOdH0TBnabNyT56TUORWfRGGlFn7cdUSNEREQmXsp8XmIFZB7hLcBWPy/TiT VbgnmFVtjusZbd58Ed2nxFdYwXPtBZ/jBKMrYXOpHg79Co7wAj7PQicJXBFE4d1Afafo cJplcuNjq5xWvKBto5ieYpx9ZNNCz6rvst0essP62c4eC0xPavV2zTyyIJhCUozzG4uG HhtA== X-Gm-Message-State: AOAM530RRjzazQA4ziEC0PISHsX3kMGAV97XD9I15tkgRPoxUWT1jB6x DW79jGCbj1BN5GJN/Mn6W8YKI7KehhpRCA6z X-Google-Smtp-Source: ABdhPJwnTaWauGrhNFByVmTZKfh0CFlDoyfaG0GbguenngzgVaNzpFrT0PIgfiuhpA9NidpuLvWF7A== X-Received: by 2002:a1c:f601:: with SMTP id w1mr10940512wmc.112.1635410817753; Thu, 28 Oct 2021 01:46:57 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:b894:feb0:b828:13b]) by smtp.gmail.com with ESMTPSA id z2sm1955281wmk.19.2021.10.28.01.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 01:46:57 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Oct 2021 09:46:43 +0100 Message-Id: <20211028084646.453775-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211028084646.453775-1-naush@raspberrypi.com> References: <20211028084646.453775-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 07/10] pipeline: raspberrypi: Apply sensor flips at the start of configure() 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Sensor flips might change the Bayer order of the requested format. The existing code would set a sensor format along with the appropriate Unicam and ISP input formats, but reset the latter two on start() once the flips had been requested. We can now set the sensor flips just before we set the sensor mode in configure(), thereby not needing the second pair of format sets in start(). Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- .../pipeline/raspberrypi/raspberrypi.cpp | 51 ++++++------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 1634ca98f481..e078b8b9a811 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -598,14 +598,26 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) } } + /* + * Configure the H/V flip controls based on the combination of + * the sensor and user transform. + */ + if (data->supportsFlips_) { + const RPiCameraConfiguration *rpiConfig = + static_cast(config); + ControlList controls; + + controls.set(V4L2_CID_HFLIP, + static_cast(!!(rpiConfig->combinedTransform_ & Transform::HFlip))); + controls.set(V4L2_CID_VFLIP, + static_cast(!!(rpiConfig->combinedTransform_ & Transform::VFlip))); + data->setSensorControls(controls); + } + /* First calculate the best sensor mode we can use based on the user request. */ V4L2VideoDevice::Formats fmts = data->unicam_[Unicam::Image].dev()->formats(); V4L2DeviceFormat sensorFormat = findBestMode(fmts, rawStream ? sensorSize : maxSize); - /* - * Unicam image output format. The ISP input format gets set at start, - * just in case we have swapped bayer orders due to flips. - */ ret = data->unicam_[Unicam::Image].dev()->setFormat(&sensorFormat); if (ret) return ret; @@ -620,10 +632,6 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) LOG(RPI, Info) << "Sensor: " << camera->id() << " - Selected mode: " << sensorFormat.toString(); - /* - * This format may be reset on start() if the bayer order has changed - * because of flips in the sensor. - */ ret = data->isp_[Isp::Input].dev()->setFormat(&sensorFormat); if (ret) return ret; @@ -843,18 +851,6 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) return ret; } - /* - * IPA configure may have changed the sensor flips - hence the bayer - * order. Get the sensor format and set the ISP input now. - */ - V4L2DeviceFormat sensorFormat; - data->unicam_[Unicam::Image].dev()->getFormat(&sensorFormat); - ret = data->isp_[Isp::Input].dev()->setFormat(&sensorFormat); - if (ret) { - stop(camera); - return ret; - } - /* Enable SOF event generation. */ data->unicam_[Unicam::Image].dev()->setFrameStartEnabled(true); @@ -1253,10 +1249,6 @@ int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig) int RPiCameraData::configureIPA(const CameraConfiguration *config) { - /* We know config must be an RPiCameraConfiguration. */ - const RPiCameraConfiguration *rpiConfig = - static_cast(config); - std::map streamConfig; std::map entityControls; ipa::RPi::IPAConfig ipaConfig; @@ -1307,17 +1299,6 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) return -EPIPE; } - /* - * Configure the H/V flip controls based on the combination of - * the sensor and user transform. - */ - if (supportsFlips_) { - controls.set(V4L2_CID_HFLIP, - static_cast(!!(rpiConfig->combinedTransform_ & Transform::HFlip))); - controls.set(V4L2_CID_VFLIP, - static_cast(!!(rpiConfig->combinedTransform_ & Transform::VFlip))); - } - if (!controls.empty()) setSensorControls(controls);