summaryrefslogtreecommitdiff
path: root/Documentation/coding-style.rst
AgeCommit message (Collapse)Author
2019-04-19libcamera: Document documentation style and update the code accordinglyLaurent Pinchart
The documentation style for the Doxygen comment blocks is inconsistent in the library. Document the expectations and update all existing comment blocks to match. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-14Documentation: coding-style: Discourage move on shared_ptr<>Jacopo Mondi
Using std::move() on return statement of a method or on the its returned value prevents the compiler from implementing copy-elision. Discourage that in the coding style document. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-22utils: checkstyle: Add support for clang-formatLaurent Pinchart
clang-format produces better results than astyle as it can better match the libcamera coding style. Default to clang-format over astyle, fall back to astyle if clang-format isn't found, and add a --formatter command line option to select a formatter manually. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-21Documentation: coding_style: Add object ownership rulesLaurent Pinchart
Object ownership is a complex topic that can lead to many issues, from memory leak to crashes. Document the rules that libcamera enforces to make object ownership tracking explicit. This is a first version of the rules and is expected to be expanded as the library is developed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-21Documentation: coding_style: Add move semantics to C++11 featuresLaurent Pinchart
Add the move semantics (move constructor and move assignment) to the allowed C++11 features, as we extensively use them for the unique and shared pointers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-16Documentation: coding_style: Allow C++11 variadic templatesLaurent Pinchart
We make use of the C++11 variadic templates feature in the signal&slot implementation, mark it as allowed in the coding style documentation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-14Documentation: Document the style check scriptJacopo Mondi
Add a section to the coding style documentation to explain usage of the checkstyle.py script. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2018-12-14Documentation: coding-style: Fix list indentationLaurent Pinchart
The various lists in the document are not quoted blocks. Don't indent them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2018-12-13Documentation: Add coding style documentJacopo Mondi
Add document to summarize the coding style adopted by libcamera. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
span class="hl kwd">start(const ControlList &controls, StartResult *result) override; void stop() override {} void mapBuffers(const std::vector<IPABuffer> &buffers) override; void unmapBuffers(const std::vector<unsigned int> &ids) override; void prepareIsp(const PrepareParams &params) override; void processStats(const ProcessParams &params) override; protected: /* Raspberry Pi controller specific defines. */ std::unique_ptr<RPiController::CamHelper> helper_; RPiController::Controller controller_; ControlInfoMap sensorCtrls_; ControlInfoMap lensCtrls_; /* Camera sensor params. */ CameraMode mode_; /* Track the frame length times over FrameLengthsQueueSize frames. */ std::deque<utils::Duration> frameLengths_; utils::Duration lastTimeout_; private: /* Number of metadata objects available in the context list. */ static constexpr unsigned int numMetadataContexts = 16; virtual int32_t platformInit(const InitParams &params, InitResult *result) = 0; virtual int32_t platformStart(const ControlList &controls, StartResult *result) = 0; virtual int32_t platformConfigure(const ConfigParams &params, ConfigResult *result) = 0; virtual void platformPrepareIsp(const PrepareParams &params, RPiController::Metadata &rpiMetadata) = 0; virtual RPiController::StatisticsPtr platformProcessStats(Span<uint8_t> mem) = 0; void setMode(const IPACameraSensorInfo &sensorInfo); void setCameraTimeoutValue(); bool validateSensorControls(); bool validateLensControls(); void applyControls(const ControlList &controls); virtual void handleControls(const ControlList &controls) = 0; void fillDeviceStatus(const ControlList &sensorControls, unsigned int ipaContext); void reportMetadata(unsigned int ipaContext); void applyFrameDurations(utils::Duration minFrameDuration, utils::Duration maxFrameDuration); void applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls); std::map<unsigned int, MappedFrameBuffer> buffers_; bool lensPresent_; bool monoSensor_; ControlList libcameraMetadata_; std::array<RPiController::Metadata, numMetadataContexts> rpiMetadata_; /* * We count frames to decide if the frame must be hidden (e.g. from * display) or mistrusted (i.e. not given to the control algos). */ uint64_t frameCount_; /* How many frames we should avoid running control algos on. */ unsigned int mistrustCount_; /* Number of frames that need to be dropped on startup. */ unsigned int dropFrameCount_; /* Frame timestamp for the last run of the controller. */ uint64_t lastRunTimestamp_; /* Do we run a Controller::process() for this frame? */ bool processPending_; /* Distinguish the first camera start from others. */ bool firstStart_; /* Frame duration (1/fps) limits. */ utils::Duration minFrameDuration_; utils::Duration maxFrameDuration_; /* The current state of flicker avoidance. */ struct FlickerState { int32_t mode; utils::Duration manualPeriod; } flickerState_; }; } /* namespace ipa::RPi */ } /* namespace libcamera */