libcamera v0.1.0+127-8e215127-dirty (2023-12-02T01:06:12+00:00)
Supporting cameras in Linux since 2019
mapped_framebuffer.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2021, Google Inc.
4 *
5 * mapped_framebuffer.h - Frame buffer memory mapping support
6 */
7
8#pragma once
9
10#include <stdint.h>
11#include <vector>
12
15#include <libcamera/base/span.h>
16
18
19namespace libcamera {
20
22{
23public:
24 using Plane = Span<uint8_t>;
25
27
30
31 bool isValid() const { return error_ == 0; }
32 int error() const { return error_; }
33 const std::vector<Plane> &planes() const { return planes_; }
34
35protected:
37
38 int error_;
39 std::vector<Plane> planes_;
40 std::vector<Plane> maps_;
41
42private:
44};
45
47{
48public:
49 enum class MapFlag {
50 Read = 1 << 0,
51 Write = 1 << 1,
53 };
54
56
57 MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags);
58};
59
61
62} /* namespace libcamera */
Utilities to help constructing class interfaces.
#define LIBCAMERA_DISABLE_COPY(klass)
Disable copy construction and assignment of the klass.
Type-safe container for enum-based bitfields.
Definition: flags.h:16
Frame buffer data and its associated dynamic metadata.
Definition: framebuffer.h:50
Provide an interface to support managing memory mapped buffers.
Definition: mapped_framebuffer.h:22
MappedBuffer()
Construct an empty MappedBuffer.
Definition: mapped_framebuffer.cpp:53
const std::vector< Plane > & planes() const
Retrieve the mapped planes.
Definition: mapped_framebuffer.h:33
std::vector< Plane > maps_
Stores the mapped buffer.
Definition: mapped_framebuffer.h:40
Span< uint8_t > Plane
A mapped region of memory accessible to the CPU.
Definition: mapped_framebuffer.h:24
int error() const
Retrieve the map error status.
Definition: mapped_framebuffer.h:32
MappedBuffer & operator=(MappedBuffer &&other)
Move assignment operator, replace the mappings with those of other.
Definition: mapped_framebuffer.cpp:82
int error_
Stores the error value if present.
Definition: mapped_framebuffer.h:38
bool isValid() const
Check if the MappedBuffer instance is valid.
Definition: mapped_framebuffer.h:31
std::vector< Plane > planes_
Stores the internal mapped planes.
Definition: mapped_framebuffer.h:39
Map a FrameBuffer using the MappedBuffer interface.
Definition: mapped_framebuffer.h:47
MapFlag
Specify the mapping mode for the FrameBuffer.
Definition: mapped_framebuffer.h:49
@ Write
Create a write-only mapping.
@ ReadWrite
Create a mapping that can be both read and written.
@ Read
Create a read-only mapping.
MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags)
Map all planes of a FrameBuffer.
Definition: mapped_framebuffer.cpp:180
Enum-based bit fields.
#define LIBCAMERA_FLAGS_ENABLE_OPERATORS(_enum)
Enable bitwise operations on the enum enumeration.
Frame buffer handling.
Top-level libcamera namespace.
Definition: backtrace.h:17