aboutsummaryrefslogtreecommitdiffstats
path: root/console
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2010-04-01 09:24:39 (GMT)
committerGerd Hoffmann <kraxel@redhat.com>2010-04-01 09:24:39 (GMT)
commit505fcccd2590694505959f179af73721cd112571 (patch)
tree90bfc3ad05423722283e17eff27fbb5c1f213f2f /console
parent4717c404e22922a13f54e431fbf683309870513f (diff)
v3.79
Diffstat (limited to 'console')
-rw-r--r--console/Subdir.mk9
-rw-r--r--console/fbtv.c1
-rw-r--r--console/showqt.c4
-rw-r--r--console/ttv.c1
-rw-r--r--console/v4l-info.c296
5 files changed, 308 insertions, 3 deletions
diff --git a/console/Subdir.mk b/console/Subdir.mk
index fb145d3..848a77b 100644
--- a/console/Subdir.mk
+++ b/console/Subdir.mk
@@ -20,7 +20,8 @@ endif
ifeq ($(FOUND_OS),linux)
TARGETS-console += \
console/radio \
- console/fbtv
+ console/fbtv \
+ console/v4l-info
TARGETS-v4l-conf += \
console/v4l-conf
endif
@@ -57,6 +58,12 @@ console/webcam: \
common/parseconfig.o \
libng/libng.a
+console/v4l-info: \
+ console/v4l-info.o \
+ structs/struct-dump.o \
+ structs/struct-v4l.o \
+ structs/struct-v4l2.o
+
console/dump-mixers: console/dump-mixers.o
console/showriff: console/showriff.o
console/showqt: console/showqt.o
diff --git a/console/fbtv.c b/console/fbtv.c
index 0572328..49d998b 100644
--- a/console/fbtv.c
+++ b/console/fbtv.c
@@ -674,6 +674,7 @@ main(int argc, char *argv[])
strcat(ng_v4l_conf," -y ");
grabber_init();
+ freq_init();
read_config(NULL,NULL,NULL);
if (0 != strlen(mixerdev)) {
struct ng_attribute *attr;
diff --git a/console/showqt.c b/console/showqt.c
index 07e0538..e721bf5 100644
--- a/console/showqt.c
+++ b/console/showqt.c
@@ -439,7 +439,7 @@ static void dump_fields(int fh, off_t pos, struct field_list *list)
break;
case INT64:
read(fh,&int64,sizeof(int64));
- printf(FIELD_NAME "%lld\n",si,list[i].name,SWAP8(int64));
+ printf(FIELD_NAME "%" PRId64 "\n",si,list[i].name,SWAP8(int64));
break;
case FIX16:
read(fh,&int16,sizeof(int16));
@@ -567,7 +567,7 @@ static int handle_classic_atom(int fh, off_t pos, off_t size, int depth)
asize = a.size;
off = 8;
}
- printf("0x%08llx 0x%08llx %*s%s\n",
+ printf("0x%08" PRIx64 " 0x%08" PRIx64 " %*s%s\n",
pos,asize,depth,"",strfcc(a.type));
switch (a.type) {
case a_dinf:
diff --git a/console/ttv.c b/console/ttv.c
index f4d5c8d..e9ae5af 100644
--- a/console/ttv.c
+++ b/console/ttv.c
@@ -208,6 +208,7 @@ main(int argc, char **argv)
/* init v4l */
grabber_init();
+ freq_init();
read_config(NULL,NULL,NULL);
ng_ratio_x = 0;
ng_ratio_y = 0;
diff --git a/console/v4l-info.c b/console/v4l-info.c
new file mode 100644
index 0000000..299e63f
--- /dev/null
+++ b/console/v4l-info.c
@@ -0,0 +1,296 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <ctype.h>
+
+#include <sys/ioctl.h>
+
+#include "videodev.h"
+#include "videodev2.h"
+
+#include "struct-dump.h"
+#include "struct-v4l.h"
+#include "struct-v4l2.h"
+
+/* --------------------------------------------------------------------- */
+/* v4l(1) */
+
+static int dump_v4l(int fd, int tab)
+{
+ struct video_capability capability;
+ struct video_channel channel;
+ struct video_tuner tuner;
+ struct video_audio audio;
+ struct video_picture picture;
+ struct video_buffer buffer;
+ struct video_window window;
+ int i;
+
+ printf("general info\n");
+ memset(&capability,0,sizeof(capability));
+ if (-1 == ioctl(fd,VIDIOCGCAP,&capability))
+ return -1;
+ printf(" VIDIOCGCAP\n");
+ print_struct(stderr,desc_video_capability,&capability,"",tab);
+ printf("\n");
+
+ printf("channels\n");
+ for (i = 0; i < capability.channels; i++) {
+ memset(&channel,0,sizeof(channel));
+ channel.channel = i;
+ if (-1 == ioctl(fd,VIDIOCGCHAN,&channel)) {
+ perror("ioctl VIDIOCGCHAN");
+ continue;
+ }
+ printf(" VIDIOCGCHAN(%d)\n",i);
+ print_struct(stderr,desc_video_channel,&channel,"",tab);
+ }
+ printf("\n");
+
+ printf("tuner\n");
+ memset(&tuner,0,sizeof(tuner));
+ if (-1 == ioctl(fd,VIDIOCGTUNER,&tuner)) {
+ perror("ioctl VIDIOCGTUNER");
+ } else {
+ printf(" VIDIOCGTUNER\n");
+ print_struct(stderr,desc_video_tuner,&tuner,"",tab);
+ }
+ printf("\n");
+
+ printf("audio\n");
+ memset(&audio,0,sizeof(audio));
+ if (-1 == ioctl(fd,VIDIOCGAUDIO,&audio)) {
+ perror("ioctl VIDIOCGAUDIO");
+ } else {
+ printf(" VIDIOCGAUDIO\n");
+ print_struct(stderr,desc_video_audio,&audio,"",tab);
+ }
+ printf("\n");
+
+ printf("picture\n");
+ memset(&picture,0,sizeof(picture));
+ if (-1 == ioctl(fd,VIDIOCGPICT,&picture)) {
+ perror("ioctl VIDIOCGPICT");
+ } else {
+ printf(" VIDIOCGPICT\n");
+ print_struct(stderr,desc_video_picture,&picture,"",tab);
+ }
+ printf("\n");
+
+ printf("buffer\n");
+ memset(&buffer,0,sizeof(buffer));
+ if (-1 == ioctl(fd,VIDIOCGFBUF,&buffer)) {
+ perror("ioctl VIDIOCGFBUF");
+ } else {
+ printf(" VIDIOCGFBUF\n");
+ print_struct(stderr,desc_video_buffer,&buffer,"",tab);
+ }
+ printf("\n");
+
+ printf("window\n");
+ memset(&window,0,sizeof(window));
+ if (-1 == ioctl(fd,VIDIOCGWIN,&window)) {
+ perror("ioctl VIDIOCGWIN");
+ } else {
+ printf(" VIDIOCGWIN\n");
+ print_struct(stderr,desc_video_window,&window,"",tab);
+ }
+ printf("\n");
+
+ return 0;
+}
+
+/* --------------------------------------------------------------------- */
+/* v4l2 */
+
+static int dump_v4l2(int fd, int tab)
+{
+ struct v4l2_capability capability;
+ struct v4l2_standard standard;
+ struct v4l2_input input;
+ struct v4l2_tuner tuner;
+ struct v4l2_fmtdesc fmtdesc;
+ struct v4l2_format format;
+ struct v4l2_framebuffer fbuf;
+ struct v4l2_queryctrl qctrl;
+ int i;
+
+ printf("general info\n");
+ memset(&capability,0,sizeof(capability));
+ if (-1 == ioctl(fd,VIDIOC_QUERYCAP,&capability))
+ return -1;
+ printf(" VIDIOC_QUERYCAP\n");
+ print_struct(stderr,desc_v4l2_capability,&capability,"",tab);
+ printf("\n");
+
+ printf("standards\n");
+ for (i = 0;; i++) {
+ memset(&standard,0,sizeof(standard));
+ standard.index = i;
+ if (-1 == ioctl(fd,VIDIOC_ENUMSTD,&standard))
+ break;
+ printf(" VIDIOC_ENUMSTD(%d)\n",i);
+ print_struct(stderr,desc_v4l2_standard,&standard,"",tab);
+ }
+ printf("\n");
+
+ printf("inputs\n");
+ for (i = 0;; i++) {
+ memset(&input,0,sizeof(input));
+ input.index = i;
+ if (-1 == ioctl(fd,VIDIOC_ENUMINPUT,&input))
+ break;
+ printf(" VIDIOC_ENUMINPUT(%d)\n",i);
+ print_struct(stderr,desc_v4l2_input,&input,"",tab);
+ }
+ printf("\n");
+
+ if (capability.capabilities & V4L2_CAP_TUNER) {
+ printf("tuners\n");
+ for (i = 0;; i++) {
+ memset(&tuner,0,sizeof(tuner));
+ tuner.index = i;
+ if (-1 == ioctl(fd,VIDIOC_G_TUNER,&tuner))
+ break;
+ printf(" VIDIOC_G_TUNER(%d)\n",i);
+ print_struct(stderr,desc_v4l2_tuner,&tuner,"",tab);
+ }
+ printf("\n");
+ }
+
+ if (capability.capabilities & V4L2_CAP_VIDEO_CAPTURE) {
+ printf("video capture\n");
+ for (i = 0;; i++) {
+ memset(&fmtdesc,0,sizeof(fmtdesc));
+ fmtdesc.index = i;
+ fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (-1 == ioctl(fd,VIDIOC_ENUM_FMT,&fmtdesc))
+ break;
+ printf(" VIDIOC_ENUM_FMT(%d,VIDEO_CAPTURE)\n",i);
+ print_struct(stderr,desc_v4l2_fmtdesc,&fmtdesc,"",tab);
+ }
+ memset(&format,0,sizeof(format));
+ format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (-1 == ioctl(fd,VIDIOC_G_FMT,&format)) {
+ perror("VIDIOC_G_FMT(VIDEO_CAPTURE)");
+ } else {
+ printf(" VIDIOC_G_FMT(VIDEO_CAPTURE)\n");
+ print_struct(stderr,desc_v4l2_format,&format,"",tab);
+ }
+ printf("\n");
+ }
+
+ if (capability.capabilities & V4L2_CAP_VIDEO_OVERLAY) {
+ printf("video overlay\n");
+ for (i = 0;; i++) {
+ memset(&fmtdesc,0,sizeof(fmtdesc));
+ fmtdesc.index = i;
+ fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
+ if (-1 == ioctl(fd,VIDIOC_ENUM_FMT,&fmtdesc))
+ break;
+ printf(" VIDIOC_ENUM_FMT(%d,VIDEO_OVERLAY)\n",i);
+ print_struct(stderr,desc_v4l2_fmtdesc,&fmtdesc,"",tab);
+ }
+ memset(&format,0,sizeof(format));
+ format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
+ if (-1 == ioctl(fd,VIDIOC_G_FMT,&format)) {
+ perror("VIDIOC_G_FMT(VIDEO_OVERLAY)");
+ } else {
+ printf(" VIDIOC_G_FMT(VIDEO_OVERLAY)\n");
+ print_struct(stderr,desc_v4l2_format,&format,"",tab);
+ }
+ memset(&fbuf,0,sizeof(fbuf));
+ if (-1 == ioctl(fd,VIDIOC_G_FBUF,&fbuf)) {
+ perror("VIDIOC_G_FBUF");
+ } else {
+ printf(" VIDIOC_G_FBUF\n");
+ print_struct(stderr,desc_v4l2_framebuffer,&fbuf,"",tab);
+ }
+ printf("\n");
+ }
+
+ if (capability.capabilities & V4L2_CAP_VBI_CAPTURE) {
+ printf("vbi capture\n");
+ for (i = 0;; i++) {
+ memset(&fmtdesc,0,sizeof(fmtdesc));
+ fmtdesc.index = i;
+ fmtdesc.type = V4L2_BUF_TYPE_VBI_CAPTURE;
+ if (-1 == ioctl(fd,VIDIOC_ENUM_FMT,&fmtdesc))
+ break;
+ printf(" VIDIOC_ENUM_FMT(%d,VBI_CAPTURE)\n",i);
+ print_struct(stderr,desc_v4l2_fmtdesc,&fmtdesc,"",tab);
+ }
+ memset(&format,0,sizeof(format));
+ format.type = V4L2_BUF_TYPE_VBI_CAPTURE;
+ if (-1 == ioctl(fd,VIDIOC_G_FMT,&format)) {
+ perror("VIDIOC_G_FMT(VBI_CAPTURE)");
+ } else {
+ printf(" VIDIOC_G_FMT(VBI_CAPTURE)\n");
+ print_struct(stderr,desc_v4l2_format,&format,"",tab);
+ }
+ printf("\n");
+ }
+
+ printf("controls\n");
+ for (i = 0;; i++) {
+ memset(&qctrl,0,sizeof(qctrl));
+ qctrl.id = V4L2_CID_BASE+i;
+ if (-1 == ioctl(fd,VIDIOC_QUERYCTRL,&qctrl))
+ break;
+ if (qctrl.flags & V4L2_CTRL_FLAG_DISABLED)
+ continue;
+ printf(" VIDIOC_QUERYCTRL(BASE+%d)\n",i);
+ print_struct(stderr,desc_v4l2_queryctrl,&qctrl,"",tab);
+ }
+ for (i = 0;; i++) {
+ memset(&qctrl,0,sizeof(qctrl));
+ qctrl.id = V4L2_CID_PRIVATE_BASE+i;
+ if (-1 == ioctl(fd,VIDIOC_QUERYCTRL,&qctrl))
+ break;
+ if (qctrl.flags & V4L2_CTRL_FLAG_DISABLED)
+ continue;
+ printf(" VIDIOC_QUERYCTRL(PRIVATE_BASE+%d)\n",i);
+ print_struct(stderr,desc_v4l2_queryctrl,&qctrl,"",tab);
+ }
+ return 0;
+}
+
+/* --------------------------------------------------------------------- */
+/* main */
+
+int main(int argc, char *argv[])
+{
+ char dummy[256];
+ char *device = "/dev/video0";
+ int tab = 1;
+ int fd;
+
+ if (argc > 1)
+ device = argv[1];
+
+ fd = open(device,O_RDONLY);
+ if (-1 == fd) {
+ fprintf(stderr,"open %s: %s\n",device,strerror(errno));
+ exit(1);
+ };
+
+ if (-1 != ioctl(fd,VIDIOC_QUERYCAP,dummy)) {
+ printf("### v4l2 device info [%s] ###\n",device);
+ dump_v4l2(fd,tab);
+ } else if (-1 != ioctl(fd,VIDIOCGCAP,dummy)) {
+ printf("### video4linux device info [%s] ###\n",device);
+ dump_v4l(fd,tab);
+ } else {
+ fprintf(stderr,"%s: not an video4linux device\n",device);
+ }
+ return 0;
+}
+/*
+ * Local variables:
+ * c-basic-offset: 8
+ * End:
+ */

Privacy Policy