/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2019, Google Inc. * * v4l2_subdevice_test.cpp - VIMC-based V4L2 subdevice test */ #include #include #include #include "device_enumerator.h" #include "media_device.h" #include "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_; } .cpp?h=vivid-pre-a07968bed276&id=7e38ae8a1ef6e82285c818d92905f539686f80ce'>treecommitdiff
blob: 19dceae123dd72c406946fa5a070bff9ef975292 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * event.cpp - Event test
 */

#include <iostream>
#include <string.h>
#include <unistd.h>

#include <libcamera/base/event_dispatcher.h>
#include <libcamera/base/event_notifier.h>
#include <libcamera/base/thread.h>
#include <libcamera/base/timer.h>

#include "test.h"

using namespace libcamera;
using namespace std;
using namespace std::chrono_literals;

class EventTest : public Test
{
protected:
	void readReady()
	{
		size_ = read(notifier_->fd(), data_, sizeof(data_));
		notified_ = true;
	}

	int init()
	{
		notifier_ = nullptr;

		return pipe(pipefd_);
	}

	int run()
	{