-
authorhackbard <hackbard>
Fri, 5 Sep 2003 23:33:29 +0000 (23:33 +0000)
committerhackbard <hackbard>
Fri, 5 Sep 2003 23:33:29 +0000 (23:33 +0000)
v4lapi.c

index a85a8a1..92b871a 100644 (file)
--- a/v4lapi.c
+++ b/v4lapi.c
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
+#include <string.h>
+#include <unistd.h>
 
 #include <linux/videodev.h>
 
 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<res;i++) printf("%c ",buf[i]);
+       printf("\n");
+
        return 1;
 }