summaryrefslogtreecommitdiff
path: root/src/libcamera/camera_sensor.cpp
diff options
context:
space:
mode:
authorHirokazu Honda <hiroh@chromium.org>2021-10-04 15:58:56 +0900
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-10-05 03:30:36 +0300
commit3c059b9164fdbe8188eaa466fe64f7f680c0843b (patch)
tree5e9638bbb3885801ab47f0fa0f76a494890e757f /src/libcamera/camera_sensor.cpp
parentf0139ed11ae7c7afeae8fa4a2a5c5d7aa9cddc5f (diff)
libcamera: camera_sensor: Reverse the key and value of test pattern mode map
The key and value of the test pattern mode are originally the index of v4l2 control and the corresponding test pattern mode control value. This key and value are useful in the initialization for reporting available test pattern modes. However, the map of the reversed key and value is much more useful in applying a requested test pattern mode. Reverses the key and value of the map as the initialization is one time but the test pattern mode request will be multiple times. 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: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/camera_sensor.cpp')
-rw-r--r--src/libcamera/camera_sensor.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index 87668509..9fdb8c09 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -320,11 +320,22 @@ void CameraSensor::initTestPatternModes(
return;
}
+ /*
+ * Create a map that associates the V4L2 control index to the test
+ * pattern mode by reversing the testPatternModes map provided by the
+ * camera sensor properties. This makes it easier to verify if the
+ * control index is supported in the below for loop that creates the
+ * list of supported test patterns.
+ */
+ std::map<int32_t, int32_t> indexToTestPatternMode;
+ for (const auto &it : testPatternModes)
+ indexToTestPatternMode[it.second] = it.first;
+
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()) {
+ const auto it = indexToTestPatternMode.find(index);
+ if (it == indexToTestPatternMode.end()) {
LOG(CameraSensor, Debug)
<< "Test pattern mode " << index << " ignored";
continue;