pwc
[Top] [All Lists]

Re: [pwc] VIDIOCPWCRUSER: Bad file descriptor

To:
Subject: Re: [pwc] VIDIOCPWCRUSER: Bad file descriptor
From: oliver <>
Date: Thu, 20 Sep 2007 02:50:25 +0200
Hello,
I do not know about pd much but have been playing with libpwc for
a few days now.
I do not understand why you want to restore settings to disable the
automatic gain control.
What I do is just set the gain any time in the program with a positive
value.

// this comes from "setpwc", a program which I find quite instructive.
void set_automatic_gain_control(int fd, int pref)
{
    if (ioctl(fd , VIDIOCPWCSAGC, &pref) == -1)
    fprintf(stderr, "Error while doing ioctl %s: %s\n", "VIDIOCPWCSAGC", 
strerror(errno));
}
When your program quits it will then go back to auto... well with my 
camera anyways : a SPC900.

    oliver




Roman Haefeli wrote:
> hi 
>
> i am still trying to find a way to overcome the
> 'agc-setting-is-reset-each-time-cam-is-accessed' problem. a friend of
> mine tried to help by writing a pd-object, that does send the 'restore'
> command to the driver, so that i can at least set the gain manually,
> when working with pd, just by restoring the nvram of the cam. 
>
> however, it doesn't work yet. i am not a c coder myself and thus have no
> idea to fix it.
>
> i get the error:
>
> IDIOCPWCRUSER: Bad file descriptor
>
> this is the code of pd-object:
>
> ########################################################################
> #include <errno.h>
> #include <string.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/ioctl.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <unistd.h>
> #define _LINUX_TIME_H 1 /* to get things compile on kernel 2.6.x */
> #include <linux/videodev.h>
>
>
> #include "m_pd.h"
> #include "pwc-ioctl.h"
>
> char *device = "/dev/video1";
>
> static t_class *setpwc_class;
>
> typedef struct _setpwc {
>   t_object  x_obj;
> } t_setpwc;
>
> void check_device(int *fd)
> {
>         if (*fd == -1)
>         {
>                 /* open device */
>                 *fd = open(device, O_RDWR);
>                 if (*fd == -1)
>                 {
>                         post("Error while accessing device");
> //                      exit(1);
>                 }
>         }
> }
>
> void restore_settings(int fd)
> {
>         if (ioctl(fd, VIDIOCPWCRUSER) == -1)
>                 perror("VIDIOCPWCRUSER");
> }
>
> void setpwc_bang(t_setpwc *x)
> {
>         int fd = -1;
>         check_device(&fd);
>         restore_settings(fd);
> }
>
> void *setpwc_new(void)
> {
>   t_setpwc *x = (t_setpwc *)pd_new(setpwc_class);
>
>   return (void *)x;
> }
>
> void setpwc_setup(void) {
>   setpwc_class = class_new(gensym("setpwc"),
>         (t_newmethod)setpwc_new,
>         0, sizeof(t_setpwc),
>         CLASS_DEFAULT, 0);
>   class_addbang(setpwc_class, setpwc_bang);
>
>
>
>
>
>
>               
> ___________________________________________________________ 
> Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
> _______________________________________________
> pwc mailing list
> 
> http://lists.saillard.org/mailman/listinfo/pwc
>
>   


_______________________________________________
pwc mailing list

http://lists.saillard.org/mailman/listinfo/pwc

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU