mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-24 17:15:07 +03:00
libcamera: camera_sensor: Reference test pattern modes by enum type
The CameraSensor stores TestPatternModes as an int32_t. This prevents the compiler from verifying the usage against the defined enum types. Fix references to the TestPatternMode to store the value as the TestPatternModeEnum type which is defined by the control generator. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
b53f6efb99
commit
5148c0aa7e
4 changed files with 14 additions and 9 deletions
|
@ -14,8 +14,10 @@
|
|||
#include <libcamera/base/class.h>
|
||||
#include <libcamera/base/log.h>
|
||||
|
||||
#include <libcamera/control_ids.h>
|
||||
#include <libcamera/controls.h>
|
||||
#include <libcamera/geometry.h>
|
||||
|
||||
#include <libcamera/ipa/core_ipa_interface.h>
|
||||
|
||||
#include "libcamera/internal/formats.h"
|
||||
|
@ -41,7 +43,7 @@ public:
|
|||
const std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }
|
||||
const std::vector<Size> sizes(unsigned int mbusCode) const;
|
||||
Size resolution() const;
|
||||
const std::vector<int32_t> &testPatternModes() const
|
||||
const std::vector<controls::draft::TestPatternModeEnum> &testPatternModes() const
|
||||
{
|
||||
return testPatternModes_;
|
||||
}
|
||||
|
@ -74,7 +76,8 @@ private:
|
|||
void initVimcDefaultProperties();
|
||||
void initStaticProperties();
|
||||
void initTestPatternModes(
|
||||
const std::map<int32_t, int32_t> &testPatternModeMap);
|
||||
const std::map<controls::draft::TestPatternModeEnum, int32_t>
|
||||
&testPatternModeMap);
|
||||
int initProperties();
|
||||
|
||||
const MediaEntity *entity_;
|
||||
|
@ -87,7 +90,7 @@ private:
|
|||
V4L2Subdevice::Formats formats_;
|
||||
std::vector<unsigned int> mbusCodes_;
|
||||
std::vector<Size> sizes_;
|
||||
std::vector<int32_t> testPatternModes_;
|
||||
std::vector<controls::draft::TestPatternModeEnum> testPatternModes_;
|
||||
|
||||
Size pixelArraySize_;
|
||||
Rectangle activeArea_;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <libcamera/control_ids.h>
|
||||
#include <libcamera/geometry.h>
|
||||
|
||||
namespace libcamera {
|
||||
|
@ -18,7 +19,7 @@ struct CameraSensorProperties {
|
|||
static const CameraSensorProperties *get(const std::string &sensor);
|
||||
|
||||
Size unitCellSize;
|
||||
std::map<int32_t, int32_t> testPatternModes;
|
||||
std::map<controls::draft::TestPatternModeEnum, int32_t> testPatternModes;
|
||||
};
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
|
|
@ -311,7 +311,7 @@ void CameraSensor::initStaticProperties()
|
|||
}
|
||||
|
||||
void CameraSensor::initTestPatternModes(
|
||||
const std::map<int32_t, int32_t> &testPatternModes)
|
||||
const std::map<controls::draft::TestPatternModeEnum, int32_t> &testPatternModes)
|
||||
{
|
||||
const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN);
|
||||
if (v4l2TestPattern == controls().end()) {
|
||||
|
@ -327,7 +327,7 @@ void CameraSensor::initTestPatternModes(
|
|||
* control index is supported in the below for loop that creates the
|
||||
* list of supported test patterns.
|
||||
*/
|
||||
std::map<int32_t, int32_t> indexToTestPatternMode;
|
||||
std::map<int32_t, controls::draft::TestPatternModeEnum> indexToTestPatternMode;
|
||||
for (const auto &it : testPatternModes)
|
||||
indexToTestPatternMode[it.second] = it.first;
|
||||
|
||||
|
|
|
@ -983,13 +983,14 @@ int PipelineHandlerIPU3::updateControls(IPU3CameraData *data)
|
|||
return ret;
|
||||
|
||||
ControlInfoMap::Map controls = IPU3Controls;
|
||||
const std::vector<int32_t> &testPatternModes = sensor->testPatternModes();
|
||||
const std::vector<controls::draft::TestPatternModeEnum>
|
||||
&testPatternModes = sensor->testPatternModes();
|
||||
if (!testPatternModes.empty()) {
|
||||
std::vector<ControlValue> values;
|
||||
values.reserve(testPatternModes.size());
|
||||
|
||||
for (int32_t pattern : testPatternModes)
|
||||
values.emplace_back(pattern);
|
||||
for (auto pattern : testPatternModes)
|
||||
values.emplace_back(static_cast<int32_t>(pattern));
|
||||
|
||||
controls[&controls::draft::TestPatternMode] = ControlInfo(values);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue