From patchwork Wed Oct 27 09:28:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14363 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 56F23BDB1C for ; Wed, 27 Oct 2021 09:28:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1584B64881; Wed, 27 Oct 2021 11:28:24 +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="H6AnylAL"; dkim-atps=neutral Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 26CC564889 for ; Wed, 27 Oct 2021 11:28:15 +0200 (CEST) Received: by mail-wr1-x42d.google.com with SMTP id e12so2992432wra.4 for ; Wed, 27 Oct 2021 02:28:15 -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=6LOw+Zj1HQnnnUcZtvYdwAlLCTY3R/hzuHOJJbbu6C8=; b=H6AnylALFo+q7m9N+myw/rQIeuKraUCiBdbeVyZBOMdX3SmLkGSziIuoEEl5IUIOwd sgzlqe1Sq53TtnsOl0g8XlmrCnaD4z5tL2CsbWBIRGgs9tyoGEgArld1te6jqohCzpob Yyek1pm0IidB4XcjtrWBW1oJYzjrHtquRkW8BK0gA7vvm9OeivbP5R5yeodZqQZHNsye kbrcqjpDl+pUB0Iq78kHrYPk0WA67LlgGpyZDMYfYynbOmCqMtApe/2Cu4YEwzT9F/kM 60nFB04jOTqc7cZhm9EjwuKmssHsFrndbiv+8ITwg5EegQDHIXUmsaMI0f7rH/awWxQX ubzg== 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=6LOw+Zj1HQnnnUcZtvYdwAlLCTY3R/hzuHOJJbbu6C8=; b=HThzubZ8N3U97sBBrihLLBlPCUH0rTTkvHRV7LXOLEkSVU9JpOpLC9P1aP+lwjC6/G imWwDDVEcGej2TzP9ngu7ixuF/EDH7RYzPG5lnkM4Q0rJJcuqZG24ouS/w9DzKfaUFAs Pdj4cvTuzQ/+rJlqpEK5Nhvr5zXkHi5D4smXYtQddsfC2YmdBt2AE1JTkqAIHTLXw5WE Ud9tGJZz6H7l1ksrHUwrrfVJxOuMEp2/XUCAqutDFQR2ywBfi9Ba+CLg2l6XV9eYgBNM OBYoiv9HRr9TfAqnLkRiJ009zOQFUdCs6S9RHDa3qaO53u+FEpSGuoO7a3rziqgB8dTd eOmg== X-Gm-Message-State: AOAM530ik+FLH+9Q2ITgriuthvhJTuD15zPSbABzF3GH7HmFKyVuh659 cvFQ7CbMwmNocwGinI8LXOLJIRflViWuXGqI X-Google-Smtp-Source: ABdhPJy1OG0eRYP7Qeeq8jLLY4l4n8kExE/Z/AU2v18sf3tx2nQfd1pd7VcrtI2Ql8y0HRdINi+IEA== X-Received: by 2002:a5d:40c9:: with SMTP id b9mr4813997wrq.409.1635326894644; Wed, 27 Oct 2021 02:28:14 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:6561:eb24:3f00:ce98]) by smtp.gmail.com with ESMTPSA id x2sm2861360wmj.3.2021.10.27.02.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 02:28:14 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Oct 2021 10:28:03 +0100 Message-Id: <20211027092803.3671096-10-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211027092803.3671096-1-naush@raspberrypi.com> References: <20211027092803.3671096-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 9/9] 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 | 56 ++++++------------- 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 52521857b61c..eaa2676b891e 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -657,16 +657,28 @@ 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. */ V4L2SubdeviceFormat sensorFormat = findBestFormat(data->sensorFormats_, rawStream ? sensorSize : maxSize); ret = data->sensor_->setFormat(&sensorFormat); if (ret) return ret; - /* - * Unicam image output format. The ISP input format gets set at start, - * just in case we have swapped bayer orders due to flips. - */ V4L2DeviceFormat unicamFormat = toV4L2DeviceFormat(sensorFormat, packing); ret = data->unicam_[Unicam::Image].dev()->setFormat(&unicamFormat); if (ret) @@ -676,10 +688,6 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) << " - Selected sensor format: " << sensorFormat.toString() << " - Selected unicam format: " << unicamFormat.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(&unicamFormat); if (ret) return ret; @@ -902,23 +910,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. - */ - V4L2SubdeviceFormat sensorFormat; - data->sensor_->device()->getFormat(0, &sensorFormat); - - V4L2DeviceFormat ispFormat; - ispFormat.fourcc = mbusCodeToBayerFormat(sensorFormat.mbus_code).toV4L2PixelFormat(); - ispFormat.size = sensorFormat.size; - - ret = data->isp_[Isp::Input].dev()->setFormat(&ispFormat); - if (ret) { - stop(camera); - return ret; - } - /* Enable SOF event generation. */ data->unicam_[Unicam::Image].dev()->setFrameStartEnabled(true); @@ -1332,10 +1323,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; @@ -1386,17 +1373,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);