Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rpi/v6.6/streams #200

Open
wants to merge 46 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
50350c5
controls: rpi: Add a vendor rpi::ScalerCrops control
naushir Jul 25, 2024
7b6faf5
pipeline: rpi: Remove CameraData::scalerCrop_
naushir Aug 6, 2024
3fb451a
pipeline: rpi: Pass crop rectangle as a parameter to platformSetIspCr…
naushir Aug 8, 2024
e56433f
pipeline: rpi: Introduce CameraData::CropParams
naushir Aug 6, 2024
8849e49
pipeline: rpi: Track which ISP output is configured for a stream
naushir Aug 2, 2024
be60c00
pipeline: rpi: Pass ISP output index into platformSetIspCrop()
naushir Aug 1, 2024
fb5774c
pipeline: rpi: Handler controls::rpi::ScalerCrops
naushir Aug 2, 2024
2da4fb4
pipeline: rpi: Fix invalid access to CameraData::sensorInfo_
naushir Sep 6, 2024
471c190
pipeline: rpi: Fix for multiple reported scaler crops
naushir Sep 13, 2024
bb52ecb
meson: Add libpisp.wrap
naushir May 4, 2023
c28fca8
pipeline: rpi: Add support for Raspberry Pi 5
naushir Jun 19, 2023
62fb6f5
ipa: rpi: Add support for Raspberry Pi 5
naushir May 4, 2023
f08b6df
RASPBERRYPI ONLY: Add Sony IMX708 sensor properties
njhollinghurst Dec 8, 2022
62b433e
RASPBERRYPI ONLY: Handle mandatory stream flags
naushir May 23, 2023
0c1bf0b
RASPBERRYPI ONLY: Add a Github workflow to generate release tarballs
XECDesign Nov 16, 2023
114c35d
RASPBERRYPI ONLY: Update README to follow Raspberry Pi documentation
mtouzot Mar 30, 2024
4cb83d3
RASPBERRYPI ONLY: libcamera: v4l2_videodevice: Limit number of queued…
naushir Jun 28, 2024
26a20d6
RASPBERRYPI ONLY: Use meson from pip when generating orig tarball
XECDesign Aug 29, 2024
02928ef
ipa: rpi: Use r-value references in the set()/setLocked() functions
naushir Sep 9, 2024
31dc985
ipa: rpi: Add erase()/eraseLocked() to RPiController::Metadata
naushir Sep 9, 2024
e21d0a9
ipa: rpi: Add a HW property to determine if the data buffer is strided
naushir Sep 9, 2024
a401e82
controls: ipa: rpi: Add CNN controls
naushir Sep 9, 2024
dc7c297
ipa: rpi: Handle the new CNN controls in the IPA
naushir Sep 9, 2024
549f80a
ipa: rpi: Provide the camera helper with the hardware configuration
naushir Sep 9, 2024
7330f29
ipa: rpi: Add support for the Sony IMX500 camera sensor
naushir Sep 9, 2024
b76f57c
ipa: rpi: Add imx290.json to meson.build.
6by9 Oct 17, 2024
080547d
include: linux: Update headers for line-based embedded data support
Oct 23, 2024
65621f4
include: linux: videodev2: Add generic line based pixel formats
Oct 23, 2024
54d2df6
include: v4l2-controls: Re-assign V4L2_CID_USER_BCM2835_ISP_BASE
Oct 24, 2024
5a87ec1
libcamera: v4l2_subdevice: Add new metadata formats
pinchartl Feb 26, 2024
8679b2f
libcamera: v4l2_videodevice: Update to the new kernel metadata API
pinchartl Mar 1, 2024
cfcebaa
libcamera: camera_sensor: Introduce CameraSensorFactory
jmondi Dec 17, 2019
f6cc2df
libcamera: camera_sensor: Create abstract base class
pinchartl Feb 4, 2024
eb9a2b3
libcamera: camera_sensor: Sort factories by priority
pinchartl Feb 23, 2024
e01d430
libcamera: Add CameraSensor implementation for raw V4L2 sensors
pinchartl Feb 23, 2024
ab68465
libcamera: camera_sensor: Add support for embedded data
pinchartl Feb 29, 2024
70c86aa
pipeline: raspberrypi: common: Configure sensor embedded data
pinchartl Feb 29, 2024
3a1cd60
pipeline: raspberrypi: vc4: Use operator<<(V4L2VideoFormat)
pinchartl Mar 1, 2024
e19432e
pipeline: raspberrypi: vc4: Reorganize platformConfigure()
pinchartl Feb 29, 2024
6379311
pipeline: raspberrypi: vc4: Use the CameraSensor embedded data API
pinchartl Feb 29, 2024
16b3048
pipeline: raspberrypi: vc4: Unconditionally create embedded data stream
pinchartl Aug 1, 2023
25f6f79
pipeline: raspberrypi: vc4: Configure format on Unicam subdev
pinchartl Aug 1, 2023
376b68a
pipeline: raspberrypi: vc4: Fix configuration of the embedded data node
pinchartl Mar 1, 2024
bae71ce
include: linux: Drop V4L2_META_FMT_SENSOR_DATA
pinchartl Mar 1, 2024
c67f1d1
[HACK]: ipa: rpi: cam_helper_imx219: Enable embedded data
pinchartl Jan 29, 2024
07e84f2
pipeline: rpi: pisp: Add support for streams api
naushir Mar 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/gen_orig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Generate source release tarball
run-name: Generating source release tarball
on:
push:
tags: # vX.Y.Z+rptYYYMMDD
- 'v[0-9]+.[0-9]+.[0-9]+\+rpt[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
workflow_dispatch:
jobs:
publish_tarball:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: | # Local cmake needs to be removed for pybind11 to be detected
sudo rm -rf /usr/local/bin/cmake
pip3 install --user meson
sudo apt-get update
sudo apt-get install -y ninja-build pkgconf cmake libgtest-dev libyaml-dev python3 python3-dev pybind11-dev python3-jinja2 python3-ply python3-yaml
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for 'git describe' to work
- name: Generate tarball
run: |
meson setup build -Dpycamera=enabled
meson dist --no-tests --include-subprojects -C build
mv build/meson-dist/*.tar.xz "build/meson-dist/libcamera-${GITHUB_REF_NAME:1}.tar.xz"
- name: Release tarball
uses: softprops/action-gh-release@v1
with:
files: build/meson-dist/*.tar.xz
- if: failure()
run: cat build/meson-logs/meson-log.txt
2 changes: 2 additions & 0 deletions Documentation/Doxyfile-internal.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ EXCLUDE = @TOP_SRCDIR@/include/libcamera/base/span.h \
@TOP_SRCDIR@/src/libcamera/device_enumerator_udev.cpp \
@TOP_SRCDIR@/src/libcamera/ipc_pipe_unixsocket.cpp \
@TOP_SRCDIR@/src/libcamera/pipeline/ \
@TOP_SRCDIR@/src/libcamera/sensor/camera_sensor_legacy.cpp \
@TOP_SRCDIR@/src/libcamera/sensor/camera_sensor_raw.cpp \
@TOP_SRCDIR@/src/libcamera/tracepoints.cpp \
@TOP_BUILDDIR@/include/libcamera/internal/tracepoints.h \
@TOP_BUILDDIR@/include/libcamera/ipa/soft_ipa_interface.h \
Expand Down
2 changes: 1 addition & 1 deletion Documentation/guides/pipeline-handler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ to the libcamera build options in the top level ``meson_options.txt``.

option('pipelines',
type : 'array',
choices : ['ipu3', 'rkisp1', 'rpi/vc4', 'simple', 'uvcvideo', 'vimc', 'vivid'],
choices : ['ipu3', 'rkisp1', 'rpi/pisp', 'rpi/vc4', 'simple', 'uvcvideo', 'vimc', 'vivid'],
description : 'Select which pipeline handlers to include')


Expand Down
38 changes: 35 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,47 @@ systems, including traditional Linux distributions, ChromeOS and Android.
Getting Started
---------------

To fetch the sources, build and install:
Only build ``libcamera`` from scratch if you need custom behaviour or the latest features that have not yet reached ``apt`` repositories.

If you run ``Raspberry Pi OS Lite``, begin by installing the following packages:

.. code::

git clone https://git.libcamera.org/libcamera/libcamera.git
sudo apt install -y python-pip git python3-jinja2

First, install the following ``libcamera`` dependencies:
.. code::

sudo apt install -y libboost-dev
sudo apt install -y libgnutls28-dev openssl libtiff-dev pybind11-dev
sudo apt install -y qtbase5-dev libqt5core5a libqt5widgets
sudo apt install -y meson cmake
sudo apt install -y python3-yaml python3-ply
sudo apt install -y libglib2.0-dev libgstreamer-plugins-base1.0-dev

Now we're ready to build ``libcamera`` itself.

Download a local copy of Raspberry Pi's fork of ``libcamera`` from GitHub, before building and installing freshly-build binary:

.. code::

git clone https://github.com/raspberrypi/libcamera.git
cd libcamera
meson setup build
meson setup build --buildtype=release -Dpipelines=rpi/vc4,rpi/pisp -Dipas=rpi/vc4,rpi/pisp -Dv4l2=true -Dgstreamer=enabled -Dtest=false -Dlc-compliance=disabled -Dcam=disabled -Dqcam=disabled -Ddocumentation=disabled -Dpycamera=enabled
ninja -C build install

You can disable the ``gstreamer`` plugin by replacing ``-Dgstreamer=enabled`` with ``-Dgstreamer=disabled`` during the ``meson`` build configuration.
If you disable ``gstreamer``, there is no need to install the ``libglib2.0-dev`` and ``libgstreamer-plugins-base1.0-dev`` dependencies.

On devices with 1GB of memory or less, the build may exceed available memory. Append the ``-j 1`` flag to ``ninja`` commands to limit the build to a single process.
This should prevent the build from exceeding available memory on devices like the Raspberry Pi Zero and the Raspberry Pi 3.

``libcamera`` does not yet have a stable binary interface. Always build ``rpicam-apps`` after you build ``libcamera``.

You can find more informations at `Raspberry Pi libcamera documentation`_ pages.

.. _Raspberry Pi libcamera documentation: https://www.raspberrypi.com/documentation/computers/camera_software.html

Dependencies
~~~~~~~~~~~~

Expand Down
151 changes: 77 additions & 74 deletions include/libcamera/internal/camera_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@

#include <memory>
#include <string>
#include <variant>
#include <vector>

#include <libcamera/base/class.h>
#include <libcamera/base/log.h>

#include <libcamera/control_ids.h>
#include <libcamera/controls.h>
#include <libcamera/geometry.h>
#include <libcamera/orientation.h>
#include <libcamera/transform.h>

#include <libcamera/ipa/core_ipa_interface.h>

#include "libcamera/internal/bayer_format.h"
#include "libcamera/internal/v4l2_subdevice.h"

Expand All @@ -31,95 +29,100 @@ class CameraLens;
class MediaEntity;
class SensorConfiguration;

struct CameraSensorProperties;

enum class Orientation;

class CameraSensor : protected Loggable
struct IPACameraSensorInfo;

class CameraSensor
{
public:
explicit CameraSensor(const MediaEntity *entity);
~CameraSensor();
virtual ~CameraSensor();

virtual const std::string &model() const = 0;
virtual const std::string &id() const = 0;

virtual const MediaEntity *entity() const = 0;
virtual V4L2Subdevice *device() = 0;

virtual CameraLens *focusLens() = 0;

int init();
virtual const std::vector<unsigned int> &mbusCodes() const = 0;
virtual std::vector<Size> sizes(unsigned int mbusCode) const = 0;
virtual Size resolution() const = 0;

const std::string &model() const { return model_; }
const std::string &id() const { return id_; }
virtual V4L2SubdeviceFormat
getFormat(const std::vector<unsigned int> &mbusCodes,
const Size &size) const = 0;
virtual int setFormat(V4L2SubdeviceFormat *format,
Transform transform = Transform::Identity) = 0;
virtual int tryFormat(V4L2SubdeviceFormat *format) const = 0;

const MediaEntity *entity() const { return entity_; }
V4L2Subdevice *device() { return subdev_.get(); }
virtual int applyConfiguration(const SensorConfiguration &config,
Transform transform = Transform::Identity,
V4L2SubdeviceFormat *sensorFormat = nullptr) = 0;

CameraLens *focusLens() { return focusLens_.get(); }
virtual V4L2Subdevice::Stream imageStream() const;
virtual std::optional<V4L2Subdevice::Stream> embeddedDataStream() const;
virtual V4L2SubdeviceFormat embeddedDataFormat() const;
virtual int setEmbeddedDataEnabled(bool enable);

const std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }
std::vector<Size> sizes(unsigned int mbusCode) const;
Size resolution() const;
virtual const ControlList &properties() const = 0;
virtual int sensorInfo(IPACameraSensorInfo *info) const = 0;
virtual Transform computeTransform(Orientation *orientation) const = 0;
virtual BayerFormat::Order bayerOrder(Transform t) const = 0;

V4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,
const Size &size) const;
int setFormat(V4L2SubdeviceFormat *format,
Transform transform = Transform::Identity);
int tryFormat(V4L2SubdeviceFormat *format) const;
virtual const ControlInfoMap &controls() const = 0;
virtual ControlList getControls(const std::vector<uint32_t> &ids) = 0;
virtual int setControls(ControlList *ctrls) = 0;

int applyConfiguration(const SensorConfiguration &config,
Transform transform = Transform::Identity,
V4L2SubdeviceFormat *sensorFormat = nullptr);
virtual const std::vector<controls::draft::TestPatternModeEnum> &
testPatternModes() const = 0;
virtual int setTestPatternMode(controls::draft::TestPatternModeEnum mode) = 0;
};

class CameraSensorFactoryBase
{
public:
CameraSensorFactoryBase(const char *name, int priority);
virtual ~CameraSensorFactoryBase() = default;

static std::unique_ptr<CameraSensor> create(MediaEntity *entity);

const ControlList &properties() const { return properties_; }
int sensorInfo(IPACameraSensorInfo *info) const;
Transform computeTransform(Orientation *orientation) const;
BayerFormat::Order bayerOrder(Transform t) const;
const std::string &name() const { return name_; }
int priority() const { return priority_; }

const ControlInfoMap &controls() const;
ControlList getControls(const std::vector<uint32_t> &ids);
int setControls(ControlList *ctrls);
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraSensorFactoryBase)

const std::vector<controls::draft::TestPatternModeEnum> &testPatternModes() const
static std::vector<CameraSensorFactoryBase *> &factories();

static void registerFactory(CameraSensorFactoryBase *factory);

virtual std::variant<std::unique_ptr<CameraSensor>, int>
match(MediaEntity *entity) const = 0;

std::string name_;
int priority_;
};

template<typename _CameraSensor>
class CameraSensorFactory final : public CameraSensorFactoryBase
{
public:
CameraSensorFactory(const char *name, int priority)
: CameraSensorFactoryBase(name, priority)
{
return testPatternModes_;
}
int setTestPatternMode(controls::draft::TestPatternModeEnum mode);

protected:
std::string logPrefix() const override;

private:
LIBCAMERA_DISABLE_COPY(CameraSensor)

int generateId();
int validateSensorDriver();
void initVimcDefaultProperties();
void initStaticProperties();
void initTestPatternModes();
int initProperties();
int discoverAncillaryDevices();
int applyTestPatternMode(controls::draft::TestPatternModeEnum mode);

const MediaEntity *entity_;
std::unique_ptr<V4L2Subdevice> subdev_;
unsigned int pad_;

const CameraSensorProperties *staticProps_;

std::string model_;
std::string id_;

V4L2Subdevice::Formats formats_;
std::vector<unsigned int> mbusCodes_;
std::vector<Size> sizes_;
std::vector<controls::draft::TestPatternModeEnum> testPatternModes_;
controls::draft::TestPatternModeEnum testPatternMode_;

Size pixelArraySize_;
Rectangle activeArea_;
const BayerFormat *bayerFormat_;
bool supportFlips_;
bool flipsAlterBayerOrder_;
Orientation mountingOrientation_;

ControlList properties_;

std::unique_ptr<CameraLens> focusLens_;
std::variant<std::unique_ptr<CameraSensor>, int>
match(MediaEntity *entity) const override
{
return _CameraSensor::match(entity);
}
};

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

} /* namespace libcamera */
2 changes: 2 additions & 0 deletions include/libcamera/internal/v4l2_pixelformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class V4L2PixelFormat
static const std::vector<V4L2PixelFormat> &
fromPixelFormat(const PixelFormat &pixelFormat);

bool isGenericLineBasedMetadata() const;

private:
uint32_t fourcc_;
};
Expand Down
4 changes: 4 additions & 0 deletions include/libcamera/internal/v4l2_videodevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <memory>
#include <optional>
#include <ostream>
#include <queue>
#include <stdint.h>
#include <string>
#include <unordered_set>
Expand Down Expand Up @@ -266,6 +267,8 @@ class V4L2VideoDevice : public V4L2Device
void bufferAvailable();
FrameBuffer *dequeueBuffer();

int queueToDevice(FrameBuffer *buffer);

void watchdogExpired();

template<typename T>
Expand All @@ -281,6 +284,7 @@ class V4L2VideoDevice : public V4L2Device

V4L2BufferCache *cache_;
std::map<unsigned int, FrameBuffer *> queuedBuffers_;
std::queue<FrameBuffer *> pendingBuffersToQueue_;

EventNotifier *fdBufferNotifier_;

Expand Down
1 change: 1 addition & 0 deletions include/libcamera/ipa/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ libcamera_ipa_headers += custom_target('core_ipa_serializer_h',
pipeline_ipa_mojom_mapping = {
'ipu3': 'ipu3.mojom',
'rkisp1': 'rkisp1.mojom',
'rpi/pisp': 'raspberrypi.mojom',
'rpi/vc4': 'raspberrypi.mojom',
'simple': 'soft.mojom',
'vimc': 'vimc.mojom',
Expand Down
1 change: 1 addition & 0 deletions include/libcamera/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ controls_map = {
'controls': {
'draft': 'control_ids_draft.yaml',
'core': 'control_ids_core.yaml',
'rpi/pisp': 'control_ids_rpi.yaml',
'rpi/vc4': 'control_ids_rpi.yaml',
},

Expand Down
2 changes: 1 addition & 1 deletion include/linux/README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: CC0-1.0

Files in this directory are imported from next-media-rkisp1-20240814-14-ga043ea54bbb9 of the Linux kernel. Do not
Files in this directory are imported from v6.12-rc1-56-g8d8fdc8a8809 of the Linux kernel. Do not
modify them manually.
4 changes: 4 additions & 0 deletions include/linux/media-bus-format.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,8 @@
#define MEDIA_BUS_FMT_META_20 0x8006
#define MEDIA_BUS_FMT_META_24 0x8007

/* Specific metadata formats. Next is 0x9003. */
#define MEDIA_BUS_FMT_CCS_EMBEDDED 0x9001
#define MEDIA_BUS_FMT_OV2740_EMBEDDED 0x9002

#endif /* __LINUX_MEDIA_BUS_FORMAT_H */
1 change: 1 addition & 0 deletions include/linux/media.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ struct media_entity_desc {
#define MEDIA_PAD_FL_SINK (1U << 0)
#define MEDIA_PAD_FL_SOURCE (1U << 1)
#define MEDIA_PAD_FL_MUST_CONNECT (1U << 2)
#define MEDIA_PAD_FL_INTERNAL (1U << 3)

struct media_pad_desc {
__u32 entity; /* entity ID */
Expand Down
2 changes: 1 addition & 1 deletion include/linux/v4l2-controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ enum v4l2_colorfx {

/* The base for the bcm2835-isp driver controls.
* We reserve 16 controls for this driver. */
#define V4L2_CID_USER_BCM2835_ISP_BASE (V4L2_CID_USER_BASE + 0x10e0)
#define V4L2_CID_USER_BCM2835_ISP_BASE (V4L2_CID_USER_BASE + 0x11d0)
/*
* The base for Allegro driver controls.
* We reserve 16 controls for this driver.
Expand Down
5 changes: 5 additions & 0 deletions include/linux/v4l2-subdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ struct v4l2_subdev_capability {
* on a video node.
*/
#define V4L2_SUBDEV_ROUTE_FL_ACTIVE (1U << 0)
/*
* Is the route immutable? The ACTIVE flag of an immutable route may not be
* unset.
*/
#define V4L2_SUBDEV_ROUTE_FL_IMMUTABLE (1U << 1)

/**
* struct v4l2_subdev_route - A route inside a subdev
Expand Down
Loading