[libcamera-devel,0/5] generate and use fixed-sized Span Control types
mbox series

Message ID 20220401000616.12976-1-Rauch.Christian@gmx.de
Headers show
Series
  • generate and use fixed-sized Span Control types
Related show

Message

Christian Rauch April 1, 2022, 12:06 a.m. UTC
Hello,

This series of patches explicitely defines Spans of Control as either fixed-
or variable- sized. The control and property definitions in "control_ids.yaml"
and "property_ids.yaml", respectively, already specify the size of array-typed
Controls. The "gen-controls.py" script, which generates source and header files
from those definitions, currently ignores the provided "size" value and
translates any "size" into a variable-sized Span<T>.

The motivation for this is to carry the dimensionaltiy of a Control from its
original definition within the source into the public API, in order to provide
information about the dimension of the settings that a camera is expecting.
Currently, this information is not available via the public API.

This patch series implements the fixed-sized Span<T,N> generation in three steps:
1. The format of the "size" property in the definitions is now interpreted as a
   shape array, where an array of size greater than 1 (e.g. [3,3]) defines the
   shape of a multi-dimensional array (a.k.a. tensor), and an empty size (e.g. [])
   defines a variable-sized array.
2. When a Control is deifned with a size in the yaml (e.g. "size: [2]"), the
   "gen-controls.py" script now translates this into a fixed-sized Span<T,N>
   (e.g. with N=2). This requires a default contructor for fixed-sized Spans and
   the removal of 0-fixed-sized Spans (i.e. Span<T,0>).
2. Where applicable, the old variable-sized Span<T> types are replaced by the new
   fixed-sized Span<T,N> types, in some cases by explicit casts.

This patch set is submitted in conjunction with my set of patches that fully define
the ControlInfo of Span Controls, but can be applied seperately without a change in
the default behaviour.

Best,
Christian


Christian Rauch (5):
  define Span size as shape vector
  generate fixed- and variable-sized Span Controls
  provide a default fixed-sized Span constructor
  apply clang-format style
  apply explicit fixed-sized Span type casts

 include/libcamera/base/span.h                 |  50 +++---
 include/libcamera/controls.h                  |   2 +-
 src/ipa/raspberrypi/raspberrypi.cpp           |  21 +--
 src/libcamera/control_ids.yaml                |   2 +-
 .../pipeline/raspberrypi/raspberrypi.cpp      |  36 +++--
 src/libcamera/property_ids.yaml               |   4 +-
 src/qcam/dng_writer.cpp                       | 142 +++++++++---------
 test/span.cpp                                 |   6 +-
 utils/gen-controls.py                         |  33 ++--
 9 files changed, 160 insertions(+), 136 deletions(-)

--
2.25.1