diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-11-15 15:42:04 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-11-15 15:42:04 -0200 |
commit | 06700d6b31366059ca963dd4aba34ea2e57aaa05 (patch) | |
tree | c7119f367f12df373a282ce01305b02feff23e4f /v4l2-apps/test/ioctl-test.c | |
parent | e73ea31dcd5884251424ccbf13a0d515f8914c27 (diff) | |
download | mediapointer-dvb-s2-06700d6b31366059ca963dd4aba34ea2e57aaa05.tar.gz mediapointer-dvb-s2-06700d6b31366059ca963dd4aba34ea2e57aaa05.tar.bz2 |
Initiated v4l-apps/lib V4L2 functions
From: Mauro Carvalho Chehab <mchehab@infradead.org>
- Created v4l2_driver.c with some basic functions to:
. Enum STD, INPUT and FORMAT
. GET/SET STD and INPUT
. GET PARAM
- ioctl-test reverted back to a simple "brute-force" all ioctl call;
- driver-test created to:
. test V4L2 kernel drivers;
. implement all functions provided by v4l2 library
- driver-test should grow following the changes at v4l2-apps/lib
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'v4l2-apps/test/ioctl-test.c')
-rw-r--r-- | v4l2-apps/test/ioctl-test.c | 193 |
1 files changed, 0 insertions, 193 deletions
diff --git a/v4l2-apps/test/ioctl-test.c b/v4l2-apps/test/ioctl-test.c index 335ccf102..f483338fb 100644 --- a/v4l2-apps/test/ioctl-test.c +++ b/v4l2-apps/test/ioctl-test.c @@ -210,192 +210,6 @@ int ioctls[] = { /********************************************************************/ -int get_capabilities (int fd, union v4l_parms *p) -{ - int ret; - - ret=ioctl(fd,VIDIOC_QUERYCAP,(void *) &p); - if (ret>=0) { - struct v4l2_capability *pq= (struct v4l2_capability *)&p; - printf ("driver=%s, card=%s, bus=%s, version=0x%08x, " - "capabilities=0x%08x\n", - pq->driver,pq->card,pq->bus_info, - pq->version, - pq->capabilities); - } - return ret; -} - -#define ERR "*** ERROR " -#define WARN "* Warning " - -int get_set_stds (int fd, union v4l_parms *p) -{ - struct v4l2_standard *pq=(void *)p; - int ok=0,ret,i; - v4l2_std_id id; - - for (i=0; ok==0; i++) { - pq->index=i; - ok=ioctl(fd,VIDIOC_ENUMSTD,pq); - if (ok>=0) { - printf ("STANDARD: index=%d, id=%Ld, name=%s, fps=%.3f, " - "framelines=%d\n", pq->index, - (unsigned long long)pq->id, pq->name, - 1.*pq->frameperiod.denominator/pq->frameperiod.numerator, - pq->framelines); - } else - break; - id=pq->id; - p->id=id; - ret=ioctl(fd,VIDIOC_S_STD,p); - if (ret) { - printf (ERR "%i while trying to set STD to %08x\n",ret, - (unsigned int) id); - } - ret=ioctl(fd,VIDIOC_G_STD,p); - if (ret) { - printf (ERR "%i while trying to get STD id\n",ret); - } - if (id & p->id) { - if (id != p->id) { - printf (WARN "Received a std subset (%08x std) while trying to adjust to %08x\n", - (unsigned int) p->id,(unsigned int) id); - } - } else - printf (ERR "Received %08x std while trying to adjust to %08x\n", - (unsigned int) p->id,(unsigned int) id); - - } - return ok; -} - -int get_set_inputs (int fd, union v4l_parms *arg) -{ - struct v4l2_input *p=(void *)arg; - int ok=0,ret,i; - int input; - - for (i=0; ok==0; i++) { - p->index=i; - ok=ioctl(fd,VIDIOC_ENUMINPUT,p); - if (ok>=0) { - - printf ("INPUT: index=%d, name=%s, type=%d, audioset=%d, " - "tuner=%d, std=%08x, status=%d\n", - p->index,p->name,p->type,p->audioset, - p->tuner, - (unsigned int)p->std, - p->status); - - } else - break; - input=p->index; - arg->i=input; - ret=ioctl(fd,VIDIOC_S_INPUT,arg); - if (ret) { - printf (ERR "%i while trying to set INPUT to %d\n",ret, - input); - } - ret=ioctl(fd,VIDIOC_G_INPUT,arg); - if (ret) { - printf (ERR "%i while trying to get INPUT id\n",ret); - } - if (input != arg->i) { - printf ("Input is different than expected (received %i, set %i)\n", - input, p->index); - } - } - return ok; -} - -int get_set_formats (int fd, union v4l_parms *arg) -{ - struct v4l2_fmtdesc *p=(void *)arg; - int ok=0,ret,i; - struct v4l2_format fmt; - struct v4l2_streamparm parm; - struct v4l2_captureparm *c; - - - for (i=0; ok==0; i++) { - p->index=i; - p->type=V4L2_BUF_TYPE_VIDEO_CAPTURE; - - ok=ioctl(fd,VIDIOC_ENUM_FMT,p); - if (ok>=0) { - printf ("FORMAT: index=%d, type=%d, flags=%d, description=%s\n\t" - "pixelformat=0x%08x\n", - p->index, p->type, p->flags,p->description, - p->pixelformat); - } else - break; - - parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (ioctl(fd,VIDIOC_G_PARM,&parm)>=0) { - c=&parm.parm.capture; - printf ("PARM: capability=%d, capturemode=%d, frame time =%.3f ns " - "ext=%x, readbuf=%d\n", - c->capability, - c->capturemode, - 100.*c->timeperframe.numerator/c->timeperframe.denominator, - c->extendedmode, c->readbuffers); - } else - perror ("VIDIOC_G_PARM"); - -#if 0 - fmt.type=p->type; - fmt.pixelformat=p->pixelformat; - - ret=ioctl(fd,VIDIOC_G_FMT,arg); - if (ret < 0) { - printf("VIDIOC_G_FMT failed\n"); - continue; - } - - switch (f->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - - err = cx8800_try_fmt(dev,fh,f); - if (0 != err) - return err; - - fmt.pixelformat=p->pixelformat; - fmt. - fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); - fh->width = f->fmt.pix.width; - fh->height = f->fmt.pix.height; - fh->vidq.field = f->fmt.pix.field; - return 0; - case V4L2_BUF_TYPE_VBI_CAPTURE: - cx8800_vbi_fmt(dev, f); - return 0; - default: - printf(WARN "format type not implemented\n"); - continue; - } - - - input=p->index; - arg->i=input; - ret=ioctl(fd,VIDIOC_S_INPUT,arg); - if (ret) { - printf (ERR "%i while trying to set INPUT to %d\n",ret, - input); - } - ret=ioctl(fd,VIDIOC_G_INPUT,arg); - if (ret) { - printf (ERR "%i while trying to get INPUT id\n",ret); - } - if (input != arg->i) { - printf ("Input is different than expected (received %i, set %i)\n", - input, p->index); - } -#endif - } - return ok; -} - int main (void) { int fd=0, ret=0; @@ -408,18 +222,11 @@ int main (void) return(-1); } - get_capabilities (fd, &p); - get_set_stds (fd, &p); - get_set_inputs (fd, &p); - get_set_formats (fd, &p); - -#if 0 for (i=0;i<S_IOCTLS;i++) { memset(&p,0,sizeof(p)); ret=ioctl(fd,ioctls[i], (void *) &p); printf("%i: ioctl=0x%08x, return=%d\n",i, ioctls[i], ret); } -#endif close (fd); |