libcamera v0.7.2 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
libcamera::MappedBuffer Class Reference

Provide an interface to support managing memory mapped buffers. More...

Inheritance diagram for libcamera::MappedBuffer:
[legend]

## Public Types
using | Plane = Span<uint8_t>
| A mapped region of memory accessible to the CPU.

## Public Member Functions
| MappedBuffer (MappedBuffer &&other)
| Move constructor, construct the MappedBuffer with the contents of other using move semantics.
MappedBuffer & | operator= (MappedBuffer &&other)
| Move assignment operator, replace the mappings with those of other.
bool | isValid () const
| Check if the MappedBuffer instance is valid.
int | error () const
| Retrieve the map error status.
const std::vector< Plane > & | planes () const
| Retrieve the mapped planes.

## Protected Member Functions
| MappedBuffer ()
| Construct an empty MappedBuffer.

## Protected Attributes
int | error_
| Stores the error value if present.
std::vector< Plane > | planes_
| Stores the internal mapped planes.
std::vector< Plane > | maps_
| Stores the mapped buffer.

## Detailed Description

Provide an interface to support managing memory mapped buffers.

The MappedBuffer interface provides access to a set of MappedPlanes which are available for access by the CPU.

This class is not meant to be constructed directly, but instead derived classes should be used to implement the correct mapping of a source buffer.

This allows treating CPU accessible memory through a generic interface regardless of whether it originates from a libcamera FrameBuffer or other source.

## Member Typedef Documentation

## ◆ Plane

using libcamera::MappedBuffer::Plane = Span<uint8_t>

A mapped region of memory accessible to the CPU.

The MappedBuffer::Plane uses the Span interface to describe the mapped memory region.

## Constructor & Destructor Documentation

## ◆ MappedBuffer()

libcamera::MappedBuffer::MappedBuffer | ( | MappedBuffer && | other | ) |

Move constructor, construct the MappedBuffer with the contents of other using move semantics.

Parameters

  [in] | other | The other MappedBuffer

Moving a MappedBuffer moves the mappings contained in the other to the new MappedBuffer and invalidates the other.

No mappings are unmapped or destroyed in this process.

## Member Function Documentation

## ◆ error()

int libcamera::MappedBuffer::error | ( |  | ) | const
| inline

Retrieve the map error status.

This function retrieves the error status from the MappedBuffer. The error status is a negative number as defined by errno.h. If no error occurred, this function returns 0.

Returns
  The map error code

## ◆ isValid()

bool libcamera::MappedBuffer::isValid | ( |  | ) | const
| inline

Check if the MappedBuffer instance is valid.

Returns
  True if the MappedBuffer has valid mappings, false otherwise

## ◆ operator=()

MappedBuffer & libcamera::MappedBuffer::operator= | ( | MappedBuffer && | other | ) |

Move assignment operator, replace the mappings with those of other.

Parameters

  [in] | other | The other MappedBuffer

Moving a MappedBuffer moves the mappings contained in the other to the new MappedBuffer and invalidates the other.

No mappings are unmapped or destroyed in this process.

## ◆ planes()

const std::vector< Plane > & libcamera::MappedBuffer::planes | ( |  | ) | const
| inline

Retrieve the mapped planes.

This function retrieves the successfully mapped planes stored as a vector of Span<uint8_t> to provide access to the mapped memory.

Returns
  A vector of the mapped planes

## Member Data Documentation

## ◆ error_

int libcamera::MappedBuffer::error_
| protected

Stores the error value if present.

MappedBuffer derived classes shall set this to a negative value as defined by errno.h if an error occured during the mapping process.

## ◆ maps_

std::vector<Plane> libcamera::MappedBuffer::maps_
| protected

Stores the mapped buffer.

MappedBuffer derived classes shall store the mappings they create in this vector which is parsed during destruct to unmap any memory mappings which completed successfully.

## ◆ planes_

std::vector<Plane> libcamera::MappedBuffer::planes_
| protected

Stores the internal mapped planes.

MappedBuffer derived classes shall store the mappings they create in this vector which points the beginning of mapped plane addresses.

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

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