v4l2-compliance: improve audmode checks.
authorHans Verkuil <hans.verkuil@cisco.com>
Wed, 12 Oct 2011 10:15:47 +0000 (12:15 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Wed, 12 Oct 2011 10:19:29 +0000 (12:19 +0200)
What drivers should return as audmode isn't as ambiguous as I thought.
So implement the proper checks.

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

index c77d00f..0200430 100644 (file)
@@ -7,8 +7,6 @@ here they won't be forgotten.
 - Should QUERYCAP report capabilities for only the current device node or
   'system wide'?
 
-- Are tuner audio modes other than MONO and STEREO allowed for FM receivers?
-
 - If I set a tuner audio mode to something that is not supported by the hardware,
   should the driver return an error, or silently modify the audio mode, or just
   accept it?
@@ -31,7 +29,7 @@ here they won't be forgotten.
 - ditto V4L2_FBUF_CAP_EXTERNOVERLAY: do bytesperline, sizeimage and base need to be
   set or not? Determine for overlay and output overlay.
 
-- RGB pixel formats: endianess issues: two tables in the spec.
+- RGB pixel formats: endianness issues: two tables in the spec.
 
 - Duplicate controls: V4L2_CID_EXPOSURE (user class) and V4L2_CID_EXPOSURE_ABSOLUTE
   (camera class).
index 44d2253..2c9f0bf 100644 (file)
@@ -36,7 +36,7 @@
 static int checkTuner(struct node *node, const struct v4l2_tuner &tuner,
                unsigned t, v4l2_std_id std)
 {
-       bool valid_modes[5] = { true, false, false, true, false };
+       bool valid_modes[5] = { true, false, false, false, false };
        bool tv = !node->is_radio;
        enum v4l2_tuner_type type = tv ? V4L2_TUNER_ANALOG_TV : V4L2_TUNER_RADIO;
        __u32 audmode;
@@ -58,6 +58,8 @@ static int checkTuner(struct node *node, const struct v4l2_tuner &tuner,
                return fail("did not expect to see V4L2_TUNER_CAP_LOW set for a tv tuner\n");
        if (!tv && !(tuner.capability & V4L2_TUNER_CAP_LOW))
                return fail("V4L2_TUNER_CAP_LOW was not set for a radio tuner\n");
+       if (tv && std == V4L2_STD_NTSC_M && (tuner.capability & V4L2_TUNER_CAP_LANG1))
+               return fail("LANG1 capability, but NTSC-M standard\n");
        if (tuner.rangelow >= tuner.rangehigh)
                return fail("rangelow >= rangehigh\n");
        if (tuner.rangelow == 0 || tuner.rangehigh == 0xffffffff)
@@ -78,13 +80,14 @@ static int checkTuner(struct node *node, const struct v4l2_tuner &tuner,
                return fail("LANG1 subchan, but NTSC-M standard\n");
        if (tuner.audmode > V4L2_TUNER_MODE_LANG1_LANG2)
                return fail("invalid audio mode\n");
-       // Ambiguous whether this is allowed or not
-       //              if (!tv && tuner.audmode > V4L2_TUNER_MODE_STEREO)
-       //                      return -16;
+       if (!tv && tuner.audmode > V4L2_TUNER_MODE_STEREO)
+               return fail("invalid audio mode for radio device\n");
        if (tuner.signal > 65535)
                return fail("signal too large\n");
        if (tuner.capability & V4L2_TUNER_CAP_STEREO)
                valid_modes[V4L2_TUNER_MODE_STEREO] = true;
+       if (tuner.capability & V4L2_TUNER_CAP_LANG1)
+               valid_modes[V4L2_TUNER_MODE_LANG1] = true;
        if (tuner.capability & V4L2_TUNER_CAP_LANG2) {
                valid_modes[V4L2_TUNER_MODE_LANG2] = true;
                valid_modes[V4L2_TUNER_MODE_LANG1_LANG2] = true;
@@ -100,11 +103,8 @@ static int checkTuner(struct node *node, const struct v4l2_tuner &tuner,
                        fail("failure to get new tuner audmode\n");
                if (tun.audmode > V4L2_TUNER_MODE_LANG1_LANG2)
                        return fail("invalid new audmode\n");
-               // Ambiguous whether this is allowed or not
-               //      if (!tv && tun.audmode > V4L2_TUNER_MODE_STEREO)
-               //              return -21;
-               //      if (!valid_modes[tun.audmode])
-               //              return fail("accepted invalid audmode %d\n", audmode);
+               if (!valid_modes[tun.audmode])
+                       return fail("accepted invalid audmode %d\n", audmode);
        }
        return 0;
 }