7 # ------------------------------------------------------------------------------
12 $mediactl -d $mdev -p | grep 'bus info' | sed 's/.*platform://'
18 $mediactl -d $mdev -p | grep -q -- "- entity.*$feature"
22 $mediactl -d $mdev -p | grep -- '- entity.*rpf.[0-9] [^i]' | wc -l
26 $mediactl -d $mdev -p | grep -- '- entity.*wpf.[0-9] [^o]' | wc -l
29 vsp1_count_bru_inputs() {
30 num_pads=`media-ctl -p | grep 'entity.*bru' | sed 's/.*(\([0-9]\) pads.*/\1/'`
34 vsp1_entity_get_size() {
38 $mediactl -d $mdev --get-v4l2 "'$dev $entity':$pad" | grep fmt | \
39 sed 's/.*\/\([0-9x]*\).*/\1/'
42 # -----------------------------------------------------------------------------
43 # Referance frame generation
59 options="$options -c ${reftype/composed-/}"
71 # XRGB555 has the X bit hardcoded to 0
75 # The X bits are configurable with a default value of 255
83 $(format_v4l2_is_yuv $format) && options="$options -y"
85 $genimage -f $format -s $size -a $alpha $options -o $file \
86 frames/frame-reference-1024x768.pnm
89 reference_histogram() {
95 $(format_v4l2_is_yuv $format) && yuv="-y"
97 $genimage -f $format $yuv -s $size -H $file \
98 frames/frame-reference-1024x768.pnm
101 # ------------------------------------------------------------------------------
102 # Image and histogram comparison
106 # Compare the two frames for exact match.
108 compare_frame_exact() {
113 diff -q $img_a $img_b > /dev/null && match='pass'
115 echo "Compared $img_a and $img_b: $match" | ./logger.sh check >> $logfile
117 if [ $match = 'pass' ] ; then
125 # Compare the two frames using a fuzzy match algorithm to account for errors
126 # introduced by the YUV packing. Accept a maximum 1% mean average error over
127 # the whole frame with no more than 5% of the pixels differing.
129 compare_frame_fuzzy() {
130 fmt=$(echo $1 | sed 's/M$//')
135 pnm_a=${img_a/bin/pnm}
136 pnm_b=${img_b/bin/pnm}
138 raw2rgbpnm -f $fmt -s $size $img_a $pnm_a > /dev/null
139 raw2rgbpnm -f $fmt -s $size $img_b $pnm_b > /dev/null
141 ae=$(compare -metric ae $pnm_a $pnm_b /dev/null 2>&1)
142 mae=$(compare -metric mae $pnm_a $pnm_b /dev/null 2>&1 | sed 's/.*(\(.*\))/\1/')
147 width=$(echo $size | cut -d 'x' -f 1)
148 height=$(echo $size | cut -d 'x' -f 2)
150 ae_match=$(echo $ae $width $height | awk '{ if ($1 / $2 / $3 < 0.05) { print "pass" } else { print "fail" } }')
151 mae_match=$(echo $mae | awk '{ if ($1 < 0.01) { print "pass" } else { print "fail" } }')
153 echo "Compared $img_a and $img_b: ae $ae ($ae_match) mae $mae ($mae_match)" | ./logger.sh check >> $logfile
155 if [ $ae_match = 'pass' -a $mae_match = 'pass' ] ; then
168 fmt=$(echo $format | tr '[:upper:]' '[:lower:]')
169 size=$(vsp1_entity_get_size wpf.$wpf 1)
171 reference_frame ref-frame.bin $reftype $format $size
174 for frame in frame-*.bin ; do
175 (compare_frame_$method $format $size $frame ref-frame.bin) || {
176 mv $frame ${0/.sh/}-${frame/.bin/-$fmt-$size.bin} ;
181 if [ $result = "fail" ] ; then
182 mv ref-frame.bin ${0/.sh/}-ref-frame-$fmt-$size.bin
190 compare_histogram() {
195 diff -q $histo_a $histo_b > /dev/null && match='pass'
197 echo "Compared $histo_a and $histo_b: $match" | ./logger.sh check >> $logfile
199 if [ $match = 'pass' ] ; then
206 compare_histograms() {
210 fmt=$(echo $format | tr '[:upper:]' '[:lower:]')
211 size=$(vsp1_entity_get_size wpf.$wpf 1)
213 reference_histogram ref-histogram.bin $format $size
216 for histo in histo-*.bin ; do
217 (compare_histogram $histo ref-histogram.bin) || {
218 mv $histo ${0/.sh/}-${histo/.bin/-$fmt.bin} ;
223 if [ $result = "fail" ] ; then
224 mv ref-histogram.bin ${0/.sh/}-ref-histogram-$fmt.bin
226 rm -f ref-histogram.bin
232 # ------------------------------------------------------------------------------
233 # Pipeline configuration
244 bru_output=$(vsp1_count_bru_inputs)
246 for input in `seq 0 1 $((ninputs-1))` ; do
247 $mediactl -d $mdev -l "'$dev rpf.$input':1 -> '$dev bru':$input [1]"
249 $mediactl -d $mdev -l "'$dev bru':$bru_output -> '$dev wpf.0':0 [1]"
250 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
254 bru_output=$(vsp1_count_bru_inputs)
256 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev bru':0 [1]"
257 $mediactl -d $mdev -l "'$dev bru':$bru_output -> '$dev uds.0':0 [1]"
258 $mediactl -d $mdev -l "'$dev uds.0':1 -> '$dev wpf.0':0 [1]"
259 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
263 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev wpf.0':0 [1]"
264 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev hgo':0 [1]"
265 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
269 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev uds.0':0 [1]"
270 $mediactl -d $mdev -l "'$dev uds.0':1 -> '$dev wpf.0':0 [1]"
271 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
275 bru_output=$(vsp1_count_bru_inputs)
277 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev uds.0':0 [1]"
278 $mediactl -d $mdev -l "'$dev uds.0':1 -> '$dev bru':0 [1]"
279 $mediactl -d $mdev -l "'$dev bru':$bru_output -> '$dev wpf.0':0 [1]"
280 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
287 $mediactl -d $mdev -l "'$dev rpf.$rpf':1 -> '$dev wpf.$wpf':0 [1]"
288 $mediactl -d $mdev -l "'$dev wpf.$wpf':1 -> '$dev wpf.$wpf output':0 [1]"
292 $mediactl -d $mdev -r
303 # ------------------------------------------------------------------------------
304 # Format Configuration
307 format_v4l2_to_mbus() {
309 RGB332 | ARGB555 | XRGB555 | RGB565 | BGR24 | RGB24 | XBGR32 | XRGB32 | ABGR32 | ARGB32)
313 NV12M | NV16M | NV21M | NV61M | UYVY | VYUY | YUV420M | YUYV | YVYU)
318 echo "Invalid format $1" >&2
319 echo -e "Valid formats are
320 \tRGB332, ARGB555, XRGB555, RGB565, BGR24, RGB24,
321 \tXBGR32, XRGB32, ABGR32, ARGB32,
322 \tNV12M, NV16M, NV21M, NV61M, UYVY, VYUY, YUV420M, YUYV, YVYU" >&2
327 format_v4l2_is_yuv() {
328 local format=$(format_v4l2_to_mbus $1)
329 [ $format = 'AYUV32' ]
333 format=$(format_v4l2_to_mbus $1)
337 $mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$format/$size]"
341 format=$(format_v4l2_to_mbus $1)
346 bru_output=$(vsp1_count_bru_inputs)
348 for input in `seq 0 1 $((ninputs-1))` ; do
349 offset=$((offset+50))
350 $mediactl -d $mdev -V "'$dev rpf.$input':0 [fmt:$format/$size]"
351 $mediactl -d $mdev -V "'$dev bru':$input [fmt:$format/$size compose:($offset,$offset)/$size]"
354 $mediactl -d $mdev -V "'$dev bru':$bru_output [fmt:$format/$size]"
355 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$format/$size]"
356 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$format/$size]"
359 format_rpf_bru_uds() {
360 infmt=$(format_v4l2_to_mbus $1)
362 outfmt=$(format_v4l2_to_mbus $3)
365 bru_output=$(vsp1_count_bru_inputs)
367 $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]"
368 $mediactl -d $mdev -V "'$dev bru':0 [fmt:$infmt/$insize]"
369 $mediactl -d $mdev -V "'$dev bru':$bru_output [fmt:$infmt/$insize]"
370 $mediactl -d $mdev -V "'$dev uds.0':0 [fmt:$infmt/$insize]"
371 $mediactl -d $mdev -V "'$dev uds.0':1 [fmt:$infmt/$outsize]"
372 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]"
373 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]"
377 format=$(format_v4l2_to_mbus $1)
380 compose=${4:+compose:$4}
382 $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$format/$size]"
383 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$format/$size]"
384 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$format/$size]"
385 $mediactl -d $mdev -V "'$dev hgo':0 [fmt:$format/$size $crop $compose]"
389 infmt=$(format_v4l2_to_mbus $1)
391 outfmt=$(format_v4l2_to_mbus $3)
394 $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]"
395 $mediactl -d $mdev -V "'$dev uds.0':0 [fmt:$infmt/$insize]"
396 $mediactl -d $mdev -V "'$dev uds.0':1 [fmt:$infmt/$outsize]"
397 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]"
398 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]"
401 format_rpf_uds_bru() {
402 infmt=$(format_v4l2_to_mbus $1)
404 outfmt=$(format_v4l2_to_mbus $3)
407 bru_output=$(vsp1_count_bru_inputs)
409 $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]"
410 $mediactl -d $mdev -V "'$dev uds.0':0 [fmt:$infmt/$insize]"
411 $mediactl -d $mdev -V "'$dev uds.0':1 [fmt:$infmt/$outsize]"
412 $mediactl -d $mdev -V "'$dev bru':0 [fmt:$infmt/$outsize]"
413 $mediactl -d $mdev -V "'$dev bru':$bru_output [fmt:$infmt/$outsize]"
414 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]"
415 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]"
421 infmt=$(format_v4l2_to_mbus $3)
423 outfmt=$(format_v4l2_to_mbus $5)
426 if [ x$crop != 'x' ] ; then
428 outsize=$(echo $crop | sed 's/.*\///')
433 $mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$infmt/$size]"
434 $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$infmt/$size $crop]"
435 $mediactl -d $mdev -V "'$dev wpf.$wpf':1 [fmt:$outfmt/$outsize]"
439 format=$(format_v4l2_to_mbus $1)
443 $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$format/$size]"
444 $mediactl -d $mdev -V "'$dev wpf.$wpf':1 [fmt:$format/$size]"
454 # ------------------------------------------------------------------------------
465 for mdev in /dev/media* ; do
467 for feature in $features ; do
468 $(vsp1_has_feature $feature) || {
474 if [ $match == 'true' ] ; then
479 if [ $match == 'false' ] ; then
480 echo "No device found with feature set $features" | ./logger.sh config >> $logfile
484 dev=$(vsp1_device $mdev)
485 echo "Using device $mdev ($dev)" | ./logger.sh config >> $logfile
487 vsp_runner=./vsp-runner.sh
491 echo "Testing $1" | ./logger.sh >> $logfile
492 echo -n "Testing $1: " >&2
496 echo "Done: $1" | ./logger.sh >> $logfile