From patchwork Sun Oct 25 15:52:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 28600 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 6185EC324C for ; Sun, 25 Oct 2026 15:52:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5FD6E68FCB; Sun, 25 Oct 2026 16:52:39 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.b="CmuDaNn8"; dkim=pass (2048-bit key; unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="aDKFNDsz"; dkim-atps=neutral Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F9F968FA2 for ; Sun, 25 Oct 2026 16:52:38 +0100 (CET) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69PFkscn3813451 for ; Sun, 25 Oct 2026 15:52:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=B71lOe2HetADbq8gKB2t1Pm6C6yZEvSE0FO 57ftckLM=; b=CmuDaNn8fdNOUtUW4WlK8nri9ybCBXoQ4vMU1ZVfwsrDRpDBc/5 c4ew6YKepsLovZOSL2A/3r0lydH5aGncMrVmFeAQQuD60VdH3BFQiLMd/viB3zQc 7PphFwDvsbyp4h6lWeivc6qxOj+EweBT2l8Z9aQ+yitgQi69cxoUqxF8vetn2n9W X2zCkiD1/1j021px1IDnb40XPbTguCslK7Y9jqhBor58OR91dSAmyqwN/xaeWZ2c 0R7040wkAAQ6U2ZWdXf6QUThEBVPw+kx7vUbTdfjtwNvypdHvNE4t1vTUoVR45fJ bOVGOKYXVPUltozee+yVjaJQW1W8WztnpZg== Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4hgn27ubjh-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sun, 25 Oct 2026 15:52:36 +0000 (GMT) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-93cb7f9bb86so457547385a.2 for ; Sun, 25 Oct 2026 08:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1792943556; x=1793548356; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=B71lOe2HetADbq8gKB2t1Pm6C6yZEvSE0FO57ftckLM=; b=aDKFNDsztX0pHz/shsgri7RQHdw/u7QIB8S3gR0SP1fGkLLsfqrx3r0qV30+bprKfC SJf2ohewXd8mGiDPtqbk0JfW5QVFF+zpCb2zq8/5K0ZYgQgjFqB1PFA4Zxm53VDI07Ln VLhEr7zWpm6BvFuI6h5lVv0ovSBd/uH8JOlTQHFEUdgpWFwKS4zplYY+dtelEjaorXwj t2yf+sAC1kKbP8Ad5xKYJxpN4uOtdibUjjJ5QVQwoQhofzzHqdyVatgqMxH+EWBGtXRk udxiQiImcVquO0d5ktwRJbaLtBYz9+VPIAVlDbuQlFziQCwR4Q26dzwsj3eYqCcxJ3yS MURw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792943556; x=1793548356; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=B71lOe2HetADbq8gKB2t1Pm6C6yZEvSE0FO57ftckLM=; b=sfzKDG2AP+eSZDuyry/4cuskLGw9460xc5p8DCrDXmHKZf8bzeC9lpzqJchISExlwu b8/2q8XGL88IaB/FiBGT3KqvDAB3apc1WvWy6uA+f3LuV+oxjIHb28WUf17a+mkrMCXF WfOh0aCmwCVBDqTRdeS6RSE7xz+bQNXCql9I9rnbV6Svlj42iyhAkzwVEDeFZNX2OZjP TiuWWkhtiFn7iqjFsQ87OzSvCkx3nLdwQfXgUErH+w4E63+JVR857AuriIelN+IPwlIu GCInJKWyzG1gHmx+f4TJCs3CfRgqOc8GbsZAqSBVJTXgQzdVExlAAhn2TkQcR5gh7wz0 gFxw== X-Gm-Message-State: AFq9FYKLL2nP40wS7x96vZhFyUiAujnRbmlJ9Ie/acs9RLLsUrXH3POw 1jebQ1tQzhA1FPv+ThjiYrdomdtOp+yCr+6CwFWGRAbvqD9llc9WPqsZFvDYfwok5jBLjQHpgnB 3BToLkl7GmRFTxoZXQyMRWiXt48qgFdFReMG4pda9yZA9I8YlOXIyA8dtla8Aq90DLQJQFS4wbt AnEikH0s11 X-Gm-Gg: AYBFou0CVAaaOp636MS9DXAbI7pz47rLlT0rGNKGfj44vT1R9z/2EfY0KlNaUSTkIVb dHVBO3SuO547kQgIlAvsBFiGo23mwR7gMPeyqavTfq3yLOAVKQ/fw3ipseb1Eg98xwAYEhOVZEW CXXTP+2Dvnp7szGp6o3GXerUhkF+aagKmk7ff9GKIOBknIM3mOdFDFON5tdi+t32xxuurneArz+ z8Sta+ieptQv6SaR9hRpR+vZwi47l2bC4AqEbD40iJl1VHCpWzM72Mt3YSFdEktBV1XsTwmWQ/W wqAfkvOPXIXtaEMJe/KhPtiVtpWtt1+LXQEPS+DRkNrCr7hlhByru5oCJU0Q9C3zrKzwTGWgMpr b6qSXh7rBOmQEA67LduXgntenQ7UpclFug/pJTc5ntKNl+N71fApVv6P0IwNcC+IWvRfBMqkefW z28GOXpBWGovb5/Q== X-Received: by 2002:a05:620a:44c9:b0:93e:cd74:33b with SMTP id af79cd13be357-940ef8fd112mr690450185a.27.1792943555198; Sun, 25 Oct 2026 08:52:35 -0700 (PDT) X-Received: by 2002:a05:620a:44c9:b0:93e:cd74:33b with SMTP id af79cd13be357-940ef8fd112mr690448485a.27.1792943554665; Sun, 25 Oct 2026 08:52:34 -0700 (PDT) Received: from shalem (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6b4458dd28fsm2438229a12.3.2026.10.25.08.52.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 08:52:33 -0700 (PDT) From: Hans de Goede To: libcamera-devel@lists.libcamera.org Cc: Wenmeng Liu , Hans de Goede Subject: [PATCH 1/2] libcamera: software_isp: Add AllocCmaDmaBuffers constructor flag Date: Sun, 25 Oct 2026 16:52:32 +0100 Message-ID: <20261025155233.113989-1-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.56.0 MIME-Version: 1.0 X-Authority-Analysis: v=2.4 cv=G7GJgNk5 c=1 sm=1 tr=0 ts=6ade25c4 cx=c_pps a=50t2pK5VMbmlHzFWWp8p/g==:117 a=xqWC_Br6kY4A:10 a=660iZSQnnn4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=uunzMm59FInRfW6TVs0A:9 a=IoWCM6iH3mJn3m4BftBB:22 X-Proofpoint-ORIG-GUID: Dto43xxKktcIF-sB667M_HzoEqYn46E6 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI1MDA2MyBTYWx0ZWRfXwvJOoHmLqCLj mIK6GmgiXcgvFhUNjjBDuVxHg0tSFWh1LPDmGMtRskEBiDfE9KFtwjywPo+bkuhvX1RLBKYjbiV 892HtCEM33Jo7H8ig9Oz44Cb8zox4N4= X-Proofpoint-GUID: Dto43xxKktcIF-sB667M_HzoEqYn46E6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI1MDA2MyBTYWx0ZWRfX7VoIoCHaOg1L hZMoqI8aXutiEKmr0aJ9fnskxNhdKgSUfMsyF8VUAk3RfrH2Vx4Z9VGlVBlpX3Tq9DhFHwxs8+i 19RV2H394HIjdju9nFOxlU2/Rzo112tAcSF5VsljHofMJKiJzUclOPGKGDsGAAmrdDOfhlXNKwB W6R/4bDoXG/HcVFTU+MbUVyyVfbIMR3jT8ypVPu31Xw2Vzu6X7wQh5DaJ9XJy6B3bFNPxbzuNJR srR4oUvGQNXHCQg8VI576s6sBWZ6RgGn7TOwXJp4KxoaX6tsO17dSR3CWfmRuk5jRih4pzQMIjM UYC9Ucw6ybKAGN62VrxYGxqCRYTqZyNb9171K624jIeNWNq09Ylkg8Sy89SgbfE8AjQEpDMBLqf LqeJY0oEOdtTTZ5O/lVU4R3iScbW8oJxYV3laNJeO1veZn4dWqYEy4Pn18/sIP05f8Vj6CKPVSV BsST+KjTjX07rdd7B1w== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293, Aquarius:18.0.1176, Hydra:6.1.138, FMLib:17.12.100.49 definitions=2026-10-25_04,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 phishscore=0 spamscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610250063 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" Allocating DMA buffers from the CMA pool is not necessary on platforms where the expected consumers (GPU, video-encoder) support non contiguous memory and allocating the buffers from the limited CMA pool may cause starvation of that pool for other processes which do actually require CMA. Add a new "SoftwareIspFlags flags" parameter to the SoftwareIsp() constructor, implement a single AllocCmaDmaBuffers flag for now and only request CmaHeap backed DmaBuffers when this flag is set. The only SoftwareIsp() constructor caller is modified to pass the new flag so this patch does not cause any behavior change. Signed-off-by: Hans de Goede --- .../internal/software_isp/software_isp.h | 13 +++++++++--- src/libcamera/pipeline/simple/simple.cpp | 4 +++- src/libcamera/software_isp/software_isp.cpp | 21 ++++++++++++------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index b64910637..7d5eab3e3 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include "libcamera/internal/camera_sensor.h" -#include "libcamera/internal/dma_buf_allocator.h" #include "libcamera/internal/pipeline_handler.h" #include "libcamera/internal/shared_mem_object.h" #include "libcamera/internal/software_isp/debayer_params.h" @@ -37,6 +37,7 @@ namespace libcamera { class Debayer; +class DmaBufAllocator; class FrameBuffer; class PixelFormat; class Stream; @@ -47,8 +48,14 @@ LOG_DECLARE_CATEGORY(SoftwareIsp) class SoftwareIsp : public Object { public: + enum class SoftwareIspFlag { + AllocCmaDmaBuffers = 1 << 0, + }; + + using SoftwareIspFlags = Flags; + SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, - ControlInfoMap *ipaControls); + SoftwareIspFlags flags, ControlInfoMap *ipaControls); ~SoftwareIsp(); int loadConfiguration([[maybe_unused]] const std::string &filename) { return 0; } @@ -99,7 +106,7 @@ private: Thread ispWorkerThread_; SharedMemObject sharedParams_; DebayerParams debayerParams_; - DmaBufAllocator dmaHeap_; + DmaBufAllocator *dmaHeap_; bool ccmEnabled_; bool lscEnabled_; diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 35c29ceca..caab09b00 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -615,7 +615,9 @@ int SimpleCameraData::init() * Instantiate Soft ISP if this is enabled for the given driver and no converter is used. */ if (!converter_ && pipe->swIspEnabled()) { - swIsp_ = std::make_unique(pipe, sensor_.get(), &controlInfo_); + swIsp_ = std::make_unique(pipe, sensor_.get(), + SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers, + &controlInfo_); if (!swIsp_->isValid()) { LOG(SimplePipeline, Warning) << "Failed to create software ISP, disabling software debayering"; diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 627625b4f..1ef4211ca 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -24,6 +24,7 @@ #include #include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/dma_buf_allocator.h" #include "libcamera/internal/framebuffer.h" #include "libcamera/internal/software_isp/debayer_params.h" @@ -76,16 +77,22 @@ LOG_DEFINE_CATEGORY(SoftwareIsp) * \brief Constructs SoftwareIsp object * \param[in] pipe The pipeline handler in use * \param[in] sensor Pointer to the CameraSensor instance owned by the pipeline handler + * \param[in] flags SoftwareIspFlags * \param[out] ipaControls The IPA controls to update */ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, - ControlInfoMap *ipaControls) - : ispWorkerThread_("SWIspWorker"), - dmaHeap_(DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap | - DmaBufAllocator::DmaBufAllocatorFlag::SystemHeap | - DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf) + SoftwareIspFlags flags, ControlInfoMap *ipaControls) + : ispWorkerThread_("SWIspWorker") { - if (!dmaHeap_.isValid()) { + DmaBufAllocator::DmaBufAllocatorFlags types = + DmaBufAllocator::DmaBufAllocatorFlag::SystemHeap | + DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf; + + if (flags & SoftwareIsp::SoftwareIspFlag::AllocCmaDmaBuffers) + types |= DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap; + + dmaHeap_ = new DmaBufAllocator(types); + if (!dmaHeap_->isValid()) { LOG(SoftwareIsp, Error) << "Failed to create DmaBufAllocator object"; return; } @@ -323,7 +330,7 @@ int SoftwareIsp::exportBuffers(const Stream *stream, unsigned int count, if (stream == nullptr) return -EINVAL; - return dmaHeap_.exportBuffers(count, { debayer_->frameSize() }, buffers); + return dmaHeap_->exportBuffers(count, { debayer_->frameSize() }, buffers); } /**