From 6b97e7497c985f18af5f790da37f1e43bc65497c Mon Sep 17 00:00:00 2001 From: hackbard Date: Fri, 5 Sep 2003 23:33:29 +0000 Subject: [PATCH] - --- v4lapi.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/v4lapi.c b/v4lapi.c index a85a8a1..92b871a 100644 --- a/v4lapi.c +++ b/v4lapi.c @@ -10,14 +10,18 @@ #include #include #include +#include +#include #include int v4l_init(char *dev) { - int fd; + int fd,i,res; + unsigned char buf[500*500]; struct video_capability vc; struct video_buffer vb; struct video_window vw; + struct video_picture vp; if((fd=open(dev,O_RDONLY))<0) { puts("open failed"); @@ -56,9 +60,10 @@ int v4l_init(char *dev) { printf("width:\t\t %d - %d\n",vc.minwidth,vc.maxwidth); printf("height:\t\t %d - %d\n\n",vc.minheight,vc.maxheight); - if(ioctl(fd,VIDIOCGFBUF,&vb)<0) + if(ioctl(fd,VIDIOCGFBUF,&vb)<0) { puts("direct framebuffer access unsupported"); puts(""); + } else { printf("\n"); printf("framebuffer:\n"); @@ -66,14 +71,48 @@ int v4l_init(char *dev) { printf("h: %d - w: %d - d: %d - bpl: %d\n\n",vb.height,vb.width,vb.depth,vb.bytesperline); } + memset(&vw,0,sizeof(struct video_window)); + vw.x=0; + vw.y=0; + vw.width=vc.maxwidth; + vw.height=vc.maxheight; + + if(ioctl(fd,VIDIOCSWIN,&vw)<0) { + puts("ioctl VIDIOCSWIN failed"); + return -1; + } + if(ioctl(fd,VIDIOCGWIN,&vw)<0) { puts("ioctl VIDIOCGWIN failed"); return -1; } - printf("capture area:\n"); + printf("real capture area:\n"); printf("x: %u - y: %u\n",vw.x,vw.y); printf("w: %u - h: %u\n",vw.width,vw.height); - printf(" + printf("flags: %08x\n",vw.flags); + + memset(&vp,0,sizeof(struct video_picture)); + + if(ioctl(fd,VIDIOCGPICT,&vp)<0) { + puts("ioctl VIDIOCGPICT failed"); + return -1; + } + + printf("picture: b: %04x - h: %04x - c: %04x - c: %04x - w: %04x - d: %04x - p: %04x\n",vp.brightness,vp.hue,vp.colour,vp.contrast,vp.whiteness,vp.depth,vp.palette); + + if(ioctl(fd,VIDIOCSPICT,&vp)<0) { + puts("ioctl VIDIOCSPICT failed"); + return -1; + } + + if((res=read(fd,buf,(500*500)))<0) { + puts("read failed"); + return -1; + } + printf("debug: wrote %d bytes:\n",i); + for(i=0;i