From 43315dd15292f6e2b75eefed38c75fb14fa12745 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 20 Dec 2006 12:42:37 -0200 Subject: Improved error handling at driver-test.c From: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- v4l2-apps/lib/v4l2_driver.c | 5 ++--- v4l2-apps/test/driver-test.c | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'v4l2-apps') diff --git a/v4l2-apps/lib/v4l2_driver.c b/v4l2-apps/lib/v4l2_driver.c index 69c873abb..24ed2846b 100644 --- a/v4l2-apps/lib/v4l2_driver.c +++ b/v4l2-apps/lib/v4l2_driver.c @@ -170,12 +170,11 @@ int v4l2_open (char *device, int debug, struct v4l2_driver *drv) drv->debug=debug; if ((drv->fd = open(device, O_RDWR )) < 0) { - perror("Couldn't open video0"); - return(errno); + return(-errno); } ret=xioctl(drv->fd,VIDIOC_QUERYCAP,(void *) &drv->cap); - if (ret>=0 && drv->debug) { + if (!ret && drv->debug) { printf ("driver=%s, card=%s, bus=%s, version=%d.%d.%d, " "capabilities=%s\n", drv->cap.driver,drv->cap.card,drv->cap.bus_info, diff --git a/v4l2-apps/test/driver-test.c b/v4l2-apps/test/driver-test.c index 61f6b812a..eaa099fac 100644 --- a/v4l2-apps/test/driver-test.c +++ b/v4l2-apps/test/driver-test.c @@ -33,19 +33,20 @@ int main(void) unsigned int count = 10, i; if (v4l2_open ("/dev/video0", 1,&drv)<0) { - perror("open"); + perror("open /dev/video0"); return -1; } if (v4l2_enum_stds (&drv)<0) { perror("enum_stds"); - } - - /* Tries all video standards */ - for (cur=drv.stds;cur!=NULL;cur=cur->next) { - v4l2_std_id id=((struct v4l2_standard *)cur->curr)->id; - if (cur->curr) - if (v4l2_setget_std (&drv, V4L2_SET_GET, &id)) - perror("set_std"); + printf("Error! Driver is not reporting supported STD, frames/sec and number of lines!\n Trying to continue anyway...\n"); + } else { + /* Tries all video standards */ + for (cur=drv.stds;cur!=NULL;cur=cur->next) { + v4l2_std_id id=((struct v4l2_standard *)cur->curr)->id; + if (cur->curr) + if (v4l2_setget_std (&drv, V4L2_SET_GET, &id)) + perror("set_std"); + } } if (v4l2_enum_input (&drv)<0) { -- cgit v1.2.3