libcamera::V4L2Subdevice Class Reference

A V4L2 subdevice as exposed by the Linux kernel. More...

Inheritance diagram for libcamera::V4L2Subdevice:

## Public Types

enum | Whence { ActiveFormat , TryFormat }
| Specify the type of format for getFormat() and setFormat() operations. More...

## Public Member Functions

| V4L2Subdevice (const MediaEntity *entity)
| Create a V4L2 subdevice from a MediaEntity using its device node path.
| V4L2Subdevice (const V4L2Subdevice &)=delete
V4L2Subdevice & | operator= (const V4L2Subdevice &)=delete
int | open ()
| Open a V4L2 subdevice. More...
const MediaEntity * | entity () const
| Retrieve the media entity associated with the subdevice. More...
int | getSelection (unsigned int pad, unsigned int target, Rectangle *rect)
| Get selection rectangle rect for target. More...
int | setSelection (unsigned int pad, unsigned int target, Rectangle *rect)
| Set selection rectangle rect for target. More...
ImageFormats | formats (unsigned int pad)
| Enumerate all media bus codes and frame sizes on a pad. More...
int | getFormat (unsigned int pad, V4L2SubdeviceFormat *format, Whence whence=ActiveFormat)
| Retrieve the image format set on one of the V4L2 subdevice pads. More...
int | setFormat (unsigned int pad, V4L2SubdeviceFormat *format, Whence whence=ActiveFormat)
| Set an image format on one of the V4L2 subdevice pads. More...
Public Member Functions inherited from libcamera::V4L2Device
void | close ()
| Close the device node. More...
bool | isOpen () const
| Check if the V4L2 device node is open. More...
const ControlInfoMap & | controls () const
| Retrieve the supported V4L2 controls and their information. More...
ControlList | getControls (const std::vector< uint32_t > &ids)
| Read controls from the device. More...
int | setControls (ControlList *ctrls)
| Write controls to the device. More...
const std::string & | deviceNode () const
| Retrieve the device node path. More...

## Static Public Member Functions

static V4L2Subdevice * | fromEntityName (const MediaDevice *media, const std::string &entity)
| Create a new video subdevice instance from entity in media device media. More...

## Protected Member Functions

std::string | logPrefix () const override
| Retrieve a string to be prefixed to the log message. More...
Protected Member Functions inherited from libcamera::V4L2Device
| V4L2Device (const std::string &deviceNode)
| Construct a V4L2Device. More...
| ~V4L2Device ()
| Destroy a V4L2Device.
int | open (unsigned int flags)
| Open a V4L2 device node. More...
int | setFd (int fd)
| Set the file descriptor of a V4L2 device. More...
int | ioctl (unsigned long request, void *argp)
| Perform an IOCTL system call on the device node. More...
int | fd ()
| Retrieve the V4L2 device file descriptor. More...
Protected Member Functions inherited from libcamera::Loggable
LogMessage | _log (const char *file, unsigned int line, LogSeverity severity) const
| Create a temporary LogMessage object to log a message. More...
LogMessage | _log (const char *file, unsigned int line, const LogCategory &category, LogSeverity severity) const
| Create a temporary LogMessage object to log a message. More...

## Detailed Description

A V4L2 subdevice as exposed by the Linux kernel.

The V4L2Subdevice class provides an API to the "Sub-device interface" as described in section 4.15 of the "Linux Media Infrastructure userspace API" chapter of the Linux Kernel documentation.

A V4L2Subdevice is constructed from a MediaEntity instance, using the system path of the entity's device node. No API call other than open(), isOpen() and close() shall be called on an unopened device instance. Upon destruction any device left open will be closed, and any resources released.

## Member Enumeration Documentation

## Whence

enum libcamera::V4L2Subdevice::Whence

Specify the type of format for getFormat() and setFormat() operations.

Enumerator
ActiveFormat | The format operation applies to ACTIVE formats.
TryFormat | The format operation applies to TRY formats.

## Member Function Documentation

## entity()

libcamera::V4L2Subdevice::entity | ( |  | ) | const

inline

Retrieve the media entity associated with the subdevice.

Returns
  The subdevice's associated media entity.

## formats()

ImageFormats libcamera::V4L2Subdevice::formats | ( | unsigned int | pad | ) |

Enumerate all media bus codes and frame sizes on a pad.

Parameters

  [in] | pad | The 0-indexed pad number to enumerate formats on

Enumerate all media bus codes and frame sizes supported by the subdevice on a pad.

Returns
  A list of the supported device formats

## fromEntityName()

V4L2Subdevice * libcamera::V4L2Subdevice::fromEntityName | ( | const MediaDevice * | media,
|  | const std::string & | entity
| ) |  |

static

Create a new video subdevice instance from entity in media device media.

Parameters

  [in] | media | The media device where the entity is registered
  [in] | entity | The media entity name

Releasing memory of the newly created instance is responsibility of the caller of this function.

Returns
  A newly created V4L2Subdevice on success, nullptr otherwise

## getFormat()

int libcamera::V4L2Subdevice::getFormat | ( | unsigned int | pad,
|  | V4L2SubdeviceFormat * | format,
|  | Whence | whence = `ActiveFormat`
| ) |  |

Retrieve the image format set on one of the V4L2 subdevice pads.

Parameters

  [in] | pad | The 0-indexed pad number the format is to be retrieved from
  [out] | format | The image bus format
  [in] | whence | The format to get, ActiveFormat or TryFormat

Returns
  0 on success or a negative error code otherwise

## getSelection()

int libcamera::V4L2Subdevice::getSelection | ( | unsigned int | pad,
|  | unsigned int | target,
|  | Rectangle * | rect
| ) |  |

Get selection rectangle rect for target.

Parameters

  [in] | pad | The 0-indexed pad number the rectangle is retrieved from
  [in] | target | The selection target defined by the V4L2_SEL_TGT_* flags
  [out] | rect | The retrieved selection rectangle

Todo:
  Define a V4L2SelectionTarget enum for the selection target

Returns
  0 on success or a negative error code otherwise

## logPrefix()

std::string libcamera::V4L2Subdevice::logPrefix | ( |  | ) | const

override protected virtual

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.

Returns
  A string to be prefixed to the log message

Implements libcamera::Loggable.

## open()

int libcamera::V4L2Subdevice::open | ( |  | ) |

Open a V4L2 subdevice.

Returns
  0 on success or a negative error code otherwise

## setFormat()

int libcamera::V4L2Subdevice::setFormat | ( | unsigned int | pad,
|  | V4L2SubdeviceFormat * | format,
|  | Whence | whence = `ActiveFormat`
| ) |  |

Set an image format on one of the V4L2 subdevice pads.

Parameters

  [in] | pad | The 0-indexed pad number the format is to be applied to
  [in,out] | format | The image bus format to apply to the subdevice's pad
  [in] | whence | The format to set, ActiveFormat or TryFormat

Apply the requested image format to the desired media pad and return the actually applied format parameters, as getFormat() would do.

Returns
  0 on success or a negative error code otherwise

## setSelection()

int libcamera::V4L2Subdevice::setSelection | ( | unsigned int | pad,
|  | unsigned int | target,
|  | Rectangle * | rect
| ) |  |

Set selection rectangle rect for target.

Parameters

  [in] | pad | The 0-indexed pad number the rectangle is to be applied to
  [in] | target | The selection target defined by the V4L2_SEL_TGT_* flags
  [in,out] | rect | The selection rectangle to be applied

Todo:
  Define a V4L2SelectionTarget enum for the selection target

Returns
  0 on success or a negative error code otherwise

The documentation for this class was generated from the following files:

- include/libcamera/internal/v4l2_subdevice.h
- src/libcamera/v4l2_subdevice.cpp