[{"id":11802,"web_url":"https://patchwork.libcamera.org/comment/11802/","msgid":"<20200803163058.GK5926@pendragon.ideasonboard.com>","date":"2020-08-03T16:30:58","subject":"Re: [libcamera-devel] [PATCH v2 08/12] android: camera_device:\n\tQuery plane length","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Mon, Aug 03, 2020 at 05:18:12PM +0100, Kieran Bingham wrote:\n> Use lseek to query the length of planes where possible rather than leaving\n> the plane.length as zero, which prevents mapping buffers for software\n> processing.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n> v2:\n>  - no longer support an invalid plane length.\n> ---\n>  src/android/camera_device.cpp | 13 +++++++------\n>  1 file changed, 7 insertions(+), 6 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 78b0246e40f0..9f3f3315aed4 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -1036,12 +1036,13 @@ FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer\n>  \t\t\tbreak;\n>  \t\t}\n>  \n> -\t\t/*\n> -\t\t * Setting length to zero here is OK as the length is only used\n> -\t\t * to map the memory of the plane. Libcamera do not need to poke\n> -\t\t * at the memory content queued by the HAL.\n> -\t\t */\n> -\t\tplane.length = 0;\n> +\t\toff_t length = lseek(plane.fd.fd(), 0, SEEK_END);\n> +\t\tif (length == -1) {\n> +\t\t\tLOG(HAL, Error) << \"Failed to query plane length\";\n> +\t\t\tbreak;\n> +\t\t}\n> +\n> +\t\tplane.length = length;\n>  \t\tplanes.push_back(std::move(plane));\n>  \t}\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 AD456BD87A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Aug 2020 16:31:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4389C60745;\n\tMon,  3 Aug 2020 18:31:11 +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 0836A605A9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Aug 2020 18:31:10 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E9D55543;\n\tMon,  3 Aug 2020 18:31:08 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"OSAth6Zh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1596472269;\n\tbh=uspsNlS3ydHWrISx0eyUl+JnVaQ8LOI3op0bx7J5Gds=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=OSAth6ZhAAns8b5LGNHroQhQuY346QP8kCtqCar+dvuko91czmA4WO6ySL56kWrIQ\n\to3E6L0OUzubEIzOZrY7Hmg/DT6i0cNkrKLrhLJOkO04vPmWj6NIW9vOwO7e4iORFyV\n\tfLY4Uet4Sa7y0qpNDpKyge0c3yQkLd3a35sZ2dXs=","Date":"Mon, 3 Aug 2020 19:30:58 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20200803163058.GK5926@pendragon.ideasonboard.com>","References":"<20200803161816.107113-1-kieran.bingham@ideasonboard.com>\n\t<20200803161816.107113-9-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200803161816.107113-9-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 08/12] android: camera_device:\n\tQuery plane length","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 <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":11803,"web_url":"https://patchwork.libcamera.org/comment/11803/","msgid":"<20200803163251.GL5926@pendragon.ideasonboard.com>","date":"2020-08-03T16:32:51","subject":"Re: [libcamera-devel] [PATCH v2 08/12] android: camera_device:\n\tQuery plane length","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Mon, Aug 03, 2020 at 07:30:59PM +0300, Laurent Pinchart wrote:\n> Hi Kieran,\n> \n> Thank you for the patch.\n> \n> On Mon, Aug 03, 2020 at 05:18:12PM +0100, Kieran Bingham wrote:\n> > Use lseek to query the length of planes where possible rather than leaving\n> > the plane.length as zero, which prevents mapping buffers for software\n> > processing.\n> > \n> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > ---\n> > v2:\n> >  - no longer support an invalid plane length.\n> > ---\n> >  src/android/camera_device.cpp | 13 +++++++------\n> >  1 file changed, 7 insertions(+), 6 deletions(-)\n> > \n> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> > index 78b0246e40f0..9f3f3315aed4 100644\n> > --- a/src/android/camera_device.cpp\n> > +++ b/src/android/camera_device.cpp\n> > @@ -1036,12 +1036,13 @@ FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer\n> >  \t\t\tbreak;\n> >  \t\t}\n> >  \n> > -\t\t/*\n> > -\t\t * Setting length to zero here is OK as the length is only used\n> > -\t\t * to map the memory of the plane. Libcamera do not need to poke\n> > -\t\t * at the memory content queued by the HAL.\n> > -\t\t */\n> > -\t\tplane.length = 0;\n> > +\t\toff_t length = lseek(plane.fd.fd(), 0, SEEK_END);\n> > +\t\tif (length == -1) {\n> > +\t\t\tLOG(HAL, Error) << \"Failed to query plane length\";\n> > +\t\t\tbreak;\n\nI spoke too fast. This will cause the function to return a FrameBuffer\nwith a too small number of planes. You should instead return nullptr\nhere.\n\nThe Rb tag still holds.\n\n> > +\t\t}\n> > +\n> > +\t\tplane.length = length;\n> >  \t\tplanes.push_back(std::move(plane));\n> >  \t}\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 3826CBD87A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Aug 2020 16:33:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B8B866194A;\n\tMon,  3 Aug 2020 18:33:03 +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 E7975605A9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Aug 2020 18:33:02 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 58E66543;\n\tMon,  3 Aug 2020 18:33:02 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"YMtcNOeq\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1596472382;\n\tbh=XSjrlIWBtrSdq3eMMIITc3FZl8i0YLh6WKciZu6KjWo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=YMtcNOeqyE4hgnMaGu18xYiv8WAUTCXPG+e6U0GEB99M9XzgAI6NIdY8c7mVwj2Gc\n\tm+LpjM4AfCj81n2iLXDkF5ChTNz+jIkjjYcIlw3oU6r3ZlOsTwcbSTp0NZAC5dYR5b\n\tFUlwvZiWG0IfVf4L+9HEuGhJlqC7ufWFSVTK2nxA=","Date":"Mon, 3 Aug 2020 19:32:51 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20200803163251.GL5926@pendragon.ideasonboard.com>","References":"<20200803161816.107113-1-kieran.bingham@ideasonboard.com>\n\t<20200803161816.107113-9-kieran.bingham@ideasonboard.com>\n\t<20200803163058.GK5926@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200803163058.GK5926@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 08/12] android: camera_device:\n\tQuery plane length","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 <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]