]> granicus.if.org Git - strace/blobdiff - v4l2.c
mips n32: fix preadv/pwritev offset decoding
[strace] / v4l2.c
diff --git a/v4l2.c b/v4l2.c
index e3c607cffc7a0b226967bad42392c7c87b699a1d..ae1ebb8adf2046151815880f8ba586d8585c51dc 100644 (file)
--- a/v4l2.c
+++ b/v4l2.c
@@ -31,6 +31,7 @@
 
 #include <stdint.h>
 #include <sys/ioctl.h>
+#include <linux/types.h>
 #include <linux/videodev2.h>
 /* some historical constants */
 #ifndef V4L2_CID_HCENTER
 
 static void print_pixelformat(uint32_t fourcc)
 {
+       union {
+               uint32_t pixelformat;
+               unsigned char cc[sizeof(uint32_t)];
+       } u = {
+               .pixelformat =
 #if WORDS_BIGENDIAN
-       fourcc = htole32(fourcc);
+                       htole32(fourcc)
+#else
+                       fourcc
 #endif
-       tprintf("%.4s", (char*)&fourcc);
+       };
+       unsigned int i;
+
+       tprints("v4l2_fourcc(");
+       for (i = 0; i < sizeof(u.cc); ++i) {
+               unsigned int c = u.cc[i];
+
+               if (i)
+                       tprints(", ");
+               if (c == ' ' ||
+                   (c >= '0' && c <= '9') ||
+                   (c >= 'A' && c <= 'Z') ||
+                   (c >= 'a' && c <= 'z')) {
+                       char sym[] = {
+                               '\'',
+                               u.cc[i],
+                               '\''
+                       };
+                       tprints(sym);
+               } else {
+                       char hex[] = {
+                               '\'',
+                               '\\',
+                               'x',
+                               "0123456789abcdef"[c >> 4],
+                               "0123456789abcdef"[c & 0xf],
+                               '\'',
+                               '\0'
+                       };
+                       tprints(hex);
+               }
+       }
+       tprints(")");
 }
 
 static void print_v4l2_format_fmt(const struct v4l2_format *f)
@@ -314,11 +354,13 @@ v4l2_ioctl(struct tcb *tcp, const unsigned int code, long arg)
                if (entering(tcp)
                    || (exiting(tcp) && tcp->auxstr && !syserror(tcp))) {
                        tprints(exiting(tcp) ? " => " : ", {id=");
+#ifdef V4L2_CTRL_FLAG_NEXT_CTRL
                        tcp->auxstr = (c.id & V4L2_CTRL_FLAG_NEXT_CTRL) ? "" : NULL;
                        if (tcp->auxstr) {
                                tprints("V4L2_CTRL_FLAG_NEXT_CTRL|");
                                c.id &= ~V4L2_CTRL_FLAG_NEXT_CTRL;
                        }
+#endif
                        printxval(v4l2_control_ids, c.id, "V4L2_CID_???");
                }
                if (exiting(tcp)) {
@@ -356,6 +398,7 @@ v4l2_ioctl(struct tcb *tcp, const unsigned int code, long arg)
                return 1;
        }
 
+#ifdef VIDIOC_S_EXT_CTRLS
        case VIDIOC_S_EXT_CTRLS:
        case VIDIOC_TRY_EXT_CTRLS:
        case VIDIOC_G_EXT_CTRLS: {
@@ -392,7 +435,7 @@ v4l2_ioctl(struct tcb *tcp, const unsigned int code, long arg)
                        }
                        tprints("{id=");
                        printxval(v4l2_control_ids, ctrl.id, "V4L2_CID_???");
-#if HAVE_DECL_V4L2_CTRL_TYPE_STRING
+# if HAVE_DECL_V4L2_CTRL_TYPE_STRING
                        tprintf(", size=%u", ctrl.size);
                        if (ctrl.size > 0) {
                                if (must_print_values) {
@@ -400,11 +443,11 @@ v4l2_ioctl(struct tcb *tcp, const unsigned int code, long arg)
                                        printstr(tcp, (long) ctrl.string, ctrl.size);
                                }
                        } else
-#endif
+# endif
                        {
                                if (must_print_values) {
-                                       tprintf(", value=%i, value64=%lli", ctrl.value,
-                                               ctrl.value64);
+                                       tprintf(", value=%i, value64=%lld", ctrl.value,
+                                               (long long) ctrl.value64);
                                }
                        }
                        tprints("}");
@@ -412,6 +455,7 @@ v4l2_ioctl(struct tcb *tcp, const unsigned int code, long arg)
                tprints("]}");
                return 1;
        }
+#endif /* VIDIOC_S_EXT_CTRLS */
 
        case VIDIOC_ENUMSTD: {
                struct v4l2_standard s;
@@ -443,7 +487,7 @@ v4l2_ioctl(struct tcb *tcp, const unsigned int code, long arg)
                if (umove(tcp, arg, &s) < 0)
                        return 0;
                if ((code == VIDIOC_S_STD) == entering(tcp))
-                       tprintf(", std=%#llx", s);
+                       tprintf(", std=%#llx", (unsigned long long) s);
                return 1;
        }
 
@@ -589,9 +633,9 @@ v4l2_ioctl(struct tcb *tcp, const unsigned int code, long arg)
                                        b.length, b.bytesused);
                                printflags(v4l2_buf_flags, b.flags, "V4L2_BUF_FLAG_???");
                                if (code == VIDIOC_DQBUF)
-                                       tprintf(", timestamp = {%lu.%06lu}",
-                                               b.timestamp.tv_sec,
-                                               b.timestamp.tv_usec);
+                                       tprintf(", timestamp = {%ju.%06ju}",
+                                               (uintmax_t)b.timestamp.tv_sec,
+                                               (uintmax_t)b.timestamp.tv_usec);
                                tprints(", ...");
                        }
                        tprints("}");