VIDIOC_QUERYCTRL: don't treat EINVAL as a fatal error
authorAndrii Bordunov <andrew.bordunov@gmail.com>
Thu, 5 Sep 2013 17:12:51 +0000 (5 20:12 +0300)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 14 Sep 2013 21:30:45 +0000 (14 14:30 -0700)
If a control (V4L2_CID_AUDIO_VOLUME in our case) is not supported by
VIDIOC_QUERYCTRL, EINVAL is returned.  If the query operation
(VIDIOC_QUERYCTRL) is not supported at all, ENOTTY is returned.  Currently
we use VIDIOC_QUERYCTRL just for the V4L2_CID_AUDIO_VOLUME and can survive
both of these errors. Let's do it.

Related to commit e5a2c03089651659f1b4159a6d7f231b1969db0b (Work with
tuners that do not support V4L2_CID_AUDIO_VOLUME.)

Tested-by: Paulo Cavalcanti <promac@gmail.com>
fmlib.c

diff --git a/fmlib.c b/fmlib.c
index ba185a3..1da81c0 100644 (file)
--- a/fmlib.c
+++ b/fmlib.c
@@ -241,8 +241,9 @@ query_control(const struct tuner *tuner, uint32_t id,
                 }
         } else if (ioctl(tuner->fd, VIDIOC_QUERYCTRL, qc) != -1) {
                 /* Success. */
-        } else if (errno == ENOTTY) {
-                /* This tuner doesn't support 'id'. */
+        } else if (errno == ENOTTY || errno == EINVAL) {
+                /* This tuner doesn't support either query operation
+                 * or the specific control ('id') respectively */
                 memset(qc, 0, sizeof *qc);
         } else {
                 fatal(errno, "VIDIOC_QUERYCTRL");