[libcamera-devel,RFC,3/4] libcamera: ipu3: Apply a requested test pattern mode
diff mbox series

Message ID 20210611084228.1830629-4-hiroh@chromium.org
State Superseded
Headers show
Series
  • Support sensor test pattern mode in Android HAL
Related show

Commit Message

Hirokazu Honda June 11, 2021, 8:42 a.m. UTC
Apply a camera sensor a requested test pattern mode. The test
pattern mode can be specified per frame.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
---
 src/libcamera/pipeline/ipu3/cio2.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp
index 8548f749..9d1ff07d 100644
--- a/src/libcamera/pipeline/ipu3/cio2.cpp
+++ b/src/libcamera/pipeline/ipu3/cio2.cpp
@@ -12,6 +12,7 @@ 
 #include <libcamera/control_ids.h>
 #include <libcamera/formats.h>
 #include <libcamera/geometry.h>
+#include <libcamera/request.h>
 #include <libcamera/stream.h>
 
 #include "libcamera/internal/camera_sensor.h"
@@ -289,6 +290,20 @@  FrameBuffer *CIO2Device::queueBuffer(Request *request, FrameBuffer *rawBuffer)
 		buffer->setRequest(request);
 	}
 
+	if (request->controls().contains(controls::draft::TestPatternMode)) {
+		const uint8_t testPatternMode =
+			static_cast<uint8_t>(request->controls().get(
+				controls::draft::TestPatternMode));
+		int ret = sensor_->setTestPatternMode(testPatternMode);
+		if (ret) {
+			LOG(IPU3, Error)
+				<< "Failed to set test pattern mode: " << ret;
+		} else {
+			request->metadata().set(controls::draft::TestPatternMode,
+						testPatternMode);
+		}
+	}
+
 	int ret = output_->queueBuffer(buffer);
 	if (ret)
 		return nullptr;