From 7d2e0c946446baafb21df665dbaa2b58bbd682fd Mon Sep 17 00:00:00 2001 From: hackbard Date: Fri, 29 Aug 2003 19:14:53 +0000 Subject: [PATCH] v4l tests --- test.c | 9 +++++++ v4lapi.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ v4lapi.h | 5 ++++ v4lapi.o | Bin 0 -> 2796 bytes 4 files changed, 93 insertions(+) create mode 100644 test.c create mode 100644 v4lapi.c create mode 100644 v4lapi.h create mode 100644 v4lapi.o 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 0000000000000000000000000000000000000000..4ffba810347ab5899624c5538ed8d23809627a04 GIT binary patch literal 2796 zcmai$Uu+ar6vofCi?mxvD-sn+bP`&FAghIHVlin=yEd(jkYEvmU}k6TvSW8=HnX#Z z^+m|i*tH=(8Hn+rCIlhz!8huQ5lT>BeGvkQAefYtL`ke9reXcg?77=*1NA1e=lsrh z?zw;F&dh$C7=AMniI8p)YNSOXYJ04zbcJR!wNR5z4edzzkG*@2-JJqVCYpZiZ;x`g z9BrRns8lNBKa?-GPV8(XVkI*6`q2{yrpxcQH!UW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