| Message ID | 20260416232625.26758-1-kieran.bingham@ideasonboard.com |
|---|---|
| State | Accepted |
| Headers | show |
| Series |
|
| Related | show |
On Fri, Apr 17, 2026 at 12:26:25AM +0100, Kieran Bingham wrote: > 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> > --- > > Quite simply: > > kbingham@charm:~/iob/libcamera$ ./build/gcc/src/apps/cam/cam --version > libcamera version v0.7.0+89-ed4dd6bb-dirty (2026-04-17T00:18:37BST) > > > and > > kbingham@charm:~/iob/libcamera$ ./build/gcc/src/apps/cam/cam --help > Options: > -c, --camera camera ... Specify which camera to operate on, by id or by index > -h, --help Display this help message > -v, --version Display libcamera version information > -I, --info Display information about stream(s) > .... <snip remaining usage help> ... > > > > 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 029f518f7294..120917eb632d 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 64e6a20e8668..9bec1e712dfb 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,
Hi Kieran On Fri, Apr 17, 2026 at 12:26:25AM +0100, Kieran Bingham wrote: > 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> Useful indeed Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> > --- > > Quite simply: > > kbingham@charm:~/iob/libcamera$ ./build/gcc/src/apps/cam/cam --version > libcamera version v0.7.0+89-ed4dd6bb-dirty (2026-04-17T00:18:37BST) > > > and > > kbingham@charm:~/iob/libcamera$ ./build/gcc/src/apps/cam/cam --help > Options: > -c, --camera camera ... Specify which camera to operate on, by id or by index > -h, --help Display this help message > -v, --version Display libcamera version information > -I, --info Display information about stream(s) > .... <snip remaining usage help> ... > > > > 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 029f518f7294..120917eb632d 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; mmm, not the best to return an error, but I understand this is the easier way out Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> > + } > + > return 0; > } > > diff --git a/src/apps/cam/main.h b/src/apps/cam/main.h > index 64e6a20e8668..9bec1e712dfb 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, > -- > 2.53.0 >
diff --git a/src/apps/cam/main.cpp b/src/apps/cam/main.cpp index 029f518f7294..120917eb632d 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 64e6a20e8668..9bec1e712dfb 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,
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> --- Quite simply: kbingham@charm:~/iob/libcamera$ ./build/gcc/src/apps/cam/cam --version libcamera version v0.7.0+89-ed4dd6bb-dirty (2026-04-17T00:18:37BST) and kbingham@charm:~/iob/libcamera$ ./build/gcc/src/apps/cam/cam --help Options: -c, --camera camera ... Specify which camera to operate on, by id or by index -h, --help Display this help message -v, --version Display libcamera version information -I, --info Display information about stream(s) .... <snip remaining usage help> ... src/apps/cam/main.cpp | 8 ++++++++ src/apps/cam/main.h | 1 + 2 files changed, 9 insertions(+)