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 <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Kieran Bingham
2026-04-17 00:26:25 +01:00
parent 2e8a518784
commit 8e5eedc851
2 changed files with 9 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -20,6 +20,7 @@ enum {
OptOrientation = 'o',
OptSDL = 'S',
OptStream = 's',
OptVersion = 'v',
OptListControls = 256,
OptStrictFormats = 257,
OptMetadata = 258,