From patchwork Thu May 1 14:16:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 23330 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 78683C327D for ; Thu, 1 May 2025 14:16:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4FEC768ADC; Thu, 1 May 2025 16:16:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RlymVgtk"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B45DD68AD0 for ; Thu, 1 May 2025 16:16:13 +0200 (CEST) Received: from Monstersaurus.lgs-net.com (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 70BE1741; Thu, 1 May 2025 16:16:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1746108966; bh=XfdBFOWRyFd2f/VcVPkeON4gYAZDif2ht/YNZJEnZ6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RlymVgtkNyNJSmF/n6KqHCrcbz4BnMk+DXkr4yg/pAcDC8v75C6KFQX3YvLLF32A4 VGfOo8gFEZIq6fVczVhKysqiSF2C/w22YhAA0JLsLEOsXV0GYayP/fffD8/rUQp32Z TWxZpjXiyoQ8t0n/SSDjkYkaWeosRLjhRoEWGCmo= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH 1/3] libcamera: pipeline: rkisp1: Detect invalid sensor configurations Date: Thu, 1 May 2025 15:16:07 +0100 Message-ID: <20250501141609.717148-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250501141609.717148-1-kieran.bingham@ideasonboard.com> References: <20250501141609.717148-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 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" If we select a Sensor Format that is larger than the ISP capabilities the pipeline will not be able to successfully start. Detect this during validate - and report accordingly, returning an 'Invalid' state to reflect that we were not able to reconfigure to adjust to a working state in this instance. Signed-off-by: Kieran Bingham --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 675f0a7490a6..d8c6100946bc 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -673,9 +673,21 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate() sensorFormat_ = sensor->getFormat(mbusCodes, maxSize, mainPath->maxResolution()); + + /* + * TODO: There doesn't seem to be a valid occasion to set the size to + * the native resolution if there was not a supported size found above. + */ if (sensorFormat_.size.isNull()) sensorFormat_.size = sensor->resolution(); + if (sensorFormat_.size > mainPath->maxResolution()) { + LOG(RkISP1, Error) + << "Sensor format size " << sensorFormat_.size + << " exceeds maximum possible size " << mainPath->maxResolution(); + return Invalid; + } + return status; } From patchwork Thu May 1 14:16:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 23331 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 9E472C327D for ; Thu, 1 May 2025 14:16:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4E26268AD9; Thu, 1 May 2025 16:16:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Sk80Z774"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CDBC368AD5 for ; Thu, 1 May 2025 16:16:13 +0200 (CEST) Received: from Monstersaurus.lgs-net.com (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ABA2F82A; Thu, 1 May 2025 16:16:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1746108966; bh=D0/2zUQlvXuJedoYsqSiOkKRCiWN0FZ3b1bx8rieaYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sk80Z7744lSrPHuliUmxZ6VTWamRty16ePWMlvFI4Gjyao2d3uslZdDJ3d+Y6Nyys V+jlG0f/didqNhPWi65aJTWc8npV8hjkLua9nNy+73nDUQnicwuhpsR+ZWhc+nAG32 RYPhSJ+R80PO17JoEq60YJxsnG+OB19noysItcNQ= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH 2/3] libcamera: camera_sensor: Extend reporting in getFormat() Date: Thu, 1 May 2025 15:16:08 +0100 Message-ID: <20250501141609.717148-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250501141609.717148-1-kieran.bingham@ideasonboard.com> References: <20250501141609.717148-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 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" When a pipeline handler asks the CameraSensor for a format, which is not achievable, it can be very helpful to the user to identify what size was requested and why it could not be provided within any constrained maximum size. This can make otherwise difficult to diagnose user errors visible and quickly correctable. Both of the CameraSensorRaw and CameraSensorLegacy are updated accordingly but that likely means these two classes could soon benefit from a more common base class to share otherwise identical code. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- src/libcamera/sensor/camera_sensor_legacy.cpp | 4 +++- src/libcamera/sensor/camera_sensor_raw.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp index 32989c19c019..20275f3bb1b2 100644 --- a/src/libcamera/sensor/camera_sensor_legacy.cpp +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp @@ -742,7 +742,9 @@ CameraSensorLegacy::getFormat(const std::vector &mbusCodes, } if (!bestSize) { - LOG(CameraSensor, Debug) << "No supported format or size found"; + LOG(CameraSensor, Warning) + << "No supported format or size found. Requested " + << size << " with a maximum size " << maxSize; return {}; } diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index ab75b1f8204c..07d1e2bfa600 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -800,7 +800,9 @@ CameraSensorRaw::getFormat(const std::vector &mbusCodes, } if (!bestSize) { - LOG(CameraSensor, Debug) << "No supported format or size found"; + LOG(CameraSensor, Warning) + << "No supported format or size found. Requested " + << size << " with a maximum size " << maxSize; return {}; } From patchwork Thu May 1 14:16:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 23332 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 864E3C327D for ; Thu, 1 May 2025 14:16:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CCA5A68B29; Thu, 1 May 2025 16:16:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IDkZkDoH"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 064C2617D7 for ; Thu, 1 May 2025 16:16:14 +0200 (CEST) Received: from Monstersaurus.lgs-net.com (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E757D886; Thu, 1 May 2025 16:16:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1746108967; bh=claqm905y/FT/D6Lf9qaKl2LB1Wjqb7c6PX2UpdCMC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IDkZkDoHryVIaybtqAFnOkbZBpPFXgq7rGdFIafiVw2/6+mhMISIdXIOemeU0Lno/ AtowqTWRhtmUEmOgBjmcavtxfGHvuHHXRACTacdVz3MnxFPLrPsKhbWmLCi9AIK6dh 1oK1ZkswsOfAVbD84lZPQsMKU9/GhQcRfRws8gAc= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH 3/3] apps: cam: Support full orientation options Date: Thu, 1 May 2025 15:16:09 +0100 Message-ID: <20250501141609.717148-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250501141609.717148-1-kieran.bingham@ideasonboard.com> References: <20250501141609.717148-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 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" The Orientation control was implemented in commit 7e5f1e1cedf5 "apps: cam: Add option to set stream orientation" but did not fully add all of the supported Orientation types. The upcoming dewarp support on RkISP1 will provide full rotation implementation options, including previously difficult '90' degree rotations. Extend the cam application to support setting any of the valid options. The existing 'mirror' and 'flip' options are not consistent with the rest of the option definitions, but maintain them as useful aliases to their corresponding type. Fixes: 7e5f1e1cedf5 ("apps: cam: Add option to set stream orientation") Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- It might be debatable if this really is a 'Fixes' as the existing commit wasn't broken - just not fully implemented - however the full set of Orientation types were there at the time the patch was merged. src/apps/cam/camera_session.cpp | 9 +++++++++ src/apps/cam/main.cpp | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp index f63fcb228519..43188133d9cb 100644 --- a/src/apps/cam/camera_session.cpp +++ b/src/apps/cam/camera_session.cpp @@ -97,7 +97,16 @@ CameraSession::CameraSession(CameraManager *cm, std::string orientOpt = options_[OptOrientation].toString(); static const std::map orientations{ { "rot0", libcamera::Orientation::Rotate0 }, + { "rot90", libcamera::Orientation::Rotate90 }, { "rot180", libcamera::Orientation::Rotate180 }, + { "rot270", libcamera::Orientation::Rotate270 }, + + { "rot0mirror", libcamera::Orientation::Rotate0Mirror }, + { "rot90mirror", libcamera::Orientation::Rotate90Mirror }, + { "rot180mirror", libcamera::Orientation::Rotate180Mirror }, + { "rot270mirror", libcamera::Orientation::Rotate270Mirror }, + + /* Helpful aliases */ { "mirror", libcamera::Orientation::Rotate0Mirror }, { "flip", libcamera::Orientation::Rotate180Mirror }, }; diff --git a/src/apps/cam/main.cpp b/src/apps/cam/main.cpp index fa266eca6d30..f1495a2db465 100644 --- a/src/apps/cam/main.cpp +++ b/src/apps/cam/main.cpp @@ -136,7 +136,10 @@ int CamApp::parseOptions(int argc, char *argv[]) OptCamera); parser.addOption(OptOrientation, OptionString, - "Desired image orientation (rot0, rot180, mirror, flip)", + "Desired image orientation. Supported values:\n" + "- rot0, rot90, rot180, rot270,\n" + "- rot0mirror, rot90mirror, rot180mirror, rot270mirror,\n" + "- mirror (alias for rot0mirror), flip (alias for rot180mirror)", "orientation", ArgumentRequired, "orientation", false, OptCamera); #ifdef HAVE_KMS