Age | Commit message (Collapse) | Author |
|
The validate function overwrites the generated StreamConfiguration with
the one reported by the CIO2 unit when inspecting the RAW stream
configuration.
As we prepare to add StreamFormats to the IPU3 StreamConfiguration,
assigning to the CIO2 generated configuration would delete the
StreamFormats.
Fix this by updating relevant fields only in order to keep the
assigned StreamFormats.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Add two methods to the CIO2Device class to retrieve all the supported
PixelFormats and sizes.
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Inspect the return status of validate() in the IPU3 pipeline handler
generateConfigurtion() implementation. If the generated configuration is
not valid, return a an empty configuration to the application.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Remove stream assignment from the IPU3 pipeline handler
generateConfiguration() implementation.
The function aims to provide a suitable default for the requested use
cases. Defer stream assignment to validation and only initialize sizes
and formats.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
It's common for code to check if a rectangle is null. Add a helper function
to do so and test the function in test/geometry.cpp
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
Add to libcamera utils library two functions to round up or down a
value to an alignment and add a test in test/utils.cpp for the two
new functions.
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The mbusCodesToInfo map actually maps media bus codes to PixelFormat
instances. Rename the map according to its actual function and while at
it drop the 'static' keyword as the map is already defined in an
anonymous namespace.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The monitor_ and notifier_ pointers are acted on in the destructor if
not set to nullptr, the pointers are however first initialized in
init() and enumerate(). Avoid acting on uninitialized pointers by
initializing them to nullptr in the constructor.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
|
|
Object::deleteLater() ensures that the deletion of the Object
takes place in a thread it is bound to. Deleting the Object
in a different thread is a violation according to the libcamera
threading model.
On hot-unplug of a currently streaming camera, the last reference
of Camera when dropped from the application /* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* libcamera V4L2 M2M video device tests
*/
#include <iostream>
#include <libcamera/framebuffer.h>
#include <libcamera/base/event_dispatcher.h>
#include <libcamera/base/thread.h>
#include <libcamera/base/timer.h>
#include "libcamera/internal/device_enumerator.h"
#include "libcamera/internal/media_device.h"
#include "libcamera/internal/v4l2_videodevice.h"
#include "test.h"
using namespace std;
using namespace libcamera;
class V4L2M2MDeviceTest : public Test
{
public:
V4L2M2MDeviceTest()
: vim2m_(nullptr), outputFrames_(0), captureFrames_(0)
{
}
void outputBufferComplete(FrameBuffer *buffer)
{
cout << "Received output buffer" << endl;
outputFrames_++;
/* Requeue the buffer for further use. */
vim2m_->output()->queueBuffer(buffer);
}
void receiveCaptureBuffer(FrameBuffer *buffer)
{
cout << "Received capture buffer" << endl;
captureFrames_++;
/* Requeue the buffer for further use. */
vim2m_->capture()->queueBuffer(buffer);
}
protected:
int init()
{
enumerator_ = DeviceEnumerator::create();
if (!enumerator_) {
cerr << "Failed to create device enumerator" << endl;
return TestFail;
}
if (enumerator_->enumerate()) {
cerr << "Failed to enumerate media devices" << endl;
return TestFail;
}
DeviceMatch dm("vim2m");
dm.add("vim2m-source");
dm.add("vim2m-sink");
media_ = enumerator_->search(dm);
if (!media_) {
cerr << "No vim2m device found" << endl;
return TestSkip;
}
return TestPass;
}
int run()
{
constexpr unsigned int bufferCount = 4;
EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
int ret;
MediaEntity *entity = media_->getEntityByName("vim2m-source");
vim2m_ = new V4L2M2MDevice(entity->deviceNode());
if (vim2m_->open()) {
cerr << "Failed to open VIM2M device" << endl;
return TestFail;
}
V4L2VideoDevice *capture = vim2m_->capture();
V4L2VideoDevice *output = vim2m_->output();
V4L2DeviceFormat format = {};
if (capture->getFormat(&format)) {
cerr << "Failed to get capture format" << endl;
return TestFail;
}
format.size.width = 640;
format.size.height = 480;
if (capture->setFormat(&format)) {
cerr << "Failed to set capture format" << endl;
return TestFail;
}
if (output->setFormat(&format)) {
cerr << "Failed to set output format" << endl;
return TestFail;
}
ret = capture->allocateBuffers(bufferCount, &captureBuffers_);
if (ret < 0) {
cerr << "Failed to allocate Capture Buffers" << endl;
return TestFail;
}
ret = output->allocateBuffers(bufferCount, &outputBuffers_);
if (ret < 0) {
cerr << "Failed to allocate Output Buffers" << endl;
return TestFail;
}
capture->bufferReady.connect(this, &V4L2M2MDeviceTest::receiveCaptureBuffer);
output->bufferReady.connect(this, &V4L2M2MDeviceTest::outputBufferComplete);
for (const std::unique_ptr<FrameBuffer> &buffer : captureBuffers_) {
if (capture->queueBuffer(buffer.get())) {
std::cout << "Failed to queue capture buffer" << std::endl;
return TestFail;
}
}
for (const std::unique_ptr<FrameBuffer> &buffer : outputBuffers_) {
if (output->queueBuffer(buffer.get())) {
std::cout << "Failed to queue output buffer" << std::endl;
return TestFail;
}
}
ret = capture->streamOn();
if (ret) {
cerr << "Failed to streamOn capture" << endl;
return TestFail;
}
ret = output->streamOn();
if (ret) {
cerr << "Failed to streamOn output" << endl;
return TestFail;
}
Timer timeout;
timeout.start(5000);
while (timeout.isRunning()) {
dispatcher->processEvents();
if (captureFrames_ > 30)
break;
}
cerr << "Output " << outputFrames_ << " frames" << std::endl;
cerr << "Captured " << captureFrames_ << " frames" << std::endl;
if (captureFrames_ < 30) {
cerr << "Failed to capture 30 frames within timeout." << std::endl;
return TestFail;
}
ret = capture->streamOff();
if (ret) {
cerr << "Failed to StreamOff the capture device." << std::endl;
return TestFail;
}
ret = output->streamOff();
if (ret) {
cerr << "Failed to StreamOff the output device." << std::endl;
return TestFail;
}
return TestPass;
}
void cleanup()
{
delete vim2m_;
}
private:
std::unique_ptr<DeviceEnumerator> enumerator_;
std::shared_ptr<MediaDevice> media_;
V4L2M2MDevice *vim2m_;
std::vector<std::unique_ptr<FrameBuffer>> captureBuffers_;
std::vector<std::unique_ptr<FrameBuffer>> outputBuffers_;
unsigned int outputFrames_;
unsigned int captureFrames_;
};
TEST_REGISTER(V4L2M2MDeviceTest)
rt@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Replace the V4L2Subdevice usage of the ImageFormats class with a
std::map and the utils::map_keys() helper.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Add support for RGB565 format.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Add support for planar YVU420.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Remove use of vcsm allocations and replace with dma heap allocations.
The pipeline handler now passes the fd of the allocation over to the IPA
instead of the raw pointer.
Also use libcamera::FileDescriptor for fd lifetime management.
This commit must be built alongside the accompanying BCM2835 ISP kernel
driver changes at https://github.com/raspberrypi/linux/pull/3715.
Otherwise a mismatch will cause undefined behavior.
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
To make error handling easier in callers, allow the stop() function to
be called when the proxy is already stopped, or not started yet.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The IPA is meant to be started when starting the camera, and stopped
when stopping it. It was so far started early in order to handle the
IPAInterface::processEvent() call related to lens shading table
allocation before IPAInterface::configure() to pass the table to the
IPA. Now that the lens shading table is passed through configure(),
starting the IPA early isn't needed anymore.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
|
|
The Raspberry Pi IPA uses the custom RPI_IPA_ACTION_SET_SENSOR_CONFIG
frame action to send the sensor staggered write configuration to the
pipeline handler when the IPA is configured. Replace this ad-hoc
mechanism by passing the corresponding data back from the IPA to the
pipeline handler through the configure() response. This allows
synchronous handling of the response on the pipeline handler side.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
|
|
The IPAInterface::configure() function now accepts custom configuration
data. Use it to pass the lens shading table instead of using a custom
IPA event. This will allow starting the IPA when starting the camera,
instead of pre-starting it early in order to process the lens shading
table allocation event.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
|
|
The camera sensor orientation is now handled by the pipeline handler.
Drop hardcoded per-sensor orientations from the IPA.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
|
|
Instead of receiving sensor orientation configuration from the IPA,
retrieve it from the CameraSensor Rotation property, and configure the
HFLIP and VFLIP controls accordingly.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
|
|
The PipelineHandlerRPi::configureIPA() function accesses plenty of
member data from the RPiCameraData class and no member from the
PipelineHandlerRPi class. Move it to RPiCameraData where it logically
belongs.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The controls parameter of StaggeredCtrl::set(), passed by reference, is
not modified by the function. Make it const.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The controls variable in PipelineHandlerRPi::start() is unused. Drop it.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
|
|
Add two new parameters, ipaConfig and result, to the
IPAInterface::configure() function to allow pipeline handlers to pass
custom data to their IPA, and receive data back. Wire this through the
code base. The C API interface will be addressed separately, likely
through automation of the C <-> C++ translation.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
A comment copied from the IPAInterfaceWrapper incorrectly mentions the
IPAInterfaceWrapper class instead of the IPAContextWrapper class. Fix
it.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|
|
The parameters to the configure() function part of the ipa_context_ops
are not documented. Fix that.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
|