[{"id":2515,"web_url":"https://patchwork.libcamera.org/comment/2515/","msgid":"<20190828113435.GQ28351@bigcity.dyn.berto.se>","date":"2019-08-28T11:34:35","subject":"Re: [libcamera-devel] [PATCH v2 6/7] libcamera: v4l2_subdevice: Add\n\tselection support","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your work.\n\nOn 2019-08-27 11:50:06 +0200, Jacopo Mondi wrote:\n> Currently the selection API are implemented by wrappers of the\n> setSelection method. As we add support for more targets, adding new\n> wrapper does not scale well. Make the setSelection operation public and\n> implement getSelection, and require callers to specify the selection\n> target in the operation parameters list.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/include/v4l2_subdevice.h |   9 +-\n>  src/libcamera/pipeline/ipu3/ipu3.cpp   |   4 +-\n>  src/libcamera/v4l2_subdevice.cpp       | 113 ++++++++++++++++---------\n>  3 files changed, 78 insertions(+), 48 deletions(-)\n> \n> diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> index 9c077674f997..b69b93280894 100644\n> --- a/src/libcamera/include/v4l2_subdevice.h\n> +++ b/src/libcamera/include/v4l2_subdevice.h\n> @@ -41,8 +41,10 @@ public:\n>  \n>  \tconst MediaEntity *entity() const { return entity_; }\n>  \n> -\tint setCrop(unsigned int pad, Rectangle *rect);\n> -\tint setCompose(unsigned int pad, Rectangle *rect);\n> +\tint getSelection(unsigned int pad, unsigned int target,\n> +\t\t\t Rectangle *rect);\n> +\tint setSelection(unsigned int pad, unsigned int target,\n> +\t\t\t Rectangle *rect);\n>  \n>  \tImageFormats formats(unsigned int pad);\n>  \n> @@ -60,9 +62,6 @@ private:\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> -\n>  \tconst MediaEntity *entity_;\n>  };\n>  \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 827906d5cd2e..bd027c7f10be 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -1071,11 +1071,11 @@ int ImgUDevice::configureInput(const Size &size,\n>  \t\t.w = inputFormat->size.width,\n>  \t\t.h = inputFormat->size.height,\n>  \t};\n> -\tret = imgu_->setCrop(PAD_INPUT, &rect);\n> +\tret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_CROP, &rect);\n>  \tif (ret)\n>  \t\treturn ret;\n>  \n> -\tret = imgu_->setCompose(PAD_INPUT, &rect);\n> +\tret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_COMPOSE, &rect);\n>  \tif (ret)\n>  \t\treturn ret;\n>  \n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index a188298de34c..262dfa23ee57 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -127,25 +127,87 @@ int V4L2Subdevice::open()\n>   */\n>  \n>  /**\n> - * \\brief Set a crop rectangle on one of the V4L2 subdevice pads\n> - * \\param[in] pad The 0-indexed pad number the rectangle is to be applied to\n> - * \\param[inout] rect The rectangle describing crop target area\n> + * \\brief Get the V4L2_SEL_TGT_* selection \\a target rectangle on \\a pad\n> + * \\param[in] pad The 0-indexed pad number to get the selection target from\n> + * \\param[in] target The selection target V4L2_SEL_TGT_* as defined by the V4L2\n> + * selection API\n> + * \\param[out] rect The rectangle describing the returned selection target\n> + *\n> + * This operations wraps the VIDIOC_SUBDEV_G_SELECTION ioctl, applied to one of\n> + * the V4L2_SEL_TGT_* targets defined by the V4L2 API on the subdevice \\a pad.\n> + * The retrieved selection rectangle is returned in the output parameter \\a\n> + * rect.\n> + *\n>   * \\return 0 on success or a negative error code otherwise\n>   */\n> -int V4L2Subdevice::setCrop(unsigned int pad, Rectangle *rect)\n> +int V4L2Subdevice::getSelection(unsigned int pad, unsigned int target,\n> +\t\t\t\tRectangle *rect)\n>  {\n> -\treturn setSelection(pad, V4L2_SEL_TGT_CROP, rect);\n> +\tstruct v4l2_subdev_selection sel = {};\n> +\n> +\tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n> +\tsel.pad = pad;\n> +\tsel.target = target;\n> +\n> +\tint ret = ioctl(VIDIOC_SUBDEV_G_SELECTION, &sel);\n> +\tif (ret < 0) {\n> +\t\tLOG(V4L2, Error)\n> +\t\t\t<< \"Unable to get rectangle \" << target << \" on pad \"\n> +\t\t\t<< pad << \": \" << strerror(-ret);\n> +\t\treturn ret;\n> +\t}\n> +\n> +\trect->x = sel.r.left;\n> +\trect->y = sel.r.top;\n> +\trect->w = sel.r.width;\n> +\trect->h = sel.r.height;\n> +\n> +\treturn 0;\n>  }\n>  \n>  /**\n> - * \\brief Set a compose rectangle on one of the V4L2 subdevice pads\n> - * \\param[in] pad The 0-indexed pad number the rectangle is to be applied to\n> - * \\param[inout] rect The rectangle describing the compose target area\n> + * \\brief Set the V4L2_SEL_TGT_* selection \\a target rectangle on \\a pad\n> + * \\param[in] pad The 0-indexed pad number to set the selection target on\n> + * \\param[in] target The selection target V4L2_SEL_TGT_* as defined by the V4L2\n> + * selection API\n> + * \\param[inout] rect The rectangle to be applied to the the selection \\a target\n> + *\n> + * This operations wraps the VIDIOC_SUBDEV_S_SELECTION ioctl, applied to one of\n> + * the V4L2_SEL_TGT_* targets defined by the V4L2 API on the subdevice \\a pad.\n> + * The selection rectangle to apply is described by the parameter \\a rect,\n> + * which is updated to reflect what has been actually applied on the subdevice\n> + * when the method returns.\n> + *\n>   * \\return 0 on success or a negative error code otherwise\n>   */\n> -int V4L2Subdevice::setCompose(unsigned int pad, Rectangle *rect)\n> +int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n> +\t\t\t\tRectangle *rect)\n>  {\n> -\treturn setSelection(pad, V4L2_SEL_TGT_COMPOSE, rect);\n> +\tstruct v4l2_subdev_selection sel = {};\n> +\n> +\tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n> +\tsel.pad = pad;\n> +\tsel.target = target;\n> +\n> +\tsel.r.left = rect->x;\n> +\tsel.r.top = rect->y;\n> +\tsel.r.width = rect->w;\n> +\tsel.r.height = rect->h;\n> +\n> +\tint ret = ioctl(VIDIOC_SUBDEV_S_SELECTION, &sel);\n> +\tif (ret < 0) {\n> +\t\tLOG(V4L2, Error)\n> +\t\t\t<< \"Unable to set rectangle \" << target << \" on pad \"\n> +\t\t\t<< pad << \": \" << strerror(-ret);\n> +\t\treturn ret;\n> +\t}\n> +\n> +\trect->x = sel.r.left;\n> +\trect->y = sel.r.top;\n> +\trect->w = sel.r.width;\n> +\trect->h = sel.r.height;\n> +\n> +\treturn 0;\n>  }\n>  \n>  /**\n> @@ -329,35 +391,4 @@ std::vector<SizeRange> V4L2Subdevice::enumPadSizes(unsigned int pad,\n>  \treturn sizes;\n>  }\n>  \n> -int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n> -\t\t\t\tRectangle *rect)\n> -{\n> -\tstruct v4l2_subdev_selection sel = {};\n> -\n> -\tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n> -\tsel.pad = pad;\n> -\tsel.target = target;\n> -\tsel.flags = 0;\n> -\n> -\tsel.r.left = rect->x;\n> -\tsel.r.top = rect->y;\n> -\tsel.r.width = rect->w;\n> -\tsel.r.height = rect->h;\n> -\n> -\tint ret = ioctl(VIDIOC_SUBDEV_S_SELECTION, &sel);\n> -\tif (ret < 0) {\n> -\t\tLOG(V4L2, Error)\n> -\t\t\t<< \"Unable to set rectangle \" << target << \" on pad \"\n> -\t\t\t<< pad << \": \" << strerror(-ret);\n> -\t\treturn ret;\n> -\t}\n> -\n> -\trect->x = sel.r.left;\n> -\trect->y = sel.r.top;\n> -\trect->w = sel.r.width;\n> -\trect->h = sel.r.height;\n> -\n> -\treturn 0;\n> -}\n> -\n>  } /* namespace libcamera */\n> -- \n> 2.23.0\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x144.google.com (mail-lf1-x144.google.com\n\t[IPv6:2a00:1450:4864:20::144])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8680960BF6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 28 Aug 2019 13:34:38 +0200 (CEST)","by mail-lf1-x144.google.com with SMTP id j4so1848123lfh.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 28 Aug 2019 04:34:38 -0700 (PDT)","from localhost (h-177-236.A463.priv.bahnhof.se. [217.31.177.236])\n\tby smtp.gmail.com with ESMTPSA id\n\ts20sm595143ljg.88.2019.08.28.04.34.36\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 28 Aug 2019 04:34:36 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=rbKbEheujGojbdo+h0xbvYXdZXIVnIMDS0KeDnoqzTY=;\n\tb=v018RsPC00LXvwkEePxLn8Gyy+d/h3rq7Asi0lq8/O2ZobRAevcc4sRNfH756M2DtB\n\tRtgKl8YG8+BjsuPODWVzVmVoAFSkas0wRHvIiLxWtyjUAxA63jA8R3uqKftS9HNpW6i5\n\tawDcWWchvhYbvJy28fr5NMPeuLGqGtrPyEqffCTOQKwOO4h+tFvsPmaTZ6xHYUmHBeRf\n\tNBrMPctW/EdT6zJ49v/51wfPebiQoqpQZMh+KNiKHpUT/BfePVqc3sKbfT4q2WSbHNuK\n\tEpOyhhaJo6g2BprHZQYriRRrjv+ruqfTmTPysJFeRxuL3JfVM0mTZF4qdKHgumBN77ol\n\tskPw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=rbKbEheujGojbdo+h0xbvYXdZXIVnIMDS0KeDnoqzTY=;\n\tb=c921hlke99A5ptp4t+ft6gCzBqALt7B45lrvj8ZBhvyu75W+Tzved/xMyMg9GAVcUc\n\t0kHswqKxovH+vJuhitheb+v04NmifFKO7+xxCdwQV70xM/IfMvgenSvZ63rw+qTMsVGC\n\t/WvUY3poRy4WYZXCFItYGvnByeWVf2JZ1rOKqxVue4UOFZr9quK7J4yNGWOrj5k8BiuG\n\tigNEDVUSXCMZ+2i3D3+QorOwUNNUZyg8G9g4eEBFcWcPM+xGu3hzUMSQi2xeQg4y/qCX\n\tPOgFj+Q/CSWjiZrDfA0402gXQNgzrmsSQCeTR50SNk8dcndXIX0vm0A++JZZgSAAm3Al\n\t92Kw==","X-Gm-Message-State":"APjAAAVCxLgr6YrWw88OyTEz6ofPTEayMOA/ab2iHzVIbSMkPB8S2G8R\n\teA5mDgFzUGielfLeBcLn4nYAXQ==","X-Google-Smtp-Source":"APXvYqzHndHuflWQDKDV15zstPO7D77fhG1dRLEmWIUdSVGd3A8qiWYUe0T0f4SGet2Ct8US2RpB1Q==","X-Received":"by 2002:a19:f819:: with SMTP id a25mr2139084lff.45.1566992078034;\n\tWed, 28 Aug 2019 04:34:38 -0700 (PDT)","Date":"Wed, 28 Aug 2019 13:34:35 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190828113435.GQ28351@bigcity.dyn.berto.se>","References":"<20190827095008.11405-1-jacopo@jmondi.org>\n\t<20190827095008.11405-7-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190827095008.11405-7-jacopo@jmondi.org>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [PATCH v2 6/7] libcamera: v4l2_subdevice: Add\n\tselection support","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":"Wed, 28 Aug 2019 11:34:38 -0000"}},{"id":2575,"web_url":"https://patchwork.libcamera.org/comment/2575/","msgid":"<20190903201732.GD4788@pendragon.ideasonboard.com>","date":"2019-09-03T20:17:32","subject":"Re: [libcamera-devel] [PATCH v2 6/7] libcamera: v4l2_subdevice: Add\n\tselection support","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 Tue, Aug 27, 2019 at 11:50:06AM +0200, Jacopo Mondi wrote:\n> Currently the selection API are implemented by wrappers of the\n> setSelection method. As we add support for more targets, adding new\n> wrapper does not scale well. Make the setSelection operation public and\n> implement getSelection, and require callers to specify the selection\n> target in the operation parameters list.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/include/v4l2_subdevice.h |   9 +-\n>  src/libcamera/pipeline/ipu3/ipu3.cpp   |   4 +-\n>  src/libcamera/v4l2_subdevice.cpp       | 113 ++++++++++++++++---------\n>  3 files changed, 78 insertions(+), 48 deletions(-)\n> \n> diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> index 9c077674f997..b69b93280894 100644\n> --- a/src/libcamera/include/v4l2_subdevice.h\n> +++ b/src/libcamera/include/v4l2_subdevice.h\n> @@ -41,8 +41,10 @@ public:\n>  \n>  \tconst MediaEntity *entity() const { return entity_; }\n>  \n> -\tint setCrop(unsigned int pad, Rectangle *rect);\n> -\tint setCompose(unsigned int pad, Rectangle *rect);\n> +\tint getSelection(unsigned int pad, unsigned int target,\n> +\t\t\t Rectangle *rect);\n> +\tint setSelection(unsigned int pad, unsigned int target,\n> +\t\t\t Rectangle *rect);\n>  \n>  \tImageFormats formats(unsigned int pad);\n>  \n> @@ -60,9 +62,6 @@ private:\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> -\n>  \tconst MediaEntity *entity_;\n>  };\n>  \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 827906d5cd2e..bd027c7f10be 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -1071,11 +1071,11 @@ int ImgUDevice::configureInput(const Size &size,\n>  \t\t.w = inputFormat->size.width,\n>  \t\t.h = inputFormat->size.height,\n>  \t};\n> -\tret = imgu_->setCrop(PAD_INPUT, &rect);\n> +\tret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_CROP, &rect);\n>  \tif (ret)\n>  \t\treturn ret;\n>  \n> -\tret = imgu_->setCompose(PAD_INPUT, &rect);\n> +\tret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_COMPOSE, &rect);\n>  \tif (ret)\n>  \t\treturn ret;\n>  \n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index a188298de34c..262dfa23ee57 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -127,25 +127,87 @@ int V4L2Subdevice::open()\n>   */\n>  \n>  /**\n> - * \\brief Set a crop rectangle on one of the V4L2 subdevice pads\n> - * \\param[in] pad The 0-indexed pad number the rectangle is to be applied to\n> - * \\param[inout] rect The rectangle describing crop target area\n> + * \\brief Get the V4L2_SEL_TGT_* selection \\a target rectangle on \\a pad\n\nI would drop V4L2_SEL_TGT_* here as it's mentioned in the target\nparameter.\n\n> + * \\param[in] pad The 0-indexed pad number to get the selection target from\n\ns/target/rectangle/\n\n> + * \\param[in] target The selection target V4L2_SEL_TGT_* as defined by the V4L2\n> + * selection API\n> + * \\param[out] rect The rectangle describing the returned selection target\n\ns/selection/selection rectangle/ or s/\\a target/rectangle/\n\n> + *\n> + * This operations wraps the VIDIOC_SUBDEV_G_SELECTION ioctl, applied to one of\n> + * the V4L2_SEL_TGT_* targets defined by the V4L2 API on the subdevice \\a pad.\n> + * The retrieved selection rectangle is returned in the output parameter \\a\n> + * rect.\n> + *\n>   * \\return 0 on success or a negative error code otherwise\n>   */\n> -int V4L2Subdevice::setCrop(unsigned int pad, Rectangle *rect)\n> +int V4L2Subdevice::getSelection(unsigned int pad, unsigned int target,\n> +\t\t\t\tRectangle *rect)\n>  {\n> -\treturn setSelection(pad, V4L2_SEL_TGT_CROP, rect);\n> +\tstruct v4l2_subdev_selection sel = {};\n> +\n> +\tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n> +\tsel.pad = pad;\n> +\tsel.target = target;\n> +\n> +\tint ret = ioctl(VIDIOC_SUBDEV_G_SELECTION, &sel);\n> +\tif (ret < 0) {\n> +\t\tLOG(V4L2, Error)\n> +\t\t\t<< \"Unable to get rectangle \" << target << \" on pad \"\n\nMaybe s/rectangle/selection rectangle/ ?\n\nAll these comments apply to setSelection() below.\n\nWith those small issues fixed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\t\t<< pad << \": \" << strerror(-ret);\n> +\t\treturn ret;\n> +\t}\n> +\n> +\trect->x = sel.r.left;\n> +\trect->y = sel.r.top;\n> +\trect->w = sel.r.width;\n> +\trect->h = sel.r.height;\n> +\n> +\treturn 0;\n>  }\n>  \n>  /**\n> - * \\brief Set a compose rectangle on one of the V4L2 subdevice pads\n> - * \\param[in] pad The 0-indexed pad number the rectangle is to be applied to\n> - * \\param[inout] rect The rectangle describing the compose target area\n> + * \\brief Set the V4L2_SEL_TGT_* selection \\a target rectangle on \\a pad\n> + * \\param[in] pad The 0-indexed pad number to set the selection target on\n> + * \\param[in] target The selection target V4L2_SEL_TGT_* as defined by the V4L2\n> + * selection API\n> + * \\param[inout] rect The rectangle to be applied to the the selection \\a target\n> + *\n> + * This operations wraps the VIDIOC_SUBDEV_S_SELECTION ioctl, applied to one of\n> + * the V4L2_SEL_TGT_* targets defined by the V4L2 API on the subdevice \\a pad.\n> + * The selection rectangle to apply is described by the parameter \\a rect,\n> + * which is updated to reflect what has been actually applied on the subdevice\n> + * when the method returns.\n> + *\n>   * \\return 0 on success or a negative error code otherwise\n>   */\n> -int V4L2Subdevice::setCompose(unsigned int pad, Rectangle *rect)\n> +int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n> +\t\t\t\tRectangle *rect)\n>  {\n> -\treturn setSelection(pad, V4L2_SEL_TGT_COMPOSE, rect);\n> +\tstruct v4l2_subdev_selection sel = {};\n> +\n> +\tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n> +\tsel.pad = pad;\n> +\tsel.target = target;\n> +\n> +\tsel.r.left = rect->x;\n> +\tsel.r.top = rect->y;\n> +\tsel.r.width = rect->w;\n> +\tsel.r.height = rect->h;\n> +\n> +\tint ret = ioctl(VIDIOC_SUBDEV_S_SELECTION, &sel);\n> +\tif (ret < 0) {\n> +\t\tLOG(V4L2, Error)\n> +\t\t\t<< \"Unable to set rectangle \" << target << \" on pad \"\n> +\t\t\t<< pad << \": \" << strerror(-ret);\n> +\t\treturn ret;\n> +\t}\n> +\n> +\trect->x = sel.r.left;\n> +\trect->y = sel.r.top;\n> +\trect->w = sel.r.width;\n> +\trect->h = sel.r.height;\n> +\n> +\treturn 0;\n>  }\n>  \n>  /**\n> @@ -329,35 +391,4 @@ std::vector<SizeRange> V4L2Subdevice::enumPadSizes(unsigned int pad,\n>  \treturn sizes;\n>  }\n>  \n> -int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n> -\t\t\t\tRectangle *rect)\n> -{\n> -\tstruct v4l2_subdev_selection sel = {};\n> -\n> -\tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n> -\tsel.pad = pad;\n> -\tsel.target = target;\n> -\tsel.flags = 0;\n> -\n> -\tsel.r.left = rect->x;\n> -\tsel.r.top = rect->y;\n> -\tsel.r.width = rect->w;\n> -\tsel.r.height = rect->h;\n> -\n> -\tint ret = ioctl(VIDIOC_SUBDEV_S_SELECTION, &sel);\n> -\tif (ret < 0) {\n> -\t\tLOG(V4L2, Error)\n> -\t\t\t<< \"Unable to set rectangle \" << target << \" on pad \"\n> -\t\t\t<< pad << \": \" << strerror(-ret);\n> -\t\treturn ret;\n> -\t}\n> -\n> -\trect->x = sel.r.left;\n> -\trect->y = sel.r.top;\n> -\trect->w = sel.r.width;\n> -\trect->h = sel.r.height;\n> -\n> -\treturn 0;\n> -}\n> -\n>  } /* namespace libcamera */","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 7507160BCF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  3 Sep 2019 22:17:41 +0200 (CEST)","from pendragon.ideasonboard.com (85-76-18-41-nat.elisa-mobile.fi\n\t[85.76.18.41])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B3A89542;\n\tTue,  3 Sep 2019 22:17:40 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1567541861;\n\tbh=jPwcnnERVyO8/Rz/jZtc7ccW2XIK+UVCeiPqf5HZzAI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Wy0xTxK5U1VUKAe6oLimakFFfz7ZHkhJT8xBy9pyxeUiQYxspw/kfzMhskLGv1MDC\n\t5YlrD+lNEczEGOQIZ/BNmTt5Zef9e/AM+J2WbdvT580VJWmz1J1OZ7bkP69InCR+p+\n\tUolvekaC5FdiXXFlaHKuTNqM2i1mTIJCC9F0yJEI=","Date":"Tue, 3 Sep 2019 23:17:32 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190903201732.GD4788@pendragon.ideasonboard.com>","References":"<20190827095008.11405-1-jacopo@jmondi.org>\n\t<20190827095008.11405-7-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190827095008.11405-7-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 6/7] libcamera: v4l2_subdevice: Add\n\tselection support","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, 03 Sep 2019 20:17:41 -0000"}}]