cam: Add option to disallow adjusting of requested formats
Add a '--strict-formats' option which fails the camera configuration step if the format is adjusted, Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
3acc31b0e3
commit
01ea694003
2 changed files with 17 additions and 1 deletions
|
@ -49,12 +49,15 @@ private:
|
||||||
std::shared_ptr<Camera> camera_;
|
std::shared_ptr<Camera> camera_;
|
||||||
std::unique_ptr<libcamera::CameraConfiguration> config_;
|
std::unique_ptr<libcamera::CameraConfiguration> config_;
|
||||||
EventLoop *loop_;
|
EventLoop *loop_;
|
||||||
|
|
||||||
|
bool strictFormats_;
|
||||||
};
|
};
|
||||||
|
|
||||||
CamApp *CamApp::app_ = nullptr;
|
CamApp *CamApp::app_ = nullptr;
|
||||||
|
|
||||||
CamApp::CamApp()
|
CamApp::CamApp()
|
||||||
: cm_(nullptr), camera_(nullptr), config_(nullptr), loop_(nullptr)
|
: cm_(nullptr), camera_(nullptr), config_(nullptr), loop_(nullptr),
|
||||||
|
strictFormats_(false)
|
||||||
{
|
{
|
||||||
CamApp::app_ = this;
|
CamApp::app_ = this;
|
||||||
}
|
}
|
||||||
|
@ -77,6 +80,9 @@ int CamApp::init(int argc, char **argv)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (options_.isSet(OptStrictFormats))
|
||||||
|
strictFormats_ = true;
|
||||||
|
|
||||||
cm_ = new CameraManager();
|
cm_ = new CameraManager();
|
||||||
|
|
||||||
ret = cm_->start();
|
ret = cm_->start();
|
||||||
|
@ -179,6 +185,9 @@ int CamApp::parseOptions(int argc, char *argv[])
|
||||||
"list-controls");
|
"list-controls");
|
||||||
parser.addOption(OptListProperties, OptionNone, "List cameras properties",
|
parser.addOption(OptListProperties, OptionNone, "List cameras properties",
|
||||||
"list-properties");
|
"list-properties");
|
||||||
|
parser.addOption(OptStrictFormats, OptionNone,
|
||||||
|
"Do not allow requested stream format(s) to be adjusted",
|
||||||
|
"strict-formats");
|
||||||
|
|
||||||
options_ = parser.parse(argc, argv);
|
options_ = parser.parse(argc, argv);
|
||||||
if (!options_.valid())
|
if (!options_.valid())
|
||||||
|
@ -214,6 +223,12 @@ int CamApp::prepareConfig()
|
||||||
case CameraConfiguration::Valid:
|
case CameraConfiguration::Valid:
|
||||||
break;
|
break;
|
||||||
case CameraConfiguration::Adjusted:
|
case CameraConfiguration::Adjusted:
|
||||||
|
if (strictFormats_) {
|
||||||
|
std::cout << "Adjusting camera configuration disallowed by --strict-formats argument"
|
||||||
|
<< std::endl;
|
||||||
|
config_.reset();
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
std::cout << "Camera configuration adjusted" << std::endl;
|
std::cout << "Camera configuration adjusted" << std::endl;
|
||||||
break;
|
break;
|
||||||
case CameraConfiguration::Invalid:
|
case CameraConfiguration::Invalid:
|
||||||
|
|
|
@ -17,6 +17,7 @@ enum {
|
||||||
OptListProperties = 'p',
|
OptListProperties = 'p',
|
||||||
OptStream = 's',
|
OptStream = 's',
|
||||||
OptListControls = 256,
|
OptListControls = 256,
|
||||||
|
OptStrictFormats = 257,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __CAM_MAIN_H__ */
|
#endif /* __CAM_MAIN_H__ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue