[{"id":31763,"web_url":"https://patchwork.libcamera.org/comment/31763/","msgid":"<172908558612.877857.6301133540539895148@ping.linuxembedded.co.uk>","date":"2024-10-16T13:33:06","subject":"Re: [PATCH v1 1/4] ipa: rkisp1: algorithms: agc: Check for correct\n\tstats type","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2024-10-15 21:38:12)\n> Sometimes the ISP produces statistics only with a subset of statistic\n> types being valid. It doesn't happen often, but it happens.  Check for\n> the RKISP1_CIF_ISP_STAT_AUTOEXP bit to prevent using invalid or outdated\n> data.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/agc.cpp | 3 +--\n>  1 file changed, 1 insertion(+), 2 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> index 17d074d9c03e..5683707fa91a 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> @@ -398,7 +398,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>                   IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats,\n>                   ControlList &metadata)\n>  {\n> -       if (!stats) {\n> +       if (!(stats && stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)) {\n>                 fillMetadata(context, frameContext, metadata);\n>                 return;\n>         }\n> @@ -412,7 +412,6 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>          */\n>  \n>         const rkisp1_cif_isp_stat *params = &stats->params;\n> -       ASSERT(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP);\n\nDid you hit this ?\nBut I think it seems reasonable\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>  \n>         /* The lower 4 bits are fractional and meant to be discarded. */\n>         Histogram hist({ params->hist.hist_bins, context.hw->numHistogramBins },\n> -- \n> 2.43.0\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 AC4F5C326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 16 Oct 2024 13:33:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7773465383;\n\tWed, 16 Oct 2024 15:33:11 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 47EF96537E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 16 Oct 2024 15:33:09 +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 B0ABBA57;\n\tWed, 16 Oct 2024 15:31:26 +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=\"eAIUB500\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729085486;\n\tbh=DO2Xdz5LRhBR+Ucc2qxd/eKEWVOQo0vVfLbXpxQ/87Y=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=eAIUB500c5iUsS6o9LZQkTFl1ml9xuPhQlTGBfo19kJMobxlj3TcpF3BzzZWDFNJm\n\tPiyYFNvxYF4Tj79k4GT8KqxLL5TFe4OMfgoAGbZEa8nH+PWGq7qBsU6NXJSGBnec4q\n\t0UEO0gwBEjFoGUTHXxhBHseYVsN9cTsCs/b/aAUI=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20241015203820.574326-2-stefan.klug@ideasonboard.com>","References":"<20241015203820.574326-1-stefan.klug@ideasonboard.com>\n\t<20241015203820.574326-2-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v1 1/4] ipa: rkisp1: algorithms: agc: Check for correct\n\tstats type","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 16 Oct 2024 14:33:06 +0100","Message-ID":"<172908558612.877857.6301133540539895148@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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":31767,"web_url":"https://patchwork.libcamera.org/comment/31767/","msgid":"<20241016143644.GA30496@pendragon.ideasonboard.com>","date":"2024-10-16T14:36:44","subject":"Re: [PATCH v1 1/4] ipa: rkisp1: algorithms: agc: Check for correct\n\tstats type","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Oct 16, 2024 at 02:33:06PM +0100, Kieran Bingham wrote:\n> Quoting Stefan Klug (2024-10-15 21:38:12)\n> > Sometimes the ISP produces statistics only with a subset of statistic\n> > types being valid. It doesn't happen often, but it happens.  Check for\n> > the RKISP1_CIF_ISP_STAT_AUTOEXP bit to prevent using invalid or outdated\n> > data.\n> > \n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > ---\n> >  src/ipa/rkisp1/algorithms/agc.cpp | 3 +--\n> >  1 file changed, 1 insertion(+), 2 deletions(-)\n> > \n> > diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> > index 17d074d9c03e..5683707fa91a 100644\n> > --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> > +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> > @@ -398,7 +398,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> >                   IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats,\n> >                   ControlList &metadata)\n> >  {\n> > -       if (!stats) {\n> > +       if (!(stats && stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)) {\n\nI'd write\n\n\tif (!stats || !(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)) {\n\n> >                 fillMetadata(context, frameContext, metadata);\n> >                 return;\n> >         }\n> > @@ -412,7 +412,6 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> >          */\n> >  \n> >         const rkisp1_cif_isp_stat *params = &stats->params;\n> > -       ASSERT(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP);\n> \n> Did you hit this ?\n\nI'm surprised. Is there a reliable way to trigger that ? What is it\ncaused by ?\n\n> But I think it seems reasonable\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> >  \n> >         /* The lower 4 bits are fractional and meant to be discarded. */\n> >         Histogram hist({ params->hist.hist_bins, context.hw->numHistogramBins },","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 83D4AC326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 16 Oct 2024 14:36:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 293FE65383;\n\tWed, 16 Oct 2024 16:36:51 +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 8840B6537E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 16 Oct 2024 16:36:49 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9E729A2F;\n\tWed, 16 Oct 2024 16:35:06 +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=\"CpvZ3YFh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729089306;\n\tbh=7LxU69jYE79r7tv+XNIZtmuPWwJ6mnqNX9M7tPGRGCQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=CpvZ3YFhWnApOrkxgwXm/hMfaAfxJOpTpAYQbX47PZGEwzp+Ps69vug3BBypyX99m\n\tLTpucnM7nu/uTgO5XDt4eNVTRPUYroZsrPCCcgt9akWnIvDMDDRGQnMx2X2M/AoLEz\n\tvYoh2lQ5qhnGpgCGHTDnk/0zuu930+ok3J4+RERw=","Date":"Wed, 16 Oct 2024 17:36:44 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 1/4] ipa: rkisp1: algorithms: agc: Check for correct\n\tstats type","Message-ID":"<20241016143644.GA30496@pendragon.ideasonboard.com>","References":"<20241015203820.574326-1-stefan.klug@ideasonboard.com>\n\t<20241015203820.574326-2-stefan.klug@ideasonboard.com>\n\t<172908558612.877857.6301133540539895148@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<172908558612.877857.6301133540539895148@ping.linuxembedded.co.uk>","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":31777,"web_url":"https://patchwork.libcamera.org/comment/31777/","msgid":"<ZxBnz78Q4-ewqzeB@pyrite.rasen.tech>","date":"2024-10-17T01:26:39","subject":"Re: [PATCH v1 1/4] ipa: rkisp1: algorithms: agc: Check for correct\n\tstats type","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Wed, Oct 16, 2024 at 05:36:44PM +0300, Laurent Pinchart wrote:\n> On Wed, Oct 16, 2024 at 02:33:06PM +0100, Kieran Bingham wrote:\n> > Quoting Stefan Klug (2024-10-15 21:38:12)\n> > > Sometimes the ISP produces statistics only with a subset of statistic\n> > > types being valid. It doesn't happen often, but it happens.  Check for\n> > > the RKISP1_CIF_ISP_STAT_AUTOEXP bit to prevent using invalid or outdated\n> > > data.\n> > > \n> > > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > > ---\n> > >  src/ipa/rkisp1/algorithms/agc.cpp | 3 +--\n> > >  1 file changed, 1 insertion(+), 2 deletions(-)\n> > > \n> > > diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> > > index 17d074d9c03e..5683707fa91a 100644\n> > > --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> > > +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> > > @@ -398,7 +398,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> > >                   IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats,\n> > >                   ControlList &metadata)\n> > >  {\n> > > -       if (!stats) {\n> > > +       if (!(stats && stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)) {\n> \n> I'd write\n> \n> \tif (!stats || !(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)) {\n\n+1\n\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> \n> > >                 fillMetadata(context, frameContext, metadata);\n> > >                 return;\n> > >         }\n> > > @@ -412,7 +412,6 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> > >          */\n> > >  \n> > >         const rkisp1_cif_isp_stat *params = &stats->params;\n> > > -       ASSERT(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP);\n> > \n> > Did you hit this ?\n> \n> I'm surprised. Is there a reliable way to trigger that ? What is it\n> caused by ?\n> \n> > But I think it seems reasonable\n> > \n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > >  \n> > >         /* The lower 4 bits are fractional and meant to be discarded. */\n> > >         Histogram hist({ params->hist.hist_bins, context.hw->numHistogramBins },\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 526D8C32FC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Oct 2024 01:26:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D0AF865383;\n\tThu, 17 Oct 2024 03:26:48 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D7D7633C7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Oct 2024 03:26:46 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:da41:46b1:7eef:1e0d])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3203D968;\n\tThu, 17 Oct 2024 03:25: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=\"bWC7C/yI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729128303;\n\tbh=t7h2XNXiYxgWcpnJZzh2ipInxbmyhRJibSM4Wl5z/AA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=bWC7C/yIAfUK2lfZz2yTE3R+Hqynv8jy+A8KcARJm8/+CeqV2OW8BpXdQSBV4H1D+\n\tDcbv36Gs+dxvEwHEErp/0A+bNA97G/KVOMSz8WUa5Eyiq5z85uEqX3uQmY11/FiEPL\n\tN0MIm4hbzvH4uIgElHFYKtmW4TurnVOXdimaB60Y=","Date":"Thu, 17 Oct 2024 10:26:39 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 1/4] ipa: rkisp1: algorithms: agc: Check for correct\n\tstats type","Message-ID":"<ZxBnz78Q4-ewqzeB@pyrite.rasen.tech>","References":"<20241015203820.574326-1-stefan.klug@ideasonboard.com>\n\t<20241015203820.574326-2-stefan.klug@ideasonboard.com>\n\t<172908558612.877857.6301133540539895148@ping.linuxembedded.co.uk>\n\t<20241016143644.GA30496@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20241016143644.GA30496@pendragon.ideasonboard.com>","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":31783,"web_url":"https://patchwork.libcamera.org/comment/31783/","msgid":"<kjdhcu3zywtrf6diqzd53h5bygj5kgwjstxmtigi7ct5qompdh@rrfgo5rpw7fc>","date":"2024-10-17T07:36:21","subject":"Re: [PATCH v1 1/4] ipa: rkisp1: algorithms: agc: Check for correct\n\tstats type","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Laurent, hi Kieran,\n\nThank you for the review. \n\nOn Wed, Oct 16, 2024 at 05:36:44PM +0300, Laurent Pinchart wrote:\n> On Wed, Oct 16, 2024 at 02:33:06PM +0100, Kieran Bingham wrote:\n> > Quoting Stefan Klug (2024-10-15 21:38:12)\n> > > Sometimes the ISP produces statistics only with a subset of statistic\n> > > types being valid. It doesn't happen often, but it happens.  Check for\n> > > the RKISP1_CIF_ISP_STAT_AUTOEXP bit to prevent using invalid or outdated\n> > > data.\n> > > \n> > > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > > ---\n> > >  src/ipa/rkisp1/algorithms/agc.cpp | 3 +--\n> > >  1 file changed, 1 insertion(+), 2 deletions(-)\n> > > \n> > > diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> > > index 17d074d9c03e..5683707fa91a 100644\n> > > --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> > > +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> > > @@ -398,7 +398,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> > >                   IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats,\n> > >                   ControlList &metadata)\n> > >  {\n> > > -       if (!stats) {\n> > > +       if (!(stats && stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)) {\n> \n> I'd write\n> \n> \tif (!stats || !(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)) {\n> \n> > >                 fillMetadata(context, frameContext, metadata);\n> > >                 return;\n> > >         }\n> > > @@ -412,7 +412,6 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> > >          */\n> > >  \n> > >         const rkisp1_cif_isp_stat *params = &stats->params;\n> > > -       ASSERT(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP);\n> > \n> > Did you hit this ?\n> \n> I'm surprised. Is there a reliable way to trigger that ? What is it\n> caused by ?\n\nI saw that while experimenting with the dewarper. I had a setup, that\nrepeatedly crashed inside libcamera. Investigating that it turned out to\nbe due to the stat type not beeing checked. Currently with my system in a\nproper state I am not able to reproduce it.\n\nI don't want to invest too much time, trying to find that point again. I\nadded a debug error on my side for now, to see if it pops up again.\nWould you prefer to drop the patches? Imho it is technically correct to\ncheck for the bit and I needed to add it to progress with my development\nbut it seems to be a rare case otherwise.\n\nBest regards,\nStefan\n\n> \n> > But I think it seems reasonable\n> > \n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > >  \n> > >         /* The lower 4 bits are fractional and meant to be discarded. */\n> > >         Histogram hist({ params->hist.hist_bins, context.hw->numHistogramBins },\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 2E87DC32FC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Oct 2024 07:36:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9744065383;\n\tThu, 17 Oct 2024 09:36:26 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 649E66537C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Oct 2024 09:36:24 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:dcec:e732:9245:1a01])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5653E6DC;\n\tThu, 17 Oct 2024 09:34:41 +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=\"OfjaLYse\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729150481;\n\tbh=IfEO6A4tsxqF4GDb5GS15EnTz2KAUtVMFjG3ozKijAM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=OfjaLYseVHGhyl4Lv+IsmkQ/cR8fHGFbN1a+qxMYJTtmGaQvwui31VzmQ98PWI2xA\n\tut1c/CNPrOoyoja4ty66mUiuvPSPSRM3DKlkclf8yyFx715I71xfsi5OQbomKXz0Ag\n\tgQd3TcFjIHCN2B7sXGdDwaU4ZJ1HcGXNe30bAIT4=","Date":"Thu, 17 Oct 2024 09:36:21 +0200","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 1/4] ipa: rkisp1: algorithms: agc: Check for correct\n\tstats type","Message-ID":"<kjdhcu3zywtrf6diqzd53h5bygj5kgwjstxmtigi7ct5qompdh@rrfgo5rpw7fc>","References":"<20241015203820.574326-1-stefan.klug@ideasonboard.com>\n\t<20241015203820.574326-2-stefan.klug@ideasonboard.com>\n\t<172908558612.877857.6301133540539895148@ping.linuxembedded.co.uk>\n\t<20241016143644.GA30496@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20241016143644.GA30496@pendragon.ideasonboard.com>","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":31784,"web_url":"https://patchwork.libcamera.org/comment/31784/","msgid":"<20241017082439.GK30496@pendragon.ideasonboard.com>","date":"2024-10-17T08:24:39","subject":"Re: [PATCH v1 1/4] ipa: rkisp1: algorithms: agc: Check for correct\n\tstats type","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Stefan,\n\nOn Thu, Oct 17, 2024 at 09:36:21AM +0200, Stefan Klug wrote:\n> On Wed, Oct 16, 2024 at 05:36:44PM +0300, Laurent Pinchart wrote:\n> > On Wed, Oct 16, 2024 at 02:33:06PM +0100, Kieran Bingham wrote:\n> > > Quoting Stefan Klug (2024-10-15 21:38:12)\n> > > > Sometimes the ISP produces statistics only with a subset of statistic\n> > > > types being valid. It doesn't happen often, but it happens.  Check for\n> > > > the RKISP1_CIF_ISP_STAT_AUTOEXP bit to prevent using invalid or outdated\n> > > > data.\n> > > > \n> > > > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > > > ---\n> > > >  src/ipa/rkisp1/algorithms/agc.cpp | 3 +--\n> > > >  1 file changed, 1 insertion(+), 2 deletions(-)\n> > > > \n> > > > diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> > > > index 17d074d9c03e..5683707fa91a 100644\n> > > > --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> > > > +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> > > > @@ -398,7 +398,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> > > >                   IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats,\n> > > >                   ControlList &metadata)\n> > > >  {\n> > > > -       if (!stats) {\n> > > > +       if (!(stats && stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)) {\n> > \n> > I'd write\n> > \n> > \tif (!stats || !(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP)) {\n> > \n> > > >                 fillMetadata(context, frameContext, metadata);\n> > > >                 return;\n> > > >         }\n> > > > @@ -412,7 +412,6 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> > > >          */\n> > > >  \n> > > >         const rkisp1_cif_isp_stat *params = &stats->params;\n> > > > -       ASSERT(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP);\n> > > \n> > > Did you hit this ?\n> > \n> > I'm surprised. Is there a reliable way to trigger that ? What is it\n> > caused by ?\n> \n> I saw that while experimenting with the dewarper. I had a setup, that\n> repeatedly crashed inside libcamera. Investigating that it turned out to\n> be due to the stat type not beeing checked. Currently with my system in a\n> proper state I am not able to reproduce it.\n> \n> I don't want to invest too much time, trying to find that point again. I\n> added a debug error on my side for now, to see if it pops up again.\n> Would you prefer to drop the patches? Imho it is technically correct to\n> check for the bit and I needed to add it to progress with my development\n> but it seems to be a rare case otherwise.\n\nI'm certainly not opposed to this patch, I don't want to cause rare\ncrashes for users :-) I'm only wondering how we could try to debug this\nin case it's a driver issue, to get it fixed. Maybe an ERROR log message\nwould be a good option, to get it noticed ? If the issue is very rare,\nit shouldn't cause much disturbance.\n\n> > > But I think it seems reasonable\n> > > \n> > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > \n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > \n> > > >  \n> > > >         /* The lower 4 bits are fractional and meant to be discarded. */\n> > > >         Histogram hist({ params->hist.hist_bins, context.hw->numHistogramBins },","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 11126C326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Oct 2024 08:24:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B6B8765383;\n\tThu, 17 Oct 2024 10:24:46 +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 22E676537C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Oct 2024 10:24:45 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D2E44968;\n\tThu, 17 Oct 2024 10:23: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=\"YRZDV2d6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729153382;\n\tbh=mL8EqHWOKv604oyWdbax0BhWuyCV1HMLG6dQFtoalwg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=YRZDV2d6grcMzED/8bBAD9pPxmZn0A6h7115I9v6jiOPQ1ZKBHoS78PlfbsMMngXS\n\t2qViNo4ljdxljXtCbTovxE3sMK1pWZH4zn9kIQE8bHl1qrkuFrmXkD8560Qycw+xqn\n\tpG2hzzQuNkpLkOd37iBRC3JyH/7G1lgpl9eakgCM=","Date":"Thu, 17 Oct 2024 11:24:39 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 1/4] ipa: rkisp1: algorithms: agc: Check for correct\n\tstats type","Message-ID":"<20241017082439.GK30496@pendragon.ideasonboard.com>","References":"<20241015203820.574326-1-stefan.klug@ideasonboard.com>\n\t<20241015203820.574326-2-stefan.klug@ideasonboard.com>\n\t<172908558612.877857.6301133540539895148@ping.linuxembedded.co.uk>\n\t<20241016143644.GA30496@pendragon.ideasonboard.com>\n\t<kjdhcu3zywtrf6diqzd53h5bygj5kgwjstxmtigi7ct5qompdh@rrfgo5rpw7fc>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<kjdhcu3zywtrf6diqzd53h5bygj5kgwjstxmtigi7ct5qompdh@rrfgo5rpw7fc>","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>"}}]