From patchwork Tue Aug 11 13:00:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 27758 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 DBEC6C330A for ; Tue, 11 Aug 2026 13:00:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 82F9C68278; Tue, 11 Aug 2026 15:00:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="AU8lepEL"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 71D246826D for ; Tue, 11 Aug 2026 15:00:47 +0200 (CEST) Received: from pb-laptop.local (185.221.141.208.nat.pool.zt.hu [185.221.141.208]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9B75D1E99; Tue, 11 Aug 2026 14:59:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1786453172; bh=ZoakN/o5HRKQAvw5CQCqGlXSgfkU+wD79pJwu1w9YHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AU8lepELYT9FathKo72LmL4/dX8Xb+zPEYYfPLkR21wD2BE1kRGl5SAc+Ju1hp35y ZLVZsvZ1eW2iE0X9moz+BGl+kX4H3LW9JLVGRL23bAEr7Ht/mdu0oq8BAA7jIZ7Q6E aqii4Jati3lyjmIjD7hz6OX/9LgiqnJb2iGXn0P0= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Jacopo Mondi Subject: [PATCH v3 8/8] libcamera: egl: initEGLContext(): Avoid double init Date: Tue, 11 Aug 2026 15:00:42 +0200 Message-ID: <20260811130042.213139-9-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260811130042.213139-1-barnabas.pocze@ideasonboard.com> References: <20260811130042.213139-1-barnabas.pocze@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 the initialization is already done, reject further attempts, otherwise resources would be leaked. Signed-off-by: Barnabás Pőcze Reviewed-by: Milan Zamazal Reviewed-by: Jacopo Mondi --- src/libcamera/egl.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 1f9e743c2f..410d27b98c 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -371,7 +371,10 @@ void eGL::createOutputTexture2D(eGLImage &eglImage) * * Each successful invocation must be followed by a call to resetEGLContext(). * - * \return 0 on success, or -ENODEV on failure + * If a valid EGL context is already present, initialization attempts + * will be rejected. + * + * \return 0 on success, or negative error code on failure */ int eGL::initEGLContext() { @@ -394,6 +397,9 @@ int eGL::initEGLContext() EGLint numConfigs; EGLConfig config; + if (context_ != EGL_NO_CONTEXT) + return -EEXIST; + if (!eglBindAPI(EGL_OPENGL_ES_API)) { LOG(eGL, Error) << "API bind fail"; goto fail;