vsp-lib: Support controls as device features
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Fri, 27 May 2016 12:57:36 +0000 (15:57 +0300)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sun, 19 Jun 2016 12:26:01 +0000 (15:26 +0300)
Enhance the feature checking code to allow checking for the presence of
a particular control on a particular entity.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
scripts/vsp-lib.sh

index 0e7fa5a..f6fd342 100755 (executable)
@@ -14,8 +14,26 @@ vsp1_device() {
 
 vsp1_has_feature() {
        feature=$1
+       entity_name=$(echo $feature | sed 's/\[.*//')
 
-       $mediactl -d $mdev -p | grep -q -- "- entity.*$feature"
+       ($mediactl -d $mdev -p | grep -q -- "- entity.*$entity_name") || return
+
+       option=$(echo $feature | cut -d '[' -f 2 -s | cut -d ']' -f 1)
+
+       [ -z $option ] && return
+
+       key=$(echo $option | sed 's/:.*//')
+       value=$(echo $option | sed "s/.*:'\(.*\)'/\1/")
+
+       case $key in
+       control)
+               vsp1_has_control $entity_name "$value"
+               return
+               ;;
+       *)
+               return 1
+               ;;
+       esac
 }
 
 vsp1_count_rpfs() {
@@ -43,6 +61,13 @@ vsp1_entity_get_size() {
              sed 's/.*\/\([0-9x]*\).*/\1/'
 }
 
+vsp1_has_control() {
+       subdev=$(vsp1_entity_subdev $1)
+       control_name=$(echo $2 | tr '+' ' ')
+
+       $yavta --no-query -l $subdev | grep -q -- "$control_name"
+}
+
 # -----------------------------------------------------------------------------
 # Referance frame generation
 #
@@ -472,9 +497,11 @@ test_init() {
        best_features_count=0
 
        for mdev in /dev/media* ; do
+               dev=$(vsp1_device $mdev)
+
                match='true'
                for feature in $features ; do
-                       $(vsp1_has_feature $feature) || {
+                       $(vsp1_has_feature "$feature") || {
                                match='false';
                                break;
                        }
@@ -491,7 +518,7 @@ test_init() {
 
                features_count=0
                for feature in $optional_features ; do
-                       $(vsp1_has_feature $feature) && {
+                       $(vsp1_has_feature "$feature") && {
                                features_count=$((features_count+1))
                                match='false';
                                break;
@@ -510,7 +537,7 @@ test_init() {
        fi
 
        mdev=$best_mdev
-       dev=$(vsp1_device $best_mdev)
+       dev=$(vsp1_device $mdev)
        echo "Using device $mdev ($dev)" | ./logger.sh config >> $logfile
 
        vsp_runner=./vsp-runner.sh