# $Id: README,v 1.5 2007/01/17 09:13:15 luigi Exp $ documentation on the pwcbsd driver and extensions

--- 1. sources of information ---

The pwcbsd driver comes from ports/multimedia/pwcbsd

The spca driver comes from
	http://mxhaard.free.fr/spca50x/Download/spca5xx-20060501.tar.gz
    but a newer one is at
	http://mxhaard.free.fr/spca50x/Download/gspcav1-20070110.tar.gz

The linux-uvc driver comes from
	svn checkout svn://svn.berlios.de/linux-uvc/linux-uvc/trunk

The newusb driver comes from
	http://perforce.freebsd.org/depotTreeBrowser.cgi?FSPC=//depot/projects/usb/src/sys/dev/usb

The quickcam-ga driver comes from
	ports/graphics/qcamview

--- 2. documentation on the pwc driver functions ----
(these are working notes, sometimes stale. The source may contain
more up-to-date comments, so double check there as well).

USB_MATCH:
	check vendor and id against table

USB_ATTACH
	check again, then initialize descriptor fields
	based on the resources.

	pwc-misc.c::pwc_construct()
		initialize supported formats depending on camera type.
		For spca, call spca5xx::spca50x_configure()
			bridge-specific config code e.g.  sonix_config()
			spca50x_set_packet_size(x, 0)
			initialize pipe size with spca5xx_getDefaultMode() or similar
			spca50x_configure_sensor():
				set frame sizes

	pwc-ctrl.c::pwc_get_cmos_sensor():
		sensor-specific call to detect the sensor type if needed.


pwc_open():
	pwc_camera_power(sc, 1): power on if necessary
	pwc_set_lets(sc, ...)	set led if necessary

	allocate and initialize buffers

	allocate decompressor table

	allocate isoc transfer buffers

	set a fallback video mode

	5. pwc.c::pwc_try_video_mode(): initialize video mode
		pwc-ctrl.c:int pwc_set_video_mode()
			call camera-specific video mode e.g.
				spca50x_set_packet_size()
					determines valternate depending on pipe_size
					which is set in spca5xx_getDefaultMode() or
					spca5xx_setMode()
					determines vendpoint depending on bridge

				set_video_mode_Nala()
					send specific commands to the camera
					to set fps and size
					identifies the valternate endpoint
				set_video_mode_Timon()
				set_video_mode_Kiara()

		initialize usbd interface ?
	 5. equivalent to calling
		spwc5xx.c::spca50x_init_source() {
			call bridge-specific init code
			call spca5xx_setMode() or
				spca50x_find_mode_index()
				spca50x_set_mode() XXX different from spca5xx_setMode()
		}
		spwc5xx.c::spwc5xx::spcaCameraStart()
			    call bridge-specific start code
		spca50x->streaming = 1;
		.

------------
in pwc_try_video_mode()
        if (sc->type == 0) {    /* spca camera */
                struct usb_spca50x *spca50x = &sc->spca50x;
                err = -spca50x_init_source(spca50x);
                if (err != 0)
                        goto bad;
                spcaCameraStart(spca50x);
                spca50x->streaming = 1;
        }

