*** vid.c-dist Wed Jun 26 15:42:31 2002 --- vid.c Wed Jun 26 16:33:37 2002 *************** *** 227,232 **** --- 227,248 ---- static void postproc(struct vidstate *vsp); + void + usage(void) + { + fprintf(stderr, "usage: vid [-v] [-h] [-s] [-d device] [-b] [-e]\n"); + fprintf(stderr, "Capture an image frame from an OV511/OV511+ based USB video camera\n"); + fprintf(stderr, "and write image data to standard output in PNM format\n"); + fprintf(stderr, " -v print program version information\n"); + fprintf(stderr, " -h summarize command line options\n"); + fprintf(stderr, " -s capture as 320x240 image (default is 640x480)\n"); + fprintf(stderr, " -d device specify OV511 ugen device\n"); + fprintf(stderr, " -b enable auto brightness\n"); + fprintf(stderr, " -e enable auto exposure\n"); + fprintf(stderr, " -f enable band filter\n"); + exit(1); + } + int main(int argc, char *argv[]) { int fd = -1, isoc = -1; /* control and isochronous input fds */ *************** *** 244,305 **** int isplus; /* bridge is OV511+ if true, else OV511 */ int is20; /* sensor is OV7620 if true, else OV7610 */ int bufsize; /* size of packet buffer */ /* pnm_init(&argc, argv); */ /* required for PNM programs? */ ! while(++argv, --argc) { ! if(strcmp(*argv, "--version") == 0) { ! fprintf(stderr, "OV511/OV511+ capture program version " VERSION ! "\nCopyright 2000 Peter S. Housel" ! "\nThis program is free software; " ! "you may redistribute it under the terms of" ! "\nthe GNU General Public License. " ! "This program has absolutely no warranty.\n"); ! exit(0); ! } else if(strcmp(*argv, "--usage") == 0) { ! fprintf(stderr, "usage: vid [--version] [--usage] [--help] [--small]\n" ! " [-d device] [--device-name=device]\n"); ! exit(0); ! } else if(strcmp(*argv, "--help") == 0) { ! fprintf(stderr, "usage: vid [options]\n" ! "Capture an image frame from an OV511/OV511+ based USB video camera\n" ! "and write image data to standard output in PNM format\n\n" ! "--version print program version information\n" ! "--usage summarize command line options\n" ! "--help print this description\n" ! "--small capture as 320x240 image (default is 640x480)\n" ! "-d device, --device-name=device\n" ! " specify OV511 ugen device\n"); ! exit(0); ! } else if(strcmp(*argv, "--small") == 0) { ! small = 1; ! } else if(strncmp(*argv, "--device-name", strlen("--device-name")) == 0) { ! if((*argv)[strlen("--device-name")] == '=') { ! devname = *argv + strlen("--device-name") + 1; ! } else if((*argv)[strlen("--device-name")] == '\0' && argc > 0) { ! devname = *++argv; ! --argc; ! } else { ! fprintf(stderr, "usage: vid [--version] [--usage] [--help] [--small]\n" ! " [-d device] [--device-name=device]\n"); ! exit(1); ! } ! } else if((*argv)[0] == '-' && (*argv)[1] == 'd') { ! if((*argv)[2] != '\0') { ! devname = *argv + 2; ! } else if(argc > 0) { ! devname = *++argv; ! --argc; ! } else { ! fprintf(stderr, "usage: vid [--version] [--usage] [--help] [--small]\n" ! " [-d device] [--device-name=device]\n"); ! exit(1); ! } ! } else { ! fprintf(stderr, "usage: vid [--version] [--usage] [--help] [--small]\n" ! " [-d device] [--device-name=device]\n"); ! exit(1); ! } } if(devname) { --- 260,312 ---- int isplus; /* bridge is OV511+ if true, else OV511 */ int is20; /* sensor is OV7620 if true, else OV7610 */ int bufsize; /* size of packet buffer */ + int autoexp = 0; + int autobri = 0; + int autobfe = 0; + int i; /* pnm_init(&argc, argv); */ /* required for PNM programs? */ ! while ((i = getopt(argc, argv, "vhsd:bef")) != -1) ! { ! switch(i) ! { ! case 'v': ! fprintf(stderr, "OV511/OV511+ capture program version " VERSION ! "\nCopyright 2000 Peter S. Housel" ! "\nThis program is free software; " ! "you may redistribute it under the terms of" ! "\nthe GNU General Public License. " ! "This program has absolutely no warranty.\n"); ! exit(0); ! break; ! ! default: ! case 'h': ! usage(); ! break; ! ! case 's': ! small = 1; ! break; ! ! case 'd': ! devname = optarg; ! break; ! ! case 'b': ! autobri = 1; ! break; ! ! case 'e': ! autoexp = 1; ! break; ! ! case 'f': ! autobfe = 1; ! break; ! ! } } if(devname) { *************** *** 456,462 **** ov511_i2c_write(fd, OV7610_REG_FD, 0x06); ov511_i2c_write(fd, OV7610_REG_COMH, 0x24); ov511_i2c_write(fd, OV7610_REG_EHSL, 0xac); - ov511_i2c_write(fd, OV7610_REG_COMA, 0x00); ov511_i2c_write(fd, OV7610_REG_COMH, 0x24); ov511_i2c_write(fd, OV7610_REG_RWB, 0x85); ov511_i2c_write(fd, OV7610_REG_COMD, 0x01); --- 463,468 ---- *************** *** 475,480 **** --- 481,509 ---- ov511_i2c_write(fd, OV7610_REG_SYN_CLK, 0x01); ov511_i2c_write(fd, OV7610_REG_BBS, 0x24); ov511_i2c_write(fd, OV7610_REG_RBS, 0x24); + i = ov511_i2c_read(fd, 0x2d); + if(autobri) + ov511_i2c_write(fd, 0x2d, i | 0x10); + else + ov511_i2c_write(fd, 0x2d, i & 0xef); + + i = ov511_i2c_read(fd, 0x2d); + if(autobfe) + ov511_i2c_write(fd, 0x2d, i | 0x04); + else + ov511_i2c_write(fd, 0x2d, i & 0xfb); + + i = ov511_i2c_read(fd, 0x13); + if(autoexp) + { + ov511_i2c_write(fd, OV7610_REG_COMA, 0x24); + ov511_i2c_write(fd, 0x13, i | 0x01); + } + else + { + ov511_i2c_write(fd, OV7610_REG_COMA, 0x00); + ov511_i2c_write(fd, 0x13, i & 0xfe); + } } else { ov511_i2c_write(fd, OV7610_REG_RWB, 0x5); ov511_i2c_write(fd, OV7610_REG_EC, 0xFF);