Following Marcus's commit of video(1) changes, the attached patch crudely
solves the "-c output is misleading for white_balance_temperature" because
we conflate auto_white_balance_temperature and white_balance_temperature
(which are two separate UVC controls) into one control in video(1).

With this patch we can tell people if white_balance_temperature is being
automatically controlled or not:

  $ video white_balance_temperature=6500
  white_balance_temperature: 4000 -> 6500
  $ obj/video -c
  brightness=128
  contrast=32
  saturation=64
  hue=0
  gamma=120
  sharpness=2
  white_balance_temperature=6500
  $ obj/video -d
  $ obj/video -c
  brightness=128
  contrast=32
  saturation=64
  hue=0
  gamma=120
  sharpness=2
  white_balance_temperature=auto

This patch raises several questions:

  1) At the moment the only "auto" control we have is
     white_balance_temperature. If we gain control of zoom/pan/exposure
     (etc), it might be worth breaking out the common "auto" functionality?

  2) Arguably the first command should look like:
       $ video white_balance_temperature=6500
       white_balance_temperature: auto -> 6500

  3) The output of "video -dv" is very different to "video -c": I suspect
     the former should look more like the latter for consistency.

  4) "video -dc" doesn't seem to reset auto_white_balance_temperature?


Laurie



Index: video.c
===================================================================
RCS file: /cvs/xenocara/app/video/video.c,v
retrieving revision 1.33
diff -u -r1.33 video.c
--- video.c     5 Aug 2020 11:34:00 -0000       1.33
+++ video.c     5 Aug 2020 20:33:56 -0000
@@ -1187,6 +1187,8 @@
 void
 dev_dump_query_ctrls(struct video *vid)
 {
+       struct dev *d = &vid->dev;
+       struct v4l2_control control;
        int i;
 
        if (!dev_check_caps(vid))
@@ -1195,8 +1197,21 @@
                return;
 
        for (i = 0; i < CTRL_LAST; i++) {
-               if (ctrls[i].supported)
-                       fprintf(stderr, "%s=%d\n", ctrls[i].name, ctrls[i].cur);
+               if (!ctrls[i].supported)
+                       continue;
+
+               if (i == CTRL_WHITE_BALANCE_TEMPERATURE) {
+                       control.id = V4L2_CID_AUTO_WHITE_BALANCE;
+                       if (ioctl(d->fd, VIDIOC_G_CTRL, &control) != 0) {
+                               warn("VIDIOC_G_CTRL");
+                               return;
+                       }
+                       if (control.value == 1) {
+                               fprintf(stderr, "%s=auto\n", ctrls[i].name);
+                               continue;
+                       }
+               }
+               fprintf(stderr, "%s=%d\n", ctrls[i].name, ctrls[i].cur);
        }
 }
 

Reply via email to