[pwc] VIDIOCPWCRUSER: Bad file descriptor

oliver oliver-dille at laposte.net
Thu Sep 20 02:50:25 CEST 2007


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
> pwc at lists.saillard.org
> http://lists.saillard.org/mailman/listinfo/pwc
>
>   




More information about the pwc mailing list