This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/xawtv3.git tree:
Subject: Re-add v4l-conf and v4l-info Author: Mauro Carvalho Chehab <[email protected]> Date: Fri Jan 28 00:02:29 2011 -0200 I was too fast removing it. As it contains both V4L1 and V4L2 API, it is just a matter of removing V4L1, while keeping V4L2 part of it. Signed-off-by: Mauro Carvalho Chehab <[email protected]> console/Subdir.mk | 21 ++- console/v4l-conf.c | 569 ++++++++++++++++++++++++++++++++++++++++++++++++++++ console/v4l-info.c | 207 +++++++++++++++++++ man/es/v4l-conf.8 | 93 +++++++++ man/v4l-conf.8 | 87 ++++++++ man/v4l-info.1 | 15 ++ xawtv.spec | 2 +- xawtv.spec.in | 2 +- 8 files changed, 989 insertions(+), 7 deletions(-) --- http://git.linuxtv.org/xawtv3.git?a=commitdiff;h=33efec922266c83cc4c477dfa547175459b105d4 diff --git a/console/Subdir.mk b/console/Subdir.mk index 502c6d1..d17666e 100644 --- a/console/Subdir.mk +++ b/console/Subdir.mk @@ -7,6 +7,7 @@ TARGETS-console := \ console/showqt \ console/streamer \ console/webcam +TARGETS-v4l-conf := ifeq ($(FOUND_ZVBI),yes) TARGETS-console += \ @@ -19,7 +20,10 @@ endif ifeq ($(FOUND_OS),linux) TARGETS-console += \ console/radio \ - console/fbtv + console/fbtv \ + console/v4l-info +TARGETS-v4l-conf += \ + console/v4l-conf endif # objects for targets @@ -54,11 +58,17 @@ console/webcam: \ common/parseconfig.o \ libng/libng.a +console/v4l-info: \ + console/v4l-info.o \ + structs/struct-dump.o \ + structs/struct-v4l2.o + console/dump-mixers: console/dump-mixers.o console/showriff: console/showriff.o console/showqt: console/showqt.o console/radio: console/radio.o console/record: console/record.o +console/v4l-conf: console/v4l-conf.o # libraries to link console/fbtv : LDLIBS += \ @@ -70,6 +80,7 @@ console/streamer : LDLIBS += $(THREAD_LIBS) -ljpeg -lm console/webcam : LDLIBS += $(THREAD_LIBS) -ljpeg -lm console/radio : LDLIBS += $(CURSES_LIBS) console/record : LDLIBS += $(CURSES_LIBS) +console/v4l-conf : LDLIBS += $(ATHENA_LIBS) # linker flags console/fbtv : LDFLAGS := $(DLFLAGS) @@ -79,13 +90,13 @@ console/streamer : LDFLAGS := $(DLFLAGS) console/webcam : LDFLAGS := $(DLFLAGS) # global targets -all:: $(TARGETS-console) +all:: $(TARGETS-console) $(TARGETS-v4l-conf) install:: $(INSTALL_PROGRAM) $(TARGETS-console) $(bindir) ifeq ($(FOUND_OS),linux) - $(INSTALL_PROGRAM) $(SUID_ROOT) $(bindir) + $(INSTALL_PROGRAM) $(SUID_ROOT) $(TARGETS-v4l-conf) $(bindir) endif -distclean:: - rm -f $(TARGETS-console) +clean distclean:: + rm -f $(TARGETS-console) $(TARGETS-v4l-conf) diff --git a/console/v4l-conf.c b/console/v4l-conf.c new file mode 100644 index 0000000..244d651 --- /dev/null +++ b/console/v4l-conf.c @@ -0,0 +1,569 @@ +/* + * Set the framebuffer parameters for bttv. + * tries to ask the X-Server if $DISPLAY is set, + * otherwise it checks /dev/fb0 + * + * (c) 1998-2001 Gerd Knorr <[email protected]> + * + * Security checks by [email protected] + */ +#include "config.h" + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <strings.h> +#include <string.h> +#include <errno.h> +#include <fcntl.h> +#include <time.h> +#include <sys/time.h> +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/stat.h> +#include <linux/vt.h> +#include <linux/fb.h> +#ifdef HAVE_GETOPT_H +# include <getopt.h> +#endif + +#ifndef X_DISPLAY_MISSING +# include <X11/Xlib.h> +# include <X11/Xutil.h> +# ifdef HAVE_LIBXXF86DGA +# include <X11/extensions/xf86dga.h> +# endif +#endif + +#include <linux/types.h> +#include "videodev2.h" + +struct DISPLAYINFO { + int width; /* visible display width (pixels) */ + int height; /* visible display height (pixels) */ + int depth; /* color depth */ + int bpp; /* bit per pixel */ + int bpl; /* bytes per scanline */ + unsigned char *base; +}; + +int verbose = 1; +int yuv = 0; +int user_bpp = 0; +int user_shift = 0; +void *user_base = NULL; +char *display = NULL; +char *fbdev = NULL; +char *videodev = "/dev/video0"; + +/* ---------------------------------------------------------------- */ +/* this is required for MkLinux */ + +#ifdef __powerpc__ +struct vc_mode { + int height; + int width; + int depth; + int pitch; + int mode; + char name[32]; + unsigned long fb_address; + unsigned long cmap_adr_address; + unsigned long cmap_data_address; + unsigned long disp_reg_address; +}; + +#define VC_GETMODE 0x7667 +#define VC_SETMODE 0x7668 +#define VC_INQMODE 0x7669 + +#define VC_SETCMAP 0x766a +#define VC_GETCMAP 0x766b + +static int +is_mklinux(void) +{ + int fd; + if(-1 == (fd = open("/proc/osfmach3", O_RDONLY))) + return 0; + close(fd); + return 1; +} + +static void +displayinfo_mklinux(struct DISPLAYINFO *d) +{ + struct vc_mode mode; + int fd; + + if (verbose) + fprintf(stderr,"v4l-conf: using mklinux console driver\n"); + + if (-1 == (fd = open("/dev/console",O_RDWR|O_NDELAY))) { + fprintf(stderr,"open console: %s\n",strerror(errno)); + exit(1); + } + if (-1 == ioctl(fd, VC_GETMODE, (unsigned long)&mode)) { + perror("ioctl VC_GETMODE"); + exit(1); + } + close(fd); + d->width = mode.width; + d->height = mode.height; + d->bpp = mode.depth; + d->bpl = mode.pitch; + d->base = (void*)mode.fb_address; +} +#endif + +/* ---------------------------------------------------------------- */ + +#ifndef major +# define major(dev) (((dev) >> 8) & 0xff) +#endif + +static int +dev_open(const char *device, int major) +{ + struct stat stb; + int fd; + + if (strncmp(device, "/dev/", 5)) { + fprintf(stderr, "error: %s is not a /dev file\n", device); + exit(1); + } + + /* open & check v4l device */ + if (-1 == (fd = open(device,O_RDWR))) { + fprintf(stderr, "can't open %s: %s\n", device, strerror(errno)); + exit(1); + } + + if (-1 == fstat(fd,&stb)) { + fprintf(stderr, "fstat(%s): %s\n", device, strerror(errno)); + exit(1); + } + if (!S_ISCHR(stb.st_mode) || (major(stb.st_rdev) != major)) { + fprintf(stderr, "%s: wrong device\n", device); + exit(1); + } + return fd; +} + +static void real_user(void) +{ + if (-1 == seteuid(getuid())) { + perror("seteuid(user)"); + exit(1); + } +} + +static void root_user(void) +{ + if (-1 == seteuid(0)) { + perror("seteuid(root)"); + exit(1); + } +} + +/* ---------------------------------------------------------------- */ +/* get mode info */ + +#ifndef X_DISPLAY_MISSING +static void +displayinfo_x11(Display *dpy, struct DISPLAYINFO *d) +{ + Window root; + XVisualInfo *info, template; + XPixmapFormatValues *pf; + XWindowAttributes wts; + int found,v,i,n; + + if (verbose) + fprintf(stderr,"v4l-conf: using X11 display %s\n",display); + + /* take size from root window */ + root = DefaultRootWindow(dpy); + XGetWindowAttributes(dpy, root, &wts); + d->width = wts.width; + d->height = wts.height; + + /* look for a usable visual */ + template.screen = XDefaultScreen(dpy); + info = XGetVisualInfo(dpy, VisualScreenMask,&template,&found); + v = -1; + for (i = 0; v == -1 && i < found; i++) + if (info[i].class == TrueColor && info[i].depth >= 15) + v = i; + for (i = 0; v == -1 && i < found; i++) + if (info[i].class == StaticGray && info[i].depth == 8) + v = i; + if (-1 == v) { + fprintf(stderr,"x11: no approximate visual available\n"); + exit(1); + } + + /* get depth + bpp (heuristic) */ + pf = XListPixmapFormats(dpy,&n); + for (i = 0; i < n; i++) { + if (pf[i].depth == info[v].depth) { + d->depth = pf[i].depth; + d->bpp = pf[i].bits_per_pixel; + d->bpl = d->bpp * d->width / 8; + break; + } + } + if (0 == d->bpp) { + fprintf(stderr,"x11: can't detect framebuffer depth\n"); + exit(1); + } +} + +#ifdef HAVE_LIBXXF86DGA +static int dga_error = 0; +static int dga_error_base; +static int (*orig_xfree_error_handler)(Display *, XErrorEvent *); + +static int dga_error_handler(Display *d, XErrorEvent *e) +{ + if (e->error_code == (dga_error_base + XF86DGANoDirectVideoMode)) { + dga_error = 1; + return 0; + } + return orig_xfree_error_handler(d, e); +} +#endif + +static void +displayinfo_dga(Display *dpy, struct DISPLAYINFO *d) +{ +#ifdef HAVE_LIBXXF86DGA + int width,bar,foo,major,minor,flags=0; + void *base = NULL; + + if (!XF86DGAQueryExtension(dpy,&foo,&dga_error_base)) { + fprintf(stderr,"WARNING: Your X-Server has no DGA support.\n"); + return; + } + XF86DGAQueryVersion(dpy,&major,&minor); + if (verbose) + fprintf(stderr,"dga: version %d.%d\n",major,minor); + XF86DGAQueryDirectVideo(dpy,XDefaultScreen(dpy),&flags); + if (!(flags & XF86DGADirectPresent)) { + fprintf(stderr,"WARNING: No DGA support available for this display.\n"); + return; + } + orig_xfree_error_handler = XSetErrorHandler(dga_error_handler); + XF86DGAGetVideoLL(dpy,XDefaultScreen(dpy),(void*)&base,&width,&foo,&bar); + XSync(dpy, 0); + XSetErrorHandler(orig_xfree_error_handler); + if (dga_error) { + fprintf(stderr,"WARNING: No DGA direct video mode for this display.\n"); + return; + } + d->bpl = width * d->bpp/8; + d->base = base; +#else + fprintf(stderr,"WARNING: v4l-conf is compiled without DGA support.\n"); +#endif +} +#endif + +static void +displayinfo_fbdev(struct DISPLAYINFO *d) +{ + struct fb_fix_screeninfo fix; + struct fb_var_screeninfo var; + struct fb_con2fbmap c2m; + struct vt_stat vstat; + int fd; + + if (NULL == fbdev) { + if (-1 == (fd = open("/dev/tty",O_RDWR,0))) { + fprintf(stderr,"open /dev/tty: %s\n",strerror(errno)); + exit(1); + } + if (-1 == ioctl(fd, VT_GETSTATE, &vstat)) { + perror("ioctl VT_GETSTATE"); + exit(1); + } + close(fd); + c2m.console = vstat.v_active; + if (-1 == (fd = open("/dev/fb0",O_RDWR,0))) { + fprintf(stderr,"open /dev/fb0: %s\n",strerror(errno)); + exit(1); + } + if (-1 == ioctl(fd, FBIOGET_CON2FBMAP, &c2m)) { + perror("ioctl FBIOGET_CON2FBMAP"); + c2m.framebuffer = 0; + } + close(fd); + fprintf(stderr,"map: vt%02d => fb%d\n",c2m.console,c2m.framebuffer); + sprintf(fbdev=malloc(16),"/dev/fb%d",c2m.framebuffer); + } + if (verbose) + fprintf(stderr,"v4l-conf: using framebuffer device %s\n",fbdev); + + /* Open frame buffer device, with security checks */ + fd = dev_open(fbdev, 29 /* VIDEO_MAJOR */); + if (-1 == ioctl(fd,FBIOGET_FSCREENINFO,&fix)) { + perror("ioctl FBIOGET_FSCREENINFO"); + exit(1); + } + if (-1 == ioctl(fd,FBIOGET_VSCREENINFO,&var)) { + perror("ioctl FBIOGET_VSCREENINFO"); + exit(1); + } + if (fix.type != FB_TYPE_PACKED_PIXELS) { + fprintf(stderr,"can handle only packed pixel frame buffers\n"); + exit(1); + } + close(fd); + + d->width = var.xres_virtual; + d->height = var.yres_virtual; + d->bpp = var.bits_per_pixel; + d->bpl = fix.line_length; + d->base = (unsigned char*)fix.smem_start; + + d->depth = d->bpp; + if (var.green.length == 5) + d->depth = 15; +} + +/* ---------------------------------------------------------------- */ +/* set mode info */ + +static int +displayinfo_v4l2(int fd, struct DISPLAYINFO *d) +{ + struct v4l2_capability cap; + struct v4l2_framebuffer fb; + + if (-1 == ioctl(fd,VIDIOC_QUERYCAP,&cap)) { + if (verbose) + fprintf(stderr,"%s [v4l2]: ioctl VIDIOC_QUERYCAP: %s\n", + videodev,strerror(errno)); + return -1; + } + if (!(cap.capabilities & V4L2_CAP_VIDEO_OVERLAY)) { + fprintf(stderr,"%s [v4l2]: no overlay support\n",videodev); + exit(1); + } + + /* read-modify-write v4l screen parameters */ + if (-1 == ioctl(fd,VIDIOC_G_FBUF,&fb)) { + fprintf(stderr,"%s [v4l2]: ioctl VIDIOC_G_FBUF: %s\n", + videodev,strerror(errno)); + exit(1); + } + + /* set values */ + fb.fmt.width = d->width; + fb.fmt.height = d->height; + switch (d->bpp) { + case 8: fb.fmt.pixelformat = V4L2_PIX_FMT_HI240; break; +#if BYTE_ORDER == BIG_ENDIAN + case 15: fb.fmt.pixelformat = V4L2_PIX_FMT_RGB555X; break; + case 16: fb.fmt.pixelformat = V4L2_PIX_FMT_RGB565X; break; + case 24: fb.fmt.pixelformat = V4L2_PIX_FMT_RGB24; break; + case 32: fb.fmt.pixelformat = V4L2_PIX_FMT_RGB32; break; +#else + case 15: fb.fmt.pixelformat = V4L2_PIX_FMT_RGB555; break; + case 16: fb.fmt.pixelformat = V4L2_PIX_FMT_RGB565; break; + case 24: fb.fmt.pixelformat = V4L2_PIX_FMT_BGR24; break; + case 32: fb.fmt.pixelformat = V4L2_PIX_FMT_BGR32; break; +#endif + } + if (yuv) + fb.fmt.pixelformat = V4L2_PIX_FMT_YUYV; + fb.fmt.bytesperline = d->bpl; + fb.fmt.sizeimage = fb.fmt.height * fb.fmt.bytesperline; + if (NULL != d->base) + fb.base = d->base; + if (NULL == fb.base) + fprintf(stderr, + "WARNING: couldn't find framebuffer base address, try manual\n" + " configuration (\"v4l-conf -a <addr>\")\n"); + + if (-1 == ioctl(fd,VIDIOC_S_FBUF,&fb)) { + fprintf(stderr,"%s [v4l2]: ioctl VIDIOC_S_FBUF: %s\n", + videodev,strerror(errno)); + if (EPERM == errno && 0 != geteuid()) + fprintf(stderr, + "v4l-conf: You should install me suid root, I need\n" + " root priviliges for the VIDIOC_S_FBUF ioctl.\n"); + exit(1); + } + if (verbose) + fprintf(stderr,"%s [v4l2]: configuration done\n",videodev); + return 0; +} + +/* ---------------------------------------------------------------- */ + +int +main(int argc, char *argv[]) +{ + struct DISPLAYINFO d; + int fd,c,i,n; + char *h; +#ifndef X_DISPLAY_MISSING + Display *dpy; +#endif + + /* we don't need root proviliges for now ... */ + real_user(); + + /* Make sure fd's 0 1 2 are open, otherwise + * we might end up sending perror() messages to + * the `device' file */ + for (i = 0; i < 3; i++) { + if (-1 == fcntl(i, F_GETFL, &n)) + exit(1); + } + + /* take defaults from environment */ + if (NULL != (h = getenv("DISPLAY"))) + display = h; + if (NULL != (h = getenv("FRAMEBUFFER"))) + fbdev = h; + + /* parse options */ + for (;;) { + if (-1 == (c = getopt(argc, argv, "hyq12d:c:b:s:fa:"))) + break; + switch (c) { + case 'q': + verbose = 0; + break; + case 'y': + yuv = 1; + break; + case 'd': + display = optarg; + break; + case 'c': + videodev = optarg; + break; + case 'b': + user_bpp = atoi(optarg); + break; + case 's': + user_shift = atoi(optarg); + if (user_shift < 0 || user_shift > 8192) + user_shift = 0; + break; + case 'f': + display = NULL; + break; + case 'a': + if (0 == getuid()) { + /* only root is allowed to set this, and it will work only + * if v4l-conf can't figure out the correct address itself. + * Useful for "post-install bttv ..." */ + sscanf(optarg,"%p",&user_base); + } else { + fprintf(stderr,"only root is allowed to use the -a option\n"); + exit(1); + } + break; + case 'h': + default: + fprintf(stderr, + "usage: %s [ options ] \n" + "\n" + "options:\n" + " -q quiet\n" +#ifndef X_DISPLAY_MISSING + " -d <dpy> X11 Display [%s]\n" +#endif + " -c <dev> video device [%s]\n" + " -b <n> displays color depth is <n> bpp\n" + " -s <n> shift display by <n> bytes\n" + " -f query frame buffer device for info\n" + " -a <addr> set framebuffer address to <addr>\n" + " (in hex, root only, successful autodetect\n" + " will overwrite this address)\n" + " -1 force v4l API\n" + " -2 force v4l2 API\n", + argv[0], +#ifndef X_DISPLAY_MISSING + display ? display : "none", +#endif + videodev); + exit(1); + } + } + + /* figure out display parameters */ + memset(&d,0,sizeof(struct DISPLAYINFO)); +#ifdef __powerpc__ + if (is_mklinux()) { + displayinfo_mklinux(&d); + } else +#endif +#ifndef X_DISPLAY_MISSING + if (NULL != display) { + /* using X11 */ + if (display[0] != ':') { + fprintf(stderr,"WARNING: remote display `%s' not allowed, ", + display); + display = strchr(display,':'); + if (NULL == display) { + fprintf(stderr,"exiting"); + exit(1); + } else { + fprintf(stderr,"using `%s' instead\n",display); + } + } + if (NULL == (dpy = XOpenDisplay(display))) { + fprintf(stderr,"can't open x11 display %s\n",display); + exit(1); + } + displayinfo_x11(dpy,&d); + displayinfo_dga(dpy,&d); + } else +#endif + { + /* try framebuffer device */ + displayinfo_fbdev(&d); + } + + /* fixup struct displayinfo according to the given command line options */ + if (user_base) { + if (NULL == d.base) { + fprintf(stderr,"using user provided base address %p\n",user_base); + d.base = user_base; + } else { + fprintf(stderr,"user provided base address %p ignored.\n", + user_base); + } + } + if (d.base) + d.base += user_shift; + if ((user_bpp == 24 || user_bpp == 32) && + (d.bpp == 24 || d.bpp == 32)) { + d.bpp = user_bpp; + d.bpl = d.width * d.bpp/8; + } + if ((user_bpp == 15 || user_bpp == 16) && + (d.depth == 15 || d.depth == 16)) + d.depth = user_bpp; + + if (verbose) { + fprintf(stderr,"mode: %dx%d, depth=%d, bpp=%d, bpl=%d, ", + d.width,d.height,d.depth,d.bpp,d.bpl); + if (NULL != d.base) + fprintf(stderr,"base=%p\n",d.base); + else + fprintf(stderr,"base=unknown\n"); + } + + /* Set the parameters (needs root) */ + root_user(); + fd = dev_open(videodev, 81 /* VIDEO_MAJOR */); + displayinfo_v4l2(fd,&d); + close(fd); + return 0; +} diff --git a/console/v4l-info.c b/console/v4l-info.c new file mode 100644 index 0000000..d37799b --- /dev/null +++ b/console/v4l-info.c @@ -0,0 +1,207 @@ +#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/time.h> +#include <sys/ioctl.h> + +#include <linux/types.h> +#include "videodev2.h" + +#include "struct-dump.h" +#include "struct-v4l.h" +#include "struct-v4l2.h" + +/* --------------------------------------------------------------------- */ +/* 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(stdout,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(stdout,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(stdout,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(stdout,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(stdout,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(stdout,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(stdout,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(stdout,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(stdout,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(stdout,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(stdout,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(stdout,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(stdout,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("\n### v4l2 device info [%s] ###\n",device); + dump_v4l2(fd,tab); + } else { + fprintf(stderr,"%s: not an video4linux device\n",device); + exit(1); + } + return 0; +} +/* + * Local variables: + * c-basic-offset: 8 + * End: + */ diff --git a/man/es/v4l-conf.8 b/man/es/v4l-conf.8 new file mode 100644 index 0000000..c3c1060 --- /dev/null +++ b/man/es/v4l-conf.8 @@ -0,0 +1,93 @@ +.TH v4l-conf 1 "(c) 1997-99 Gerd Knorr" +.SH NOMBRE +v4l-conf - configura un driver video4linux +.SH SINOPSIS +.B v4l-conf [ opciones ] +.SH DESCRIPCIÓN +.B v4l-conf +es una pequeña herramienta auxiliar. Trata de averiguar el modo del +video y la dirección base del framebuffer de la tarjeta gráfica +y configura un driver video4linux como el bttv. +Esto es necesario para drivers que pueden enviar el video por DMA +a través de PCI directamente a la memoria de video. +.P +Normalmente no es necesario usar v4l-conf manualmente, xawtv(1) y +fbtv(1) lo ejecutan automáticamente al inicio. Puede ser útil en +caso de problemas en la ejecución de esos programas. +Se debe instalar +.B v4l-conf +como suid-root. +.P +.B v4l-conf +tiene tres maneras para obtener la información: +.TP 3 + * +Pregunta al servidor X usando la extensión DGA de XF86. Esto es lo +que hace por defecto si la variable de entorno DISPLAY está establecida. +.TP 3 + * +Pregunta al driver framebuffer. Esto es lo que hace por defecto si DISPLAY +no está establecida. +.TP 3 + * +Pregunta al driver de la consola. Se usa sólamente en mklinux. +.SH OPCIONES +.TP 4 +\fB-h\fP +Muestra una breve descripción de todas las opciones. +.TP 4 +\fB-q\fP +Estar callado. +.TP 4 +\fB-d\fP dpy +Usa el display X11 \fBdpy\fP para obtener los parámetros. +.TP 4 +\fB-f\fP +Usa el driver framebuffer para obtener los parámetros. +.TP 4 +\fB-c\fP dispositivo +Establece el dispositivo de video4linux. +.TP 4 +\fB-b\fP n +fuerza una profundidad de color de +.B n +bpp. Funciona para cambiar entre 15/16 y 24/32 bpp. +.TP 4 +\fB-s\fP n +Desplaza la imagen de video +.B n +bytes. +.TP 4 +\fB-a\fP adr +Establece la dirección del framebuffer a \fBadr\fP. El valor +hay que especificarlo en hexadecimal. Sólo se le permite esta +opción a root. No se puede sobreescribir el valor detectado +automáticamente, esta opción sólo es válida si la autodetección no +funciona debido a que el servidor X no tiene soporte DGA. +Puede poner esto en el fichero /etc/conf.modules, como "post-install bttv ..." +por ejemplo. +.SH BUGS +Espero no haber dejado ninguna fisura de seguridad. Si encuentra alguna +envíeme una nota. Prefiero correos que incluyan parches :-) +.SH VEA TAMBIÉN +xawtv(1), fbtv(1) +.SH AUTOR +Gerd Knorr <[email protected]> +.SH COPYRIGHT +Copyright (C) 1997-99 Gerd Knorr <[email protected]> +.P +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. +.P +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +.P +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +.SH TRADUCCIÓN +Página traducida al español por Ricardo Villalba <[email protected]> diff --git a/man/v4l-conf.8 b/man/v4l-conf.8 new file mode 100644 index 0000000..7475bf7 --- /dev/null +++ b/man/v4l-conf.8 @@ -0,0 +1,87 @@ +.TH v4l-conf 1 "(c) 1997-99 Gerd Knorr" +.SH NAME +v4l-conf - configure a video4linux driver +.SH SYNOPSIS +.B v4l-conf [ options ] +.SH DESCRIPTION +.B v4l-conf +is a small helper tool. It figures out the video mode and framebuffer +base address of the graphics board and configures a video4linux driver +like bttv. This is needed for drivers which can DMA the video over PCI +directly into the video memory. +.P +Usually it is not required to use v4l-conf manually, xawtv(1) and +fbtv(1) run it automatically at startup. It might be useful for +trouble-shooting. +.B v4l-conf +must be installed suid-root. +.P +.B v4l-conf +knows three ways to get the informations: +.TP 3 + * +Query the X-Server using the XF86 DGA extension. This is the default +if the DISPLAY environment variable is set. +.TP 3 + * +Query the framebuffer driver. This is the default if DISPLAY is not +set. +.TP 3 + * +Query the console driver. This is used on mklinux only. +.SH OPTIONS +.TP 4 +\fB-h\fP +Print a short description of all command line options. +.TP 4 +\fB-q\fP +Be quiet. +.TP 4 +\fB-d\fP dpy +Use the X11 display \fBdpy\fP to get the parameters. +.TP 4 +\fB-f\fP +Use the framebuffer driver to get the parameters. +.TP 4 +\fB-c\fP device +Set the video4linux device. +.TP 4 +\fB-b\fP n +enforce +.B n +bpp color depth. Works for switching between 15/16 and 24/32 bpp. +.TP 4 +\fB-s\fP n +Shift the video display by +.B n +bytes. +.TP 4 +\fB-a\fP adr +Set framebuffer address to \fBadr\fP. The value should be specified +in hex. This option is allowed for root only. You can't overwrite the +autodetected value, this switch is only useful if autodetect doesn't +work because the X-Server lacks DGA support. You can put this into +/etc/conf.modules, as "post-install bttv ..." for example. +.SH BUGS +Hope I haven't any security flaws in there. If you find one, drop me a +note. Mails with patches are preferred :-) +.SH SEE ALSO +xawtv(1), fbtv(1) +.SH AUTHOR +Gerd Knorr <[email protected]> +.SH COPYRIGHT +Copyright (C) 1997-99 Gerd Knorr <[email protected]> +.P +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. +.P +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +.P +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/man/v4l-info.1 b/man/v4l-info.1 new file mode 100644 index 0000000..90ce560 --- /dev/null +++ b/man/v4l-info.1 @@ -0,0 +1,15 @@ +.TH v4l-info 1 "(c) Gerd Knorr" +.SH NAME +v4l-info - dump video4linux(2) device info to stdout +.SH SYNOPSIS +.B v4l-info [ device ] +.SH DESCRIPTION +.B v4l-info +just prints the v4l(2) device info, i.e. calls lots of ioctls and dumps +the results to stdout. It optionally accepts the device you want to +query. Default is /dev/video0. +.P +Was written to help debug drivers, probably not that useful for end +users ... +.SH AUTHOR +Gerd Knorr <[email protected]> diff --git a/xawtv.spec b/xawtv.spec index 937dad9..1c57fdd 100644 --- a/xawtv.spec +++ b/xawtv.spec @@ -5,7 +5,7 @@ Version: 3.97 Release: 0 License: GPL Summary: v4l applications -Source: http://bytesex.org/xawtv/%{name}_%{version}.tar.gz +Source: http://linuxtv.org/downloads/xawtv/%{name}-%{version}.tar.bz2 Buildroot: /var/tmp/root.%{name}-%{version} %description diff --git a/xawtv.spec.in b/xawtv.spec.in index a4ffe85..4fb359f 100644 --- a/xawtv.spec.in +++ b/xawtv.spec.in @@ -5,7 +5,7 @@ Version: @VERSION@ Release: 0 License: GPL Summary: v4l applications -Source: http://bytesex.org/xawtv/%{name}_%{version}.tar.gz +Source: http://linuxtv.org/downloads/xawtv/%{name}-%{version}.tar.bz2 Buildroot: /var/tmp/root.%{name}-%{version} %description
_______________________________________________ linuxtv-commits mailing list [email protected] http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits
