@@ -69,6 +69,8 @@ protected:
std::string logPrefix() const;
private:
+ int initProperties();
+
const MediaEntity *entity_;
std::unique_ptr<V4L2Subdevice> subdev_;
unsigned int pad_;
@@ -205,7 +205,47 @@ int CameraSensor::init()
if (ret < 0)
return ret;
- /* Retrieve and store the camera sensor properties. */
+ /* Enumerate, sort and cache media bus codes and sizes. */
+ formats_ = subdev_->formats(pad_);
+ if (formats_.isEmpty()) {
+ LOG(CameraSensor, Error) << "No image format found";
+ return -EINVAL;
+ }
+
+ mbusCodes_ = formats_.formats();
+ std::sort(mbusCodes_.begin(), mbusCodes_.end());
+
+ for (const auto &format : formats_.data()) {
+ const std::vector<SizeRange> &ranges = format.second;
+ std::transform(ranges.begin(), ranges.end(), std::back_inserter(sizes_),
+ [](const SizeRange &range) { return range.max; });
+ }
+
+ std::sort(sizes_.begin(), sizes_.end());
+
+ /* Remove duplicates. */
+ auto last = std::unique(sizes_.begin(), sizes_.end());
+ sizes_.erase(last, sizes_.end());
+
+ /*
+ * The sizes_ vector is sorted in ascending order, the resolution is
+ * thus the last element of the vector.
+ */
+ resolution_ = sizes_.back();
+
+ return initProperties();
+}
+
+/**
+ * \brief Initialize the camera sensor standard properties
+ *
+ * This method initializes the camera sensor standard properties, by inspecting
+ * the control information reported by the sensor subdevice.
+ *
+ * \return 0 on success, a negative error code otherwise
+ */
+int CameraSensor::initProperties()
+{
const ControlInfoMap &controls = subdev_->controls();
int32_t propertyValue;
@@ -243,35 +283,6 @@ int CameraSensor::init()
propertyValue = 0;
properties_.set(properties::Rotation, propertyValue);
- /* Enumerate, sort and cache media bus codes and sizes. */
- formats_ = subdev_->formats(pad_);
- if (formats_.isEmpty()) {
- LOG(CameraSensor, Error) << "No image format found";
- return -EINVAL;
- }
-
- mbusCodes_ = formats_.formats();
- std::sort(mbusCodes_.begin(), mbusCodes_.end());
-
- for (const auto &format : formats_.data()) {
- const std::vector<SizeRange> &ranges = format.second;
- std::transform(ranges.begin(), ranges.end(), std::back_inserter(sizes_),
- [](const SizeRange &range) { return range.max; });
- }
-
- std::sort(sizes_.begin(), sizes_.end());
-
- /* Remove duplicates. */
- auto last = std::unique(sizes_.begin(), sizes_.end());
- sizes_.erase(last, sizes_.end());
-
- /*
- * The sizes_ vector is sorted in ascending order, the resolution is
- * thus the last element of the vector.
- */
- resolution_ = sizes_.back();
-
- return 0;
}
/**
@@ -438,12 +449,6 @@ ControlList CameraSensor::getControls(const std::vector<uint32_t> &ids)
return subdev_->getControls(ids);
}
-/**
- * \fn CameraSensor::properties()
- * \brief Retrieve the camera sensor properties
- * \return The list of camera sensor properties
- */
-
/**
* \brief Write controls to the sensor
* \param[in] ctrls The list of controls to write
@@ -535,6 +540,12 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const
return 0;
}
+/**
+ * \fn CameraSensor::properties()
+ * \brief Retrieve the camera sensor properties
+ * \return The list of camera sensor properties
+ */
+
std::string CameraSensor::logPrefix() const
{
return "'" + entity_->name() + "'";