The very minimum driver required to support a Video Spigot. See the

copyright notices in the code for information on where to go to pick
up additional useful bits.
Submitted by:   Jim Lowe <james@blatz.cs.uwm.edu>
This commit is contained in:
Jordan K. Hubbard 1995-02-06 23:20:17 +00:00
parent 2cd01159da
commit f741ad121b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=6219
3 changed files with 357 additions and 4 deletions

View File

@ -41,7 +41,7 @@
* SUCH DAMAGE.
*
* from: @(#)conf.c 5.8 (Berkeley) 5/12/91
* $Id: conf.c,v 1.56 1995/01/31 06:34:53 amurai Exp $
* $Id: conf.c,v 1.57 1995/02/05 11:29:38 jkh Exp $
*/
#include <sys/param.h>
@ -751,6 +751,24 @@ d_select_t tunselect;
#define tunselect (d_select_t *)enxio
#endif
#include "spigot.h"
#if NSPIGOT > 0
d_open_t spigot_open;
d_close_t spigot_close;
d_ioctl_t spigot_ioctl;
d_rdwr_t spigot_read, spigot_write;
d_select_t spigot_select;
d_mmap_t spigot_mmap;
#else
#define spigot_open (d_open_t *)enxio
#define spigot_close (d_close_t *)enxio
#define spigot_ioctl (d_ioctl_t *)enxio
#define spigot_read (d_rdwr_t *)enxio
#define spigot_write (d_rdwr_t *)enxio
#define spigot_select seltrue
#define spigot_mmap nommap
#endif
/* open, close, read, write, ioctl, stop, reset, ttys, select, mmap, strat */
struct cdevsw cdevsw[] =
{
@ -787,9 +805,9 @@ struct cdevsw cdevsw[] =
{ wtopen, wtclose, rawread, rawwrite, /*10*/
wtioctl, nostop, nullreset, NULL, /* wt */
seltrue, nommap, wtstrategy },
{ noopen, noclose, noread, nowrite, /*11*/
noioc, nostop, nullreset, NULL,
seltrue, nommap, nostrat },
{ spigot_open, spigot_close, spigot_read, spigot_write, /*11*/
spigot_ioctl, nostop, nullreset, NULL, /* Spigot */
spigot_select, spigot_mmap, NULL },
{ scopen, scclose, scread, scwrite, /*12*/
scioctl, nullstop, nullreset, sccons, /* sc */
ttselect, scmmap, NULL },

80
sys/i386/include/spigot.h Normal file
View File

@ -0,0 +1,80 @@
/*
* Video spigot capture driver.
*
* Copyright (c) 1995, Jim Lowe. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
*
* Version 1.1, Feb 1, 1995.
*/
/*
* Set up a user interrupt.
*/
#define SPIGOT_SETINT _IOW('s', 5, int)
/*
* Allow/disallow access to the I/O Page.
*/
#define SPIGOT_IOPL_ON _IO ('s', 6)
#define SPIGOT_IOPL_OFF _IO ('s', 7)
#ifndef KERNEL
/*
* Defines for spigot library.
*/
unsigned short * spigot_open(char *dev);
void spigot_close(void);
void spigot_set_capture_size(int width, int vtof);
unsigned char spigot_start_xfer(int num_frames);
void spigot_stop_xfer(void);
unsigned char spigot_status(void);
/*
* Define the status bits.
*/
#define SPIGOT_COLOR 0x01 /* Color present (No color) */
#define SPIGOT_60HZ 0x02 /* 60 hz input signal (50hz) */
#define SPIGOT_NO_HORIZONTAL_LOCK 0x04 /* Horizontal lock present */
#define SPIGOT_HPLL_LOCKED 0x08 /* HPLL locked (HPLL unlocked)*/
#define SPIGOT_VCR_MODE 0x10 /* VCR mode (TV mode) */
#define SPIGOT_VSYNC_PRESENT 0x20 /* Vsync present */
/*
* spigot_open() returns a data address pointing to the spigot data.
* Each read from this address returns the next word. The ``dev'' passed
* is usually "/dev/spigot". Data is described in the phillips desktop
* video data handbook under the 7191 chip. Formats may be either
* YUV 4:2:2 or YUV 4:1:1. A sample device driver for ``nv'' is included
* with this code.
*
* spigot_close() cleans up and closes the device.
*
* spigot_set_capture_size() will set the capture window size. Width should be
* one of: 80, 160, 240, 320, or 640 for NTSC or
* 96, 192, 288, 384 for PAL.
* vtof is the Vertical top of frame offset and must be between 0 and 15 lines.
*
* spigot_start_xfer() will start a transfer from the 7191 to the data fifo.
* spigot_stop_xfer() will clear the data fifo and abort any transfers.
*
* spigot_status() will return the above status bits.
*/
#endif

255
sys/i386/isa/spigot.c Normal file
View File

@ -0,0 +1,255 @@
/*
* Video spigot capture driver.
*
* Copyright (c) 1995, Jim Lowe. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
*
* This is the minimum driver code required to make a spigot work.
* Unfortunatly, I can't include a real driver since the information
* on the spigot is under non-disclosure. You can pick up a library
* that will work with this driver from ftp://ftp.cs.uwm.edu/pub/FreeBSD.
* The library contains the source that I can release as well as several
* object modules and functions that allows one to read spigot data.
* See the code for spigot_grab.c that is included with the library
* data.
*
* We are working with the vendor so I can release the code, please don't
* ask me for it. When/if I can release it, I will.
*
* Version 1.1, Feb 1, 1995.
*
*/
#include "spigot.h"
#if NSPIGOT > 0
#if NSPIGOT > 1
error "Can only have 1 spigot configured."
#endif
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/file.h>
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/devconf.h>
#include <sys/errno.h>
#include <sys/mman.h>
#include <i386/isa/isa.h>
#include <i386/isa/isa_device.h>
#include <i386/include/spigot.h>
#include <i386/include/psl.h>
struct spigot_softc {
int flags;
caddr_t maddr;
struct proc *p;
int signal_num;
} spigot_softc[NSPIGOT];
/* flags in softc */
#define OPEN 0x01
#define UNIT(dev) minor(dev)
int spigot_probe(struct isa_device *id);
int spigot_attach(struct isa_device *id);
struct isa_driver spidriver = {spigot_probe, spigot_attach, "spigot"};
static struct kern_devconf kdc_spigot[NSPIGOT] = {
0, /* kdc_next -> filled in by dev_attach() */
0, /* kdc_rlink -> filled in by dev_attach() */
0, /* kdc_number -> filled in by dev_attach() */
"spigot", /* kdc_name */
0, /* kdc_unit */
{ /* kdc_md */
MDDT_ISA, /* mddc_devtype */
0 /* mddc_flags */
/* mddc_imask[4] */
},
isa_generic_externalize, /* kdc_externalize */
0, /* kdc_internalize */
0, /* kdc_goaway */
ISA_EXTERNALLEN, /* kdc_datalen */
&kdc_isa0, /* kdc_parent */
0, /* kdc_parentdata */
DC_UNKNOWN, /* kdc_state - not supported */
"Video Spigot frame grabber" /* kdc_description */
};
static inline void
spigot_registerdev(struct isa_device *id)
{
if(id->id_unit)
kdc_spigot[id->id_unit] = kdc_spigot[0];
kdc_spigot[id->id_unit].kdc_unit = id->id_unit;
kdc_spigot[id->id_unit].kdc_isa = id;
dev_attach(&kdc_spigot[id->id_unit]);
}
int
spigot_probe(struct isa_device *devp)
{
int status;
if(inb(0xad9) == 0xff) /* ff if board isn't there??? */
status = 0;
else
status = 1;
return(status);
}
int
spigot_attach(struct isa_device *devp)
{
struct spigot_softc *ss=(struct spigot_softc *)&spigot_softc[devp->id_unit];
ss->flags = 0;
ss->maddr = devp->id_maddr;
spigot_registerdev(devp);
return 1;
}
int
spigot_open(dev_t dev, int flag)
{
struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
if(ss->flags & OPEN)
return EBUSY;
ss->flags |= OPEN;
ss->p = 0;
ss->signal_num = 0;
return 0;
}
int
spigot_close(dev_t dev, int flag)
{
struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
ss->flags &= ~OPEN;
ss->p = 0;
ss->signal_num = 0;
outb(0xad6, 0);
return 0;
}
int
spigot_write(dev_t dev, struct uio *uio, int ioflag)
{
struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
return ENXIO;
}
int
spigot_read(dev_t dev, struct uio *uio, int ioflag)
{
struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
return ENXIO;
}
int
spigot_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
{
struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
struct trapframe *fp;
switch(cmd){
case SPIGOT_SETINT:
ss->p = p;
ss->signal_num = *((int *)data);
break;
case SPIGOT_IOPL_ON: /* allow access to the IO PAGE */
fp=(struct trapframe *)p->p_md.md_regs;
fp->tf_eflags |= PSL_IOPL;
break;
case SPIGOT_IOPL_OFF: /* deny access to the IO PAGE */
fp=(struct trapframe *)p->p_md.md_regs;
fp->tf_eflags &= ~PSL_IOPL;
break;
default:
printf("spigot ioctl: cmd=0x%x, '%c', num = %d, len=%d, %s\n",
cmd, IOCGROUP(cmd), cmd & 0xff, IOCPARM_LEN(cmd),
cmd&IOC_IN ? "in" : "out");
return ENOTTY;
}
return 0;
}
int
spigot_select(dev_t dev, int rw, struct proc *p)
{
struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
int s;
int r;
return ENXIO;
}
/*
* Interrupt procedure.
* Just call a user level interrupt routine.
*/
void
spigintr(int unit)
{
struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[unit];
if(ss->p && ss->signal_num)
psignal(ss->p, ss->signal_num);
}
int
spigot_mmap(dev_t dev, int offset, int nprot)
{
struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[0];
if(offset != 0)
return 0;
if(nprot & PROT_EXEC)
return 0;
return i386_btop(ss->maddr);
}
#endif /* NSPIGOT */