summaryrefslogtreecommitdiff
path: root/v4l2-apps/libv4l/libv4l2
diff options
context:
space:
mode:
Diffstat (limited to 'v4l2-apps/libv4l/libv4l2')
-rw-r--r--v4l2-apps/libv4l/libv4l2/libv4l2.c6
-rw-r--r--v4l2-apps/libv4l/libv4l2/log.c9
2 files changed, 13 insertions, 2 deletions
diff --git a/v4l2-apps/libv4l/libv4l2/libv4l2.c b/v4l2-apps/libv4l/libv4l2/libv4l2.c
index 314087255..2685b9e19 100644
--- a/v4l2-apps/libv4l/libv4l2/libv4l2.c
+++ b/v4l2-apps/libv4l/libv4l2/libv4l2.c
@@ -793,8 +793,12 @@ int v4l2_ioctl (int fd, unsigned long int request, ...)
&src_fmt);
}
- if (result)
+ if (result) {
+ saved_err = errno;
+ V4L2_LOG("S_FMT error trying format: %s\n", strerror(errno));
+ errno = saved_err;
break;
+ }
if (src_fmt.fmt.pix.pixelformat != dest_fmt->fmt.pix.pixelformat &&
v4l2_log_file) {
diff --git a/v4l2-apps/libv4l/libv4l2/log.c b/v4l2-apps/libv4l/libv4l2/log.c
index 6237d55ec..437b51d3e 100644
--- a/v4l2-apps/libv4l/libv4l2/log.c
+++ b/v4l2-apps/libv4l/libv4l2/log.c
@@ -18,6 +18,8 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
#include <linux/ioctl.h>
/* These headers are not needed by us, but by linux/videodev2.h,
which is broken on some systems and doesn't include them itself :( */
@@ -95,6 +97,7 @@ void v4l2_log_ioctl(unsigned long int request, void *arg, int result)
{
const char *ioctl_str;
char buf[40];
+ int saved_errno = errno;
if (!v4l2_log_file)
return;
@@ -143,6 +146,10 @@ void v4l2_log_ioctl(unsigned long int request, void *arg, int result)
break;
}
- fprintf(v4l2_log_file, "result == %d\n", result);
+ if (result < 0)
+ fprintf(v4l2_log_file, "result == %d (%s)\n", result, strerror(saved_errno));
+ else
+ fprintf(v4l2_log_file, "result == %d\n", result);
+
fflush(v4l2_log_file);
}