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

Add support files for OV7251 #191

Open
wants to merge 27 commits into
base: next
Choose a base branch
from
Open

Add support files for OV7251 #191

wants to merge 27 commits into from

Conversation

6by9
Copy link
Collaborator

@6by9 6by9 commented Oct 10, 2024

No description provided.

naushir and others added 27 commits September 25, 2024 15:35
Add a vendor control rpi::ScalerCrops that is analogous to the current
core::ScalerCrop, but can apply a different crop to each configured
stream.

This control takes a span of Rectangle structures - the order of
rectangles must match the order of streams configured by the application.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Do not cache the scalerCrop_ parameter. The cached value is used to
update the request metadata, but since this is not an expensive
operation (and can only occur once per frame), caching it is of limited
value.

This will simplify logic in a future commit where we can specify a
crop per-output stream.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
…op()

This will be required when we program separate crop values to each ISP
output in a future commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
In preparation for assigning separate crop windows for each stream, add
a new CropParams structure that stores the existing ispCrop_ and
ispMinCropSize_ as fields. Use a new std::map to store a CropParams
structure where the map key is the index of the stream configuration in
the CameraConfiguration vector.

At preset, only a single CropParams structure will be set at key == 0 to
preserve the existing crop handling logic.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Add a ispIndex field to CropParams that is used to track
which ISP output (0/1) will be used for a given stream during
configuration.

Tracking this information is required for an upcoming change where crop
rectangles can be specified for each configured stream. Currently, the
value is fixed to 0.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
At this point, the index is unused, but will be in a future commit where
we can set different crops on each ISP output.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Handle multiple scaler crops being set through the rpi::ScalerCrops
control. We now populate the cropParams_ map in the loop where we handle
the output stream configuration items. The key of this map is the index
of the stream configuration structure set by the application. This will
also be the same index used to specify the crop rectangles through the
ScalerCrops control.

CameraData::applyScalerCrop() has been adapted to look at either
controls::ScalerCrop or controls::rpi::ScalerCrops. The former takes
priority over the latter, and if present, will apply the same scaler
crop to all output streams.

Finally return all crops through the same ScalerCrops control via
request metadata. The first configure stream's crop rectangle is also
returned via the ScalerCrop control in the request metadata.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
sensorInfo_ currently gets populated in configureIPA(), but is possibly
referenced in platformConfigure() which is called first. Fix this by
populating sensorInfo_ straight after configuring the sensor in
configure(), ensuring the fields are valid in the call to
platformConfigure().

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Ensure we index the CameraConfiguration incrementally when setting up
the raw and output streams.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Add a new subpoject wrap file for the libpisp library located at
https://github.com/raspberrypi/libpisp

The libpisp library is used to configure the Raspberry Pi 5 Frontend
and Backend ISP components.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Add the Raspberry Pi 5 ISP (PiSP) pipeline handler to libcamera. To
include this pipeline handler in the build, set the following meson
option:

meson configure -Dpipelines=rpi/pisp

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Add the Raspberry Pi 5 ISP (PiSP) IPA to libcamera. To include this IPA
in the build, set the following meson option:

meson configure -Dipas=rpi/pisp

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
The IMX708 sensor driver advertises its module variants (narrow/wide angle lens,
IR block/pass) by modifying the media entity name string. So add duplicate
entries for each variant.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Look for the RAW mandatory stream flag in the pipeline handler config
file. If this flag is set, it guarantees that the application will
provide buffers for Unicam Image, so override the minUnicamBuffers and
minTotalUnicamBuffers config parameters in the following way:

- If startup drop frames are required, allocate at least 1 internal buffer.
- If no startup drop frames are required, do not allocate any internal buffers.

Look for the Output 0 mandatory stream flag in in the pipeline handler
config file. If this flag is set, it guarantees that the application
will provide buffers for the ISP, do not allocate any internal buffers
for the device.

Add a new rpi_apps.yaml pipeline handler config file that enables both
these flags.  To use the file, set the following env variable for a
custom build:

export LIBCAMERA_RPI_CONFIG_FILE=/usr/local/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml

or for a packaged install:

export LIBCAMERA_RPI_CONFIG_FILE=/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
… buffers

V4L2 only allows upto VIDEO_MAX_FRAME frames to be queued at a time, so
if we reach this limit, store the framebuffers in a pending queue, and
try to enqueue once a buffer has been dequeued.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Use an r-value reference in set() and setLocked(), allowing more
efficient metadata handling with std::forward and std::move if needed.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
These function erases a key/value pair from the metadata object.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
This property (cfeDataBufferStrided) indicates if the CSI-2 hardware
writes to the embedded/metadata buffer directly, or if it treats the
buffer like an image buffer and strides the metadata lines.

Unicam write this buffer strided, while the PiSP Frontend writes to it
directly. This information will be relevant to data parsers in the
helpers where the data is structured in lines.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Add the follwing RPi vendor controls to handle Convolutional Neural
Network processing:

CnnOutputTensor
CnnOutputTensorInfo
CnnEnableInputTensor
CnnInputTensor
CnnInputTensorInfo
CnnKpiInfo

These controls will be used to support the new Raspberry Pi AI Camera,
using an IMX500 sensor with on-board neural network processing.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Add code to handle the new CNN vendor controls in the Raspberry Pi IPA.

The value of CnnInputTensorInfo is cached as it is the only stateful
input control.

All other controls are output controls, and the values are copied into
directly from the rpiMetadata object if present. The camera helpers
populate the rpiMetadata object if the sensor supports on-board CNN
processing, such as the IMX500.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Add a CamHelper::setHwConfig() helper used by the IPA to set the
hardware configuartion in use by the pipeline. This will be needed by
the IMX500 camera helper in a future commit to determine if the
metadata buffer is strided.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Add a Sony IMX500 camera helper to the IPA. This also includes support
for the on-chip CNN hardware accelerator and parsing of the neural
network data stream returned in the metadata buffer.

Add tuning files for both VC4 and PiSP platforms.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
OV7251 is a mono VGA global shutter sensor that has a mainline
driver and works with libcamera.
Add the supporting files for it. The tuning is copied from OV9281.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Can't squash these into the one commit as pisp isn't upstream yet.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
@6by9 6by9 mentioned this pull request Oct 10, 2024
@6by9 6by9 requested a review from naushir October 17, 2024 10:56
@6by9
Copy link
Collaborator Author

6by9 commented Oct 17, 2024

Kieran sent the vc4 and cam_helper upstream - any chance of a review there? https://lists.libcamera.org/pipermail/libcamera-devel/2024-October/045749.html

@szym1998
Copy link

Should I already see it in next or am I getting something wrong?

@naushir
Copy link
Collaborator

naushir commented Oct 22, 2024

It will come to next/main when I rebase from upstream libcamera in a few days (hopefully).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants