summaryrefslogtreecommitdiff
path: root/test/media_device
AgeCommit message (Expand)Author
2022-10-07test: meson: Use dictionaries instead of arrays to store test informationLaurent Pinchart
2022-10-07test: Rename 't' to 'test' in meson.buildLaurent Pinchart
2021-11-24test: Convert to pragma onceKieran Bingham
2021-10-15test: Remove using namespace in header filesHirokazu Honda
2021-08-09libcamera: Rename 'method' to 'function'Laurent Pinchart
2021-06-25libcamera/base: Validate internal headers as privateKieran Bingham
2020-10-23libcamera: Drop unneeded empty default constructors and destructorsLaurent Pinchart
2020-10-20test: Omit extra semicolonsHirokazu Honda
2020-05-16libcamera: Move internal headers to include/libcamera/internal/Laurent Pinchart
2020-05-13licenses: License all meson files under CC0-1.0Laurent Pinchart
2019-11-18libcamera: Remove space between empty curly bracketsLaurent Pinchart
2019-10-23libcamera: Standardise on C compatibility headersLaurent Pinchart
2019-05-23meson: Create and use a dependency for libcamera and its headersLaurent Pinchart
2019-05-23meson: Fix coding style in meson.build filesLaurent Pinchart
2019-05-17test: media_device: Add test for acquire() and release()Niklas Söderlund
2019-05-17test: media_device: Create a common MediaDeviceTest base classNiklas Söderlund
2019-05-17libcamera: media_device: Handle media device fd in acquire() and release()Niklas Söderlund
2019-05-17libcamera: media_device: Open and close media device inside populate()Niklas Söderlund
2019-05-17libcamera: Always check return value of MediaDevice::acquire()Niklas Söderlund
2019-01-24libcamera: device_enumerator: Reference-count MediaDevice instancesLaurent Pinchart
2019-01-22libcamera: Global s/devnode/deviceNode renameJacopo Mondi
2019-01-14test: media_device: Add link handling testJacopo Mondi
2019-01-14test: media_device: Make MediaDeviceTest a MediaDevicePrintTestJacopo Mondi
2019-01-14test: media_device: Convert to foreachKieran Bingham
2019-01-02test: media_device: Move test definitionKieran Bingham
2019-01-01test: Move test objects to libtestKieran Bingham
2018-12-31test: Add media device testJacopo Mondi
n>CameraLens() = default; /** * \brief Initialize the camera lens instance * * This function performs the initialisation steps of the CameraLens that may * fail. It shall be called once and only once after constructing the instance. * * \return 0 on success or a negative error code otherwise */ int CameraLens::init() { if (entity_->function() != MEDIA_ENT_F_LENS) { LOG(CameraLens, Error) << "Invalid lens function " << utils::hex(entity_->function()); return -EINVAL; } /* Create and open the subdev. */ subdev_ = std::make_unique<V4L2Subdevice>(entity_); int ret = subdev_->open(); if (ret < 0) return ret; ret = validateLensDriver(); if (ret) return ret; model_ = subdev_->model(); return 0; } /** * \brief This function sets the focal point of the lens to a specific position. * \param[in] position The focal point of the lens * * This function sets the value of focal point of the lens as in \a position. * * \return 0 on success or -EINVAL otherwise */ int CameraLens::setFocusPosition(int32_t position) { ControlList lensCtrls(subdev_->controls()); lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, static_cast<int32_t>(position)); if (subdev_->setControls(&lensCtrls)) return -EINVAL; return 0; } int CameraLens::validateLensDriver() { int ret = 0; static constexpr uint32_t mandatoryControls[] = { V4L2_CID_FOCUS_ABSOLUTE, }; const ControlInfoMap &controls = subdev_->controls(); for (uint32_t ctrl : mandatoryControls) { if (!controls.count(ctrl)) { LOG(CameraLens, Error) << "Mandatory V4L2 control " << utils::hex(ctrl) << " not available"; ret = -EINVAL; } } if (ret) { LOG(CameraLens, Error) << "The lens kernel driver needs to be fixed"; LOG(CameraLens, Error) << "See Documentation/lens_driver_requirements.rst in" << " the libcamera sources for more information"; return ret; } return ret; } /** * \fn CameraLens::model() * \brief Retrieve the lens model name * * The lens model name is a free-formed string that uniquely identifies the * lens model. * * \return The lens model name */ std::string CameraLens::logPrefix() const { return "'" + entity_->name() + "'"; } /** * \fn CameraLens::controls() * \brief Retrieve the V4L2 controls of the lens' subdev * * \return A map of the V4L2 controls supported by the lens' driver */ const ControlInfoMap &CameraLens::controls() const { return subdev_->controls(); } } /* namespace libcamera */