Âllo Michel,
On Mon, Mar 17, 2008 at 13:28:50 +0100, Michel Xhaard wrote:
> Moritz,
> Thanks for all your patchs ;-)
Thanks for your feedback. :)
If these patches are really of interest, I've been hacking around a
little more.
First I noticed that the famous test.c displays an identification
string describing the device (coming from cap.card). I thought this
would be extremely useful, because I had accidentally been trying to
use luvcview with my TV card ;-) (which is on /dev/video1, and I had
forgotten about).
Then, just yesterday, I noticed in my "motion" logs that it too lists
this string, and it lists all (most of) the detected capabilities. I
thought this too would be nifty, as luvcview already checks a few of
them (e.g. to make sure it can function properly).
At the same time, I saw that a lot of code was basically duplicated in
those sections (v4l_init() for example). So I went through the pain of
taking that apart. Not sure I got it right.
Attached is a patch which attempts to do all these three things. I must
say I do not have a device which doesn't support streaming, therefore I
could not test those coded error conditions. But apart from that, it
works for me. :-) (There's one warning in compiling the code where I
tried to avoid passing a possible NULL pointer to printf(). Oh well.)
This is what my TV card looks like now (sorry, no UVC device connected
currently, I'm not physically next to my machine):
-- snip --
[EMAIL PROTECTED]:~ > luvcview -d /dev/video1 -L
luvcview version 0.2.2
Video driver: x11
A window manager is available
Video device /dev/video1
Device is "Terratec Cinergy 400 TV"
on bus "PCI:0000:03:0b.0"
Device capabilities:
- VIDEO_CAPTURE (is a video capture device)
- VIDEO_OVERLAY (can do video overlay)
- VBI_CAPTURE (is a raw VBI capture device)
- TUNER (has a tuner)
- READWRITE (supports read/write system calls)
- STREAMING (supports streaming I/O ioctls)
{ pixelformat = 'GREY', description = '8 bpp gray' }
{ pixelformat = 'RGBO', description = '15 bpp RGB, le' }
[...more pixelformats...]
-- snip --
The two other patches align my recent whitespace and perror patches to
this new patch. All three apply nicely on top of each other.
See if you can make any use of this. I find it quite practical.
Kind regards,
Moritzdiff -ur luvcview-20070512/luvcview.c
luvcview-20070512-name_and_capabilities/luvcview.c
--- luvcview-20070512/luvcview.c 2007-05-12 12:03:14.000000000 +0200
+++ luvcview-20070512-name_and_capabilities/luvcview.c 2008-03-17
23:36:19.000000000 +0100
@@ -425,7 +425,9 @@
if ( queryformats ) {
/* if we're supposed to list the video formats, do that now and go out */
check_videoIn(videoIn,(char *) videodevice);
- free(videoIn);
+ free(videoIn->videodevice);
+ free(videoIn->status);
+ free(videoIn);
SDL_Quit();
exit(1);
}
diff -ur luvcview-20070512/v4l2uvc.c
luvcview-20070512-name_and_capabilities/v4l2uvc.c
--- luvcview-20070512/v4l2uvc.c 2007-05-08 17:39:40.000000000 +0200
+++ luvcview-20070512-name_and_capabilities/v4l2uvc.c 2008-03-18
00:33:38.000000000 +0100
@@ -34,39 +34,68 @@
int check_videoIn(struct vdIn *vd, char *device)
{
-int ret;
- if (vd == NULL || device == NULL)
- return -1;
- vd->videodevice = (char *) calloc(1, 16 * sizeof(char));
- snprintf(vd->videodevice, 12, "%s", device);
- printf("video %s \n", vd->videodevice);
+ /* return value:
+ * 0 - okay
+ * 1 - opening device failed
+ * 2 - device opened, but some other failure
+ */
+ int ret;
+ char buf[512];
+ if (vd == NULL || device == NULL)
+ return -2; /* stupid error if it happens */
+ vd->videodevice = (char *) calloc(1, 16 * sizeof(char));
+ snprintf(vd->videodevice, 12, "%s", device);
+ printf("Video device %s\n", vd->videodevice);
if ((vd->fd = open(vd->videodevice, O_RDWR)) == -1) {
- perror("ERROR opening V4L interface \n");
- exit(1);
+ perror("ERROR opening V4L interface");
+ return -1;
}
memset(&vd->cap, 0, sizeof(struct v4l2_capability));
ret = ioctl(vd->fd, VIDIOC_QUERYCAP, &vd->cap);
if (ret < 0) {
- printf("Error opening device %s: unable to query device.\n",
- vd->videodevice);
- goto fatal;
- }
- if ((vd->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
- printf("Error opening device %s: video capture not supported.\n",
- vd->videodevice);
- }
- if (!(vd->cap.capabilities & V4L2_CAP_STREAMING)) {
- printf("%s does not support streaming i/o\n", vd->videodevice);
- }
- if (!(vd->cap.capabilities & V4L2_CAP_READWRITE)) {
- printf("%s does not support read i/o\n", vd->videodevice);
- }
+ snprintf(buf, sizeof(buf), "Error opening device %s: unable to query
device", vd->videodevice);
+ perror(buf);
+ return -2;
+ }
+
+ printf("Device is \"%s\"\n\ton bus \"%s\"\n",
+ vd->cap.card, (vd->cap.bus_info) ? (vd->cap.bus_info) : "<unknown>"
);
+
+ printf("Device capabilities:\n");
+ if (vd->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)
+ printf("- VIDEO_CAPTURE (is a video capture device)\n");
+ else
+ printf("* WARNING: video capture not supported\n");
+ if (vd->cap.capabilities & V4L2_CAP_VIDEO_OUTPUT)
+ printf("- VIDEO_OUTPUT (is a video output device)\n");
+ if (vd->cap.capabilities & V4L2_CAP_VIDEO_OVERLAY)
+ printf("- VIDEO_OVERLAY (can do video overlay)\n");
+ if (vd->cap.capabilities & V4L2_CAP_VBI_CAPTURE)
+ printf("- VBI_CAPTURE (is a raw VBI capture device)\n");
+ if (vd->cap.capabilities & V4L2_CAP_VBI_OUTPUT)
+ printf("- VBI_OUTPUT (is a raw VBI output device)\n");
+ if (vd->cap.capabilities & V4L2_CAP_RDS_CAPTURE)
+ printf("- RDS_CAPTURE (supports RDS data capture)\n");
+ if (vd->cap.capabilities & V4L2_CAP_TUNER)
+ printf("- TUNER (has a tuner)\n");
+ if (vd->cap.capabilities & V4L2_CAP_AUDIO)
+ printf("- AUDIO (has audio support)\n");
+ if (vd->cap.capabilities & V4L2_CAP_READWRITE)
+ printf("- READWRITE (supports read/write system calls)\n");
+ else
+ printf("* WARNING: read I/O not supported\n");
+ if (vd->cap.capabilities & V4L2_CAP_ASYNCIO)
+ printf("- ASYNCIO (supports async I/O)\n");
+ if (vd->cap.capabilities & V4L2_CAP_STREAMING)
+ printf("- STREAMING (supports streaming I/O ioctls)\n");
+ else
+ printf("* WARNING: streaming I/O not supported\n");
+
+ printf("\n");
enum_frame_formats(vd->fd);
-fatal:
- close(vd->fd);
- free(vd->videodevice);
return 0;
}
+
int
init_videoIn(struct vdIn *vd, char *device, int width, int height, int fps,
int format, int grabmethod, char *avifilename)
@@ -86,7 +115,6 @@
vd->status = (char *) calloc(1, 100 * sizeof(char));
vd->pictName = (char *) calloc(1, 80 * sizeof(char));
snprintf(vd->videodevice, 12, "%s", device);
- printf("video %s \n", vd->videodevice);
vd->toggleAvi = 0;
vd->avifile = NULL;
vd->avifilename = avifilename;
@@ -314,36 +342,36 @@
static int init_v4l2(struct vdIn *vd)
{
int i;
- int ret = 0;
+ int ret;
+ int retval = 0;
- if ((vd->fd = open(vd->videodevice, O_RDWR)) == -1) {
- perror("ERROR opening V4L interface \n");
+ ret = check_videoIn(vd, vd->videodevice);
+
+ if (ret == -1) {
+ /* failed to open device */
exit(1);
}
- memset(&vd->cap, 0, sizeof(struct v4l2_capability));
- ret = ioctl(vd->fd, VIDIOC_QUERYCAP, &vd->cap);
- if (ret < 0) {
- printf("Error opening device %s: unable to query device.\n",
- vd->videodevice);
- goto fatal;
+ if (ret == -2) {
+ /* opening succeeded, but other failure - close now */
+ return -1;
}
-
- if ((vd->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
- printf("Error opening device %s: video capture not supported.\n",
- vd->videodevice);
- goto fatal;;
+ if (!(vd->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
+ printf("ERROR: video capture (V4L2_CAP_VIDEO_CAPTURE) not supported\n");
+ retval = -1;
}
if (vd->grabmethod) {
if (!(vd->cap.capabilities & V4L2_CAP_STREAMING)) {
- printf("%s does not support streaming i/o\n", vd->videodevice);
- goto fatal;
+ printf("ERROR: streaming I/O (V4L2_CAP_STREAMING) not supported\n");
+ retval = -1;
}
} else {
if (!(vd->cap.capabilities & V4L2_CAP_READWRITE)) {
- printf("%s does not support read i/o\n", vd->videodevice);
- goto fatal;
+ printf("ERROR: read I/O (V4L2_CAP_READWRITE) not supported\n");
+ retval = -1;
}
}
+ if (retval)
+ return retval;
/* set format in */
memset(&vd->fmt, 0, sizeof(struct v4l2_format));
vd->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -354,7 +382,7 @@
ret = ioctl(vd->fd, VIDIOC_S_FMT, &vd->fmt);
if (ret < 0) {
printf("Unable to set format: %d.\n", errno);
- goto fatal;
+ return -1;
}
if ((vd->fmt.fmt.pix.width != vd->width) ||
(vd->fmt.fmt.pix.height != vd->height)) {
@@ -384,7 +412,7 @@
ret = ioctl(vd->fd, VIDIOC_REQBUFS, &vd->rb);
if (ret < 0) {
printf("Unable to allocate buffers: %d.\n", errno);
- goto fatal;
+ return -1;
}
/* map the buffers */
for (i = 0; i < NB_BUFFER; i++) {
@@ -395,7 +423,7 @@
ret = ioctl(vd->fd, VIDIOC_QUERYBUF, &vd->buf);
if (ret < 0) {
printf("Unable to query buffer (%d).\n", errno);
- goto fatal;
+ return -1;
}
if (debug)
printf("length: %u offset: %u\n", vd->buf.length,
@@ -405,7 +433,7 @@
vd->buf.m.offset);
if (vd->mem[i] == MAP_FAILED) {
printf("Unable to map buffer (%d)\n", errno);
- goto fatal;
+ return -1;
}
if (debug)
printf("Buffer mapped at address %p.\n", vd->mem[i]);
@@ -419,13 +447,10 @@
ret = ioctl(vd->fd, VIDIOC_QBUF, &vd->buf);
if (ret < 0) {
printf("Unable to queue buffer (%d).\n", errno);
- goto fatal;;
+ return -1;
}
}
return 0;
- fatal:
- return -1;
-
}
static int video_enable(struct vdIn *vd)
diff -ur luvcview-20070512-name_and_capabilities/avilib.c
luvcview-20070512-name_and_capabilities-whitespace/avilib.c
--- luvcview-20070512-name_and_capabilities/avilib.c 2006-09-20
17:47:36.000000000 +0200
+++ luvcview-20070512-name_and_capabilities-whitespace/avilib.c 2008-03-18
00:34:43.000000000 +0100
@@ -616,7 +616,7 @@
readable in the most cases */
idxerror = 0;
- // fprintf(stderr, "pos=%lu, index_len=%ld \n", AVI->pos,
AVI->n_idx*16);
+ // fprintf(stderr, "pos=%lu, index_len=%ld\n", AVI->pos, AVI->n_idx*16);
ret = avi_add_chunk(AVI, (unsigned char *)"idx1", (unsigned char
*)AVI->idx, AVI->n_idx*16);
hasIndex = (ret==0);
//fprintf(stderr, "pos=%lu, index_len=%d\n", AVI->pos, hasIndex);
diff -ur luvcview-20070512-name_and_capabilities/luvcview.c
luvcview-20070512-name_and_capabilities-whitespace/luvcview.c
--- luvcview-20070512-name_and_capabilities/luvcview.c 2008-03-17
23:36:19.000000000 +0100
+++ luvcview-20070512-name_and_capabilities-whitespace/luvcview.c
2008-03-18 00:34:43.000000000 +0100
@@ -238,7 +238,7 @@
- printf("luvcview version %s \n", version);
+ printf("luvcview version %s\n", version);
for (i = 1; i < argc; i++) {
/* skip bad arguments */
if (argv[i] == NULL || *argv[i] == 0 || *argv[i] != '-') {
@@ -287,24 +287,24 @@
width = strtoul(sizestring, &separateur, 10);
if (*separateur != 'x') {
- printf("Error in size use -s widthxheight \n");
+ printf("Error in size use -s widthxheight\n");
exit(1);
} else {
++separateur;
height = strtoul(separateur, &separateur, 10);
if (*separateur != 0)
- printf("hmm.. dont like that!! trying this height \n");
- printf(" size width: %d height: %d \n", width, height);
+ printf("hmm.. dont like that!! trying this height\n");
+ printf(" size width: %d height: %d\n", width, height);
}
}
if (strcmp(argv[i], "-i") == 0){
if (i + 1 >= argc) {
- printf("No parameter specified with -i, aborting. \n");
+ printf("No parameter specified with -i, aborting.\n");
exit(1);
}
fpsstring = strdup(argv[i + 1]);
fps = strtoul(fpsstring, &separateur, 10);
- printf(" interval: %d fps \n", fps);
+ printf(" interval: %d fps\n", fps);
}
if (strcmp(argv[i], "-S") == 0) {
/* Enable raw stream capture from the start */
@@ -340,14 +340,14 @@
readconfigfile = 1;
}
if (strcmp(argv[i], "-h") == 0) {
- printf("usage: uvcview [-h -d -g -f -s -i -c -o -C -S -L -l -r]
\n");
- printf("-h print this message \n");
+ printf("usage: uvcview [-h -d -g -f -s -i -c -o -C -S -L -l -r]\n");
+ printf("-h print this message\n");
printf("-d /dev/videoX use videoX device\n");
- printf("-g use read method for grab instead mmap \n");
- printf("-w disable SDL hardware accel. \n");
- printf("-f video format default jpg others options are yuv jpg
\n");
- printf("-i fps use specified frame interval \n");
- printf("-s widthxheight use specified input size \n");
+ printf("-g use read method for grab instead mmap\n");
+ printf("-w disable SDL hardware accel.\n");
+ printf("-f video format default jpg others options are yuv
jpg\n");
+ printf("-i fps use specified frame interval\n");
+ printf("-s widthxheight use specified input size\n");
printf("-c enable raw frame capturing for the first frame\n");
printf("-C enable raw frame stream capturing from the start\n");
printf("-S enable raw stream capturing from the start\n");
@@ -489,7 +489,7 @@
}
lasttime = currtime;
if (uvcGrab(videoIn) < 0) {
- printf("Error grabbing \n");
+ printf("Error grabbing\n");
break;
}
@@ -542,7 +542,7 @@
free(videoIn);
destroyButt();
freeLut();
- printf(" Clean Up done Quit \n");
+ printf(" Clean Up done Quit\n");
SDL_Quit();
}
@@ -642,7 +642,7 @@
case A_CONTRAST_UP:
if ((value =
v4l2UpControl(videoIn, V4L2_CID_CONTRAST)) < 0)
- printf("Set Contrast up error \n");
+ printf("Set Contrast up error\n");
break;
case A_SATURATION_UP:
if ((value =
@@ -824,7 +824,7 @@
if ((value = ioctl(videoIn->fd, VIDIOC_S_CTRL, &control)) < 0)
printf("Set Auto Exposure on error\n");
else
- printf("Auto Exposure set to %d \n", control.value);
+ printf("Auto Exposure set to %d\n", control.value);
break;
case A_EXPOSURE_OFF:
control.id =V4L2_CID_EXPOSURE_AUTO;
@@ -832,7 +832,7 @@
if ((value = ioctl(videoIn->fd, VIDIOC_S_CTRL, &control)) < 0)
printf("Set Auto Exposure off error\n");
else
- printf("Auto Exposure set to %d \n", control.value);
+ printf("Auto Exposure set to %d\n", control.value);
break;
case A_BALANCE_UP:
if ((value = v4l2UpControl(videoIn,
V4L2_CID_WHITE_BALANCE_TEMPERATURE)) < 0)
@@ -848,7 +848,7 @@
if ((value = ioctl(videoIn->fd, VIDIOC_S_CTRL, &control)) < 0)
printf("Set Auto Balance on error\n");
else
- printf("Auto Balance set to %d \n", control.value);
+ printf("Auto Balance set to %d\n", control.value);
break;
case A_BALANCE_OFF:
control.id =V4L2_CID_WHITE_BALANCE_TEMPERATURE_AUTO;
@@ -856,14 +856,14 @@
if ((value = ioctl(videoIn->fd, VIDIOC_S_CTRL, &control)) < 0)
printf("Set Auto Balance off error\n");
else
- printf("Auto Balance set to %d \n", control.value);
+ printf("Auto Balance set to %d\n", control.value);
break;
case A_SAVE:
- printf("Save controls \n");
+ printf("Save controls\n");
save_controls(videoIn->fd);
break;
case A_LOAD:
- printf("load controls \n");
+ printf("load controls\n");
load_controls(videoIn->fd);
break;
default:
@@ -883,7 +883,7 @@
}
SDL_Delay(50);
- //printf("fp/s %d \n",frmrate);
+ //printf("fp/s %d\n",frmrate);
} //end main loop
/* Close the stream capture file */
diff -ur luvcview-20070512-name_and_capabilities/utils.c
luvcview-20070512-name_and_capabilities-whitespace/utils.c
--- luvcview-20070512-name_and_capabilities/utils.c 2007-05-12
12:13:11.000000000 +0200
+++ luvcview-20070512-name_and_capabilities-whitespace/utils.c 2008-03-18
00:34:43.000000000 +0100
@@ -191,7 +191,7 @@
return 0;
case M_DQT:
- //printf("find DQT \n");
+ //printf("find DQT\n");
lq = getword();
while (lq > 2) {
pq = getbyte();
@@ -208,7 +208,7 @@
break;
case M_DHT:
- //printf("find DHT \n");
+ //printf("find DHT\n");
l = getword();
while (l > 2) {
int hufflen[16], k;
@@ -235,7 +235,7 @@
break;
case M_DRI:
- printf("find DRI \n");
+ printf("find DRI\n");
l = getword();
info.dri = getword();
break;
@@ -385,7 +385,7 @@
if (i != 0 || j != 63 || m != 0) {
printf("hmm FW error,not seq DCT ??\n");
}
- // printf("ext huffman table %d \n",isInitHuffman);
+ // printf("ext huffman table %d\n",isInitHuffman);
if(!isInitHuffman) {
if(huffman_init() < 0)
return -ERR_BAD_TABLES;
@@ -1250,7 +1250,7 @@
if(picture){
Pyuv422torgb24(buf, picture, width, height);
}else{
- printf(" no room to take a picture \n");
+ printf(" no room to take a picture\n");
return 0;
}
if(name){
diff -ur luvcview-20070512-name_and_capabilities/v4l2uvc.c
luvcview-20070512-name_and_capabilities-whitespace/v4l2uvc.c
--- luvcview-20070512-name_and_capabilities/v4l2uvc.c 2008-03-18
00:33:38.000000000 +0100
+++ luvcview-20070512-name_and_capabilities-whitespace/v4l2uvc.c
2008-03-18 00:34:43.000000000 +0100
@@ -136,7 +136,7 @@
vd->bytesWritten = 0;
vd->framesWritten = 0;
if (init_v4l2(vd) < 0) {
- printf(" Init v4L2 failed !! exit fatal \n");
+ printf(" Init v4L2 failed !! exit fatal\n");
goto error;;
}
/* alloc a temp buffer to reconstruct the pict */
@@ -215,7 +215,7 @@
control_s.id=queryctrl.id;
ioctl(vd, VIDIOC_G_CTRL, &control_s);
SDL_Delay(10);
- printf (" index:%-10d name:%-32s type:%d min:%-5d max:%-5d step:%-5d
def:%-5d now:%d \n",
+ printf (" index:%-10d name:%-32s type:%d min:%-5d max:%-5d step:%-5d
def:%-5d now:%d\n",
queryctrl.id, queryctrl.name, queryctrl.type, queryctrl.minimum,
queryctrl.maximum, queryctrl.step, queryctrl.default_value,
control_s.value);
if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
@@ -238,7 +238,7 @@
control_s.id=queryctrl.id;
ioctl(vd, VIDIOC_G_CTRL, &control_s);
SDL_Delay(20);
- printf (" index:%-10d name:%-32s type:%d min:%-5d max:%-5d step:%-5d
def:%-5d now:%d \n",
+ printf (" index:%-10d name:%-32s type:%d min:%-5d max:%-5d step:%-5d
def:%-5d now:%d\n",
queryctrl.id, queryctrl.name, queryctrl.type, queryctrl.minimum,
queryctrl.maximum, queryctrl.step, queryctrl.default_value,
control_s.value);
if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
@@ -323,16 +323,16 @@
printf( "configfile luvcview.cfg open failed, errno = %d (%s)\n", errno,
strerror( errno));
}
else {
- printf("loading controls from luvcview.cfg \n");
+ printf("loading controls from luvcview.cfg\n");
char buffer[512];
fgets(buffer, sizeof(buffer), configfile);
while (NULL !=fgets(buffer, sizeof(buffer), configfile) )
{
sscanf(buffer, "%i%i", &control.id, &control.value);
if (ioctl(vd, VIDIOC_S_CTRL, &control))
- printf("ERROR id:%d val:%d \n", control.id, control.value);
+ printf("ERROR id:%d val:%d\n", control.id, control.value);
else
- printf("OK id:%d val:%d \n", control.id, control.value);
+ printf("OK id:%d val:%d\n", control.id, control.value);
SDL_Delay(20);
}
fclose(configfile);
@@ -386,7 +386,7 @@
}
if ((vd->fmt.fmt.pix.width != vd->width) ||
(vd->fmt.fmt.pix.height != vd->height)) {
- printf(" format asked unavailable get width %d height %d \n",
+ printf(" format asked unavailable get width %d height %d\n",
vd->fmt.fmt.pix.width, vd->fmt.fmt.pix.height);
vd->width = vd->fmt.fmt.pix.width;
vd->height = vd->fmt.fmt.pix.height;
@@ -594,7 +594,7 @@
goto err;
}
if (debug)
- printf("bytes in used %d \n", vd->buf.bytesused);
+ printf("bytes in used %d\n", vd->buf.bytesused);
break;
case V4L2_PIX_FMT_YUYV:
if (vd->buf.bytesused > vd->framesizeIn)
@@ -645,13 +645,13 @@
if ((err= ioctl(vd->fd, VIDIOC_QUERYCTRL, queryctrl)) < 0) {
printf("ioctl querycontrol error %d \n",errno);
} else if (queryctrl->flags & V4L2_CTRL_FLAG_DISABLED) {
- printf("control %s disabled \n", (char *) queryctrl->name);
+ printf("control %s disabled\n", (char *) queryctrl->name);
} else if (queryctrl->flags & V4L2_CTRL_TYPE_BOOLEAN) {
return 1;
} else if (queryctrl->type & V4L2_CTRL_TYPE_INTEGER) {
return 0;
} else {
- printf("contol %s unsupported \n", (char *) queryctrl->name);
+ printf("contol %s unsupported\n", (char *) queryctrl->name);
}
return -1;
}
@@ -708,7 +708,7 @@
val_def = queryctrl.default_value;
current = v4l2GetControl(vd, control);
current += step;
- printf("max %d, min %d, step %d, default %d ,current %d
\n",max,min,step,val_def,current);
+ printf("max %d, min %d, step %d, default %d ,current
%d\n",max,min,step,val_def,current);
if (current <= max) {
control_s.id = control;
control_s.value = current;
@@ -718,7 +718,7 @@
}
printf ("Control name:%s set to value:%d\n", queryctrl.name,
control_s.value);
} else {
- printf ("Control name:%s already has max value:%d \n", queryctrl.name,
max);
+ printf ("Control name:%s already has max value:%d\n", queryctrl.name,
max);
}
return control_s.value;
}
@@ -736,7 +736,7 @@
val_def = queryctrl.default_value;
current = v4l2GetControl(vd, control);
current -= step;
- printf("max %d, min %d, step %d, default %d ,current %d
\n",max,min,step,val_def,current);
+ printf("max %d, min %d, step %d, default %d ,current
%d\n",max,min,step,val_def,current);
if (current >= min) {
control_s.id = control;
control_s.value = current;
@@ -747,7 +747,7 @@
printf ("Control name:%s set to value:%d\n", queryctrl.name,
control_s.value);
}
else {
- printf ("Control name:%s already has min value:%d \n", queryctrl.name,
min);
+ printf ("Control name:%s already has min value:%d\n", queryctrl.name,
min);
}
return control_s.value;
}
diff -ur luvcview-20070512-name_and_capabilities/v4l2uvc.c
luvcview-20070512-name_and_capabilities-perror/v4l2uvc.c
--- luvcview-20070512-name_and_capabilities/v4l2uvc.c 2008-03-18
00:00:15.000000000 +0100
+++ luvcview-20070512-name_and_capabilities-perror/v4l2uvc.c 2008-03-18
00:06:52.000000000 +0100
@@ -230,7 +230,7 @@
} else {
if (errno == EINVAL)
continue;
- printf ("error getting base controls");
+ perror ("error getting base controls");
goto fatal_controls;
}
}
@@ -270,7 +270,7 @@
memset (&control_s, 0, sizeof (control_s));
configfile = fopen("luvcview.cfg", "w");
if ( configfile == NULL) {
- printf( "saving configfile luvcview.cfg failed, errno = %d (%s)\n", errno,
strerror( errno));
+ perror("saving configfile luvcview.cfg failed");
}
else {
fprintf(configfile, "id value # luvcview control settings
configuration file\n");
@@ -327,7 +327,7 @@
memset (&control, 0, sizeof (control));
configfile = fopen("luvcview.cfg", "r");
if ( configfile == NULL) {
- printf( "configfile luvcview.cfg open failed, errno = %d (%s)\n", errno,
strerror( errno));
+ perror("configfile luvcview.cfg open failed");
}
else {
printf("loading controls from luvcview.cfg \n");
@@ -385,7 +385,7 @@
vd->fmt.fmt.pix.field = V4L2_FIELD_ANY;
ret = ioctl(vd->fd, VIDIOC_S_FMT, &vd->fmt);
if (ret < 0) {
- printf("Unable to set format: %d.\n", errno);
+ perror("Unable to set format");
return -1;
}
if ((vd->fmt.fmt.pix.width != vd->width) ||
@@ -415,7 +415,7 @@
ret = ioctl(vd->fd, VIDIOC_REQBUFS, &vd->rb);
if (ret < 0) {
- printf("Unable to allocate buffers: %d.\n", errno);
+ perror("Unable to allocate buffers");
return -1;
}
/* map the buffers */
@@ -426,7 +426,7 @@
vd->buf.memory = V4L2_MEMORY_MMAP;
ret = ioctl(vd->fd, VIDIOC_QUERYBUF, &vd->buf);
if (ret < 0) {
- printf("Unable to query buffer (%d).\n", errno);
+ perror("Unable to query buffer");
return -1;
}
if (debug)
@@ -436,7 +436,7 @@
vd->buf.length, PROT_READ, MAP_SHARED, vd->fd,
vd->buf.m.offset);
if (vd->mem[i] == MAP_FAILED) {
- printf("Unable to map buffer (%d)\n", errno);
+ perror("Unable to map buffer");
return -1;
}
if (debug)
@@ -450,7 +450,7 @@
vd->buf.memory = V4L2_MEMORY_MMAP;
ret = ioctl(vd->fd, VIDIOC_QBUF, &vd->buf);
if (ret < 0) {
- printf("Unable to queue buffer (%d).\n", errno);
+ perror("Unable to queue buffer");
return -1;
}
}
@@ -464,7 +464,7 @@
ret = ioctl(vd->fd, VIDIOC_STREAMON, &type);
if (ret < 0) {
- printf("Unable to %s capture: %d.\n", "start", errno);
+ perror("Unable to start capture");
return ret;
}
vd->isstreaming = 1;
@@ -478,7 +478,7 @@
ret = ioctl(vd->fd, VIDIOC_STREAMOFF, &type);
if (ret < 0) {
- printf("Unable to %s capture: %d.\n", "stop", errno);
+ perror("Unable to stop capture");
return ret;
}
vd->isstreaming = 0;
@@ -499,7 +499,7 @@
vd->buf.memory = V4L2_MEMORY_MMAP;
ret = ioctl(vd->fd, VIDIOC_DQBUF, &vd->buf);
if (ret < 0) {
- printf("Unable to dequeue buffer (%d).\n", errno);
+ perror("Unable to dequeue buffer");
goto err;
}
@@ -614,7 +614,7 @@
}
ret = ioctl(vd->fd, VIDIOC_QBUF, &vd->buf);
if (ret < 0) {
- printf("Unable to requeue buffer (%d).\n", errno);
+ perror("Unable to requeue buffer");
goto err;
}
@@ -647,7 +647,7 @@
int err =0;
queryctrl->id = control;
if ((err= ioctl(vd->fd, VIDIOC_QUERYCTRL, queryctrl)) < 0) {
- printf("ioctl querycontrol error %d \n",errno);
+ perror("ioctl querycontrol error");
} else if (queryctrl->flags & V4L2_CTRL_FLAG_DISABLED) {
printf("control %s disabled \n", (char *) queryctrl->name);
} else if (queryctrl->flags & V4L2_CTRL_TYPE_BOOLEAN) {
@@ -977,7 +977,7 @@
}
printf("\n");
if (ret != 0 && errno != EINVAL) {
- printf("ERROR enumerating frame intervals: %d\n", errno);
+ perror("ERROR enumerating frame intervals");
return errno;
}
@@ -1019,7 +1019,7 @@
fsize.index++;
}
if (ret != 0 && errno != EINVAL) {
- printf("ERROR enumerating frame sizes: %d\n", errno);
+ perror("ERROR enumerating frame sizes");
return errno;
}
@@ -1045,7 +1045,7 @@
printf(" Unable to enumerate frame sizes.\n");
}
if (errno != EINVAL) {
- printf("ERROR enumerating frame formats: %d\n", errno);
+ perror("ERROR enumerating frame formats");
return errno;
}
_______________________________________________
Linux-uvc-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel