From 001508b8f1cac41243cf0563ddeb8c9168d83521 Mon Sep 17 00:00:00 2001 From: kstailey Date: Mon, 10 Mar 1997 02:29:39 +0000 Subject: [PATCH] do GET_BUFFER_STATUS in special minphys --- sys/scsi/scsi_scanner.h | 15 ++++-- sys/scsi/ss.c | 109 ++++++++++++++++++++++++++-------------- sys/scsi/ss_mustek.c | 4 +- sys/scsi/ss_scanjet.c | 4 +- sys/scsi/ssvar.h | 10 ++-- 5 files changed, 93 insertions(+), 49 deletions(-) diff --git a/sys/scsi/scsi_scanner.h b/sys/scsi/scsi_scanner.h index 4bddd242065..8c27ca3866c 100644 --- a/sys/scsi/scsi_scanner.h +++ b/sys/scsi/scsi_scanner.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_scanner.h,v 1.6 1997/03/10 01:06:11 kstailey Exp $ */ +/* $OpenBSD: scsi_scanner.h,v 1.7 1997/03/10 02:29:39 kstailey Exp $ */ /* * Copyright (c) 1995 Kenneth Stailey. All rights reserved. @@ -41,7 +41,6 @@ #define GET_IMAGE_STATUS 0x0f #define WRITE_BIG 0x2a #define OBJECT_POSITION 0x31 -#define GET_BUFFER_STATUS 0x34 /* generic scanner command formats */ @@ -49,7 +48,7 @@ struct scsi_r_scanner { #define READ_BIG 0x28 u_int8_t opcode; u_int8_t lun:3; - u_int8_t res1; + u_int8_t res1:5; u_int8_t code; u_int8_t res2; u_int8_t qualifier; @@ -57,6 +56,16 @@ struct scsi_r_scanner { u_int8_t control; }; +struct scsi_get_buffer_status { +#define GET_BUFFER_STATUS 0x34 + u_int8_t opcode; + u_int8_t lun:3; + u_int8_t res1:4; + u_int8_t wait:1; + u_int8_t res2[5]; + u_int8_t len[2]; + u_int8_t control; +}; struct scsi_rw_scanner { #define READ 0x08 diff --git a/sys/scsi/ss.c b/sys/scsi/ss.c index e731bbacf07..bfc35923a79 100644 --- a/sys/scsi/ss.c +++ b/sys/scsi/ss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ss.c,v 1.20 1997/03/10 00:56:59 kstailey Exp $ */ +/* $OpenBSD: ss.c,v 1.21 1997/03/10 02:29:39 kstailey Exp $ */ /* $NetBSD: ss.c,v 1.10 1996/05/05 19:52:55 christos Exp $ */ /* @@ -68,18 +68,17 @@ struct quirkdata { char *name; u_int quirks; #define SS_Q_WINDOW_DESC_LEN 0x0001 /* needs special WDL */ -#define SS_Q_BRIGHTNESS 0x0002 /* use special value for brightness */ +#define SS_Q_BRIGHTNESS 0x0002 /* needs special value for brightness */ #define SS_Q_REV_BRIGHTNESS 0x0004 /* reverse brightness control in s/w */ -#define SS_Q_THRESHOLD 0x0008 /* use special value for threshold */ +#define SS_Q_THRESHOLD 0x0008 /* needs special value for threshold */ #define SS_Q_MONO_THRESHOLD 0x0010 /* same as SS_Q_THRESHOLD but only * for monochrome image data */ -#define SS_Q_CONTRAST 0x0020 /* use special value for contrast */ +#define SS_Q_CONTRAST 0x0020 /* needs special value for contrast */ #define SS_Q_REV_CONTRAST 0x0040 /* reverse contrast control in s/w */ #define SS_Q_HALFTONE 0x0080 /* uses non-zero halftone */ #define SS_Q_SET_RIF 0x0100 /* set RIF bit */ #define SS_Q_PADDING_TYPE 0x0200 /* does not pad to byte boundary */ -#define SS_Q_BIT_ORDERING 0x0400 /* uses non-zero bit ordering */ -#define SS_Q_GET_BUFFER_SIZE 0x0800 /* use GET_BUFFER_SIZE while reading */ +#define SS_Q_BIT_ORDERING 0x0400 /* needs non-zero bit ordering */ long window_descriptor_length; u_int8_t brightness; u_int8_t threshold; @@ -87,8 +86,13 @@ struct quirkdata { u_int8_t halftone_pattern[2]; int pad_type; long bit_ordering; + /* + * To enable additional scanner options, point vendor_unique_sw + * at a function that adds more stuff to the SET_WINDOW parameters. + */ int (*vendor_unique_sw)__P((struct ss_softc *, struct scan_io *, struct scsi_set_window *, void *)); + void (*special_minphys)__P(( struct ss_softc *, struct buf *)); }; struct ss_quirk_inquiry_pattern { @@ -112,6 +116,7 @@ int fujitsu_m3096g_sw __P((struct ss_softc *, struct scan_io *, struct scsi_set_window *, void *)); #endif +void get_buffer_status __P((struct ss_softc *, struct buf *)); /* * WDL: @@ -133,7 +138,7 @@ struct ss_quirk_inquiry_pattern ss_quirk_patterns[] = { SS_Q_HALFTONE | SS_Q_BIT_ORDERING, 320, 0, 0, 0, { 2, 0x0a }, 0, 7, - ricoh_is410_sw + ricoh_is410_sw, get_buffer_status }}, {{T_SCANNER, T_FIXED, "RICOH ", "IS410 ", " "}, { @@ -143,7 +148,7 @@ struct ss_quirk_inquiry_pattern ss_quirk_patterns[] = { SS_Q_HALFTONE | SS_Q_BIT_ORDERING, 320, 0, 0, 0, { 2, 0x0a }, 0, 7, - ricoh_is410_sw + ricoh_is410_sw, get_buffer_status }}, {{T_SCANNER, T_FIXED, /* Ricoh IS-410 OEMed by IBM */ "IBM ", "2456-001 ", " "}, { @@ -153,7 +158,7 @@ struct ss_quirk_inquiry_pattern ss_quirk_patterns[] = { SS_Q_HALFTONE | SS_Q_BIT_ORDERING, 320, 0, 0, 0, { 2, 0x0a }, 0, 7, - ricoh_is410_sw + ricoh_is410_sw, get_buffer_status }}, {{T_SCANNER, T_FIXED, "UMAX ", "UC630 ", " "}, { @@ -161,7 +166,7 @@ struct ss_quirk_inquiry_pattern ss_quirk_patterns[] = { SS_Q_WINDOW_DESC_LEN | SS_Q_HALFTONE, 0x2e, 0, 0, 0, { 0, 1 }, 0, 0, - umax_uc630_sw + umax_uc630_sw, NULL }}, {{T_SCANNER, T_FIXED, "UMAX ", "UG630 ", " "}, { @@ -169,7 +174,7 @@ struct ss_quirk_inquiry_pattern ss_quirk_patterns[] = { SS_Q_WINDOW_DESC_LEN | SS_Q_HALFTONE, 0x2e, 0, 0, 0, { 0, 1 }, 0, 0, - umax_uc630_sw + umax_uc630_sw, NULL }}, #ifdef NOTYET /* ADF version */ {{T_SCANNER, T_FIXED, @@ -182,7 +187,7 @@ struct ss_quirk_inquiry_pattern ss_quirk_patterns[] = { SS_Q_SET_RIF | SS_Q_PADDING_TYPE, 64, 0, 0, 0, { 0, 1 }, 0, 0, - fujistsu_m3096g_sw + fujistsu_m3096g_sw, NULL }}, #else /* flatbed-only version */ {{T_SCANNER, T_FIXED, @@ -194,7 +199,7 @@ struct ss_quirk_inquiry_pattern ss_quirk_patterns[] = { SS_Q_HALFTONE | SS_Q_PADDING_TYPE, 0, 0, 0, 0, { 0, 1 }, 0, 0, - NULL + NULL, NULL }}, #endif }; @@ -302,6 +307,9 @@ ss_identify_scanner(ss, inqbuf) sizeof(ss_quirk_patterns[0]), &priority); if (priority != 0) { ss->quirkdata = &finger->quirkdata; + if (ss->quirkdata->special_minphys != NULL) { + ss->special.minphys = ss->quirkdata->special_minphys; + } printf("%s\n", ss->quirkdata->name); } else { printf("generic scanner\n"); /* good luck 8c{)] */ @@ -390,9 +398,9 @@ ssclose(dev, flag, mode, p) SC_DEBUG(ss->sc_link, SDEV_DB1, ("closing\n")); if (SSMODE(dev) == MODE_REWIND) { - if (ss->special->rewind_scanner) { + if (ss->special.rewind_scanner) { /* call special handler to rewind/abort scan */ - error = (ss->special->rewind_scanner)(ss); + error = (ss->special.rewind_scanner)(ss); if (error) return (error); } else { @@ -426,8 +434,8 @@ ssminphys(bp) * time, also some cannot disconnect, so the read must be * short enough to happen quickly */ - if (ss->special->minphys) - (ss->special->minphys)(ss, bp); + if (ss->special.minphys) + (ss->special.minphys)(ss, bp); } /* @@ -446,8 +454,8 @@ ssread(dev, uio, flag) /* 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 (ss->special.trigger_scanner) { + error = (ss->special.trigger_scanner)(ss); if (error) return (error); } @@ -534,7 +542,7 @@ ssstart(v) struct ss_softc *ss = v; struct scsi_link *sc_link = ss->sc_link; register struct buf *bp, *dp; - struct scsi_r_scanner cmd; + struct scsi_r_scanner read_cmd; int flags; SC_DEBUG(sc_link, SDEV_DB2, ("ssstart ")); @@ -562,23 +570,20 @@ ssstart(v) ss->buf_queue.b_actb = bp->b_actb; *bp->b_actb = dp; - if (ss->special->read) { - (ss->special->read)(ss, bp); + if (ss->special.read) { + (ss->special.read)(ss, bp); } else { /* generic scsi2 scanner read */ - if (ss->quirkdata->quirks & SS_Q_GET_BUFFER_SIZE) { - /* XXX add GET BUFFER SIZE command */ - } - bzero(&cmd, sizeof(cmd)); - cmd.opcode = READ; - _lto3b(bp->b_bcount, cmd.len); + bzero(&read_cmd, sizeof(read_cmd)); + read_cmd.opcode = READ; + _lto3b(bp->b_bcount, read_cmd.len); flags = SCSI_DATA_IN; /* * 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, 0, - 100000, bp, flags | SCSI_NOSLEEP)) + if (scsi_scsi_cmd(sc_link, (struct scsi_generic *) + &read_cmd, sizeof(read_cmd), (u_char *) bp->b_data, + bp->b_bcount, 0, 100000, bp, flags | SCSI_NOSLEEP)) printf("%s: not queued\n", ss->sc_dev.dv_xname); } } @@ -603,8 +608,8 @@ ssioctl(dev, cmd, addr, flag, p) switch (cmd) { case SCIOCGET: /* call special handler, if any */ - if (ss->special->get_params) { - error = (ss->special->get_params)(ss); + if (ss->special.get_params) { + error = (ss->special.get_params)(ss); if (error) return (error); } @@ -614,8 +619,8 @@ ssioctl(dev, cmd, addr, flag, p) sio = (struct scan_io *)addr; /* call special handler, if any */ - if (ss->special->set_params) { - error = (ss->special->set_params)(ss, sio); + if (ss->special.set_params) { + error = (ss->special.set_params)(ss, sio); if (error) return (error); } else { @@ -625,8 +630,8 @@ ssioctl(dev, cmd, addr, flag, p) break; case SCIOCRESTART: /* call special handler, if any */ - if (ss->special->rewind_scanner ) { - error = (ss->special->rewind_scanner)(ss); + if (ss->special.rewind_scanner ) { + error = (ss->special.rewind_scanner)(ss); if (error) return (error); } else @@ -880,3 +885,33 @@ fujitsu_m3096g_sw(ss, sio, wcmd, vwd) SCSI_DATA_OUT)); } #endif + +void +get_buffer_status(ss, bp) + struct ss_softc *ss; + struct buf *bp; +{ + struct scsi_get_buffer_status gbs_cmd; + struct scsi_link *sc_link = ss->sc_link; + struct { + u_int8_t stat_len[3]; + u_int8_t res1; + u_int8_t window_id; + u_int8_t res2; + u_int8_t tgt_accept_buf_len[3]; + u_int8_t tgt_send_buf_len[3]; + } buf_sz_retn; + int flags; + + bzero(&gbs_cmd, sizeof(gbs_cmd)); + gbs_cmd.opcode = GET_BUFFER_STATUS; + _lto2b(12, gbs_cmd.len); + flags = SCSI_DATA_IN; + + if (scsi_scsi_cmd(sc_link, (struct scsi_generic *) &gbs_cmd, + sizeof(gbs_cmd), (u_char *) &buf_sz_retn, sizeof(buf_sz_retn), + 0, 100000, bp, flags | SCSI_NOSLEEP)) { + printf("%s: not queued\n", ss->sc_dev.dv_xname); + } + bp->b_bcount = _3btol(buf_sz_retn.tgt_send_buf_len); +} diff --git a/sys/scsi/ss_mustek.c b/sys/scsi/ss_mustek.c index 3afe58a1e7c..58379d359b5 100644 --- a/sys/scsi/ss_mustek.c +++ b/sys/scsi/ss_mustek.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ss_mustek.c,v 1.6 1997/03/06 12:44:42 kstailey Exp $ */ +/* $OpenBSD: ss_mustek.c,v 1.7 1997/03/10 02:29:40 kstailey Exp $ */ /* $NetBSD: ss_mustek.c,v 1.4 1996/05/05 19:52:57 christos Exp $ */ /* @@ -124,7 +124,7 @@ mustek_attach(ss, sa) ss->sio.scan_scanner_type)); /* install special handlers */ - ss->special = &mustek_special; + ss->special = mustek_special; /* * populate the scanio struct with legal values diff --git a/sys/scsi/ss_scanjet.c b/sys/scsi/ss_scanjet.c index 5f472ecf997..3c198198366 100644 --- a/sys/scsi/ss_scanjet.c +++ b/sys/scsi/ss_scanjet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ss_scanjet.c,v 1.15 1997/03/06 12:44:42 kstailey Exp $ */ +/* $OpenBSD: ss_scanjet.c,v 1.16 1997/03/10 02:29:40 kstailey Exp $ */ /* $NetBSD: ss_scanjet.c,v 1.6 1996/05/18 22:58:01 christos Exp $ */ /* @@ -120,7 +120,7 @@ scanjet_attach(ss, sa) ss->sio.scan_scanner_type)); /* now install special handlers */ - ss->special = &scanjet_special; + ss->special = scanjet_special; /* * populate the scanio struct with legal values diff --git a/sys/scsi/ssvar.h b/sys/scsi/ssvar.h index 8801df6b898..df6b050821a 100644 --- a/sys/scsi/ssvar.h +++ b/sys/scsi/ssvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssvar.h,v 1.6 1997/03/08 05:39:01 kstailey Exp $ */ +/* $OpenBSD: ssvar.h,v 1.7 1997/03/10 02:29:41 kstailey Exp $ */ /* $NetBSD: ssvar.h,v 1.2 1996/03/30 21:47:11 christos Exp $ */ /* @@ -65,11 +65,11 @@ struct ss_softc { 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 scsi_link *sc_link; /* contains our targ, lun, etc. */ struct scan_io sio; - struct buf buf_queue; /* the queue of pending IO operations */ - struct quirkdata *quirkdata; /* if we have a rogue entry */ - struct ss_special *special; /* special handlers for spec. devices */ + struct buf buf_queue; /* the queue of pending IO operations */ + struct quirkdata *quirkdata; /* if we have a rogue entry */ + struct ss_special special; /* special handlers for spec. devices */ }; /* -- 2.20.1