[libcamera-devel] [PATCH v2] libcamera: Improve Request life cycle tracking
Jacopo Mondi
jacopo at jmondi.org
Tue Feb 2 12:55:30 CET 2021
The current logging to track the status of a Request when running the
Android camera HAL provide the following information:
When a Request is queued to libcamera:
HAL camera_device.cpp:1776 '\_SB_.PCI0.I2C2.CAM0': Queueing Request to libcamera with 1 HAL streams
When a Request completes:
Request request.cpp:268 Request has completed - cookie: 138508601719648
The queueing of a Request reports the number of streams it contains
while the completion of a Request reports the address of the associated
cookie.
This makes very hard to keep track of what Requests have completed, as
the logging associated with a queue/complete event does not allow to identify
a Request easily.
Add two more printouts to make it easier to track a Request life cycle.
To make it possible to print the Request cookie in the CameraDevice
class add a method to access it from the CameraRequest class.
The result looks like the following trace:
Request request.cpp:92 Created request - cookie: 140701719392768
HAL camera_device.cpp:1710 '\_SB_.PCI0.I2C2.CAM0': Queueing request 140701719392768 with 1 streams
HAL camera_device.cpp:1747 '\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12] (direct)
...
Request request.cpp:268 Request has completed - cookie: 140701719392768
HAL camera_device.cpp:1800 '\_SB_.PCI0.I2C2.CAM0': Request 140701719392768 completed with 1 streams..
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/android/camera_device.cpp | 7 +++++--
src/android/camera_worker.h | 1 +
src/libcamera/request.cpp | 2 ++
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index c1025e812e5e..82479ad88f91 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1707,8 +1707,8 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
else
descriptor->settings_ = lastSettings_;
- LOG(HAL, Debug) << "Queueing Request to libcamera with "
- << descriptor->numBuffers_ << " HAL streams";
+ LOG(HAL, Debug) << "Queueing request " << descriptor->request_->cookie()
+ << " with " << descriptor->numBuffers_ << " streams";
for (unsigned int i = 0; i < descriptor->numBuffers_; ++i) {
const camera3_stream_buffer_t *camera3Buffer = &descriptor->buffers_[i];
camera3_stream *camera3Stream = camera3Buffer->stream;
@@ -1797,6 +1797,9 @@ void CameraDevice::requestComplete(Request *request)
status = CAMERA3_BUFFER_STATUS_ERROR;
}
+ LOG(HAL, Debug) << "Request " << request->cookie() << " completed with "
+ << descriptor->numBuffers_ << " streams";
+
/*
* \todo The timestamp used for the metadata is currently always taken
* from the first buffer (which may be the first stream) in the Request.
diff --git a/src/android/camera_worker.h b/src/android/camera_worker.h
index 6522f1d68a20..d70605761509 100644
--- a/src/android/camera_worker.h
+++ b/src/android/camera_worker.h
@@ -30,6 +30,7 @@ public:
{
return request_->metadata();
}
+ unsigned long cookie() const { return request_->cookie(); }
void addBuffer(libcamera::Stream *stream,
libcamera::FrameBuffer *buffer, int fence);
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index a68684ef9fd3..e561ce1d5d0e 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -88,6 +88,8 @@ Request::Request(Camera *camera, uint64_t cookie)
metadata_ = new ControlList(controls::controls);
LIBCAMERA_TRACEPOINT(request_construct, this);
+
+ LOG(Request, Debug) << "Created request - cookie: " << cookie_;
}
Request::~Request()
--
2.30.0
More information about the libcamera-devel
mailing list