Remove the 'qcam' driver. Development has ceased, and the driver is
nonfunctional. Submitted by: pst (conversation some time ago)
This commit is contained in:
parent
2df8bcb8a9
commit
1f98b2eb0f
sys
@ -2,7 +2,7 @@
|
||||
# LINT -- config file for checking all the sources, tries to pull in
|
||||
# as much of the source tree as it can.
|
||||
#
|
||||
# $Id: LINT,v 1.407 1998/02/13 13:00:01 phk Exp $
|
||||
# $Id: LINT,v 1.408 1998/02/16 23:57:35 eivind Exp $
|
||||
#
|
||||
# NB: You probably don't want to try running a kernel built from this
|
||||
# file. Instead, you should start from GENERIC, and add options from
|
||||
@ -1201,7 +1201,6 @@ controller matcd0 at isa? port 0x230 bio
|
||||
device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr
|
||||
device ctx0 at isa? port 0x230 iomem 0xd0000
|
||||
device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000 vector spigintr
|
||||
device qcam0 at isa? port "IO_LPT3" tty
|
||||
device apm0 at isa?
|
||||
device gp0 at isa? port 0x2c0 tty
|
||||
device gsc0 at isa? port "IO_GSC1" tty drq 3
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file tells config what files go into building a kernel,
|
||||
# files marked standard are always included.
|
||||
#
|
||||
# $Id: files.i386,v 1.189 1998/02/15 14:42:31 peter Exp $
|
||||
# $Id: files.i386,v 1.190 1998/02/17 11:32:33 sos Exp $
|
||||
#
|
||||
# The long compile-with and dependency lines are required because of
|
||||
# limitations in config: backslash-newline doesn't work in strings, and
|
||||
@ -152,8 +152,6 @@ i386/isa/pnp.c optional pnp device-driver
|
||||
i386/isa/prof_machdep.c optional profiling-routine
|
||||
i386/isa/ppc.c optional ppc device-driver
|
||||
i386/isa/psm.c optional psm device-driver
|
||||
i386/isa/qcam.c optional qcam device-driver
|
||||
i386/isa/qcamio.c optional qcam device-driver
|
||||
i386/isa/random_machdep.c standard
|
||||
i386/isa/rc.c optional rc device-driver
|
||||
i386/isa/rp.c optional rp device-driver
|
||||
|
@ -1,4 +1,4 @@
|
||||
$Id: majors.i386,v 1.28 1998/02/17 10:44:23 sos Exp $
|
||||
$Id: majors.i386,v 1.29 1998/02/17 10:52:56 jkh Exp $
|
||||
|
||||
Hopefully, this list will one day be obsoleted by DEVFS, but for now
|
||||
this is the current allocation of device major numbers.
|
||||
@ -113,7 +113,7 @@ chrdev name comments
|
||||
70 od SCSI "magneto-optical disk type"
|
||||
71 asc AmiScan driver
|
||||
72 stl Stallion (cd1400 based) (gerg@stallion.oz.au)
|
||||
73 qcam quickcam
|
||||
73 ?? was qcam
|
||||
74 ccd concatenated disk
|
||||
75 stli Stallion (intelligent cdk based) (gerg@stallion.oz.au)
|
||||
76 scc IBM Smart Capture Card (ohashi@mickey.ai.kyutech.ac.jp)
|
||||
|
@ -2,7 +2,7 @@
|
||||
# LINT -- config file for checking all the sources, tries to pull in
|
||||
# as much of the source tree as it can.
|
||||
#
|
||||
# $Id: LINT,v 1.407 1998/02/13 13:00:01 phk Exp $
|
||||
# $Id: LINT,v 1.408 1998/02/16 23:57:35 eivind Exp $
|
||||
#
|
||||
# NB: You probably don't want to try running a kernel built from this
|
||||
# file. Instead, you should start from GENERIC, and add options from
|
||||
@ -1201,7 +1201,6 @@ controller matcd0 at isa? port 0x230 bio
|
||||
device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr
|
||||
device ctx0 at isa? port 0x230 iomem 0xd0000
|
||||
device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000 vector spigintr
|
||||
device qcam0 at isa? port "IO_LPT3" tty
|
||||
device apm0 at isa?
|
||||
device gp0 at isa? port 0x2c0 tty
|
||||
device gsc0 at isa? port "IO_GSC1" tty drq 3
|
||||
|
@ -2,7 +2,7 @@
|
||||
# LINT -- config file for checking all the sources, tries to pull in
|
||||
# as much of the source tree as it can.
|
||||
#
|
||||
# $Id: LINT,v 1.407 1998/02/13 13:00:01 phk Exp $
|
||||
# $Id: LINT,v 1.408 1998/02/16 23:57:35 eivind Exp $
|
||||
#
|
||||
# NB: You probably don't want to try running a kernel built from this
|
||||
# file. Instead, you should start from GENERIC, and add options from
|
||||
@ -1201,7 +1201,6 @@ controller matcd0 at isa? port 0x230 bio
|
||||
device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr
|
||||
device ctx0 at isa? port 0x230 iomem 0xd0000
|
||||
device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000 vector spigintr
|
||||
device qcam0 at isa? port "IO_LPT3" tty
|
||||
device apm0 at isa?
|
||||
device gp0 at isa? port 0x2c0 tty
|
||||
device gsc0 at isa? port "IO_GSC1" tty drq 3
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file tells config what files go into building a kernel,
|
||||
# files marked standard are always included.
|
||||
#
|
||||
# $Id: files.i386,v 1.189 1998/02/15 14:42:31 peter Exp $
|
||||
# $Id: files.i386,v 1.190 1998/02/17 11:32:33 sos Exp $
|
||||
#
|
||||
# The long compile-with and dependency lines are required because of
|
||||
# limitations in config: backslash-newline doesn't work in strings, and
|
||||
@ -152,8 +152,6 @@ i386/isa/pnp.c optional pnp device-driver
|
||||
i386/isa/prof_machdep.c optional profiling-routine
|
||||
i386/isa/ppc.c optional ppc device-driver
|
||||
i386/isa/psm.c optional psm device-driver
|
||||
i386/isa/qcam.c optional qcam device-driver
|
||||
i386/isa/qcamio.c optional qcam device-driver
|
||||
i386/isa/random_machdep.c standard
|
||||
i386/isa/rc.c optional rc device-driver
|
||||
i386/isa/rp.c optional rp device-driver
|
||||
|
@ -1,4 +1,4 @@
|
||||
$Id: majors.i386,v 1.28 1998/02/17 10:44:23 sos Exp $
|
||||
$Id: majors.i386,v 1.29 1998/02/17 10:52:56 jkh Exp $
|
||||
|
||||
Hopefully, this list will one day be obsoleted by DEVFS, but for now
|
||||
this is the current allocation of device major numbers.
|
||||
@ -113,7 +113,7 @@ chrdev name comments
|
||||
70 od SCSI "magneto-optical disk type"
|
||||
71 asc AmiScan driver
|
||||
72 stl Stallion (cd1400 based) (gerg@stallion.oz.au)
|
||||
73 qcam quickcam
|
||||
73 ?? was qcam
|
||||
74 ccd concatenated disk
|
||||
75 stli Stallion (intelligent cdk based) (gerg@stallion.oz.au)
|
||||
76 scc IBM Smart Capture Card (ohashi@mickey.ai.kyutech.ac.jp)
|
||||
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Connectix QuickCam parallel-port camera video capture driver.
|
||||
* Copyright (c) 1996, Paul Traina.
|
||||
*
|
||||
* This driver is based in part on work
|
||||
* Copyright (c) 1996, Thomas Davis.
|
||||
*
|
||||
* QuickCam(TM) is a registered trademark of Connectix Inc.
|
||||
* Use this driver at your own risk, it is not warranted by
|
||||
* Connectix or the authors.
|
||||
*
|
||||
* 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
|
||||
* in this position and unchanged.
|
||||
* 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software withough 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.
|
||||
*
|
||||
* NOTE: this file contains the sole public interface between the driver
|
||||
* and user applications. Every effort should be made to retain comaptibility
|
||||
* with the decided upon standard interface shared between Linux and
|
||||
* FreeBSD. Currently, FreeBSD uses a different (richer) interface than
|
||||
* the Linux.
|
||||
*
|
||||
* WARNING WARNING: The contents of this structure is in flux,
|
||||
* recompile often, the driver will change the version
|
||||
* number when the interface changes for now...
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_QUICKCAM_H_
|
||||
#define _MACHINE_QUICKCAM_H_
|
||||
|
||||
#ifndef KERNEL
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <sys/ioccom.h>
|
||||
|
||||
#ifndef _IOR
|
||||
/* SCO doesn't have _IOR/_IOW for ioctls, so fake it out to keep things clean*/
|
||||
#define _IOR(cat, func, data) (((cat) << 8) | (func))
|
||||
#define _IOW(cat, func, data) (((cat) << 8) | (func))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ioctls
|
||||
*/
|
||||
#define QC_GET _IOR('S', 1, struct qcam) /* get parameter structure */
|
||||
#define QC_SET _IOW('S', 2, struct qcam) /* set parameter structure */
|
||||
|
||||
#define QC_IOCTL_VERSION 3 /* version of the structure */
|
||||
|
||||
struct qcam {
|
||||
int qc_version; /* version of qcam structure */
|
||||
int qc_xsize; /* size in pixels */
|
||||
int qc_ysize; /* size in pixels */
|
||||
int qc_xorigin; /* x origin */
|
||||
int qc_yorigin; /* y origin */
|
||||
int qc_bpp; /* bits per pixel (4 or 6) */
|
||||
int qc_zoom; /* zoom mode */
|
||||
int qc_exposure; /* length of exposure */
|
||||
u_char qc_brightness; /* 0..255 */
|
||||
u_char qc_whitebalance; /* 0..255 */
|
||||
u_char qc_contrast; /* 0..255 */
|
||||
};
|
||||
|
||||
#define QC_MAX_XSIZE 320 /* pixels */
|
||||
#define QC_MAX_YSIZE 240 /* pixels */
|
||||
|
||||
/*
|
||||
* zoom flags
|
||||
*/
|
||||
#define QC_ZOOM_100 0x00 /* no zoom */
|
||||
#define QC_ZOOM_150 0x01 /* 1.5x */
|
||||
#define QC_ZOOM_200 0x02 /* 2.0x */
|
||||
|
||||
#endif /* !_MACHINE_QUICKCAM_H_ */
|
@ -1,320 +0,0 @@
|
||||
/*
|
||||
* Connectix QuickCam parallel-port camera video capture driver.
|
||||
* Copyright (c) 1996, Paul Traina.
|
||||
*
|
||||
* This driver is based in part on work
|
||||
* Copyright (c) 1996, Thomas Davis.
|
||||
*
|
||||
* QuickCam(TM) is a registered trademark of Connectix Inc.
|
||||
* Use this driver at your own risk, it is not warranted by
|
||||
* Connectix or the authors.
|
||||
*
|
||||
* 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
|
||||
* in this position and unchanged.
|
||||
* 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software withough 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 "qcam.h"
|
||||
#if NQCAM > 0
|
||||
|
||||
#include "opt_devfs.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/malloc.h>
|
||||
#ifdef DEVFS
|
||||
#include <sys/devfsext.h>
|
||||
#endif /* DEVFS */
|
||||
|
||||
#include <machine/clock.h>
|
||||
#include <machine/qcam.h>
|
||||
|
||||
#include <i386/isa/qcamdefs.h>
|
||||
#include <i386/isa/isa.h>
|
||||
#include <i386/isa/isa_device.h>
|
||||
|
||||
/* working off of nostrategy is very ugly, but we need to determine if we're
|
||||
running in a kernel that has eliminated the cdevsw table (yea!) */
|
||||
|
||||
#if defined(__FreeBSD__) && defined(nostrategy)
|
||||
|
||||
#define CDEV_MAJOR 73
|
||||
#define STATIC_CDEVSW static
|
||||
|
||||
static d_open_t qcam_open;
|
||||
static d_close_t qcam_close;
|
||||
static d_read_t qcam_read;
|
||||
static d_ioctl_t qcam_ioctl;
|
||||
|
||||
static struct cdevsw qcam_cdevsw =
|
||||
{ qcam_open, qcam_close, qcam_read, nowrite,
|
||||
qcam_ioctl, nostop, nullreset, nodevtotty,
|
||||
seltrue, nommap, nostrategy, "qcam",
|
||||
NULL, -1 };
|
||||
|
||||
static int qcam_probe(struct isa_device *devp);
|
||||
static int qcam_attach(struct isa_device *devp);
|
||||
|
||||
struct isa_driver qcamdriver =
|
||||
{qcam_probe, qcam_attach, "qcam"};
|
||||
|
||||
/*
|
||||
* Initialize the dynamic cdevsw hooks.
|
||||
*/
|
||||
static void
|
||||
qcam_drvinit (void *unused)
|
||||
{
|
||||
static int qcam_devsw_installed = 0;
|
||||
dev_t dev;
|
||||
|
||||
if (!qcam_devsw_installed) {
|
||||
dev = makedev(CDEV_MAJOR, 0);
|
||||
cdevsw_add(&dev,&qcam_cdevsw, NULL);
|
||||
qcam_devsw_installed++;
|
||||
}
|
||||
}
|
||||
|
||||
SYSINIT(qcamdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,qcam_drvinit,NULL)
|
||||
|
||||
#endif /* new FreeBSD configuration system */
|
||||
|
||||
#ifndef STATIC_CDEVSW
|
||||
#define STATIC_CDEVSW
|
||||
#endif
|
||||
|
||||
int qcam_debug = 0;
|
||||
|
||||
static struct qcam_softc qcam_softc[NQCAM];
|
||||
|
||||
#define QC_CONF_NODETECT 0x01 /* always assume camera is present */
|
||||
#define QC_CONF_FORCEUNI 0x02 /* force unidirectional transfers */
|
||||
|
||||
#define UNIT(dev) minor(dev)
|
||||
|
||||
static int
|
||||
qcam_probe (struct isa_device *devp)
|
||||
{
|
||||
switch (devp->id_iobase) { /* don't probe weird ports */
|
||||
case IO_LPT1:
|
||||
case IO_LPT2:
|
||||
case IO_LPT3:
|
||||
break;
|
||||
default:
|
||||
printf("qcam%d: ignoring non-standard port 0x%x\n",
|
||||
devp->id_unit, devp->id_iobase);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX The probe code is reported to be flakey.
|
||||
* We need to work on this some more, so temporarily,
|
||||
* allow bit one of the "flags" parameter to bypass this
|
||||
* check.
|
||||
*/
|
||||
|
||||
if (!(devp->id_flags & QC_CONF_NODETECT))
|
||||
if (!qcam_detect(devp->id_iobase))
|
||||
return 0; /* failure */
|
||||
|
||||
return 1; /* found */
|
||||
}
|
||||
|
||||
static int
|
||||
qcam_attach (struct isa_device *devp)
|
||||
{
|
||||
struct qcam_softc *qs = &qcam_softc[devp->id_unit];
|
||||
|
||||
qs->iobase = devp->id_iobase;
|
||||
qs->unit = devp->id_unit;
|
||||
qs->flags |= QC_ALIVE;
|
||||
|
||||
/* force unidirectional parallel port mode? */
|
||||
if (devp->id_flags & QC_CONF_FORCEUNI)
|
||||
qs->flags |= QC_FORCEUNI;
|
||||
|
||||
qcam_reset(qs);
|
||||
|
||||
printf("qcam%d: %sdirectional parallel port\n",
|
||||
qs->unit, qs->flags & QC_BIDIR_HW ? "bi" : "uni");
|
||||
|
||||
#ifdef DEVFS
|
||||
qs->devfs_token =
|
||||
devfs_add_devswf(&qcam_cdevsw, qs->unit, DV_CHR, 0, 0, 0600,
|
||||
"qcam%d", qs->unit);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
STATIC_CDEVSW int
|
||||
qcam_open (dev_t dev, int flags, int fmt, struct proc *p)
|
||||
{
|
||||
struct qcam_softc *qs = &qcam_softc[UNIT(dev)];
|
||||
|
||||
if (!(qs->flags & QC_ALIVE))
|
||||
return ENXIO;
|
||||
|
||||
if (qs->flags & QC_OPEN)
|
||||
return EBUSY;
|
||||
|
||||
qs->buffer_end = qs->buffer = malloc(QC_MAXFRAMEBUFSIZE, M_DEVBUF,
|
||||
M_WAITOK);
|
||||
if (!qs->buffer)
|
||||
return ENOMEM;
|
||||
|
||||
qcam_reset(qs);
|
||||
qcam_default(qs);
|
||||
qs->init_req = 1; /* request initialization before scan */
|
||||
|
||||
qs->flags |= QC_OPEN;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC_CDEVSW int
|
||||
qcam_close (dev_t dev, int flags, int fmt, struct proc *p)
|
||||
{
|
||||
struct qcam_softc *qs = &qcam_softc[UNIT(dev)];
|
||||
|
||||
if (qs->buffer) {
|
||||
free(qs->buffer, M_DEVBUF);
|
||||
qs->buffer = NULL;
|
||||
qs->buffer_end = NULL;
|
||||
}
|
||||
|
||||
qs->flags &= ~QC_OPEN;
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC_CDEVSW int
|
||||
qcam_read (dev_t dev, struct uio *uio, int ioflag)
|
||||
{
|
||||
struct qcam_softc *qs = &qcam_softc[UNIT(dev)];
|
||||
int bytes, bufsize;
|
||||
int error;
|
||||
|
||||
/* if we've seeked back to 0, that's our signal to scan */
|
||||
if (uio->uio_offset == 0)
|
||||
if (qcam_scan(qs))
|
||||
return EIO;
|
||||
|
||||
bufsize = qs->buffer_end - qs->buffer;
|
||||
if (uio->uio_offset > bufsize)
|
||||
return EIO;
|
||||
|
||||
bytes = min(uio->uio_resid, (bufsize - uio->uio_offset));
|
||||
error = uiomove(qs->buffer + uio->uio_offset, bytes, uio);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
STATIC_CDEVSW int
|
||||
qcam_ioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
|
||||
{
|
||||
struct qcam_softc *qs = &qcam_softc[UNIT(dev)];
|
||||
struct qcam *info = (struct qcam *)data;
|
||||
|
||||
if (!data)
|
||||
return(EINVAL);
|
||||
|
||||
switch (cmd) {
|
||||
case QC_GET:
|
||||
return qcam_ioctl_get(qs, info) ? EINVAL : 0;
|
||||
|
||||
case QC_SET:
|
||||
return qcam_ioctl_set(qs, info) ? EINVAL : 0;
|
||||
|
||||
default:
|
||||
return(ENOTTY);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef QCAM_MODULE
|
||||
|
||||
#include <sys/exec.h>
|
||||
#include <sys/sysent.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/lkm.h>
|
||||
|
||||
static struct isa_device qcam_mod_dev =
|
||||
{0, &qcamdriver, IO_LPT1, 0, -1, (caddr_t) 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 0, 0};
|
||||
|
||||
MOD_DEV(qcam, LM_DT_CHAR, CDEV_MAJOR, &qcam_cdevsw);
|
||||
|
||||
static int
|
||||
qcam_load (struct lkm_table *lkmtp, int cmd)
|
||||
{
|
||||
if (qcam_probe(&qcam_mod_dev)) {
|
||||
qcam_attach(&qcam_mod_dev);
|
||||
|
||||
qcam_drvinit(NULL); /* XXX this shouldn't NEED to be here
|
||||
* the LKM code should be doing this
|
||||
* for us! */
|
||||
|
||||
uprintf("qcam: driver loaded\n");
|
||||
return 0;
|
||||
} else {
|
||||
uprintf("qcam: probe failed\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
qcam_unload (struct lkm_table *lkmtp, int cmd)
|
||||
{
|
||||
struct qcam_softc *qs;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NQCAM; i++) {
|
||||
qs = &qcam_softc[i];
|
||||
if (qs->flags & QC_OPEN) {
|
||||
uprintf("qcam%d: cannot unload, device busy", qs->unit);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
uprintf("qcam: driver unloaded\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
qcam_stat (struct lkm_table *lkmtp, int cmd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
qcam_mod (struct lkm_table *lkmtp, int cmd, int ver)
|
||||
{
|
||||
MOD_DISPATCH(qcam, lkmtp, cmd, ver,
|
||||
qcam_load, qcam_unload, qcam_stat);
|
||||
}
|
||||
|
||||
#endif /* QCAM_MODULE */
|
||||
#endif /* NQCAM */
|
@ -1,135 +0,0 @@
|
||||
/*
|
||||
* Connectix QuickCam parallel-port camera video capture driver.
|
||||
* Copyright (c) 1996, Paul Traina.
|
||||
*
|
||||
* This driver is based in part on work
|
||||
* Copyright (c) 1996, Thomas Davis.
|
||||
*
|
||||
* QuickCam(TM) is a registered trademark of Connectix Inc.
|
||||
* Use this driver at your own risk, it is not warranted by
|
||||
* Connectix or the authors.
|
||||
*
|
||||
* 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
|
||||
* in this position and unchanged.
|
||||
* 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software withough 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.
|
||||
*
|
||||
* The information in this file is private and shared between various
|
||||
* parts of the QuickCam(TM) driver.
|
||||
*/
|
||||
|
||||
#ifndef _QCAM_DEFS_H
|
||||
#define _QCAM_DEFS_H 1
|
||||
|
||||
extern int qcam_debug;
|
||||
|
||||
struct qcam_softc {
|
||||
|
||||
#if defined(bsdi) && defined(KERNEL)
|
||||
/* must be first in structure */
|
||||
struct device sc_dev; /* kernel configuration */
|
||||
#endif /* bsdi KERNEL */
|
||||
|
||||
u_char *buffer; /* frame buffer */
|
||||
u_char *buffer_end; /* end of frame buffer */
|
||||
u_int flags;
|
||||
u_int iobase;
|
||||
int unit; /* device */
|
||||
void (*scanner)(struct qcam_softc *);
|
||||
|
||||
int init_req; /* initialization required */
|
||||
int x_size; /* pixels */
|
||||
int y_size; /* pixels */
|
||||
int x_origin; /* ?? units */
|
||||
int y_origin; /* ?? units */
|
||||
int zoom; /* 0=none, 1=1.5x, 2=2x */
|
||||
int bpp; /* 4 or 6 */
|
||||
int exposure; /* time to open shutter */
|
||||
u_char xferparms; /* calcualted transfer params */
|
||||
u_char contrast;
|
||||
u_char brightness;
|
||||
u_char whitebalance;
|
||||
|
||||
#if defined(__FreeBSD__) && defined(KERNEL)
|
||||
#ifdef DEVFS
|
||||
void *devfs_token; /* device filesystem handle */
|
||||
#endif /* DEVFS */
|
||||
#endif /* __FreeBSD__ KERNEL */
|
||||
};
|
||||
|
||||
/* flags in softc */
|
||||
#define QC_OPEN 0x01 /* device open */
|
||||
#define QC_ALIVE 0x02 /* probed and attached */
|
||||
#define QC_BIDIR_HW 0x04 /* bidir parallel port */
|
||||
#define QC_FORCEUNI 0x08 /* ...but force unidir mode */
|
||||
|
||||
#define QC_MAXFRAMEBUFSIZE (QC_MAX_XSIZE*QC_MAX_YSIZE)
|
||||
|
||||
#ifdef __linux__ /* Linux is backwards from *BSD */
|
||||
|
||||
#define read_data(P) inb((P))
|
||||
#define read_data_word(P) inw((P))
|
||||
#define read_status(P) inb((P)+1)
|
||||
#define write_data(P, V) outb((V), (P)+0)
|
||||
#define write_status(P, V) outb((V), (P)+1)
|
||||
#define write_control(P, V) outb((V), (P)+2)
|
||||
|
||||
#define LONGDELAY(n) tsleep((n)/1000)
|
||||
|
||||
#else /* FreeBSD/NetBSD/BSDI */
|
||||
|
||||
#define read_data(P) inb((P))
|
||||
#define read_data_word(P) inw((P))
|
||||
#define read_status(P) inb((P)+1)
|
||||
#define write_data(P, V) outb((P)+0, (V))
|
||||
#define write_status(P, V) outb((P)+1, (V))
|
||||
#define write_control(P, V) outb((P)+2, (V))
|
||||
|
||||
#define LONGDELAY(n) DELAY(n)
|
||||
|
||||
#ifndef KERNEL
|
||||
#define DELAY(n) usleep(n)
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define QC_TIMEOUT_INIT 60000 /* timeout for first
|
||||
read of scan */
|
||||
#define QC_TIMEOUT_CMD 5000 /* timeout for control cmds */
|
||||
#define QC_TIMEOUT 400 /* timeout on scan reads */
|
||||
|
||||
/* This value could be OS
|
||||
dependant */
|
||||
#define QC_DEF_EXPOSURE 200 /* default exposure */
|
||||
|
||||
extern int qcam_detect __P((u_int port));
|
||||
extern void qcam_reset __P((struct qcam_softc *qs));
|
||||
extern int qcam_scan __P((struct qcam_softc *qs));
|
||||
extern void qcam_default __P((struct qcam_softc *qs));
|
||||
extern int qcam_ioctl_get __P((struct qcam_softc *qs,
|
||||
struct qcam *info));
|
||||
extern int qcam_ioctl_set __P((struct qcam_softc *qs,
|
||||
struct qcam *info));
|
||||
#endif /* _QCAM_DEFS_H */
|
@ -1,662 +0,0 @@
|
||||
/*
|
||||
* Connectix QuickCam parallel-port camera video capture driver.
|
||||
* Copyright (c) 1996, Paul Traina.
|
||||
*
|
||||
* This driver is based in part on work
|
||||
* Copyright (c) 1996, Thomas Davis.
|
||||
*
|
||||
* Additional ideas from code written by Michael Chinn and Nelson Minar.
|
||||
*
|
||||
* QuickCam(TM) is a registered trademark of Connectix Inc.
|
||||
* Use this driver at your own risk, it is not warranted by
|
||||
* Connectix or the authors.
|
||||
*
|
||||
* 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
|
||||
* in this position and unchanged.
|
||||
* 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software withough 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.
|
||||
*/
|
||||
|
||||
#ifndef NQCAM
|
||||
#include "qcam.h" /* this file defines NQCAM _only_ */
|
||||
#endif
|
||||
|
||||
#if NQCAM > 0
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
#include <sys/param.h>
|
||||
#include <machine/cpufunc.h>
|
||||
#ifdef KERNEL
|
||||
#include <sys/systm.h>
|
||||
#include <machine/clock.h>
|
||||
#include <machine/qcam.h>
|
||||
#else /* user mode version of driver */
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include "qcam.h"
|
||||
#endif /* KERNEL */
|
||||
#endif /* FreeBSD or NetBSD */
|
||||
|
||||
#ifdef bsdi
|
||||
#include <sys/param.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/device.h>
|
||||
#include "qcam.h"
|
||||
#endif /* bsdi */
|
||||
|
||||
#ifdef __linux__
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/delay.h>
|
||||
#include <asm/io.h>
|
||||
#include "qcam-linux.h"
|
||||
#include "qcam.h"
|
||||
#endif /* __linux__ */
|
||||
|
||||
#ifdef _SCO_DS
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include "qcam-sco.h"
|
||||
#include "qcam.h"
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <i386/isa/qcamreg.h>
|
||||
#include <i386/isa/qcamdefs.h>
|
||||
|
||||
#include <machine/limits.h> /* XXX for bogus UCHAR_MAX checks -
|
||||
* the types are all u_char so the
|
||||
* tests are null */
|
||||
#else
|
||||
#include "qcamreg.h"
|
||||
#include "qcamdefs.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* There should be _NO_ operating system dependant code or definitions
|
||||
* past this point.
|
||||
*/
|
||||
|
||||
static const u_char qcam_zoommode[3][3] = {
|
||||
{ QC_XFER_WIDE, QC_XFER_WIDE, QC_XFER_WIDE },
|
||||
{ QC_XFER_NARROW, QC_XFER_WIDE, QC_XFER_WIDE },
|
||||
{ QC_XFER_TIGHT, QC_XFER_NARROW, QC_XFER_WIDE }
|
||||
};
|
||||
|
||||
static int qcam_timeouts;
|
||||
|
||||
#ifdef QCAM_GRAB_STATS
|
||||
|
||||
#define STATBUFSIZE (QC_MAXFRAMEBUFSIZE*2+50)
|
||||
static u_short qcam_rsbhigh[STATBUFSIZE];
|
||||
static u_short qcam_rsblow[STATBUFSIZE];
|
||||
static u_short *qcam_rsbhigh_p = qcam_rsbhigh;
|
||||
static u_short *qcam_rsblow_p = qcam_rsblow;
|
||||
static u_short *qcam_rsbhigh_end = &qcam_rsbhigh[STATBUFSIZE];
|
||||
static u_short *qcam_rsblow_end = &qcam_rsblow[STATBUFSIZE];
|
||||
|
||||
#define STATHIGH(T) \
|
||||
if (qcam_rsbhigh_p < qcam_rsbhigh_end) \
|
||||
*qcam_rsbhigh_p++ = ((T) - timeout); \
|
||||
if (!timeout) qcam_timeouts++;
|
||||
|
||||
#define STATLOW(T) \
|
||||
if (qcam_rsblow_p < qcam_rsblow_end) \
|
||||
*qcam_rsblow_p++ = ((T) - timeout); \
|
||||
if (!timeout) qcam_timeouts++;
|
||||
|
||||
#else
|
||||
|
||||
#define STATHIGH(T) if (!timeout) qcam_timeouts++;
|
||||
#define STATLOW(T) if (!timeout) qcam_timeouts++;
|
||||
|
||||
#endif /* QCAM_GRAB_STATS */
|
||||
|
||||
#define READ_STATUS_BYTE_HIGH(P, V, T) { \
|
||||
u_short timeout = (T); \
|
||||
do { (V) = read_status((P)); \
|
||||
} while (!(((V) & 0x08)) && --timeout); STATHIGH(T) \
|
||||
}
|
||||
|
||||
#define READ_STATUS_BYTE_LOW(P, V, T) { \
|
||||
u_short timeout = (T); \
|
||||
do { (V) = read_status((P)); \
|
||||
} while (((V) & 0x08) && --timeout); STATLOW(T) \
|
||||
}
|
||||
|
||||
#define READ_DATA_WORD_HIGH(P, V, T) { \
|
||||
u_int timeout = (T); \
|
||||
do { (V) = read_data_word((P)); \
|
||||
} while (!((V) & 0x01) && --timeout); STATHIGH(T) \
|
||||
}
|
||||
|
||||
#define READ_DATA_WORD_LOW(P, V, T) { \
|
||||
u_int timeout = (T); \
|
||||
do { (V) = read_data_word((P)); \
|
||||
} while (((V) & 0x01) && --timeout); STATLOW(T) \
|
||||
}
|
||||
|
||||
inline static int
|
||||
sendbyte (u_int port, int value, int sdelay)
|
||||
{
|
||||
u_char s1, s2;
|
||||
|
||||
write_data(port, value);
|
||||
if (sdelay) {
|
||||
DELAY(sdelay);
|
||||
write_data(port, value);
|
||||
}
|
||||
|
||||
write_control(port, QC_CTL_HIGHNIB);
|
||||
READ_STATUS_BYTE_HIGH(port, s1, QC_TIMEOUT_CMD);
|
||||
|
||||
write_control(port, QC_CTL_LOWNIB);
|
||||
READ_STATUS_BYTE_LOW(port, s2, QC_TIMEOUT_CMD);
|
||||
|
||||
return (s1 & 0xf0) | (s2 >> 4);
|
||||
}
|
||||
|
||||
static int
|
||||
send_command (struct qcam_softc *qs, int cmd, int value)
|
||||
{
|
||||
if (sendbyte(qs->iobase, cmd, qs->exposure) != cmd)
|
||||
return 1;
|
||||
|
||||
if (sendbyte(qs->iobase, value, qs->exposure) != value)
|
||||
return 1;
|
||||
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
static int
|
||||
send_xfermode (struct qcam_softc *qs, int value)
|
||||
{
|
||||
if (sendbyte(qs->iobase, QC_XFERMODE, qs->exposure) != QC_XFERMODE)
|
||||
return 1;
|
||||
|
||||
if (sendbyte(qs->iobase, value, qs->exposure) != value)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
qcam_reset (struct qcam_softc *qs)
|
||||
{
|
||||
register u_int iobase = qs->iobase;
|
||||
register u_char result;
|
||||
|
||||
write_control(iobase, 0x20);
|
||||
write_data (iobase, 0x75);
|
||||
|
||||
result = read_data(iobase);
|
||||
|
||||
if ((result != 0x75) && !(qs->flags & QC_FORCEUNI))
|
||||
qs->flags |= QC_BIDIR_HW; /* bidirectional parallel port */
|
||||
else
|
||||
qs->flags &= ~QC_BIDIR_HW;
|
||||
|
||||
write_control(iobase, 0x0b);
|
||||
DELAY(250);
|
||||
write_control(iobase, QC_CTL_LOWNIB);
|
||||
DELAY(250);
|
||||
}
|
||||
|
||||
static int
|
||||
qcam_waitfor_bi (u_int port)
|
||||
{
|
||||
u_char s1, s2;
|
||||
|
||||
write_control(port, QC_CTL_HIGHWORD);
|
||||
READ_STATUS_BYTE_HIGH(port, s1, QC_TIMEOUT_INIT);
|
||||
|
||||
write_control(port, QC_CTL_LOWWORD);
|
||||
READ_STATUS_BYTE_LOW(port, s2, QC_TIMEOUT);
|
||||
|
||||
return (s1 & 0xf0) | (s2 >> 4);
|
||||
}
|
||||
|
||||
/*
|
||||
* The pixels are read in 16 bits at a time, and we get 3 valid pixels per
|
||||
* 16-bit read. The encoding format looks like this:
|
||||
*
|
||||
* |---- status reg -----| |----- data reg ------|
|
||||
* 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
||||
* 3 3 3 3 2 x x x 2 2 2 1 1 1 1 R
|
||||
*
|
||||
* 1 = left pixel R = camera ready
|
||||
* 2 = middle pixel x = unknown/unused?
|
||||
* 3 = right pixel
|
||||
*
|
||||
* XXX do not use this routine yet! It does not work.
|
||||
* Nelson believes that even though 6 pixels are read in per 2 words,
|
||||
* only the 1 & 2 pixels from the first word are correct. This seems
|
||||
* bizzare, more study is needed here.
|
||||
*/
|
||||
|
||||
#define DECODE_WORD_BI4BPP(P, W) \
|
||||
*(P)++ = 15 - (((W) >> 12) & 0x0f); \
|
||||
*(P)++ = 15 - ((((W) >> 8) & 0x08) | (((W) >> 5) & 0x07)); \
|
||||
*(P)++ = 15 - (((W) >> 1) & 0x0f);
|
||||
|
||||
static void
|
||||
qcam_bi_4bit (struct qcam_softc *qs)
|
||||
{
|
||||
u_char *p;
|
||||
u_int port;
|
||||
u_short word;
|
||||
|
||||
port = qs->iobase; /* for speed */
|
||||
|
||||
qcam_waitfor_bi(port);
|
||||
|
||||
/*
|
||||
* Unlike the other routines, this routine has NOT be interleaved
|
||||
* yet because we don't have the algorythm for 4bbp down tight yet,
|
||||
* so why add to the confusion?
|
||||
*/
|
||||
for (p = qs->buffer; p < qs->buffer_end; ) {
|
||||
write_control(port, QC_CTL_HIGHWORD);
|
||||
READ_DATA_WORD_HIGH(port, word, QC_TIMEOUT);
|
||||
DECODE_WORD_BI4BPP(p, word);
|
||||
|
||||
write_control(port, QC_CTL_LOWWORD);
|
||||
READ_DATA_WORD_HIGH(port, word, QC_TIMEOUT);
|
||||
DECODE_WORD_BI4BPP(p, word);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The pixels are read in 16 bits at a time, 12 of those bits contain
|
||||
* pixel information, the format looks like this:
|
||||
*
|
||||
* |---- status reg -----| |----- data reg ------|
|
||||
* 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
||||
* 2 2 2 2 2 x x x 2 1 1 1 1 1 1 R
|
||||
*
|
||||
* 1 = left pixel R = camera ready
|
||||
* 2 = right pixel x = unknown/unused?
|
||||
*/
|
||||
|
||||
#define DECODE_WORD_BI6BPP(P, W) \
|
||||
*(P)++ = 63 - (((W) >> 1) & 0x3f); \
|
||||
*(P)++ = 63 - ((((W) >> 10) & 0x3e) | (((W) >> 7) & 0x01));
|
||||
|
||||
static void
|
||||
qcam_bi_6bit (struct qcam_softc *qs)
|
||||
{
|
||||
u_char *p;
|
||||
u_short hi, low;
|
||||
u_int port;
|
||||
|
||||
port = qs->iobase; /* for speed */
|
||||
|
||||
qcam_waitfor_bi(port);
|
||||
|
||||
/*
|
||||
* This was interleaved before, but I cut it back to the simple
|
||||
* mode so that it's easier for people to play with it. A quick
|
||||
* unrolling of the loop coupled with interleaved decoding and I/O
|
||||
* should get us a slight CPU bonus later.
|
||||
*/
|
||||
for (p = qs->buffer; p < qs->buffer_end; ) {
|
||||
write_control(port, QC_CTL_HIGHWORD);
|
||||
READ_DATA_WORD_HIGH(port, hi, QC_TIMEOUT);
|
||||
DECODE_WORD_BI6BPP(p, hi);
|
||||
|
||||
write_control(port, QC_CTL_LOWWORD);
|
||||
READ_DATA_WORD_LOW(port, low, QC_TIMEOUT);
|
||||
DECODE_WORD_BI6BPP(p, low);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We're doing something tricky here that makes this routine a little
|
||||
* more complex than you would expect. We're interleaving the high
|
||||
* and low nibble reads with the math required for nibble munging.
|
||||
* This should allow us to use the "free" time while we're waiting for
|
||||
* the next nibble to come ready to do any data conversion operations.
|
||||
*/
|
||||
#define DECODE_WORD_UNI4BPP(P, W) \
|
||||
*(P)++ = 15 - ((W) >> 4);
|
||||
|
||||
static void
|
||||
qcam_uni_4bit (struct qcam_softc *qs)
|
||||
{
|
||||
u_char *p, *end, hi, low;
|
||||
u_int port;
|
||||
|
||||
port = qs->iobase;
|
||||
p = qs->buffer;
|
||||
end = qs->buffer_end - 1;
|
||||
|
||||
/* request and wait for first nibble */
|
||||
|
||||
write_control(port, QC_CTL_HIGHNIB);
|
||||
READ_STATUS_BYTE_HIGH(port, hi, QC_TIMEOUT_INIT);
|
||||
|
||||
/* request second nibble, munge first nibble while waiting, read 2nd */
|
||||
|
||||
write_control(port, QC_CTL_LOWNIB);
|
||||
DECODE_WORD_UNI4BPP(p, hi);
|
||||
READ_STATUS_BYTE_LOW(port, low, QC_TIMEOUT);
|
||||
|
||||
while (p < end) {
|
||||
write_control(port, QC_CTL_HIGHNIB);
|
||||
DECODE_WORD_UNI4BPP(p, low);
|
||||
READ_STATUS_BYTE_HIGH(port, hi, QC_TIMEOUT);
|
||||
|
||||
write_control(port, QC_CTL_LOWNIB);
|
||||
DECODE_WORD_UNI4BPP(p, hi);
|
||||
READ_STATUS_BYTE_LOW(port, low, QC_TIMEOUT);
|
||||
}
|
||||
DECODE_WORD_UNI4BPP(p, low);
|
||||
}
|
||||
|
||||
/*
|
||||
* If you treat each pair of nibble operations as pulling in a byte, you
|
||||
* end up with a byte stream that looks like this:
|
||||
*
|
||||
* msb lsb
|
||||
* 2 2 1 1 1 1 1 1
|
||||
* 2 2 2 2 3 3 3 3
|
||||
* 3 3 4 4 4 4 4 4
|
||||
*/
|
||||
|
||||
static void
|
||||
qcam_uni_6bit (struct qcam_softc *qs)
|
||||
{
|
||||
u_char *p;
|
||||
u_int port;
|
||||
u_char word1, word2, word3, hi, low;
|
||||
|
||||
port = qs->iobase;
|
||||
|
||||
/*
|
||||
* This routine has been partially interleaved... we can do a better
|
||||
* job, but for right now, I've deliberately kept it less efficient
|
||||
* so we can play with decoding without hurting peoples brains.
|
||||
*/
|
||||
for (p = qs->buffer; p < qs->buffer_end; ) {
|
||||
write_control(port, QC_CTL_HIGHNIB);
|
||||
READ_STATUS_BYTE_HIGH(port, hi, QC_TIMEOUT_INIT);
|
||||
write_control(port, QC_CTL_LOWNIB);
|
||||
READ_STATUS_BYTE_LOW(port, low, QC_TIMEOUT);
|
||||
write_control(port, QC_CTL_HIGHNIB);
|
||||
word1 = (hi & 0xf0) | (low >>4);
|
||||
READ_STATUS_BYTE_HIGH(port, hi, QC_TIMEOUT);
|
||||
write_control(port, QC_CTL_LOWNIB);
|
||||
*p++ = 63 - (word1 >> 2);
|
||||
READ_STATUS_BYTE_LOW(port, low, QC_TIMEOUT);
|
||||
write_control(port, QC_CTL_HIGHNIB);
|
||||
word2 = (hi & 0xf0) | (low >> 4);
|
||||
READ_STATUS_BYTE_HIGH(port, hi, QC_TIMEOUT);
|
||||
write_control(port, QC_CTL_LOWNIB);
|
||||
*p++ = 63 - (((word1 & 0x03) << 4) | (word2 >> 4));
|
||||
READ_STATUS_BYTE_LOW(port, low, QC_TIMEOUT);
|
||||
word3 = (hi & 0xf0) | (low >> 4);
|
||||
*p++ = 63 - (((word2 & 0x0f) << 2) | (word3 >> 6));
|
||||
*p++ = 63 - (word3 & 0x3f);
|
||||
}
|
||||
|
||||
/* XXX this is something xfqcam does, doesn't make sense to me,
|
||||
but we don't see timeoutes here... ? */
|
||||
write_control(port, QC_CTL_LOWNIB);
|
||||
READ_STATUS_BYTE_LOW(port, word1, QC_TIMEOUT);
|
||||
write_control(port, QC_CTL_HIGHNIB);
|
||||
READ_STATUS_BYTE_LOW(port, word1, QC_TIMEOUT);
|
||||
}
|
||||
|
||||
static void
|
||||
qcam_xferparms (struct qcam_softc *qs)
|
||||
{
|
||||
int bidir;
|
||||
|
||||
qs->xferparms = 0;
|
||||
|
||||
bidir = (qs->flags & QC_BIDIR_HW);
|
||||
if (bidir)
|
||||
qs->xferparms |= QC_XFER_BIDIR;
|
||||
|
||||
if (qcam_debug)
|
||||
printf("qcam%d: %dbpp %sdirectional scan mode selected\n",
|
||||
qs->unit, qs->bpp, bidir ? "bi" : "uni");
|
||||
|
||||
if (qs->bpp == 6) {
|
||||
qs->xferparms |= QC_XFER_6BPP;
|
||||
qs->scanner = bidir ? qcam_bi_6bit : qcam_uni_6bit;
|
||||
} else {
|
||||
qs->scanner = bidir ? qcam_bi_4bit : qcam_uni_4bit;
|
||||
}
|
||||
|
||||
if (qs->x_size > 160 || qs->y_size > 120) {
|
||||
qs->xferparms |= qcam_zoommode[0][qs->zoom];
|
||||
} else if (qs->x_size > 80 || qs->y_size > 60) {
|
||||
qs->xferparms |= qcam_zoommode[1][qs->zoom];
|
||||
} else
|
||||
qs->xferparms |= qcam_zoommode[2][qs->zoom];
|
||||
}
|
||||
|
||||
static void
|
||||
qcam_init (struct qcam_softc *qs)
|
||||
{
|
||||
int x_size = (qs->bpp == 4) ? qs->x_size / 2 : qs->x_size / 4;
|
||||
|
||||
qcam_xferparms(qs);
|
||||
|
||||
send_command(qs, QC_BRIGHTNESS, qs->brightness);
|
||||
send_command(qs, QC_BRIGHTNESS, 1);
|
||||
send_command(qs, QC_BRIGHTNESS, 1);
|
||||
send_command(qs, QC_BRIGHTNESS, qs->brightness);
|
||||
send_command(qs, QC_BRIGHTNESS, qs->brightness);
|
||||
send_command(qs, QC_BRIGHTNESS, qs->brightness);
|
||||
send_command(qs, QC_YSIZE, qs->y_size);
|
||||
send_command(qs, QC_XSIZE, x_size);
|
||||
send_command(qs, QC_YORG, qs->y_origin);
|
||||
send_command(qs, QC_XORG, qs->x_origin);
|
||||
send_command(qs, QC_CONTRAST, qs->contrast);
|
||||
send_command(qs, QC_WHITEBALANCE, qs->whitebalance);
|
||||
|
||||
if (qs->buffer)
|
||||
qs->buffer_end = qs->buffer +
|
||||
min((qs->x_size*qs->y_size), QC_MAXFRAMEBUFSIZE);
|
||||
|
||||
qs->init_req = 0;
|
||||
}
|
||||
|
||||
int
|
||||
qcam_scan (struct qcam_softc *qs)
|
||||
{
|
||||
int timeouts;
|
||||
|
||||
#ifdef QCAM_GRAB_STATS
|
||||
bzero(qcam_rsbhigh, sizeof(qcam_rsbhigh));
|
||||
bzero(qcam_rsblow, sizeof(qcam_rsblow));
|
||||
qcam_rsbhigh_p = qcam_rsbhigh;
|
||||
qcam_rsblow_p = qcam_rsblow;
|
||||
#endif
|
||||
|
||||
timeouts = qcam_timeouts;
|
||||
|
||||
if (qs->init_req)
|
||||
qcam_init(qs);
|
||||
|
||||
if (send_xfermode(qs, qs->xferparms))
|
||||
return 1;
|
||||
|
||||
if (qcam_debug && (timeouts != qcam_timeouts))
|
||||
printf("qcam%d: %d timeouts during init\n", qs->unit,
|
||||
qcam_timeouts - timeouts);
|
||||
|
||||
timeouts = qcam_timeouts;
|
||||
|
||||
if (qs->scanner)
|
||||
(*qs->scanner)(qs);
|
||||
else
|
||||
return 1;
|
||||
|
||||
if (qcam_debug && (timeouts != qcam_timeouts))
|
||||
printf("qcam%d: %d timeouts during scan\n", qs->unit,
|
||||
qcam_timeouts - timeouts);
|
||||
|
||||
write_control(qs->iobase, 0x0f);
|
||||
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
void
|
||||
qcam_default (struct qcam_softc *qs)
|
||||
{
|
||||
qs->contrast = QC_DEF_CONTRAST;
|
||||
qs->brightness = QC_DEF_BRIGHTNESS;
|
||||
qs->whitebalance = QC_DEF_WHITEBALANCE;
|
||||
qs->x_size = QC_DEF_XSIZE;
|
||||
qs->y_size = QC_DEF_YSIZE;
|
||||
qs->x_origin = QC_DEF_XORG;
|
||||
qs->y_origin = QC_DEF_YORG;
|
||||
qs->bpp = QC_DEF_BPP;
|
||||
qs->zoom = QC_DEF_ZOOM;
|
||||
qs->exposure = QC_DEF_EXPOSURE;
|
||||
}
|
||||
|
||||
int
|
||||
qcam_ioctl_get (struct qcam_softc *qs, struct qcam *info)
|
||||
{
|
||||
info->qc_version = QC_IOCTL_VERSION;
|
||||
info->qc_xsize = qs->x_size;
|
||||
info->qc_ysize = qs->y_size;
|
||||
info->qc_xorigin = qs->x_origin;
|
||||
info->qc_yorigin = qs->y_origin;
|
||||
info->qc_bpp = qs->bpp;
|
||||
info->qc_zoom = qs->zoom;
|
||||
info->qc_exposure = qs->exposure;
|
||||
info->qc_brightness = qs->brightness;
|
||||
info->qc_whitebalance = qs->whitebalance;
|
||||
info->qc_contrast = qs->contrast;
|
||||
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
int
|
||||
qcam_ioctl_set (struct qcam_softc *qs, struct qcam *info)
|
||||
{
|
||||
/*
|
||||
* sanity check parameters passed in by user
|
||||
* we're extra paranoid right now because the API
|
||||
* is in flux
|
||||
*/
|
||||
if (info->qc_xsize > QC_MAX_XSIZE ||
|
||||
info->qc_ysize > QC_MAX_YSIZE ||
|
||||
info->qc_xorigin > QC_MAX_XSIZE ||
|
||||
info->qc_yorigin > QC_MAX_YSIZE ||
|
||||
(info->qc_bpp != 4 && info->qc_bpp != 6) ||
|
||||
info->qc_zoom > QC_ZOOM_200 ||
|
||||
info->qc_brightness > UCHAR_MAX ||
|
||||
info->qc_whitebalance > UCHAR_MAX ||
|
||||
info->qc_contrast > UCHAR_MAX)
|
||||
return 1; /* failure */
|
||||
|
||||
/* version check */
|
||||
if (info->qc_version != QC_IOCTL_VERSION)
|
||||
return 1; /* failure */
|
||||
|
||||
qs->x_size = info->qc_xsize;
|
||||
qs->y_size = info->qc_ysize;
|
||||
qs->x_origin = info->qc_xorigin;
|
||||
qs->y_origin = info->qc_yorigin;
|
||||
qs->bpp = info->qc_bpp;
|
||||
qs->zoom = info->qc_zoom;
|
||||
qs->exposure = info->qc_exposure;
|
||||
qs->brightness = info->qc_brightness;
|
||||
qs->whitebalance = info->qc_whitebalance;
|
||||
qs->contrast = info->qc_contrast;
|
||||
|
||||
/* request initialization before next scan pass */
|
||||
qs->init_req = 1;
|
||||
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
#ifndef QCAM_INVASIVE_SCAN
|
||||
/*
|
||||
* Attempt a non-destructive probe for the QuickCam.
|
||||
* Current models appear to toggle the upper 4 bits of
|
||||
* the status register at approximately 5-10 Hz.
|
||||
*
|
||||
* Be aware that this isn't the way that Connectix detects the
|
||||
* camera (they send a reset and try to handshake), but this
|
||||
* way is safe.
|
||||
*/
|
||||
int
|
||||
qcam_detect (u_int port)
|
||||
{
|
||||
int i, transitions = 0;
|
||||
u_char reg, last;
|
||||
|
||||
write_control(port, 0x20);
|
||||
write_control(port, 0x0b);
|
||||
write_control(port, 0x0e);
|
||||
|
||||
last = reg = read_status(port);
|
||||
|
||||
for (i = 0; i < QC_PROBELIMIT; i++) {
|
||||
reg = read_status(port) & 0xf0;
|
||||
|
||||
if (reg != last) /* if we got a toggle, count it */
|
||||
transitions++;
|
||||
|
||||
last = reg;
|
||||
LONGDELAY(100000); /* 100ms */
|
||||
}
|
||||
|
||||
return transitions >= QC_PROBECNTLOW &&
|
||||
transitions <= QC_PROBECNTHI;
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* This form of probing for the camera can cause garbage to show
|
||||
* up on your printers if they're plugged in instead. However,
|
||||
* some folks have a problem with the nondestructive scan when
|
||||
* using EPP/ECP parallel ports.
|
||||
*
|
||||
* Try to send down a brightness command, if we succeed, we've
|
||||
* got a camera on the remote side.
|
||||
*/
|
||||
int
|
||||
qcam_detect (u_int port)
|
||||
{
|
||||
write_control(port, 0x20);
|
||||
write_data(port, 0x75);
|
||||
read_data(port);
|
||||
write_control(port, 0x0b);
|
||||
DELAY(250);
|
||||
write_control(port, 0x0e);
|
||||
DELAY(250);
|
||||
|
||||
if (sendbyte(port, QC_BRIGHTNESS, QC_DEF_EXPOSURE) != QC_BRIGHTNESS)
|
||||
return 0; /* failure */
|
||||
return (sendbyte(port, 1, QC_DEF_EXPOSURE) == 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NQCAM */
|
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Connectix QuickCam parallel-port camera video capture driver.
|
||||
* Copyright (c) 1996, Paul Traina.
|
||||
*
|
||||
* This driver is based in part on work
|
||||
* Copyright (c) 1996, Thomas Davis.
|
||||
*
|
||||
* QuickCam(TM) is a registered trademark of Connectix Inc.
|
||||
* Use this driver at your own risk, it is not warranted by
|
||||
* Connectix or the authors.
|
||||
*
|
||||
* 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
|
||||
* in this position and unchanged.
|
||||
* 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software withough 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.
|
||||
*
|
||||
* The following information is hardware dependant. It should not be used
|
||||
* by user applications, see machine/qcam.h for the applications interface.
|
||||
*/
|
||||
|
||||
#ifndef _QCAMREG_H
|
||||
#define _QCAMREG_H
|
||||
|
||||
/*
|
||||
* Camera autodetection parameters
|
||||
*/
|
||||
#define QC_PROBELIMIT 30 /* number of times to probe */
|
||||
#define QC_PROBECNTLOW 5 /* minimum transitions */
|
||||
#define QC_PROBECNTHI 25 /* maximum transitions */
|
||||
|
||||
/*
|
||||
* QuickCam camera commands
|
||||
*/
|
||||
#define QC_BRIGHTNESS 0x0b
|
||||
#define QC_CONTRAST 0x19
|
||||
#define QC_WHITEBALANCE 0x1f
|
||||
#define QC_XFERMODE 0x07
|
||||
#define QC_XSIZE 0x13
|
||||
#define QC_YSIZE 0x11
|
||||
#define QC_YORG 0x0d
|
||||
#define QC_XORG 0x0f
|
||||
|
||||
/*
|
||||
* XFERmode register flags
|
||||
*/
|
||||
#define QC_XFER_BIDIR 0x01 /* bidirectional transfer */
|
||||
#define QC_XFER_6BPP 0x02 /* 6 bits per pixel */
|
||||
#define QC_XFER_WIDE 0x00 /* wide angle */
|
||||
#define QC_XFER_NARROW 0x04 /* narrow */
|
||||
#define QC_XFER_TIGHT 0x08 /* very narrow */
|
||||
|
||||
/*
|
||||
* QuickCam default values (don't depend on these staying the same)
|
||||
*/
|
||||
#define QC_DEF_XSIZE 160
|
||||
#define QC_DEF_YSIZE 120
|
||||
#define QC_DEF_XORG 7
|
||||
#define QC_DEF_YORG 1
|
||||
#define QC_DEF_BPP 6
|
||||
#define QC_DEF_CONTRAST 180
|
||||
#define QC_DEF_BRIGHTNESS 180
|
||||
#define QC_DEF_WHITEBALANCE 150
|
||||
#define QC_DEF_ZOOM QC_ZOOM_100
|
||||
|
||||
/*
|
||||
* QuickCam parallel port handshake constants
|
||||
*/
|
||||
#define QC_CTL_HIGHNIB 0x06
|
||||
#define QC_CTL_LOWNIB 0x0e
|
||||
#define QC_CTL_HIGHWORD 0x26
|
||||
#define QC_CTL_LOWWORD 0x2f
|
||||
|
||||
#endif /* _QCAMREG_H */
|
Loading…
x
Reference in New Issue
Block a user