summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-05-17 23:58:31 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-08-05 16:23:11 +0300
commit2288550f7d9cb260021de436bb8ff8c0e8ea86be (patch)
treeaa38954356f5a8cf88fc52988580019f314d414e /src
parent063c9969f502d133428639adbee9b864f22e2d6f (diff)
cam: Add support for viewfinder through DRM/KMS
Use the KMSSink class to display the viewfinder stream, if any, through DRM/KMS. The output connector is selected through the new -D/--display argument. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/cam/camera_session.cpp30
-rw-r--r--src/cam/main.cpp6
-rw-r--r--src/cam/main.h1
3 files changed, 37 insertions, 0 deletions
diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp
index f34a6ed5..60d640f2 100644
--- a/src/cam/camera_session.cpp
+++ b/src/cam/camera_session.cpp
@@ -16,6 +16,9 @@
#include "camera_session.h"
#include "event_loop.h"
#include "file_sink.h"
+#ifdef HAVE_KMS
+#include "kms_sink.h"
+#endif
#include "main.h"
#include "stream_options.h"
@@ -66,6 +69,28 @@ CameraSession::CameraSession(CameraManager *cm,
bool strictFormats = options_.isSet(OptStrictFormats);
+#ifdef HAVE_KMS
+ if (options_.isSet(OptDisplay)) {
+ if (options_.isSet(OptFile)) {
+ std::cerr << "--display and --file options are mutually exclusive"
+ << std::endl;
+ return;
+ }
+
+ if (roles.size() != 1) {
+ std::cerr << "Display doesn't support multiple streams"
+ << std::endl;
+ return;
+ }
+
+ if (roles[0] != StreamRole::Viewfinder) {
+ std::cerr << "Display requires a viewfinder stream"
+ << std::endl;
+ return;
+ }
+ }
+#endif
+
switch (config->validate()) {
case CameraConfiguration::Valid:
break;
@@ -161,6 +186,11 @@ int CameraSession::start()
camera_->requestCompleted.connect(this, &CameraSession::requestComplete);
+#ifdef HAVE_KMS
+ if (options_.isSet(OptDisplay))
+ sink_ = std::make_unique<KMSSink>(options_[OptDisplay].toString());
+#endif
+
if (options_.isSet(OptFile)) {
if (!options_[OptFile].toString().empty())
sink_ = std::make_unique<FileSink>(options_[OptFile]);
diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index 34cbc322..c7f664b9 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -132,6 +132,12 @@ int CamApp::parseOptions(int argc, char *argv[])
"Capture until interrupted by user or until <count> frames captured",
"capture", ArgumentOptional, "count", false,
OptCamera);
+#ifdef HAVE_KMS
+ parser.addOption(OptDisplay, OptionString,
+ "Display viewfinder through DRM/KMS on specified connector",
+ "display", ArgumentOptional, "connector", false,
+ OptCamera);
+#endif
parser.addOption(OptFile, OptionString,
"Write captured frames to disk\n"
"If the file name ends with a '/', it sets the directory in which\n"
diff --git a/src/cam/main.h b/src/cam/main.h
index d22451f5..1c2fab76 100644
--- a/src/cam/main.h
+++ b/src/cam/main.h
@@ -10,6 +10,7 @@
enum {
OptCamera = 'c',
OptCapture = 'C',
+ OptDisplay = 'D',
OptFile = 'F',
OptHelp = 'h',
OptInfo = 'I',