aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/test/test-media
blob: d5d6af0dc30bde7013acdf185655ac1f2bbe7d43 (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
#!/bin/bash

# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright 2019 Cisco Systems, Inc. and/or its affiliates. All rights reserved.

vivid=0
vim2m=0
vimc=0
cec=0
cecpwr=--skip-test-standby-resume
kmemleak=0
dmesg=0
unload=0
unbind_time=1
rmmod_time=1
kobj_rel=0

if [ -f /proc/config.gz ]; then
	if cat /proc/config.gz | gunzip |grep -q CONFIG_DEBUG_KOBJECT_RELEASE=y ; then
		kobj_rel=1
	fi
elif [ -f .config ]; then
	if grep -q CONFIG_DEBUG_KOBJECT_RELEASE=y .config ; then
		kobj_rel=1
	fi
fi

if [ $kobj_rel -eq 1 ]; then
	echo Detected CONFIG_DEBUG_KOBJECT_RELEASE=y
	unbind_time=10
	rmmod_time=5
fi

cur_lvl=`cut -c 1-2 /proc/sys/kernel/printk`
dmesg -n notice

if [ -z "$1" ]; then
	echo "usage: test-media [options] test-targets"
	echo
	echo Run as root.
	echo
	echo Options:
	echo "-unload: unload any media modules before testing"
	echo "-kmemleak: enable memory leak scan"
	echo "-dmesg: run dmesg at the end"
	echo
	echo Test Targets:
	echo "vivid: test the vivid driver"
	echo "vim2m: test the vim2m driver"
	echo "vimc: test the vimc driver"
	echo "cec: adds the vivid CEC compliance tests, 'cec-pwr' adds the CEC standby/wakeup tests."
	echo "all: equals 'vivid vim2m vimc cec cec-pwr'"
	echo "mc: equals 'vivid vim2m vimc'"
	exit 0
fi

if [ `id -u` -ne 0 ]; then
	echo "$0 must be run as root"
	exit -1
fi

while [ ! -z "$1" ]; do
	case "$1" in
	-unload)
		unload=1
		;;
	-dmesg)
		dmesg=1
		;;
	-kmemleak)
		if [ -f /sys/kernel/debug/kmemleak ]; then
			kmemleak=1
		else
			echo /sys/kernel/debug/kmemleak not found, disable memleak testing
		fi
		;;
	all)
		vivid=1
		vim2m=1
		vimc=1
		cec=1
		cecpwr=
		;;
	mc)
		vivid=1
		vim2m=1
		vimc=1
		;;
	vivid)
		vivid=1
		;;
	vim2m)
		vim2m=1
		;;
	vimc)
		vimc=1
		;;
	cec)
		cec=1
		;;
	cec-pwr)
		cecpwr=
		;;
	esac
	shift
done

if [ $unload -eq 1 ]; then
	test-media-unload.pl
	dmesg -n notice
fi

if [ $kmemleak -eq 1 ]; then
	echo clear >/sys/kernel/debug/kmemleak
fi

modprobe vivid n_devs=3 multiplanar=1,2,2 #allocators=0,1,1
sleep 1

v4l2-ctl -z platform:vivid-000 -d vivid-000-vid-cap -i3 -v width=3840,height=2160,pixelformat=NV24
v4l2-ctl -z platform:vivid-000 -d vivid-000-vid-out -o1 -x width=3840,height=2160,pixelformat=NV24
v4l2-ctl -z platform:vivid-001 -d vivid-001-vid-cap -i3 -v width=3840,height=2160,pixelformat=NM16
v4l2-ctl -z platform:vivid-001 -d vivid-001-vid-out -o1 -x width=3840,height=2160,pixelformat=NM16
v4l2-ctl -z platform:vivid-002 -d vivid-002-vid-cap -i3 -v width=3840,height=2160,pixelformat=NV24
v4l2-ctl -z platform:vivid-002 -d vivid-002-vid-out -o1 -x width=3840,height=2160,pixelformat=NM16

echo

tmp=`mktemp`

if [ $vivid -eq 1 ]; then
	dmesg -n notice
	echo
	echo vivid compliance tests, contiguous planes
	echo
	stdbuf -oL v4l2-compliance -m platform:vivid-000 -z platform:vivid-002 -e vivid-002-vid-cap -P -s10 -a 2>&1 | tee -a $tmp
	echo
	echo vivid compliance tests, non-contiguous planes
	echo
	stdbuf -oL v4l2-compliance -m platform:vivid-001 -z platform:vivid-002 -e vivid-002-vid-out -P -s10 -a 2>&1 | tee -a $tmp
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
fi

if [ $cec -eq 1 ]; then
	dmesg -n notice
	echo
	echo vivid cec compliance tests
	echo
	cec-ctl -D vivid -a vivid-000-vid-cap0 --tv
	sleep 1
	cec-ctl -D vivid -a vivid-000-vid-out0 --playback
	sleep 1
	trap 'kill $f0 $f1 2>/dev/null' INT
	cec-follower -s -D vivid -a vivid-000-vid-cap0 2>&1 >/dev/null &
	f0=$!
	cec-follower -s -D vivid -a vivid-000-vid-out0 2>&1 >/dev/null &
	f1=$!
	stdbuf -oL cec-compliance -D vivid -a vivid-000-vid-cap0 -A -r4 -t10 $cecpwr 2>&1 | tee -a $tmp
	sleep 5
	stdbuf -oL cec-compliance -D vivid -a vivid-000-vid-out0 -A -r0 -t10 $cecpwr 2>&1 | tee -a $tmp
	kill $f0
	kill $f1
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	vivid=1
fi

if [ $vivid -eq 1 ]; then
	echo
	echo unbind vivid
	echo
	echo -n vivid.0 >/sys/bus/platform/drivers/vivid/unbind
	sleep $unbind_time
	echo
	echo rebind vivid
	echo
	echo -n vivid.0 >/sys/bus/platform/drivers/vivid/bind
	sleep 1
	echo
	echo second unbind vivid
	echo
	echo -n vivid.0 >/sys/bus/platform/drivers/vivid/unbind
	sleep $unbind_time
	echo
	echo rmmod vivid
	echo
	rmmod vivid
	sleep $rmmod_time

	if [ $kmemleak -eq 1 ]; then
		echo
		echo kmemleak results for vivid:
		echo
		echo scan >/sys/kernel/debug/kmemleak
		cat /sys/kernel/debug/kmemleak
		echo
		echo end of kmemleak results
		echo
	fi

	modprobe vivid n_devs=3 multiplanar=1,2,2 #allocators=0,1,1
	sleep 1

	v4l2-ctl -z platform:vivid-002 -d vivid-002-vid-cap -i3 -v width=3840,height=2160,pixelformat=NV24
	v4l2-ctl -z platform:vivid-002 -d vivid-002-vid-out -o1 -x width=3840,height=2160,pixelformat=NM16

	if [ $kmemleak -eq 1 ]; then
		echo clear >/sys/kernel/debug/kmemleak
	fi
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
fi

if [ $vim2m -eq 1 ]; then
	modprobe vim2m
	sleep 1
	dmesg -n notice
	echo
	echo vim2m compliance tests
	echo
	stdbuf -oL v4l2-compliance -m platform:vim2m -z platform:vivid-002 -e vivid-002-vid-cap -s10 -P -a 2>&1 | tee -a $tmp
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo unbind vim2m
	echo
	echo -n vim2m.0 >/sys/bus/platform/drivers/vim2m/unbind
	sleep $unbind_time
	echo
	echo rebind vim2m
	echo
	echo -n vim2m.0 >/sys/bus/platform/drivers/vim2m/bind
	sleep 1
	echo
	echo second unbind vim2m
	echo
	echo -n vim2m.0 >/sys/bus/platform/drivers/vim2m/unbind
	sleep $unbind_time
	echo
	echo rmmod vim2m
	echo
	rmmod vim2m
	sleep $rmmod_time
	if [ $kmemleak -eq 1 ]; then
		echo
		echo kmemleak results for vim2m:
		echo
		echo scan >/sys/kernel/debug/kmemleak
		cat /sys/kernel/debug/kmemleak
		echo
		echo end of kmemleak results
		echo clear >/sys/kernel/debug/kmemleak
	fi
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
fi

if [ $vimc -eq 1 ]; then
	modprobe vimc
	sleep 1
	dmesg -n notice
	media-ctl -d platform:vimc -V '1:0[fmt:SBGGR8_1X8/640x480]'
	media-ctl -d platform:vimc -V '5:0[fmt:SBGGR8_1X8/640x480]'
	v4l2-ctl -z platform:vimc -d "RGB/YUV Capture" -v width=1920,height=1440
	v4l2-ctl -z platform:vimc -d "Raw Capture 0" -v pixelformat=BA81
	dmesg -n notice
	echo
	echo vimc compliance tests
	echo
	stdbuf -oL v4l2-compliance -m platform:vimc -z platform:vivid-002 -e vivid-002-vid-cap -s10 -P -a 2>&1 | tee -a $tmp
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo unbind vimc
	echo
	echo -n vimc.0 >/sys/bus/platform/drivers/vimc/unbind
	sleep $unbind_time
	echo
	echo rebind vimc
	echo
	echo -n vimc.0 >/sys/bus/platform/drivers/vimc/bind
	sleep 1
	echo
	echo second unbind vimc
	echo
	echo -n vimc.0 >/sys/bus/platform/drivers/vimc/unbind
	sleep $unbind_time
	echo
	echo rmmod vimc
	echo
	rmmod vimc
	sleep $rmmod_time
	if [ $kmemleak -eq 1 ]; then
		echo
		echo kmemleak results for vimc:
		echo
		echo scan >/sys/kernel/debug/kmemleak
		cat /sys/kernel/debug/kmemleak
		echo
		echo end of kmemleak results
		echo clear >/sys/kernel/debug/kmemleak
		echo
		echo
		echo
		echo
		echo
		echo
		echo
		echo
	fi
fi

echo
echo unbind vivid
echo
echo -n vivid.0 >/sys/bus/platform/drivers/vivid/unbind
sleep $unbind_time
echo
echo rmmod vivid
echo
rmmod vivid
sleep $rmmod_time

echo
echo Summary:
echo

grep 'Total' $tmp | perl -e '
while (<>) {
	if (/Total/) {
		print;
		$added_nl = /^Grand/ || /\/dev\/cec/;
		printf("\n") if $added_nl;
	}
	next unless /^Total/;
	($succeeded, $failed, $warnings) = /Succeeded: (\d+), Failed: (\d+), Warnings: (\d+)/;
	$tot_succeeded += $succeeded;
	$tot_failed += $failed;
	$tot_warnings += $warnings;
}

printf("\n") unless $added_nl;
printf("Final Summary: %d, Succeeded: %d, Failed: %d, Warnings: %d\n",
	$tot_succeeded + $tot_failed, $tot_succeeded, $tot_failed, $tot_warnings);
'

rm -f $tmp

if [ $dmesg -eq 1 ]; then
	echo
	echo -----------------------------------------------------------
	echo
	dmesg
fi

dmesg -n $cur_lvl

Privacy Policy