[{"id":27589,"web_url":"https://patchwork.libcamera.org/comment/27589/","msgid":"<fsscxwcokp46tcfh7eqymhcs3lpo6kdoisawy3mqdnhipkgyrk@hircge7rvjnb>","date":"2023-07-19T12:33:33","subject":"Re: [libcamera-devel] [PATCH v5 1/2] libcamera: controls: Add\n\tcontrols for AEC/AGC flicker avoidance","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi David\n\nOn Tue, Jul 18, 2023 at 03:43:00PM +0100, David Plowman via libcamera-devel wrote:\n> Flicker is the term used to describe brightness banding or oscillation\n> of images caused typically by artificial lighting driven by a 50 or\n> 60Hz mains supply. We add three controls intended to be used by\n> AEC/AGC algorithms:\n>\n> AeFlickerMode to enable flicker avoidance.\n>\n> AeFlickerPeriod to set the flicker period \"manually\".\n>\n> AeFlickerDetected to report any flicker that is currently detected.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/libcamera/control_ids.yaml | 90 +++++++++++++++++++++++++++-------\n>  1 file changed, 73 insertions(+), 17 deletions(-)\n>\n> diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml\n> index 056886e6..f2e542f4 100644\n> --- a/src/libcamera/control_ids.yaml\n> +++ b/src/libcamera/control_ids.yaml\n> @@ -156,6 +156,79 @@ controls:\n>          control of which features should be automatically adjusted shouldn't\n>          better be handled through a separate AE mode control.\n>\n> +  - AeFlickerMode:\n> +      type: int32_t\n> +      description: |\n> +        Set the flicker mode, which determines whether, and how, the AGC/AEC\n> +        algorithm attempts to hide flicker effects caused by the duty cycle of\n> +        artificial lighting.\n> +\n> +        Although implementation dependent, many algorithms for \"flicker\n> +        avoidance\" work by restricting this exposure time to integer multiples\n> +        of the cycle period, wherever possible.\n> +\n> +        Implementations may not support all of the flicker modes listed below.\n\nI would drop this, PH/IPA are supposed to register only the modes they\nsupport. This applies generally to all controls\n\n> +\n> +        By default the system will start in FlickerAuto mode if this is\n> +        supported, otherwise the flicker mode will be set to FlickerOff.\n> +\n> +      enum:\n> +        - name: FlickerOff\n> +          value: 0\n> +          description: No flicker avoidance is performed.\n> +        - name: FlickerManual\n> +          value: 1\n> +          description: Manual flicker avoidance.\n> +            Suppress flicker effects caused by lighting running with a period\n> +            specified by the AeFlickerPeriod control.\n> +            \\sa AeFlickerPeriod\n> +        - name: FlickerAuto\n> +          value: 2\n> +          description: Automatic flicker period detection and avoidance.\n> +            The system will automatically determine the most likely value of\n> +            flicker period, and avoid flicker of this frequency. Once flicker\n> +            is being corrected, it is implementation dependent whether the\n> +            system is still able to detect a change in the flicker period.\n> +            \\sa AeFlickerDetected\n> +\n> +  - AeFlickerPeriod:\n> +      type: int32_t\n> +      description: Manual flicker period in microseconds.\n> +        This value sets the current flicker period to avoid. It is used when\n> +        AeFlickerMode is set to FlickerManual.\n> +\n> +        To cancel 50Hz mains flicker, this should be set to 10000 (corresponding\n> +        to 100Hz), or 8333 (120Hz) for 60Hz mains.\n> +\n> +        Setting the mode to FlickerManual when no AeFlickerPeriod has ever been\n> +        set means that no flicker cancellation occurs (until the value of this\n> +        control is updated).\n> +\n> +        Switching to modes other than FlickerManual has no effect on the\n> +        value of the AeFlickerPeriod control.\n> +\n> +        \\sa AeFlickerMode\n> +\n> +  - AeFlickerDetected:\n> +      type: int32_t\n> +      description: Flicker period detected in microseconds.\n> +        The value reported here indicates the currently detected flicker\n> +        period, or zero if no flicker at all is detected.\n> +\n> +        When AeFlickerMode is set to FlickerAuto, there may be a period during\n> +        which the value reported here remains zero. Once a non-zero value is\n> +        reported, then this is the flicker period that has been detected and is\n> +        now being cancelled.\n> +\n> +        In the case of 50Hz mains flicker, the value would be 10000\n> +        (corresponding to 100Hz), or 8333 (120Hz) for 60Hz mains flicker.\n> +\n> +        It is implementation dependent whether the system can continue to detect\n> +        flicker of different periods when another frequency is already being\n> +        cancelled.\n> +\n> +        \\sa AeFlickerMode\n> +\n\nLooks good to me\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n>    - Brightness:\n>        type: float\n>        description: |\n> @@ -850,23 +923,6 @@ controls:\n>            value: 1\n>            description: The lens shading map mode is available.\n>\n> -  - SceneFlicker:\n> -      type: int32_t\n> -      draft: true\n> -      description: |\n> -       Control to report the detected scene light frequency. Currently\n> -       identical to ANDROID_STATISTICS_SCENE_FLICKER.\n> -      enum:\n> -        - name: SceneFickerOff\n> -          value: 0\n> -          description: No flickering detected.\n> -        - name: SceneFicker50Hz\n> -          value: 1\n> -          description: 50Hz flickering detected.\n> -        - name: SceneFicker60Hz\n> -          value: 2\n> -          description: 60Hz flickering detected.\n> -\n>    - PipelineDepth:\n>        type: int32_t\n>        draft: true\n> --\n> 2.30.2\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 919ECBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 19 Jul 2023 12:33:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DCDEF628C0;\n\tWed, 19 Jul 2023 14:33:38 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F161060381\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Jul 2023 14:33:36 +0200 (CEST)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9DA3DAF2;\n\tWed, 19 Jul 2023 14:32:42 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689770018;\n\tbh=JVi7p/K4rwMG2rPyr4WOPEy7FLilsGbSK+TUBhpM6d0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=C9bD7JSLmkjTPQhtxwt7A6LOQvLvT0UPA8Dpy7DirutoTn0STUoLn8oinoN79M7v3\n\tPkQU2XtVi5qLMwjQWgR/xSy7pxZRIM6OvSwpI9n8RctSB1MMH79Xa19qBmfSv26uIz\n\t9qt8mAZyAzNv74FIiYPu+vQOIa13Si1SLTwMafBtAEk8NHB/qyfc9MD8KbnhZ7cjDE\n\tHeydYk9NgkFDEAOaItsBEMPTemIG3hpUDmaNGqHHYvf3dc8QW58EA8XgaLUY77Wdsy\n\tdpfV9nyssQsNK9sbSQrYJq1VPlNw/D3f34baGwo18KjyBaQxzYKicva/O9FeWuMp8/\n\t8TGgqKV+Eo3kA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1689769962;\n\tbh=JVi7p/K4rwMG2rPyr4WOPEy7FLilsGbSK+TUBhpM6d0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ocuv65Z2+RbqGloToTSgBUjiKPrLOFgiDJ9L/SZlpntjxvviyfG2eH5iY7UjrIaXm\n\tVhMVhjP+qCq1tWUBS34fbWZi7Qqu7bAjFe5HXDJckw8umnRCXuGRyH75MxipNUr/kN\n\txYE0pT3lUPIMEw1Sagcq7Aovtd746kQvMEL4YGUw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ocuv65Z2\"; dkim-atps=neutral","Date":"Wed, 19 Jul 2023 14:33:33 +0200","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<fsscxwcokp46tcfh7eqymhcs3lpo6kdoisawy3mqdnhipkgyrk@hircge7rvjnb>","References":"<20230718144301.3612-1-david.plowman@raspberrypi.com>\n\t<20230718144301.3612-2-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20230718144301.3612-2-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v5 1/2] libcamera: controls: Add\n\tcontrols for AEC/AGC flicker avoidance","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>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":27593,"web_url":"https://patchwork.libcamera.org/comment/27593/","msgid":"<8db7ad7f-f748-c7db-9831-1e1b4f74832f@ideasonboard.com>","date":"2023-07-21T04:22:28","subject":"Re: [libcamera-devel] [PATCH v5 1/2] libcamera: controls: Add\n\tcontrols for AEC/AGC flicker avoidance","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi David\n\nOn 7/19/23 6:03 PM, Jacopo Mondi via libcamera-devel wrote:\n> Hi David\n>\n> On Tue, Jul 18, 2023 at 03:43:00PM +0100, David Plowman via libcamera-devel wrote:\n>> Flicker is the term used to describe brightness banding or oscillation\n>> of images caused typically by artificial lighting driven by a 50 or\n>> 60Hz mains supply. We add three controls intended to be used by\n>> AEC/AGC algorithms:\n>>\n>> AeFlickerMode to enable flicker avoidance.\n>>\n>> AeFlickerPeriod to set the flicker period \"manually\".\n>>\n>> AeFlickerDetected to report any flicker that is currently detected.\n>>\n>> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n>> ---\n>>   src/libcamera/control_ids.yaml | 90 +++++++++++++++++++++++++++-------\n>>   1 file changed, 73 insertions(+), 17 deletions(-)\n>>\n>> diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml\n>> index 056886e6..f2e542f4 100644\n>> --- a/src/libcamera/control_ids.yaml\n>> +++ b/src/libcamera/control_ids.yaml\n>> @@ -156,6 +156,79 @@ controls:\n>>           control of which features should be automatically adjusted shouldn't\n>>           better be handled through a separate AE mode control.\n>>\n>> +  - AeFlickerMode:\n>> +      type: int32_t\n>> +      description: |\n>> +        Set the flicker mode, which determines whether, and how, the AGC/AEC\n>> +        algorithm attempts to hide flicker effects caused by the duty cycle of\n>> +        artificial lighting.\n>> +\n>> +        Although implementation dependent, many algorithms for \"flicker\n>> +        avoidance\" work by restricting this exposure time to integer multiples\n>> +        of the cycle period, wherever possible.\n>> +\n>> +        Implementations may not support all of the flicker modes listed below.\n> I would drop this, PH/IPA are supposed to register only the modes they\n> support. This applies generally to all controls\n\nWith this addressed,\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\n>\n>> +\n>> +        By default the system will start in FlickerAuto mode if this is\n>> +        supported, otherwise the flicker mode will be set to FlickerOff.\n>> +\n>> +      enum:\n>> +        - name: FlickerOff\n>> +          value: 0\n>> +          description: No flicker avoidance is performed.\n>> +        - name: FlickerManual\n>> +          value: 1\n>> +          description: Manual flicker avoidance.\n>> +            Suppress flicker effects caused by lighting running with a period\n>> +            specified by the AeFlickerPeriod control.\n>> +            \\sa AeFlickerPeriod\n>> +        - name: FlickerAuto\n>> +          value: 2\n>> +          description: Automatic flicker period detection and avoidance.\n>> +            The system will automatically determine the most likely value of\n>> +            flicker period, and avoid flicker of this frequency. Once flicker\n>> +            is being corrected, it is implementation dependent whether the\n>> +            system is still able to detect a change in the flicker period.\n>> +            \\sa AeFlickerDetected\n>> +\n>> +  - AeFlickerPeriod:\n>> +      type: int32_t\n>> +      description: Manual flicker period in microseconds.\n>> +        This value sets the current flicker period to avoid. It is used when\n>> +        AeFlickerMode is set to FlickerManual.\n>> +\n>> +        To cancel 50Hz mains flicker, this should be set to 10000 (corresponding\n>> +        to 100Hz), or 8333 (120Hz) for 60Hz mains.\n>> +\n>> +        Setting the mode to FlickerManual when no AeFlickerPeriod has ever been\n>> +        set means that no flicker cancellation occurs (until the value of this\n>> +        control is updated).\n>> +\n>> +        Switching to modes other than FlickerManual has no effect on the\n>> +        value of the AeFlickerPeriod control.\n>> +\n>> +        \\sa AeFlickerMode\n>> +\n>> +  - AeFlickerDetected:\n>> +      type: int32_t\n>> +      description: Flicker period detected in microseconds.\n>> +        The value reported here indicates the currently detected flicker\n>> +        period, or zero if no flicker at all is detected.\n>> +\n>> +        When AeFlickerMode is set to FlickerAuto, there may be a period during\n>> +        which the value reported here remains zero. Once a non-zero value is\n>> +        reported, then this is the flicker period that has been detected and is\n>> +        now being cancelled.\n>> +\n>> +        In the case of 50Hz mains flicker, the value would be 10000\n>> +        (corresponding to 100Hz), or 8333 (120Hz) for 60Hz mains flicker.\n>> +\n>> +        It is implementation dependent whether the system can continue to detect\n>> +        flicker of different periods when another frequency is already being\n>> +        cancelled.\n>> +\n>> +        \\sa AeFlickerMode\n>> +\n> Looks good to me\n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n>\n> Thanks\n>    j\n>\n>>     - Brightness:\n>>         type: float\n>>         description: |\n>> @@ -850,23 +923,6 @@ controls:\n>>             value: 1\n>>             description: The lens shading map mode is available.\n>>\n>> -  - SceneFlicker:\n>> -      type: int32_t\n>> -      draft: true\n>> -      description: |\n>> -       Control to report the detected scene light frequency. Currently\n>> -       identical to ANDROID_STATISTICS_SCENE_FLICKER.\n>> -      enum:\n>> -        - name: SceneFickerOff\n>> -          value: 0\n>> -          description: No flickering detected.\n>> -        - name: SceneFicker50Hz\n>> -          value: 1\n>> -          description: 50Hz flickering detected.\n>> -        - name: SceneFicker60Hz\n>> -          value: 2\n>> -          description: 60Hz flickering detected.\n>> -\n>>     - PipelineDepth:\n>>         type: int32_t\n>>         draft: true\n>> --\n>> 2.30.2\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 3D200BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 21 Jul 2023 04:22:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 54D2E628BD;\n\tFri, 21 Jul 2023 06:22:37 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 33569600F7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Jul 2023 06:22:33 +0200 (CEST)","from [192.168.1.108] (unknown [103.86.18.219])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 00C938CC;\n\tFri, 21 Jul 2023 06:21:36 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689913357;\n\tbh=3ef6TWsJjePEdkcIcFtDlUMegj9bGxXo3/zO7MQW7t0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=HhJjEoJ6a9XXSKvryVGRh0BDWsRFBu09rbOCahMMN5gqUpaJtoHml+NA7yCAFbSME\n\t1or4MJag08z6DBa0Mcn5ld3NJMtzzYRQh5AkkK9+EZRr7DP6kv2VyX0qCHrHGYr/OL\n\tLKWP+sv+MEwmLbHkkJCrGvnnZDl4hUfLPYPA60UPD6qMb2nqpPVYqvB4j5bWbaL0G4\n\tNqTsac/+SBap/lsAZOr9/8uVIvoGuNH7aULJUS4OHN6HJ03yZp4De9rztET/8Gmxpj\n\tY1TRveM/YYhiXDFAalDLD9JcQcHjJwI13JichBaP3smjq4J65u2XB9H6X61R/zHsgz\n\tTtQvhWZqETTzg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1689913297;\n\tbh=3ef6TWsJjePEdkcIcFtDlUMegj9bGxXo3/zO7MQW7t0=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=trFBTKl82wEVsY1ob2EjcebfRP/kWL77k3iGJc+I/inw/7BPaEvKrTrJ12r/jb2rY\n\tEDqf4The4OQjteUmaI1pTAYumV1rmw84++Vpu+WjNhQDjLB/BklADEZ5BU2AxM3lrb\n\taRNuB2SDyRtLecUd5rKCtifVtJ1EcbZP7qU6SM3o="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"trFBTKl8\"; dkim-atps=neutral","Message-ID":"<8db7ad7f-f748-c7db-9831-1e1b4f74832f@ideasonboard.com>","Date":"Fri, 21 Jul 2023 09:52:28 +0530","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101\n\tThunderbird/102.7.1","Content-Language":"en-US","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tDavid Plowman <david.plowman@raspberrypi.com>","References":"<20230718144301.3612-1-david.plowman@raspberrypi.com>\n\t<20230718144301.3612-2-david.plowman@raspberrypi.com>\n\t<fsscxwcokp46tcfh7eqymhcs3lpo6kdoisawy3mqdnhipkgyrk@hircge7rvjnb>","In-Reply-To":"<fsscxwcokp46tcfh7eqymhcs3lpo6kdoisawy3mqdnhipkgyrk@hircge7rvjnb>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v5 1/2] libcamera: controls: Add\n\tcontrols for AEC/AGC flicker avoidance","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>","From":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]