[{"id":4035,"web_url":"https://patchwork.libcamera.org/comment/4035/","msgid":"<20200316160124.GL2260535@oden.dyn.berto.se>","date":"2020-03-16T16:01:24","subject":"Re: [libcamera-devel] [PATCH 3/8] libcamera: v4l2_subdevice: Extend\n\t[gs]etFormat() to specify format type","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-03-14 01:38:51 +0200, Laurent Pinchart wrote:\n> The V4L2 subdevice API exposes ACTIVE and TRY formats, but the\n> V4L2Subdevice getFormat() and setFormat() operations only apply on\n> ACTIVE formats. Extend them to support TRY formats as well.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/include/v4l2_subdevice.h | 11 +++++++++--\n>  src/libcamera/v4l2_subdevice.cpp       | 23 +++++++++++++++++++----\n>  2 files changed, 28 insertions(+), 6 deletions(-)\n> \n> diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> index 9c077674f997..4a04eadfb1f9 100644\n> --- a/src/libcamera/include/v4l2_subdevice.h\n> +++ b/src/libcamera/include/v4l2_subdevice.h\n> @@ -32,6 +32,11 @@ struct V4L2SubdeviceFormat {\n>  class V4L2Subdevice : public V4L2Device\n>  {\n>  public:\n> +\tenum Whence {\n> +\t\tActiveFormat,\n> +\t\tTryFormat,\n> +\t};\n> +\n>  \texplicit V4L2Subdevice(const MediaEntity *entity);\n>  \tV4L2Subdevice(const V4L2Subdevice &) = delete;\n>  \tV4L2Subdevice &operator=(const V4L2Subdevice &) = delete;\n> @@ -46,8 +51,10 @@ public:\n>  \n>  \tImageFormats formats(unsigned int pad);\n>  \n> -\tint getFormat(unsigned int pad, V4L2SubdeviceFormat *format);\n> -\tint setFormat(unsigned int pad, V4L2SubdeviceFormat *format);\n> +\tint getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n> +\t\t      Whence whence = ActiveFormat);\n> +\tint setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n> +\t\t      Whence whence = ActiveFormat);\n>  \n>  \tstatic V4L2Subdevice *fromEntityName(const MediaDevice *media,\n>  \t\t\t\t\t     const std::string &entity);\n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index f2bcd7f73c5c..d9c90a34c0d8 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -95,6 +95,15 @@ const std::string V4L2SubdeviceFormat::toString() const\n>   * any device left open will be closed, and any resources released.\n>   */\n>  \n> +/**\n> + * \\enum V4L2Subdevice::Whence\n> + * \\brief Specify the type of format for getFormat() and setFormat() operations\n> + * \\var V4L2Subdevice::ActiveFormat\n> + * \\brief The format operation applies to ACTIVE formats\n> + * \\var V4L2Subdevice::TryFormat\n> + * \\brief The format operation applies to TRY formats\n> + */\n> +\n>  /**\n>   * \\brief Create a V4L2 subdevice from a MediaEntity using its device node\n>   * path\n> @@ -184,12 +193,15 @@ ImageFormats V4L2Subdevice::formats(unsigned int pad)\n>   * \\brief Retrieve the image format set on one of the V4L2 subdevice pads\n>   * \\param[in] pad The 0-indexed pad number the format is to be retrieved from\n>   * \\param[out] format The image bus format\n> + * \\param[in] whence The format to retrieve, ACTIVE or TRY\n>   * \\return 0 on success or a negative error code otherwise\n>   */\n> -int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n> +int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n> +\t\t\t     Whence whence)\n>  {\n>  \tstruct v4l2_subdev_format subdevFmt = {};\n> -\tsubdevFmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n> +\tsubdevFmt.which = whence == ActiveFormat ? V4L2_SUBDEV_FORMAT_ACTIVE\n> +\t\t\t: V4L2_SUBDEV_FORMAT_TRY;\n>  \tsubdevFmt.pad = pad;\n>  \n>  \tint ret = ioctl(VIDIOC_SUBDEV_G_FMT, &subdevFmt);\n> @@ -211,6 +223,7 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n>   * \\brief Set an image format on one of the V4L2 subdevice pads\n>   * \\param[in] pad The 0-indexed pad number the format is to be applied to\n>   * \\param[inout] format The image bus format to apply to the subdevice's pad\n> + * \\param[in] whence The format to set, ACTIVE or TRY\n>   *\n>   * Apply the requested image format to the desired media pad and return the\n>   * actually applied format parameters, as \\ref V4L2Subdevice::getFormat would\n> @@ -218,10 +231,12 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n>   *\n>   * \\return 0 on success or a negative error code otherwise\n>   */\n> -int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format)\n> +int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n> +\t\t\t     Whence whence)\n>  {\n>  \tstruct v4l2_subdev_format subdevFmt = {};\n> -\tsubdevFmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n> +\tsubdevFmt.which = whence == ActiveFormat ? V4L2_SUBDEV_FORMAT_ACTIVE\n> +\t\t\t: V4L2_SUBDEV_FORMAT_TRY;\n>  \tsubdevFmt.pad = pad;\n>  \tsubdevFmt.format.width = format->size.width;\n>  \tsubdevFmt.format.height = format->size.height;\n> -- \n> Regards,\n> \n> Laurent Pinchart\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-lj1-x241.google.com (mail-lj1-x241.google.com\n\t[IPv6:2a00:1450:4864:20::241])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 340B66041A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Mar 2020 17:01:26 +0100 (CET)","by mail-lj1-x241.google.com with SMTP id w1so19298455ljh.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Mar 2020 09:01:26 -0700 (PDT)","from localhost (h-200-138.A463.priv.bahnhof.se. [176.10.200.138])\n\tby smtp.gmail.com with ESMTPSA id\n\tp14sm138543ljn.80.2020.03.16.09.01.24\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 16 Mar 2020 09:01:24 -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\tbh=ajDM1VVUtI41QeqWpc3VaAfI2vQp0sek/Rp+35pccKQ=;\n\tb=DbSoBcJS1ZRjgcM7ADbQ2DSY9BH/zmoJeznRUx7qgvk850xIt/wvTjFoX3YC0pf0Jv\n\tkjpWZkda1sZKQCupLhvBYHkSZ20KIZjzNPeVCXgIbv5ncvfZks2V2t8FlT/pmmNEMYlE\n\tbb67YskICPPsyatkT9JM0ZpyT4NxTGfWGnLaSTqlD/oCWPfTiPZi01Bm5UQWHUr3CyWl\n\tUsSsuB2QBAOiUolOIAdH+eH2OHTfSs2riX52EDVKzZV3aD4ANcGuqb5HJbApnnWHBOEX\n\ty0joKsp0WnALZZuPMGT0Uq8YWBDmXeg2W1DdU9VQd821ieHje/QdXO5V/oXeZxLhzfCq\n\t4O8A==","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;\n\tbh=ajDM1VVUtI41QeqWpc3VaAfI2vQp0sek/Rp+35pccKQ=;\n\tb=pvPckGoaW0DDHlXDdSzFqsPYWm7bZ7jgwtklsUkVrlf5SLq9Gbbd4PvAOVu1BZN84U\n\tba80sYW/CBtfRfi9ctbQQ0w+usEBRD1VrubjISRzSJe0kZfcqwfpoPN+zPUhwZpR7PWq\n\tkRm4vLJ2Ci5c/BcMHF3ccD8tPh9DnkYQbdvvB8LAUMDebmeieDThRo/09kPk1E3nbwcx\n\t49YjvvvB96CmZNvSljm6TcgrHeIFJzS0nDIhfXuXRwDLiScPLKxw+tdRQ5ftMzymv+Qk\n\tebzpQYufZ+L4/DBzoi16mnInPXdnoZpDKICPU3eerNr35Bj96mbpAJDX0WunZrRpG/KH\n\tvOvA==","X-Gm-Message-State":"ANhLgQ22iYtUZ61dHC9JjCFJRLcSmUPblqsrvTnCjAgWrySCLtR1IEo+\n\tLTxuWn1BDJ8V2/F2sPqMMCfNcw==","X-Google-Smtp-Source":"ADFU+vsyEVS2ZfF+YLcvlmbR4s/ZvqSjFvgmOCdUDrngz6i5tOScAxKSUUzUftwddbLKecm1yAsqIA==","X-Received":"by 2002:a2e:9ac5:: with SMTP id p5mr15132ljj.200.1584374485516; \n\tMon, 16 Mar 2020 09:01:25 -0700 (PDT)","Date":"Mon, 16 Mar 2020 17:01:24 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, Martijn Braam <martijn@brixit.nl>, \n\tMickael GUENE <mickael.guene@st.com>,\n\tBenjamin GAIGNARD <benjamin.gaignard@st.com>","Message-ID":"<20200316160124.GL2260535@oden.dyn.berto.se>","References":"<20200313233856.25202-1-laurent.pinchart@ideasonboard.com>\n\t<20200313233856.25202-4-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200313233856.25202-4-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 3/8] libcamera: v4l2_subdevice: Extend\n\t[gs]etFormat() to specify format type","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>","X-List-Received-Date":"Mon, 16 Mar 2020 16:01:26 -0000"}}]