e92eda12adcb2ef4b280e60b5eeb1aa083550b27
[renesas/vsp-tests.git] / scripts / vsp-runner.sh
1 #!/bin/sh
2
3 set -e
4
5 source vsp-lib.sh
6
7 mediactl='media-ctl'
8 yavta='yavta'
9
10 # ------------------------------------------------------------------------------
11 # Format retrieval
12 #
13
14 frame_reference() {
15         format=$1
16         size=$2
17
18         lcfmt=`echo $infmt | tr '[:upper:]' '[:lower:]'`
19
20         case $format in
21         ARGB555)
22                 echo "frames/frame-reference-$lcfmt-$size-alpha255.bin"
23                 ;;
24         ABGR32 | ARGB32)
25                 echo "frames/frame-reference-$lcfmt-$size-alpha200.bin"
26                 ;;
27         XRGB555 | XBGR32 | XRGB32)
28                 echo "frames/frame-reference-$lcfmt-$size-alpha0.bin"
29                 ;;
30         *)
31                 echo "frames/frame-reference-$lcfmt-$size.bin"
32                 ;;
33         esac
34 }
35
36 # ------------------------------------------------------------------------------
37 # Parse the command line and retrieve the formats
38 #
39
40 syntax() {
41         echo "Syntax: vsp-runner.sh dev cmd [...]"
42         echo ""
43         echo "Supported commands:"
44         echo "    hgo [options]"
45         echo "    input index infmt [options]"
46         echo "    output index outfmt [options]"
47 }
48
49 parse() {
50         if [ $# -lt 2 ] ; then
51                 syntax
52                 return 1
53         fi
54
55         mdev=$1
56         dev=`$mediactl -d $mdev -p | grep 'bus info' | sed 's/.*platform://'`
57
58         if [ -z $dev ] ; then
59                 echo "Error: Device $dev doesn't exist"
60                 syntax
61                 return 1
62         fi
63
64         cmd=$2
65
66         case $cmd in
67         hgo)
68                 options=$3
69                 ;;
70
71         input)
72                 index=$3
73                 infmt=$4
74                 options=$5
75                 ;;
76
77         output)
78                 index=$3
79                 outfmt=$4
80                 options=$5
81                 ;;
82
83         *)
84                 echo "Invalid command $cmd"
85                 ;;
86         esac
87 }
88
89 # ------------------------------------------------------------------------------
90 # Execute the command
91 #
92
93 execute() {
94         case $cmd in
95         hgo)
96                 if [ "x$options" = xinfinite ] ; then
97                         $yavta -c -n 4 \
98                                 `$mediactl -d $mdev -e "$dev hgo histo"`
99                 else
100                         $yavta -c10 -n 10 --file=histo-#.bin $options \
101                                 `$mediactl -d $mdev -e "$dev hgo histo"`
102                 fi
103                 ;;
104
105         input)
106                 rpf=rpf.$index
107                 size=$(vsp1_entity_get_size $rpf 0)
108
109                 file=$(frame_reference $infmt $size)
110
111                 if [ "x$options" = xinfinite ] ; then
112                         $yavta -c -n 4 -f $infmt -s $size --file=$file $options \
113                                 `$mediactl -d $mdev -e "$dev $rpf input"`
114                 else
115                         $yavta -c10 -n 4 -f $infmt -s $size --file=$file $options \
116                                 `$mediactl -d $mdev -e "$dev $rpf input"`
117                 fi
118                 ;;
119
120         output)
121                 wpf=wpf.$index
122                 size=$(vsp1_entity_get_size $wpf 1)
123
124                 if [ "x$options" = xinfinite ] ; then
125                         $yavta -c -n 4 -f $outfmt -s $size \
126                                 `$mediactl -d $mdev -e "$dev $wpf output"`
127                 else
128                         $yavta -c10 -n 4 -f $outfmt -s $size --skip 7 -F $options \
129                                 `$mediactl -d $mdev -e "$dev $wpf output"`
130                 fi
131                 ;;
132         esac
133 }
134
135 parse $* && execute