libcamera: CameraSensor: Enable retrieving supported test pattern modes
This enables retrieving supported test pattern modes through CameraSensorInfo. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
0b312cb4ac
commit
5d0eb40249
2 changed files with 41 additions and 0 deletions
|
@ -39,6 +39,10 @@ public:
|
||||||
const std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }
|
const std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }
|
||||||
const std::vector<Size> &sizes() const { return sizes_; }
|
const std::vector<Size> &sizes() const { return sizes_; }
|
||||||
Size resolution() const;
|
Size resolution() const;
|
||||||
|
const std::vector<int32_t> &testPatternModes() const
|
||||||
|
{
|
||||||
|
return testPatternModes_;
|
||||||
|
}
|
||||||
|
|
||||||
V4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,
|
V4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,
|
||||||
const Size &size) const;
|
const Size &size) const;
|
||||||
|
@ -65,6 +69,8 @@ private:
|
||||||
int validateSensorDriver();
|
int validateSensorDriver();
|
||||||
void initVimcDefaultProperties();
|
void initVimcDefaultProperties();
|
||||||
void initStaticProperties();
|
void initStaticProperties();
|
||||||
|
void initTestPatternModes(
|
||||||
|
const std::map<int32_t, int32_t> &testPatternModeMap);
|
||||||
int initProperties();
|
int initProperties();
|
||||||
|
|
||||||
const MediaEntity *entity_;
|
const MediaEntity *entity_;
|
||||||
|
@ -77,6 +83,7 @@ private:
|
||||||
V4L2Subdevice::Formats formats_;
|
V4L2Subdevice::Formats formats_;
|
||||||
std::vector<unsigned int> mbusCodes_;
|
std::vector<unsigned int> mbusCodes_;
|
||||||
std::vector<Size> sizes_;
|
std::vector<Size> sizes_;
|
||||||
|
std::vector<int32_t> testPatternModes_;
|
||||||
|
|
||||||
Size pixelArraySize_;
|
Size pixelArraySize_;
|
||||||
Rectangle activeArea_;
|
Rectangle activeArea_;
|
||||||
|
|
|
@ -305,6 +305,32 @@ void CameraSensor::initStaticProperties()
|
||||||
|
|
||||||
/* Register the properties retrieved from the sensor database. */
|
/* Register the properties retrieved from the sensor database. */
|
||||||
properties_.set(properties::UnitCellSize, props->unitCellSize);
|
properties_.set(properties::UnitCellSize, props->unitCellSize);
|
||||||
|
|
||||||
|
initTestPatternModes(props->testPatternModes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CameraSensor::initTestPatternModes(
|
||||||
|
const std::map<int32_t, int32_t> &testPatternModes)
|
||||||
|
{
|
||||||
|
const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN);
|
||||||
|
if (v4l2TestPattern == controls().end()) {
|
||||||
|
LOG(CameraSensor, Debug) << "No static test pattern map for \'"
|
||||||
|
<< model() << "\'";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const ControlValue &value : v4l2TestPattern->second.values()) {
|
||||||
|
const int32_t index = value.get<int32_t>();
|
||||||
|
|
||||||
|
const auto it = testPatternModes.find(index);
|
||||||
|
if (it == testPatternModes.end()) {
|
||||||
|
LOG(CameraSensor, Debug)
|
||||||
|
<< "Test pattern mode " << index << " ignored";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
testPatternModes_.push_back(it->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CameraSensor::initProperties()
|
int CameraSensor::initProperties()
|
||||||
|
@ -469,6 +495,14 @@ Size CameraSensor::resolution() const
|
||||||
return std::min(sizes_.back(), activeArea_.size());
|
return std::min(sizes_.back(), activeArea_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn CameraSensor::testPatternModes()
|
||||||
|
* \brief Retrieve all the supported test pattern modes of the camera sensor
|
||||||
|
* The test pattern mode values correspond to the controls::TestPattern control.
|
||||||
|
*
|
||||||
|
* \return The list of test pattern modes
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retrieve the best sensor format for a desired output
|
* \brief Retrieve the best sensor format for a desired output
|
||||||
* \param[in] mbusCodes The list of acceptable media bus codes
|
* \param[in] mbusCodes The list of acceptable media bus codes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue