[{"id":1915,"web_url":"https://patchwork.libcamera.org/comment/1915/","msgid":"<20190618225337.GM23556@pendragon.ideasonboard.com>","date":"2019-06-18T22:53:37","subject":"Re: [libcamera-devel] [PATCH v3 07/16] libcamera: v4l2_subdevice:\n\tRework enumPadSizes()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Sun, Jun 16, 2019 at 03:33:53PM +0200, Niklas Söderlund wrote:\n> Align the enumPadSizes() interface and implementation with that of\n> enumPadCodes(). There is no functional change.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/include/v4l2_subdevice.h |  4 +--\n>  src/libcamera/v4l2_subdevice.cpp       | 37 ++++++++++++++------------\n>  2 files changed, 22 insertions(+), 19 deletions(-)\n> \n> diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> index e714e2575022c04d..c6fdf417b43c0423 100644\n> --- a/src/libcamera/include/v4l2_subdevice.h\n> +++ b/src/libcamera/include/v4l2_subdevice.h\n> @@ -58,8 +58,8 @@ protected:\n>  \n>  private:\n>  \tstd::vector<unsigned int> enumPadCodes(unsigned int pad);\n> -\tint enumPadSizes(unsigned int pad, unsigned int code,\n> -\t\t\t std::vector<SizeRange> *size);\n> +\tstd::vector<SizeRange> enumPadSizes(unsigned int pad,\n> +\t\t\t\t\t    unsigned int code);\n>  \n>  \tint setSelection(unsigned int pad, unsigned int target,\n>  \t\t\t Rectangle *rect);\n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index 99e202fa264af5a6..35052b4aa45d3e42 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -209,10 +209,15 @@ FormatEnum V4L2Subdevice::formats(unsigned int pad)\n>  \t\treturn {};\n>  \t}\n>  \n> -\tfor (unsigned int code : enumPadCodes(pad))\n> -\t\tif (enumPadSizes(pad, code, &formatMap[code]))\n> +\tfor (unsigned int code : enumPadCodes(pad)) {\n> +\t\tstd::vector<SizeRange> sizes = enumPadSizes(pad, code);\n> +\n\nYou can remove this blank line.\n\n> +\t\tif (sizes.empty())\n>  \t\t\treturn {};\n>  \n> +\t\tformatMap[code] = sizes;\n> +\t}\n> +\n>  \treturn formatMap;\n>  }\n>  \n> @@ -335,25 +340,25 @@ std::vector<unsigned int> V4L2Subdevice::enumPadCodes(unsigned int pad)\n>  \treturn codes;\n>  }\n>  \n> -int V4L2Subdevice::enumPadSizes(unsigned int pad,unsigned int code,\n> -\t\t\t\tstd::vector<SizeRange> *sizes)\n> +std::vector<SizeRange> V4L2Subdevice::enumPadSizes(unsigned int pad,\n> +\t\t\t\t\t\t   unsigned int code)\n>  {\n> -\tstruct v4l2_subdev_frame_size_enum sizeEnum = {};\n> +\tstd::vector<SizeRange> sizes;\n>  \tint ret;\n>  \n> -\tsizeEnum.index = 0;\n> -\tsizeEnum.pad = pad;\n> -\tsizeEnum.code = code;\n> -\tsizeEnum.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n> -\twhile (true) {\n> +\tfor (unsigned int index = 0;; index++) {\n> +\t\tstruct v4l2_subdev_frame_size_enum sizeEnum = {};\n> +\t\tsizeEnum.index = index;\n> +\t\tsizeEnum.pad = pad;\n> +\t\tsizeEnum.code = code;\n> +\t\tsizeEnum.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n> +\n>  \t\tret = ioctl(fd_, VIDIOC_SUBDEV_ENUM_FRAME_SIZE, &sizeEnum);\n>  \t\tif (ret)\n>  \t\t\tbreak;\n>  \n> -\t\tsizes->emplace_back(sizeEnum.min_width, sizeEnum.min_height,\n> +\t\tsizes.emplace_back(sizeEnum.min_width, sizeEnum.min_height,\n>  \t\t\t\t    sizeEnum.max_width, sizeEnum.max_height);\n\nWrong indentation.\n\nWith these small issues address,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> -\n> -\t\tsizeEnum.index++;\n>  \t}\n>  \n>  \tif (ret && (errno != EINVAL && errno != ENOTTY)) {\n> @@ -361,12 +366,10 @@ int V4L2Subdevice::enumPadSizes(unsigned int pad,unsigned int code,\n>  \t\tLOG(V4L2Subdev, Error)\n>  \t\t\t<< \"Unable to enumerate sizes on pad \" << pad\n>  \t\t\t<< \": \" << strerror(-ret);\n> -\t\tsizes->clear();\n> -\n> -\t\treturn ret;\n> +\t\treturn {};\n>  \t}\n>  \n> -\treturn 0;\n> +\treturn sizes;\n>  }\n>  \n>  int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B02D760BF5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Jun 2019 00:53:55 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7F759D5;\n\tWed, 19 Jun 2019 00:53:54 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1560898434;\n\tbh=bmK1rG3DzCtwyxs4cP1r7GrryUI6p3afM0EkxIIUfX4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=As7Tat55ZuL00G3TS/6toMqpztJBqOW3xbg3jRDhcCj/rHL1OM2Lr8spqmGIaPbY7\n\taQTK3NV3YcwnPREDXjhHYWcFHhs0x7fvHNOY13byYBAAjCXGp2BPrUMNl/awd5soqH\n\tJinxQWqE/3fV9Pa+aTg6llF4ed3hhhfILCU31TSM=","Date":"Wed, 19 Jun 2019 01:53:37 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190618225337.GM23556@pendragon.ideasonboard.com>","References":"<20190616133402.21934-1-niklas.soderlund@ragnatech.se>\n\t<20190616133402.21934-8-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190616133402.21934-8-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 07/16] libcamera: v4l2_subdevice:\n\tRework enumPadSizes()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Tue, 18 Jun 2019 22:53:55 -0000"}}]