From patchwork Fri May 31 05:25:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 20159 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 081BCBD87C for ; Fri, 31 May 2024 05:25:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ACB22634BA; Fri, 31 May 2024 07:25:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JWGUl2Z9"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5BAF2634AF for ; Fri, 31 May 2024 07:25:18 +0200 (CEST) Received: from fedora.local (unknown [IPv6:2409:4056:ecf:2c0c:629d:1df6:d7ca:cb53]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A0C38E22; Fri, 31 May 2024 07:25:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1717133113; bh=KljAcoauDhQh5SXtUaCy5unCijNv6v91D/evORqfcq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JWGUl2Z9eTBwkfSiXtIsFsuAI92+EGe4t2zWz0k0r1RUDmdMnQc/vmydQSHbcndOG EkUAnB27uWENgcW5xrh/PNLnKJL7509uRgwy2T8klFp1Tg13en2fq9PUMh+fQhn1zZ yD5rR65vj0hnXUd9pdmnAjKKZs/osChgFvxod2XM= From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Andrey Konovalov , Umang Jain , Kieran Bingham Subject: [PATCH v3 1/4] converter: converter_v4l2_m2m: Rectify streams sanity check Date: Fri, 31 May 2024 10:55:02 +0530 Message-ID: <20240531052505.150921-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240531052505.150921-1-umang.jain@ideasonboard.com> References: <20240531052505.150921-1-umang.jain@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 streams sanity check tries to determine if all the stream indexes passed in outputs std::map<> are unique. However, since the data container is std::map<>, all its keys (stream indexes in this case), are already unique. Instead, rectify the sanity check to ensure all the framebuffers passed in the outputs std::map<> are unique to each index. Hence, no two stream indexes should have same framebuffer. Update the comment to reflect the change. Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham --- src/libcamera/converter/converter_v4l2_m2m.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp index d8929fc5..27a50e34 100644 --- a/src/libcamera/converter/converter_v4l2_m2m.cpp +++ b/src/libcamera/converter/converter_v4l2_m2m.cpp @@ -403,13 +403,13 @@ void V4L2M2MConverter::stop() int V4L2M2MConverter::queueBuffers(FrameBuffer *input, const std::map &outputs) { - unsigned int mask = 0; + std::set outputBufs; int ret; /* * Validate the outputs as a sanity check: at least one output is * required, all outputs must reference a valid stream and no two - * outputs can reference the same stream. + * streams can reference same output framebuffers. */ if (outputs.empty()) return -EINVAL; @@ -419,12 +419,13 @@ int V4L2M2MConverter::queueBuffers(FrameBuffer *input, return -EINVAL; if (index >= streams_.size()) return -EINVAL; - if (mask & (1 << index)) - return -EINVAL; - mask |= 1 << index; + outputBufs.insert(buffer); } + if (outputBufs.size() != streams_.size()) + return -EINVAL; + /* Queue the input and output buffers to all the streams. */ for (auto [index, buffer] : outputs) { ret = streams_[index].queueBuffers(input, buffer);