[libcamera-devel,3/3] libcamera: request: Use external CameraControlValidator
diff mbox series

Message ID 20210810161134.2243796-4-kieran.bingham@ideasonboard.com
State Superseded
Delegated to: Kieran Bingham
Headers show
Series
  • Request: Use the Camera's CameraControlValidator
Related show

Commit Message

Kieran Bingham Aug. 10, 2021, 4:11 p.m. UTC
Each Request is currently creating its own CameraControlValidator
using the Camera instance at construction.

Now that the Camera exposes its own CameraControlValidator on its
private interface, use that one on all Requests.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 include/libcamera/request.h |  1 -
 src/libcamera/request.cpp   | 11 ++++-------
 2 files changed, 4 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/request.h b/include/libcamera/request.h
index 2d361c9d97dc..d16904e6b679 100644
--- a/include/libcamera/request.h
+++ b/include/libcamera/request.h
@@ -71,7 +71,6 @@  private:
 	bool completeBuffer(FrameBuffer *buffer);
 
 	Camera *camera_;
-	CameraControlValidator *validator_;
 	ControlList *controls_;
 	ControlList *metadata_;
 	BufferMap bufferMap_;
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index f95ce4db5eaa..4cb4963ea352 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -17,6 +17,7 @@ 
 #include <libcamera/framebuffer.h>
 #include <libcamera/stream.h>
 
+#include "libcamera/internal/camera.h"
 #include "libcamera/internal/camera_controls.h"
 #include "libcamera/internal/framebuffer.h"
 #include "libcamera/internal/tracepoints.h"
@@ -77,12 +78,9 @@  Request::Request(Camera *camera, uint64_t cookie)
 	: camera_(camera), sequence_(0), cookie_(cookie),
 	  status_(RequestPending), cancelled_(false)
 {
-	/**
-	 * \todo Should the Camera expose a validator instance, to avoid
-	 * creating a new instance for each request?
-	 */
-	validator_ = new CameraControlValidator(camera);
-	controls_ = new ControlList(controls::controls, validator_);
+	const CameraControlValidator &validator = camera->_d()->validator();
+
+	controls_ = new ControlList(controls::controls, &validator);
 
 	/**
 	 * \todo: Add a validator for metadata controls.
@@ -100,7 +98,6 @@  Request::~Request()
 
 	delete metadata_;
 	delete controls_;
-	delete validator_;
 }
 
 /**