_______________________________________________________________________________
 
Small Computer Systems Interface
 
Image Scanning Software Development Aid
 
 
 
 
 
 
                                   Microtek
 
                              SCSI IMAGE SCANNER
 
                            Programmer's Reference
 
 
 
 
 
 
                                  Preliminary
                                 May 12, 1995
                              Ref. No.: PRG94420
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    Microtek International, Inc.
      No. 6, Industry East Road III                   Tel:  886-35-772155
      Science-based Industrial Park                   Tlx: 32169 MICROTEK
      Hsinchu, Taiwan 30077, ROC                      Fax:  886-35-772598
 
 
 
 
 
 
 
 _______________________________________________________________________________
 
Copyright (C) 1994 Microtek International Inc.  All rights reserved.
 
This manual is subject to change without notice. Nothing herein shall be
construed as a recommendation to use any product in violation of existing
patents or other rights of third parties.
_______________________________________________________________________________
 
 
                CONTENTS
 
 
                Introduction    1
 
             1. Connection Information    2
 
                1.1   Cable Termination    2
                1.2   SCSI ID Setting    2
                1.3   Scanner I/O Connector Pin Assignment    2
 
             2. Programming Notes    3
 
                2.1   SCSI Phase Structure and Microtek SCSI Scanners    3
                2.2   Details of SCSI Communication Phases    4
                2.3   Status Byte    5
                2.4   Messages    5
                2.4   Special Considerations    6
                2.5   Command List    7
 
             3. Command Descriptions    8
 
                3.1   TEST UNIT READY Command    8
                3.2   REQUEST SENSE Command    9
                3.3   SCANNING FRAME Command    12
                3.4   READ SCANNED DATA Command    15
                3.5   GET SCAN STATUS Command    16
                3.6   ACCESSORY & BACKTRACKING Command    17
                3.7   INQUIRY Command    18
                3.8   MODE SELECT Command    25
                3.9   MODE SELECT 1 Command    29
                3.10  MODE SENSE 1 Command    31
                3.11  MODE SENSE Command    32
                3.12  START/STOP SCAN Command    34
                3.13  RECEIVE DIAGNOSTIC RESULTS Command    35
                3.14  SEND DIAGNOSTIC Command    36
                3.15  LOOK-UP TABLE DOWNLOAD Command    37
                                                                                
 
Introduction
 
 
This manual describes the commands used to control Microtek ScanMaker series
SCSI image scanners.
 
It is assumed that the reader is an experienced programmer with access to
detailed SCSI documentation. Knowledge of digital image processing fundamentals
is recommended; a quick reading of the software manual(s) included with the
scanner will provide the necessary background. For information on scanner setup
and handling, document positioning and the like, please refer to the owner's
manual included with the scanner (and that included with any optional accessory
such as a transparency illuminator or automatic document feeder).
 
Microtek's image scanning product line includes software development tools,
drivers and application programs of many types for many kinds of systems.
Product updates and new product releases are frequent. Developers are urged to
keep in touch with Microtek for up-to-date product information. Questions
regarding products and product documentation are always welcome.
                                                                                
 
Chapter 1: Connection Information
 
 
1.1  Cable Termination
 
Before connecting the scanner, check the documentation for your computer's SCSI
port to determine whether a SCSI cable terminator is required. This will depend
on the scanner's position in the SCSI chain and other factors. As shipped from
the factory, Microtek SCSI scanners do NOT have internal cable terminators.
 
 
1.2  SCSI ID Setting
 
Be sure to check the scanner's SCSI ID before powering up the unit. The ID is
set with a push-indexing or rotary switch on the rear panel or the underside of
the scanner. Any ID from 0 through 6 is valid as long as it is not used by any
other device on the SCSI bus. ID number 7 is reserved for testing purposes.
 
 
1.3  Scanner I/O Connector Pin Assignment
 
                 Pin(s)   Signal Name   Explanation         I/O
                 """"""   """""""""""   """"""""""""""""    """
                   1-12   GND           Ground
                  14-25   GND           Ground
                   26     -DB(0)        Data Bit 0          I/O
                   27     -DB(1)        Data Bit 1          I/O
                   28     -DB(2)        Data Bit 2          I/O
                   29     -DB(3)        Data Bit 3          I/O
                   30     -DB(4)        Data Bit 4          I/O
                   31     -DB(5)        Data Bit 5          I/O
                   32     -DB(6)        Data Bit 6          I/O
                   33     -DB(7)        Data Bit 7          I/O
                   34     -DB(P)        Data Parity Bit     I/O
                  35-37   GND           Ground
                   38     TERMPWR       Terminator Power     O
                   39     GND           Ground
                   40     GND           Ground
                   41     -ATN          Attention            I
                   42     GND           Ground
                   43     -BSY          Busy                I/O
                   44     -ACK          Acknowledge          I
                   45     -RST          Reset               I/O
                   46     -MSG          Message              O
                   47     -SEL          Select               I
                   48     -C/D          Control/Data         O
                   49     -REQ          Request              O
                   50     -I/O          Input/Output         O
 
Pin 13 is not connected. Signals preceded by a minus sign [-] are "active low"
(true, or asserted, when TTL low).
                                                                                
 
Chapter 2: Programming Notes
 
 
2.1  SCSI Phase Structure and Microtek SCSI Scanners
 
The SCSI standard defines basic signal structure and communication protocols
for an intelligent I/O bus on which up to eight devices (both hosts and
peripherals) can be connected in daisy-chain fashion. The standard is flexible
enough to allow a wide variety of implementations, from single-user,
single-tasking to multi-user, multi-tasking and multi-processor configurations.
 
Two roles are defined for devices on the bus: that of "initiator" (usually,
host) and that of "target" (usually, peripheral). Nearly complete target
control of the bus during I/O operations, and a wide variety of command
options, give the SCSI standard its great flexibility.
 
Another salient feature of the SCSI standard is its division of each I/O
operation into distinct phases. Bus-Free, Arbitration, and Selection/
Reselection phases are used to decide control of the bus by means of hardware
signals; Command, Data, Status, and Message phases are used to carry out actual
information transfers over the data bus.
 
A complete communication cycle begins and ends with the Bus Free phase. When
the (optional) Arbitration and Reselection phases are implemented, the sequence
of phases is as shown below.
 
SCSI Phase Sequence (Full Implementation)
         ______    _____________    _____________    ________________
        |      \  |             \  |             \  |                \
       _| Bus   \_| Arbitration  \_| Selection/   \_| Command/Data/   \_
      | | Free  / |              / | Reselection  / | Status/Message  / |
      | |______/  |_____________/  |_____________/  |________________/  |
      |                  |                |                  ^          |
      |                  v                v                  |          |
       <________________________________________________________________
 
A Microtek SCSI scanner takes the role of a target with a host computer as
initiator. The scanner does not actively participate in the Arbitration and
Reselection phases. After being selected by an initiator, the scanner controls
the flow of information on the bus; when information transfer is complete, it
sends a message to the initiator indicating that the bus is to be freed. The
sequence of phases in a scanner communication cycle is shown below. As per the
SCSI standard, the Data phase is invoked only if required by the preceding
command.
 
Microtek SCSI Scanner Phase Sequence
   __________   ___________   _________     ______     ________   _________
 _| Bus Free \_| Selection \_| Command \___| Data \___| Status \_| Message \_
| |__________/ |___________/ |_________/ | |______/ | |________/ |_________/ |
|                    |                   |          |                        |
|                    v                    _________>                         |
 <___________________________________________________________________________
                                                                               2.2  Details of SCSI Communication Phases
 
The phases of the SCSI communication protocol are described in greater detail
below. Remember that Microtek SCSI scanners provide only passive support for
the Arbitration, Reselection, and Message Out phases.
 
 
System Control Phases
 
Bus Free Phase           SCSI bus not in use.
 
Arbitration Phase        Highest-priority device among those contending for use
                         of the bus gains control.
 
Selection Phase          Initiator selects target for information transfer.
 
Reselection Phase        Target reconnects to initiator to continue an
                         information transfer previously broken off by the
                         target.
 
 
Information Transfer Phases
 
Command Phase            Target requests transfer of command information from
                         initiator; command packet flows from initiator to
                         target.
 
Data Phases
 
   Data In Phase         Target requests transfer of data to initiator; data
                         flow from target to initiator.
 
   Data Out Phase        Target requests transfer of data from initiator; data
                         flow from initiator to target.
 
Status Phase             Target requests transfer of status information to
                         initiator; Status byte flows from target to initiator.
 
Message Phases
 
   Message In Phase      Target requests transfer of message to initiator;
                         message flows from target to initiator.
 
   Message Out Phase     Target requests transfer of message from initiator;
                         message flows from initiator to target.
2.3  Status Byte
 
The Status byte is sent immediately after the Data phase, or immediately after
the Command phase if the command involves no data transfer. The bit definition
of the Status byte in Microtek SCSI scanners is shown below.
 
   Status Byte
 
    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
   Rsvd, 0  VenUniq  VenUniq  ------------Status Code-----------  VenUniq
 
Bit 7 is reserved and always zero. Vendor-unique bits 6, 5 and 0, and bits 2
and 4, are currently undefined and always zero. Possible Status Code bit
configurations are shown below.
 
   Status Code (Status Byte Bits 4 through 1)
 
   ___________
    |4|3|2|1|
   ___________
 
     0 0 0 0      No error detected during the preceding Command(/Data)
                  phase(s); status is GOOD.
 
     0 0 0 1      Hardware or software error detected during the preceding
                  Command(/Data) phase(s); status is CHECK CONDITION.
 
     0 1 0 0      Scanner busy and unable to process preceding command; status
                  is BUSY.
 
If a CHECK CONDITION status is returned, the REQUEST SENSE command should be
issued to obtain error information from the scanner.
 
 
2.4  Messages
 
Microtek SCSI scanners support the following Message phase byte values:
 
  00h    COMMAND COMPLETE. Indicates to the initiator that an I/O process has
         ended.
 
  05h    INITIATOR DETECTED ERROR. Informs the scanner that an error has
         occurred.
 
  06h    ABORT. Sent by the initiator to clear the current operation.
 
  07h    MESSAGE REJECT. Indicates to the initiator or the scanner that the
         last message received was inappropriate or has not been implemented.
 
  08h    NO OPERATION. Sent by the initiator to indicate that it has no message
         to send in response the scanner's request for a message.
 
  09h    MESSAGE PARITY ERROR. Sent by the initiator to indicate that the last
         message byte received contained a parity error.
 
  0Ch    BUS DEVICE RESET. Sent by the initiator to clear all operations on the
         scanner; forces a hard reset.
 
C0h/80h  IDENTIFY message sent to establish a connection to a routine on the
         scanner and to indicate that the scanner may (C0h) or may not (80h)
         disconnect.
2.5  Special Considerations
 
Microtek SCSI scanners accept commands in SCSI Group 0 format. Command contents
and data formats are described in detail in the following chapter. Below are
some things to keep in mind when writing software for these scanners.
 
1. A single pass of the scanning "frame" (the area to be scanned) is carried
   out in three basic steps: first the START/STOP SCAN command is issued to
   bring the image sensor into starting position; then the GET SCAN STATUS
   command is sent to make sure the scanner is ready and to get the line width
   and the total number of lines; and finally, the READ SCANNED DATA command is
   issued one or more times to have material scanned and the data transferred
   to the host. Except on one-pass color scanners, color scanning requires
   three such passes.
 
2. Using two or more READ SCANNED DATA commands to complete a single pass (see
   preceding) is referred to as "segment scanning." Before the READ SCANNED
   DATA command is issued for each image segment, it is good programming
   practice to issue the GET SCAN STATUS command and make sure the scanner is
   ready. If the READ SCANNED DATA command is sent directly and the scanner is
   not ready, the scanner will return CHECK CONDITION in the Status phase and
   report "scanner busy" upon receiving the REQUEST SENSE command.
 
   Note that when the paper length and scanning frame are set in units of 1/8"
   and segment scanning is used, no segment may be less than 1/8" in height.
 
3. After the initiator has sent the START/STOP SCAN command (with a Start bit
   of 1 to indicate "start"), the only commands that can be issued before the
   pass is complete are GET SCAN STATUS, READ SCANNED DATA and START/STOP SCAN
   (with a Start bit of 0 to indicate "stop"). Any other command will be
   considered an error, and will cause a COMMAND/DATA ERROR flag to be set.
 
4. When scanning is aborted during a pass, it takes time for the scanner to
   return the carriage to the starting position. If any command is issued
   during this time the scanner will return CHECK CONDITION in the Status phase
   and report "scanner busy" upon receiving the REQUEST SENSE command.
 
5. Microtek SCSI scanners adopt the hard reset alternative.
 
6. Should the reset condition occur during a scanning pass, the scanner will
   abort scanning and reset itself. Until the reset is complete, issuance of
   any command will cause the scanner to return CHECK CONDITION in the Status
   phase and report "scanner busy" upon receiving the REQUEST SENSE command.
 2.6  Command List
 
Microtek SCSI scanners support the following SCSI Group 0 commands for image
scanning devices:
 
                                            Operation    Command
    Command Name                              Code        Type*
    """"""""""""""""""""""""""              """""""""    """""""
    TEST UNIT READY                            00h          M
    REQUEST SENSE                              03h          M
    SCANNING FRAME                             04h          V
    READ SCANNED DATA                          08h          V
    GET SCAN STATUS                            0Fh          V
    ACCESSORY & BACKTRACKING                   10h          O
    INQUIRY                                    12h          M
    MODE SELECT                                15h          O
    MODE SELECT 1                              16h          O
    MODE SENSE 1                               19h          O
    MODE SENSE                                 1Ah          O
    START/STOP SCAN                            1Bh          M
    RECEIVE DIAGNOSTIC RESULTS                 1Ch          M
    SEND DIAGNOSTIC                            1Dh          O
    LOOK-UP TABLE DOWNLOAD                     55h          O
 
 
  *Command Type Details:
 
     E   Meets "extended requirement" of the SCSI standard (enables software to
         determine scanner characteristics and configure itself accordingly).
 
     M   Command implementation is mandatory.
 
     O   Command implementation is optional.
 
     V   Operation code available for vendor-unique commands.
 
 
All codes from 00h through 55h not listed above are either reserved for future
standardization or not used.
                                                                                
 
Chapter 3: Command Descriptions
 
 
3.1  TEST UNIT READY Command
 
Operation Code ...:  00h
 
Type .............:  Mandatory
 
Purpose ..........:  To see if the scanner is ready. If the scanner is ready
                     for operation, it will return GOOD in the Status phase;
                     otherwise it will return CHECK CONDITION or BUSY.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     00h
    1                                     00h
    2                                     00h
    3                                     00h
    4                                     00h
    5                                     00h
                                                                               3.2  REQUEST SENSE Command
 
Operation Code ...:  03h
 
Type .............:  Mandatory
 
Purpose ..........:  To request the scanner to return sense data. Note that
                     some error conditions will be cleared upon completion of
                     this command.
 
The host should issue the REQUEST SENSE command after any communication
cycle in which the scanner returns CHECK CONDITION in the Status phase.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     03h
    1                                     00h
    2                                     00h
    3                                     00h
    4                                     TL
    5                                     00h
 
TL (Transfer Length) is the number of data bytes that the host will send to the
scanner during the Data Out phase.
 
Details of Returned Sense Data
 
COMMAND/DATA ERROR Message
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     81h
    1    --------------------Reserved, 0---------------------  TooMany  SCSIcmd
    2                                     00h
    3                                     00h
 
A one-bit in byte 1 of this message denotes an error as indicated below:
 
Bit 0:  SCSI command or data error.
Bit 1:  Too many lines requested in a READ SCANNED DATA command.
                                                                               Details of returned REQUEST SENSE data, continued
 
SCANNER HARDWARE ERROR Message
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     82h
    1    FdrEjct  ScnM/Sn  Lmp/CCD   DCofs   Rsvd, 0  ImgRAM   SysRAM   CPURAM
    2    -------Reserved, 0-------  FltM/Sn  FdrFeed  TxpM/Sn  TxpLmp   ExtPwr
    3                                     00h
 
One-bits in byte 1 of this message denote the errors indicated below:
 
Bit 0: CPU RAM failure.
Bit 1: Scanner system RAM failure.
Bit 2: Image RAM failure (image buffer or ping-pong buffer).
Bit 4: DC offset error (black level calibration failure).
Bit 5: Scanning lamp or image sensor circuit failure.
Bit 6: Scanning head motor or home position sensor failure.
Bit 7: Automatic document feeder paper ejection failure.
 
One-bits in byte 2 of this message denote the errors indicated below:
 
Bit 0: External power (e.g., feeder or illuminator power adapter) failure.
Bit 1: Transparency illuminator lamp failure.
Bit 2: Transparency illuminator motor or home position sensor failure.
Bit 3: Feeder paper feeding failure (see also OPERATION ERROR message, below).
Bit 4: Filter motor or filter position sensor failure.
 
OPERATION ERROR Message
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     83h
    1    ExpTime  HiMidSh  PprLnth   Contr   Rsvd, 0  ScnFram   Rsltn    Grain
    2    -------Reserved, 0-------  Bits/Px  Offset    Gamma   NoPaper  Fdr+Flt
    3                                     00h
 
One-bits in bytes 1 and 2 of this message denote operation errors as indicated
below. Note that all illegal settings will automatically be replaced by default
settings.
 
Byte 1
 
Bit 0: Illegal grain setting.
Bit 1: Illegal resolution setting.
Bit 2: Illegal scanning frame coordinate.
Bit 4: Illegal contrast setting.
Bit 5: Illegal paper length setting.
Bit 6: Illegal highlight/midtone/shadow adjustment setting.
Bit 7: Illegal exposure time (analog brightness adjustment) setting.
 Details of returned REQUEST SENSE data, continued
 
OPERATION ERROR Message, Byte 2
 
Bit 0: Color filter specified with automatic document feeder selected.
Bit 1: No paper in feeder.
Bit 2: Illegal look-up table (gamma adjustment) setting.
Bit 3: Illegal offset (digital brightness adjustment) setting.
Bit 4: Illegal bits-per-pixel setting.
 
 3.3  SCANNING FRAME Command
 
Operation Code ...:  04h
 
Type .............:  Vendor Unique
 
Purpose ..........:  To send scanning frame and user-defined halftoning pattern
                     settings to the scanner.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     04h
    1                                     00h
    2                                     00h
    3                                     00h
    4                                     TL
    5                                     00h
 
TL (Transfer Length) is the number of data bytes that the host will send to the
scanner during the Data Out phase.
 
Data Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                Frame Header
    1                                  X11 (LSB)
    2                                  X12 (MSB)
    3                                  Y11 (LSB)
    4                                  Y12 (MSB)
    5                                  X21 (LSB)
    6                                  X22 (MSB)
    7                                  Y21 (LSB)
    8                                  Y22 (MSB)
    9                               Usr HT Pat Header
   10                              Usr HT Pat Sz Indic
   11                                      P1
   12                                      P2
    .                                       .
    .                                       .
    .                                       .
    .                                      Pn
 
The frame is the area to be scanned. The scanning frame is set within an area
8-1/2" wide and 14" long on most models. The coordinate values (0000h,0000h)
express the top left corner of this area; higher values express distance from
this point in units of 1/8" or one pixel. (X1n,Y1n) are the coordinates of the
top left corner, and (X2n,Y2n) those of the bottom right corner, of the frame.
 
A user-defined halftoning pattern need not be sent with the frame setting, but
if both are sent the pattern must follow the frame data. Sending this command
with no frame setting resets the scanning frame and setting unit to the
defaults (frame size 8-1/2" by 11" [or the maximum for the scanner in use],
setting unit 1/8").
                                                                               Details of SCANNING FRAME Data
 
Frame/Pattern Header Bit Definition
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
 """"""  """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
 0 or 9   Frame    UsrHT   --Reserved, 0---  1/8"/Px  --Reserved, 0---   LA/HT
 
One- and zero-bits in SCANNING FRAME headers identify and define the associated
data blocks as follows:
 
Bit 0: Background identifier; 0 = line art, 1 = halftone. Valid in frame header
       only.
 
Bit 3: Frame setting unit identifier; 0 if frame coordinates represent units of
       1/8", 1 if they represent pixel units.
 
Bit 6: User-defined halftoning pattern identifier; 0 in the frame header, 1 in
       user halftoning pattern header.
 
Bit 7: Frame identifier; 0 in both frame and pattern headers.
 
Frame Header
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0       0        0     --Reserved, 0---  1/8"/Px  --Reserved, 0---   LA/HT
 
User-defined Halftoning Pattern Header (Byte 9)
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    9       0        1     --Reserved, 0---     0     --Reserved, 0---     0
  
User-defined Halftoning Pattern Size Indicator (Byte 10)
 
Size of Pattern:   2 x 2    3 x 3    4 x 4 . . . 8 x 8
Indicator Value:    22h      33h      44h  . . .  88h
 Details of SCANNING FRAME data, continued
 
Downloading Sequence for Halftoning Values
 
When the user-defined halftoning pattern size indicator is 44h, downloaded
halftoning values are arranged as follows to create a halftoning screen:
 
                                ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿
                                ³P1 ³P2 ³P3 ³P4 ³
                                ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´
                                ³P5 ³P6 ³P7 ³P8 ³
                                ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´
                                ³P9 ³P10³P11³P12³
                                ÃÄÄÄÅÄÄÄÅÄÄÄÅÄÄÄ´
                                ³P13³P14³P15³P16³
                                ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ
 
It is recommended that values P1 through Pn always be in the range of 22h
through C0h.
                                                                               3.4  READ SCANNED DATA Command
 
Operation Code ...:  08h
 
Type .............:  Vendor Unique
 
Purpose ..........:  To read image data from the scanner. Image data can be
                     requested all at once or in segments, using a separate
                     READ SCANNED DATA command for each successive segment.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     08h
    1                                     00h
    2                                  TL1 (MSB)
    3                                     TL2
    4                                  TL3 (LSB)
    5                                     00h
 
TL1, TL2 and TL3 together specify the number of lines to be transferred to the
host for the segment about to be scanned. This value must not be greater than
the value returned in response to the GET SCAN STATUS command, or the scanner
will return CHECK CONDITION in the Status phase.
 
Segments in the same scanning frame need not be equal in height. When scanning
frame and paper length settings have been sent in units of 1/8", however, each
segment must be 1/8" or more in height.
 
While scanning is still incomplete, the only commands that the scanner will
accept are READ SCANNED DATA, GET SCAN STATUS and START/STOP SCAN (with a Start
bit of 0 to abort scanning; note that scanning can also be aborted by means of
the -RST signal). If any other command is sent, the scanner will invoke the
Status phase and report a CHECK CONDITION status. The REQUEST SENSE command
will be accepted at this time. The scanner will return a COMMAND/DATA ERROR
message and remain in segment scanning condition.
 
The number of lines requested in the READ SCANNED DATA command must not exceed
the number of lines remaining in the scanning frame. If more lines are
requested than remain, the scanner will invoke the Status phase and return a
CHECK CONDITION status; then, when the REQUEST SENSE command is received, a
COMMAND/DATA ERROR message will be returned with bit 1 of byte 1 set to
indicate "too many lines requested." The initiator can then issue the GET SCAN
STATUS command to find out the number of lines remaining in the current scan,
or abort the scan by issuing the START/STOP SCAN command with a Start bit of 0.
                                                                               3.5  GET SCAN STATUS Command
 
Operation Code ...:  0Fh
 
Type .............:  Vendor Unique
 
Purpose ..........:  To check the progress of a scan. This command is unique to
                     Microtek image scanners. It is used only when the scanner
                     is in the scanning state.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     0Fh
    1                                     00h
    2                                     00h
    3                                     00h
    4                                  TL (06h)
    5                                     00h
 
Format of Returned Data
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                   Rdy/Bsy
    1                                  LW1 (LSB)
    2                                  LW2 (MSB)
    3                                  RM1 (LSB)
    4                                     RM2
    5                                  RM3 (MSB)
 
Key: Rdy/Bsy = Scanner ready/busy indicator. 00h to indicate that the scanner
               is ready to transmit image data, 01h to indicate that the
               scanner is busy.
 
          LW = Line width. At fewer than eight bits per pixel, the number of
               bytes per scan line; at eight or more bits per pixel, the number
               of pixels plus the number of data header bytes per scan line
               (for information on data headers see byte 69 of returned INQUIRY
               data). Valid only when Rdy/Bsy is 00h.
 
               Examples: When resolution is 300 dpi and the frame is one inch
               wide, LW can have the following values:
 
                                             Single-bit scanning (line art or halftone):0026h (38 [300/8]) 
                                             Nibble mode (four bits per pixel):0096h (150 [300/2])
                                             Other multi-bit modes with no data headers:012Ch (300)        
                                             Multi-bit color scanning with data headers:012Eh (302)        
 
         RM =  Number of lines remaining in the current image. Valid only when
               Rdy/Bsy is 00h.
3.6  ACCESSORY & BACKTRACKING Command
 
Operation Code ...:  10h
 
Type .............:  Optional
 
Purpose ..........:  To enable/disable an automatic document feeder or a
                     transparency illuminator; to enable/disable "backtracking"
                     (retrograde carriage motion between image segments).
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     10h
    1                                     00h
    2                                     00h
    3                                     00h
    4    BckEnbl  FdrEnbl  TxpEnbl  PreEnbl  PreSlct  TxpSlct  BckSlct  FdrSlct
    5                                     00h
 
One- and zero-bits in byte 4 control scanner operation as follows:
 
Bit 0: 0 = deselect, 1 = select, automatic document feeder.
 
Bit 1: 0 = do not allow, 1 = allow, backtracking.
 
       When allowed, the scanner will automatically backtrack between segments
       in segment scanning (see section 2.5 and the READ SCANNED DATA command).
       Segment scanning without backtracking can result in smearing.  
 
Bit 2: 0 = deselect, 1 = select, transparency illuminator.
 
Bit 3: 0 = turn off, 1 = turn on, prescan mode.
 
       Prescan mode results in much faster, but less accurate, recalibration
       and scanning, and is designed for capturing a low-resolution preview
       image of the material to be scanned.
 
Bit 4: 0 = disregard bit 3 and retain current setting; 1 = decode bit 3.
 
Bit 5: 0 = disregard bit 2 and retain current setting; 1 = decode bit 2.
 
Bit 6: 0 = disregard bit 0 and retain current setting; 1 = decode bit 0.
 
Bit 7: 0 = disregard bit 1 and retain current setting; 1 = decode bit 1.
                                                                               3.7  INQUIRY Command
 
Operation Code ...:  12h
 
Type .............:  Mandatory
 
Purpose ..........:  To determine scanner type and capabilities.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     12h
    1                                     00h
    2                                     00h
    3                                     00h
    4                               TL (05h or 60h)
    5                                     00h
 
Format of Returned Data
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                        Peripheral Device Type (06h)
    1                        SCSI Firmware Version Number
    2                       Scanner Firmware Version Number
    3                         Response Data Format (01h)
    4                           Additional Length (5Bh)
  5, 6                              Reserved (00h)
    7                             SCSI Options (00h)
  8-15                       Vendor Identification (ASCII)
  16-31                     Product Identification (ASCII)
  32-35                     Product Revision Level (ASCII)
  36-55                             Vendor Specific
   56                            Resolution Selections
   57                          Scanning Mode Selections
   58                              Grain Selections
   59                                Data Forming
   60                            Maximum Document Size
   61                    Contrast and Exposure Time Selections
   62                                 Model Code
   63                     Feeder and Illuminator Information
   64                       Expanded Resolution Range Flag
   65                  Shadow/Midtone/Highlight Adjustment Flag
   66                    Look-up Table (Gamma Adjustment) Flag
   67                           Fast Color Prescan Flag
   68                               Reserved (00h)
   69                            Color Data Sequencing
   70                               Reserved (00h)
   71                     MODE SELECT 1 Command Support Flag
   72                        Expanded Contrast Selections
   73                      Expanded Exposure Time Selections
   74                           Multi-bit Data Formats
   75                            MODE SELECT 1 Options
  76-94                             Reserved (00h)
   95                               Reserved (FFh)                             Details of Returned INQUIRY Data
 
Byte 0 "" Peripheral Device Type
 
Byte 0 is 06h to indicate a "scanner device."
 
 
Byte 1 "" SCSI Firmware Version Number
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    1    -------Major Version Number-------  -------Minor Version Number-------
 
The high nibble of byte 1 indicates the major, and the low nibble the minor,
version number of the SCSI communication firmware being used. A value of 23h,
for instance, indicates version 2.3.
 
 
Byte 2 "" Scanner Firmware Version Number
 
Byte 2 indicates the version number of the scanner engine firmware. It is in
the same format as byte 1 (see preceding). As the full version number can run
to three digits, the driver should check bytes 32 through 35.
 
 
Byte 3 "" Response Data Format
 
Byte 3 is 00h for scanners that return INQUIRY data in standard SCSI I format,
02h for scanners that use standard SCSI II format. A value of 01h indicates an
intermediate format compatible with many products developed before the
introduction of SCSI II.
 
 
Byte 7 "" SCSI Options
 
This byte is currently 00h, indicating that the scanner does not support the
RelAdr, WBus32, WBus16, Sync, Linked, CmdQue and SftRe options.
 
 
Bytes 8 through 15 "" Vendor Identification
 
Bytes 8 through 15 are the ASCII values for MICROTEK.
 
 
Bytes 16 through 31 "" Product Identification
Bytes 32 through 35 "" Product Revision Level
 
These are ASCII strings indicating scanner model and version. The version
number is in the format X.XX, where X is 0-9 (30h-39h).
 
 
Bytes 36 through 55 "" Vendor Specific
 
Bytes 36 through 55 contain an ASCII string of vendor-determined content and
purpose, for example SCSI F/WV3.0 CTL5380.
                                                                               Details of returned INQUIRY data, continued
 
Byte 56 "" Resolution Selections
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
   56    --------------------Reserved, 0---------------------    5%       1%
  
A one-bit indicates that resolution can be set in multiples of 1% or 5% of
maximum (as expressed in dpi). For details see "Byte 1 "" Resolution Setting
Register" in the description of the MODE SELECT command (next section).
 
Byte 57 "" Scanning Mode Selections
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
   57     Negtv   OnePass  Trnsmsv    00h     Color   MultBit  Hlftone  LineArt
 
A one-bit indicates that the corresponding scanning or processing method is
offered. Bit 2 is 1 for scanners that can return more than 1 bit per pixel; see
also "Byte 74 "" Multi-bit Data Formats." Bit 5 is 1 for dedicated slide/
transparency scanners only. Bit 6 refers to one-pass color scanning.
 
"Mode" as used here is unrelated to the MODE SELECT command. Halftone and line
art are processing methods specified with the SCANNING FRAME command in
single-bit scanning; pixel depth (single- or multi-bit) and color are specified
with the START/STOP SCAN command.
 
Byte 58 "" Grain Selections
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
   58    DnLoad   --------------------------Built-in---------------------------
 
Bits 0 through 6 indicate the number of built-in grain selections (that is,
halftoning patterns or "dithers") offered by the scanner. Bit 7 is 1 if the
scanner supports downloading of halftoning patterns, 0 if it does not.
 
Byte 59 "" Data Forming
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
   59    PxlSet   1/8"Set  RdCompr  HfCompr  Rsvd, 0  AutoFdr  PprMvmt  SnsMvmt
 
A one-bit denotes that the scanner has the indicated feature:
 
Bit 0: Line advance by sensor movement ("flatbed" type).
Bit 1: Line advance by paper movement ("edge feed" type).
Bit 2: Automatic document feeder support.
Bit 3: Reserved.
Bit 4: Data compression by modified Huffman code.
Bit 5: Data compression by modified Read code.
Bit 6: Accepts frame and paper length settings in 1/8" units.
Bit 7: Accepts frame and paper length settings in pixel units.
                                                                               Details of returned INQUIRY data, continued
 
Byte 60 "" Maximum Document Size
 
The following values are currently defined for byte 60:
 
          00h = 8.5" x 14" (legal size)               80h = 35 x 35 mm
          01h = 8.5" x 11" (letter size)              81h = 5" x 5"
          02h = 8.5" x 11.69"                         82h = 36 x 36 mm
          03h = 8.5" x 13"
          04h = 8.0" x 10"
          05h = 8.3" x 14"              
          06h = 8.3" x 13.5"
          07h = 8.0" x 14"
 
Byte 61 "" Contrast and Exposure Time Selections
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
   61    ---Number of Contrast Settings----  -Number of Exposure Time Settings-
 
The high nibble of byte 61 indicates the number of contrast settings, and the
low nibble the number of exposure time (analog brightness adjustment) settings,
offered by the scanner.
 
Byte 62 "" Model Code
 
            50h = ScanMaker II/IIXE     5Ah = StudioScan           
            51h = ScanMaker 45t         5Bh = StudioScan II              
            52h = ScanMaker 35t         5Ch = Arcus II                   
            54h = ScanMaker IISP        5Dh = Phantom                    
            55h = ScanMaker IIER        5Eh = SS3                        
            56h = ScanMaker A3t         5Fh = TR1                        
            57h = ScanMaker IIHR        60h = HR1    
            58h = ScanMaker IIG         61h = 45T-Plus    
            59h = ScanMaker III         62h = 35T-LE     
                                        63h = HR1-10bit
                                        64h = TR1 3Pass
                                        65h = Jupiter
                                        66h = HR1-10bit Philip
                                        67h = TR3
                                        68h = Saturn X-Ray
                                        69h = Phantom X-Ray
                                                          
                                                          
Byte 63 "" Feeder and Illuminator Information             
                                                          
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
   63       0     TxpInst  ----Typ/Loc-----  Out/Rdy  FdrInst  S/Wslct  F/Wsupp
 
Bit 0: 0 = F/W does not support, 1 = F/W does support, document feeder.
 
Bit 1: 0 = F/W does not support, 1 = F/W does support, feeder/backtracking
       enable/disable (ACCESSORY & BACKTRACKING) command.
 
Bit 2: 0 = feeder not installed; 1 = feeder installed (determined at POST).
 
Bit 3: 0 = feeder not ready (i.e., out of paper); 1 = feeder ready.
 
Bits 4 and 5 indicate the type and location of the document the scanner is
currently set to scan (default values are determined at POST; note that a
feeder and a transparency illuminator cannot be installed at the same time):
 
     Bit 5   Bit 4   Document Type and Location
     """""   """""   """"""""""""""""""""""""""""""""""""""""""""""""""""""""""
       0       0     opaque document lying flat on document glass.
       0       1     opaque document in feeder (default if feeder is detected).
       1       0     transparency (default if illuminator is detected).
 
Bit 6: 0 = no transparency illuminator installed; 1 = illuminator installed.
                                                                               Details of returned INQUIRY data, continued
 
Byte 64 "" Expanded Resolution Range Flag
 
Byte 64 is 01h if the scanner offers an expanded range of resolution settings,
00h if it does not. For details see "Byte 1 "" Resolution Setting Register" in
the description of the MODE SELECT command (next section).
 
 
Byte 65 "" Shadow/Midtone/Highlight Adjustment Flag
 
Bit 0: 0 if unit does not support shadow/highlight adjustment, 1 if it does.
 
Bit 1: 0 if unit does not support midtone adjustment, 1 if it does.
 
TL (Transfer length) in the MODE SELECT command (next section) will be 0Ah if
bit 1 is 0, 0Bh if bit 1 is 1. Bits 2 through 7 are reserved (0).
 
 
Byte 66 "" Look-up Table (Gamma Adjustment) Flag
 
Bit 0: 1 =   256-entry table supported; 0 = look-up table not supported.
Bit 1: 1 =  1024-entry table  supported (256-entry table  also supported).
Bit 2: 1 =  4096-entry table  supported  (smaller  tables also supported).
Bit 3: 1 = 65536-entry table  supported  (smaller  tables also supported).
 
     Bit 7   Bit 6   Bit 5    Gamma Value Range    Entry Length
     """""   """""   """""    """""""""""""""""    """"""""""""
       0       0       0       0 through   255        1 byte
       0       0       1       0 through  1023        2 bytes
       0       1       0       0 through  4095        2 bytes
       0       1       1       0 through 65535        2 bytes
 
Bit 4 is reserved (0).
 
 
Byte 67 "" Fast Color Prescan Flag
 
"Fast color prescanning" in the case of a three-pass color scanner means
bottom-to-top green-plane capture on the return stroke between normal-
direction passes for red and blue. Bit 0 is 1 if the scanner supports this
feature, 0 if it does not. The remaining bits are reserved (0).
 
 
Byte 68 "" Data Transfer Format
 
Bit 0 of byte 68 is 1 if the scanner allows selection of transfer format (low
byte first or high byte first) for image and look-up table (gamma adjustment)
data.
Details of returned INQUIRY data, continued
 
Byte 69 "" Color Data Sequencing
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
   69     3pass   -----------------Color Data Sequencing Value-----------------
 
Bits 6-0: 00h = Plane by plane (three-pass color scanner).
          01h = Pixel by pixel.
          02h = Line by line, in R-G-B sequence, with no data headers.
          03h = Line by line, in non-R-G-B sequence, with data headers.
 
          A scan line data header consists of two bytes. The first is reserved
          and must be treated as "don't care"; the second is the ASCII value
          for R, G or B.
 
   Bit 7: 0 if the unit supports three-pass color scanning, 1 if it does not
          (e.g., a single-pass-only color scanner).
 
 
Byte 71 "" MODE SELECT 1 Command Support Flag
 
Bit 0 of byte 71 is 0 if the scanner does not support the MODE SELECT 1 and
MODE SENSE 1 commands, 1 if it does. Bits 1 through 7 are reserved (0).
 
 
Byte 72 "" Expanded Contrast Selections
 
Byte 72 contains the number of possible contrast settings (cntr_vals) if this
is greater than the number in the base range. The base range is -42% through
+49% in 14 steps of 7% each; an expanded range allows settings in excess of
+49%, up to a maximum percentage figure (max_cntr) that can be derived as
follows:
 
                          max_cntr = (cntr_vals*7 - 49)
 
 
Byte 73 "" Expanded Exposure Time Selections
 
Byte 73 contains the number of possible exposure time (analog brightness
adjustment) settings (exp_vals) if this is greater than the number in the base
range (-18% through +21% in 14 steps of 3% each). An expanded range allows
settings greater than +21%, up to a maximum percentage figure (max_exp) that
can be derived as follows: 
 
                           max_exp = (exp_vals*3 - 21)
 
 
Byte 74 "" Multi-bit Data Formats
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
   74    -----------Reserved, 0------------  16b/pxl  12b/px   10b/pxl  4b/pxl
 
A one-bit indicates that the scanner supports the specified number of bits per
pixel (4, 10, 12 or 16). Support for 1- and 8-bit data formats is indicated by
byte 57 (Scanning Mode Selections, above).
                                                                               Details of returned INQUIRY data, continued
 
Byte 75 "" MODE SELECT 1 Options
 
One-bits in byte 75 indicate support for MODE SELECT 1 command options as
follows:
 
Bit 0: 1 = offset adjustment (i.e., digital brightness control) supported.
 
Bit 1: 1 = linearization table (a means of compensating for certain
       characteristics of optoelectronic systems) can be disabled.
 
Bit 2: 1 = start-of-scan recalibration function can be disabled.
3.8  MODE SELECT Command
 
Operation Code ...:  15h
 
Type .............:  Optional
 
Purpose ..........:  To send mode, resolution, shading, velocity and paper
                     length settings to the scanner.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     15h
    1                                     00h
    2                                     00h
    3                                  TL1 (MSB)
    4                                  TL2 (LSB)
    5                                     00h
 
TL (Transfer Length, i.e., the number of bytes that the host will send to the
scanner during the Data Out phase) must be 000Ah if bit 1 of returned INQUIRY
data byte 65 is 0, 000Bh if this bit is 1 (see preceding section).
 
Data Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                            Mode Setting Register
    1                         Resolution Setting Register
    2                       Exposure Time Setting Register
    3                          Contrast Setting Register
    4                           Grain Setting Register
    5                          Velocity Setting Register
    6                     Shadow Adjustment Setting Register
    7                    Highlight Adjustment Setting Register
    8                             Paper Length (LSB)
    9                             Paper Length (MSB)
   10                     Midtone Adjustment Setting Register
 
Details of MODE SELECT Data
 
Byte 0 "" Mode Setting Register
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0    Rsvd, 1  ----ColrCode----   HTSrc    PprLn   Rsvd, 0   Rsltn   Rsvd, 1
 
Bit 1: Resolution setting increment; 0 = 5% of maximum, 1 = 1% of maximum.
Bit 3: Paper length setting unit; 0 = 1/8", 1 = pixel.
Bit 4: Halftoning pattern source; 0 = built-in, 1 = downloaded.
 
ColrCode (bits 5 and 6) is used only for a one-pass color scanner, and must be
zeroed for all other scanner types. ColrCode is 00h for gray or all three
primaries, 01h for red, 02h for green, 03h for blue.
 
Note that reserved bits 0 and 7 must be 1, while bit 2 must be 0.              Details of MODE SELECT data, continued
 
Byte 1 "" Resolution Setting Register
 
Each Microtek SCSI scanner offers a base resolution range of up to 300 dpi or
more. Returned INQUIRY data bytes 56 and 64 indicate the step size(s) in which
resolution can be set (byte 56) and whether the scanner offers an expanded
resolution range (byte 64) of up to 600 dpi or more. When both step sizes (5%
and 1%) are available, the step size is set with MODE SELECT data byte 0, bit
1; when both ranges (base and expanded) are available, the range is selected
with START/STOP SCAN command byte 4, bit 7.
 
When resolution is set in steps of 5% of maximum, MODE SELECT data byte 1 must
be a hexadecimal number (nnh) with a minimum value (min_val) of 10h (300- and
600-dpi models) or 20h (400- and 800-dpi models) and a maximum value of min_val
+ 0Fh, specifying resolution as shown below (note that resolution decreases as
nnh increases in the selected range):
 
     nnh = min_val + (max_in_range - desired_level) / (max_in_range * 0.05)
 
If the base range goes up to 300 dpi, for example, nnh would be 11h to specify
a resolution of 285 dpi: 10h + (300 - 285) / (300 * 0.05) = 11h.
 
In cases where max_in_range is 300 or 600, exceptions are made for values of
min_val + 07h and min_val + 0Dh in order to support resolution levels of 100,
200 and 400 dpi.
 
When resolution is set in steps of 1% of maximum, MODE SELECT data byte 1 must
be a hexadecimal value from 64h through 01h (decimal 100 through 1) directly
expressing the desired percentage (100% through 1%) of the highest level in the
selected range.
 
The default scanning resolution is the highest level in the range selected with
the START/STOP SCAN command.
 
 
Byte 2 "" Exposure Time Setting Register
 
                Setting   Adjustment    |    Setting   Adjustment
                """""""   """"""""""    |    """""""   """"""""""
                  01h        -18%       |      08h         +3%
                  02h        -15%       |      09h         +6%
                  03h        -12%       |      0Ah         +9%
                  04h         -9%       |      0Bh        +12%
                  05h         -6%       |       .           .  
                  06h         -3%       |       .           . 
                  07h          0%       |       .           .  
 
The exposure time (analog brightness adjustment) setting is effective in all
scanning modes except on very early-model G series units, where it does not
affect multi-bit scanning.
Details of MODE SELECT data, continued
 
Byte 3 "" Contrast Setting Register
 
                Setting   Adjustment    |    Setting   Adjustment
                """""""   """"""""""    |    """""""   """"""""""
                  01h        -42%       |      08h         +7%
                  02h        -35%       |      09h        +14%
                  03h        -28%       |      0Ah        +21%
                  04h        -21%       |      0Bh        +28%
                  05h        -14%       |      0Ch        +35%
                  06h         -7%       |      0Dh        +42%
                  07h          0%       |      0Eh        +49%
 
The contrast setting is effective in halftone-mode scanning on all models, and
in multi-bit scanning on gray-scale and color scanners that can perform shadow/highlight and look-up table (image gamma) adjustments.
 
 
Byte 4 "" Grain Setting Register
 
                      Grain   Gray      |               Grain   Gray
            Setting   Size   Levels     |     Setting   Size   Levels
            """""""   """""  """"""     |     """""""   """""  """"""
              00h     8 x 8    53       |       06h     5 x 5    26
              01h     8 x 8    65       |       07h     4 x 4    17
              02h     8 x 8    65       |       08h     4 x 4    17
              03h     8 x 8    33       |       09h     4 x 4    17
              04h     6 x 6    29       |       0Ah     3 x 3    10
              05h     5 x 5    26       |       0Bh     2 x 2     5
 
The grain setting determines the halftoning pattern used in single-bit scanning
when the scanning frame is set for halftone processing and the halftoning
pattern source is set to "built-in."
 
 
Byte 5 "" Velocity Setting Register
 
Sending a value n in this register sets minimum scanning time per line of image
data to n times 3 milliseconds. Effective settings are 01h through 07h; the
default setting is 01h. Lower speeds (higher settings) can be used to prevent
deterioration of image quality when the host's receiving buffer is small and
the image must be scanned in segments (see description of the READ SCANNED DATA
command, section 3.4).
 
 
Byte 6 "" Shadow Adjustment Setting Register
 
When scanning is in multi-bit mode and the scanner supports shadow adjustment,
sending a value other than 00h in this register makes the darkest scanned
shades (all raw pixel values equal to or less than the register value) come out
as pure black (00h) and linearly maps the remaining scanned shades (all raw
pixel values greater than the shadow adjustment register value and less than
the highlight adjustment register value) into the range of 00h through FFh.
                                                                               Details of MODE SELECT data, continued
 
Byte 7 "" Highlight Adjustment Setting Register
 
When scanning is in multi-bit mode and the scanner supports highlight
adjustment, sending a value other than FFh in this register makes the lightest
scanned shades (all raw pixel values equal to or greater than the register
value) come out as pure white (FFh) and linearly maps the remaining scanned
shades (all raw pixel values less than the highlight adjustment register value
and greater than the shadow adjustment register value) into the range of 00h
through FFh.
 
 
Bytes 8 and 9 "" Paper Length
 
These two bytes should equal the length, in the unit indicated by bit 3 of the
Mode Setting Register, of the document to be scanned.
 
 
Byte 10 "" Midtone Adjustment Setting Register
 
When scanning is in multi-bit mode and the scanner supports midtone adjustment,
sending a value other than 80h in this register causes all raw scanned values
from 00h (or the shadow adjustment register value) through the midtone
adjustment register value minus one to be mapped linearly into the range of 00h
through 7Fh, and all raw scanned values from the midtone adjustment register
value through FFh (or the highlight adjustment register value) to be mapped
linearly into the range of 80h through FFh.
 
 
Notes
 
1. When the Rsltn bit (bit 1) of the Mode Setting Register (byte 0) is set to
   0, be sure to set the Resolution Setting Register (byte 1) to a legal value
   (10h through 1Fh or 20h through 2Fh) for setting resolution in steps of 5%
   of maximum. When the Rsltn bit is set to 1, make sure the Resolution Setting
   Register contains a value from 64h through 01h (decimal 100 through 1).
 
2. When the PprLn bit (bit 3) of the Mode Setting Register (byte 0) is set to
   0, be sure to set the Paper Length bytes (bytes 8 and 9) to a value
   representing paper length in units of 1/8". When the PprLn bit is set to 1,
   make sure bytes 8 and 9 indicate paper length in units of one pixel.
 
3. When the HTSrc bit (bit 4) of the Mode Setting Register (byte 0) is set to
   0, be sure to set the Grain Setting Register (byte 4) to the value
   representing the desired built-in grain setting (00h-0Bh).
                                                                               3.9  MODE SELECT 1 Command
 
Operation Code ...:  16h
 
Type .............:  Optional
 
Purpose ..........:  To send offset (digital brightness adjustment), pixel
                     depth and data format settings to the scanner; to disable
                     or re-enable the scanner's linearization table and/or its
                     start-of-scan recalibration feature.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     16h
    1                                     00h
    2                                     00h
    3                                     00h
    4                                     0Ah
    5                                     00h
 
Data Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0       0     ----ColrCode----  ----------------Reserved, 0----------------
    1                                    Offset
    2    XferFmt  -------Reserved, 0-------  16b/pxl  12b/pxl  10b/pxl  4b/pxl
    3    ----------------Reserved, 0-------  QuickCal ImmCal   DsblCal  DsblIGa
   4-9                                Reserved, 0
 
Details of MODE SELECT 1 Data
 
Byte 0 "" One-pass Color Capture Control
 
ColrCode in byte 0 controls color capture on a one-pass color scanner, and must
be zeroed for all other scanner types. Taking bit 5 as the least significant
bit, ColrCode is 00h for gray or all three primaries, 01h for red, 02h for
green, 03h for blue.
 
Byte 1 "" Digital Brightness Adjustment Control
 
For scanners that support digital brightness adjustment, byte 1 can be in the
range of 00h through 64h to specify a +0% through +100% increase, or 9Ch
through FFh to specify a -100% through -1% decrease, in image brightness.
 
Byte 2 "" Pixel Depth and Data Format Control
 
A one-bit in the lower nibble of byte 2 commands the scanner to generate the
indicated number of data bits per pixel (4, 10, 12 or 16). Note that for 10 or
12 bits, the scanner sends the host two bytes per pixel, with image data
occupying the low bits and the high bits zeroed.
 
XferFmt is 0 to specify low byte first (PC format), 1 to specify high byte
first (Macintosh format).
                                                                               Details of MODE SELECT 1 data, continued
 
Byte 3 "" Linearization Table and Recalibration Control
 
Bit 0: 0 = enable, 1 = disable, linearization table.
 
       The linearization table, on by default, is used to compensate for
       certain characteristics of optoelectronic systems.
 
Bit 1: 0 = enable, 1 = disable, start-of-scan recalibration.
 
       When this function is disabled, the scanner uses the most recent
       calibration results rather than automatically recalibrating itself
       before scanning.

Bit 2: 0 = normal, 1 = make calibration right away.

       This function will make a calibration right after receiving this 
       command. This function is not well implemented on all the scanner.
       I won't recommand you to program this function.

Bit 3: 0 = normal, 1 = enable quick calibration.

       This function authorize the scanner to decide whether to recalibrate
       or not before scanning.
                                                                               3.10  MODE SENSE 1 Command
 
Operation Code ...:  19h
 
Type .............:  Vendor unique
 
Purpose ..........:  To send separate offset (digital brightness adjustment)
                     settings for different color channels.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     19h
    1                                     00h
    2                                     00h
    3                                     00h
    4                                     1Eh
    5                                     00h
 
Data Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                Reserved, 00h          
    1                     Red Channel (or Gray) Offset Setting
    2                         Green Channel Offset Setting   
    3                          Blue Channel Offset Setting  
  4-29                               Reserved, 00h      
 
 
Notes
 
1. This command is supported if bit 0 of returned INQUIRY data byte 71 is 1.
 
2. If the scanner is not a one-pass model, only byte 1 of MODE SENSE 1 data is
   valid.
                                                                               3.11  MODE SENSE Command
 
Operation Code ...:  1Ah
 
Type .............:  Optional
 
Purpose ..........:  To read current settings from the scanner.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     1Ah
    1                                     00h
    2                                     00h
    3                                     00h
    4                                     TL
    5                                     00h
 
TL (Transfer Length) is 13h for a one-pass scanner. For a three-pass scanner,
TL is 0Bh if the unit supports midtone adjustment, 0Ah if it does not.
 
The format of returned data for different transfer lengths is shown below.
Except where otherwise noted, the format of the individual data bytes is the
same as in data for the MODE SELECT command.
 
When TL = 0Ah, returned data are in the same format as when TL = 0Bh except
that byte 10 is not returned.
 
Format of Returned Data (TL = 0Bh)
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                Mode Setting
    1                             Resolution Setting
    2                            Exposure Time Setting
    3                              Contrast Setting
    4                                Grain Setting
    5                              Velocity Setting
    6                          Shadow Adjustment Setting
    7                        Highlight Adjustment Setting
    8                             Paper Length (LSB)
    9                             Paper Length (MSB)
   10                         Midtone Adjustment Setting
                                                                               MODE SENSE command, continued
 
Format of Returned Data (TL = 13h)
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                Mode Setting*
    1                             Resolution Setting
    2                                Grain Setting
    3                              Velocity Setting        
    4                      Red Channel Exposure Time Setting
    5                        Red Channel Contrast Setting
    6                    Red Channel Shadow Adjustment Setting
    7                  Red Channel Highlight Adjustment Setting
    8                   Red Channel Midtone Adjustment Setting
    9                     Green Channel Exposure Time Setting
   10                       Green Channel Contrast Setting
   11                   Green Channel Shadow Adjustment Setting
   12                 Green Channel Highlight Adjustment Setting
   13                  Green Channel Midtone Adjustment Setting
   14                     Blue Channel Exposure Time Setting
   15                        Blue Channel Contrast Setting
   16                   Blue Channel Shadow Adjustment Setting
   17                  Blue Channel Highlight Adjustment Setting
   18                   Blue Channel Midtone Adjustment Setting
 
*Currently reserved (00h).
 
 
Note
 
If gray-scale scanning is specified with the MODE SELECT command, the same
exposure time, contrast and shadow/midtone/highlight settings will be reported
for all three color channels.
                                                                               3.12  START/STOP SCAN Command
 
Operation Code ...:  1Bh
 
Type .............:  Mandatory
 
Purpose ..........:  To send final settings and start the scanner; to abort
                     scanning.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     1Bh
    1                                     00h
    2                                     00h
    3                                     00h
    4    ExpdRes   Multi   1Pcolor  Filter1  Filter2  Neg2Pos  FastPre   Start
    5                                     00h
 
One- and zero-bits in byte 4 control scanner operation as follows:
 
Bit 0: 1 to start the scanner, 0 to abort scanning.
 
Bit 1: 1 = fast color prescan, 0 = normal scanning (see byte 67 of returned
       INQUIRY data).
 
Bit 2: 1 = reverse colors (to produce a positive image of a negative original),
       0 = scan "as is" (do not reverse colors).
 
       Clear  Red  Green  Blue
       """""  """  """""  """"
Bit 3:   0     1     0      1
Bit 4:   0     0     1      1
 
       Bits 3 and 4 select a scanning filter. A clear filter is used for
       single-bit or gray-scale scanning.
 
Bit 5: 1 = one-pass color scan; set only for a one-pass color scanner.
 
Bit 6: 1 = multi-bit mode, 0 = single-bit mode.
 
Bit 7: 1 for the expanded resolution range, 0 for the base range.
3.13  RECEIVE DIAGNOSTIC RESULTS Command
 
Operation Code ...:  1Ch
 
Type .............:  Mandatory
 
Purpose ..........:  To read scanner self-test results after completion of the
                     SEND DIAGNOSTIC command.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     1Ch
    1                                     00h
    2                                     00h
    3                                     00h
    4                                  TL (01h)
    5                                     00h
 
Format of Returned Data
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0    FdrEjct  ScnM/Sn  Lmp/CCD   DCofs   Rsvd, 0  ImgRAM   SysRAM   CPURAM
 
One-bits in the returned data byte denote the errors indicated below:
 
Bit 0: CPU RAM failure.
Bit 1: Scanner system RAM failure.
Bit 2: Image RAM failure (image buffer or ping-pong buffer).
Bit 4: DC offset error (black level calibration failure).
Bit 5: Scanning lamp or image sensor circuit failure.
Bit 6: Scanning head motor or home position sensor failure.
Bit 7: Automatic document feeder paper ejection failure.
                                                                               3.14  SEND DIAGNOSTIC Command
 
Operation Code ...:  1Dh
 
Type .............:  Optional
 
Purpose ..........:  To instruct the scanner to test its major components and
                     modules.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     1Dh
    1    ----------------Reserved, 0----------------    ST     --Reserved, 0---
    2                                     00h
    3                                     00h
    4                                     00h
    5                                     00h
 
Key:  ST = SELFTEST bit. This bit must be 1, the designated value for
           instructing the scanner to carry out a complete self-test.
 
This command instructs the scanner to carry out a self-test similar to the one
it executes at power-up. If no malfunction is detected, status is reported as
GOOD; if a malfunction is detected, a CHECK CONDITION status is reported and
the nature of the error can be determined by issuing the RECEIVE DIAGNOSTIC
RESULTS command.
                                                                               3.15  LOOK-UP-TABLE DOWNLOAD Command
 
Operation Code ...:  55h
 
Type .............:  Optional
 
Purpose ..........:  To send a look-up table of shading adjustment values (also
                     referred to as a gamma table) to the scanner for use in
                     multi-bit scanning.
 
Command Format
 
  Byte    Bit 7    Bit 6    Bit 5    Bit 4    Bit 3    Bit 2    Bit 1    Bit 0
  """"   """""""  """""""  """""""  """""""  """""""  """""""  """""""  """""""
    0                                     55h
    1                                     00h
    2                                     27h
    3                                     00h
    4                                     00h
    5                                     00h
    6                                     00h
    7                                  TL1 (MSB)
    8                                  TL2 (LSB)
    9    ----ColrCode----  ----------------Reserved, 0----------------  EntWdth
 
 
Bytes 7 and 8 "" TL (Transfer Length)
 
TL is transfer length, that is, the number of bytes that the host will send to
the scanner during the Data Out phase. If the EntWdth bit is 1, transfer length
is the number of entries times 2.
 
 
Byte 9 "" Color Code and Entry Width
 
Bit 0: 0 = each table entry is one byte, 1 = entries are two bytes long.
 
Bits 6 and 7:  These bits indicate the color to which the table applies on a
               one-pass color scanner. They must be 0 for all other scanner
               types. Taking bit 6 as the least significant bit, ColrCode is
               00h for gray or all three primaries, 01h for red, 02h for green,
               03h for blue.
 
Data Format
 
Data for this command consist of 256, 1024, 4096 or 65536 look-up-table
entries, downloaded sequentially.
 
Each entry specifies the value to which a particular raw scanned shading value
is to be adjusted. Entry 0 is the value to which all pixels with a raw scanned
shading value of 00h (or 0000h) are to be adjusted, entry 1 is the value to
which pixels with a raw value of 01h (or 0001h) are to be adjusted, and so on
up to the final entry (entry TL-1), which is the adjusted shading value of all
pixels with the highest possible raw scanned value.

