summaryrefslogtreecommitdiff
path: root/src/cam
AgeCommit message (Collapse)Author
2019-02-01cam: options: Add explicit conversion methods to OptionValueLaurent Pinchart
The OptionValue class defines operators to convert the variant to all the supported option types. As a convenience, add explicit methods to perform the same operations, avoiding the need to write long static_cast<>() statements in the caller. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-01cam: Add --format option to configure a streamNiklas Söderlund
Add an option to configure the first stream of a camera from an argument with options and parse the width, height and pixel format from that list. The pixel format is still specified as a integer which should correspond to the kernels FOURCC identifiers. Going forward this should be turned into a string representation and the cam parser should translate between the two. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-01cam: options: Add a key=value parserNiklas Söderlund
Some options passed to the cam utility need to be complex and specify a list of key=value pairs. Add a new parser to deal with these options, usable on its own to parse key=value pairs from any string. Integrate the KeyValueParser into the existing OptionsParser. The cam application can fully describe all its options in one location and perform full parsing of all arguments in one go. The KeyValueParser also integrates itself with the usage() printing of the OptionsParser. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-01cam: options: Add option type handling to options parserLaurent Pinchart
Extend the options parser with support for option types. All options must now specify the type of their argument, and the parser automatically parses the argument and handles errors internally. Available types are none, integer or string. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-01cam: options: Store options in a list instead of a vectorLaurent Pinchart
When option are added to the parser, they are stored in the OptionsParser::options_ vector, and a pointer to the option referencing the vector entry is indexed in the OptionsParser::optionsMap_ map. When the next option is added the vector may be resized, which invalidates the pointers stored in the map. Fix this by storing the options in an std::list<> instead of std::vector<>. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-01cam: options: Return whether addOption() succeeds or notNiklas Söderlund
To later extend the options handling to cover subparsing of arguments it will be needed to know if the addition of the option itself was successful or not. The information is already present in addOption() this change just makes it available. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-01cam: options: Create a template class for optionsNiklas Söderlund
In preparation to adding more parsers create a template class to hold the parsed information. The rational for making it a template are that different parsers can index the options using different data types. The OptionsParser index its options using an int while the upcoming KeyValyeParser will index its options using strings for example. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-01cam: options: Move struct OptionLaurent Pinchart
The Option structure is declared within the OptionsParser, but will later be needed by other parsers. Move it outside the OptionsParser class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-01cam: options: Move enum OptionArgumentNiklas Söderlund
The enumeration of the different possibilities for arguments can be used by other parser then OptionsParser. Move it outside the class to make it ready to be used by other parsers. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-27cam: options: Indent multi-line help message correctlyLaurent Pinchart
Split multi-line help messages and indent all lines the same way. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-25cam: options: optional arguments needs to be specified as --foo=barNiklas Söderlund
It's not stated in the getopt_long documentation but optional arguments need to be specified as '--foo=bar' instead of '--foo bar', otherwise the value is not propagated to optarg during argument parsing. Update the usage printing helper to reflect this requirement. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-25cam: Add event loopLaurent Pinchart
Add a simple event loop to the cam application and use it in the main() function, with an example of how to handle SIGINT to gracefully stop the loop. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-22cam: options: Don't implement move semantics for OptionsParser::OptionsLaurent Pinchart
The compiler creates a move constructor automatically when none is supplied, and it does the right thing by default in this case. Using std::move() inside the function prevents the compiler from doing return value optimization and actually hinders performances. Using std::move() in the caller is unnecessary, the move constructor is used automatically by the compiler. For all these reasons remove the tentative optimization that resulted in worse performances and worse code. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-22cam: Extract option parser to separate fileLaurent Pinchart
And turn it into an OptionsParser object. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-22cam: add utility to control camerasNiklas Söderlund
Provide a utility to interact with cameras. This initial state is limited and only supports listing cameras in the system and selecting a camera to interact with. There is not much a interacting possible yet with a camera so the tool simply exercise the API to get hold of a camera. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>