summaryrefslogtreecommitdiff
path: root/src/cam
AgeCommit message (Collapse)Author
2019-03-25cam: options: Create separate enum for OptionValue typesNiklas Söderlund
In preparation for support of multiple instances of the same option, create a separate enum for the OptionValue types as it will diverge from enum OptionType. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-03-01cam: Don't requeue requests when stopping streamLaurent Pinchart
When stopping the stream all pending requests are cancelled, resulting in the request completion signal being emitted with the request status set appropriately. Check the request status in the request completion slot and skip requeuing the request if it has been cancelled. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-28libcamera: store stream pointers in sets instead of a vectorsNiklas Söderlund
The arrays that store Stream pointers shall always contain unique values. Storing them in vectors opens up for the same stream pointer appearing twice. Remove this possibility by storing them in a set which guarantees each element is unique. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-28cam: fix order camera is operated onNiklas Söderlund
Upcoming enforcing of order the camera shall be operate on is not compatible with the cam utility. Requests shall be queued after the camera is started, not before. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-25cam: Improve when usage information is printedNiklas Söderlund
Running the cam tool without any options results in the tool to exit with EXIT_FAILURE but no usage being printed, this is confusing. Improve this by also printing the usage text. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-25cam: fix printing of camera nameNiklas Söderlund
Since commit c8c546fe99a343c1 ("cam: options: Add option type handling to options parser") introduced type handling for options the context the option is read became important. When reading the camera option for printing there is no explicit context to print it as a string and instead the int context was chosen resulting in: $ cam --camera foo Camera 0 not found While the expected output is: $ cam --camera foo Camera foo not found Fix this by providing the correct context for the camera option when printing it. Fixes: c8c546fe99a343c1 ("cam: options: Add option type handling to options parser") Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-25cam: improve error checking when capturingNiklas Söderlund
The return value when start() and stop() the camera should be checked and handled. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-25cam: free allocated buffers when done capturingNiklas Söderlund
The allocated buffers needs to be freed once the application is done with them. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-25cam: fix return type of configureStreams()Niklas Söderlund
The only caller of configureStreams() stores its return value as an int and not bool. This is confusing and also prevents the (possibly) different error codes returned by Camera::configureStreams() to be propagated inside the cam tool. Fix this by changing the return type to int and propagate the return value from the camera. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-13cam: options: Fix coding style issue related to templatesLaurent Pinchart
Our coding style doesn't add a space after the template keyword. Fix the source code accordingly. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-06cam: Add option to write raw frames to diskNiklas Söderlund
Use the helper BufferWriter to optionally write frames to disk as they are captured. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-06cam: Add BufferWriter helperNiklas Söderlund
Add a simpler helper to allow the cam application to write raw captured frames to disk. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-06cam: Add capture operationNiklas Söderlund
Add an option to capture frames from a camera and keep it running until the user terminates by sending SIGINT. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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>