[{"id":35600,"web_url":"https://patchwork.libcamera.org/comment/35600/","msgid":"<7e5012d5-97a4-425e-8055-50e062651f4c@ideasonboard.com>","date":"2025-08-28T09:53:01","subject":"Re: [PATCH] py: gen-py-controls: Use generic workaround for enum\n\tprefixes","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n2025. 08. 28. 11:25 keltezéssel, Matthias Fend írta:\n> Detecting the prefix from the enum value strings doesn't work properly if\n> the individual values start with the same characters. This is the case, for\n> example, with On/Off and Start/Stop. Therefore, a hard-coded workaround was\n> required for the LensShadingMapMode (Off/On) control.\n\nWas something other than LensShadingMapMode missed? Or the motivation is just\nto be more future proof?\n\nFYI, the same issue is present in gen-gst-controls.py, although that only considers\na fixed set of controls.\n\nIn any case, I'm hoping that https://patchwork.libcamera.org/patch/23381/ could be\nmerged at some point, eliminating this issue once and for all.\n\n\nRegards,\nBarnabás Pőcze\n\n> \n> Since enum values typically use the control name as the prefix, a better\n> and more generic solution would be to use the name directly as the prefix.\n> \n> However, since some existing control enums use a different prefix than\n> their name, the previous version is still required for these.\n> \n> To eliminate the workaround and still remain compatible, the control name\n> is used as the prefix if the prefix determined with the original method\n> begins with the control name.\n> \n> Signed-off-by: Matthias Fend <matthias.fend@emfend.at>\n> ---\n>   src/py/libcamera/gen-py-controls.py | 12 +++---------\n>   1 file changed, 3 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/py/libcamera/gen-py-controls.py b/src/py/libcamera/gen-py-controls.py\n> index d43a7c1c7eab5744988febebc493c8a858f1d82e..8e9fb560145dd655f3d605be2863407feaef1fc1 100755\n> --- a/src/py/libcamera/gen-py-controls.py\n> +++ b/src/py/libcamera/gen-py-controls.py\n> @@ -34,15 +34,9 @@ def extend_control(ctrl, mode):\n>       if not ctrl.is_enum:\n>           return ctrl\n>   \n> -    if mode == 'controls':\n> -        # Adjustments for controls\n> -        if ctrl.name == 'LensShadingMapMode':\n> -            prefix = 'LensShadingMapMode'\n> -        else:\n> -            prefix = find_common_prefix([e.name for e in ctrl.enum_values])\n> -    else:\n> -        # Adjustments for properties\n> -        prefix = find_common_prefix([e.name for e in ctrl.enum_values])\n> +    prefix = find_common_prefix([e.name for e in ctrl.enum_values])\n> +    if prefix.startswith(ctrl.name):\n> +        prefix = ctrl.name\n>   \n>       for enum in ctrl.enum_values:\n>           enum.py_name = enum.name[len(prefix):]\n> \n> ---\n> base-commit: d54e5537ca0909339bb6950f3a565c9077406a3c\n> change-id: 20250828-py-control-prefix-72ca9aac9f16\n> \n> Best regards,","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5EB67BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Aug 2025 09:53:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BAD0A692F1;\n\tThu, 28 Aug 2025 11:53:07 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A1D26613BE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Aug 2025 11:53:05 +0200 (CEST)","from [192.168.33.12] (185.221.143.232.nat.pool.zt.hu\n\t[185.221.143.232])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2246B1980;\n\tThu, 28 Aug 2025 11:52:01 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"aWgyF1H/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1756374721;\n\tbh=OO1mO4gzG4nIL0iamus3GFWyubnNEFygpgtm8XOurUo=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=aWgyF1H/FJRaSU/2gCpL0zupo5g6wF4zqU80Bu7E4Pxz4xZI2STRQm6HeUKtnFFI0\n\t69rjPsw82/VhGUH0+bE9pd2jpxm1R4ZCpUPNVs0UeCmSrt4b36LMJTTMoOMMKrFsVJ\n\tQchdT+9LNx6OhVY+Dyx7oyQKtl64foyuueW3RT2Y=","Message-ID":"<7e5012d5-97a4-425e-8055-50e062651f4c@ideasonboard.com>","Date":"Thu, 28 Aug 2025 11:53:01 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] py: gen-py-controls: Use generic workaround for enum\n\tprefixes","To":"Matthias Fend <matthias.fend@emfend.at>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20250828-py-control-prefix-v1-1-7b9496996fa3@emfend.at>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20250828-py-control-prefix-v1-1-7b9496996fa3@emfend.at>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":35601,"web_url":"https://patchwork.libcamera.org/comment/35601/","msgid":"<9e530cec-7f74-44bc-a8c1-19a6722394c4@emfend.at>","date":"2025-08-28T10:06:19","subject":"Re: [PATCH] py: gen-py-controls: Use generic workaround for enum\n\tprefixes","submitter":{"id":134,"url":"https://patchwork.libcamera.org/api/people/134/","name":"Matthias Fend","email":"matthias.fend@emfend.at"},"content":"Hi Barnabás,\n\nAm 28.08.2025 um 11:53 schrieb Barnabás Pőcze:\n> Hi\n> \n> 2025. 08. 28. 11:25 keltezéssel, Matthias Fend írta:\n>> Detecting the prefix from the enum value strings doesn't work properly if\n>> the individual values start with the same characters. This is the \n>> case, for\n>> example, with On/Off and Start/Stop. Therefore, a hard-coded \n>> workaround was\n>> required for the LensShadingMapMode (Off/On) control.\n> \n> Was something other than LensShadingMapMode missed? Or the motivation is \n> just\n> to be more future proof?\n\nI created a new control that uses Start and Stop as values ​​and \nwondered why camshark offered \"art\" and \"op\" as options ;)\n\nInstead of another hard-coded workaround, I tried this slightly more \ngeneric solution.\n\nbest regards\n  ~Matthias\n\n> \n> FYI, the same issue is present in gen-gst-controls.py, although that \n> only considers\n> a fixed set of controls.\n> \n> In any case, I'm hoping that https://patchwork.libcamera.org/ \n> patch/23381/ could be\n> merged at some point, eliminating this issue once and for all.\n> \n> \n> Regards,\n> Barnabás Pőcze\n> \n>>\n>> Since enum values typically use the control name as the prefix, a better\n>> and more generic solution would be to use the name directly as the \n>> prefix.\n>>\n>> However, since some existing control enums use a different prefix than\n>> their name, the previous version is still required for these.\n>>\n>> To eliminate the workaround and still remain compatible, the control name\n>> is used as the prefix if the prefix determined with the original method\n>> begins with the control name.\n>>\n>> Signed-off-by: Matthias Fend <matthias.fend@emfend.at>\n>> ---\n>>   src/py/libcamera/gen-py-controls.py | 12 +++---------\n>>   1 file changed, 3 insertions(+), 9 deletions(-)\n>>\n>> diff --git a/src/py/libcamera/gen-py-controls.py b/src/py/libcamera/ \n>> gen-py-controls.py\n>> index \n>> d43a7c1c7eab5744988febebc493c8a858f1d82e..8e9fb560145dd655f3d605be2863407feaef1fc1 100755\n>> --- a/src/py/libcamera/gen-py-controls.py\n>> +++ b/src/py/libcamera/gen-py-controls.py\n>> @@ -34,15 +34,9 @@ def extend_control(ctrl, mode):\n>>       if not ctrl.is_enum:\n>>           return ctrl\n>> -    if mode == 'controls':\n>> -        # Adjustments for controls\n>> -        if ctrl.name == 'LensShadingMapMode':\n>> -            prefix = 'LensShadingMapMode'\n>> -        else:\n>> -            prefix = find_common_prefix([e.name for e in \n>> ctrl.enum_values])\n>> -    else:\n>> -        # Adjustments for properties\n>> -        prefix = find_common_prefix([e.name for e in ctrl.enum_values])\n>> +    prefix = find_common_prefix([e.name for e in ctrl.enum_values])\n>> +    if prefix.startswith(ctrl.name):\n>> +        prefix = ctrl.name\n>>       for enum in ctrl.enum_values:\n>>           enum.py_name = enum.name[len(prefix):]\n>>\n>> ---\n>> base-commit: d54e5537ca0909339bb6950f3a565c9077406a3c\n>> change-id: 20250828-py-control-prefix-72ca9aac9f16\n>>\n>> Best regards,\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 31822BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Aug 2025 10:06:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DEC41692F2;\n\tThu, 28 Aug 2025 12:06:22 +0200 (CEST)","from lx20.hoststar.hosting (lx20.hoststar.hosting [168.119.41.54])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E68E692E3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Aug 2025 12:06:21 +0200 (CEST)","from 194-208-208-245.tele.net ([194.208.208.245]:64144\n\thelo=[192.168.0.207])\n\tby lx20.hoststar.hosting with esmtpsa (TLS1.3) tls\n\tTLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.93)\n\t(envelope-from <matthias.fend@emfend.at>)\n\tid 1urZWO-0087oH-EU; Thu, 28 Aug 2025 12:06:20 +0200"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=emfend.at header.i=@emfend.at\n\theader.b=\"M7GYI+Cl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=emfend.at;\n\ts=mail;\n\th=Content-Transfer-Encoding:Content-Type:In-Reply-To:From:References\n\t:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To:Cc:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:\n\tList-Post:List-Owner:List-Archive;\n\tbh=DtpBsCMs+OT2YRYftXpPBBrbniNULz61In/SJByYOVI=;\n\tb=M7GYI+ClxmirtR3bW8SbnQAoWD\n\tPZz+1btaYvOsviJOJ1bASYGY+w57mm2PnHxUR471b01GlGdX8JIZf6FIfY//6mlll1e2RgER6RIOI\n\trGSPZJyZ4uhBJhh/bXzhelwJMquplX+iXXyFLzVIvF3GQhP577L98MadZLtyIenwpmdU=;","Message-ID":"<9e530cec-7f74-44bc-a8c1-19a6722394c4@emfend.at>","Date":"Thu, 28 Aug 2025 12:06:19 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] py: gen-py-controls: Use generic workaround for enum\n\tprefixes","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20250828-py-control-prefix-v1-1-7b9496996fa3@emfend.at>\n\t<7e5012d5-97a4-425e-8055-50e062651f4c@ideasonboard.com>","Content-Language":"de-DE","From":"Matthias Fend <matthias.fend@emfend.at>","In-Reply-To":"<7e5012d5-97a4-425e-8055-50e062651f4c@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":35609,"web_url":"https://patchwork.libcamera.org/comment/35609/","msgid":"<175639553582.3208301.7526391226375391949@ping.linuxembedded.co.uk>","date":"2025-08-28T15:38:55","subject":"Re: [PATCH] py: gen-py-controls: Use generic workaround for enum\n\tprefixes","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2025-08-28 10:53:01)\n> Hi\n> \n> 2025. 08. 28. 11:25 keltezéssel, Matthias Fend írta:\n> > Detecting the prefix from the enum value strings doesn't work properly if\n> > the individual values start with the same characters. This is the case, for\n> > example, with On/Off and Start/Stop. Therefore, a hard-coded workaround was\n> > required for the LensShadingMapMode (Off/On) control.\n> \n> Was something other than LensShadingMapMode missed? Or the motivation is just\n> to be more future proof?\n> \n> FYI, the same issue is present in gen-gst-controls.py, although that only considers\n> a fixed set of controls.\n> \n> In any case, I'm hoping that https://patchwork.libcamera.org/patch/23381/ could be\n> merged at some point, eliminating this issue once and for all.\n\nI'm fine progressing that patch for this next release window!\n\nCould you rebase the work and get an update on the list please?\n\n--\nKieran\n\n> Regards,\n> Barnabás Pőcze\n> \n> > \n> > Since enum values typically use the control name as the prefix, a better\n> > and more generic solution would be to use the name directly as the prefix.\n> > \n> > However, since some existing control enums use a different prefix than\n> > their name, the previous version is still required for these.\n> > \n> > To eliminate the workaround and still remain compatible, the control name\n> > is used as the prefix if the prefix determined with the original method\n> > begins with the control name.\n> > \n> > Signed-off-by: Matthias Fend <matthias.fend@emfend.at>\n> > ---\n> >   src/py/libcamera/gen-py-controls.py | 12 +++---------\n> >   1 file changed, 3 insertions(+), 9 deletions(-)\n> > \n> > diff --git a/src/py/libcamera/gen-py-controls.py b/src/py/libcamera/gen-py-controls.py\n> > index d43a7c1c7eab5744988febebc493c8a858f1d82e..8e9fb560145dd655f3d605be2863407feaef1fc1 100755\n> > --- a/src/py/libcamera/gen-py-controls.py\n> > +++ b/src/py/libcamera/gen-py-controls.py\n> > @@ -34,15 +34,9 @@ def extend_control(ctrl, mode):\n> >       if not ctrl.is_enum:\n> >           return ctrl\n> >   \n> > -    if mode == 'controls':\n> > -        # Adjustments for controls\n> > -        if ctrl.name == 'LensShadingMapMode':\n> > -            prefix = 'LensShadingMapMode'\n> > -        else:\n> > -            prefix = find_common_prefix([e.name for e in ctrl.enum_values])\n> > -    else:\n> > -        # Adjustments for properties\n> > -        prefix = find_common_prefix([e.name for e in ctrl.enum_values])\n> > +    prefix = find_common_prefix([e.name for e in ctrl.enum_values])\n> > +    if prefix.startswith(ctrl.name):\n> > +        prefix = ctrl.name\n> >   \n> >       for enum in ctrl.enum_values:\n> >           enum.py_name = enum.name[len(prefix):]\n> > \n> > ---\n> > base-commit: d54e5537ca0909339bb6950f3a565c9077406a3c\n> > change-id: 20250828-py-control-prefix-72ca9aac9f16\n> > \n> > Best regards,\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5C847BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Aug 2025 15:39:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7D47E692F3;\n\tThu, 28 Aug 2025 17:39:01 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 25FEC613B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Aug 2025 17:38:59 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7001E1785;\n\tThu, 28 Aug 2025 17:37:54 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Avkvm/83\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1756395474;\n\tbh=aZFGTx336htDpgJ+cR6UL0xxG0v57eLIdEtkFfi6KnY=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=Avkvm/83W8cHhwSPod/5/Ak1UgUjvgaaETuJU+2sntxWs/NOE9KQRnPMPpPS0jbRl\n\tQmrcVPA2nXsRmYzW1dJVKr6Mo6wm4naA7Ov/AiIGEF9fg1w8W0aNyv7tBl5U84V++P\n\tVL9Mo6AL6hrg+MYZmIF6mErG50alEvGqyhcLmsvU=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<7e5012d5-97a4-425e-8055-50e062651f4c@ideasonboard.com>","References":"<20250828-py-control-prefix-v1-1-7b9496996fa3@emfend.at>\n\t<7e5012d5-97a4-425e-8055-50e062651f4c@ideasonboard.com>","Subject":"Re: [PATCH] py: gen-py-controls: Use generic workaround for enum\n\tprefixes","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tMatthias Fend\n\t<matthias.fend@emfend.at>, libcamera-devel@lists.libcamera.org","Date":"Thu, 28 Aug 2025 16:38:55 +0100","Message-ID":"<175639553582.3208301.7526391226375391949@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]