diff options
author | julian <julian@FreeBSD.org> | 1995-09-08 03:08:01 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1995-09-08 03:08:01 +0000 |
commit | 0704e6325a24ef62463139c9ae535757d055bc37 (patch) | |
tree | 3579505a54b5ad71fcf041d251f9776655f4204f /usr.bin/sasc | |
parent | b63f80398aaa10926795aa82696b3db47f789828 (diff) | |
download | FreeBSD-src-0704e6325a24ef62463139c9ae535757d055bc37.zip FreeBSD-src-0704e6325a24ef62463139c9ae535757d055bc37.tar.gz |
Submitted by: Luigi Rizzo (luigi@iet.unipi.it)
Obtained from: Gunther Schadow and Luigi Rizzo
control program for Trust AmiScan BW (GI1904 chipset)
ASC - A device driver for a handy scanner
This is a device driver for GI1904-based hand scanners, e.g. the Trust
Amiscan Grey and possibly others. The driver is based on the "gsc"
driver and, partly, on a Linux driver.
The driver has a working select().
-Luigi Rizzo (luigi@iet.unipi.it)
Diffstat (limited to 'usr.bin/sasc')
-rw-r--r-- | usr.bin/sasc/INSTALL | 86 | ||||
-rw-r--r-- | usr.bin/sasc/Makefile | 5 | ||||
-rw-r--r-- | usr.bin/sasc/README | 9 | ||||
-rw-r--r-- | usr.bin/sasc/sasc.1 | 91 | ||||
-rw-r--r-- | usr.bin/sasc/sasc.c | 193 |
5 files changed, 384 insertions, 0 deletions
diff --git a/usr.bin/sasc/INSTALL b/usr.bin/sasc/INSTALL new file mode 100644 index 0000000..448a7a2 --- /dev/null +++ b/usr.bin/sasc/INSTALL @@ -0,0 +1,86 @@ +To install the device driver, please do the following steps: + +1. Install the files by copying them as listed in the following table: + + asc.c /usr/sys/i386/isa/ + ascreg.h /usr/sys/i386/isa/ + asc_ioctl.h /usr/sys/i386/include/ + + Note that if you have copies of the system header directories + in /usr/include/ instead of symbolic links, you have to copy + `asc.h' to /usr/include/machine/ also. I recommend to replace + the copies by links though. + +[the following steps, 2..5, can be achieved by moving to + /sys/i386 and doing "patch < diffs.asc"] + +2. Make the driver source known to config(8) by editing the file + /usr/src/sys/i386/conf/files.i386. Just append the following line: + + i386/isa/asc.c optional asc device-driver + +3. Include a driver access record in /usr/src/sys/i386/i386/conf.c + Append the following structure at the end of the array that + contains the *character* device drivers. Remember the major number + that will be used for the driver, i.e. the number following the + number af the preceeding record. + + { ascopen, ascclose, ascread, nowrite, /*<major>*/ + ascioctl, nostop, nullreset, nodevtotty, /* asc */ + ascselect, nommap, NULL }, + +4. Insert the definitions for the base port addresses of the device + into the file /usr/src/sys/i386/isa/isa.h: + +#define IO_ASC1 0x3EB /* AmiScan addr.grp. 1 */ +#define IO_ASC2 0x22B /* AmiScan addr.grp. 2 */ +#define IO_ASC3 0x26B /* AmiScan addr.grp. 3 */ +#define IO_ASC4 0x2AB /* AmiScan addr.grp. 4 */ +#define IO_ASC5 0x2EB /* AmiScan addr.grp. 5 */ +#define IO_ASC6 0x32B /* AmiScan addr.grp. 6 */ +#define IO_ASC7 0x36B /* AmiScan addr.grp. 7 */ +#define IO_ASC8 0x3AB /* AmiScan addr.grp. 8 */ + +5. Patch /dev/MAKEDEV by adding the following lines in the switch to + create the device entries: + + asc*) + rm -f asc0 + mknod asc0 c 68 0 + mknod asc0p c 68 8 + chmod 666 asc0 asc0p + chown root.wheel asc0 asc0p + ;; + + + +6. Edit your kernel configuration file (in /usr/src/sys/i386/conf/) + by inserting the following line: + + device asc0 at isa? port 0x2ab tty drq 3 irq 10 vector ascintr + + This should usually work for you as it reflects the factory + settings of the AMI scanner. However, if this conflicts with + any other device on your system, you have the option to change + `drq 3' into `drq 1' or `drq 5' and the actual port value to + "IO_ASC1".. "IO_ASC8" as defined in isa.h + +7. Rebuild the kernel, don't forget to config(8) and `make depend' first. + +8. Make the following device nodes: + + mknod /dev/asc0 c <major> 0 + mknod /dev/asc0p c <major> 8 + + (or, cd /dev and do ./MAKEDEV asc0). + + If you plan to modify the and debug the driver, add these (you + won't need these though, unless you know how to get this + information from elsewhere. + + mknod /dev/asc0d c <major> 32 + mknod /dev/asc0pd c <major> 40 + +9. Install the new kernel and reboot. You can try the driver by + doing a simple "cat /dev/asc0p > myfile.pbm" and then trying + to display the PBM image with xv or some other tool. diff --git a/usr.bin/sasc/Makefile b/usr.bin/sasc/Makefile new file mode 100644 index 0000000..022cd27 --- /dev/null +++ b/usr.bin/sasc/Makefile @@ -0,0 +1,5 @@ +# @(#)Makefile 8.1 (Berkeley) 6/6/93 + +PROG= sasc + +.include <bsd.prog.mk> diff --git a/usr.bin/sasc/README b/usr.bin/sasc/README new file mode 100644 index 0000000..5436bd2 --- /dev/null +++ b/usr.bin/sasc/README @@ -0,0 +1,9 @@ +ASC - A device driver for a handy scanner + +This is a device driver for GI1904-based hand scanners, e.g. the Trust +Amiscan Grey and possibly others. The driver is based on the "gsc" +driver and, partly, on a Linux driver. + +The driver has a working select(). + +-Luigi Rizzo (luigi@iet.unipi.it) diff --git a/usr.bin/sasc/sasc.1 b/usr.bin/sasc/sasc.1 new file mode 100644 index 0000000..76af185 --- /dev/null +++ b/usr.bin/sasc/sasc.1 @@ -0,0 +1,91 @@ +.\" sasc(1) - manual page for the `asc' scanner device driver utility +.\" +.\" +.\" Copyright (c) 1995 Gunther Schadow. 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 Gunther Schadow. +.\" 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. +.TH SASC 1 "January 6, 1995" FreeBSD "FreeBSD Reference Manual" +.SH NAME +\fBsasc\fP - set the options of the asc scanner device +.SH SYNOPSIS +.TP 5 +\fBsasc\fP +[\fB-sq\fP] +[\fB-b\fP\ \fIlen\fP] +[\fB-f\fP\ \fIfile\fP] +[\fB-h\fP\ \fIheight\fP] +[\fB-r\fP\ \fIresolution\fP] +[\fB-t\fP\ \fItimeout\fP] +[\fB-w\fP\ \fIwidth\fP] +.SH DESCRIPTION +The \fBsasc\fP utility provides shell level access to the ioctl +requests served by the handy scanner device driver asc. Please see +asc(4) for the exact meaning of the requests. Generally they modify +the output and behaviour of the asc scanner device. When \fBsasc\fP is +called with no option only the current settings are reported. +.SH OPTIONS +.TP 3 +\fB-s\fP [ASC_SRESSW] +Set the scanner with the values of the resolution selector switch. +.TP +\fB-q\fP +Operate in quiet mode, i.e. do not report any of the current setings. +Normally the parameters are shown after the modifications have been +performed. +.TP +\fB-f\fP \fIfile\fP +Operate on a different scanner device node given by filename. Note +that even though there may exist more than one node of scanner device +several of them will refer the same device unit. The modifications are +performed od the unit regardless of the device node by which it is +accessed. +.TP +\fB-r\fP \fIresolution\fP [ASC_SRES] +Set the resolution in dpi. +.TP +\fB-w\fP \fIwidth\fP [ASC_SWIDHT] +Set the width of the bitmap in pixels. +.TP +\fB-h\fP \fIheight\fP [ASC_SHEIGHT] +Set the height of the bitmap in lines of pixels. +.TP +\fB-b\fP \fIlen\fP [ASC_SBLEN] +Set the internal dma buffer to be \fIlen\fP lines in size. +.TP +\fB-t\fP \fItimeout\fP [ASC_SBTIME] +Set the timeout time for reading one dma buffer. +.SH FILES +.TP 15 +.BI /dev/asc0 +device node for \fIraw\fP output. +.TP +.BI /dev/asc0p +device node for output in \fIpbm\fP file format. +.PB +.SH SEE ALSO +asc(4) +.SH AUTHOR +Gunther Schadow <gusw@fub46.zedat.fu-berlin.de> diff --git a/usr.bin/sasc/sasc.c b/usr.bin/sasc/sasc.c new file mode 100644 index 0000000..40346be --- /dev/null +++ b/usr.bin/sasc/sasc.c @@ -0,0 +1,193 @@ +/* sasc(1) - utility for the `asc' scanner device driver + * + * + * Copyright (c) 1995 Gunther Schadow. 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 Gunther Schadow. + * 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 <stdlib.h> +#include <stdio.h> +#include <sys/file.h> +#include <sys/ioctl.h> +#include <machine/asc_ioctl.h> + +#ifndef DEFAULT_FILE +#define DEFAULT_FILE "/dev/asc0" +#endif +#ifdef FAIL +#undef FAIL +#endif +#define FAIL -1 + +usage(char *progn) +{ + fprintf(stderr, "usage: %s [-sq] [-f file] [-r dpi] " + "[-w width] [-h height] " + "[-b len] [-t time]\n", progn); + exit(1); +} + +int +main(int argc, char **argv) +{ + char c; + int fd; + + char *file = DEFAULT_FILE; + + int show_dpi = 0; + int show_width = 0; + int show_height = 0; + int show_blen = 0; + int show_btime = 0; + int show_all = 1; + + int set_blen = 0; + int set_dpi = 0; + int set_width = 0; + int set_height = 0; + int set_btime = 0; + int set_switch = 0; + + char *progn = *argv; + + if (argc == 0) usage(progn); + + while( (c = getopt(argc, argv, "sqf:b:r:w:h:t:")) != FAIL) + { + switch(c) { + case 'f': file = optarg; break; + case 'r': set_dpi = atoi(optarg); break; + case 'w': set_width = atoi(optarg); break; + case 'h': set_height = atoi(optarg); break; + case 'b': set_blen = atoi(optarg); break; + case 't': set_btime = atoi(optarg); break; + case 's': set_switch = 1; break; + case 'q': show_all = 0; break; + default: usage(progn); + } + } + + fd = open(file, O_RDONLY); + if ( fd == FAIL ) + { + perror(file); + exit(1); + } + + if (set_switch != 0) + { + if(ioctl(fd, ASC_SRESSW) == FAIL) + { + perror("ASC_SRESSW"); + exit(1); + } + } + + if (set_dpi != 0) + { + if(ioctl(fd, ASC_SRES, &set_dpi) == FAIL) + { + perror("ASC_SRES"); + exit(1); + } + } + + if (set_width != 0) + { + if(ioctl(fd, ASC_SWIDTH, &set_width) == FAIL) + { + perror("ASC_SWIDTH"); + exit(1); + } + } + + if (set_height != 0) + { + if(ioctl(fd, ASC_SHEIGHT, &set_height) == FAIL) + { + perror("ASC_SHEIGHT"); + exit(1); + } + } + + if (set_blen != 0) + { + if(ioctl(fd, ASC_SBLEN, &set_blen) == FAIL) + { + perror("ASC_SBLEN"); + exit(1); + } + } + + if (set_btime != 0) + { + if(ioctl(fd, ASC_SBTIME, &set_btime) == FAIL) + { + perror("ASC_SBTIME"); + exit(1); + } + } + + if (show_all != 0) + { + if(ioctl(fd, ASC_GRES, &show_dpi) == FAIL) + { + perror("ASC_GRES"); + exit(1); + } + if(ioctl(fd, ASC_GWIDTH, &show_width) == FAIL) + { + perror("ASC_GWIDTH"); + exit(1); + } + if(ioctl(fd, ASC_GHEIGHT, &show_height) == FAIL) + { + perror("ASC_GHEIGHT"); + exit(1); + } + if(ioctl(fd, ASC_GBLEN, &show_blen) == FAIL) + { + perror("ASC_GBLEN"); + exit(1); + } + if(ioctl(fd, ASC_GBTIME, &show_btime) == FAIL) + { + perror("ASC_GBTIME"); + exit(1); + } + + printf("%s:\n", file); + printf("resolution\t %d dpi\n", show_dpi); + printf("width\t\t %d\n", show_width); + printf("height\t\t %d\n",show_height); + printf("buffer length\t %d\n", show_blen); + printf("buffer timeout\t %d\n", show_btime); + } + + return 0; +} |