Commit graph

9 commits

Author SHA1 Message Date
Laurent Pinchart
73b7ba9da5 libcamera: controls: Name all ControlInfoMap instance variables infoMap
To prepare for the rename of ControlRange to ControlInfo, rename all the
ControlInfoMap instance variables currently named info to infoMap. This
will help avoiding namespace clashes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-03-20 16:47:45 +02:00
Laurent Pinchart
4034e45f0a test: controls: Add ControlInfoMap test
Add a test to exercise the ControlInfoMap API. This currently tests
at(), count(), find() and end().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-11-20 21:47:22 +02:00
Laurent Pinchart
ace50f75a4 libcamera: controls: Rename ControlInfo to ControlRange
The ControlInfo class stores a range of valid values for a control. Its
name is vague, as "info" has multiple meanings. Rename it to
ControlRange.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-05 20:02:51 +03:00
Laurent Pinchart
f1ab117e81 libcamera: controls: Remove ControlInfo::id
The ControlInfo id member is only used in the toString() method of the
class, and nowhere else externally. The same way that ControlValue
doesn't store a ControlId, ControlInfo shouldn't. Remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-05 20:02:51 +03:00
Laurent Pinchart
a8c40942b9 libcamera: controls: Improve the API towards applications
Rework the control-related classes to improve the API towards
applications. The goal is to enable writing code similar to

	Request *req = ...;
	ControlList &controls = req->controls();
	controls->set(controls::AwbEnable, false);
	controls->set(controls::ManualExposure, 1000);

	...

	int32_t exposure = controls->get(controls::ManualExposure);

with the get and set operations ensuring type safety for the control
values. This is achieved by creating the following classes:

- Control defines controls and is the main way to reference a control.
  It is a template class to allow methods using it to refer to the
  control type.

- ControlId is the base class of Control. It stores the control ID, name
  and type, and can be used in contexts where a control needs to be
  referenced regardless of its type (for instance in lists of controls).
  This class replaces ControlIdentifier.

- ControlValue is kept as-is.

The ControlList class now exposes two template get() and set() methods
that replace the operator[]. They ensure type safety by infering the
value type from the Control reference that they receive.

The main way to refer to a control is now through the Control class, and
optionally through its base ControlId class. The ControlId enumeration
is removed, replaced by a list of global Control instances. Numerical
control IDs are turned into macros, and are still exposed as they are
required to communicate with IPAs (especially to deserialise control
lists). They should however not be used by applications.

Auto-generation of header and source files is removed for now to keep
the change simple. It will be added back in the future in a more
elaborate form.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-04 19:33:08 +03:00
Laurent Pinchart
dd37ef784e libcamera: controls: Use explicit 32-bit integer types
Make the control API more explicit when dealing with integer controls by
specifying the size. We already do so for 64-bit integers, using int64_t
and ControlTypeInteger64, do the same for 32-bit integers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-04 19:33:08 +03:00
Laurent Pinchart
224ef9776a libcamera: controls: Make ControlValue get/set accessors template methods
The ControlValue get accessors are implemented with functions of
different names, whlie the set accessors use polymorphism to support
different control types. This isn't very consistent and intuitive. Make
the API clearer by using template methods. This will also have the added
advantage that support for the new types will only require adding
template specialisations, without adding new methods.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-04 19:33:08 +03:00
Laurent Pinchart
c5dfd9d57e libcamera: controls: Rename ControlValueType to ControlType
The type of a control value is also the type of the control. Shorten the
ControlValueType enumeration to ControlType, and rename ControlValue* to
ControlType* for better clarity.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-10-04 19:33:08 +03:00
Kieran Bingham
41c184afc3 libcamera: test: Add ControlInfo test
Provide an initial test coverage for the ControlInfo class.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-02 16:59:49 +03:00