[{"id":19903,"web_url":"https://patchwork.libcamera.org/comment/19903/","msgid":"<YVJnKFnMwfcWocQ5@pendragon.ideasonboard.com>","date":"2021-09-28T00:51:52","subject":"Re: [libcamera-devel] [PATCH v2 1/2] android: Post-pone fences\n\treset in capture result","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Mon, Sep 27, 2021 at 11:36:59PM +0200, Jacopo Mondi wrote:\n> When a request has been completed and a new capture_result is created\n> we assumed all fences had been waited on, hence we set both\n\nMaybe \"we assumed we have waited for all the fences to be signalled\" ?\n\n> the release and acquisition fences to -1.\n\ns/acquisition/acquire/\n\nsame below\n\n> As no buffer is queued to libcamera::Camera for streams of type Mapped,\n> their acquisition fences went ignored. Prepare to fix that by\n> by moving fences resetting after post-processing, that will be\n> instrumented to handle fences in the next patch.\n> \n> Also correct the release_fence handling for failed captures, as the\n> framework requires the release fences to be set to the acquire fence\n> value if the acquire fence has not been waited on.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n>  src/android/camera_device.cpp | 44 ++++++++++++++++++++++++-----------\n>  1 file changed, 31 insertions(+), 13 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 21844e5114a9..3c9609d74402 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -1098,22 +1098,10 @@ void CameraDevice::requestComplete(Request *request)\n>  \t}\n>  \tCamera3RequestDescriptor &descriptor = node.mapped();\n>  \n> -\t/*\n> -\t * Prepare the capture result for the Android camera stack.\n> -\t *\n> -\t * The buffer status is set to OK and later changed to ERROR if\n> -\t * post-processing/compression fails.\n> -\t */\n>  \tcamera3_capture_result_t captureResult = {};\n>  \tcaptureResult.frame_number = descriptor.frameNumber_;\n>  \tcaptureResult.num_output_buffers = descriptor.buffers_.size();\n> -\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n> -\t\tbuffer.acquire_fence = -1;\n> -\t\tbuffer.release_fence = -1;\n> -\t\tbuffer.status = CAMERA3_BUFFER_STATUS_OK;\n> -\t}\n>  \tcaptureResult.output_buffers = descriptor.buffers_.data();\n> -\tcaptureResult.partial_result = 1;\n>  \n>  \t/*\n>  \t * If the Request has failed, abort the request by notifying the error\n> @@ -1128,8 +1116,27 @@ void CameraDevice::requestComplete(Request *request)\n>  \t\t\t    CAMERA3_MSG_ERROR_REQUEST);\n>  \n>  \t\tcaptureResult.partial_result = 0;\n> -\t\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_)\n> +\t\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n> +\t\t\tCameraStream *cameraStream =\n> +\t\t\t\tstatic_cast<CameraStream *>(buffer.stream->priv);\n> +\n> +\t\t\t/*\n> +\t\t\t * Streams of type Direct have been queued to the\n> +\t\t\t * libcamera::Camera and their acquisition fences has\n\ns/has/have/\n\n> +\t\t\t * already been waited on by the CameraWorker.\n> +\t\t\t *\n> +\t\t\t * For other stream types signal to the framework the\n> +\t\t\t * acquisition fence has not been waited on, by setting\n> +\t\t\t * the release fence to its value.\n> +\t\t\t */\n> +\t\t\tif (cameraStream->type() == CameraStream::Type::Direct)\n> +\t\t\t\tbuffer.release_fence = -1;\n> +\t\t\telse\n> +\t\t\t\tbuffer.release_fence = buffer.acquire_fence;\n> +\n> +\t\t\tbuffer.acquire_fence = -1;\n>  \t\t\tbuffer.status = CAMERA3_BUFFER_STATUS_ERROR;\n> +\t\t}\n\nBlank line here.\n\n>  \t\tcallbacks_->process_capture_result(callbacks_, &captureResult);\n>  \n>  \t\treturn;\n> @@ -1196,6 +1203,17 @@ void CameraDevice::requestComplete(Request *request)\n>  \t\t}\n>  \t}\n>  \n> +\t/*\n> +\t * Finalize the capture result by setting fences and buffer status\n> +\t * before executing the callback.\n> +\t */\n> +\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n> +\t\tbuffer.acquire_fence = -1;\n\nIdeally, it would be nice to set the acquire_fence to -1 in\nCameraWorker::Worker::waitFence(), just after closing the fence fd.\nThat's not possible yet, as the CameraWorker doesn't have access to the\ndescriptor. This will be fixed by Umang's work, but I don't think we\nshould wait until it gets merged. A \\todo comment here would be good\nthough.\n\nIf we could set acquire_fence to -1 right after waiting, the above code\nwould also be simplified, you could write\n\n\t\t\tbuffer.release_fence = buffer.acquire_fence;\n\nregardless of the stream type.\n\n> +\t\tbuffer.release_fence = -1;\n> +\t\tbuffer.status = CAMERA3_BUFFER_STATUS_OK;\n\nThis will override the buffer status set to CAMERA3_BUFFER_STATUS_ERROR\nin case post-processing fails. I think it would be easier to keep\nsetting buffer.status to CAMERA3_BUFFER_STATUS_OK at the beginning of\nthis function to avoid this problem. And if you keep the loop, you could\nas well set release_fence to -1 there too, but that's up to you.\n\n> +\t}\n> +\tcaptureResult.partial_result = 1;\n> +\n>  \tcaptureResult.result = resultMetadata->get();\n>  \tcallbacks_->process_capture_result(callbacks_, &captureResult);\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 40FB8BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Sep 2021 00:52:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8E57C6918B;\n\tTue, 28 Sep 2021 02:52:03 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 35ECF6012D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Sep 2021 02:52:02 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D7E933F1;\n\tTue, 28 Sep 2021 02:52:00 +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=\"gOaxLxiG\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632790321;\n\tbh=OhD4LZHoG9h5r0akQLvT+s0WRsYQ9k2nRSDHOVBR5pA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=gOaxLxiG6cNgSw1gUiRZsdpRPMpyF27CTQFD8pYy/1kVxFIxpKSAweMROwo4MBLKx\n\t79495DKmUfzF7cQ4WIsVt8g76irvijmVK0hwtQAsYUUIYQJEn32vr/oku5lKWxt93e\n\t6IzuOjdY4T/PFJpU5L8ShDoFjxWkIvlxeC39I9d0=","Date":"Tue, 28 Sep 2021 03:51:52 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YVJnKFnMwfcWocQ5@pendragon.ideasonboard.com>","References":"<20210927213700.25365-1-jacopo@jmondi.org>\n\t<20210927213700.25365-2-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210927213700.25365-2-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] android: Post-pone fences\n\treset in capture result","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19917,"web_url":"https://patchwork.libcamera.org/comment/19917/","msgid":"<20210928100236.dxqwzwmw33igqna4@uno.localdomain>","date":"2021-09-28T10:02:36","subject":"Re: [libcamera-devel] [PATCH v2 1/2] android: Post-pone fences\n\treset in capture result","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Tue, Sep 28, 2021 at 03:51:52AM +0300, Laurent Pinchart wrote:\n> Hi Jacopo,\n>\n> Thank you for the patch.\n>\n> On Mon, Sep 27, 2021 at 11:36:59PM +0200, Jacopo Mondi wrote:\n> > When a request has been completed and a new capture_result is created\n> > we assumed all fences had been waited on, hence we set both\n>\n> Maybe \"we assumed we have waited for all the fences to be signalled\" ?\n>\n> > the release and acquisition fences to -1.\n>\n> s/acquisition/acquire/\n>\n> same below\n>\n> > As no buffer is queued to libcamera::Camera for streams of type Mapped,\n> > their acquisition fences went ignored. Prepare to fix that by\n> > by moving fences resetting after post-processing, that will be\n> > instrumented to handle fences in the next patch.\n> >\n> > Also correct the release_fence handling for failed captures, as the\n> > framework requires the release fences to be set to the acquire fence\n> > value if the acquire fence has not been waited on.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> > ---\n> >  src/android/camera_device.cpp | 44 ++++++++++++++++++++++++-----------\n> >  1 file changed, 31 insertions(+), 13 deletions(-)\n> >\n> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> > index 21844e5114a9..3c9609d74402 100644\n> > --- a/src/android/camera_device.cpp\n> > +++ b/src/android/camera_device.cpp\n> > @@ -1098,22 +1098,10 @@ void CameraDevice::requestComplete(Request *request)\n> >  \t}\n> >  \tCamera3RequestDescriptor &descriptor = node.mapped();\n> >\n> > -\t/*\n> > -\t * Prepare the capture result for the Android camera stack.\n> > -\t *\n> > -\t * The buffer status is set to OK and later changed to ERROR if\n> > -\t * post-processing/compression fails.\n> > -\t */\n> >  \tcamera3_capture_result_t captureResult = {};\n> >  \tcaptureResult.frame_number = descriptor.frameNumber_;\n> >  \tcaptureResult.num_output_buffers = descriptor.buffers_.size();\n> > -\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n> > -\t\tbuffer.acquire_fence = -1;\n> > -\t\tbuffer.release_fence = -1;\n> > -\t\tbuffer.status = CAMERA3_BUFFER_STATUS_OK;\n> > -\t}\n> >  \tcaptureResult.output_buffers = descriptor.buffers_.data();\n> > -\tcaptureResult.partial_result = 1;\n> >\n> >  \t/*\n> >  \t * If the Request has failed, abort the request by notifying the error\n> > @@ -1128,8 +1116,27 @@ void CameraDevice::requestComplete(Request *request)\n> >  \t\t\t    CAMERA3_MSG_ERROR_REQUEST);\n> >\n> >  \t\tcaptureResult.partial_result = 0;\n> > -\t\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_)\n> > +\t\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n> > +\t\t\tCameraStream *cameraStream =\n> > +\t\t\t\tstatic_cast<CameraStream *>(buffer.stream->priv);\n> > +\n> > +\t\t\t/*\n> > +\t\t\t * Streams of type Direct have been queued to the\n> > +\t\t\t * libcamera::Camera and their acquisition fences has\n>\n> s/has/have/\n>\n> > +\t\t\t * already been waited on by the CameraWorker.\n> > +\t\t\t *\n> > +\t\t\t * For other stream types signal to the framework the\n> > +\t\t\t * acquisition fence has not been waited on, by setting\n> > +\t\t\t * the release fence to its value.\n> > +\t\t\t */\n> > +\t\t\tif (cameraStream->type() == CameraStream::Type::Direct)\n> > +\t\t\t\tbuffer.release_fence = -1;\n> > +\t\t\telse\n> > +\t\t\t\tbuffer.release_fence = buffer.acquire_fence;\n> > +\n> > +\t\t\tbuffer.acquire_fence = -1;\n> >  \t\t\tbuffer.status = CAMERA3_BUFFER_STATUS_ERROR;\n> > +\t\t}\n>\n> Blank line here.\n>\n> >  \t\tcallbacks_->process_capture_result(callbacks_, &captureResult);\n> >\n> >  \t\treturn;\n> > @@ -1196,6 +1203,17 @@ void CameraDevice::requestComplete(Request *request)\n> >  \t\t}\n> >  \t}\n> >\n> > +\t/*\n> > +\t * Finalize the capture result by setting fences and buffer status\n> > +\t * before executing the callback.\n> > +\t */\n> > +\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n> > +\t\tbuffer.acquire_fence = -1;\n>\n> Ideally, it would be nice to set the acquire_fence to -1 in\n> CameraWorker::Worker::waitFence(), just after closing the fence fd.\n> That's not possible yet, as the CameraWorker doesn't have access to the\n> descriptor. This will be fixed by Umang's work, but I don't think we\n> should wait until it gets merged. A \\todo comment here would be good\n> though.\n>\n> If we could set acquire_fence to -1 right after waiting, the above code\n> would also be simplified, you could write\n>\n> \t\t\tbuffer.release_fence = buffer.acquire_fence;\n>\n> regardless of the stream type.\n\nI considered that too, but it required giving the full descriptor to\nthe camera worker, something that would conflict with what Umang is\ndoing.\n\n>\n> > +\t\tbuffer.release_fence = -1;\n> > +\t\tbuffer.status = CAMERA3_BUFFER_STATUS_OK;\n>\n> This will override the buffer status set to CAMERA3_BUFFER_STATUS_ERROR\n> in case post-processing fails. I think it would be easier to keep\n> setting buffer.status to CAMERA3_BUFFER_STATUS_OK at the beginning of\n> this function to avoid this problem. And if you keep the loop, you could\n> as well set release_fence to -1 there too, but that's up to you.\n\nAh crabs, yes, we call the callback in the same path, sorry, I'll fix!\n\n>\n> > +\t}\n> > +\tcaptureResult.partial_result = 1;\n> > +\n> >  \tcaptureResult.result = resultMetadata->get();\n> >  \tcallbacks_->process_capture_result(callbacks_, &captureResult);\n> >  }\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 80E43BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Sep 2021 10:01:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 07E986918C;\n\tTue, 28 Sep 2021 12:01:51 +0200 (CEST)","from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C249769185\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Sep 2021 12:01:49 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay10.mail.gandi.net (Postfix) with ESMTPSA id 4DAB824000F;\n\tTue, 28 Sep 2021 10:01:49 +0000 (UTC)"],"Date":"Tue, 28 Sep 2021 12:02:36 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20210928100236.dxqwzwmw33igqna4@uno.localdomain>","References":"<20210927213700.25365-1-jacopo@jmondi.org>\n\t<20210927213700.25365-2-jacopo@jmondi.org>\n\t<YVJnKFnMwfcWocQ5@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<YVJnKFnMwfcWocQ5@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] android: Post-pone fences\n\treset in capture result","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":19923,"web_url":"https://patchwork.libcamera.org/comment/19923/","msgid":"<1ff37d3a-5600-57c3-1858-7679bba11113@ideasonboard.com>","date":"2021-09-28T11:25:57","subject":"Re: [libcamera-devel] [PATCH v2 1/2] android: Post-pone fences\n\treset in capture result","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi,\n\nOn 9/28/21 3:32 PM, Jacopo Mondi wrote:\n> Hi Laurent,\n>\n> On Tue, Sep 28, 2021 at 03:51:52AM +0300, Laurent Pinchart wrote:\n>> Hi Jacopo,\n>>\n>> Thank you for the patch.\n>>\n>> On Mon, Sep 27, 2021 at 11:36:59PM +0200, Jacopo Mondi wrote:\n>>> When a request has been completed and a new capture_result is created\n>>> we assumed all fences had been waited on, hence we set both\n>> Maybe \"we assumed we have waited for all the fences to be signalled\" ?\n>>\n>>> the release and acquisition fences to -1.\n>> s/acquisition/acquire/\n>>\n>> same below\n>>\n>>> As no buffer is queued to libcamera::Camera for streams of type Mapped,\n>>> their acquisition fences went ignored. Prepare to fix that by\n>>> by moving fences resetting after post-processing, that will be\n>>> instrumented to handle fences in the next patch.\n>>>\n>>> Also correct the release_fence handling for failed captures, as the\n>>> framework requires the release fences to be set to the acquire fence\n>>> value if the acquire fence has not been waited on.\n>>>\n>>> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n>>> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n>>> ---\n>>>   src/android/camera_device.cpp | 44 ++++++++++++++++++++++++-----------\n>>>   1 file changed, 31 insertions(+), 13 deletions(-)\n>>>\n>>> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n>>> index 21844e5114a9..3c9609d74402 100644\n>>> --- a/src/android/camera_device.cpp\n>>> +++ b/src/android/camera_device.cpp\n>>> @@ -1098,22 +1098,10 @@ void CameraDevice::requestComplete(Request *request)\n>>>   \t}\n>>>   \tCamera3RequestDescriptor &descriptor = node.mapped();\n>>>\n>>> -\t/*\n>>> -\t * Prepare the capture result for the Android camera stack.\n>>> -\t *\n>>> -\t * The buffer status is set to OK and later changed to ERROR if\n>>> -\t * post-processing/compression fails.\n>>> -\t */\n>>>   \tcamera3_capture_result_t captureResult = {};\n>>>   \tcaptureResult.frame_number = descriptor.frameNumber_;\n>>>   \tcaptureResult.num_output_buffers = descriptor.buffers_.size();\n>>> -\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n>>> -\t\tbuffer.acquire_fence = -1;\n>>> -\t\tbuffer.release_fence = -1;\n>>> -\t\tbuffer.status = CAMERA3_BUFFER_STATUS_OK;\n>>> -\t}\n>>>   \tcaptureResult.output_buffers = descriptor.buffers_.data();\n>>> -\tcaptureResult.partial_result = 1;\n>>>\n>>>   \t/*\n>>>   \t * If the Request has failed, abort the request by notifying the error\n>>> @@ -1128,8 +1116,27 @@ void CameraDevice::requestComplete(Request *request)\n>>>   \t\t\t    CAMERA3_MSG_ERROR_REQUEST);\n>>>\n>>>   \t\tcaptureResult.partial_result = 0;\n>>> -\t\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_)\n>>> +\t\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n>>> +\t\t\tCameraStream *cameraStream =\n>>> +\t\t\t\tstatic_cast<CameraStream *>(buffer.stream->priv);\n>>> +\n>>> +\t\t\t/*\n>>> +\t\t\t * Streams of type Direct have been queued to the\n>>> +\t\t\t * libcamera::Camera and their acquisition fences has\n>> s/has/have/\n>>\n>>> +\t\t\t * already been waited on by the CameraWorker.\n>>> +\t\t\t *\n>>> +\t\t\t * For other stream types signal to the framework the\n>>> +\t\t\t * acquisition fence has not been waited on, by setting\n>>> +\t\t\t * the release fence to its value.\n>>> +\t\t\t */\n>>> +\t\t\tif (cameraStream->type() == CameraStream::Type::Direct)\n>>> +\t\t\t\tbuffer.release_fence = -1;\n>>> +\t\t\telse\n>>> +\t\t\t\tbuffer.release_fence = buffer.acquire_fence;\n>>> +\n>>> +\t\t\tbuffer.acquire_fence = -1;\n>>>   \t\t\tbuffer.status = CAMERA3_BUFFER_STATUS_ERROR;\n>>> +\t\t}\n>> Blank line here.\n>>\n>>>   \t\tcallbacks_->process_capture_result(callbacks_, &captureResult);\n>>>\n>>>   \t\treturn;\n>>> @@ -1196,6 +1203,17 @@ void CameraDevice::requestComplete(Request *request)\n>>>   \t\t}\n>>>   \t}\n>>>\n>>> +\t/*\n>>> +\t * Finalize the capture result by setting fences and buffer status\n>>> +\t * before executing the callback.\n>>> +\t */\n>>> +\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n>>> +\t\tbuffer.acquire_fence = -1;\n>> Ideally, it would be nice to set the acquire_fence to -1 in\n>> CameraWorker::Worker::waitFence(), just after closing the fence fd.\n>> That's not possible yet, as the CameraWorker doesn't have access to the\n>> descriptor. This will be fixed by Umang's work, but I don't think we\n>> should wait until it gets merged. A \\todo comment here would be good\n>> though.\n>>\n>> If we could set acquire_fence to -1 right after waiting, the above code\n>> would also be simplified, you could write\n>>\n>> \t\t\tbuffer.release_fence = buffer.acquire_fence;\n>>\n>> regardless of the stream type.\n> I considered that too, but it required giving the full descriptor to\n> the camera worker, something that would conflict with what Umang is\n> doing.\n\n\nYes, it seems so. I wouldn't mind having a \\todo here, plus, a patch to \naddress this shall go on top of my map => deque work, because I do not \nthink my series will address the patch to share descriptor to \nCameraWorker (hence, I am advocating a \\todo)\n\n>\n>>> +\t\tbuffer.release_fence = -1;\n>>> +\t\tbuffer.status = CAMERA3_BUFFER_STATUS_OK;\n>> This will override the buffer status set to CAMERA3_BUFFER_STATUS_ERROR\n>> in case post-processing fails. I think it would be easier to keep\n>> setting buffer.status to CAMERA3_BUFFER_STATUS_OK at the beginning of\n>> this function to avoid this problem. And if you keep the loop, you could\n>> as well set release_fence to -1 there too, but that's up to you.\n> Ah crabs, yes, we call the callback in the same path, sorry, I'll fix!\n>\n>>> +\t}\n>>> +\tcaptureResult.partial_result = 1;\n>>> +\n>>>   \tcaptureResult.result = resultMetadata->get();\n>>>   \tcallbacks_->process_capture_result(callbacks_, &captureResult);\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 5B4C5BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Sep 2021 11:26:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9FEB96918C;\n\tTue, 28 Sep 2021 13:26:03 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 81A7A69185\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Sep 2021 13:26:02 +0200 (CEST)","from [192.168.1.104] (unknown [103.251.226.4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7B2973F1;\n\tTue, 28 Sep 2021 13:26: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=\"FC8I8d0Q\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632828362;\n\tbh=b484tSNXxZKZFkMVkGquYUEkvuMsAOdnfbXn2cqX738=;\n\th=Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=FC8I8d0QQbgvO0i/JM63wmELu7T7m51vkk0zOuQ15DekkgtEdfBU5rX8u98ZMHENZ\n\tNXPhyBt1ZKoJrnu2mw6qVR05TBS0avF/QR4y7P64TWzg/cTJQzYiuZquAWD8ioTe2r\n\to24AE0BXB0x9uN3FPXXSIHNVw93Qei3egfgkqpiI=","To":"Jacopo Mondi <jacopo@jmondi.org>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20210927213700.25365-1-jacopo@jmondi.org>\n\t<20210927213700.25365-2-jacopo@jmondi.org>\n\t<YVJnKFnMwfcWocQ5@pendragon.ideasonboard.com>\n\t<20210928100236.dxqwzwmw33igqna4@uno.localdomain>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<1ff37d3a-5600-57c3-1858-7679bba11113@ideasonboard.com>","Date":"Tue, 28 Sep 2021 16:55:57 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.10.2","MIME-Version":"1.0","In-Reply-To":"<20210928100236.dxqwzwmw33igqna4@uno.localdomain>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] android: Post-pone fences\n\treset in capture result","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]