From 9944d12c8692600229b59857bb4622035ab70551 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 20 Jun 2016 00:44:41 +0300 Subject: vsp-lib: Add support for pausing and resuming yavta When the --pause argument to vsp_runner() is specified, the corresponding yavta instance will pause after capturing or outputting the given number of frames and wait for a signal before resuming. The new vsp_runner_wait() and vsp_runner_resume() functions can be used to respectively wait for yavta to pause and instruct it to resume. Signed-off-by: Laurent Pinchart --- scripts/vsp-lib.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh index bf80aa0..a2af586 100755 --- a/scripts/vsp-lib.sh +++ b/scripts/vsp-lib.sh @@ -249,6 +249,7 @@ compare_frames() { mv ref-frame.bin ${0/.sh/}-ref-frame-$params.bin else rm -f ref-frame.bin + rm -f frame-*.bin fi echo $result @@ -291,6 +292,7 @@ compare_histograms() { mv ref-histogram.bin ${0/.sh/}-ref-histogram-$fmt.bin else rm -f ref-histogram.bin + rm -f histo-*.bin fi echo $result @@ -649,6 +651,7 @@ vsp_runner() { local option local buffers=4 local count=10 + local pause= local skip=7 for option in $* ; do @@ -661,6 +664,10 @@ vsp_runner() { count=${option/--count=/} ;; + --pause=*) + pause=${option/--pause=/} + ;; + --skip=*) skip=${option/--skip=/} ;; @@ -700,8 +707,60 @@ vsp_runner() { esac $yavta -c$count -n $buffers ${format:+-f $format} ${size:+-s $size} \ - ${skip:+--skip $skip} ${file:+--file=$file} $videodev \ - | ./logger.sh $entity >> $logfile + ${skip:+--skip $skip} ${file:+--file=$file} ${pause:+-p$pause} \ + $videodev | ./logger.sh $entity >> $logfile +} + +vsp_runner_find() { + local entity=$1 + local videodev + + case $entity in + hgo) + videodev=$(vsp1_entity_subdev "hgo histo") + ;; + + rpf.*) + videodev=$(vsp1_entity_subdev "$entity input") + ;; + + wpf.*) + videodev=$(vsp1_entity_subdev "$entity output") + ;; + esac + + local pid + + for pid in $(pidof yavta) ; do + (ls -l /proc/$pid/fd/ | grep -q "$videodev$") && { + echo $pid ; + break + } + done +} + +vsp_runner_wait() { + local timeout=5 + local pid + + while [ $timeout != 0 ] ; do + pid=$(vsp_runner_find $1) + [ x$pid != x ] && break + sleep 1 + timeout=$((timeout-1)) + done + + [ x$pid != x ] || return + + while [ ! -f .yavta.wait.$pid ] ; do + sleep 1 + done +} + +vsp_runner_resume() { + local pid=$(vsp_runner_find $1) + + [ x$pid != x ] && kill -USR1 $pid } # ------------------------------------------------------------------------------ -- cgit v1.2.3