summaryrefslogtreecommitdiff
path: root/src/v4l2/v4l2_camera_file.cpp
diff options
context:
space:
mode:
authorStefan Klug <stefan.klug@ideasonboard.com>2024-12-16 16:41:00 +0100
committerStefan Klug <stefan.klug@ideasonboard.com>2024-12-17 11:19:36 +0100
commit62959e1f89f2327172f3d0ed5842e2eeec74a919 (patch)
tree071a9e7a8d135a2da1aa7536cb18cc9d66f4860a /src/v4l2/v4l2_camera_file.cpp
parent60e94a0d9957a8dd25ed78ae4c16c2918644671f (diff)
pipeline: rkisp1: Limit sensor size to max resolution
In RkISPPath::validate() the sensor sizes are correctly filtered to the ones supported by the ISP. But later in RkISPPipeline::configure() the configured stream size is passed to sensor->getFormat() and the CameraSensor class chooses the best sensor format for the requested stream size. This can result in a sensor format that is too big for the ISP. Fix that by supplying the maximum resolution supported by the ISP to setFormat(). Fixes: 761545407c76 ("pipeline: rkisp1: Filter out sensor sizes not supported by the pipeline") Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Diffstat (limited to 'src/v4l2/v4l2_camera_file.cpp')
0 files changed, 0 insertions, 0 deletions
n59' href='#n59'>59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * libcamera V4L2 API tests
 */

#include <iostream>

#include <linux/media-bus-format.h>

#include "v4l2_videodevice_test.h"

#include "device_enumerator.h"
#include "media_device.h"

using namespace std;
using namespace libcamera;

int V4L2VideoDeviceTest::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(driver_);
	dm.add(entity_);

	media_ = enumerator_->search(dm);
	if (!media_)
		return TestSkip;

	MediaEntity *entity = media_->getEntityByName(entity_);
	if (!entity)
		return TestSkip;

	capture_ = new V4L2VideoDevice(entity);
	if (!capture_)
		return TestFail;

	if (!media_->acquire())
		return TestFail;

	int ret = media_->disableLinks();
	media_->release();
	if (ret)
		return TestFail;

	if (capture_->open())
		return TestFail;

	V4L2DeviceFormat format = {};
	if (capture_->getFormat(&format))
		return TestFail;

	if (driver_ == "vimc") {
		sensor_ = new CameraSensor(media_->getEntityByName("Sensor A"));
		if (sensor_->init())
			return TestFail;

		debayer_ = new V4L2Subdevice(media_->getEntityByName("Debayer A"));
		if (debayer_->open())
			return TestFail;

		format.fourcc = V4L2_PIX_FMT_SBGGR8;

		V4L2SubdeviceFormat subformat = {};
		subformat.mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8;
		subformat.size = format.size;

		if (sensor_->setFormat(&subformat))
			return TestFail;

		if (debayer_->setFormat(0, &subformat))
			return TestFail;
	}

	format.size.width = 640;
	format.size.height = 480;
	if (capture_->setFormat(&format))
		return TestFail;

	return TestPass;
}

void V4L2VideoDeviceTest::cleanup()
{
	capture_->streamOff();
	capture_->releaseBuffers();
	capture_->close();

	delete debayer_;
	delete sensor_;
	delete capture_;
}