mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-21 03:15:06 +03:00
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>
This commit is contained in:
parent
36ab14e12d
commit
175cd10611
2 changed files with 29 additions and 0 deletions
|
@ -37,6 +37,7 @@ public:
|
||||||
private:
|
private:
|
||||||
int parseOptions(int argc, char *argv[]);
|
int parseOptions(int argc, char *argv[]);
|
||||||
int prepareConfig();
|
int prepareConfig();
|
||||||
|
int listControls();
|
||||||
int listProperties();
|
int listProperties();
|
||||||
int infoConfiguration();
|
int infoConfiguration();
|
||||||
int run();
|
int run();
|
||||||
|
@ -182,6 +183,8 @@ int CamApp::parseOptions(int argc, char *argv[])
|
||||||
parser.addOption(OptInfo, OptionNone,
|
parser.addOption(OptInfo, OptionNone,
|
||||||
"Display information about stream(s)", "info");
|
"Display information about stream(s)", "info");
|
||||||
parser.addOption(OptList, OptionNone, "List all cameras", "list");
|
parser.addOption(OptList, OptionNone, "List all cameras", "list");
|
||||||
|
parser.addOption(OptListControls, OptionNone, "List cameras controls",
|
||||||
|
"list-controls");
|
||||||
parser.addOption(OptListProperties, OptionNone, "List cameras properties",
|
parser.addOption(OptListProperties, OptionNone, "List cameras properties",
|
||||||
"list-properties");
|
"list-properties");
|
||||||
|
|
||||||
|
@ -276,6 +279,25 @@ int CamApp::prepareConfig()
|
||||||
return 0;
|
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()
|
int CamApp::listProperties()
|
||||||
{
|
{
|
||||||
if (!camera_) {
|
if (!camera_) {
|
||||||
|
@ -339,6 +361,12 @@ int CamApp::run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options_.isSet(OptListControls)) {
|
||||||
|
ret = listControls();
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptListProperties)) {
|
if (options_.isSet(OptListProperties)) {
|
||||||
ret = listProperties();
|
ret = listProperties();
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
@ -16,6 +16,7 @@ enum {
|
||||||
OptList = 'l',
|
OptList = 'l',
|
||||||
OptListProperties = 'p',
|
OptListProperties = 'p',
|
||||||
OptStream = 's',
|
OptStream = 's',
|
||||||
|
OptListControls = 256,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __CAM_MAIN_H__ */
|
#endif /* __CAM_MAIN_H__ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue