[{"id":975,"web_url":"https://patchwork.libcamera.org/comment/975/","msgid":"<20190228224706.GN899@bigcity.dyn.berto.se>","date":"2019-02-28T22:47:06","subject":"Re: [libcamera-devel] [PATCH 07/10] libcamera: buffer: Add buffer\n\tcompletion status","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 2019-02-28 18:29:10 +0200, Laurent Pinchart wrote:\n> Add a new field to the Buffer class to report its completion status,\n> with a new cancel() method to mark the buffer as cancelled.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  include/libcamera/buffer.h    | 10 ++++++++++\n>  src/libcamera/buffer.cpp      | 35 +++++++++++++++++++++++++++++++++++\n>  src/libcamera/v4l2_device.cpp |  2 ++\n>  3 files changed, 47 insertions(+)\n> \n> diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\n> index dc9aaad12a81..f740ade9bb4f 100644\n> --- a/include/libcamera/buffer.h\n> +++ b/include/libcamera/buffer.h\n> @@ -40,12 +40,19 @@ private:\n>  class Buffer final\n>  {\n>  public:\n> +\tenum Status {\n> +\t\tBufferSuccess,\n> +\t\tBufferError,\n> +\t\tBufferCancelled,\n> +\t};\n> +\n>  \tBuffer();\n>  \n>  \tunsigned int index() const { return index_; }\n>  \tunsigned int bytesused() const { return bytesused_; }\n>  \tuint64_t timestamp() const { return timestamp_; }\n>  \tunsigned int sequence() const { return sequence_; }\n> +\tStatus status() const { return status_; }\n>  \tstd::vector<Plane> &planes() { return planes_; }\n>  \n>  \tSignal<Buffer *> completed;\n> @@ -54,10 +61,13 @@ private:\n>  \tfriend class BufferPool;\n>  \tfriend class V4L2Device;\n>  \n> +\tvoid cancel();\n> +\n>  \tunsigned int index_;\n>  \tunsigned int bytesused_;\n>  \tuint64_t timestamp_;\n>  \tunsigned int sequence_;\n> +\tStatus status_;\n>  \n>  \tstd::vector<Plane> planes_;\n>  };\n> diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp\n> index 80dd9c854a4b..524eb47d4364 100644\n> --- a/src/libcamera/buffer.cpp\n> +++ b/src/libcamera/buffer.cpp\n> @@ -181,6 +181,20 @@ void *Plane::mem()\n>   * objects if the image format is multi-planar.\n>   */\n>  \n> +/**\n> + * \\enum Buffer::Status\n> + * Buffer completion status\n> + * \\var Buffer::BufferSuccess\n> + * The buffer has completed with success and contains valid data. All its other\n> + * metadata (such as bytesused(), timestamp() or sequence() number) are valid.\n> + * \\var Buffer::BufferError\n> + * The buffer has completed with an error and doesn't contain valid data. Its\n> + * other metadata are valid.\n> + * \\var Buffer::BufferCancelled\n> + * The buffer has been cancelled due to capture stop. Its other metadata are\n> + * invalid and shall not be used.\n> + */\n> +\n>  Buffer::Buffer()\n>  \t: index_(-1)\n>  {\n> @@ -229,6 +243,27 @@ Buffer::Buffer()\n>   * \\return Sequence number of the buffer\n>   */\n>  \n> +/**\n> + * \\fn Buffer::status()\n> + * \\brief Retrieve the buffer status\n> + *\n> + * The buffer status reports whether the buffer has completed successfully\n> + * (BufferSuccess) or if an error occurred (BufferError).\n> + *\n> + * \\return The buffer status\n> + */\n> +\n> +/**\n> + * \\brief Mark a buffer as cancel by setting its status to BufferCancelled\n> + */\n> +void Buffer::cancel()\n> +{\n> +\tbytesused_ = 0;\n> +\ttimestamp_ = 0;\n> +\tsequence_ = 0;\n> +\tstatus_ = BufferCancelled;\n> +}\n> +\n>  /**\n>   * \\class BufferPool\n>   * \\brief A pool of buffers\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 31200a6e7d6f..054499e4b888 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -793,6 +793,8 @@ Buffer *V4L2Device::dequeueBuffer()\n>  \tbuffer->timestamp_ = buf.timestamp.tv_sec * 1000000000ULL\n>  \t\t\t   + buf.timestamp.tv_usec * 1000ULL;\n>  \tbuffer->sequence_ = buf.sequence;\n> +\tbuffer->status_ = buf.flags & V4L2_BUF_FLAG_ERROR\n> +\t\t\t? Buffer::BufferError : Buffer::BufferSuccess;\n>  \n>  \treturn buffer;\n>  }\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-x244.google.com (mail-lj1-x244.google.com\n\t[IPv6:2a00:1450:4864:20::244])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F3804610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 23:47:08 +0100 (CET)","by mail-lj1-x244.google.com with SMTP id z7so18476791lji.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 14:47:08 -0800 (PST)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\tp142sm4898182lfe.92.2019.02.28.14.47.06\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tThu, 28 Feb 2019 14:47:07 -0800 (PST)"],"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=ZEDGzSAXdE+loGxkRRBW1eDWYXtGFf/he+NKJeYMYrc=;\n\tb=NgildDhci3YXByPDJp7A9H8UqYwY/gEdHPOSg5R7Fxb4bc8F41aI1QxF4otdj0T7AG\n\tgUXopGuRTHQ64axh46iGmFb8CBY+4zKV8EFGm1J23Ykhorwe7J/WBQov17psU/m9ajgK\n\tbYWqh7NulddZ4hv7OlzidIhaSlXhSkBKkhqCO4HhTSbjw+inzsQclcIfR/JDhTKSHwXa\n\ta8XQfBRG2meqAaCjo0ueIfB3EGd3/DCdMeIKVnL2NajfgPH+h1czt+lUJ02PA2wQFc6p\n\tysvQ0W6Qx8aTz7iv3TuupC62GCuSd8yVsD5Yt6S15/36rBJB2Uq7wkhFAW7mAYIRxQfs\n\tDvFw==","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=ZEDGzSAXdE+loGxkRRBW1eDWYXtGFf/he+NKJeYMYrc=;\n\tb=s51S6zUp7HgEpOxemAr9rdZ+/YSDXCaEGM08NU0+/hI7uEVFyo5WKp2ZwmbfHCYcWI\n\tUNpZCUw/yFy6MXHYLBclRKZF37eBqyGy9U9pT3ERtjP40rJe/EelHE1OQTHe/TYxpxc/\n\tIb9L0TY+15iTu4xfrjzmyZGB727Lbw2tGcOWolCQ15h191oKazJIO3XglwVFJORx/hbR\n\tDlrymnirWMk5/ENjottJ71sIRmgfQV8FVCgSzCCL2Yn0VE+1xeWA8OBUnr9FcdDJlO4C\n\ttw50wZSp+P/8/sIWKvoeLktun2uPh0daYje2c6vUshdsZDthCufLEEKs3iwimptjIFGX\n\tGzcg==","X-Gm-Message-State":"APjAAAUe9E2HwyhL/Y5HfUzKVq967kcyMSJzO/+ggELKQV4ogc2pKMxn\n\t0mX98iPAmK+GbA0H5ploV4X8bt0mL7s=","X-Google-Smtp-Source":"APXvYqwbiKh0HzQeN9D+ztgupq+9Kk5SvBVQdy+hIbT9+ZYA1z21NtjriF0N4djxM5wwc7mb7Zw7Mg==","X-Received":"by 2002:a2e:8949:: with SMTP id b9mr736785ljk.173.1551394028035; \n\tThu, 28 Feb 2019 14:47:08 -0800 (PST)","Date":"Thu, 28 Feb 2019 23:47:06 +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","Message-ID":"<20190228224706.GN899@bigcity.dyn.berto.se>","References":"<20190228162913.6508-1-laurent.pinchart@ideasonboard.com>\n\t<20190228162913.6508-8-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":"<20190228162913.6508-8-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 07/10] libcamera: buffer: Add buffer\n\tcompletion status","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":"Thu, 28 Feb 2019 22:47:09 -0000"}}]