From patchwork Thu Apr 27 10:53:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 18565 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 9E84DC0DA4 for ; Thu, 27 Apr 2023 10:54:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 091E2627DF; Thu, 27 Apr 2023 12:54:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1682592892; bh=QxC1WfZVHysTuVGJJeqcIy9RkceIs8w+Dowxs906M4A=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=t9QOxFizGFgsXOwBtThoMkUAf7cYiQQYbqszkRdGQCs62sm/z3aIW9CS92FT9pzqA zABFpvwzd2tb83gojR37Ey3ynMIaDvSBdUNwpYUGeikYsivfzF/Q/PFq1AmGmN6ZK3 ETSsL7F/+QDJO9T5QND8PJ2DUECcW2A9C7yG/+Ssjv/tSvUoadLbtXnVDanpciKhrt rdztrAPpOpJAM88ym48GJdU3sxrifLo790Z8Qa39CoxPYzRtNF7qHGtx/e85VQV46z GUolh7lU+pDVfnJDvoQtFEo8ieHuVNjdtx6HQ6O/Fj0Qako9StlivehdQwpsOFxKqq 85/iF6LWrqnOw== Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B7CA627B7 for ; Thu, 27 Apr 2023 12:54:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="kwuYD6UC"; dkim-atps=neutral Received: from thinkpad-t460p.mediaserver.passengera.com (85-160-31-131.reb.o2.cz [85.160.31.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: rmader) by madras.collabora.co.uk (Postfix) with ESMTPSA id B1E356603219; Thu, 27 Apr 2023 11:54:49 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1682592890; bh=QxC1WfZVHysTuVGJJeqcIy9RkceIs8w+Dowxs906M4A=; h=From:To:Cc:Subject:Date:From; b=kwuYD6UC2qdXkbQPgfmx4f5cbo7YN+FWhOpjKeRArpJbP+ShQiJ4nMTGyw3mOFRbd vpW7Epq5MpxZe12D8xfAYCpsJ+ZupLSfLwzDJPftm9s0W895BnEuHIJ6HbrvGBWWAq p2Y0jgjuIHrruLIX2uB35nfZdESP1gjAq2+PBE85vciBkk/GayFs1KR4UgTWkKEcnQ CkWQl6x+j+YTB2oQWwg/3thHNZwK2Wt5gHSwY7g7VR7HTMy9lucxEeNgFu7hcDfz7w uZRnyODZC5b2mC86BMTOAvqyD5lfQvqAb0ySdVTEhSS7627Q+0zjYgQMnLl864RoTv cP3sW/aKSjwyg== To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Apr 2023 12:53:56 +0200 Message-Id: <20230427105356.16869-1-robert.mader@collabora.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] pipeline: simple: Validate transform 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: Robert Mader via libcamera-devel From: Robert Mader Reply-To: Robert Mader Cc: Robert Mader , Arnav Singh Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Just like we do for other pipeline handlers already. This ensures we corretly pass on transforms that are not handled by the sensor - e.g. rotations - back to the app via the config, which is required on devices like the Pinephone. Signed-off-by: Robert Mader Tested-by: Arnav Singh Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/simple/simple.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 2423ec10..abfb4c87 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -211,7 +211,8 @@ public: int init(); int setupLinks(); int setupFormats(V4L2SubdeviceFormat *format, - V4L2Subdevice::Whence whence); + V4L2Subdevice::Whence whence, + Transform transform = Transform::Identity); void bufferReady(FrameBuffer *buffer); unsigned int streamIndex(const Stream *stream) const @@ -292,6 +293,7 @@ public: } bool needConversion() const { return needConversion_; } + const Transform &combinedTransform() { return combinedTransform_; } private: /* @@ -304,6 +306,7 @@ private: const SimpleCameraData::Configuration *pipeConfig_; bool needConversion_; + Transform combinedTransform_; }; class SimplePipelineHandler : public PipelineHandler @@ -664,7 +667,8 @@ int SimpleCameraData::setupLinks() } int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, - V4L2Subdevice::Whence whence) + V4L2Subdevice::Whence whence, + Transform transform) { SimplePipelineHandler *pipe = SimpleCameraData::pipe(); int ret; @@ -673,7 +677,7 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, * Configure the format on the sensor output and propagate it through * the pipeline. */ - ret = sensor_->setFormat(format); + ret = sensor_->setFormat(format, transform); if (ret < 0) return ret; @@ -877,15 +881,16 @@ SimpleCameraConfiguration::SimpleCameraConfiguration(Camera *camera, CameraConfiguration::Status SimpleCameraConfiguration::validate() { + const CameraSensor *sensor = data_->sensor_.get(); Status status = Valid; if (config_.empty()) return Invalid; - if (transform != Transform::Identity) { - transform = Transform::Identity; + Transform requestedTransform = transform; + combinedTransform_ = sensor->validateTransform(&transform); + if (transform != requestedTransform) status = Adjusted; - } /* Cap the number of entries to the available streams. */ if (config_.size() > data_->streams_.size()) { @@ -1116,7 +1121,9 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) format.mbus_code = pipeConfig->code; format.size = pipeConfig->sensorSize; - ret = data->setupFormats(&format, V4L2Subdevice::ActiveFormat); + ret = data->setupFormats(&format, + V4L2Subdevice::ActiveFormat, + config->combinedTransform()); if (ret < 0) return ret;