Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Apr 1999 01:40:10 -0700
From:      Amancio Hasty <hasty@rah.star-gate.com>
To:        John-Mark Gurney <gurney_j@resnet.uoregon.edu>
Cc:        multimedia@freebsd.org, Steve Passe <fsmp@freebsd.org>
Subject:   Re: brooktree driver problems?? 
Message-ID:  <199904260840.BAA05220@rah.star-gate.com>
In-Reply-To: Your message of "Sun, 25 Apr 1999 18:53:12 PDT." <19990425185312.25505@hydrogen.nike.efn.org> 

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
See if this program works any better for you.



[-- Attachment #2 --]
/* Takes snapshots every SLEEP_TIME period and save the image in
   jpeg format.
  To compile:
 cc -o videocapture videocapture.c -I /usr/local/include -L/usr/local/lib -ljpeg
*/

/* Copyright (c) 1997 Amancio Hasty
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by Amancio Hasty
 * 4. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <sys/types.h>
#include <sys/mman.h>
#include <sys/fcntl.h>
#include <stdio.h>
#include <machine/ioctl_meteor.h>
#include <signal.h>
#include <setjmp.h>

/* time to sleep between single captures */

#define SLEEP_TIME 10

/* number of frames to capture */

#define FRAMES 300

/* height and width of the picuture */

#define ROWS 240
#define COLS 320

/* stuff for the driver */

#define SIZE (ROWS * COLS * 4)

typedef unsigned char uint8;
typedef signed char int8;

static char *copybuf=NULL;
int hwidth;
int hheight;
static uint8 *yuv_data;
static int8 *ue, *uo, *ve, *vo;
extern int errno;
static frames = -1;
	u_char * pyuv_        ;
	u_int *  frame_      ;
	int  framesize_      ;

int bt848;
int scratch_file;

sig_t done() {
	  close(bt848);
	  printf("captured %d frames \n", frames);
          exit(0);
}



sig_t do_write() {

          int o;
	  int j;
	  int k;
	  char *buf;
	  char file_name[128];
	  char buffer[ROWS*COLS*4];
	  printf(" frame %d \n", frames);
	  ++frames;
	  return;
	  if (frames < 0 ) frames = 0;
	  sprintf((char *) &file_name, "img%d.jpg", frames);

	  ++frames;
	  return ;
}


main(int ac, char **av)
{
	struct meteor_geomet geo;
	int o,c,r;
	volatile u_int* py   ;
	volatile u_int* pu   ;
	volatile u_int* pv   ;
	u_int* 		lum  ;
	u_int*		uoff ;
	u_int*	 	voff ;
	int             row, col, numc, i;
	char   file_name[30];
        char                    *cmd;
	int  c_opt = 3, h_opt = 320, v_opt = 240, f_opt = 1000;

        for (i = 1 ; i < ac; i+=2) {
          cmd = av[i];
          if ( strcmp(cmd, "-c") == 0) {
            c_opt = atoi(av[i+1]);
          } else if ( strcmp(cmd, "-h") == 0) {
            h_opt = atoi(av[i+1]);
          } else if ( strcmp(cmd, "-v") == 0){
            v_opt = atoi(av[i+1]);
          }else if ( strcmp(cmd, "-f") == 0 ) {
            f_opt = atoi(av[i+1]);
          }

        }



	frame_ = (u_int *) malloc(ROWS*COLS*4);
	framesize_ = ROWS * COLS * 4;
	if ((bt848 = open("/dev/bktr0", O_RDONLY)) < 0) {
		printf("open failed: %d\n", errno);
		exit(1);
	}
				/* set up the capture type and size */
        geo.rows = ROWS;
        geo.columns = COLS;
	geo.frames = 1;
        hwidth = geo.columns;
	hheight = geo.rows;

        i = 112;
        if (ioctl(bt848, METEORSCONT, &i) < 0) {
                fprintf(stderr, "ioctl failed: %s\n", strerror(errno));
		exit(0);

        }

        i = 0x30;
        if (ioctl(bt848, METEORSBRIG, &i) < 0) {
                fprintf(stderr, "ioctl failed: %s\n", strerror(errno));
		exit(0);

        }



	if ( geo.rows <= 320 ) 
	  geo.oformat = METEOR_GEO_RGB24 | METEOR_GEO_EVEN_ONLY; 
	else 
	  geo.oformat = METEOR_GEO_RGB24;

        if (ioctl(bt848, METEORSETGEO, &geo) < 0) {
		printf("ioctl failed: %d\n", errno);
		exit(1);
	}


	c = METEOR_INPUT_DEV1;

        if (ioctl(bt848, METEORSINPUT, &c) < 0) {
		printf("ioctl failed: %d\n", errno);
		exit(1);
	}

        pyuv_ = (u_char *)mmap((caddr_t)0,SIZE,PROT_READ,0, bt848, (off_t)0);

	if ((int) pyuv_ ==  -1) return (0);
	frames = -1;

	sleep(1); /* Let the unit settled down -- very important 
                     and this only needed when a video input or
                     video format is specified */

	c = 31;
	ioctl(bt848, METEORSSIGNAL, &c); 

	signal(c, (sig_t) do_write);

	signal(SIGINT,  (sig_t) done);

	  c = METEOR_CAP_SINGLE;
	  ioctl(bt848, METEORCAPTUR, &c);
	  while (frames < (FRAMES+2)) { 
	    ioctl(bt848, METEORCAPTUR, &c);	    
	    do_write();
	  };

	close(bt848);
	exit(0);
}


[-- Attachment #3 --]

 Amancio Hasty
 hasty@star-gate.com
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904260840.BAA05220>