[2/2] apps: qcam: Add option to configure sensor
diff mbox series

Message ID 20240520120110.110067-3-umang.jain@ideasonboard.com
State Not Applicable
Headers show
Series
  • apps: Add option to configure sensor
Related show

Commit Message

Umang Jain May 20, 2024, 12:01 p.m. UTC
From: Kieran Bingham <kieran.bingham@ideasonboard.com>

Add a '-f|--sensor_format' option to qcam to allow forcing a sensor
configuration from the command line.

As an example:
qcam -f width=3840,height=2160,bitDepth=10

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/apps/qcam/main.cpp        | 3 +++
 src/apps/qcam/main_window.cpp | 7 +++++++
 src/apps/qcam/main_window.h   | 1 +
 3 files changed, 11 insertions(+)

Patch
diff mbox series

diff --git a/src/apps/qcam/main.cpp b/src/apps/qcam/main.cpp
index 9846fba5..2d0d0c5f 100644
--- a/src/apps/qcam/main.cpp
+++ b/src/apps/qcam/main.cpp
@@ -30,6 +30,7 @@  void signalHandler([[maybe_unused]] int signal)
 OptionsParser::Options parseOptions(int argc, char *argv[])
 {
 	StreamKeyValueParser streamKeyValue;
+	SensorKeyValueParser sensorKeyValue;
 
 	OptionsParser parser;
 	parser.addOption(OptCamera, OptionString,
@@ -42,6 +43,8 @@  OptionsParser::Options parseOptions(int argc, char *argv[])
 			 "renderer", ArgumentRequired, "renderer");
 	parser.addOption(OptStream, &streamKeyValue,
 			 "Set configuration of a camera stream", "stream", true);
+	parser.addOption(OptSensorFmt, &sensorKeyValue,
+			 "Apply a format to the sensor", "sensor_format", true);
 	parser.addOption(OptVerbose, OptionNone,
 			 "Print verbose log messages", "verbose");
 
diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp
index d515beed..aa725344 100644
--- a/src/apps/qcam/main_window.cpp
+++ b/src/apps/qcam/main_window.cpp
@@ -414,6 +414,13 @@  int MainWindow::startCapture()
 		return -EINVAL;
 	}
 
+	/* Apply a sensor configuration if requested. */
+	if (SensorKeyValueParser::updateConfiguration(config_.get(),
+						      options_[OptSensorFmt])) {
+		qWarning() << "Failed to apply sensor configuration";
+		return -EINVAL;
+	}
+
 	CameraConfiguration::Status validation = config_->validate();
 	if (validation == CameraConfiguration::Invalid) {
 		qWarning() << "Failed to create valid camera configuration";
diff --git a/src/apps/qcam/main_window.h b/src/apps/qcam/main_window.h
index 4cead734..60c46388 100644
--- a/src/apps/qcam/main_window.h
+++ b/src/apps/qcam/main_window.h
@@ -42,6 +42,7 @@  enum {
 	OptHelp = 'h',
 	OptRenderer = 'r',
 	OptStream = 's',
+	OptSensorFmt = 'f',
 	OptVerbose = 'v',
 };