libcamera  v0.4.0
Supporting cameras in Linux since 2019
Classes | Namespaces | Macros
camera_sensor.h File Reference

A camera sensor. More...

#include <memory>
#include <string>
#include <variant>
#include <vector>
#include <libcamera/base/class.h>
#include <libcamera/control_ids.h>
#include <libcamera/controls.h>
#include <libcamera/geometry.h>
#include <libcamera/orientation.h>
#include <libcamera/transform.h>
#include "libcamera/internal/bayer_format.h"
#include "libcamera/internal/camera_sensor_properties.h"
#include "libcamera/internal/v4l2_subdevice.h"
Include dependency graph for camera_sensor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  libcamera::CameraSensor
 A abstract camera sensor. More...
 
class  libcamera::CameraSensorFactoryBase
 Base class for camera sensor factories. More...
 
class  libcamera::CameraSensorFactory< _CameraSensor >
 Registration of CameraSensorFactory classes and creation of instances. More...
 

Namespaces

 libcamera
 Top-level libcamera namespace.
 

Macros

#define REGISTER_CAMERA_SENSOR(sensor, priority)   static CameraSensorFactory<sensor> global_##sensor##Factory{ #sensor, priority };
 Register a camera sensor type to the sensor factory. More...
 

Detailed Description

A camera sensor.

Macro Definition Documentation

◆ REGISTER_CAMERA_SENSOR

#define REGISTER_CAMERA_SENSOR (   sensor,
  priority 
)    static CameraSensorFactory<sensor> global_##sensor##Factory{ #sensor, priority };

Register a camera sensor type to the sensor factory.

Parameters
[in]sensorClass name of the CameraSensor derived class to register
[in]priorityPriority order for factory selection

Register a CameraSensor subclass with the factory and make it available to try and match sensors. The subclass needs to implement a static match function:

static std::variant<std::unique_ptr<CameraSensor>, int> match(MediaEntity *entity);

The function tests if the sensor class supports the camera sensor identified by a MediaEntity. If so, it creates a new instance of the sensor class. The return value is a variant that contains

  • A new instance of the camera sensor class if the entity matched and creation succeeded ;
  • A non-zero error code if the entity matched and the creation failed ; or
  • A zero error code if the entity didn't match.

When multiple factories can support the same MediaEntity (as in the match() function of multiple factories returning true for the same entity), the priority argument selects which factory will be used. See CameraSensorFactoryBase::create() for more information.