From patchwork Mon Nov 1 09:15:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14443 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 5ABDEBDB1C for ; Mon, 1 Nov 2021 09:15:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 077F7600BB; Mon, 1 Nov 2021 10:15:25 +0100 (CET) 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="R3R/MAqB"; dkim-atps=neutral Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 439C860158 for ; Mon, 1 Nov 2021 10:15:19 +0100 (CET) Received: by mail-wr1-x431.google.com with SMTP id m22so27267312wrb.0 for ; Mon, 01 Nov 2021 02:15:19 -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=R3R/MAqBJYUw1avowwmBHeDPgrDFnj1Z+yGz4FH9OotnQM63gnH9GdRz1PaiMIC1Kr LoTV0Jg4kiUjLqDdPSs4jbet+rI1r2bP+d7+beOFDLo1JDVxsGYo3B3s0p2kl5Dqw6RE UyFoD38FX/7XO4tP+Pt+10PVTCrV4N89q4sXD/U0FrpV0ijm4ABEp5SCMiLKEmJEZJrZ eea+ymZHpMIyfK5hw+B/LZDGsmDAqfF9Kv0CRD/8EhfVdLjnBj4V6dTZmJhnXD7f0W4/ 7FHsJmNZqQkKLf85cSU2iWMN/s8GrUtA3Yhd9T6OmDWNeJKo1ESy/HbSYrrkCTRNl2pj C1Xg== 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=JiJ51Usnl5fM2YeiV6cTKkWMBjcQ17gmyHuqctGACkmLJgSYaZ86qdcRBcTqRU+ca0 MWT5vNoOB3EI/Z1aHZUfGfUIeaYzyDHEVRiLlRP6pZzLm/+RXmIiTQ8MWDK3hTRGgelk 9fa/45qFisYNk7CEhADjzZQWhYNEh1r36AFju9OQXlvp2vJBqJT4j7GbXoWWQ50C4Sr6 dhPrPLfEA5K8KM0fI8BY1pUxaI6qR604F8wPa07F/q/s+Jm/RDSkeE2+XS5uuz1KrjV6 2CzoI1KdgzFhH45gpfS2M4icoCaOMZTeS/2HZsK0kKR46XIfZ0lWOm558ZSLPZ6wp1oK JJFA== X-Gm-Message-State: AOAM530fXCxBVgFNpQvwgM7YQWahpWBk68kvp/Q0o7Ol0rBNzezWJ0ya CIKHXtI5Kfi4YGUysIQ0df2holRLaw0PCucR X-Google-Smtp-Source: ABdhPJzvYu78jYotIPu8SNbi7roCNoNHk4POQK1wl4553eWXzp07nLjSjXVQpJUBQJAXtc75EskYcQ== X-Received: by 2002:adf:c514:: with SMTP id q20mr17722258wrf.420.1635758118617; Mon, 01 Nov 2021 02:15:18 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:3a2b:9d8c:92b9:ece6]) by smtp.gmail.com with ESMTPSA id w10sm13168849wrq.88.2021.11.01.02.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 02:15:18 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 1 Nov 2021 09:15:07 +0000 Message-Id: <20211101091510.23204-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101091510.23204-1-naush@raspberrypi.com> References: <20211101091510.23204-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 08/11] 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);