[{"id":34815,"web_url":"https://patchwork.libcamera.org/comment/34815/","msgid":"<CAHW6GYKMG-jp0q3pAhytnxv0h4L+w5=uj6L7TZBpW=4AFt8EDw@mail.gmail.com>","date":"2025-07-07T20:11:05","subject":"Re: [PATCH] ipa: rpi: Fix bug in AfState reporting","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"HI Nick\n\nThanks for the fix.\n\nOn Mon, 7 Jul 2025 at 18:11, Nick Hollinghurst\n<nick.hollinghurst@raspberrypi.com> wrote:\n>\n> A previous change introduced a bug in which it reported AfStateIdle\n> when idle in Auto mode, when it should continue to report the most\n> recent AF cycle's outcome (AfStateFocused or AfStateFailed).\n>\n> Also fix the Pause method so it won't reset state to AfStateIdle\n> when paused in Continuous AF mode (to match documented behaviour).\n>\n> Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>\n\nMaybe you could add a \"Fixes\" tag that identifies the commit where\nthings went wrong?\nWith that small change:\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nTested-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks\nDavid\n\n> ---\n>  src/ipa/rpi/controller/rpi/af.cpp | 12 +++++++-----\n>  1 file changed, 7 insertions(+), 5 deletions(-)\n>\n> diff --git a/src/ipa/rpi/controller/rpi/af.cpp b/src/ipa/rpi/controller/rpi/af.cpp\n> index eaaca4bc..26e59930 100644\n> --- a/src/ipa/rpi/controller/rpi/af.cpp\n> +++ b/src/ipa/rpi/controller/rpi/af.cpp\n> @@ -810,10 +810,10 @@ void Af::prepare(Metadata *imageMetadata)\n>         else\n>                 status.pauseState = AfPauseState::Running;\n>\n> -       if (scanState_ == ScanState::Idle)\n> -               status.state = AfState::Idle;\n> -       else if (mode_ == AfModeAuto)\n> +       if (mode_ == AfModeAuto && scanState_ != ScanState::Idle)\n>                 status.state = AfState::Scanning;\n> +       else if (mode_ == AfModeManual)\n> +               status.state = AfState::Idle;\n>         else\n>                 status.state = reportState_;\n>         status.lensSetting = initted_ ? std::optional<int>(cfg_.map.eval(fsmooth_))\n> @@ -954,8 +954,10 @@ void Af::pause(AfAlgorithm::AfPause pause)\n>                                 scanState_ = ScanState::Trigger;\n>                 } else if (pause != AfPauseResume && !pauseFlag_) {\n>                         pauseFlag_ = true;\n> -                       if (pause == AfPauseImmediate || scanState_ < ScanState::Coarse1)\n> -                               goIdle();\n> +                       if (pause == AfPauseImmediate || scanState_ < ScanState::Coarse1) {\n> +                               scanState_ = ScanState::Idle;\n> +                               scanData_.clear();\n> +                       }\n>                 }\n>         }\n>  }\n> --\n> 2.39.5\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 AE2B4C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  7 Jul 2025 20:11:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DBDD568EC8;\n\tMon,  7 Jul 2025 22:11:19 +0200 (CEST)","from mail-qt1-x831.google.com (mail-qt1-x831.google.com\n\t[IPv6:2607:f8b0:4864:20::831])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 04FC06151E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Jul 2025 22:11:17 +0200 (CEST)","by mail-qt1-x831.google.com with SMTP id\n\td75a77b69052e-4a6f0bcdf45so47487791cf.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 07 Jul 2025 13:11:17 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"kpKJoK7i\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1751919077; x=1752523877;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=kDaAVNHVavLHvnN34o9JDl5fsRSuqXN8aAN04PBJPpw=;\n\tb=kpKJoK7idBURqB3wII6lQLHq9cZ9Dowqh1JcZJ7iPFV50GfU/h6DS0+nH8K1ui2ILD\n\tS4CpEoQBDIn0UZniw8KFc+TFvWAaKv1nQ7FBtZ9brOVsRwonTUUVmv4UyVD0HdGv9gxn\n\tgErkE/IzefdnRB+0dy8l7aI5OacRxqGB0SCSXGUAX09OWAy55xiY46Y3BucKJoBJlKH2\n\tNj1fnU9ZoQPS8W3r63xU8Ugh2w0b2Hez7DIgHIq/HsVjw8kwAbMdbkRFlUjLUQqnx2i2\n\tV4THj+QrI9w+j32OgFoP/Nx0F40pWgXthifXrF+9LT3UWTPbngwqPgwoOigqQynJQRHh\n\t0ULA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1751919077; x=1752523877;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=kDaAVNHVavLHvnN34o9JDl5fsRSuqXN8aAN04PBJPpw=;\n\tb=UhRGY+BYBP+GsWoZP/Qg9dHiJ08p8X3cS8qtI6pGNVwR+u9LZ+VeUln493n7sbz36q\n\tu8i+T700DbII0QXJAtQsY+j/LlJ8zkyoV/PSBuAyUnJUNOkdv2UUUImyOszJa1ytIOGu\n\tpxMPHLFXwvq0pZweMYWzJUiDA/dU2BOwyHO7HolYilv4D5XqNL6iqQ5LGoXSfqB3LHiO\n\tVfwt9S7mjc1aXVVdQ1GdDcKA0d58BPrEzOsxF6LmVbyrq/88m7kChBC2Cfy2L9mO6c/8\n\t4V8s+n/4SR07N8wGIh4c6wtdEFd8BDowvdlSjufaTnroESf3UBYEtlQ0QyinubCXOGvF\n\tEUeA==","X-Gm-Message-State":"AOJu0YxTngFuvBFjmQixHdoEoLddT6Xb7/LDpVG3h47B6ln41m+aCP+W\n\tGqGew+WSZ4UqbEZOhmQYT8Dt1pl7ZZthXw387lsPOxab1/v5HpvhGhZGQQF31PhjxVNlCOJAejt\n\t+qNHi/+Tklnbv1WS/d4MS/EHkjDquMeXmSVp9tFInhoU4q/I7Sh963MU=","X-Gm-Gg":"ASbGncs2Mf3f64xTURrItKd3pmAkiwNmGMsyt3Qlqdsb6rxmhAlSGeGlw9jPTmObn9r\n\tPmOQQ/FBRhUfPOcUP/dCCSJa0jQF/+cnhmDvaklTxh6oXBZKYeEal8fAlZSfrJ6Mgdor/nARnr3\n\t2NaoaVwXIDUI/fM/evH5ChpnDdDpsVlcxsZ1z9mywzv8GkCAmKWBCe6BLNUuGLRh6A90PtH4HpG\n\tw==","X-Google-Smtp-Source":"AGHT+IFbUhzorE46m7Ah92sUFaaa4tShRX084ZQB4NmIFhk2M9SOGDBNR/CWx1I1G1g8ghuRRBubOefKoSV65CFXnCU=","X-Received":"by 2002:a05:622a:551:b0:4a3:800d:2a9a with SMTP id\n\td75a77b69052e-4a9964ac9aemr201681051cf.6.1751919076656;\n\tMon, 07 Jul 2025 13:11:16 -0700 (PDT)","MIME-Version":"1.0","References":"<20250707171059.3259-1-nick.hollinghurst@raspberrypi.com>","In-Reply-To":"<20250707171059.3259-1-nick.hollinghurst@raspberrypi.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Mon, 7 Jul 2025 21:11:05 +0100","X-Gm-Features":"Ac12FXwkexO65DzYz85xA8l03i06EoFqVKbtDynbE8MHqUtNNETnu2QZBpw0C6A","Message-ID":"<CAHW6GYKMG-jp0q3pAhytnxv0h4L+w5=uj6L7TZBpW=4AFt8EDw@mail.gmail.com>","Subject":"Re: [PATCH] ipa: rpi: Fix bug in AfState reporting","To":"Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","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":34820,"web_url":"https://patchwork.libcamera.org/comment/34820/","msgid":"<CAPhyPA4NXjH10SYb7zMHN=Fe=geDBDt5ezoEDYa_tc_axPqKkg@mail.gmail.com>","date":"2025-07-08T09:01:16","subject":"Re: [PATCH] ipa: rpi: Fix bug in AfState reporting","submitter":{"id":130,"url":"https://patchwork.libcamera.org/api/people/130/","name":"Nick Hollinghurst","email":"nick.hollinghurst@raspberrypi.com"},"content":"Thanks, David\n\nOn Mon, 7 Jul 2025 at 21:11, David Plowman\n<david.plowman@raspberrypi.com> wrote:\n>\n> HI Nick\n>\n> Thanks for the fix.\n>\n> On Mon, 7 Jul 2025 at 18:11, Nick Hollinghurst\n> <nick.hollinghurst@raspberrypi.com> wrote:\n> >\n> > A previous change introduced a bug in which it reported AfStateIdle\n> > when idle in Auto mode, when it should continue to report the most\n> > recent AF cycle's outcome (AfStateFocused or AfStateFailed).\n> >\n> > Also fix the Pause method so it won't reset state to AfStateIdle\n> > when paused in Continuous AF mode (to match documented behaviour).\n> >\n> > Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>\n>\n> Maybe you could add a \"Fixes\" tag that identifies the commit where\n> things went wrong?\n> With that small change:\n>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> Tested-by: David Plowman <david.plowman@raspberrypi.com>\n\nI'll add that to a v2 shortly.\n\n Nick\n\n> > ---\n> >  src/ipa/rpi/controller/rpi/af.cpp | 12 +++++++-----\n> >  1 file changed, 7 insertions(+), 5 deletions(-)\n> >\n> > diff --git a/src/ipa/rpi/controller/rpi/af.cpp b/src/ipa/rpi/controller/rpi/af.cpp\n> > index eaaca4bc..26e59930 100644\n> > --- a/src/ipa/rpi/controller/rpi/af.cpp\n> > +++ b/src/ipa/rpi/controller/rpi/af.cpp\n> > @@ -810,10 +810,10 @@ void Af::prepare(Metadata *imageMetadata)\n> >         else\n> >                 status.pauseState = AfPauseState::Running;\n> >\n> > -       if (scanState_ == ScanState::Idle)\n> > -               status.state = AfState::Idle;\n> > -       else if (mode_ == AfModeAuto)\n> > +       if (mode_ == AfModeAuto && scanState_ != ScanState::Idle)\n> >                 status.state = AfState::Scanning;\n> > +       else if (mode_ == AfModeManual)\n> > +               status.state = AfState::Idle;\n> >         else\n> >                 status.state = reportState_;\n> >         status.lensSetting = initted_ ? std::optional<int>(cfg_.map.eval(fsmooth_))\n> > @@ -954,8 +954,10 @@ void Af::pause(AfAlgorithm::AfPause pause)\n> >                                 scanState_ = ScanState::Trigger;\n> >                 } else if (pause != AfPauseResume && !pauseFlag_) {\n> >                         pauseFlag_ = true;\n> > -                       if (pause == AfPauseImmediate || scanState_ < ScanState::Coarse1)\n> > -                               goIdle();\n> > +                       if (pause == AfPauseImmediate || scanState_ < ScanState::Coarse1) {\n> > +                               scanState_ = ScanState::Idle;\n> > +                               scanData_.clear();\n> > +                       }\n> >                 }\n> >         }\n> >  }\n> > --\n> > 2.39.5\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 5C951C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Jul 2025 09:01:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C185068EDC;\n\tTue,  8 Jul 2025 11:01:30 +0200 (CEST)","from mail-ej1-x633.google.com (mail-ej1-x633.google.com\n\t[IPv6:2a00:1450:4864:20::633])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 99C2C68E3A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Jul 2025 11:01:28 +0200 (CEST)","by mail-ej1-x633.google.com with SMTP id\n\ta640c23a62f3a-ae3703c2a8bso810218666b.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 08 Jul 2025 02:01:28 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"J5m0EO5k\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1751965288; x=1752570088;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=rfSF7/mv2Daz2BGr/9o52ge/uwFkTt6VBVfqjO8LJxo=;\n\tb=J5m0EO5kxfXuhnsJ/BjRHsYqRVOjd0L4rLDRgvqqbhUFPuf6VhOnf4GVJOmkIFsx4+\n\tWbzjCQaoYa2ug5uP0cuxKQ8JEJScHWOjD1YfI50SpW1vOgIKvzBzc7bXlR+0PD7vpmp9\n\tjFTSFNFTiW5YnJoWMGEPMVQDop341muT3jo9iYb1iO1g0SWFLSkyFzOp9dCjm6+wEmcp\n\taYjZ3kAG2jgXKLdnvcrXuFxkkTo/0/W+HZtDjQe4MKlw5OdQw2IX5vc2N7h85Lpw2dVj\n\tHARQ+KkgE6erv20zUWiUNMSSHOTz0ntRy3sBQLLWOG78cLxu8vnXwhaAMla6KIk4k9V6\n\tX3tw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1751965288; x=1752570088;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=rfSF7/mv2Daz2BGr/9o52ge/uwFkTt6VBVfqjO8LJxo=;\n\tb=GLLUJ0h05Rk7hL7HgKUlus8ofMftpj5MYw2cUFQpKg1xWfQxlAHokXS3UFNfnlO61p\n\tuCt4HPpg1MsmkS5QKTBN/DqXzzDW9+dUajWats2/jruCuJY1Lt4STVvGGFVil5BfZ340\n\tAVEm9aFRweQJgwPzSRcsO7ZznC6JAMILydKu6wlnMuKTgWt2qivUK7XT5pYEqC/h/vDr\n\tMr0NGjylWKYxm/1jyIJtoBMaJbja2s3YyuJmOTU2fX5GC5zu+RqSuERN96jtM+8oJYA7\n\t6qER2vYIozw4BvAoH7tsLDAPsG4/To/Wp8EPAT900RJz/hfGLwGKYIycuGUQV8LB1yO6\n\tRsWA==","X-Gm-Message-State":"AOJu0YyXwSOfHdxyFxsvaa3a4PXJx6c22IOBlUlJNtbZ0in1iD5T+3wT\n\t+ojZM0m44mR72IPQBjjE99pYSU6uR9wZEC3U+CcpIZEaNB+1auJ/4JCSIaHRcn2qZ4lvJue46xf\n\tt6G5510oL8F+7msCGEFpTdhhu7cjTFO5jtRoEiUN5hwjrFAgdqnFR","X-Gm-Gg":"ASbGnct+35FWuaZu+hJAsojll69/rN8vv4A63bN/Ap+kCH1AtNLXpjrNYZyWB8RMWca\n\t2aD1DlrrD3+u6x1lB1TK6bZQhmU/TcZ0tU4BpkBg5WpwjVDiOQZJvSvMt+/nSeUwSB9Kfijlq4m\n\tY/9lc6/NnNsQkhxcPjMlxjuuTpg0TN6Krv60/Eg8G4YqENDgqyK/+xEh9J/CLpxR4jqydsqXMCU\n\tOBI+VP9wDf90w==","X-Google-Smtp-Source":"AGHT+IHXdevZ0qMF2Rj/twciYe4XxZJ7NpB3eLxwVOm/2gN53g0Eyagn6ZSqUY0rZscjt5saGtfByw0MKn0oY3EzAu0=","X-Received":"by 2002:a17:907:d84a:b0:adb:428f:f748 with SMTP id\n\ta640c23a62f3a-ae6b00c14a2mr239301566b.21.1751965287697;\n\tTue, 08 Jul 2025 02:01:27 -0700 (PDT)","MIME-Version":"1.0","References":"<20250707171059.3259-1-nick.hollinghurst@raspberrypi.com>\n\t<CAHW6GYKMG-jp0q3pAhytnxv0h4L+w5=uj6L7TZBpW=4AFt8EDw@mail.gmail.com>","In-Reply-To":"<CAHW6GYKMG-jp0q3pAhytnxv0h4L+w5=uj6L7TZBpW=4AFt8EDw@mail.gmail.com>","From":"Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>","Date":"Tue, 8 Jul 2025 10:01:16 +0100","X-Gm-Features":"Ac12FXzsGEQliqgqVuTJEC9vQxw23-cusoDBq8j_zoS2qGwJrwtG2oN538HyY-Y","Message-ID":"<CAPhyPA4NXjH10SYb7zMHN=Fe=geDBDt5ezoEDYa_tc_axPqKkg@mail.gmail.com>","Subject":"Re: [PATCH] ipa: rpi: Fix bug in AfState reporting","To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","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>"}}]