aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/test/test-media
blob: bf7117dc895fae0691218e7bf3567320409d39fa (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
#!/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

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
	stdbuf -oL v4l2-compliance -m platform:vivid-000 -z platform:vivid-002 -e vivid-002-vid-cap -s10 -a 2>&1 | tee -a $tmp
	echo
	stdbuf -oL v4l2-compliance -m platform:vivid-001 -z platform:vivid-002 -e vivid-002-vid-out -s10 -a 2>&1 | tee -a $tmp
	echo
fi

if [ $cec -eq 1 ]; then
	dmesg -n notice
	cec-ctl -s -D vivid -a vivid-000-vid-cap0 --tv
	cec-ctl -s -D vivid -a vivid-000-vid-out0 --playback
	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
fi

if [ $vim2m -eq 1 ]; then
	modprobe vim2m
	sleep 1
	dmesg -n notice
	stdbuf -oL v4l2-compliance -m platform:vim2m -z platform:vivid-002 -e vivid-002-vid-cap -s10 -a 2>&1 | tee -a $tmp
	echo
	rmmod vim2m
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
	stdbuf -oL v4l2-compliance -m platform:vimc -z platform:vivid-002 -e vivid-002-vid-cap -s10 -a 2>&1 | tee -a $tmp
	echo
	rmmod vimc
fi

rmmod vivid

if [ $kmemleak -eq 1 ]; then
	sleep 10
	echo
	echo kmemleak results:
	echo
	echo scan >/sys/kernel/debug/kmemleak
	cat /sys/kernel/debug/kmemleak
	echo
fi

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