8 # ------------------------------------------------------------------------------
13 $mediactl -d $mdev -p | grep 'bus info' | sed 's/.*platform://'
17 $mediactl -d $mdev -p | grep 'model' | sed 's/.* //'
21 echo $(vsp1_model) | sed 's/-.*//'
26 local entity_name=$(echo $feature | sed 's/\[.*//')
28 ($mediactl -d $mdev -p | grep -q -- "- entity.*$entity_name") || return
30 local option=$(echo $feature | cut -d '[' -f 2 -s | cut -d ']' -f 1)
32 [ -z $option ] && return
34 local key=$(echo $option | sed 's/:.*//')
35 local value=$(echo $option | sed "s/.*:'\(.*\)'/\1/")
39 vsp1_has_control $entity_name "$value"
49 $mediactl -d $mdev -p | grep -- '- entity.*rpf.[0-9] [^i]' | wc -l
53 $mediactl -d $mdev -p | grep -- '- entity.*wpf.[0-9] [^o]' | wc -l
56 vsp1_count_bru_inputs() {
57 local num_pads=`media-ctl -p | grep 'entity.*bru' | sed 's/.*(\([0-9]\) pads.*/\1/'`
61 vsp1_entity_subdev() {
62 $mediactl -d $mdev -e "$dev $1"
65 vsp1_entity_get_size() {
69 $mediactl -d $mdev --get-v4l2 "'$dev $entity':$pad" | grep fmt | \
70 sed 's/.*\/\([0-9x]*\).*/\1/'
74 local subdev=$(vsp1_entity_subdev $1)
75 local control_name=$(echo $2 | tr '+' ' ')
77 $yavta --no-query -l $subdev | grep -q -- "$control_name"
82 local control_name=$(echo $2 | tr '+' ' ')
85 local subdev=$(vsp1_entity_subdev $entity)
86 local control=$($yavta --no-query -l $subdev | grep -- "$control_name" | cut -d ' ' -f 2)
88 echo "Setting control $control_name ($control) to $value" | ./logger.sh "$entity" >> $logfile
89 $yavta --no-query -w "$control $value" $subdev | ./logger.sh "$entity" >> $logfile
92 # -----------------------------------------------------------------------------
93 # Referance frame generation
106 # Start with the input format to compute the alpha value being used by
107 # the RPF after unpacking. Keep in sync with generate_input_frame.
110 # The 1-bit alpha value is expanded to 8 bits by copying the
111 # high order bits, resulting in value of 255 after unpacking.
115 # 8-bit alpha value, hardcoded to 200.
119 # In all other cases the alpha value is set through a control
120 # whose default value is 255.
125 # Convert the input alpha value based on the output format.
127 ARGB555 | ABGR32 | ARGB32)
128 # Pass the 8-bit alpha value unchanged to the image generator.
131 # The format has the X bit hardcoded to 0.
135 # In all other cases the alpha value is set through a control
136 # whose default value is 255.
143 local name=$(echo $arg | cut -d '=' -f 1)
144 local value=$(echo $arg | cut -d '=' -f 2)
148 options="$options --clu $value"
151 [ x$value = x1 ] && options="$options --hflip"
154 options="$options --lut $value"
157 [ x$value = x90 ] && {
158 options="$options --rotate" ;
159 __vsp_pixel_perfect=false ;
163 [ x$value = x1 ] && options="$options --vflip"
168 [ x$__vsp_bru_inputs != x ] && options="$options -c $__vsp_bru_inputs"
170 $genimage -i $in_format -f $out_format -s $size -a $alpha $options -o $file \
171 frames/frame-reference-1024x768.pnm
174 reference_histogram() {
179 $genimage -i $format -f $format -s $size -H $file \
180 frames/frame-reference-1024x768.pnm
183 # ------------------------------------------------------------------------------
184 # Image and histogram comparison
188 # Compare the two frames for exact match.
190 compare_frame_exact() {
195 diff -q $img_a $img_b > /dev/null && match='pass'
197 echo "Compared $img_a and $img_b: $match" | ./logger.sh check >> $logfile
199 if [ $match = 'pass' ] ; then
207 # Compare the two frames using a fuzzy match algorithm to account for errors
208 # introduced by the YUV packing. Accept a maximum 1% mean average error over
209 # the whole frame with no more than 5% of the pixels differing.
211 compare_frame_fuzzy() {
212 local fmt=$(echo $1 | sed 's/M$/P/')
217 local pnm_a=${img_a/bin/pnm}
218 local pnm_b=${img_b/bin/pnm}
220 raw2rgbpnm -f $fmt -s $size $img_a $pnm_a > /dev/null
221 raw2rgbpnm -f $fmt -s $size $img_b $pnm_b > /dev/null
223 local ae=$(compare -metric ae $pnm_a $pnm_b /dev/null 2>&1)
224 local mae=$(compare -metric mae $pnm_a $pnm_b /dev/null 2>&1 | sed 's/.*(\(.*\))/\1/')
229 local width=$(echo $size | cut -d 'x' -f 1)
230 local height=$(echo $size | cut -d 'x' -f 2)
232 local ae_match=$(echo $ae $width $height | awk '{ if ($1 / $2 / $3 < 0.05) { print "pass" } else { print "fail" } }')
233 local mae_match=$(echo $mae | awk '{ if ($1 < 0.01) { print "pass" } else { print "fail" } }')
235 echo "Compared $img_a and $img_b: ae $ae ($ae_match) mae $mae ($mae_match)" | ./logger.sh check >> $logfile
237 if [ $ae_match = 'pass' -a $mae_match = 'pass' ] ; then
246 local in_format=$__vsp_rpf_format
247 local out_format=$__vsp_wpf_format
248 local wpf=$__vsp_wpf_index
250 local in_fmt=$(echo $in_format | tr '[:upper:]' '[:lower:]')
251 local out_fmt=$(echo $out_format | tr '[:upper:]' '[:lower:]')
252 local size=$(vsp1_entity_get_size wpf.$wpf 1)
254 reference_frame ${frames_dir}ref-frame.bin $in_format $out_format $size $args
258 local params=${args// /-}
259 params=${params:+-$params}
260 params=${params//\//_}
261 params=$in_fmt-$out_fmt-$size$params
263 if [ x$__vsp_pixel_perfect != xtrue ] ; then
267 for frame in ${frames_dir}frame-*.bin ; do
270 (compare_frame_$method $out_format $size $frame ${frames_dir}ref-frame.bin) || {
275 if [ $match = "false" -o x$VSP_KEEP_FRAMES = x1 ] ; then
276 mv $frame ${0/.sh/}-$(basename ${frame/.bin/-$params.bin})
280 if [ x$VSP_KEEP_FRAMES = x1 -o $result = "fail" ] ; then
281 mv ${frames_dir}ref-frame.bin ${0/.sh/}-ref-frame-$params.bin
283 rm -f ${frames_dir}ref-frame.bin
284 rm -f ${frames_dir}frame-*.bin
290 compare_histogram() {
295 diff -q $histo_a $histo_b > /dev/null && match='pass'
297 echo "Compared $histo_a and $histo_b: $match" | ./logger.sh check >> $logfile
299 if [ $match = 'pass' ] ; then
306 compare_histograms() {
307 local format=$__vsp_wpf_format
308 local wpf=$__vsp_wpf_index
310 local fmt=$(echo $format | tr '[:upper:]' '[:lower:]')
311 local size=$(vsp1_entity_get_size wpf.$wpf 1)
313 reference_histogram ${frames_dir}ref-histogram.bin $format $size
316 for histo in ${frames_dir}histo-*.bin ; do
317 (compare_histogram $histo ${frames_dir}ref-histogram.bin) || {
318 mv $histo ${0/.sh/}-$(basename ${histo/.bin/-$fmt.bin}) ;
323 if [ $result = "fail" ] ; then
324 mv ${frames_dir}ref-histogram.bin ${0/.sh/}-ref-histogram-$fmt.bin
326 rm -f ${frames_dir}ref-histogram.bin
327 rm -f ${frames_dir}histo-*.bin
333 # ------------------------------------------------------------------------------
334 # Pipeline configuration
345 local bru_output=$(vsp1_count_bru_inputs)
347 for input in `seq 0 1 $((ninputs-1))` ; do
348 $mediactl -d $mdev -l "'$dev rpf.$input':1 -> '$dev bru':$input [1]"
350 $mediactl -d $mdev -l "'$dev bru':$bru_output -> '$dev wpf.0':0 [1]"
351 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
353 __vsp_bru_inputs=$ninputs
358 local bru_output=$(vsp1_count_bru_inputs)
360 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev bru':0 [1]"
361 $mediactl -d $mdev -l "'$dev bru':$bru_output -> '$dev uds.0':0 [1]"
362 $mediactl -d $mdev -l "'$dev uds.0':1 -> '$dev wpf.0':0 [1]"
363 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
369 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev clu':0 [1]"
370 $mediactl -d $mdev -l "'$dev clu':1 -> '$dev wpf.0':0 [1]"
371 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
377 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev wpf.0':0 [1]"
378 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev hgo':0 [1]"
379 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
385 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev hst':0 [1]"
386 $mediactl -d $mdev -l "'$dev hst':1 -> '$dev wpf.0':0 [1]"
387 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
393 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev lut':0 [1]"
394 $mediactl -d $mdev -l "'$dev lut':1 -> '$dev wpf.0':0 [1]"
395 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
401 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev uds.0':0 [1]"
402 $mediactl -d $mdev -l "'$dev uds.0':1 -> '$dev wpf.0':0 [1]"
403 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
409 local bru_output=$(vsp1_count_bru_inputs)
411 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev uds.0':0 [1]"
412 $mediactl -d $mdev -l "'$dev uds.0':1 -> '$dev bru':0 [1]"
413 $mediactl -d $mdev -l "'$dev bru':$bru_output -> '$dev wpf.0':0 [1]"
414 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
420 $mediactl -d $mdev -l "'$dev rpf.0':1 -> '$dev sru':0 [1]"
421 $mediactl -d $mdev -l "'$dev sru':1 -> '$dev wpf.0':0 [1]"
422 $mediactl -d $mdev -l "'$dev wpf.0':1 -> '$dev wpf.0 output':0 [1]"
431 $mediactl -d $mdev -l "'$dev rpf.$rpf':1 -> '$dev wpf.$wpf':0 [1]"
432 $mediactl -d $mdev -l "'$dev wpf.$wpf':1 -> '$dev wpf.$wpf output':0 [1]"
438 $mediactl -d $mdev -r
444 __vsp_pixel_perfect=true
455 # ------------------------------------------------------------------------------
456 # Format Configuration
459 format_v4l2_to_mbus() {
461 RGB332 | ARGB555 | XRGB555 | RGB565 | BGR24 | RGB24 | XBGR32 | XRGB32 | ABGR32 | ARGB32)
466 echo "AHSV8888_1X32";
469 UYVY | VYUY | YUYV | YVYU | NV12M | NV16M | NV21M | NV61M | YUV420M | YUV422M | YUV444M | YVU420M | YVU422M | YVU444M)
474 echo "Invalid format $1" >&2
475 echo -e "Valid formats are
476 \tRGB332, ARGB555, XRGB555, RGB565, BGR24, RGB24,
477 \tXBGR32, XRGB32, ABGR32, ARGB32, HSV24, HSV32
478 \tUYVY, VYUY, YUYV, YVYU,
479 \tNV12M, NV16M, NV21M, NV61M,
480 \tYUV420M, YUV422M, YUV444M,
481 \tYVU420M, YVU422M, YVU444M" >&2
486 format_v4l2_is_yuv() {
487 local format=$(format_v4l2_to_mbus $1)
488 [ $format = 'AYUV32' ]
492 local format=$(format_v4l2_to_mbus $1)
496 $mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$format/$size]"
502 local format=$(format_v4l2_to_mbus $1)
507 local bru_output=$(vsp1_count_bru_inputs)
509 for input in `seq 0 1 $((ninputs-1))` ; do
510 offset=$((offset+50))
511 $mediactl -d $mdev -V "'$dev rpf.$input':0 [fmt:$format/$size]"
512 $mediactl -d $mdev -V "'$dev bru':$input [fmt:$format/$size compose:($offset,$offset)/$size]"
515 $mediactl -d $mdev -V "'$dev bru':$bru_output [fmt:$format/$size]"
516 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$format/$size]"
517 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$format/$size]"
523 format_rpf_bru_uds() {
524 local infmt=$(format_v4l2_to_mbus $1)
526 local outfmt=$(format_v4l2_to_mbus $3)
529 local bru_output=$(vsp1_count_bru_inputs)
531 $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]"
532 $mediactl -d $mdev -V "'$dev bru':0 [fmt:$infmt/$insize]"
533 $mediactl -d $mdev -V "'$dev bru':$bru_output [fmt:$infmt/$insize]"
534 $mediactl -d $mdev -V "'$dev uds.0':0 [fmt:$infmt/$insize]"
535 $mediactl -d $mdev -V "'$dev uds.0':1 [fmt:$infmt/$outsize]"
536 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]"
537 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]"
539 [ $insize != $outsize ] && __vsp_pixel_perfect=false
545 local format=$(format_v4l2_to_mbus $1)
548 $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$format/$size]"
549 $mediactl -d $mdev -V "'$dev clu':0 [fmt:$format/$size]"
550 $mediactl -d $mdev -V "'$dev clu':1 [fmt:$format/$size]"
551 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$format/$size]"
552 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$format/$size]"
559 local format=$(format_v4l2_to_mbus $1)
562 $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$format/$size]"
563 $mediactl -d $mdev -V "'$dev hst':0 [fmt:$format/$size]"
564 $mediactl -d $mdev -V "'$dev hst':1 [fmt:AHSV8888_1X32/$size]"
565 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:AHSV8888_1X32/$size]"
566 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:AHSV8888_1X32/$size]"
573 local format=$(format_v4l2_to_mbus $1)
575 local crop=${3:+crop:$3}
576 local compose=${4:+compose:$4}
578 $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$format/$size]"
579 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$format/$size]"
580 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$format/$size]"
581 $mediactl -d $mdev -V "'$dev hgo':0 [fmt:$format/$size $crop $compose]"
588 local format=$(format_v4l2_to_mbus $1)
591 $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$format/$size]"
592 $mediactl -d $mdev -V "'$dev lut':0 [fmt:$format/$size]"
593 $mediactl -d $mdev -V "'$dev lut':1 [fmt:$format/$size]"
594 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$format/$size]"
595 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$format/$size]"
602 local infmt=$(format_v4l2_to_mbus $1)
604 local outfmt=$(format_v4l2_to_mbus $3)
607 $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]"
608 $mediactl -d $mdev -V "'$dev uds.0':0 [fmt:$infmt/$insize]"
609 $mediactl -d $mdev -V "'$dev uds.0':1 [fmt:$infmt/$outsize]"
610 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]"
611 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]"
613 [ $insize != $outsize ] && __vsp_pixel_perfect=false
618 format_rpf_uds_bru() {
619 local infmt=$(format_v4l2_to_mbus $1)
621 local outfmt=$(format_v4l2_to_mbus $3)
624 local bru_output=$(vsp1_count_bru_inputs)
626 $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]"
627 $mediactl -d $mdev -V "'$dev uds.0':0 [fmt:$infmt/$insize]"
628 $mediactl -d $mdev -V "'$dev uds.0':1 [fmt:$infmt/$outsize]"
629 $mediactl -d $mdev -V "'$dev bru':0 [fmt:$infmt/$outsize]"
630 $mediactl -d $mdev -V "'$dev bru':$bru_output [fmt:$infmt/$outsize]"
631 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]"
632 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]"
634 [ $insize != $outsize ] && __vsp_pixel_perfect=false
640 local infmt=$(format_v4l2_to_mbus $1)
642 local outfmt=$(format_v4l2_to_mbus $3)
645 $mediactl -d $mdev -V "'$dev rpf.0':0 [fmt:$infmt/$insize]"
646 $mediactl -d $mdev -V "'$dev sru':0 [fmt:$infmt/$insize]"
647 $mediactl -d $mdev -V "'$dev sru':1 [fmt:$infmt/$outsize]"
648 $mediactl -d $mdev -V "'$dev wpf.0':0 [fmt:$infmt/$outsize]"
649 $mediactl -d $mdev -V "'$dev wpf.0':1 [fmt:$outfmt/$outsize]"
651 __vsp_pixel_perfect=false
659 local infmt=$(format_v4l2_to_mbus $3)
661 local outfmt=$(format_v4l2_to_mbus $5)
665 if [ x$crop != 'x' ] ; then
667 outsize=$(echo $crop | sed 's/.*\///')
672 $mediactl -d $mdev -V "'$dev rpf.$rpf':0 [fmt:$infmt/$size]"
673 $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$infmt/$size $crop]"
674 $mediactl -d $mdev -V "'$dev wpf.$wpf':1 [fmt:$outfmt/$outsize]"
681 local format=$(format_v4l2_to_mbus $1)
685 $mediactl -d $mdev -V "'$dev wpf.$wpf':0 [fmt:$format/$size]"
686 $mediactl -d $mdev -V "'$dev wpf.$wpf':1 [fmt:$format/$size]"
698 # ------------------------------------------------------------------------------
699 # Frame capture and output
702 generate_input_frame() {
717 XRGB555 | XBGR32 | XRGB32)
725 $(format_v4l2_is_yuv $format) && options="$options -C -i YUV444M"
727 $genimage -f $format -s $size -a $alpha $options -o $file \
728 frames/frame-reference-1024x768.pnm
741 for option in $* ; do
744 buffers=${option/--buffers=/}
748 count=${option/--count=/}
752 pause=${option/--pause=/}
756 skip=${option/--skip=/}
772 videodev=$(vsp1_entity_subdev "hgo histo")
773 file="${frames_dir}histo-#.bin"
778 videodev=$(vsp1_entity_subdev "$entity input")
779 format=$__vsp_rpf_format
780 size=$(vsp1_entity_get_size $entity 0)
781 file=${frames_dir}${entity}.bin
782 generate_input_frame $file $format $size
786 videodev=$(vsp1_entity_subdev "$entity output")
787 format=$__vsp_wpf_format
788 size=$(vsp1_entity_get_size $entity 1)
789 file="${frames_dir}frame-#.bin"
793 $yavta -c$count -n $buffers ${format:+-f $format} ${size:+-s $size} \
794 ${skip:+--skip $skip} ${file:+--file=$file} ${pause:+-p$pause} \
795 $videodev | ./logger.sh $entity >> $logfile
804 videodev=$(vsp1_entity_subdev "hgo histo")
808 videodev=$(vsp1_entity_subdev "$entity input")
812 videodev=$(vsp1_entity_subdev "$entity output")
818 for pid in $(pidof yavta) ; do
819 (ls -l /proc/$pid/fd/ | grep -q "$videodev$") && {
830 while [ $timeout != 0 ] ; do
831 pid=$(vsp_runner_find $1)
832 [ x$pid != x ] && break
834 timeout=$((timeout-1))
837 [ x$pid != x ] || return
839 while [ ! -f .yavta.wait.$pid ] ; do
844 vsp_runner_resume() {
845 local pid=$(vsp_runner_find $1)
847 [ x$pid != x ] && kill -USR1 $pid
850 # ------------------------------------------------------------------------------
855 export logfile=${1/sh/log}
857 local optional_features=$3
862 local best_features_count=0
865 for mdev in /dev/media* ; do
866 dev=$(vsp1_device $mdev)
869 for feature in $features ; do
870 $(vsp1_has_feature "$feature") || {
876 if [ $match == 'false' ] ; then
880 if [ -z "$optional_features" ] ; then
885 local features_count=0
886 for feature in $optional_features ; do
887 $(vsp1_has_feature "$feature") && {
888 features_count=$((features_count+1))
894 if [ $features_count -ge $best_features_count ] ; then
896 best_features_count=$features_count
900 if [ -z $best_mdev ] ; then
901 echo "No device found with feature set \`$features'" | ./logger.sh config >> $logfile
902 echo "Test requires unavailable feature set \`$features': skipped" >&2
907 dev=$(vsp1_device $mdev)
908 echo "Using device $mdev ($dev)" | ./logger.sh config >> $logfile
910 vsp_runner=./vsp-runner.sh
914 echo "Testing $1" | ./logger.sh >> $logfile
915 echo -n "Testing $1: " >&2
919 echo "Done: $1" | ./logger.sh >> $logfile
922 rm -f ${frames_dir}frame-*.bin
923 rm -f ${frames_dir}histo-*.bin
924 rm -f ${frames_dir}rpf.*.bin
928 test_main | ./logger.sh error >> $logfile