Array controls (eg. ColourCorrectionMatrix, FrameDurationLimits, ColourGains) are serialized properly by the ControlSerializer, but are not deserialized properly. This is because their arrayness and size are not considered during deserialization. Fix this by adding arrayness and size to the serialized form of all ControlValues. This is achieved by fully serializing the min/max/def ControlValue's metadata associated with each ControlInfo entry in the ControlInfoMap. While at it, clean up the serialization format of ControlValues and ControlLists: - ControlValue's id is only used by ControlList, so add a new struct for ControlList entries to contain it, and remove id from ControlValue - Remove offset from ControlInfo's entry, as it is no longer needed, since the serialized data of a ControlInfo has now been converted to simply three serialized ControlValues - Remove the type from the serialized data of ControlValue, as it is already in the metadata entry The issue regarding array controls was not noticed before because the default value of the ControlInfo of other array controls had been set to scalar values similar to how min/max are set, and ColourCorrectionMatrix was the first control to properly define a non-scalar default value. Bug: https://bugs.libcamera.org/show_bug.cgi?id=285 Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> # rkisp1 Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
67 lines
1.6 KiB
C++
67 lines
1.6 KiB
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2019, Google Inc.
|
|
*
|
|
* Control (de)serializer
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include <libcamera/controls.h>
|
|
|
|
namespace libcamera {
|
|
|
|
class ByteStreamBuffer;
|
|
|
|
class ControlSerializer
|
|
{
|
|
public:
|
|
enum class Role {
|
|
Proxy,
|
|
Worker
|
|
};
|
|
|
|
ControlSerializer(Role role);
|
|
|
|
void reset();
|
|
|
|
static size_t binarySize(const ControlInfoMap &infoMap);
|
|
static size_t binarySize(const ControlList &list);
|
|
|
|
int serialize(const ControlInfoMap &infoMap, ByteStreamBuffer &buffer);
|
|
int serialize(const ControlList &list, ByteStreamBuffer &buffer);
|
|
|
|
template<typename T>
|
|
T deserialize(ByteStreamBuffer &buffer);
|
|
|
|
bool isCached(const ControlInfoMap &infoMap);
|
|
|
|
private:
|
|
static size_t binarySize(const ControlValue &value);
|
|
static size_t binarySize(const ControlInfo &info);
|
|
|
|
static void store(const ControlValue &value, ByteStreamBuffer &buffer);
|
|
static void store(const ControlInfo &info, ByteStreamBuffer &buffer);
|
|
|
|
void populateControlValueEntry(struct ipa_control_value_entry &entry,
|
|
const ControlValue &value,
|
|
uint32_t offset);
|
|
|
|
ControlValue loadControlValue(ByteStreamBuffer &buffer,
|
|
ControlType type,
|
|
bool isArray, unsigned int count);
|
|
|
|
unsigned int serial_;
|
|
unsigned int serialSeed_;
|
|
std::vector<std::unique_ptr<ControlId>> controlIds_;
|
|
std::vector<std::unique_ptr<ControlIdMap>> controlIdMaps_;
|
|
std::map<unsigned int, ControlInfoMap> infoMaps_;
|
|
std::map<const ControlInfoMap *, unsigned int> infoMapHandles_;
|
|
};
|
|
|
|
} /* namespace libcamera */
|