summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1996-05-07 09:34:36 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1996-05-07 09:34:36 +0000
commit2a3af654b451c34d43d83e9ee72f205e44ad7594 (patch)
tree86741f8ae15be55b5fcdc5ff31a7922af43a71f2 /sys/scsi
parent722bd518efbd13b806137bf4640e167916ca4093 (diff)
Remove erroneously doubled text (patch can do that when a new file
comes into existence simultaneously from two directions).
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/ss.c479
-rw-r--r--sys/scsi/ss_mustek.c625
-rw-r--r--sys/scsi/ss_mustek.h220
-rw-r--r--sys/scsi/ss_scanjet.c412
-rw-r--r--sys/scsi/ssvar.h81
5 files changed, 5 insertions, 1812 deletions
diff --git a/sys/scsi/ss.c b/sys/scsi/ss.c
index b924bdd8890..7bbec366a92 100644
--- a/sys/scsi/ss.c
+++ b/sys/scsi/ss.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ss.c,v 1.3 1996/04/21 22:31:12 deraadt Exp $ */
+/* $OpenBSD: ss.c,v 1.4 1996/05/07 09:34:31 niklas Exp $ */
/* $NetBSD: ss.c,v 1.9 1996/03/30 21:47:00 christos Exp $ */
/*
@@ -482,480 +482,3 @@ ssioctl(dev, cmd, addr, flag, p)
}
return (error);
}
-/* $NetBSD: ss.c,v 1.6 1996/02/19 00:06:07 mycroft Exp $ */
-
-/*
- * Copyright (c) 1995 Kenneth Stailey. All rights reserved.
- * modified for configurable scanner support by Joachim Koenig
- *
- * 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 Kenneth Stailey.
- * 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/param.h>
-#include <sys/systm.h>
-#include <sys/fcntl.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-#include <sys/device.h>
-#include <sys/conf.h> /* for cdevsw */
-#include <sys/scanio.h>
-
-#include <scsi/scsi_all.h>
-#include <scsi/scsi_scanner.h>
-#include <scsi/scsiconf.h>
-#include <scsi/ssvar.h>
-
-#include <scsi/ss_mustek.h>
-
-#define SSMODE(z) ( minor(z) & 0x03)
-#define SSUNIT(z) ((minor(z) >> 4) )
-
-/*
- * If the mode is 3 (e.g. minor = 3,7,11,15)
- * then the device has been openned to set defaults
- * This mode does NOT ALLOW I/O, only ioctls
- */
-#define MODE_REWIND 0
-#define MODE_NONREWIND 1
-#define MODE_CONTROL 3
-
-int ssmatch __P((struct device *, void *, void *));
-void ssattach __P((struct device *, struct device *, void *));
-
-struct cfdriver sscd = {
- NULL, "ss", ssmatch, ssattach, DV_DULL, sizeof(struct ss_softc)
-};
-
-void ssstrategy __P((struct buf *));
-void ssstart __P((void *));
-
-struct scsi_device ss_switch = {
- NULL,
- ssstart,
- NULL,
- NULL,
-};
-
-struct scsi_inquiry_pattern ss_patterns[] = {
- {T_SCANNER, T_FIXED,
- "", "", ""},
- {T_SCANNER, T_REMOV,
- "", "", ""},
- {T_PROCESSOR, T_FIXED,
- "HP ", "C1750A ", ""},
- {T_PROCESSOR, T_FIXED,
- "HP ", "C2500A ", ""},
-};
-
-int
-ssmatch(parent, match, aux)
- struct device *parent;
- void *match, *aux;
-{
- struct scsibus_attach_args *sa = aux;
- int priority;
-
- (void)scsi_inqmatch(sa->sa_inqbuf,
- (caddr_t)ss_patterns, sizeof(ss_patterns)/sizeof(ss_patterns[0]),
- sizeof(ss_patterns[0]), &priority);
- return (priority);
-}
-
-/*
- * The routine called by the low level scsi routine when it discovers
- * A device suitable for this driver
- * If it is a know special, call special attach routine to install
- * special handlers into the ss_softc structure
- */
-void
-ssattach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- struct ss_softc *ss = (void *)self;
- struct scsibus_attach_args *sa = aux;
- struct scsi_link *sc_link = sa->sa_sc_link;
-
- SC_DEBUG(sc_link, SDEV_DB2, ("ssattach: "));
-
- /*
- * Store information needed to contact our base driver
- */
- ss->sc_link = sc_link;
- sc_link->device = &ss_switch;
- sc_link->device_softc = ss;
- sc_link->openings = 1;
-
- /*
- * look for non-standard scanners with help of the quirk table
- * and install functions for special handling
- */
- SC_DEBUG(sc_link, SDEV_DB2, ("ssattach:\n"));
- if (!bcmp(sa->sa_inqbuf->vendor, "MUSTEK ", 8))
- mustek_attach(ss, sa);
- if (!bcmp(sa->sa_inqbuf->vendor, "HP ", 8))
- scanjet_attach(ss, sa);
- if (ss->special == NULL) {
- /* XXX add code to restart a SCSI2 scanner, if any */
- }
-
- /*
- * Set up the buf queue for this device
- */
- ss->buf_queue.b_active = 0;
- ss->buf_queue.b_actf = 0;
- ss->buf_queue.b_actb = &ss->buf_queue.b_actf;
-}
-
-/*
- * open the device.
- */
-int
-ssopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- int unit;
- u_int ssmode;
- int error = 0;
- struct ss_softc *ss;
- struct scsi_link *sc_link;
-
- unit = SSUNIT(dev);
- if (unit >= sscd.cd_ndevs)
- return (ENXIO);
- ss = sscd.cd_devs[unit];
- if (!ss)
- return (ENXIO);
-
- ssmode = SSMODE(dev);
- sc_link = ss->sc_link;
-
- SC_DEBUG(sc_link, SDEV_DB1, ("open: dev=0x%x (unit %d (of %d))\n", dev,
- unit, sscd.cd_ndevs));
-
- if (sc_link->flags & SDEV_OPEN) {
- printf("%s: already open\n", ss->sc_dev.dv_xname);
- return (EBUSY);
- }
-
- /*
- * Catch any unit attention errors.
- *
- * SCSI_IGNORE_MEDIA_CHANGE: when you have an ADF, some scanners
- * consider paper to be a changeable media
- *
- */
- error = scsi_test_unit_ready(sc_link,
- SCSI_IGNORE_MEDIA_CHANGE | SCSI_IGNORE_ILLEGAL_REQUEST |
- (ssmode == MODE_CONTROL ? SCSI_IGNORE_NOT_READY : 0));
- if (error)
- goto bad;
-
- sc_link->flags |= SDEV_OPEN; /* unit attn are now errors */
-
- /*
- * If the mode is 3 (e.g. minor = 3,7,11,15)
- * then the device has been opened to set defaults
- * This mode does NOT ALLOW I/O, only ioctls
- */
- if (ssmode == MODE_CONTROL)
- return (0);
-
- SC_DEBUG(sc_link, SDEV_DB2, ("open complete\n"));
- return (0);
-
-bad:
- sc_link->flags &= ~SDEV_OPEN;
- return (error);
-}
-
-/*
- * close the device.. only called if we are the LAST
- * occurence of an open device
- */
-int
-ssclose(dev)
- dev_t dev;
-{
- struct ss_softc *ss = sscd.cd_devs[SSUNIT(dev)];
- int error;
-
- SC_DEBUG(ss->sc_link, SDEV_DB1, ("closing\n"));
-
- if (SSMODE(dev) == MODE_REWIND) {
- if (ss->special->rewind_scanner) {
- /* call special handler to rewind/abort scan */
- error = (ss->special->rewind_scanner)(ss);
- if (error)
- return (error);
- } else {
- /* XXX add code to restart a SCSI2 scanner, if any */
- }
- ss->sio.scan_window_size = 0;
- ss->flags &= ~SSF_TRIGGERED;
- }
- ss->sc_link->flags &= ~SDEV_OPEN;
-
- return (0);
-}
-
-/*
- * trim the size of the transfer if needed,
- * called by physio
- * basically the smaller of our min and the scsi driver's
- * minphys
- */
-void
-ssminphys(bp)
- struct buf *bp;
-{
- register struct ss_softc *ss = sscd.cd_devs[SSUNIT(bp->b_dev)];
-
- (ss->sc_link->adapter->scsi_minphys)(bp);
-
- /*
- * trim the transfer further for special devices this is
- * because some scanners only read multiples of a line at a
- * time, also some cannot disconnect, so the read must be
- * short enough to happen quickly
- */
- if (ss->special->minphys)
- (ss->special->minphys)(ss, bp);
-}
-
-/*
- * Do a read on a device for a user process.
- * Prime scanner at start of read, check uio values, call ssstrategy
- * via physio for the actual transfer.
- */
-int
-ssread(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- struct ss_softc *ss = sscd.cd_devs[SSUNIT(dev)];
- int error;
-
- /* if the scanner has not yet been started, do it now */
- if (!(ss->flags & SSF_TRIGGERED)) {
- if (ss->special->trigger_scanner) {
- error = (ss->special->trigger_scanner)(ss);
- if (error)
- return (error);
- }
- ss->flags |= SSF_TRIGGERED;
- }
-
- return (physio(ssstrategy, NULL, dev, B_READ, ssminphys, uio));
-}
-
-/*
- * Actually translate the requested transfer into one the physical
- * driver can understand The transfer is described by a buf and will
- * include only one physical transfer.
- */
-void
-ssstrategy(bp)
- struct buf *bp;
-{
- struct ss_softc *ss = sscd.cd_devs[SSUNIT(bp->b_dev)];
- struct buf *dp;
- int s;
-
- SC_DEBUG(ss->sc_link, SDEV_DB1,
- ("ssstrategy %d bytes @ blk %d\n", bp->b_bcount, bp->b_blkno));
-
- if (bp->b_bcount > ss->sio.scan_window_size)
- bp->b_bcount = ss->sio.scan_window_size;
-
- /*
- * If it's a null transfer, return immediatly
- */
- if (bp->b_bcount == 0)
- goto done;
-
- s = splbio();
-
- /*
- * Place it in the queue of activities for this scanner
- * at the end (a bit silly because we only have on user..
- * (but it could fork()))
- */
- dp = &ss->buf_queue;
- bp->b_actf = NULL;
- bp->b_actb = dp->b_actb;
- *dp->b_actb = bp;
- dp->b_actb = &bp->b_actf;
-
- /*
- * Tell the device to get going on the transfer if it's
- * not doing anything, otherwise just wait for completion
- * (All a bit silly if we're only allowing 1 open but..)
- */
- ssstart(ss);
-
- splx(s);
- return;
-bad:
- bp->b_flags |= B_ERROR;
-done:
- /*
- * Correctly set the buf to indicate a completed xfer
- */
- bp->b_resid = bp->b_bcount;
- biodone(bp);
-}
-
-/*
- * ssstart looks to see if there is a buf waiting for the device
- * and that the device is not already busy. If both are true,
- * It dequeues the buf and creates a scsi command to perform the
- * transfer required. The transfer request will call scsi_done
- * on completion, which will in turn call this routine again
- * so that the next queued transfer is performed.
- * The bufs are queued by the strategy routine (ssstrategy)
- *
- * This routine is also called after other non-queued requests
- * have been made of the scsi driver, to ensure that the queue
- * continues to be drained.
- * ssstart() is called at splbio
- */
-void
-ssstart(v)
- void *v;
-{
- struct ss_softc *ss = v;
- struct scsi_link *sc_link = ss->sc_link;
- register struct buf *bp, *dp;
-
- SC_DEBUG(sc_link, SDEV_DB2, ("ssstart "));
- /*
- * See if there is a buf to do and we are not already
- * doing one
- */
- while (sc_link->openings > 0) {
- /* if a special awaits, let it proceed first */
- if (sc_link->flags & SDEV_WAITING) {
- sc_link->flags &= ~SDEV_WAITING;
- wakeup((caddr_t)sc_link);
- return;
- }
-
- /*
- * See if there is a buf with work for us to do..
- */
- dp = &ss->buf_queue;
- if ((bp = dp->b_actf) == NULL)
- return;
- if ((dp = bp->b_actf) != NULL)
- dp->b_actb = bp->b_actb;
- else
- ss->buf_queue.b_actb = bp->b_actb;
- *bp->b_actb = dp;
-
- if (ss->special->read) {
- (ss->special->read)(ss, bp);
- } else {
- /* generic scsi2 scanner read */
- /* XXX add code for SCSI2 scanner read */
- }
- }
-}
-
-/*
- * Perform special action on behalf of the user;
- * knows about the internals of this device
- */
-int
-ssioctl(dev, cmd, addr, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
-{
- struct ss_softc *ss = sscd.cd_devs[SSUNIT(dev)];
- int error = 0;
- int unit;
- struct scan_io *sio;
-
- switch (cmd) {
- case SCIOCGET:
- if (ss->special->get_params) {
- /* call special handler */
- error = (ss->special->get_params)(ss);
- if (error)
- return (error);
- } else {
- /* XXX add code for SCSI2 scanner, if any */
- return (EOPNOTSUPP);
- }
- bcopy(&ss->sio, addr, sizeof(struct scan_io));
- break;
- case SCIOCSET:
- sio = (struct scan_io *)addr;
-
- if (ss->special->set_params) {
- /* call special handler */
- error = (ss->special->set_params)(ss, sio);
- if (error)
- return (error);
- } else {
- /* XXX add code for SCSI2 scanner, if any */
- return (EOPNOTSUPP);
- }
- break;
- case SCIOCRESTART:
- if (ss->special->rewind_scanner ) {
- /* call special handler */
- error = (ss->special->rewind_scanner)(ss);
- if (error)
- return (error);
- } else
- /* XXX add code for SCSI2 scanner, if any */
- return (EOPNOTSUPP);
- ss->flags &= ~SSF_TRIGGERED;
- break;
-#ifdef NOTYET
- case SCAN_USE_ADF:
- break;
-#endif
- default:
- if (SSMODE(dev) != MODE_CONTROL)
- return (ENOTTY);
- return (scsi_do_ioctl(ss->sc_link, dev, cmd, addr, flag, p));
- }
- return (error);
-}
diff --git a/sys/scsi/ss_mustek.c b/sys/scsi/ss_mustek.c
index 3fd7abfc862..369651bd4aa 100644
--- a/sys/scsi/ss_mustek.c
+++ b/sys/scsi/ss_mustek.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ss_mustek.c,v 1.3 1996/04/21 22:31:13 deraadt Exp $ */
+/* $OpenBSD: ss_mustek.c,v 1.4 1996/05/07 09:34:32 niklas Exp $ */
/* $NetBSD: ss_mustek.c,v 1.3 1996/03/30 21:47:04 christos Exp $ */
/*
@@ -600,626 +600,3 @@ mustek_compute_sizes(ss)
ss->sio.scan_window_size = ss->sio.scan_lines *
((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8);
}
-/* $NetBSD: ss_mustek.c,v 1.1 1996/02/18 20:32:47 mycroft Exp $ */
-
-/*
- * Copyright (c) 1995 Joachim Koenig-Baltes. 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 Joachim Koenig-Baltes.
- * 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.
- */
-
-/*
- * special driver for MUSTEK flatbed scanners MFS 06000CX and MFS 12000CX
- * these scanners come with their own scsi card, containing an NCR53C400
- * SCSI controller chip. I'm in the progress of writing a driver for this
- * card to work under NetBSD-current. I've hooked it up to a Seagate ST01
- * hostadapter in the meantime, giving 350KB/sec for higher resolutions!
- *
- * I tried to connect it to my Adaptec 1542B, but with no success. It seems,
- * it does not like synchronous negotiation between Hostadapter and other
- * targets, but I could not turn this off for the 1542B.
- *
- * There is also an other reason why you would not like to connect it to your
- * favourite SCSI host adapter: The Mustek DOES NOT DISCONNECT. It will block
- * other traffic from the bus while a transfer is active.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/fcntl.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-#include <sys/device.h>
-#include <sys/conf.h> /* for cdevsw */
-#include <sys/scanio.h>
-
-#include <scsi/scsi_all.h>
-#include <scsi/scsi_scanner.h>
-#include <scsi/scsiconf.h>
-#include <scsi/ssvar.h>
-#include <scsi/ss_mustek.h>
-
-#define MUSTEK_RETRIES 4
-
-int mustek_get_params __P((struct ss_softc *));
-int mustek_set_params __P((struct ss_softc *, struct scan_io *));
-int mustek_trigger_scanner __P((struct ss_softc *));
-void mustek_minphys __P((struct ss_softc *, struct buf *));
-int mustek_read __P((struct ss_softc *, struct buf *));
-int mustek_rewind_scanner __P((struct ss_softc *));
-
-/* only used internally */
-int mustek_get_status __P((struct ss_softc *, int, int));
-void mustek_compute_sizes __P((struct ss_softc *));
-
-/*
- * structure for the special handlers
- */
-struct ss_special mustek_special = {
- mustek_set_params,
- mustek_trigger_scanner,
- mustek_get_params,
- mustek_minphys,
- mustek_read,
- mustek_rewind_scanner,
- NULL, /* no adf support right now */
- NULL /* no adf support right now */
-};
-
-/*
- * mustek_attach: attach special functions to ss
- */
-void
-mustek_attach(ss, sa)
- struct ss_softc *ss;
- struct scsibus_attach_args *sa;
-{
- struct scsi_link *sc_link = sa->sa_sc_link;
-
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_attach: start\n"));
- ss->sio.scan_scanner_type = 0;
-
- /* first, check the model which determines resolutions */
- if (!bcmp(sa->sa_inqbuf->product, "MFS-06000CX", 11)) {
- ss->sio.scan_scanner_type = MUSTEK_06000CX;
- printf(": Mustek 6000CX Flatbed 3-pass color scanner, 3 - 600 dpi\n");
- }
- if (!bcmp(sa->sa_inqbuf->product, "MFS-12000CX", 11)) {
- ss->sio.scan_scanner_type = MUSTEK_12000CX;
- printf(": Mustek 12000CX Flatbed 3-pass color scanner, 6 - 1200 dpi\n");
- }
-
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_attach: scanner_type = %d\n",
- ss->sio.scan_scanner_type));
-
- /* install special handlers */
- ss->special = &mustek_special;
-
- /*
- * populate the scanio struct with legal values
- * the default should come from user space
- */
- ss->sio.scan_width = 1200;
- ss->sio.scan_height = 1200;
- ss->sio.scan_x_resolution = 99;
- ss->sio.scan_y_resolution = 99;
- ss->sio.scan_x_origin = 0;
- ss->sio.scan_y_origin = 0;
- ss->sio.scan_brightness = 100;
- ss->sio.scan_contrast = 100;
- ss->sio.scan_quality = 100;
- ss->sio.scan_image_mode = SIM_GRAYSCALE;
-
- mustek_compute_sizes(ss);
-}
-
-int
-mustek_get_params (ss)
- struct ss_softc *ss;
-{
-
- return (0);
-}
-
-/*
- * check the parameters if the mustek is capable of fulfilling it
- * but don't send the command to the scanner in case the user wants
- * to change parameters by more than one call
- */
-int
-mustek_set_params(ss, sio)
- struct ss_softc *ss;
- struct scan_io *sio;
-{
- int error;
-
- /*
- * if the scanner is triggered, then rewind it
- */
- if (ss->flags & SSF_TRIGGERED) {
- error = mustek_rewind_scanner(ss);
- if (error)
- return (error);
- }
-
- /* size constraints: 8.5" horizontally and 14" vertically */
-#ifdef MUSTEK_INCH_SPEC
- /* sizes must be a multiple of 1/8" */
- sio->scan_x_origin -= sio->scan_x_origin % 150;
- sio->scan_y_origin -= sio->scan_y_origin % 150;
- sio->scan_width -= sio->scan_width % 150;
- sio->scan_height -= sio->scan_height % 150;
-#endif
- if (sio->scan_width == 0 ||
- sio->scan_x_origin + sio->scan_width > 10200 ||
- sio->scan_height == 0 ||
- sio->scan_y_origin + sio->scan_height > 16800)
- return (EINVAL);
-
- /*
- * for now, only realize the values for the MUSTEK_06000CX
- * in the future, values for the MUSTEK_12000CX will be implemented
- */
-
- /*
- * resolution (dpi) must be <= 300 and a multiple of 3 or
- * between 300 and 600 and a multiple of 30
- */
- sio->scan_x_resolution -= sio->scan_x_resolution <= 300 ?
- sio->scan_x_resolution % 3 : sio->scan_x_resolution % 30;
- sio->scan_y_resolution -= sio->scan_y_resolution <= 300 ?
- sio->scan_y_resolution % 3 : sio->scan_y_resolution % 30;
- if (sio->scan_x_resolution < 3 || sio->scan_x_resolution > 600 ||
- sio->scan_x_resolution != sio->scan_y_resolution)
- return (EINVAL);
-
- /* assume brightness values are between 64 and 136 in steps of 3 */
- sio->scan_brightness -= (sio->scan_brightness - 64) % 3;
- if (sio->scan_brightness < 64 || sio->scan_brightness > 136)
- return (EINVAL);
-
- /* contrast values must be between 16 and 184 in steps of 7 */
- sio->scan_contrast -= (sio->scan_contrast - 16) % 7;
- if (sio->scan_contrast < 16 || sio->scan_contrast > 184)
- return (EINVAL);
-
- /*
- * velocity: between 0 (fast) and 4 (slow) which will be mapped
- * to 100% = 4, 80% = 3, 60% = 2, 40% = 1, 20% = 0
- * must be a multiple of 20
- */
- sio->scan_quality -= sio->scan_quality % 20;
- if (sio->scan_quality < 20 || sio->scan_quality > 100)
- return (EINVAL);
-
- switch (sio->scan_image_mode) {
- case SIM_BINARY_MONOCHROME:
- case SIM_DITHERED_MONOCHROME:
- case SIM_GRAYSCALE:
- case SIM_RED:
- case SIM_GREEN:
- case SIM_BLUE:
- break;
- default:
- return (EINVAL);
- }
-
- /* change ss_softc to the new values, but save ro-variables */
- sio->scan_scanner_type = ss->sio.scan_scanner_type;
- bcopy(sio, &ss->sio, sizeof(struct scan_io));
-
- mustek_compute_sizes(ss);
-
- return (0);
-}
-
-/*
- * trim the requested transfer to a multiple of the line size
- * this is called only from ssread() which guarantees, scanner is triggered
- * In the future, it will trim the transfer to not read to much at a time
- * because the mustek cannot disconnect. It will be calculated by the
- * resolution, the velocity and the number of bytes per line.
- */
-void
-mustek_minphys(ss, bp)
- struct ss_softc *ss;
- struct buf *bp;
-{
- struct scsi_link *sc_link = ss->sc_link;
-
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_minphys: before: %d\n",
- bp->b_bcount));
- bp->b_bcount -= bp->b_bcount %
- ((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8);
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_minphys: after: %d\n",
- bp->b_bcount));
-}
-
-/*
- * trigger the scanner to start a scan operation
- * this includes sending the mode- and window-data, starting the scanner
- * and getting the image size info
- */
-int
-mustek_trigger_scanner(ss)
- struct ss_softc *ss;
-{
- struct mustek_mode_select_cmd mode_cmd;
- struct mustek_mode_select_data mode_data;
- struct mustek_set_window_cmd window_cmd;
- struct mustek_set_window_data window_data;
- struct mustek_start_scan_cmd start_scan_cmd;
- struct scsi_link *sc_link = ss->sc_link;
-#ifndef MUSTEK_INCH_SPEC
- int pixel_tlx, pixel_tly, pixel_brx, pixel_bry, paperlength;
-#endif
- int error;
-
- mustek_compute_sizes(ss);
-
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_trigger_scanner\n"));
-
- /*
- * set the window params and send the scsi command
- */
- bzero(&window_cmd, sizeof(window_cmd));
- window_cmd.opcode = MUSTEK_SET_WINDOW;
- window_cmd.length = sizeof(window_data);
-
- bzero(&window_data, sizeof(window_data));
- window_data.frame_header = MUSTEK_LINEART_BACKGROUND | MUSTEK_UNIT_SPEC;
-#ifdef MUSTEK_INCH_SPEC
- /* the positional values are all 1 byte because 256 / 8 = 32" */
- window_data.frame_tl_x_0 = ss->sio.scan_x_origin / 150;
- window_data.frame_tl_x_1 = 0;
- window_data.frame_tl_y_0 = ss->sio.scan_y_origin / 150;
- window_data.frame_tl_y_1 = 0;
- window_data.frame_br_x_0 = (ss->sio.scan_x_origin +
- ss->sio.scan_width) / 150;
- window_data.frame_br_x_1 = 0;
- window_data.frame_br_y_0 = (ss->sio.scan_y_origin +
- ss->sio.scan_height) / 150;
- window_data.frame_br_y_1 = 0;
-#else
- pixel_tlx = (ss->sio.scan_x_origin * ss->sio.scan_x_resolution) / 1200;
- window_data.frame_tl_x_0 = pixel_tlx & 0xff;
- window_data.frame_tl_x_1 = (pixel_tlx >> 8) & 0xff;
- pixel_tly = (ss->sio.scan_y_origin * ss->sio.scan_y_resolution) / 1200;
- window_data.frame_tl_y_0 = pixel_tly & 0xff;
- window_data.frame_tl_y_1 = (pixel_tly >> 8) & 0xff;
- pixel_brx = pixel_tlx +
- (ss->sio.scan_width * ss->sio.scan_x_resolution) / 1200;
- window_data.frame_br_x_0 = pixel_brx & 0xff;
- window_data.frame_br_x_1 = (pixel_brx >> 8) & 0xff;
- pixel_bry = pixel_tly +
- (ss->sio.scan_height * ss->sio.scan_y_resolution) / 1200;
- window_data.frame_br_y_0 = pixel_bry & 0xff;
- window_data.frame_br_y_1 = (pixel_bry >> 8) & 0xff;
-#endif
-
-#if MUSTEK_WINDOWS >= 1
- window_data.window1_header = MUSTEK_WINDOW_MASK | MUSTEK_UNIT_SPEC;
- window_data.window1_tl_x_0 = window_data.frame_tl_x_0;
- window_data.window1_tl_x_1 = window_data.frame_tl_x_1;
- window_data.window1_tl_y_0 = window_data.frame_tl_y_0;
- window_data.window1_tl_y_1 = window_data.frame_tl_y_1;
- window_data.window1_br_x_0 = window_data.frame_br_x_0;
- window_data.window1_br_x_1 = window_data.frame_br_x_1;
- window_data.window1_br_y_0 = window_data.frame_br_y_0;
- window_data.window1_br_y_1 = window_data.frame_br_y_1;
-#endif
-
- /* send the set window command to the scanner */
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_set_parms: set_window\n"));
- error = scsi_scsi_cmd(sc_link, (struct scsi_generic *) &window_cmd,
- sizeof(window_cmd), (u_char *) &window_data, sizeof(window_data),
- MUSTEK_RETRIES, 5000, NULL, SCSI_DATA_OUT);
- if (error)
- return (error);
-
- /*
- * do what it takes to actualize the mode
- */
- bzero(&mode_cmd, sizeof(mode_cmd));
- mode_cmd.opcode = MUSTEK_MODE_SELECT;
- mode_cmd.length_0 = sizeof(mode_data);
-
- bzero(&mode_data, sizeof(mode_data));
- mode_data.mode =
- MUSTEK_MODE_MASK | MUSTEK_HT_PATTERN_BUILTIN | MUSTEK_UNIT_SPEC;
- if (ss->sio.scan_x_resolution <= 300) {
- mode_data.resolution = ss->sio.scan_x_resolution / 3;
- } else {
- /*
- * the resolution values is computed by modulo 100, but not
- * for 600dpi, where the value is 100 (a bit tricky, but ...)
- */
- mode_data.resolution =
- ((ss->sio.scan_x_resolution - 1) % 100) + 1;
- }
- mode_data.brightness = (ss->sio.scan_brightness - 64) / 3;
- mode_data.contrast = (ss->sio.scan_contrast - 16) / 7;
- mode_data.grain = 0;
- mode_data.velocity = ss->sio.scan_quality / 20 - 1;
-#ifdef MUSTEK_INCH_SPEC
- mode_data.paperlength_0 = 14 * 8; /* 14" */
- mode_data.paperlength_1 = 0;
-#else
- paperlength = 14 * ss->sio.scan_y_resolution; /* 14" */
- mode_data.paperlength_0 = paperlength & 0xff;
- mode_data.paperlength_1 = (paperlength >> 8) & 0xff;
-#endif
-
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_trigger_scanner: mode_select\n"));
- /* send the command to the scanner */
- error = scsi_scsi_cmd(sc_link, (struct scsi_generic *) &mode_cmd,
- sizeof(mode_cmd), (u_char *) &mode_data, sizeof(mode_data),
- MUSTEK_RETRIES, 5000, NULL, SCSI_DATA_OUT);
- if (error)
- return (error);
-
- /*
- * now construct and send the start command
- */
- bzero(&start_scan_cmd,sizeof(start_scan_cmd));
- start_scan_cmd.opcode = MUSTEK_START_STOP;
- start_scan_cmd.mode = MUSTEK_SCAN_START;
- if (ss->sio.scan_x_resolution <= 300)
- start_scan_cmd.mode |= MUSTEK_RES_STEP_1;
- else
- start_scan_cmd.mode |= MUSTEK_RES_STEP_10;
- switch (ss->sio.scan_image_mode) {
- case SIM_BINARY_MONOCHROME:
- case SIM_DITHERED_MONOCHROME:
- start_scan_cmd.mode |= MUSTEK_BIT_MODE | MUSTEK_GRAY_FILTER;
- break;
- case SIM_GRAYSCALE:
- start_scan_cmd.mode |= MUSTEK_GRAY_MODE | MUSTEK_GRAY_FILTER;
- break;
- case SIM_RED:
- start_scan_cmd.mode |= MUSTEK_GRAY_MODE | MUSTEK_RED_FILTER;
- break;
- case SIM_GREEN:
- start_scan_cmd.mode |= MUSTEK_GRAY_MODE | MUSTEK_GREEN_FILTER;
- break;
- case SIM_BLUE:
- start_scan_cmd.mode |= MUSTEK_GRAY_MODE | MUSTEK_BLUE_FILTER;
- break;
- }
-
- /* send the command to the scanner */
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_trigger_scanner: start_scan\n"));
- error = scsi_scsi_cmd(sc_link, (struct scsi_generic *) &start_scan_cmd,
- sizeof(start_scan_cmd), NULL, 0,
- MUSTEK_RETRIES, 5000, NULL, 0);
- if (error)
- return (error);
-
- /*
- * now check if scanner ready this time with update of size info
- * we wait here so that if the user issues a read directly afterwards,
- * the scanner will respond directly (otherwise we had to sleep with
- * a buffer locked in memory)
- */
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_trigger_scanner: get_status\n"));
- error = mustek_get_status(ss, 60, 1);
- if (error)
- return (error);
-
- return (0);
-}
-
-/*
- * stop a scan operation in progress
- */
-int
-mustek_rewind_scanner(ss)
- struct ss_softc *ss;
-{
- struct mustek_start_scan_cmd cmd;
- struct scsi_link *sc_link = ss->sc_link;
- int error;
-
- if (ss->sio.scan_window_size != 0) {
- /*
- * only if not all data has been read, the scanner has to be
- * stopped
- */
- bzero(&cmd, sizeof(cmd));
- cmd.opcode = MUSTEK_START_STOP;
- cmd.mode = MUSTEK_SCAN_STOP;
-
- /* send the command to the scanner */
- SC_DEBUG(sc_link, SDEV_DB1,
- ("mustek_rewind_scanner: stop_scan\n"));
- error = scsi_scsi_cmd(sc_link, (struct scsi_generic *) &cmd,
- sizeof(cmd), NULL, 0, MUSTEK_RETRIES, 5000, NULL, 0);
- if (error)
- return (error);
- }
-
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_rewind_scanner: end\n"));
-
- return (0);
-}
-
-/*
- * read the requested number of bytes/lines from the scanner
- */
-int
-mustek_read(ss, bp)
- struct ss_softc *ss;
- struct buf *bp;
-{
- struct mustek_read_cmd cmd;
- struct scsi_link *sc_link = ss->sc_link;
- u_long lines_to_read;
-
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_read: start\n"));
-
- bzero(&cmd, sizeof(cmd));
- cmd.opcode = MUSTEK_READ;
-
- /* instead of the bytes, the mustek wants the number of lines */
- lines_to_read = bp->b_bcount /
- ((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8);
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_read: read %d lines\n",
- lines_to_read));
- cmd.length_0 = lines_to_read & 0xff;
- cmd.length_1 = (lines_to_read >> 8) & 0xff;
- cmd.length_2 = (lines_to_read >> 16) & 0xff;
-
- /*
- * go ask the adapter to do all this for us
- */
- if (scsi_scsi_cmd(sc_link, (struct scsi_generic *) &cmd, sizeof(cmd),
- (u_char *) bp->b_data, bp->b_bcount, MUSTEK_RETRIES, 10000, bp,
- SCSI_NOSLEEP | SCSI_DATA_IN) != SUCCESSFULLY_QUEUED)
- printf("%s: not queued\n", ss->sc_dev.dv_xname);
- else {
- ss->sio.scan_lines -= lines_to_read;
- ss->sio.scan_window_size -= bp->b_bcount;
- }
-
- return (0);
-}
-
-/*
- * check if the scanner is ready to take commands
- * wait timeout seconds and try only every second
- * if update, then update picture size info
- *
- * returns EBUSY if scanner not ready
- */
-int
-mustek_get_status(ss, timeout, update)
- struct ss_softc *ss;
- int timeout, update;
-{
- struct mustek_get_status_cmd cmd;
- struct mustek_get_status_data data;
- struct scsi_link *sc_link = ss->sc_link;
- int error, lines, bytes_per_line;
-
- bzero(&cmd, sizeof(cmd));
- cmd.opcode = MUSTEK_GET_STATUS;
- cmd.length = sizeof(data);
-
- while (1) {
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_get_status: stat_cmd\n"));
- error = scsi_scsi_cmd(sc_link, (struct scsi_generic *) &cmd,
- sizeof(cmd), (u_char *) &data, sizeof(data), MUSTEK_RETRIES,
- 5000, NULL, SCSI_DATA_IN);
- if (error)
- return (error);
- if ((data.ready_busy == MUSTEK_READY) ||
- (timeout-- <= 0))
- break;
- /* please wait a second */
- tsleep((caddr_t)mustek_get_status, PRIBIO + 1, "mtkrdy", hz);
- }
-
- if (update) {
- bytes_per_line =
- (data.bytes_per_line_1 << 8) |
- data.bytes_per_line_0;
- lines =
- (data.lines_2 << 16) |
- (data.lines_1 << 8) |
- data.lines_0;
- if (lines != ss->sio.scan_lines) {
- printf("mustek: lines actual(%d) != computed(%d)\n",
- lines, ss->sio.scan_lines);
- return (EIO);
- }
- if (bytes_per_line * lines != ss->sio.scan_window_size) {
- printf("mustek: win-size actual(%d) != computed(%d)\n",
- bytes_per_line * lines, ss->sio.scan_window_size);
- return (EIO);
- }
-
- SC_DEBUG(sc_link, SDEV_DB1,
- ("mustek_get_size: bpl=%d, lines=%d\n",
- (ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8,
- ss->sio.scan_lines));
- SC_DEBUG(sc_link, SDEV_DB1, ("window size = %d\n",
- ss->sio.scan_window_size));
- }
-
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_get_status: end\n"));
- if (data.ready_busy == MUSTEK_READY)
- return (0);
- else
- return (EBUSY);
-}
-
-/*
- * mustek_compute_sizes: compute window_size and lines for the picture
- * this function is called from different places in the code
- */
-void
-mustek_compute_sizes(ss)
- struct ss_softc *ss;
-{
-
- switch (ss->sio.scan_image_mode) {
- case SIM_BINARY_MONOCHROME:
- case SIM_DITHERED_MONOCHROME:
- ss->sio.scan_bits_per_pixel = 1;
- break;
- case SIM_GRAYSCALE:
- case SIM_RED:
- case SIM_GREEN:
- case SIM_BLUE:
- ss->sio.scan_bits_per_pixel = 8;
- break;
- }
-
- /*
- * horizontal number of bytes is always a multiple of 2,
- * in 8-bit mode at least
- */
- ss->sio.scan_pixels_per_line =
- (ss->sio.scan_width * ss->sio.scan_x_resolution) / 1200;
- if (ss->sio.scan_bits_per_pixel == 1)
- /* make it a multiple of 16, and thus of 2 bytes */
- ss->sio.scan_pixels_per_line =
- (ss->sio.scan_pixels_per_line + 15) & 0xfffffff0;
- else
- ss->sio.scan_pixels_per_line =
- (ss->sio.scan_pixels_per_line + 1) & 0xfffffffe;
-
- ss->sio.scan_lines =
- (ss->sio.scan_height * ss->sio.scan_y_resolution) / 1200;
- ss->sio.scan_window_size = ss->sio.scan_lines *
- ((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8);
-}
diff --git a/sys/scsi/ss_mustek.h b/sys/scsi/ss_mustek.h
index 5ea70e95d86..ff5dcc7b40a 100644
--- a/sys/scsi/ss_mustek.h
+++ b/sys/scsi/ss_mustek.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ss_mustek.h,v 1.3 1996/04/21 22:31:15 deraadt Exp $ */
+/* $OpenBSD: ss_mustek.h,v 1.4 1996/05/07 09:34:33 niklas Exp $ */
/* $NetBSD: ss_mustek.h,v 1.2 1996/03/19 03:08:37 mycroft Exp $ */
/*
@@ -178,221 +178,3 @@ struct mustek_start_scan_cmd {
};
#endif /* _SS_MUSTEK_H_ */
-/* $NetBSD: ss_mustek.h,v 1.1 1996/02/18 20:32:48 mycroft Exp $ */
-
-/*
- * Copyright (c) 1995 Joachim Koenig-Baltes. 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 Joachim Koenig-Baltes.
- * 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.
- */
-
-#ifndef _SS_MUSTEK_H_
-#define _SS_MUSTEK_H_ 1
-
-/*
- * support for MUSTEK flatbed SCSI scanners MFS-06000CX and MFS-12000CX
- * (600 and 1200 dpi horizontally resp), not conforming to the SCSI2 spec.
- */
-
-/*
- * Configuration section: describes the mode in which scanner is driven
- * MUSTEK_INCH_SPEC: frame/window sizes are given in inches instead of
- * pixels, note: unit is 1/8th of an inch
- * MUSTEK_WINDOWS: number of windows in a frame, up to 4 allowed,
- * not used yet, so set to 0
- */
-#define MUSTEK_INCH_SPEC /* use inches to specify sizes */
-#define MUSTEK_WINDOWS 0 /* no window support yet */
-
-/* mustek scsi commands */
-#define MUSTEK_SET_WINDOW 0x04 /* set image area and windows */
-#define MUSTEK_READ 0x08 /* read command */
-#define MUSTEK_GET_STATUS 0x0f /* image status */
-#define MUSTEK_MODE_SELECT 0x15 /* set resolution, paper length, .. */
-#define MUSTEK_ADF 0x10 /* ADF and backtracking selection */
-#define MUSTEK_START_STOP 0x1b /* start/stop scan */
-#define MUSTEK_LUT 0x55 /* look up table download */
-
-/* the size spec is at the same bit position in different commands */
-#define MUSTEK_UNIT_INCHES 0x00
-#define MUSTEK_UNIT_PIXELS 0x08
-#ifdef MUSTEK_INCH_SPEC
-#define MUSTEK_UNIT_SPEC MUSTEK_UNIT_INCHES
-#else
-#define MUSTEK_UNIT_SPEC MUSTEK_UNIT_PIXELS
-#endif
-
-/*
- * SCSI command formats
- */
-
-struct mustek_set_window_cmd {
- u_char opcode; /* 0x04 */
- u_char reserved[3];
- u_char length; /* in bytes */
- u_char control;
-};
-
-struct mustek_set_window_data {
-#define MUSTEK_LINEART_BACKGROUND 0x00
-#define MUSTEK_HALFTONE_BACKGROUND 0x01
- u_char frame_header; /* unit-defines also apply */
- u_char frame_tl_x_0;
- u_char frame_tl_x_1;
- u_char frame_tl_y_0;
- u_char frame_tl_y_1;
- u_char frame_br_x_0;
- u_char frame_br_x_1;
- u_char frame_br_y_0;
- u_char frame_br_y_1;
-#if MUSTEK_WINDOWS >= 1
-#define MUSTEK_WINDOW_MASK 0x80
- u_char window1_header; /* unit-defines also apply */
- u_char window1_tl_x_0;
- u_char window1_tl_x_1;
- u_char window1_tl_y_0;
- u_char window1_tl_y_1;
- u_char window1_br_x_0;
- u_char window1_br_x_1;
- u_char window1_br_y_0;
- u_char window1_br_y_1;
-#endif
-#if MUSTEK_WINDOWS >= 2
- u_char window2_header;
- u_char window2_tl_x_0;
- u_char window2_tl_x_1;
- u_char window2_tl_y_0;
- u_char window2_tl_y_1;
- u_char window2_br_x_0;
- u_char window2_br_x_1;
- u_char window2_br_y_0;
- u_char window2_br_y_1;
-#endif
-#if MUSTEK_WINDOWS >= 3
- u_char window3_header;
- u_char window3_tl_x_0;
- u_char window3_tl_x_1;
- u_char window3_tl_y_0;
- u_char window3_tl_y_1;
- u_char window3_br_x_0;
- u_char window3_br_x_1;
- u_char window3_br_y_0;
- u_char window3_br_y_1;
-#endif
-#if MUSTEK_WINDOWS == 4
- u_char window4_header;
- u_char window4_tl_x_0;
- u_char window4_tl_x_1;
- u_char window4_tl_y_0;
- u_char window4_tl_y_1;
- u_char window4_br_x_0;
- u_char window4_br_x_1;
- u_char window4_br_y_0;
- u_char window4_br_y_1;
-#endif
-};
-
-struct mustek_read_cmd {
- u_char opcode; /* 0x08 */
- u_char reserved;
- u_char length_2; /* number of LINES to be read (MSB) */
- u_char length_1; /* number of LINES to be read */
- u_char length_0; /* number of LINES to be read (LSB) */
- u_char control;
-};
-
-struct mustek_get_status_cmd {
- u_char opcode; /* 0x0f */
- u_char reserved[3];
- u_char length; /* 0x06 */
- u_char control;
-};
-
-struct mustek_get_status_data {
-#define MUSTEK_READY 0
-#define MUSTEK_BUSY -1
- u_char ready_busy; /* 0 = ready */
- u_char bytes_per_line_0; /* LSB */
- u_char bytes_per_line_1; /* MSB */
- u_char lines_0; /* LSB */
- u_char lines_1;
- u_char lines_2; /* MSB */
-};
-
-struct mustek_mode_select_cmd {
- u_char opcode; /* 0x15 */
- u_char reserved[2];
- u_char length_1; /* MSB */
- u_char length_0; /* LSB */
- u_char control;
-};
-
-/*
- * resolution settings:
- * MFS06000CX:
- * 1% : 0x01 0x02 ... 0x64
- * 3 6 ... 300 dpi
- * 10%: 0x1e 0x3c 0x5a 0x14 0x32 0x50 0x0a 0x28 0x46 0x64
- * 330 360 390 420 450 480 510 540 570 600 dpi
- * MFS12000CX:
- * 1% : 0x01 0x02 ... 0x64
- * 6 12 ... 600 dpi
- * 10%: 0x1e 0x3c 0x5a 0x14 0x32 0x50 0x0a 0x28 0x46 0x64
- * 660 720 780 840 900 960 1020 1080 1140 1200 dpi
- */
-struct mustek_mode_select_data {
-#define MUSTEK_MODE_MASK 0x83
-#define MUSTEK_HT_PATTERN_BUILTIN 0x00
-#define MUSTEK_HT_PATTERN_DOWNLOADED 0x10
- u_char mode;
- u_char resolution;
- u_char brightness;
- u_char contrast;
- u_char grain; /* 0 = 8x8, ..... 5 = 2x2 */
- u_char velocity; /* 0 = fast, ...., 4 = slow */
- u_char reserved[2];
- u_char paperlength_0; /* LSB */
- u_char paperlength_1; /* MSB */
-};
-
-struct mustek_start_scan_cmd {
- u_char opcode; /* 0x1b */
- u_char reserved[3];
-#define MUSTEK_SCAN_STOP 0x00
-#define MUSTEK_SCAN_START 0x01
-#define MUSTEK_GRAY_FILTER 0x00
-#define MUSTEK_RED_FILTER 0x08
-#define MUSTEK_GREEN_FILTER 0x10
-#define MUSTEK_BLUE_FILTER 0x18
-#define MUSTEK_GRAY_MODE 0x40
-#define MUSTEK_BIT_MODE 0x00
-#define MUSTEK_RES_STEP_1 0x00
-#define MUSTEK_RES_STEP_10 0x80
- u_char mode;
- u_char control;
-};
-
-#endif /* _SS_MUSTEK_H_ */
diff --git a/sys/scsi/ss_scanjet.c b/sys/scsi/ss_scanjet.c
index 6c1bb689e55..164f94271e9 100644
--- a/sys/scsi/ss_scanjet.c
+++ b/sys/scsi/ss_scanjet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ss_scanjet.c,v 1.3 1996/04/21 22:31:17 deraadt Exp $ */
+/* $OpenBSD: ss_scanjet.c,v 1.4 1996/05/07 09:34:34 niklas Exp $ */
/* $NetBSD: ss_scanjet.c,v 1.3 1996/03/30 21:47:07 christos Exp $ */
/*
@@ -418,413 +418,3 @@ scanjet_compute_sizes(ss)
ss->sio.scan_window_size = ss->sio.scan_lines *
((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8);
}
-/* $NetBSD: ss_scanjet.c,v 1.1 1996/02/18 20:32:49 mycroft Exp $ */
-
-/*
- * Copyright (c) 1995 Kenneth Stailey. 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 Kenneth Stailey.
- * 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.
- */
-
-/*
- * special functions for the HP ScanJet IIc and IIcx
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/fcntl.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-#include <sys/device.h>
-#include <sys/conf.h> /* for cdevsw */
-#include <sys/scanio.h>
-
-#include <scsi/scsi_all.h>
-#include <scsi/scsi_scanner.h>
-#include <scsi/scsiconf.h>
-#include <scsi/ssvar.h>
-
-#define SCANJET_RETRIES 4
-
-int scanjet_get_params __P((struct ss_softc *));
-int scanjet_set_params __P((struct ss_softc *, struct scan_io *));
-int scanjet_trigger_scanner __P((struct ss_softc *));
-int scanjet_read __P((struct ss_softc *, struct buf *));
-
-/* only used internally */
-int scanjet_write __P((struct ss_softc *ss, char *buf, u_int size, int flags));
-int scanjet_set_window __P((struct ss_softc *ss));
-void scanjet_compute_sizes __P((struct ss_softc *));
-
-/*
- * structure for the special handlers
- */
-struct ss_special scanjet_special = {
- scanjet_set_params,
- scanjet_trigger_scanner,
- scanjet_get_params,
- NULL, /* no special minphys */
- scanjet_read, /* scsi 6-byte read */
- NULL, /* no "rewind" code (yet?) */
- NULL, /* no adf support right now */
- NULL /* no adf support right now */
-};
-
-/*
- * scanjet_attach: attach special functions to ss
- */
-void
-scanjet_attach(ss, sa)
- struct ss_softc *ss;
- struct scsibus_attach_args *sa;
-{
- struct scsi_link *sc_link = sa->sa_sc_link;
-
- SC_DEBUG(sc_link, SDEV_DB1, ("scanjet_attach: start\n"));
- ss->sio.scan_scanner_type = 0;
-
- /* first, check the model (which determines nothing yet) */
-
- if (!bcmp(sa->sa_inqbuf->product, "C1750A", 6)) {
- ss->sio.scan_scanner_type = HP_SCANJET_IIC;
- printf(": HP ScanJet IIc\n");
- }
- if (!bcmp(sa->sa_inqbuf->product, "C2500A", 6)) {
- ss->sio.scan_scanner_type = HP_SCANJET_IIC;
- printf(": HP ScanJet IIcx\n");
- }
-
- SC_DEBUG(sc_link, SDEV_DB1, ("mustek_attach: scanner_type = %d\n",
- ss->sio.scan_scanner_type));
-
- /* now install special handlers */
- ss->special = &scanjet_special;
-
- /*
- * populate the scanio struct with legal values
- */
- ss->sio.scan_width = 1200;
- ss->sio.scan_height = 1200;
- ss->sio.scan_x_resolution = 100;
- ss->sio.scan_y_resolution = 100;
- ss->sio.scan_x_origin = 0;
- ss->sio.scan_y_origin = 0;
- ss->sio.scan_brightness = 100;
- ss->sio.scan_contrast = 100;
- ss->sio.scan_quality = 100;
- ss->sio.scan_image_mode = SIM_GRAYSCALE;
-
- scanjet_compute_sizes(ss);
-}
-
-int
-scanjet_get_params(ss)
- struct ss_softc *ss;
-{
-
- return (0);
-}
-
-/*
- * check the parameters if the scanjet is capable of fulfilling it
- * but don't send the command to the scanner in case the user wants
- * to change parameters by more than one call
- */
-int
-scanjet_set_params(ss, sio)
- struct ss_softc *ss;
- struct scan_io *sio;
-{
- int error;
-
-#if 0
- /*
- * if the scanner is triggered, then rewind it
- */
- if (ss->flags & SSF_TRIGGERED) {
- error = scanjet_rewind_scanner(ss);
- if (error)
- return (error);
- }
-#endif
-
- /* size constraints... */
- if (sio->scan_width == 0 ||
- sio->scan_x_origin + sio->scan_width > 10200 || /* 8.5" */
- sio->scan_height == 0 ||
- sio->scan_y_origin + sio->scan_height > 16800) /* 14" */
- return (EINVAL);
-
- /* resolution (dpi)... */
- if (sio->scan_x_resolution < 100 ||
- sio->scan_x_resolution > 400 ||
- sio->scan_y_resolution < 100 ||
- sio->scan_y_resolution > 400)
- return (EINVAL);
-
- switch (sio->scan_image_mode) {
- case SIM_BINARY_MONOCHROME:
- case SIM_DITHERED_MONOCHROME:
- case SIM_GRAYSCALE:
- case SIM_COLOR:
- break;
- default:
- return (EINVAL);
- }
-
- /* change ss_softc to the new values, but save ro-variables */
- sio->scan_scanner_type = ss->sio.scan_scanner_type;
- bcopy(sio, &ss->sio, sizeof(struct scan_io));
-
- scanjet_compute_sizes(ss);
-
- return (0);
-}
-
-/*
- * trigger the scanner to start a scan operation
- * this includes sending the mode- and window-data,
- * and starting the scanner
- */
-int
-scanjet_trigger_scanner(ss)
- struct ss_softc *ss;
-{
- char escape_codes[20];
- struct scsi_link *sc_link = ss->sc_link;
- int error;
-
- scanjet_compute_sizes(ss);
-
- /* send parameters */
- error = scanjet_set_window(ss);
- if (error) {
- uprintf("set window failed\n");
- return (error);
- }
-
- /* send "trigger" operation */
- strcpy(escape_codes, "\033*f0S");
- error = scanjet_write(ss, escape_codes, strlen(escape_codes), 0);
- if (error) {
- uprintf("trigger failed\n");
- return (error);
- }
-
- return (0);
-}
-
-int
-scanjet_read(ss, bp)
- struct ss_softc *ss;
- struct buf *bp;
-{
- struct scsi_rw_scanner cmd;
- struct scsi_link *sc_link = ss->sc_link;
-
- /*
- * Fill out the scsi command
- */
- bzero(&cmd, sizeof(cmd));
- cmd.opcode = READ;
-
- /*
- * Handle "fixed-block-mode" tape drives by using the
- * block count instead of the length.
- */
- lto3b(bp->b_bcount, cmd.len);
-
- /*
- * go ask the adapter to do all this for us
- */
- if (scsi_scsi_cmd(sc_link, (struct scsi_generic *) &cmd, sizeof(cmd),
- (u_char *) bp->b_data, bp->b_bcount, SCANJET_RETRIES, 100000, bp,
- SCSI_NOSLEEP | SCSI_DATA_IN) != SUCCESSFULLY_QUEUED)
- printf("%s: not queued\n", ss->sc_dev.dv_xname);
- else {
- ss->sio.scan_window_size -= bp->b_bcount;
- if (ss->sio.scan_window_size < 0)
- ss->sio.scan_window_size = 0;
- }
-
- return (0);
-}
-
-
-/*
- * Do a synchronous write. Used to send control messages.
- */
-int
-scanjet_write(ss, buf, size, flags)
- struct ss_softc *ss;
- char *buf;
- u_int size;
- int flags;
-{
- struct scsi_rw_scanner cmd;
-
- /*
- * If it's a null transfer, return immediatly
- */
- if (size == 0)
- return (0);
- bzero(&cmd, sizeof(cmd));
- cmd.opcode = WRITE;
- lto3b(size, cmd.len);
- return (scsi_scsi_cmd(ss->sc_link, (struct scsi_generic *) &cmd,
- sizeof(cmd), (u_char *) buf, size, 0, 100000, NULL,
- flags | SCSI_DATA_OUT));
-}
-
-#ifdef SCANJETDEBUG
-static void show_es(char *es)
-{
- char *p = es;
- while (*p) {
- if (*p == '\033')
- printf("[Esc]");
- else
- printf("%c", *p);
- ++p;
- }
- printf("\n");
-}
-#endif
-
-/*
- * simulate SCSI_SET_WINDOW for ScanJets
- */
-int
-scanjet_set_window(ss)
- struct ss_softc *ss;
-{
- char escape_codes[128], *p;
-
- p = escape_codes;
-
- sprintf(p, "\033*f%dP", ss->sio.scan_width / 4);
- p += strlen(p);
- sprintf(p, "\033*f%dQ", ss->sio.scan_height / 4);
- p += strlen(p);
- sprintf(p, "\033*f%dX", ss->sio.scan_x_origin / 4);
- p += strlen(p);
- sprintf(p, "\033*f%dY", ss->sio.scan_y_origin / 4);
- p += strlen(p);
- sprintf(p, "\033*a%dR", ss->sio.scan_x_resolution);
- p += strlen(p);
- sprintf(p, "\033*a%dS", ss->sio.scan_y_resolution);
- p += strlen(p);
-
- switch (ss->sio.scan_image_mode) {
- case SIM_BINARY_MONOCHROME:
- /* use "line art" mode */
- strcpy(p, "\033*a0T");
- p += strlen(p);
- /* make image data be "min-is-white ala PBM */
- strcpy(p, "\033*a0I");
- p += strlen(p);
- break;
- case SIM_DITHERED_MONOCHROME:
- /* use dithered mode */
- strcpy(p, "\033*a3T");
- p += strlen(p);
- /* make image data be "min-is-white ala PBM */
- strcpy(p, "\033*a0I");
- p += strlen(p);
- break;
- case SIM_GRAYSCALE:
- /* use grayscale mode */
- strcpy(p, "\033*a4T");
- p += strlen(p);
- /* make image data be "min-is-black ala PGM */
- strcpy(p, "\033*a1I");
- p += strlen(p);
- break;
- case SIM_COLOR:
- /* use RGB color mode */
- strcpy(p, "\033*a5T");
- p += strlen(p);
- /* make image data be "min-is-black ala PPM */
- strcpy(p, "\033*a1I");
- p += strlen(p);
- /* use pass-through matrix (disable NTSC) */
- strcpy(p, "\033*u2T");
- p += strlen(p);
- }
-
- sprintf(p, "\033*a%dG", ss->sio.scan_bits_per_pixel);
- p += strlen(p);
- sprintf(p, "\033*a%dL", (int)(ss->sio.scan_brightness) - 128);
- p += strlen(p);
- sprintf(p, "\033*a%dK", (int)(ss->sio.scan_contrast) - 128);
- p += strlen(p);
-
- return (scanjet_write(ss, escape_codes, p - escape_codes, 0));
-}
-
-void
-scanjet_compute_sizes(ss)
- struct ss_softc *ss;
-{
-
- /*
- * Deal with the fact that the HP ScanJet IIc uses 1/300" not 1/1200"
- * as its base unit of measurement. PINT uses 1/1200" (yes I know
- * ScanJet II's use decipoints as well but 1200 % 720 != 0)
- */
- ss->sio.scan_width = (ss->sio.scan_width + 3) & 0xfffffffc;
- ss->sio.scan_height = (ss->sio.scan_height + 3) & 0xfffffffc;
-
- switch (ss->sio.scan_image_mode) {
- case SIM_BINARY_MONOCHROME:
- case SIM_DITHERED_MONOCHROME:
- ss->sio.scan_bits_per_pixel = 1;
- break;
- case SIM_GRAYSCALE:
- ss->sio.scan_bits_per_pixel = 8;
- break;
- case SIM_COLOR:
- ss->sio.scan_bits_per_pixel = 24;
- break;
- }
-
- ss->sio.scan_pixels_per_line =
- (ss->sio.scan_width * ss->sio.scan_x_resolution) / 1200;
- if (ss->sio.scan_bits_per_pixel == 1)
- /* pad to byte boundary: */
- ss->sio.scan_pixels_per_line =
- (ss->sio.scan_pixels_per_line + 7) & 0xfffffff8;
-
- ss->sio.scan_lines =
- (ss->sio.scan_height * ss->sio.scan_y_resolution) / 1200;
- ss->sio.scan_window_size = ss->sio.scan_lines *
- ((ss->sio.scan_pixels_per_line * ss->sio.scan_bits_per_pixel) / 8);
-}
diff --git a/sys/scsi/ssvar.h b/sys/scsi/ssvar.h
index 166c9d3770f..55ea6b42f77 100644
--- a/sys/scsi/ssvar.h
+++ b/sys/scsi/ssvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssvar.h,v 1.3 1996/04/21 22:31:18 deraadt Exp $ */
+/* $OpenBSD: ssvar.h,v 1.4 1996/05/07 09:34:35 niklas Exp $ */
/* $NetBSD: ssvar.h,v 1.2 1996/03/30 21:47:11 christos Exp $ */
/*
@@ -82,82 +82,3 @@ struct ss_softc {
*/
void mustek_attach __P((struct ss_softc *, struct scsibus_attach_args *));
void scanjet_attach __P((struct ss_softc *, struct scsibus_attach_args *));
-/* $NetBSD: ssvar.h,v 1.1 1996/02/18 20:32:50 mycroft Exp $ */
-
-/*
- * Copyright (c) 1995 Kenneth Stailey. All rights reserved.
- * modified for configurable scanner support by Joachim Koenig
- *
- * 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 Kenneth Stailey.
- * 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.
- */
-
-/*
- * SCSI scanner interface description
- */
-
-/*
- * Special handlers for impractically different scanner types.
- * Register NULL for a function if you want to try the real SCSI code
- * (with quirks table)
- */
-struct ss_special {
- int (*set_params)();
- int (*trigger_scanner)();
- int (*get_params)();
- void (*minphys)(); /* some scanners only send line-multiples */
- int (*read)();
- int (*rewind_scanner)();
- int (*load_adf)();
- int (*unload_adf)();
-};
-
-/*
- * ss_softc has to be declared here, because the device dependant
- * modules include it
- */
-struct ss_softc {
- struct device sc_dev;
-
- int flags;
-#define SSF_TRIGGERED 0x01 /* read operation has been primed */
-#define SSF_LOADED 0x02 /* parameters loaded */
- struct scsi_link *sc_link; /* contains our targ, lun, etc. */
- struct scan_io sio;
- struct buf buf_queue; /* the queue of pending IO operations */
- u_int quirks; /* scanner is only mildly twisted */
-#define SS_Q_GET_BUFFER_SIZE 0x0001 /* poll for available data in ssread() */
-/* truncate to byte boundry is assumed by default unless one of these is set */
-#define SS_Q_PAD_TO_BYTE 0x0002 /* pad monochrome data to byte boundary */
-#define SS_Q_PAD_TO_WORD 0x0004 /* pad monochrome data to word boundary */
-#define SS_Q_THRESHOLD_FOLLOWS_BRIGHTNESS 0x0008
- struct ss_special *special; /* special handlers for spec. devices */
-};
-
-/*
- * define the special attach routines if configured
- */
-void mustek_attach __P((struct ss_softc *, struct scsibus_attach_args *));
-void scanjet_attach __P((struct ss_softc *, struct scsibus_attach_args *));