aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/test/test-media
blob: bf2604e5a8ddcc6ef2990da9b463b51aa5172bc3 (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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
#!/bin/bash

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

vidtv=0
vivid=0
vim2m=0
vimc=0
vicodec=0
cec=0
cecpwr=--skip-test-standby-resume
kmemleak=0
dmesg=0
setup=0
unload=0
unbind_time=1
reunbind_time=9
rmmod_time=1
kobj_rel=0
v4l2_ctl=v4l2-ctl
v4l2_compliance=v4l2-compliance
compliance_args=

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
	reunbind_time=14
	rmmod_time=5
fi

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

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 "-E: exit on fail"
	echo "-W: exit on warn"
	echo "-32: use v4l2-ctl-32 and v4l2-compliance-32 to test the 32 bit compat layer"
	echo "-setup: load and configure all the drivers, but do not run tests"
	echo
	echo Test Targets:
	echo "vivid: test the vivid driver"
	echo "vim2m: test the vim2m driver"
	echo "vimc: test the vimc driver"
	echo "vicodec: test the vicodec driver"
	echo "vidtv: test the vidtv driver"
	echo "cec: adds the vivid CEC compliance tests, 'cec-pwr' adds the CEC standby/wakeup tests."
	echo "all: equals 'vivid vim2m vimc vicodec vidtv cec cec-pwr'"
	echo "mc: equals 'vivid vim2m vimc vicodec'"
	exit 0
fi

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

dmesg -n notice

while [ ! -z "$1" ]; do
	case "$1" in
	-unload)
		unload=1
		;;
	-dmesg)
		dmesg=1
		;;
	-E)
		compliance_args="$compliance_args -E"
		;;
	-W)
		compliance_args="$compliance_args -W"
		;;
	-setup)
		setup=1
		;;
	-kmemleak)
		if [ -f /sys/kernel/debug/kmemleak ]; then
			kmemleak=1
		else
			echo /sys/kernel/debug/kmemleak not found, disable memleak testing
		fi
		;;
	-32)
		v4l2_ctl=v4l2-ctl-32
		v4l2_compliance=v4l2-compliance-32
		if ! which $v4l2_ctl >/dev/null ; then
			echo v4l2-ctl-32 is not installed.
			exit 0
		fi
		if ! which $v4l2_compliance >/dev/null ; then
			echo v4l2-compliance-32 is not installed.
			exit 0
		fi
		;;
	all)
		vidtv=1
		vivid=1
		vim2m=1
		vimc=1
		vicodec=1
		cec=1
		cecpwr=
		;;
	mc)
		vivid=1
		vim2m=1
		vimc=1
		vicodec=1
		;;
	vidtv)
		vidtv=1
		;;
	vivid)
		vivid=1
		;;
	vim2m)
		vim2m=1
		;;
	vimc)
		vimc=1
		;;
	vicodec)
		vicodec=1
		;;
	cec)
		cec=1
		;;
	cec-pwr)
		cecpwr=
		;;
	esac
	shift
done

if [ $vidtv -eq 1 ]; then
	if [ ! -f /proc/config.gz ]; then
		if cat /proc/config.gz | gunzip | grep -q CONFIG_MEDIA_CONTROLLER_DVB=y ; then
			echo vidtv cannot be tested since CONFIG_MEDIA_CONTROLLER_DVB is not enabled
			exit 0
		fi
	elif [ -f .config ]; then
		if ! grep -q CONFIG_MEDIA_CONTROLLER_DVB=y .config ; then
			echo vidtv cannot be tested since CONFIG_MEDIA_CONTROLLER_DVB is not enabled
			exit 0
		fi
	fi
fi

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

rmmod vivid 2&>/dev/null
modprobe vivid n_devs=3 multiplanar=1,2,2 cache_hints=1,0,0 #allocators=0,1,1
sleep 1

tmp=`mktemp`

if ! $v4l2_ctl -z platform:vivid-002 -d vivid-002-vid-cap ; then
	echo "FAIL: the vivid module failed to load" | tee -a $tmp
	echo "Grand Total for vivid: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
	echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
	exit 0
fi

$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

v4l2_compliance="$v4l2_compliance $compliance_args"

if [ $vivid -eq 1 -a $setup -eq 0 ]; then
	dmesg -n notice
	echo
	echo vivid compliance tests, contiguous planes | tee /dev/kmsg
	echo
	date
	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 | tee /dev/kmsg
	echo
	date
	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
	if ! cec-ctl -D vivid -a vivid-000-vid-cap0 >/dev/null ; then
		echo "FAIL: the vivid module had no cec support" | tee -a $tmp
		echo "Grand Total for vivid cec: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
		exit 0
	fi
	cec-ctl -D vivid -a vivid-000-vid-cap0 --tv
	sleep 1
	cec-ctl -D vivid -a vivid-000-vid-out0 --playback
	sleep 1
fi

if [ $cec -eq 1 -a $setup -eq 0 ]; then
	echo
	echo vivid cec compliance tests | tee /dev/kmsg
	echo
	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=$!
	date
	# Once vivid is properly handling Arbitration Lost situation, then
	# we can add back the -A option for the cec-compliance commands.
	stdbuf -oL cec-compliance $compliance_args -D vivid -a vivid-000-vid-cap0 -r4 -t10 $cecpwr 2>&1 | tee -a $tmp
	sleep 5
	date
	stdbuf -oL cec-compliance $compliance_args -D vivid -a vivid-000-vid-out0 -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 -a $setup -eq 0 ]; then
	echo
	echo unbind vivid | tee /dev/kmsg
	echo
	echo -n vivid.0 >/sys/bus/platform/drivers/vivid/unbind
	sleep $unbind_time
	echo
	echo rebind vivid | tee /dev/kmsg
	echo
	echo -n vivid.0 >/sys/bus/platform/drivers/vivid/bind
	sleep 1
	echo
	echo second unbind vivid | tee /dev/kmsg
	echo
	for i in `$v4l2_ctl -z platform:vivid-000 --list-devices` `cec-ctl -D vivid -a vivid-000-vid-cap0 -s --list-devices` `cec-ctl -D vivid -a vivid-000-vid-out0 -s --list-devices`; do
		let "t = 1 + $RANDOM / 4096"
		echo $i: sleep ${t}s
		sleep $t <$i &
	done
	sleep 1
	echo
	echo -n vivid.0 >/sys/bus/platform/drivers/vivid/unbind
	sleep $reunbind_time
	echo
	echo rmmod vivid | tee /dev/kmsg
	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
	rmmod vim2m 2&>/dev/null
	modprobe vim2m
	sleep 1
	dmesg -n notice

	if ! $v4l2_ctl -z platform:vim2m ; then
		echo "FAIL: the vim2m module failed to load" | tee -a $tmp
		echo "Grand Total for vim2m: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
		rmmod vivid
		exit 0
	fi
fi

if [ $vim2m -eq 1 -a $setup -eq 0 ]; then
	echo
	echo vim2m compliance tests | tee /dev/kmsg
	echo
	date
	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 | tee /dev/kmsg
	echo
	echo -n vim2m.0 >/sys/bus/platform/drivers/vim2m/unbind
	sleep $unbind_time
	echo
	echo rebind vim2m | tee /dev/kmsg
	echo
	echo -n vim2m.0 >/sys/bus/platform/drivers/vim2m/bind
	sleep 1
	echo
	echo second unbind vim2m | tee /dev/kmsg
	echo
	for i in `$v4l2_ctl -z platform:vim2m --list-devices`; do
		let "t = 1 + $RANDOM / 4096"
		echo $i: sleep ${t}s
		sleep $t <$i &
	done
	sleep 1
	echo
	echo -n vim2m.0 >/sys/bus/platform/drivers/vim2m/unbind
	sleep $reunbind_time
	echo
	echo rmmod vim2m | tee /dev/kmsg
	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
	rmmod vimc 2&>/dev/null
	modprobe vimc
	sleep 1
	dmesg -n notice

	if ! $v4l2_ctl -z platform:vimc -d "Sensor A" ; then
		echo "FAIL: the vimc module failed to load" | tee -a $tmp
		echo "Grand Total for vimc: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
		rmmod vivid
		exit 0
	fi

	media-ctl -d platform:vimc -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480]'
	media-ctl -d platform:vimc -V '"Debayer A":0[fmt:SBGGR8_1X8/640x480]'
	media-ctl -d platform:vimc -V '"Sensor B":0[fmt:SBGGR8_1X8/640x480]'
	media-ctl -d platform:vimc -V '"Debayer B":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
	$v4l2_ctl -z platform:vimc -d "Raw Capture 1" -v pixelformat=BA81
fi

if [ $vimc -eq 1 -a $setup -eq 0 ]; then
	dmesg -n notice
	echo
	echo vimc compliance tests | tee /dev/kmsg
	echo
	date
	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 | tee /dev/kmsg
	echo
	echo -n vimc.0 >/sys/bus/platform/drivers/vimc/unbind
	sleep $unbind_time
	echo
	echo rebind vimc | tee /dev/kmsg
	echo
	echo -n vimc.0 >/sys/bus/platform/drivers/vimc/bind
	sleep 1
	media-ctl -d platform:vimc -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480]'
	media-ctl -d platform:vimc -V '"Debayer A":0[fmt:SBGGR8_1X8/640x480]'
	media-ctl -d platform:vimc -V '"Sensor B":0[fmt:SBGGR8_1X8/640x480]'
	media-ctl -d platform:vimc -V '"Debayer B":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
	$v4l2_ctl -z platform:vimc -d "Raw Capture 1" -v pixelformat=BA81
	echo
	echo second unbind vimc | tee /dev/kmsg
	echo
	# Max sleep time is 6 + 8 = 14s
	for i in `$v4l2_ctl -z platform:vimc --list-devices`; do
		let "t = 6 + $RANDOM / 4096"
		echo $i: sleep ${t}s
		sleep $t <$i &
	done
	$v4l2_ctl -z platform:vimc -d "Raw Capture 0" --stream-mmap --sleep 5 &
	sleep 1
	echo -n vimc.0 >/sys/bus/platform/drivers/vimc/unbind
	sleep 14
	echo
	echo rmmod vimc | tee /dev/kmsg
	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

if [ $vicodec -eq 1 ]; then
	if [ $setup -eq 0 ]; then
		tmpdir=`mktemp -d`
	else
		tmpdir=/tmp/vicodec-test
		rm -rf $tmpdir
		mkdir $tmpdir
	fi

	rmmod vicodec 2&>/dev/null
	modprobe vicodec
	sleep 2
	dmesg -n notice

	if ! $v4l2_ctl -z platform:vicodec ; then
		echo "FAIL: the vicodec module failed to load" | tee -a $tmp
		echo "Grand Total for vicodec: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
		rmmod vivid
		exit 0
	fi

	echo
	echo vicodec create test files in $tmpdir | tee /dev/kmsg
	echo

	encful_opts='-z platform:vicodec -d stateful-encoder-source --stream-mmap --stream-out-mmap --stream-out-hor-speed=1'
	$v4l2_ctl $encful_opts --stream-count=24 --stream-to-hdr=$tmpdir/comp.hdr.yu12.1280.24
	$v4l2_ctl $encful_opts --stream-count=24 --stream-to=$tmpdir/comp.yu12.1280.24
	$v4l2_ctl $encful_opts --stream-count=1 --stream-to-hdr=$tmpdir/comp.hdr.yu12.1280.1
	$v4l2_ctl $encful_opts --stream-count=1 --stream-to=$tmpdir/comp.yu12.1280.1
	$v4l2_ctl $encful_opts --stream-count=2 --stream-to-hdr=$tmpdir/comp.hdr.yu12.1280.2
	$v4l2_ctl $encful_opts --stream-count=2 --stream-to=$tmpdir/comp.yu12.1280.2
	$v4l2_ctl $encful_opts -x width=1920,height=1080 --set-selection-output target=crop,height=1080 --stream-count=24 --stream-to-hdr=$tmpdir/comp.hdr.yu12.1920.24
	$v4l2_ctl $encful_opts -x width=1920,height=1080 --set-selection-output target=crop,height=1080 --stream-count=24 --stream-to=$tmpdir/comp.yu12.1920.24
	$v4l2_ctl $encful_opts -x width=1920,height=1080 --set-selection-output target=crop,height=1080 --stream-count=1 --stream-to-hdr=$tmpdir/comp.hdr.yu12.1920.1
	$v4l2_ctl $encful_opts -x width=1920,height=1080 --set-selection-output target=crop,height=1080 --stream-count=1 --stream-to=$tmpdir/comp.yu12.1920.1
	$v4l2_ctl $encful_opts -x width=1920,height=1080 --set-selection-output target=crop,height=1080 --stream-count=2 --stream-to-hdr=$tmpdir/comp.hdr.yu12.1920.2
	$v4l2_ctl $encful_opts -x width=1920,height=1080 --set-selection-output target=crop,height=1080 --stream-count=2 --stream-to=$tmpdir/comp.yu12.1920.2

	cat $tmpdir/comp.hdr.yu12.1280.1 $tmpdir/comp.hdr.yu12.1920.1 >$tmpdir/comp.hdr.yu12.mix.2
	cat $tmpdir/comp.yu12.1280.1 $tmpdir/comp.yu12.1920.1 >$tmpdir/comp.yu12.mix.2
	cat $tmpdir/comp.hdr.yu12.mix.2 $tmpdir/comp.hdr.yu12.mix.2 $tmpdir/comp.hdr.yu12.mix.2 $tmpdir/comp.hdr.yu12.mix.2 $tmpdir/comp.hdr.yu12.mix.2 $tmpdir/comp.hdr.yu12.mix.2 $tmpdir/comp.hdr.yu12.mix.2 $tmpdir/comp.hdr.yu12.mix.2 $tmpdir/comp.hdr.yu12.mix.2 $tmpdir/comp.hdr.yu12.mix.2 $tmpdir/comp.hdr.yu12.mix.2 $tmpdir/comp.hdr.yu12.mix.2 >$tmpdir/comp.hdr.yu12.mix.2.12
	cat $tmpdir/comp.yu12.mix.2 $tmpdir/comp.yu12.mix.2 $tmpdir/comp.yu12.mix.2 $tmpdir/comp.yu12.mix.2 $tmpdir/comp.yu12.mix.2 $tmpdir/comp.yu12.mix.2 $tmpdir/comp.yu12.mix.2 $tmpdir/comp.yu12.mix.2 $tmpdir/comp.yu12.mix.2 $tmpdir/comp.yu12.mix.2 $tmpdir/comp.yu12.mix.2 $tmpdir/comp.yu12.mix.2 >$tmpdir/comp.yu12.mix.2.12
	cat $tmpdir/comp.hdr.yu12.1280.2 $tmpdir/comp.hdr.yu12.1920.2 >$tmpdir/comp.hdr.yu12.mix.4
	cat $tmpdir/comp.yu12.1280.2 $tmpdir/comp.yu12.1920.2 >$tmpdir/comp.yu12.mix.4
	cat $tmpdir/comp.hdr.yu12.mix.4 $tmpdir/comp.hdr.yu12.mix.4 $tmpdir/comp.hdr.yu12.mix.4 $tmpdir/comp.hdr.yu12.mix.4 $tmpdir/comp.hdr.yu12.mix.4 $tmpdir/comp.hdr.yu12.mix.4 >$tmpdir/comp.hdr.yu12.mix.4.6
	cat $tmpdir/comp.yu12.mix.4 $tmpdir/comp.yu12.mix.4 $tmpdir/comp.yu12.mix.4 $tmpdir/comp.yu12.mix.4 $tmpdir/comp.yu12.mix.4 $tmpdir/comp.yu12.mix.4 >$tmpdir/comp.yu12.mix.4.6
fi

if [ $vicodec -eq 1 -a $setup -eq 0 ]; then
	echo
	echo vicodec media controller compliance tests | tee /dev/kmsg
	echo
	date
	stdbuf -oL $v4l2_compliance -M platform:vicodec 2>&1 | tee -a $tmp

	echo
	echo vicodec encoder compliance tests | tee /dev/kmsg
	echo
	stdbuf -oL $v4l2_compliance -z platform:vicodec -d stateful-encoder-source -z platform:vivid-002 -e vivid-002-vid-cap -s10 -P -a 2>&1 | tee -a $tmp

	echo
	echo vicodec decoder compliance tests | tee /dev/kmsg
	echo
	decful_opts='-z platform:vicodec -d stateful-decoder-source -z platform:vivid-002 -e vivid-002-vid-cap'
	stdbuf -oL $v4l2_compliance $decful_opts --stream-from-hdr=$tmpdir/comp.hdr.yu12.1280.24 -s24 -P -a 2>&1 | tee -a $tmp
	stdbuf -oL $v4l2_compliance $decful_opts --stream-from $tmpdir/comp.yu12.1280.24 -s24 -P -a 2>&1 | tee -a $tmp
	stdbuf -oL $v4l2_compliance $decful_opts --stream-from-hdr $tmpdir/comp.hdr.yu12.mix.4.6 -s24 -P -a 2>&1 | tee -a $tmp
	stdbuf -oL $v4l2_compliance $decful_opts --stream-from $tmpdir/comp.yu12.mix.4.6 -s24 -P -a 2>&1 | tee -a $tmp
	stdbuf -oL $v4l2_compliance $decful_opts --stream-from-hdr $tmpdir/comp.hdr.yu12.mix.2.12 -s24 -P -a 2>&1 | tee -a $tmp
	stdbuf -oL $v4l2_compliance $decful_opts --stream-from $tmpdir/comp.yu12.mix.2.12 -s24 -P -a 2>&1 | tee -a $tmp

	decful_opts='-z platform:vicodec -d stateful-decoder-source --stream-mmap --stream-out-mmap'
	decless_opts='-z platform:vicodec -d stateless-decoder-source --stream-mmap --stream-out-mmap'
	echo
	echo stateful decode | tee /dev/kmsg
	echo
	$v4l2_ctl $decful_opts --stream-from-hdr=$tmpdir/comp.hdr.yu12.1280.24 --stream-to=$tmpdir/raw.yu12.1280.24
	echo
	echo stateless decode | tee /dev/kmsg
	echo
	$v4l2_ctl $decless_opts --stream-from-hdr=$tmpdir/comp.hdr.yu12.1280.24 --stream-to=$tmpdir/raw.yu12.1280.24.stateless
	cmp $tmpdir/raw.yu12.1280.24 $tmpdir/raw.yu12.1280.24.stateless

	echo
	echo stateful decode with dynamic resolution changes for every frame | tee /dev/kmsg
	echo
	$v4l2_ctl $decful_opts --stream-from-hdr=$tmpdir/comp.hdr.yu12.mix.2.12 --stream-to=$tmpdir/raw.yu12.mix.2.12
	# v4l2-ctl does not yet reallocate buffers if they are too small for the new format
	$v4l2_ctl $decless_opts -v width=1920,height=1088 --stream-from-hdr=$tmpdir/comp.hdr.yu12.mix.2.12 --stream-to=$tmpdir/raw.yu12.mix.2.12.stateless
	cmp $tmpdir/raw.yu12.mix.2.12 $tmpdir/raw.yu12.mix.2.12.stateless

	echo
	echo stateful decode with dynamic resolution changes for every other frame | tee /dev/kmsg
	echo
	$v4l2_ctl $decful_opts --stream-from-hdr=$tmpdir/comp.hdr.yu12.mix.4.6 --stream-to=$tmpdir/raw.yu12.mix.4.6
	# v4l2-ctl does not yet reallocate buffers if they are too small for the new format
	$v4l2_ctl $decless_opts -v width=1920,height=1088 --stream-from-hdr=$tmpdir/comp.hdr.yu12.mix.4.6 --stream-to=$tmpdir/raw.yu12.mix.4.6.stateless
	cmp $tmpdir/raw.yu12.mix.4.6 $tmpdir/raw.yu12.mix.4.6.stateless

	rm -rf $tmpdir
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo unbind vicodec | tee /dev/kmsg
	echo
	echo -n vicodec.0 >/sys/bus/platform/drivers/vicodec/unbind
	sleep $unbind_time
	echo
	echo rebind vicodec | tee /dev/kmsg
	echo
	echo -n vicodec.0 >/sys/bus/platform/drivers/vicodec/bind
	sleep 1
	echo
	echo second unbind vicodec | tee /dev/kmsg
	echo
	for i in `$v4l2_ctl -z platform:vicodec --list-devices`; do
		let "t = 1 + $RANDOM / 4096"
		echo $i: sleep ${t}s
		sleep $t <$i &
	done
	sleep 1
	echo
	echo -n vicodec.0 >/sys/bus/platform/drivers/vicodec/unbind
	sleep $reunbind_time
	echo
	echo rmmod vicodec | tee /dev/kmsg
	echo
	rmmod vicodec
	sleep $rmmod_time
	if [ $kmemleak -eq 1 ]; then
		echo
		echo kmemleak results for vicodec:
		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 [ $vidtv -eq 1 ]; then
	rmmod dvb_vidtv_bridge dvb_vidtv_tuner dvb_vidtv_demod 2&>/dev/null
	modprobe vidtv
	sleep 2
	dmesg -n notice

	if ! media-ctl -d platform:vidtv ; then
		echo "FAIL: the vidtv module failed to load" | tee -a $tmp
		echo "Grand Total for vidtv: Succeeded: 0, Failed: 1, Warnings: 0" | tee -a $tmp
		echo "Final Summary: 1, Succeeded: 0, Failed: 1, Warnings: 0"
		rmmod dvb_vidtv_bridge dvb_vidtv_tuner dvb_vidtv_demod 2&>/dev/null
		exit 0
	fi
fi

if [ $vidtv -eq 1 -a $setup -eq 0 ]; then
	echo
	echo vidtv media controller compliance tests | tee /dev/kmsg
	echo
	date
	stdbuf -oL $v4l2_compliance -M platform:vidtv 2>&1 | tee -a $tmp

	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo
	echo unbind vidtv
	echo
	echo -n vidtv.0 >/sys/bus/platform/drivers/vidtv/unbind
	sleep $unbind_time
	echo
	echo rebind vidtv
	echo
	echo -n vidtv.0 >/sys/bus/platform/drivers/vidtv/bind
	sleep 1
	echo
	echo second unbind vidtv
	echo
	sleep 1
	echo
	echo -n vidtv.0 >/sys/bus/platform/drivers/vidtv/unbind
	sleep $reunbind_time
	echo
	echo rmmod dvb_vidtv_bridge dvb_vidtv_tuner dvb_vidtv_demod
	echo
	rmmod dvb_vidtv_bridge dvb_vidtv_tuner dvb_vidtv_demod
	sleep $rmmod_time
	if [ $kmemleak -eq 1 ]; then
		echo
		echo kmemleak results for vidtv:
		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 [ $setup -eq 0 ]; then
	date
	echo
	echo unbind vivid | tee /dev/kmsg
	echo
	echo -n vivid.0 >/sys/bus/platform/drivers/vivid/unbind
	sleep $unbind_time
	echo
	echo rmmod vivid | tee /dev/kmsg
	echo
	rmmod vivid
	sleep $rmmod_time
fi

if [ $setup -eq 0 ]; then
	date
	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);
	'

	date
	rm -f $tmp

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

dmesg -n $cur_lvl

Privacy Policy