libcamera: control_serializer: Add array info to serialized ControlValue

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>
This commit is contained in:
Paul Elder
2025-11-17 17:08:14 +09:00
committed by Kieran Bingham
parent 7313f046a2
commit cfdc281100
4 changed files with 182 additions and 126 deletions

View File

@@ -47,9 +47,13 @@ private:
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,
bool isArray = false, unsigned int count = 1);
ControlInfo loadControlInfo(ByteStreamBuffer &buffer);
ControlType type,
bool isArray, unsigned int count);
unsigned int serial_;
unsigned int serialSeed_;

View File

@@ -15,7 +15,7 @@ namespace libcamera {
extern "C" {
#endif
#define IPA_CONTROLS_FORMAT_VERSION 1
#define IPA_CONTROLS_FORMAT_VERSION 2
enum ipa_controls_id_map_type {
IPA_CONTROL_ID_MAP_CONTROLS,
@@ -34,20 +34,26 @@ struct ipa_controls_header {
};
struct ipa_control_value_entry {
uint32_t id;
uint8_t type;
uint8_t is_array;
uint16_t count;
uint32_t offset;
uint32_t padding[1];
uint32_t reserved[2];
};
struct ipa_control_list_entry {
uint32_t id;
struct ipa_control_value_entry value;
};
struct ipa_control_info_entry {
uint32_t id;
uint32_t type;
uint32_t offset;
uint8_t direction;
uint8_t padding[3];
uint8_t padding[7];
struct ipa_control_value_entry min;
struct ipa_control_value_entry max;
struct ipa_control_value_entry def;
};
#ifdef __cplusplus