/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * v4l2_subdevice_test.cpp - VIMC-based V4L2 subdevice test
 */

#include <iostream>
#include <string.h>
#include <sys/stat.h>

#include "libcamera/internal/device_enumerator.h"
#include "libcamera/internal/media_device.h"
#include "libcamera/internal/v4l2_subdevice.h"

#include "v4l2_subdevice_test.h"

using namespace std;
using namespace libcamera;

/*
 * This test runs on vimc media device. For a description of vimc, in the
 * context of libcamera testing, please refer to
 * 'test/media_device/media_device_link_test.cpp' file.
 *
 * If the vimc module is not loaded, the test gets skipped.
 */

int V4L2SubdeviceTest::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("vimc");
	media_ = enumerator_->search(dm);
	if (!media_) {
		cerr << "Unable to find \'vimc\' media device node" << endl;
		return TestSkip;
	}

	MediaEntity *videoEntity = media_->getEntityByName("Scaler");
	if (!videoEntity) {
		cerr << "Unable to find media entity 'Scaler'" << endl;
		return TestFail;
	}

	scaler_ = new V4L2Subdevice(videoEntity);
	if (scaler_->open()) {
		cerr << "Unable to open video subdevice "
		     << scaler_->entity()->deviceNode() << endl;
		return TestSkip;
	}

	return 0;
}

void V4L2SubdeviceTest::cleanup()
{
	delete scaler_;
}
ons/cloud-lightning.svg?h=v0.0.1&amp;id=79266225d2af742195f99be7c91c7d5356f7eb78'>tree</a><a href='/libcamera/vivid.git/commit/src/qcam/assets/feathericons/cloud-lightning.svg?h=v0.0.1&amp;id=79266225d2af742195f99be7c91c7d5356f7eb78'>commit</a><a href='/libcamera/vivid.git/diff/src/qcam/assets/feathericons/cloud-lightning.svg?h=v0.0.1&amp;id=79266225d2af742195f99be7c91c7d5356f7eb78'>diff</a></td><td class='form'><form class='right' method='get' action='/libcamera/vivid.git/log/src/qcam/assets/feathericons/cloud-lightning.svg'>
<input type='hidden' name='h' value='v0.0.1'/><input type='hidden' name='id' value='79266225d2af742195f99be7c91c7d5356f7eb78'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/libcamera/vivid.git/tree/?h=v0.0.1&amp;id=79266225d2af742195f99be7c91c7d5356f7eb78'>root</a>/<a href='/libcamera/vivid.git/tree/src?h=v0.0.1&amp;id=79266225d2af742195f99be7c91c7d5356f7eb78'>src</a>/<a href='/libcamera/vivid.git/tree/src/qcam?h=v0.0.1&amp;id=79266225d2af742195f99be7c91c7d5356f7eb78'>qcam</a>/<a href='/libcamera/vivid.git/tree/src/qcam/assets?h=v0.0.1&amp;id=79266225d2af742195f99be7c91c7d5356f7eb78'>assets</a>/<a href='/libcamera/vivid.git/tree/src/qcam/assets/feathericons?h=v0.0.1&amp;id=79266225d2af742195f99be7c91c7d5356f7eb78'>feathericons</a>/<a href='/libcamera/vivid.git/tree/src/qcam/assets/feathericons/cloud-lightning.svg?h=v0.0.1&amp;id=79266225d2af742195f99be7c91c7d5356f7eb78'>cloud-lightning.svg</a></div><div class='content'>blob: 32d154cc00e3f398f04dac3df90c102c667475c8 (<a href='/libcamera/vivid.git/plain/src/qcam/assets/feathericons/cloud-lightning.svg?h=v0.0.1&amp;id=79266225d2af742195f99be7c91c7d5356f7eb78'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
</pre></td>
<td class='lines'><pre><code><span class="hl kwa">&lt;svg</span> <span class="hl kwb">xmlns</span>=<span class="hl str">&quot;http://www.w3.org/2000/svg&quot;</span> <span class="hl kwb">width</span>=<span class="hl str">&quot;24&quot;</span> <span class="hl kwb">height</span>=<span class="hl str">&quot;24&quot;</span> <span class="hl kwb">viewBox</span>=<span class="hl str">&quot;0 0 24 24&quot;</span> <span class="hl kwb">fill</span>=<span class="hl str">&quot;none&quot;</span> <span class="hl kwb">stroke</span>=<span class="hl str">&quot;currentColor&quot;</span> <span class="hl kwb">stroke-width</span>=<span class="hl str">&quot;2&quot;</span> <span class="hl kwb">stroke-linecap</span>=<span class="hl str">&quot;round&quot;</span> <span class="hl kwb">stroke-linejoin</span>=<span class="hl str">&quot;round&quot;</span> <span class="hl kwb">class</span>=<span class="hl str">&quot;feather feather-cloud-lightning&quot;</span><span class="hl kwa">&gt;&lt;path</span> <span class="hl kwb">d</span>=<span class="hl str">&quot;M19 16.9A5 5 0 0 0 18 7h-1.26a8 8 0 1 0-11.62 9&quot;</span><span class="hl kwa">&gt;&lt;/path&gt;&lt;polyline</span> <span class="hl kwb">points</span>=<span class="hl str">&quot;13 11 9 17 15 17 11 23&quot;</span><span class="hl kwa">&gt;&lt;/polyline&gt;&lt;/svg&gt;</span>
</code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.1</a> (<a href='https://git-scm.com/'>git 2.18.0</a>) at 2025-02-16 18:51:19 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>