From 8e5eedc851e66c5735df4c1066105c996e9abe19 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Fri, 17 Apr 2026 00:26:25 +0100 Subject: [PATCH] cam: Add option to report libcamera version The cam tool is our swiss army knife for interogating libcamera. A frequently needed piece of information is to determine what version of libcamera is installed or being run on a system. This information is available in the debug logs of libcamera when a CameraManager is instantiated. However without actually starting the CameraManager this information is not presented. Add an option to 'cam' to allow it to report the version. Whilst this is the version from the 'cam' command, it directly gets the version of the libcamera library to which cam is linked. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Jacopo Mondi Signed-off-by: Kieran Bingham --- src/apps/cam/main.cpp | 8 ++++++++ src/apps/cam/main.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/apps/cam/main.cpp b/src/apps/cam/main.cpp index 029f518f..120917eb 100644 --- a/src/apps/cam/main.cpp +++ b/src/apps/cam/main.cpp @@ -126,6 +126,8 @@ int CamApp::parseOptions(int argc, char *argv[]) ArgumentRequired, "camera", true); parser.addOption(OptHelp, OptionNone, "Display this help message", "help"); + parser.addOption(OptVersion, OptionNone, "Display libcamera version information", + "version"); parser.addOption(OptInfo, OptionNone, "Display information about stream(s)", "info"); parser.addOption(OptList, OptionNone, "List all cameras", "list"); @@ -197,6 +199,12 @@ int CamApp::parseOptions(int argc, char *argv[]) return options_.empty() ? -EINVAL : -EINTR; } + if (options_.isSet(OptVersion)) { + const std::string &version = CameraManager::version(); + std::cout << "libcamera version " << version << std::endl; + return -EINTR; + } + return 0; } diff --git a/src/apps/cam/main.h b/src/apps/cam/main.h index 64e6a20e..9bec1e71 100644 --- a/src/apps/cam/main.h +++ b/src/apps/cam/main.h @@ -20,6 +20,7 @@ enum { OptOrientation = 'o', OptSDL = 'S', OptStream = 's', + OptVersion = 'v', OptListControls = 256, OptStrictFormats = 257, OptMetadata = 258,