libcamera
v0.0.0+100-debian/0_git20200629+e7aa92a-8-9-g77f5237c-dirty (2021-05-05T16:20:29+01:00)
Supporting cameras in Linux since 2019
|
A camera sensor based on V4L2 subdevices. More...
Public Member Functions | |
CameraSensor (const MediaEntity *entity) | |
Construct a CameraSensor. More... | |
~CameraSensor () | |
Destroy a CameraSensor. | |
int | init () |
Initialize the camera sensor instance. More... | |
const std::string & | model () const |
Retrieve the sensor model name. More... | |
const std::string & | id () const |
Retrieve the sensor ID. More... | |
const MediaEntity * | entity () const |
Retrieve the sensor media entity. More... | |
const std::vector< unsigned int > & | mbusCodes () const |
Retrieve the media bus codes supported by the camera sensor. More... | |
const std::vector< Size > & | sizes () const |
Retrieve the frame sizes supported by the camera sensor. More... | |
Size | resolution () const |
Retrieve the camera sensor resolution. More... | |
V4L2SubdeviceFormat | getFormat (const std::vector< unsigned int > &mbusCodes, const Size &size) const |
Retrieve the best sensor format for a desired output. More... | |
int | setFormat (V4L2SubdeviceFormat *format) |
Set the sensor output format. More... | |
const ControlInfoMap & | controls () const |
Retrieve the supported V4L2 controls and their information. More... | |
ControlList | getControls (const std::vector< uint32_t > &ids) |
Read V4L2 controls from the sensor. More... | |
int | setControls (ControlList *ctrls) |
Write V4L2 controls to the sensor. More... | |
V4L2Subdevice * | device () |
Retrieve the camera sensor device. More... | |
const ControlList & | properties () const |
Retrieve the camera sensor properties. More... | |
int | sensorInfo (CameraSensorInfo *info) const |
Assemble and return the camera sensor info. More... | |
Protected Member Functions | |
std::string | logPrefix () const override |
Retrieve a string to be prefixed to the log message. More... | |
![]() | |
LogMessage | _log (const LogCategory *category, LogSeverity severity, const char *fileName=__builtin_FILE(), unsigned int line=__builtin_LINE()) const |
Create a temporary LogMessage object to log a message. More... | |
A camera sensor based on V4L2 subdevices.
The CameraSensor class eases handling of sensors for pipeline handlers by hiding the details of the V4L2 subdevice kernel API and caching sensor information.
The implementation is currently limited to sensors that expose a single V4L2 subdevice with a single pad. It will be extended to support more complex devices as the needs arise.
|
explicit |
Construct a CameraSensor.
[in] | entity | The media entity backing the camera sensor |
Once constructed the instance must be initialized with init().
const ControlInfoMap & libcamera::CameraSensor::controls | ( | ) | const |
Retrieve the supported V4L2 controls and their information.
|
inline |
Retrieve the camera sensor device.
|
inline |
Retrieve the sensor media entity.
ControlList libcamera::CameraSensor::getControls | ( | const std::vector< uint32_t > & | ids | ) |
Read V4L2 controls from the sensor.
[in] | ids | The list of controls to read, specified by their ID |
This method reads the value of all controls contained in ids, and returns their values as a ControlList. The control identifiers are defined by the V4L2 specification (V4L2_CID_*).
If any control in ids is not supported by the device, is disabled (i.e. has the V4L2_CTRL_FLAG_DISABLED flag set), or if any other error occurs during validation of the requested controls, no control is read and this method returns an empty control list.
V4L2SubdeviceFormat libcamera::CameraSensor::getFormat | ( | const std::vector< unsigned int > & | mbusCodes, |
const Size & | size | ||
) | const |
Retrieve the best sensor format for a desired output.
[in] | mbusCodes | The list of acceptable media bus codes |
[in] | size | The desired size |
Media bus codes are selected from mbusCodes, which lists all acceptable codes in decreasing order of preference. Media bus codes supported by the sensor but not listed in mbusCodes are ignored. If none of the desired codes is supported, it returns an error.
size indicates the desired size at the output of the sensor. This method selects the best media bus code and size supported by the sensor according to the following criteria.
When multiple media bus codes can produce the same size, the code at the lowest position in mbusCodes is selected.
The use of this method is optional, as the above criteria may not match the needs of all pipeline handlers. Pipeline handlers may implement custom sensor format selection when needed.
The returned sensor output format is guaranteed to be acceptable by the setFormat() method without any modification.
|
inline |
Retrieve the sensor ID.
The sensor ID is a free-form string that uniquely identifies the sensor in the system. The ID satisfies the requirements to be used as a camera ID.
int libcamera::CameraSensor::init | ( | ) |
Initialize the camera sensor instance.
This method performs the initialisation steps of the CameraSensor that may fail. It shall be called once and only once after constructing the instance.
|
overrideprotectedvirtual |
Retrieve a string to be prefixed to the log message.
This method allows classes inheriting from the Loggable class to extend the logger with an object-specific prefix output right before the log message contents.
Implements libcamera::Loggable.
|
inline |
Retrieve the media bus codes supported by the camera sensor.
|
inline |
Retrieve the sensor model name.
The sensor model name is a free-formed string that uniquely identifies the sensor model.
|
inline |
Retrieve the camera sensor properties.
Size libcamera::CameraSensor::resolution | ( | ) | const |
Retrieve the camera sensor resolution.
The camera sensor resolution is the active pixel area size, clamped to the maximum frame size the sensor can produce if it is smaller than the active pixel area.
int libcamera::CameraSensor::sensorInfo | ( | CameraSensorInfo * | info | ) | const |
Assemble and return the camera sensor info.
[out] | info | The camera sensor info |
This function fills info with information that describes the camera sensor and its current configuration. The information combines static data (such as the the sensor model or active pixel array size) and data specific to the current sensor configuration (such as the line length and pixel rate).
Sensor information is only available for raw sensors. When called for a YUV sensor, this function returns -EINVAL.
int libcamera::CameraSensor::setControls | ( | ControlList * | ctrls | ) |
Write V4L2 controls to the sensor.
[in] | ctrls | The list of controls to write |
This method writes the value of all controls contained in ctrls, and stores the values actually applied to the device in the corresponding ctrls entry. The control identifiers are defined by the V4L2 specification (V4L2_CID_*).
If any control in ctrls is not supported by the device, is disabled (i.e. has the V4L2_CTRL_FLAG_DISABLED flag set), is read-only, or if any other error occurs during validation of the requested controls, no control is written and this method returns -EINVAL.
If an error occurs while writing the controls, the index of the first control that couldn't be written is returned. All controls below that index are written and their values are updated in ctrls, while all other controls are not written and their values are not changed.
-EINVAL | One of the control is not supported or not accessible |
i | The index of the control that failed |
int libcamera::CameraSensor::setFormat | ( | V4L2SubdeviceFormat * | format | ) |
Set the sensor output format.
[in] | format | The desired sensor output format |
|
inline |
Retrieve the frame sizes supported by the camera sensor.
The reported sizes span all media bus codes supported by the camera sensor. Not all sizes may be supported by all media bus codes.