[libcamera-devel,6/9] android: Set PipelineConfigFile option if it's supported by the camera
diff mbox series

Message ID 20220209071917.559993-7-hanlinchen@chromium.org
State New
Headers show
Series
  • Introduce Pipeline configuration preference for IPU3
Related show

Commit Message

Hanlin Chen Feb. 9, 2022, 7:19 a.m. UTC
If the libcamera::Camera supports the PipelineConfigFile option and
the HAL configuration file provides the path, set the option before
opening the camera.

Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>
---
 src/android/camera_device.cpp | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 83825736..61883a54 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -20,6 +20,7 @@ 
 #include <libcamera/control_ids.h>
 #include <libcamera/controls.h>
 #include <libcamera/fence.h>
+#include <libcamera/option_ids.h>
 #include <libcamera/formats.h>
 #include <libcamera/property_ids.h>
 
@@ -293,6 +294,24 @@  std::unique_ptr<CameraDevice> CameraDevice::create(unsigned int id,
  */
 int CameraDevice::initialize(const CameraConfigData *cameraConfigData)
 {
+	/*
+	 * Initialize pipeline configuration file for the camera.
+	 *
+	 * If the libcamera::Camera supports the PipelineConfigFile option and
+	 * the HAL configuration file provides the path, set the option before
+	 * opening the camera.
+	 */
+	const ControlInfoMap optionInfo = camera_->options();
+
+	if (cameraConfigData &&
+	    cameraConfigData->pipelineConfigFile != "" &&
+	    optionInfo.count(&options::PipelineConfigFile)) {
+		ControlList options(optionInfo);
+		options.set(options::PipelineConfigFile,
+			    cameraConfigData->pipelineConfigFile);
+		camera_->setOptions(&options);
+	}
+
 	/*
 	 * Initialize orientation and facing side of the camera.
 	 *