From patchwork Thu Aug 28 09:25:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Fend X-Patchwork-Id: 24251 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 F1F69BD87C for ; Thu, 28 Aug 2025 09:25:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AD6A5692F1; Thu, 28 Aug 2025 11:25:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=emfend.at header.i=@emfend.at header.b="KCLiQJar"; dkim-atps=neutral Received: from lx20.hoststar.hosting (lx20.hoststar.hosting [168.119.41.54]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A12A3613BE for ; Thu, 28 Aug 2025 11:25:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=emfend.at; s=mail; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:Sender:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=JV3yalUTNx1iRiwCZg7bgloFGJpJxEVV25rokJkAIm8=; b=KCLiQJarc7zDNtg5jPzITgMP+C TJdK5zi0wWj3kpxPava0190KlMjrOSqzMsusRnTqE8buQccxLdszHON0u4M5KaWInDQ1rLcxhIsVD tuNWyoTyMDnnxpVqW1TzyOO334yiAk5dum+zAi9LxPR7+Y3bJoS8n0jYlA2NaF4XZYq8=; Received: from 194-208-208-245.tele.net ([194.208.208.245]:49864 helo=[127.0.1.1]) by lx20.hoststar.hosting with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1urYt6-007XtY-E0; Thu, 28 Aug 2025 11:25:44 +0200 From: Matthias Fend Date: Thu, 28 Aug 2025 11:25:39 +0200 Subject: [PATCH] py: gen-py-controls: Use generic workaround for enum prefixes MIME-Version: 1.0 Message-Id: <20250828-py-control-prefix-v1-1-7b9496996fa3@emfend.at> X-B4-Tracking: v=1; b=H4sIAJIgsGgC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDI1MDCyML3YJK3eT8vJKi/BzdgqLUtMwKXXOj5ETLxMRkyzRDMyWgPogw2Mz o2NpaAMrtX6pjAAAA X-Change-ID: 20250828-py-control-prefix-72ca9aac9f16 To: libcamera-devel@lists.libcamera.org Cc: Matthias Fend X-Mailer: b4 0.14.2 X-Spam-Score: X-Spam-Bar: X-Spam-Report: 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" Detecting the prefix from the enum value strings doesn't work properly if the individual values start with the same characters. This is the case, for example, with On/Off and Start/Stop. Therefore, a hard-coded workaround was required for the LensShadingMapMode (Off/On) control. Since enum values typically use the control name as the prefix, a better and more generic solution would be to use the name directly as the prefix. However, since some existing control enums use a different prefix than their name, the previous version is still required for these. To eliminate the workaround and still remain compatible, the control name is used as the prefix if the prefix determined with the original method begins with the control name. Signed-off-by: Matthias Fend --- src/py/libcamera/gen-py-controls.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) --- base-commit: d54e5537ca0909339bb6950f3a565c9077406a3c change-id: 20250828-py-control-prefix-72ca9aac9f16 Best regards, diff --git a/src/py/libcamera/gen-py-controls.py b/src/py/libcamera/gen-py-controls.py index d43a7c1c7eab5744988febebc493c8a858f1d82e..8e9fb560145dd655f3d605be2863407feaef1fc1 100755 --- a/src/py/libcamera/gen-py-controls.py +++ b/src/py/libcamera/gen-py-controls.py @@ -34,15 +34,9 @@ def extend_control(ctrl, mode): if not ctrl.is_enum: return ctrl - if mode == 'controls': - # Adjustments for controls - if ctrl.name == 'LensShadingMapMode': - prefix = 'LensShadingMapMode' - else: - prefix = find_common_prefix([e.name for e in ctrl.enum_values]) - else: - # Adjustments for properties - prefix = find_common_prefix([e.name for e in ctrl.enum_values]) + prefix = find_common_prefix([e.name for e in ctrl.enum_values]) + if prefix.startswith(ctrl.name): + prefix = ctrl.name for enum in ctrl.enum_values: enum.py_name = enum.name[len(prefix):]