diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-04-24 20:46:33 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-04-26 21:04:41 +0300 |
commit | 175cd1061112992df9dee2c51f641d60a3d1705c (patch) | |
tree | 043b20d450794e518c046a0f15104bab8e99d210 /src | |
parent | 36ab14e12d25ec8277fe44a0f4ebb5402b9df38e (diff) |
cam: Add an option to list camera controls
Add a new --list-controls option to print information about all the
controls supported by a camera.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/cam/main.cpp | 28 | ||||
-rw-r--r-- | src/cam/main.h | 1 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 340849e7..ced4f567 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -37,6 +37,7 @@ public: private: int parseOptions(int argc, char *argv[]); int prepareConfig(); + int listControls(); int listProperties(); int infoConfiguration(); int run(); @@ -182,6 +183,8 @@ int CamApp::parseOptions(int argc, char *argv[]) parser.addOption(OptInfo, OptionNone, "Display information about stream(s)", "info"); parser.addOption(OptList, OptionNone, "List all cameras", "list"); + parser.addOption(OptListControls, OptionNone, "List cameras controls", + "list-controls"); parser.addOption(OptListProperties, OptionNone, "List cameras properties", "list-properties"); @@ -276,6 +279,25 @@ int CamApp::prepareConfig() return 0; } +int CamApp::listControls() +{ + if (!camera_) { + std::cout << "Cannot list controls without a camera" + << std::endl; + return -EINVAL; + } + + for (const auto &ctrl : camera_->controls()) { + const ControlId *id = ctrl.first; + const ControlInfo &info = ctrl.second; + + std::cout << "Control: " << id->name() << ": " + << info.toString() << std::endl; + } + + return 0; +} + int CamApp::listProperties() { if (!camera_) { @@ -339,6 +361,12 @@ int CamApp::run() } } + if (options_.isSet(OptListControls)) { + ret = listControls(); + if (ret) + return ret; + } + if (options_.isSet(OptListProperties)) { ret = listProperties(); if (ret) diff --git a/src/cam/main.h b/src/cam/main.h index d23c6dfb..4a130d8d 100644 --- a/src/cam/main.h +++ b/src/cam/main.h @@ -16,6 +16,7 @@ enum { OptList = 'l', OptListProperties = 'p', OptStream = 's', + OptListControls = 256, }; #endif /* __CAM_MAIN_H__ */ |