[{"id":25980,"web_url":"https://patchwork.libcamera.org/comment/25980/","msgid":"<Y4oDOv4RfaC8Gpl5@pendragon.ideasonboard.com>","date":"2022-12-02T13:52:58","subject":"Re: [libcamera-devel] [PATCH v2 06/10] pipeline: raspberrypi:\n\tReorder startup drop frame initialisation","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Tue, Nov 29, 2022 at 01:45:30PM +0000, Naushir Patuck via libcamera-devel wrote:\n> Reorder the code such that the IPA requested startup drop frames count is\n> available before the pipeline handler allocates any stream buffers.\n> \n> This will be used in a subsequent change to stop Unicam buffer allocations if\n> there are no startup drop frames required.\n\nDo you mean \"if there are no startup drop frames required and the\napplication has configured a raw stream and always provides buffers for\nit\" ?\n\nWhy is that related ? Can't you avoid allocating internal raw buffers\neven without startup frames being dropped ? Can't you use the raw buffer\nfrom the first request to capture all the dropped frames and the first\nuseful frame ?\n\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 30 +++++++++----------\n>  1 file changed, 15 insertions(+), 15 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 86eb43a3a3c5..742521927780 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -1044,21 +1044,6 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)\n>  \tRPiCameraData *data = cameraData(camera);\n>  \tint ret;\n>  \n> -\tfor (auto const stream : data->streams_)\n> -\t\tstream->resetBuffers();\n> -\n> -\tif (!data->buffersAllocated_) {\n> -\t\t/* Allocate buffers for internal pipeline usage. */\n> -\t\tret = prepareBuffers(camera);\n> -\t\tif (ret) {\n> -\t\t\tLOG(RPI, Error) << \"Failed to allocate buffers\";\n> -\t\t\tdata->freeBuffers();\n> -\t\t\tstop(camera);\n> -\t\t\treturn ret;\n> -\t\t}\n> -\t\tdata->buffersAllocated_ = true;\n> -\t}\n> -\n>  \t/* Check if a ScalerCrop control was specified. */\n>  \tif (controls)\n>  \t\tdata->applyScalerCrop(*controls);\n> @@ -1075,6 +1060,21 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)\n>  \t/* Configure the number of dropped frames required on startup. */\n>  \tdata->dropFrameCount_ = startConfig.dropFrameCount;\n>  \n> +\tfor (auto const stream : data->streams_)\n> +\t\tstream->resetBuffers();\n> +\n> +\tif (!data->buffersAllocated_) {\n> +\t\t/* Allocate buffers for internal pipeline usage. */\n> +\t\tret = prepareBuffers(camera);\n> +\t\tif (ret) {\n> +\t\t\tLOG(RPI, Error) << \"Failed to allocate buffers\";\n> +\t\t\tdata->freeBuffers();\n> +\t\t\tstop(camera);\n> +\t\t\treturn ret;\n> +\t\t}\n> +\t\tdata->buffersAllocated_ = true;\n> +\t}\n> +\n>  \t/* We need to set the dropFrameCount_ before queueing buffers. */\n>  \tret = queueAllBuffers(camera);\n>  \tif (ret) {","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 58451BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Dec 2022 13:53:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 142F363336;\n\tFri,  2 Dec 2022 14:53:02 +0100 (CET)","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 3BE4460483\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Dec 2022 14:53:00 +0100 (CET)","from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AAE566E0;\n\tFri,  2 Dec 2022 14:52:59 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669989182;\n\tbh=goJFNfLL+LDl2adw4pygC2ir7gUnfVL26UQW+Ll2XHc=;\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=t86OFfRp1kKXgJ/X8yxRwy/CwoQibfcb8jOqtRSH2cyIv4uKdKm1bOC3Su+F6K/2F\n\tHEY4iv6lfKSHD+NhpM3hkcIVUCN6TL/vAU4d7xAyet5Vfyui+JDStj0tMy1kmzpBcH\n\t8rNIUI8z27G4oIkTxN6D3Zl600hVxohwCWMGtaMajZlgk33jkG9+WFY1JhqRzaownR\n\t7AQAHkXVfzviusMnOPbTiDvIikzhIV54w8r6uVsA1GpiVsfnrskjKSOBX+N4UMfvJm\n\tG0z2lQzj84hzu64tmrSuuF6U+/GomoIWcH/PRr+Y/FNfzqPP7F4XdfEZ7284uwdmfN\n\t8V7UGwTyH+vkA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669989179;\n\tbh=goJFNfLL+LDl2adw4pygC2ir7gUnfVL26UQW+Ll2XHc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=JpplBZnzu7WyjERGMUrxwyigU0liQBQ3yQDkECObmAtrzqvq+5C1tPJxNL5FoposQ\n\tsITYEdsQIgsoWXogfMtKqj5aMy/t60vwip/N0JTYfC/Dx/yAyd2d/KtdUXfDnijYUB\n\tQJPQnjd4aC66C7G+8TcwPKnBmVYRfzV3aMTbjF8Y="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"JpplBZnz\"; dkim-atps=neutral","Date":"Fri, 2 Dec 2022 15:52:58 +0200","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<Y4oDOv4RfaC8Gpl5@pendragon.ideasonboard.com>","References":"<20221129134534.2933-1-naush@raspberrypi.com>\n\t<20221129134534.2933-7-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20221129134534.2933-7-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2 06/10] pipeline: raspberrypi:\n\tReorder startup drop frame initialisation","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@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":25984,"web_url":"https://patchwork.libcamera.org/comment/25984/","msgid":"<CAEmqJPrao9z9E2dffwF=iyX_Wb+7OyA2HcKuog5-9jJybc+ADA@mail.gmail.com>","date":"2022-12-02T14:42:38","subject":"Re: [libcamera-devel] [PATCH v2 06/10] pipeline: raspberrypi:\n\tReorder startup drop frame initialisation","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Laurent,\n\nOn Fri, 2 Dec 2022 at 13:53, Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> Hi Naush,\n>\n> Thank you for the patch.\n>\n> On Tue, Nov 29, 2022 at 01:45:30PM +0000, Naushir Patuck via\n> libcamera-devel wrote:\n> > Reorder the code such that the IPA requested startup drop frames count is\n> > available before the pipeline handler allocates any stream buffers.\n> >\n> > This will be used in a subsequent change to stop Unicam buffer\n> allocations if\n> > there are no startup drop frames required.\n>\n> Do you mean \"if there are no startup drop frames required and the\n> application has configured a raw stream and always provides buffers for\n> it\" ?\n>\n\nYes!\n\n\n>\n> Why is that related ? Can't you avoid allocating internal raw buffers\n> even without startup frames being dropped ? Can't you use the raw buffer\n> from the first request to capture all the dropped frames and the first\n> useful frame ?\n>\n\nThere are a couple of reasons for this:\n\n1) I'm working under the assumption that I cannot enqueue the same buffer\nmultiple times in v4l2  Because of this, I can only ever queue 1 buffer,\nhave it\ndequeued, processed by the ISP, and requeue it back to Unicam.  This\neffectively halves my overall framerate because of the added latency of\nrunning\nthe ISP.\n\n2) Even if V4L2 does allow enquing the same framebuffer multiple times,\nthere is\na possible (probable?) HW race condition where the ISP could be processing\nthe\nbuffer for frame N, while Unicam is writing out to the buffer for frame N +\n1.\n\n It would be interesting to know if (1) is actually possible.  I don't\nrecall exactly, but\nI think I did try it, and might have got complaints from the v4l2 framework.\n\nRegards,\nNaush\n\n\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> > ---\n> >  .../pipeline/raspberrypi/raspberrypi.cpp      | 30 +++++++++----------\n> >  1 file changed, 15 insertions(+), 15 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > index 86eb43a3a3c5..742521927780 100644\n> > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > @@ -1044,21 +1044,6 @@ int PipelineHandlerRPi::start(Camera *camera,\n> const ControlList *controls)\n> >       RPiCameraData *data = cameraData(camera);\n> >       int ret;\n> >\n> > -     for (auto const stream : data->streams_)\n> > -             stream->resetBuffers();\n> > -\n> > -     if (!data->buffersAllocated_) {\n> > -             /* Allocate buffers for internal pipeline usage. */\n> > -             ret = prepareBuffers(camera);\n> > -             if (ret) {\n> > -                     LOG(RPI, Error) << \"Failed to allocate buffers\";\n> > -                     data->freeBuffers();\n> > -                     stop(camera);\n> > -                     return ret;\n> > -             }\n> > -             data->buffersAllocated_ = true;\n> > -     }\n> > -\n> >       /* Check if a ScalerCrop control was specified. */\n> >       if (controls)\n> >               data->applyScalerCrop(*controls);\n> > @@ -1075,6 +1060,21 @@ int PipelineHandlerRPi::start(Camera *camera,\n> const ControlList *controls)\n> >       /* Configure the number of dropped frames required on startup. */\n> >       data->dropFrameCount_ = startConfig.dropFrameCount;\n> >\n> > +     for (auto const stream : data->streams_)\n> > +             stream->resetBuffers();\n> > +\n> > +     if (!data->buffersAllocated_) {\n> > +             /* Allocate buffers for internal pipeline usage. */\n> > +             ret = prepareBuffers(camera);\n> > +             if (ret) {\n> > +                     LOG(RPI, Error) << \"Failed to allocate buffers\";\n> > +                     data->freeBuffers();\n> > +                     stop(camera);\n> > +                     return ret;\n> > +             }\n> > +             data->buffersAllocated_ = true;\n> > +     }\n> > +\n> >       /* We need to set the dropFrameCount_ before queueing buffers. */\n> >       ret = queueAllBuffers(camera);\n> >       if (ret) {\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\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 22F0ABDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Dec 2022 14:42:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9CDDA63336;\n\tFri,  2 Dec 2022 15:42:55 +0100 (CET)","from mail-il1-x134.google.com (mail-il1-x134.google.com\n\t[IPv6:2607:f8b0:4864:20::134])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 17B9660483\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Dec 2022 15:42:54 +0100 (CET)","by mail-il1-x134.google.com with SMTP id x11so1306797ilo.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 02 Dec 2022 06:42:54 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669992175;\n\tbh=+9dwSVmC+LfX4vdOgkLFNSzPMJnhqqfNR6pxUSsji6U=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=XURRCCDSnR3WmKZZvJ65pONdicy5uPrDtlmtExoCftmVIXsxNniNXW49bm9shkLZs\n\t7/mMX6VIlKAVOJPN/+P2wLT4tFypznWi/WHaQs1f77y77ZOVnyf4arAXQ0ZnRck4au\n\tK3QoiWnGUTVIufl9yhyFdwntaNIj6VCRq5cPwMm4Q9tzzel0K6cig4NH+YHQpCMnYS\n\tjIw9ZNHF5/WFXcOQrC91HN0hIqVcG6zhdG692p2K/IJKD7B9tXZazrgL3yIXBq08Au\n\t7p2ZhlM1l41nnphYjbOY7m0gF6o7BHGVOYKqpp9bE+FNb1ADkuxpbS/ojSDQTraeD5\n\tXY3d3mLAE3koQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\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=R3bVn9ZZy9owyEFC627KQHEQJKPAcJEnVyfne4+ZAbU=;\n\tb=VN+3NxnzRL86j1KGoW6OUgqa+5fSbOTm6UK/Xg1OVodYDlvRANSIIZIiKuALLChY1n\n\t7UXoFlgct524H37BuAt7cbiaNZXCFTEon1j+AoY5EYkWA2iLUX+ptbb9kUaS7aIR9l7y\n\to5htxx9UTtMK4cj2fRDgOJY5r2bgUOP3ufvskFIq5psZZ9OFCjHg4SES1Rzcn+PYP1Z4\n\tBYGjH37kT5LGaxNWCBPAKfE9E6B4D8WTUCd5luFcBIIluEL/wdkPuGSUwXBZ/Q3goBVx\n\tpRBWizerqc2BmrPyyrfZcgKXi513SAE61sl3bzZP7noCM5dW5cS7fNUhpiYl8PXzqMnD\n\tPHJA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"VN+3Nxnz\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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=R3bVn9ZZy9owyEFC627KQHEQJKPAcJEnVyfne4+ZAbU=;\n\tb=3JQ9Ms9h3BiSogFTnm6/g2FFeCxqNvFRkJn3xEZDPtyJX4Upuc3exTCfhKONVPC3jD\n\tJBUTeZwbUOoRrDHrvoUVJEo9Ttuoqum4OLzeYN+sGC4rC7c78lYoKT83IbrJ3RuuLH6b\n\tLG9sFSltLmnEDXrA/JArDv28piU5dxzB2cfhXYPoP28mlWqc5NzAPuM7krWUa+2SIEXi\n\t3WmSgGqob7OiOjavj/w5H9oLYN4ocfr6/iz+D+YlY9hz/THVQU3ZTz0O34CHI0i1Qk4c\n\tmasraAxysgDpYjq5lzitQV/vN664UZxsneyt6yvfwxWSzSUB4VaSREztoxQ6+PwSpYxx\n\tCKAA==","X-Gm-Message-State":"ANoB5pmvxbYT/Mutm13sG+IoX7k1RnE/cMiuI/Vc2au56rapbziCXtxy\n\tBYJBsPOGleRHG5IYO4Dd1DRiOP+ky2SutBdUMPbPSuUXBiIwQw==","X-Google-Smtp-Source":"AA0mqf68NZx1749EiLcRk6jDdF7T0Ax1g6IdnRXj75yjAGk8QpMItcxVm0f50LKHI1vpOiIIcd28ujE9muubyQ6gkkE=","X-Received":"by 2002:a92:8748:0:b0:2f9:b1d0:2f24 with SMTP id\n\td8-20020a928748000000b002f9b1d02f24mr33379469ilm.181.1669992172828;\n\tFri, 02 Dec 2022 06:42:52 -0800 (PST)","MIME-Version":"1.0","References":"<20221129134534.2933-1-naush@raspberrypi.com>\n\t<20221129134534.2933-7-naush@raspberrypi.com>\n\t<Y4oDOv4RfaC8Gpl5@pendragon.ideasonboard.com>","In-Reply-To":"<Y4oDOv4RfaC8Gpl5@pendragon.ideasonboard.com>","Date":"Fri, 2 Dec 2022 14:42:38 +0000","Message-ID":"<CAEmqJPrao9z9E2dffwF=iyX_Wb+7OyA2HcKuog5-9jJybc+ADA@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"0000000000003d5b0305eed95a63\"","Subject":"Re: [libcamera-devel] [PATCH v2 06/10] pipeline: raspberrypi:\n\tReorder startup drop frame initialisation","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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.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":25991,"web_url":"https://patchwork.libcamera.org/comment/25991/","msgid":"<Y4pdmYXMq17NcBBY@pendragon.ideasonboard.com>","date":"2022-12-02T20:18:33","subject":"Re: [libcamera-devel] [PATCH v2 06/10] pipeline: raspberrypi:\n\tReorder startup drop frame initialisation","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nOn Fri, Dec 02, 2022 at 02:42:38PM +0000, Naushir Patuck wrote:\n> On Fri, 2 Dec 2022 at 13:53, Laurent Pinchart wrote:\n> > On Tue, Nov 29, 2022 at 01:45:30PM +0000, Naushir Patuck via libcamera-devel wrote:\n> > > Reorder the code such that the IPA requested startup drop frames count is\n> > > available before the pipeline handler allocates any stream buffers.\n> > >\n> > > This will be used in a subsequent change to stop Unicam buffer allocations if\n> > > there are no startup drop frames required.\n> >\n> > Do you mean \"if there are no startup drop frames required and the\n> > application has configured a raw stream and always provides buffers for\n> > it\" ?\n> \n> Yes!\n\nCould you update the commit message please ?\n\n> > Why is that related ? Can't you avoid allocating internal raw buffers\n> > even without startup frames being dropped ? Can't you use the raw buffer\n> > from the first request to capture all the dropped frames and the first\n> > useful frame ?\n> \n> There are a couple of reasons for this:\n> \n> 1) I'm working under the assumption that I cannot enqueue the same buffer\n> multiple times in v4l2  Because of this, I can only ever queue 1 buffer, have it\n> dequeued, processed by the ISP, and requeue it back to Unicam.  This\n> effectively halves my overall framerate because of the added latency of running\n> the ISP.\n> \n> 2) Even if V4L2 does allow enquing the same framebuffer multiple times, there is\n> a possible (probable?) HW race condition where the ISP could be processing the\n> buffer for frame N, while Unicam is writing out to the buffer for frame N + 1.\n> \n> It would be interesting to know if (1) is actually possible.  I don't recall exactly, but\n> I think I did try it, and might have got complaints from the v4l2 framework.\n\n(1) should be checked indeed. I had missed in my initial review the fact\nthat the buffer still needed to be processed by the ISP for algorithms\nto converge, so (2) is a valid concern.\n\nIn any case, even if we handled frame drop and buffer allocation\ndifferently, this patch wouldn't hurt, so\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> > > ---\n> > >  .../pipeline/raspberrypi/raspberrypi.cpp      | 30 +++++++++----------\n> > >  1 file changed, 15 insertions(+), 15 deletions(-)\n> > >\n> > > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > index 86eb43a3a3c5..742521927780 100644\n> > > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > @@ -1044,21 +1044,6 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)\n> > >       RPiCameraData *data = cameraData(camera);\n> > >       int ret;\n> > >\n> > > -     for (auto const stream : data->streams_)\n> > > -             stream->resetBuffers();\n> > > -\n> > > -     if (!data->buffersAllocated_) {\n> > > -             /* Allocate buffers for internal pipeline usage. */\n> > > -             ret = prepareBuffers(camera);\n> > > -             if (ret) {\n> > > -                     LOG(RPI, Error) << \"Failed to allocate buffers\";\n> > > -                     data->freeBuffers();\n> > > -                     stop(camera);\n> > > -                     return ret;\n> > > -             }\n> > > -             data->buffersAllocated_ = true;\n> > > -     }\n> > > -\n> > >       /* Check if a ScalerCrop control was specified. */\n> > >       if (controls)\n> > >               data->applyScalerCrop(*controls);\n> > > @@ -1075,6 +1060,21 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)\n> > >       /* Configure the number of dropped frames required on startup. */\n> > >       data->dropFrameCount_ = startConfig.dropFrameCount;\n> > >\n> > > +     for (auto const stream : data->streams_)\n> > > +             stream->resetBuffers();\n> > > +\n> > > +     if (!data->buffersAllocated_) {\n> > > +             /* Allocate buffers for internal pipeline usage. */\n> > > +             ret = prepareBuffers(camera);\n> > > +             if (ret) {\n> > > +                     LOG(RPI, Error) << \"Failed to allocate buffers\";\n> > > +                     data->freeBuffers();\n> > > +                     stop(camera);\n> > > +                     return ret;\n> > > +             }\n> > > +             data->buffersAllocated_ = true;\n> > > +     }\n> > > +\n> > >       /* We need to set the dropFrameCount_ before queueing buffers. */\n> > >       ret = queueAllBuffers(camera);\n> > >       if (ret) {","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 22C1FBE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Dec 2022 20:18:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4B1146333F;\n\tFri,  2 Dec 2022 21:18:36 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A0D3B60483\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Dec 2022 21:18:35 +0100 (CET)","from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 10F7A6E0;\n\tFri,  2 Dec 2022 21:18:35 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1670012316;\n\tbh=N8GFSwCaK0wyFI0emt6K2ThNFUyFoOWOySIVXTOB3LU=;\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=2ESOVdL5A5G00Wk0LSo+MqY6h+s+lUuNKQISo/ZbrVYFCK6IpDzYK8Zi5IUeCH9tC\n\tf5cDDnmTYsuDeIPy7Akj2P9d9ZjQdM6M220IP7K4zpoB6pYin35r0ED+i6k9YJPpAF\n\tgV/kkpH8oyZgm+DBPNX54YtRMpau1oh/Kx64nPxWpP0rp+LDcYANIZIdRLHKAdBrSb\n\t+R4JYRmld1UBIqUbWTxZsqOs970Qm/Ed8hsfSguXhE4JWiDBarFCQHvXKm5gCquJI8\n\tV5+Bc8DGGEVRZcE80mWLqdJVTuNgCkqEUVccH0RrRyHDK6gwPqogKGz3zvWA4ow30l\n\tZzcRcAsfwtrqg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1670012315;\n\tbh=N8GFSwCaK0wyFI0emt6K2ThNFUyFoOWOySIVXTOB3LU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ANHkqCTMwRSBCs+OvQiQVWmcYmkevValPBeXtfTyQaPLkAs5pKMPuC8cAQb1zAmi9\n\tjnK+LxlE2J9eJ0i66xoKQsafRZcE+ddiZ6/PG/QlkO+0J7ZwcSiE/lNlM+B0HjnErC\n\tvQcRvRQ21p3PWNaJuHmttijs+XswYpVFqC8N18gs="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ANHkqCTM\"; dkim-atps=neutral","Date":"Fri, 2 Dec 2022 22:18:33 +0200","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<Y4pdmYXMq17NcBBY@pendragon.ideasonboard.com>","References":"<20221129134534.2933-1-naush@raspberrypi.com>\n\t<20221129134534.2933-7-naush@raspberrypi.com>\n\t<Y4oDOv4RfaC8Gpl5@pendragon.ideasonboard.com>\n\t<CAEmqJPrao9z9E2dffwF=iyX_Wb+7OyA2HcKuog5-9jJybc+ADA@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAEmqJPrao9z9E2dffwF=iyX_Wb+7OyA2HcKuog5-9jJybc+ADA@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2 06/10] pipeline: raspberrypi:\n\tReorder startup drop frame initialisation","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@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>"}}]