summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2021-05-08 10:41:02 +0200
committerJacopo Mondi <jacopo@jmondi.org>2021-06-14 12:26:27 +0200
commitd09838ef3e83abc2ad37752b64c91267d7309d95 (patch)
tree8a42cc70b34030d1e9ddda0ff99b12b2266ff56d
parenta86d281e52c772c4d40c6b9578c1eec8de8c5ca2 (diff)
libcamera: request: Add Request::cancel()
Add a cancel() function to the Request class that allows to forcefully complete the request and its associated buffers in error state. Only pending requests can be forcefully cancelled. Enforce that by asserting the request state to be RequestPending. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--include/libcamera/internal/tracepoints/request.tp8
-rw-r--r--include/libcamera/request.h1
-rw-r--r--src/libcamera/request.cpp23
3 files changed, 32 insertions, 0 deletions
diff --git a/include/libcamera/internal/tracepoints/request.tp b/include/libcamera/internal/tracepoints/request.tp
index 9e872951..9c841b97 100644
--- a/include/libcamera/internal/tracepoints/request.tp
+++ b/include/libcamera/internal/tracepoints/request.tp
@@ -66,6 +66,14 @@ TRACEPOINT_EVENT_INSTANCE(
)
)
+TRACEPOINT_EVENT_INSTANCE(
+ libcamera,
+ request,
+ request_cancel,
+ TP_ARGS(
+ libcamera::Request *, req
+ )
+)
TRACEPOINT_EVENT(
libcamera,
diff --git a/include/libcamera/request.h b/include/libcamera/request.h
index 4cf5ff3f..5596901d 100644
--- a/include/libcamera/request.h
+++ b/include/libcamera/request.h
@@ -65,6 +65,7 @@ private:
friend class PipelineHandler;
void complete();
+ void cancel();
bool completeBuffer(FrameBuffer *buffer);
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index ce2dd7b1..6611e74d 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -293,6 +293,29 @@ void Request::complete()
}
/**
+ * \brief Cancel a queued request
+ *
+ * Mark the request and its associated buffers as cancelled and complete it.
+ *
+ * Set each pending buffer in error state and emit the buffer completion signal
+ * before completing the Request.
+ */
+void Request::cancel()
+{
+ LIBCAMERA_TRACEPOINT(request_cancel, this);
+
+ ASSERT(status_ == RequestPending);
+
+ for (FrameBuffer *buffer : pending_) {
+ buffer->cancel();
+ camera_->bufferCompleted.emit(this, buffer);
+ }
+
+ pending_.clear();
+ cancelled_ = true;
+}
+
+/**
* \brief Complete a buffer for the request
* \param[in] buffer The buffer that has completed
*