piuspatch  v0.1
USB addition to PIE backend
Data Structures | Defines | Typedefs | Enumerations | Functions | Variables
only-pie/backend/pie_usb.h File Reference

Go to the source code of this file.

Data Structures

struct  PIE_USB_Value_Data
 USB control sequence element. More...
struct  PIE_USB_cal_ired
 Infrared extension, not critical. More...
struct  PIE_USB_Calibration_Read
 Read by vendor specific 0xd7 SCSI command "PIE_READ_CALIBRATION". More...
struct  PIE_USB_Calibration_Send
 Written by vendor specific 0xdc SCSI command "PIE_WRITE_CALIBRATION". More...
struct  PIE_USB_Calibration_Set
 Handle calibration in software. More...
struct  PIE_USB_Calibration
 Hold data from the last calibration. More...
struct  PIE_USB_Model
 Describe a PIE USB scanner. More...
struct  PIE_USB_Device_Entry
 Distinguish between different scanner models. More...

Defines

#define BULKIN_MAXSIZE   0xFFF0
#define BUFFER_MAXSIZE   0x7F000
#define AVERAGE_CAL_LINES   13
#define REQUEST_TYPE_IN   (USB_TYPE_VENDOR | USB_DIR_IN)
#define REQUEST_TYPE_OUT   (USB_TYPE_VENDOR | USB_DIR_OUT)
#define REQUEST_REGISTER   0x0c
#define REQUEST_BUFFER   0x04
#define VALUE_BUFFER   0x82
#define VALUE_READ_REGISTER   0x84
#define VALUE_WRITE_REGISTER   0x85
#define VALUE_INIT_1   0x87
#define VALUE_INIT_2   0x88
#define VALUE_BUF_ENDACCESS   0x8c
#define VALUE_GET_REGISTER   0x8e
#define INDEX   0x00
#define SLOW_START   26700.0
 slowdown values for calibration
#define SLOW_LENGTH   5340.0
#define SLOW_HEIGHT   8.0
#define SLOW_IRED   -2
#define PIE_USB_FLAG_MIRROR_IMAGE   (1 << 0) /**> mirror image and X-window settings */
#define PIE_USB_FLAG_XRES_FAKE   (1 << 1) /**> highest X-resolution has to be emulated */
#define CONST_GAMMA   0.454545455

Typedefs

typedef struct PIE_USB_Value_Data PIE_USB_Value_Data
 USB control sequence element.
typedef struct
PIE_USB_Calibration_Set 
PIE_USB_Calibration_Set
 Handle calibration in software.
typedef struct PIE_USB_Calibration PIE_USB_Calibration
 Hold data from the last calibration.
typedef struct PIE_USB_Model PIE_USB_Model
 Describe a PIE USB scanner.
typedef struct PIE_USB_Device_Entry PIE_USB_Device_Entry
 Distinguish between different scanner models.

Enumerations

enum  PIE_USB_Operation_Mode { OPM_PREVIEW, OPM_SKIPCAL, OPM_QUALITY }
 Modes affecting calibration and quality. More...

Functions

struct PIE_USB_cal_ired __attribute__ ((__packed__)) PIE_USB_cal_ired
 Infrared extension, not critical.

Variables

uint16_t texp
unsigned char offset
unsigned char zero
unsigned char gain
unsigned char zero_1 [54]
uint16_t illumination [3]
unsigned char zero_2 [3]
unsigned char some_time
uint16_t t_min
unsigned char no_idea [20]
PIE_USB_cal_ired infrared
unsigned char scsi_cmd [6]

Detailed Description

This file contains definitions for the USB code for PIE SF film scanners. For documentation of the code see pie.c. Here the more general things are explained.

Exposure time (texp) and gain calibration is done in software for each of the R, G, B channels between two custom SCSI commands. The first 0xd7 named PIE_READ_CALIBRATION reads what the scanner suggest, the second 0xdc named PIE_WRITE_CALIBRATION sends what has been calculated. Commands sent during a scan:

Steps 7 to 17 are done for calibration. Steps 11 to 16 are only done for full calibration, i.e. for steps 7, 8 an initial set or the result of the last full calibration is used. Full calibration mode is termed OPM_QUALITY below, the short sequence may be OPM_PREVIEW or OPM_SKIPCAL.

The best documentation of what the 0xd7 and 0xdc commands contain is found in Jan Vleeshouwers post "Reflecta Crystalscan / ProScan 7200 update" at sane-devel Tue Dec 20 22:26:52 UTC 2011: http://lists.alioth.debian.org/pipermail/sane-devel/2011-December/029337.html Jan disassembled a PIE ROM.

Jan named the 0xd7 command READ GAIN OFFSET and the 0xdc one SET GAIN OFFSET. Here they are phrased PIE_READ_CALIBRATION and PIE_WRITE_CALIBRATION because the Windows programs do all calibration by changing exposure time (texp below, Jan's Timer count) and gain values. In USB snoops, the offsets are the same in read to write.

PIE_USB_Calibration_Read contains what is read for calibration.

PIE_USB_Calibration_Send contains what is written for calibration.

Definition in file pie_usb.h.


Define Documentation

#define AVERAGE_CAL_LINES   13

Definition at line 108 of file pie_usb.h.

#define BUFFER_MAXSIZE   0x7F000

Definition at line 107 of file pie_usb.h.

#define BULKIN_MAXSIZE   0xFFF0

Definition at line 106 of file pie_usb.h.

#define CONST_GAMMA   0.454545455

constant gamma as guessed from Silverfast (tm) scans

Definition at line 312 of file pie_usb.h.

#define INDEX   0x00

Definition at line 127 of file pie_usb.h.

#define PIE_USB_FLAG_MIRROR_IMAGE   (1 << 0) /**> mirror image and X-window settings */

Definition at line 308 of file pie_usb.h.

#define PIE_USB_FLAG_XRES_FAKE   (1 << 1) /**> highest X-resolution has to be emulated */

Definition at line 309 of file pie_usb.h.

#define REQUEST_BUFFER   0x04

Definition at line 117 of file pie_usb.h.

#define REQUEST_REGISTER   0x0c

Definition at line 116 of file pie_usb.h.

#define REQUEST_TYPE_IN   (USB_TYPE_VENDOR | USB_DIR_IN)

Definition at line 112 of file pie_usb.h.

#define REQUEST_TYPE_OUT   (USB_TYPE_VENDOR | USB_DIR_OUT)

Definition at line 113 of file pie_usb.h.

#define SLOW_HEIGHT   8.0

Definition at line 175 of file pie_usb.h.

#define SLOW_IRED   -2

Definition at line 176 of file pie_usb.h.

#define SLOW_LENGTH   5340.0

Definition at line 174 of file pie_usb.h.

#define SLOW_START   26700.0

slowdown values for calibration

No need yet to make them model specific. Construct a slope SLOW_HEIGHT / SLOW_LENGTH beginning at SLOW_START bytes per line, for infrared result is lower. This quirk seems to satisfy a limitation of the physical SCSI to USB interface within the scanner

Definition at line 173 of file pie_usb.h.

#define VALUE_BUF_ENDACCESS   0x8c

Definition at line 124 of file pie_usb.h.

#define VALUE_BUFFER   0x82

Definition at line 119 of file pie_usb.h.

#define VALUE_GET_REGISTER   0x8e

Definition at line 125 of file pie_usb.h.

#define VALUE_INIT_1   0x87

Definition at line 122 of file pie_usb.h.

#define VALUE_INIT_2   0x88

Definition at line 123 of file pie_usb.h.

#define VALUE_READ_REGISTER   0x84

Definition at line 120 of file pie_usb.h.

#define VALUE_WRITE_REGISTER   0x85

Definition at line 121 of file pie_usb.h.


Typedef Documentation

Hold data from the last calibration.

Initially loaded with default sets for exposure and gain but not shading

Handle calibration in software.

Distinguish between different scanner models.

typedef struct PIE_USB_Model PIE_USB_Model

Describe a PIE USB scanner.

There are several different PIE SF scanners which are different from each other. The following is an approach to hold model specific values.

Todo:
Define some of the constraints constant

USB control sequence element.


Enumeration Type Documentation

Modes affecting calibration and quality.

  • Before the first scan after opening,
  • during OPM_QUALITY scanning
  • and after having changed from OPM_QUALITY to some other mode

the full calibration sequence has to be done by the code !!! The actual values sent may be different for different scanner models.

Enumerator:
OPM_PREVIEW 

low quality preview

OPM_SKIPCAL 

low quality, full calibration is skipped

OPM_QUALITY 

high quality, always fully calibrate before scan

Definition at line 157 of file pie_usb.h.


Function Documentation

struct PIE_USB_Calibration_Send __attribute__ ( (__packed__)  )

Infrared extension, not critical.

Written by vendor specific 0xdc SCSI command "PIE_WRITE_CALIBRATION".

Read by vendor specific 0xd7 SCSI command "PIE_READ_CALIBRATION".


Variable Documentation

unsigned char gain

infrared gain

for a Reflecta ProScan 7200 in quality mode the read R G B gain values are usually one less than the written ones

R G B gain values inversely correlate with texp values

Definition at line 191 of file pie_usb.h.

uint16_t illumination[3]

R G B targeted illumination, [0] and [1] may be zero

Definition at line 211 of file pie_usb.h.

infrared extension

Definition at line 221 of file pie_usb.h.

unsigned char no_idea[20]

Definition at line 220 of file pie_usb.h.

unsigned char offset

infrared offset

R G B offsets

R G B offset usually copied from calibration read

Definition at line 189 of file pie_usb.h.

unsigned char scsi_cmd[6]

header

Definition at line 232 of file pie_usb.h.

unsigned char some_time

slow down value, may correspond to some_time[0] sent

Definition at line 218 of file pie_usb.h.

uint16_t t_min

?? minimal exposure time ??

Definition at line 219 of file pie_usb.h.

uint16_t texp

infrared exposure time

R G B exposure times

texp values are inversely correlated with gain values below, marked differences between different types of scanners, relatively high in quality mode, R G B

Definition at line 188 of file pie_usb.h.

unsigned char zero

Definition at line 190 of file pie_usb.h.

unsigned char zero_1[54]

Definition at line 209 of file pie_usb.h.

unsigned char zero_2

usually copied from calibration read

Definition at line 214 of file pie_usb.h.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines