Message ID | 20211120111313.106621-7-jacopo@jmondi.org |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Jacopo, Thank you for the patch. On Sat, Nov 20, 2021 at 12:13:07PM +0100, Jacopo Mondi wrote: > In order to prepare to handle synchronization fences at Request > queueing time, split the PipelineHandler::queueRequest() function in > two, by creating a list of waiting requests and introducing the > doQueueRequest() function that queues requests to the device in the > order the pipeline has received them. > > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> > --- > include/libcamera/internal/pipeline_handler.h | 6 +++++ > .../libcamera/internal/tracepoints/request.tp | 9 +++++++ > src/libcamera/pipeline_handler.cpp | 27 +++++++++++++++++++ > 3 files changed, 42 insertions(+) > > diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h > index 41cba44d990f..608e6f79039f 100644 > --- a/include/libcamera/internal/pipeline_handler.h > +++ b/include/libcamera/internal/pipeline_handler.h > @@ -7,6 +7,7 @@ > #ifndef __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__ > #define __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__ > > +#include <deque> > #include <memory> > #include <set> > #include <string> > @@ -76,9 +77,14 @@ private: > void mediaDeviceDisconnected(MediaDevice *media); > virtual void disconnect(); > > + void doQueueRequest(Request *request); > + void doQueueRequests(); > + > std::vector<std::shared_ptr<MediaDevice>> mediaDevices_; > std::vector<std::weak_ptr<Camera>> cameras_; > > + std::deque<Request *> waitingRequests_; Can you use a std::queue ? > + > const char *name_; > > friend class PipelineHandlerFactory; > diff --git a/include/libcamera/internal/tracepoints/request.tp b/include/libcamera/internal/tracepoints/request.tp > index 37cd2f8864ce..87219b8d8e6f 100644 > --- a/include/libcamera/internal/tracepoints/request.tp > +++ b/include/libcamera/internal/tracepoints/request.tp > @@ -58,6 +58,15 @@ TRACEPOINT_EVENT_INSTANCE( > ) > ) > > +TRACEPOINT_EVENT_INSTANCE( > + libcamera, > + request, > + request_device_queue, Maybe request_queue_device ? > + TP_ARGS( > + libcamera::Request *, req > + ) > +) > + > TRACEPOINT_EVENT_INSTANCE( > libcamera, > request, > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp > index 67fdf1d8db01..b8dd03647954 100644 > --- a/src/libcamera/pipeline_handler.cpp > +++ b/src/libcamera/pipeline_handler.cpp > @@ -312,6 +312,17 @@ void PipelineHandler::queueRequest(Request *request) > { > LIBCAMERA_TRACEPOINT(request_queue, request); > > + waitingRequests_.push_back(request); > + doQueueRequests(); > +} > + > +/** > + * \brief Queue one requests to the device > + */ > +void PipelineHandler::doQueueRequest(Request *request) > +{ > + LIBCAMERA_TRACEPOINT(request_device_queue, request); > + > Camera *camera = request->_d()->camera(); > Camera::Private *data = camera->_d(); > data->queuedRequests_.push_back(request); > @@ -325,6 +336,22 @@ void PipelineHandler::queueRequest(Request *request) > } > } > > +/** > + * \brief Queue requests to the device We need more documentation here and for doQueueRequest(), to explain how fences and requests are handled. > + */ > +void PipelineHandler::doQueueRequests() > +{ > + while (true) { > + if (waitingRequests_.empty()) > + return; > + > + Request *request = waitingRequests_.front(); > + waitingRequests_.pop_front(); > + > + doQueueRequest(request); > + } > +} > + > /** > * \fn PipelineHandler::queueRequestDevice() > * \brief Queue a request to the device
diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 41cba44d990f..608e6f79039f 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -7,6 +7,7 @@ #ifndef __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__ #define __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__ +#include <deque> #include <memory> #include <set> #include <string> @@ -76,9 +77,14 @@ private: void mediaDeviceDisconnected(MediaDevice *media); virtual void disconnect(); + void doQueueRequest(Request *request); + void doQueueRequests(); + std::vector<std::shared_ptr<MediaDevice>> mediaDevices_; std::vector<std::weak_ptr<Camera>> cameras_; + std::deque<Request *> waitingRequests_; + const char *name_; friend class PipelineHandlerFactory; diff --git a/include/libcamera/internal/tracepoints/request.tp b/include/libcamera/internal/tracepoints/request.tp index 37cd2f8864ce..87219b8d8e6f 100644 --- a/include/libcamera/internal/tracepoints/request.tp +++ b/include/libcamera/internal/tracepoints/request.tp @@ -58,6 +58,15 @@ TRACEPOINT_EVENT_INSTANCE( ) ) +TRACEPOINT_EVENT_INSTANCE( + libcamera, + request, + request_device_queue, + TP_ARGS( + libcamera::Request *, req + ) +) + TRACEPOINT_EVENT_INSTANCE( libcamera, request, diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 67fdf1d8db01..b8dd03647954 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -312,6 +312,17 @@ void PipelineHandler::queueRequest(Request *request) { LIBCAMERA_TRACEPOINT(request_queue, request); + waitingRequests_.push_back(request); + doQueueRequests(); +} + +/** + * \brief Queue one requests to the device + */ +void PipelineHandler::doQueueRequest(Request *request) +{ + LIBCAMERA_TRACEPOINT(request_device_queue, request); + Camera *camera = request->_d()->camera(); Camera::Private *data = camera->_d(); data->queuedRequests_.push_back(request); @@ -325,6 +336,22 @@ void PipelineHandler::queueRequest(Request *request) } } +/** + * \brief Queue requests to the device + */ +void PipelineHandler::doQueueRequests() +{ + while (true) { + if (waitingRequests_.empty()) + return; + + Request *request = waitingRequests_.front(); + waitingRequests_.pop_front(); + + doQueueRequest(request); + } +} + /** * \fn PipelineHandler::queueRequestDevice() * \brief Queue a request to the device
In order to prepare to handle synchronization fences at Request queueing time, split the PipelineHandler::queueRequest() function in two, by creating a list of waiting requests and introducing the doQueueRequest() function that queues requests to the device in the order the pipeline has received them. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> --- include/libcamera/internal/pipeline_handler.h | 6 +++++ .../libcamera/internal/tracepoints/request.tp | 9 +++++++ src/libcamera/pipeline_handler.cpp | 27 +++++++++++++++++++ 3 files changed, 42 insertions(+)