From patchwork Fri Oct 23 10:58:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 28592 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 E6FCEC324C for ; Fri, 23 Oct 2026 11:00:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A17D668FF1; Fri, 23 Oct 2026 13:00:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tKJZLHLh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 743BD68FCB for ; Fri, 23 Oct 2026 13:00:42 +0200 (CEST) Received: from mail.ideasonboard.com (unknown [IPv6:2401:4900:1c30:59f6:be2b:2877:6bc4:392]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4A9A712B2; Fri, 23 Oct 2026 12:58:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1792753113; bh=ZnWrVI3VqLLar8HzlxXoyx/6ZoZfVuyZbZAz6m/eYec=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tKJZLHLheuy8eisUI10vzaPN1R5muDojcjmZMWWM0A3CKGqrY4qfRixAm14bKQ6wj u7Xih53Mo0gl2kEbPTbCq+MSbObLc6CALGj0U2sDW0SfkXRcEnDfUOA5a9YnOpgjKM FRZM5p9IyXTiTrMoWpAUjOjJka2kyJeY3mDOinHs= From: Jai Luthra Date: Fri, 23 Oct 2026 16:28:30 +0530 Subject: [PATCH WIP RFC 22/26] pipeline: rpi: Prefer generic raw formats MIME-Version: 1.0 Message-Id: <20261023-b4-raw-model-v1-22-eadb9948901b@ideasonboard.com> References: <20261023-b4-raw-model-v1-0-eadb9948901b@ideasonboard.com> In-Reply-To: <20261023-b4-raw-model-v1-0-eadb9948901b@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Laurent Pinchart , Kieran Bingham , Sakari Ailus , Naushir Patuck , Jai Luthra X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1991; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=ZnWrVI3VqLLar8HzlxXoyx/6ZoZfVuyZbZAz6m/eYec=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBq2z3YK+ZlHk2Nw68jz8H5YeI+qWm5kv+Kiczjq 8lSb3oxjgSJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCats92AAKCRBD3pH5JJpx RaV+D/9vAHbZgHUUbs6oKXz2fpQu2Yz2EaAhIrZtiMIA6hKqgKh/IYSAQKCYyqYw83V4I2qamFr eYxNkjZ1YFpdK/XrfkmcyGqmi7FjsAJOAtCTCAncBlFVtP23Fyt3iMRAkybq1Cw+VTkFNvFC7SL GjPZsbeWyAApk3joym7dRvC5k1danK8apFKgZ9MLVvW338aKTVSL1hyWamXVHAloKQdA3t3FjL5 ietPEy0PbdOjyQCbf9B7ijUfzQN+hKoW3QUCL3CXxtxbbSPXtz3gnPiPBYC520hjkvzXxpWATRA KADYxRY99BUZPMhB4U/C+swFHvmVAGgbKjH/0k3K2jekh4Ms1aP8gn0ago7u2cCoZY++Kn6stav DDlWz/Cm8JE6gISrDAhOjQcUJhzSV4rKlqnscEHVy3DqdcXBjU7MqBMjqJiHj9/3XAH2yPwWs2M Ep2rCW2JTGnl1IACu+Ueo0WGTCVdYe4gASsuSeXxBs5uYPzTikp5+j1y7vAazJP9kyXNchsZ68K uP5wEjbRxSUoiHG/Ssng0akNUS9FyPmxfppvVQgkBVollgWHIRy6ourDFN3I8AFVRBFuCp7GNNO CujIo/hdjH7D7Y+rFJYL9LiK7VH7Y2GdgbIYcV2o9je+pykZ0ulViDEQncVCaD1YjuVsdjyt87d QZCqWuOP+FTM8Xw== X-Developer-Key: i=jai.luthra@ideasonboard.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 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" Most sensors that support the new common raw sensor model advertise both generic raw formats, and legacy bayer-specific formats. Break the tie by preferring the generic formats by a smidge, as all the Raspberry Pi drivers involved in the capture path (unicam, bcm2835-isp, cfe and pisp) can work with the newer media bus codes. Signed-off-by: Jai Luthra --- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 8453c8668542..081866aa68ab 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -964,6 +964,7 @@ V4L2SubdeviceFormat CameraData::findBestFormat(const Size &req, unsigned int bit constexpr float penaltyAr = 1500.0; constexpr float penaltyBitDepth = 500.0; + constexpr float penaltyNonGeneric = 1.0; /* Calculate the closest/best mode from the user requested size. */ for (const auto &[mbusCode, sizes] : sensorFormats_) { @@ -987,14 +988,19 @@ V4L2SubdeviceFormat CameraData::findBestFormat(const Size &req, unsigned int bit /* Add any penalties... this is not an exact science! */ score += utils::abs_diff(info.bitsPerPixel, bitDepth) * penaltyBitDepth; + /* Break ties when sensor advertises both legacy and generic codes */ + if (MediaBusFormatInfo::info(mbusCode).genericRaw == false) + score += penaltyNonGeneric; + if (score <= bestScore) { bestScore = score; bestFormat.code = mbusCode; bestFormat.size = size; } - LOG(RPI, Debug) << "Format: " << size - << " fmt " << *format + LOG(RPI, Debug) << "Format: " << *format + << "_" << utils::hex(mbusCode, 4) + << "_" << size << " Score: " << score << " (best " << bestScore << ")"; }