From: hackbard Date: Fri, 29 Aug 2003 19:14:53 +0000 (+0000) Subject: v4l tests X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Fivac.git;a=commitdiff_plain;h=7d2e0c946446baafb21df665dbaa2b58bbd682fd v4l tests --- diff --git a/test.c b/test.c new file mode 100644 index 0000000..2ad2ba8 --- /dev/null +++ b/test.c @@ -0,0 +1,9 @@ +#include +#include "v4lapi.h" + +int main(void) { + + v4l_init("/dev/v4l/video0"); + + return 1; +} diff --git a/v4lapi.c b/v4lapi.c new file mode 100644 index 0000000..a85a8a1 --- /dev/null +++ b/v4lapi.c @@ -0,0 +1,79 @@ +/* + * v4lapi.c -- api to the video4linux interface + * + * author: hackbard@hackdaworld.dyndns.org + * + */ + +#include +#include +#include +#include +#include + +#include + +int v4l_init(char *dev) { + int fd; + struct video_capability vc; + struct video_buffer vb; + struct video_window vw; + + if((fd=open(dev,O_RDONLY))<0) { + puts("open failed"); + return -1; + } + + if(ioctl(fd,VIDIOCGCAP,&vc)<0) { + puts("ioctl VIDIOCGCAP failed"); + return -1; + } + + printf("video device information:\n"); + printf("-------------------------\n\n"); + printf("interface name: %s\n\n",vc.name); + printf("type:\n"); + printf("capture:\t %c\n",(vc.type&1)?'y':'n'); + printf("tuner:\t\t %c\n",((vc.type>>1)&1)?'y':'n'); + printf("teletext:\t %c\n",((vc.type>>2)&1)?'y':'n'); + printf("overlay:\t %c\n",((vc.type>>3)&1)?'y':'n'); + printf("chromakey:\t %c\n",((vc.type>>4)&1)?'y':'n'); + printf("clipping:\t %c\n",((vc.type>>5)&1)?'y':'n'); + printf("fb memory:\t %c\n",((vc.type>>6)&1)?'y':'n'); + printf("scalable:\t %c\n",((vc.type>>7)&1)?'y':'n'); + printf("monochrome:\t %c\n",((vc.type>>8)&1)?'y':'n'); + printf("subcapture:\t %c\n",((vc.type>>9)&1)?'y':'n'); + printf("decode: "); + if((vc.type>>10)&1) printf("mpeg "); + if((vc.type>>12)&1) printf("mjpeg "); + printf("\n"); + printf("encode: "); + if((vc.type>>11)&1) printf("mpeg "); + if((vc.type>>13)&1) printf("mjpeg "); + printf("\n\n"); + printf("channels:\t %d\n",vc.channels); + printf("audios:\t\t %d\n",vc.audios); + 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) + puts("direct framebuffer access unsupported"); + puts(""); + else { + printf("\n"); + printf("framebuffer:\n"); + printf("buffer addr:\t %d\n",vb.base); + printf("h: %d - w: %d - d: %d - bpl: %d\n\n",vb.height,vb.width,vb.depth,vb.bytesperline); + } + + if(ioctl(fd,VIDIOCGWIN,&vw)<0) { + puts("ioctl VIDIOCGWIN failed"); + return -1; + } + + printf("capture area:\n"); + printf("x: %u - y: %u\n",vw.x,vw.y); + printf("w: %u - h: %u\n",vw.width,vw.height); + printf(" + return 1; +} diff --git a/v4lapi.h b/v4lapi.h new file mode 100644 index 0000000..25d3210 --- /dev/null +++ b/v4lapi.h @@ -0,0 +1,5 @@ +/* + * v4lapi.h -- function prototypes + */ + +int v4l_init(char *dev); diff --git a/v4lapi.o b/v4lapi.o new file mode 100644 index 0000000..4ffba81 Binary files /dev/null and b/v4lapi.o differ