v4l2-compliance: fix frequency tests
authorHans Verkuil <hans.verkuil@cisco.com>
Fri, 13 Jan 2012 09:44:22 +0000 (10:44 +0100)
committerHans Verkuil <hans.verkuil@cisco.com>
Fri, 13 Jan 2012 09:44:22 +0000 (10:44 +0100)
1) If you set a frequency that is out of range then the spec says that the
   driver must map it to the closest valid frequency.

2) Assume that radio devices are either tuners or modulators but not both.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/v4l2-compliance/v4l2-test-input-output.cpp

index 2c9f0bf739a0b5205033be97d28034e0c718152b..efb9bd090157a15d3b5a77095e410063a288088b 100644 (file)
@@ -207,19 +207,22 @@ int testTunerFreq(struct node *node)
                        return fail("could not set rangehigh frequency\n");
                freq.frequency = tuner.rangelow - 1;
                ret = doioctl(node, VIDIOC_S_FREQUENCY, &freq);
-               if (ret != EINVAL)
-                       return fail("set rangelow-1 frequency did not return EINVAL\n");
+               if (ret)
+                       return fail("could not set rangelow-1 frequency\n");
+               ret = doioctl(node, VIDIOC_G_FREQUENCY, &freq);
+               if (ret || freq.frequency != tuner.rangelow)
+                       return fail("frequency rangelow-1 wasn't mapped to rangelow\n");
                freq.frequency = tuner.rangehigh + 1;
                ret = doioctl(node, VIDIOC_S_FREQUENCY, &freq);
-               if (ret != EINVAL)
-                       return fail("set rangehigh+1 frequency did not return EINVAL\n");
+               if (ret)
+                       return fail("could not set rangehigh+1 frequency\n");
+               ret = doioctl(node, VIDIOC_G_FREQUENCY, &freq);
+               if (ret || freq.frequency != tuner.rangehigh)
+                       return fail("frequency rangehigh+1 wasn't mapped to rangehigh\n");
        }
 
-       /* There is an ambiguity in the API and G/S_FREQUENCY: you cannot specify
-          correctly whether to the ioctl is for a tuner or a modulator. This should
-          be corrected, but until then the tests below have to be skipped if there
-          is a modulator of index t. */
-       if (node->modulators > t)
+       /* If this is a modulator device, then skip the remaining tests */
+       if (node->caps & V4L2_CAP_MODULATOR)
                return 0;
 
        freq.tuner = t;
@@ -542,19 +545,22 @@ int testModulatorFreq(struct node *node)
                        return fail("could not set rangehigh frequency\n");
                freq.frequency = modulator.rangelow - 1;
                ret = doioctl(node, VIDIOC_S_FREQUENCY, &freq);
-               if (ret != EINVAL)
-                       return fail("set rangelow-1 frequency did not return EINVAL\n");
+               if (ret)
+                       return fail("could not set rangelow-1 frequency\n");
+               ret = doioctl(node, VIDIOC_G_FREQUENCY, &freq);
+               if (ret || freq.frequency != modulator.rangelow)
+                       return fail("frequency rangelow-1 wasn't mapped to rangelow\n");
                freq.frequency = modulator.rangehigh + 1;
                ret = doioctl(node, VIDIOC_S_FREQUENCY, &freq);
-               if (ret != EINVAL)
-                       return fail("set rangehigh+1 frequency did not return EINVAL\n");
+               if (ret)
+                       return fail("could not set rangehigh+1 frequency\n");
+               ret = doioctl(node, VIDIOC_G_FREQUENCY, &freq);
+               if (ret || freq.frequency != modulator.rangehigh)
+                       return fail("frequency rangehigh+1 wasn't mapped to rangehigh\n");
        }
 
-       /* There is an ambiguity in the API and G/S_FREQUENCY: you cannot specify
-          correctly whether to the ioctl is for a tuner or a modulator. This should
-          be corrected, but until then the tests below have to be skipped if there
-          is a tuner of index m. */
-       if (node->tuners > m)
+       /* If this is a tuner device, then skip the remaining tests */
+       if (node->caps & V4L2_CAP_TUNER)
                return 0;
 
        freq.tuner = m;