2 * v4lapi.c -- api to the video4linux interface
4 * author: hackbard@hackdaworld.dyndns.org
12 #include <sys/ioctl.h>
14 #include <linux/videodev.h>
16 int v4l_init(char *dev) {
18 struct video_capability vc;
19 struct video_buffer vb;
20 struct video_window vw;
22 if((fd=open(dev,O_RDONLY))<0) {
27 if(ioctl(fd,VIDIOCGCAP,&vc)<0) {
28 puts("ioctl VIDIOCGCAP failed");
32 printf("video device information:\n");
33 printf("-------------------------\n\n");
34 printf("interface name: %s\n\n",vc.name);
36 printf("capture:\t %c\n",(vc.type&1)?'y':'n');
37 printf("tuner:\t\t %c\n",((vc.type>>1)&1)?'y':'n');
38 printf("teletext:\t %c\n",((vc.type>>2)&1)?'y':'n');
39 printf("overlay:\t %c\n",((vc.type>>3)&1)?'y':'n');
40 printf("chromakey:\t %c\n",((vc.type>>4)&1)?'y':'n');
41 printf("clipping:\t %c\n",((vc.type>>5)&1)?'y':'n');
42 printf("fb memory:\t %c\n",((vc.type>>6)&1)?'y':'n');
43 printf("scalable:\t %c\n",((vc.type>>7)&1)?'y':'n');
44 printf("monochrome:\t %c\n",((vc.type>>8)&1)?'y':'n');
45 printf("subcapture:\t %c\n",((vc.type>>9)&1)?'y':'n');
47 if((vc.type>>10)&1) printf("mpeg ");
48 if((vc.type>>12)&1) printf("mjpeg ");
51 if((vc.type>>11)&1) printf("mpeg ");
52 if((vc.type>>13)&1) printf("mjpeg ");
54 printf("channels:\t %d\n",vc.channels);
55 printf("audios:\t\t %d\n",vc.audios);
56 printf("width:\t\t %d - %d\n",vc.minwidth,vc.maxwidth);
57 printf("height:\t\t %d - %d\n\n",vc.minheight,vc.maxheight);
59 if(ioctl(fd,VIDIOCGFBUF,&vb)<0)
60 puts("direct framebuffer access unsupported");
64 printf("framebuffer:\n");
65 printf("buffer addr:\t %d\n",vb.base);
66 printf("h: %d - w: %d - d: %d - bpl: %d\n\n",vb.height,vb.width,vb.depth,vb.bytesperline);
69 if(ioctl(fd,VIDIOCGWIN,&vw)<0) {
70 puts("ioctl VIDIOCGWIN failed");
74 printf("capture area:\n");
75 printf("x: %u - y: %u\n",vw.x,vw.y);
76 printf("w: %u - h: %u\n",vw.width,vw.height);