 USB cameras based CPiA2 Utility Programs 0.03 for NetBSD

 This patches written by Takafumi Mizuno <taka-qce@ls-a.jp>

USB Cameras based CPia2 Utilities for NetBSD
-----------------------------------------------

1. What is it?
	cpia2shot ... simple image capture program ( output stdout JPEG file )
	cpia2view ... sequential image viewer program ( about 6fps )

2. What is supported USB camera?

	Vendor	Device	Product Name
	------	------	------------
	0x0553	0x0100	ex. maxell compact PC camera P-M2(ST)
	0x0553	0x0140	(untested)

2. How to compile?
 a) Check your system.
	I tested below;
		cpia2shot ... NetBSD/i386 1.6.2-RC3
	cpia2view requred below;
		- gtk+-1.2.?? ( I tested 1.2.10 )
		- imlib 1.9.?? ( I tested 1.9.14 )
		- jpeg6 ( I tested 6nb1 )
	and kernel applied a patch that ugen(4) have checksum function. ( see below f)kernel rebuild. )
		
 b) Download Linux device driver from 
	CPiA2 Linux Device Driver Project;  http://cpia2.sourceforge.net/

	You must download 'cpia2_driver-1.0.tgz'.
	
	MD5 (cpia2_driver-1.0.tgz) = a8ea21d5d155e75055170e3836c31f71

 c) Get patches for NetBSD
	from http://www2.starcat.ne.jp/~takam/bsd/cpia2_driver-1.0-bsd-0.03.patch.gz

 d) Extract files and applied patches.

	% tar zxvf cpia2_driver-1.0.tgz
	% gzip -dc cpia2_driver-1.0-bsd-0.03.patch.gz | patch -p0

 e) Do make
        % cd cpia2_driver-1.0
        % make -f Makefile.cpia2shot
        % su root -c 'make -f Makefile.cpia2shot install'
        % make -f Makefile.cpia2view
        % su root -c 'make -f Makefile.cpia2view install'

 f) kernel rebuild
    ex.
	% mount -t union ${YOUR_WORK_DIR} /usr/src/sys
	% cat cpia2-netbsd-sys-1.6.2.diff | ( cd /usr/src/sys; patch -p0 )
	% cd /usr/src/sys/arch/i386/conf
	% config GENERIC
	% cd ../compile/GENERIC
	% make depend; make
	% su root -c 'make install'
	( Please boot new kernel. )
	% sync; shutdown -r now

3. How to use?
3.1. cpia2shot
 a) usage: cpia2shot [devname]

    for Example.
        % cpia2shot > output.jpg

 b) Command line options.
     [devname]       specify ugen device name. ex. /dev/ugen0.00

     If no device file is specified, the program will cycle through the
     /dev/ugen0, /dev/ugen1, ... devices until it finds an attached usb camera.

3.2. cpia2view
 a) usage: cpia2view [devname]

    for Excample.
	% cpia2view /dev/ugen1.00

 b) Command line options.
     [devname]       specify ugen device name. ex. /dev/ugen0.00

     If no device file is specified, the program will cycle through the
     /dev/ugen0, /dev/ugen1, ... devices until it finds an attached usb camera.

-----------------------------------------------
References:
	CPiA2 Linux Device Driver Project
	http://cpia2.sourceforge.net/

        OV511/OV511+ Capture for FreeBSD/NetBSD
	http://ovtvid-bsd.sourceforge.net/

	Linux NI YORU GAZOU SYORI PUROGURAMING (Japanese only!)
	ohmsha publising. ISBN 4-274-94623-1

-----------------------------------------------
Problems and Questions and Todo:
 a) Those programs are not device driver.

 b) Those programs needs local-extended ugen(4). This extend is checksum function.
    It's no good hack very much, but I have no idea to checksum against raw isoc-packets.
    TODO: To create a new device driver for device that uses isochronous transfer with checksum.

-----------------------------------------------
History:
2004-01-03 0.00 First release ( cpia2shot )
2004-01-11 0.01 add cpia2view
2004-01-13 0.02 bug fix that is memory leak by cpia2view.
2004-01-14 0.03 bug fix that is memory leak by cpia2view again :-(
		throw away a jpeg data with some warring.

-----------------------------------------------
Credits:
Thanks to CPiA2 Linux Device Driver Project developers.
Thanks to Oshima for advice of jpeg decoding and some bug fix.

written by Takafumi Mizuno <taka-qce@ls-a.jp>	