- release memory allocated by sane_get_devices

- several bugfixes
         - supports the M3097
         - get threshold, contrast and brightness from vpd
         - imprinter support
	 - get_hardware_status now works before calling sane_start
	 - avoid unnecessary reload of options when using source=fb
DEVEL_2_0_BRANCH-1
Oliver Schirrmeister 2002-06-06 08:35:42 +00:00
rodzic 084d5b5b44
commit b743d8d0fb
3 zmienionych plików z 1455 dodań i 513 usunięć

Wyświetl plik

@ -97,6 +97,7 @@ scsiblk;
#define MODE_SELECT 0x15
#define MODE_SENSE 0x1a
#define SCAN 0x1b
#define IMPRINTER 0xc1
#define HW_STATUS 0xc2
@ -182,6 +183,12 @@ static scsiblk inquiryB = { inquiryC, sizeof (inquiryC) };
#define get_IN_has_set_subwindow(in) (getnbyte(in+0x2a, 2)) & 1
#define get_IN_has_imprinter(in) (getnbyte(in+0x2a, 2)) & 2
#define get_IN_has_hw_status(in) (getnbyte(in+0x2a, 2)) & 4
#define get_IN_brightness_steps(in) getnbyte(in+0x52, 1)
#define get_IN_threshold_steps(in) getnbyte(in+0x53, 1)
#define get_IN_contrast_steps(in) getnbyte(in+0x54, 1)
#define get_IN_ipc_bw_reverse(in) getbitfield(in+0x58, 1, 6)
#define get_IN_ipc_auto1(in) getbitfield(in+0x58, 1, 5)
#define get_IN_ipc_auto2(in) getbitfield(in+0x58, 1, 5)
#define get_IN_ipc_outline_extraction(in) getbitfield(in+0x58, 1, 4)
#define get_IN_ipc_image_emphasis(in) getbitfield(in+0x58, 1, 3)
#define get_IN_ipc_auto_separation(in) getbitfield(in+0x58, 1, 2)
@ -196,6 +203,9 @@ static scsiblk inquiryB = { inquiryC, sizeof (inquiryC) };
#define get_IN_compression_JPG_BASE(in) getbitfield(in+0x5a, 1, 3)
#define get_IN_compression_JPG_EXT(in) getbitfield(in+0x5a, 1, 2)
#define get_IN_compression_JPG_INDEP(in) getbitfield(in+0x5a, 1, 1)
#define get_IN_imprinter(in) getbitfield(in+0x5c, 1, 7)
#define get_IN_imprinter_stamp(in) getbitfield(in+0x5c, 1, 6)
#define get_IN_imprinter_electrical(in) getbitfield(in+0x5c, 1, 5)
/* ==================================================================== */
@ -226,18 +236,23 @@ static scsiblk object_positionB =
/* ==================================================================== */
/*
static unsigned char sendC[] =
static unsigned char sendC[] =
{SEND, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static scsiblk sendB =
static scsiblk sendB =
{sendC, sizeof (sendC)};
*/
#define set_S_datatype_code(sb, val) sb[0x02] = (unsigned char)val
#define S_datatype_imagedatai 0x00
#define S_EX_datatype_LUT 0x01 /* Experiment code */
#define S_datatype_halftone_mask 0x02
#define S_datatype_gamma_function 0x03
#define S_datatype_LUT_data 0x83
#define S_datatype_jpg_q_table 0x88
#define S_datatype_imprinter_data 0x90
#define S_EX_datatype_LUT 0x01 /* Experiment code */
#define S_EX_datatype_shading_data 0xa0 /* Experiment code */
#define S_user_reg_gamma 0xc0
#define S_user_reg_gamma 0xc0
#define S_device_internal_info 0x03
#define set_S_datatype_qual_upper(sb, val) sb[0x04] = (unsigned char)val
#define S_DQ_none 0x00
@ -249,6 +264,44 @@ static scsiblk object_positionB =
#define S_DQ_Reg3 0x03
#define set_S_xfer_length(sb, val) putnbyte(sb + 0x06, val, 3)
static unsigned char send_imprinterC[] =
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00};
static scsiblk send_imprinterB =
{send_imprinterC, sizeof(send_imprinterC)};
/* imprinter counter
* 0 = increase counter
* 1 = decrease counter
*/
#define set_imprinter_cnt_dir(sb, val) setbitfield(sb + 0x01, 1, 5, val)
#define S_im_dir_inc 0
#define S_im_dir_dec 1
/* counter value
* 1 = 24 bit
* 0 = 16 bit
*/
#define set_imprinter_lap24(sb, val) setbitfield(sb + 0x01, 1, 4, val)
#define S_im_ctr_24bit 1
#define S_im_ctr_16bit 0
/* stepping of the imprinter counter
* 0..2 allowed
*/
#define set_imprinter_cstep(sb, val) setbitfield(sb + 0x01, 0x03, 0, val)
#define set_imprinter_uly(sb, val) putnbyte(sb + 0x06, val, 4)
/* specifies the way of printing direction of the strings.
*/
#define set_imprinter_dirs(sb, val) setbitfield(sb + 0x0c, 0x03, 0, val)
#define S_im_dir_left_right 0
#define S_im_dir_top_bottom 1
#define S_im_dir_right_left 2
#define S_im_dir_bottom_top 3
#define set_imprinter_string_length(sb, len) putnbyte(sb + 0x11, len, 1)
#define max_imprinter_string_length 40
/*
static unsigned char gamma_user_LUT_LS1K[512] = { 0x00 };
static scsiblk gamma_user_LUT_LS1K_LS1K = {
@ -258,6 +311,34 @@ static scsiblk object_positionB =
/* ==================================================================== */
static unsigned char imprinterC[] =
{ IMPRINTER, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static scsiblk imprinterB = { imprinterC, sizeof (imprinterC) };
#define set_IM_xfer_length(sb, val) putnbyte(sb + 0x7, val, 2)
static unsigned char imprinter_descC[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static scsiblk imprinter_descB = {imprinter_descC, sizeof(imprinter_descC) };
/* enable/disable imprinter printing*/
#define set_IMD_enable(sb, val) setbitfield(sb + 0x01, 1, 7, val)
#define IMD_enable 0
#define IMD_disable 1
/* specifies thes side of a document to be printed */
#define set_IMD_side(sb, val) setbitfield(sb + 0x01, 1, 6, val)
#define IMD_front 0
#define IMD_back 1
/* format of the counter 16/24 bit*/
#define set_IMD_format(sb, val) setbitfield(sb + 0x01, 1, 5, val)
#define IMD_16_bit 0
#define IMD_24_bit 1
/* initial count */
#define set_IMD_initial_count_16(sb, val) putnbyte(sb + 0x02, val, 2)
#define set_IMD_initial_count_24(sb, val) putnbyte(sb + 0x03, val, 3)
/* ==================================================================== */
static unsigned char readC[] =
{ READ, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* Type, rsvd, type qual, __xfer length__, Ctl */
@ -364,7 +445,7 @@ static unsigned char hw_statusC[] =
{ HW_STATUS, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static scsiblk hw_statusB = { hw_statusC, sizeof (hw_statusC) };
#define set_HW_allocation_length(sb, len) putnbyte(sb + 0x06, len, 2)
#define set_HW_allocation_length(sb, len) putnbyte(sb + 0x07, len, 2)
#define get_HW_B5_present(in) getbitfield(in+0x02, 1, 0)
#define get_HW_A4_present(in) getbitfield(in+0x02, 1, 1)

Plik diff jest za duży Load Diff

Wyświetl plik

@ -12,6 +12,13 @@
static int num_devices;
static struct fujitsu *first_dev;
typedef union
{
SANE_Word w;
SANE_String s;
}
Option_Value;
/* -------------------------------------------------------------------------
* This option list has to contain all options for all scanners supported by
* this driver. If a certain scanner cannot handle a certain option, there's
@ -79,6 +86,17 @@ enum fujitsu_Option
OPT_GREEN_OFFSET,
OPT_USE_SWAPFILE,
OPT_IMPRINTER_GROUP,
OPT_IMPRINTER,
OPT_IMPRINTER_DIR,
OPT_IMPRINTER_YOFFSET,
OPT_IMPRINTER_STRING,
OPT_IMPRINTER_CTR_INIT,
OPT_IMPRINTER_CTR_STEP,
OPT_IMPRINTER_CTR_DIR,
OPT_SLEEP_MODE,
/* must come last: */
NUM_OPTIONS
};
@ -89,8 +107,10 @@ struct fujitsu
struct fujitsu *next;
SANE_Option_Descriptor opt[NUM_OPTIONS];
Option_Value val[NUM_OPTIONS];
SANE_Device sane;
/* Immutable values which are set during initial probing of the scanner. */
/* --------------------------------------------------------------------- */
@ -110,7 +130,8 @@ struct fujitsu
/* when scanning duplex */
int can_read_alternate; /* duplex transfer mode front/back/front/back... */
int adf_present; /* true if an ADF has been detected. */
int has_adf; /* true if an ADF has been detected. */
int has_fb;
int duplex_present; /* true if a duplex unit has been detected. */
int ipc_present; /* true if ipc2/3 option detected */
int cmp_present; /* true if cmp2 present */
@ -122,6 +143,33 @@ struct fujitsu
int has_white_level_follow; /* ............ */
int has_subwindow; /* ............ */
int has_dropout_color; /* */
int has_imprinter;
int has_threshold;
int has_brightness;
int has_contrast;
SANE_Range adf_width_range;
SANE_Range adf_height_range;
SANE_Range x_range;
SANE_Range y_range;
SANE_Range x_res_range;
SANE_Range y_res_range;
SANE_Range x_grey_res_range;
SANE_Range y_grey_res_range;
SANE_String_Const vpd_mode_list[7];
SANE_String_Const compression_mode_list[9];
SANE_Int x_res_list[17]; /* range of x and y resolution */
SANE_Int y_res_list[17]; /* if scanner has only fixed resolutions */
SANE_Int x_res_list_grey[17];
SANE_Int y_res_list_grey[17];
SANE_Range threshold_range;
SANE_Range brightness_range;
SANE_Range contrast_range;
/* User settable values (usually mirrored in SANE options) */
/* --------------------------------------------------------------------- */
@ -191,23 +239,6 @@ struct fujitsu
int green_offset; /* color tuning - green scan line offset */
int blue_offset; /* color tuning - blue scan line offset */
SANE_Range adf_width_range;
SANE_Range adf_height_range;
SANE_Range x_range;
SANE_Range y_range;
SANE_Range x_res_range;
SANE_Range y_res_range;
SANE_Range x_grey_res_range;
SANE_Range y_grey_res_range;
SANE_String_Const vpd_mode_list[7];
SANE_String_Const compression_mode_list[9];
SANE_Int x_res_list[17]; /* range of x and y resolution */
SANE_Int y_res_list[17]; /* if scanner has only fixed resolutions */
SANE_Int x_res_list_grey[17];
SANE_Int y_res_list_grey[17];
/* Derived values (calculated by calculateDerivedValues from the above) */
@ -294,6 +325,16 @@ struct fujitsu
/***** end of "set window" terms *****/
int dropout_color;
SANE_Bool use_imprinter;
int imprinter_direction;
SANE_Word imprinter_y_offset;
SANE_Char imprinter_string[max_imprinter_string_length];
int imprinter_ctr_init;
int imprinter_ctr_step;
int imprinter_ctr_dir;
SANE_Int sleep_time;
};
/** scan only front page */
@ -316,6 +357,7 @@ struct fujitsu
#define MODEL_4097 5
/** fi-???? */
#define MODEL_FI 6
#define MODEL_3097 7
/* A note regarding the MODEL... constants. There's a place in
* identifyScanner() where the INQUIRY data is parsed and the model
@ -328,7 +370,7 @@ struct fujitsu
* treated differently in the backend. For example, if the "abc" model
* has an optional ADF and the "xyz" model has the ADF built-in, we
* don't need to distinguish these models, and it's sufficient to set
* the "adf_present" variable accordingly.
* the "has_adf" variable accordingly.
*
* The same would apply if two sub-models behave in the same way but
* one of them is faster, or has some exotic extra capability that we
@ -429,11 +471,12 @@ static int identifyScanner (struct fujitsu *s);
static void doInquiry (struct fujitsu *s);
static int do_scsi_cmd (int fd, unsigned char *cmd, int cmd_len,
unsigned char *out, size_t out_len);
unsigned char *out, size_t req_out_len,
size_t *res_out_len);
static void hexdump (int level, char *comment, unsigned char *p, int l);
static SANE_Status initOptions (struct fujitsu *scanner);
static SANE_Status init_options (struct fujitsu *scanner);
static int grabScanner (struct fujitsu *s);
@ -441,14 +484,20 @@ static int freeScanner (struct fujitsu *s);
static int waitScanner (struct fujitsu *s);
static int objectPosition (struct fujitsu *s);
static int object_position (struct fujitsu *s, int i_load);
static SANE_Status doCancel (struct fujitsu *scanner);
static int objectDischarge (struct fujitsu *s);
/*static int objectDischarge (struct fujitsu *s);*/
static int fujitsu_set_sleep_mode(struct fujitsu *s);
static int set_mode_params (struct fujitsu *s);
static int imprinter(struct fujitsu *s);
static int fujitsu_send(struct fujitsu *s);
static int setWindowParam (struct fujitsu *s);
static size_t maxStringSize (const SANE_String_Const strings[]);
@ -473,7 +522,8 @@ static unsigned int readerGenericPassthrough (struct fujitsu *scanner,
static int read_large_data_block (struct fujitsu *s,
unsigned char *buffer, unsigned int length,
int i_window_id);
int i_window_id,
unsigned int *i_data_read);
static SANE_Status attachOne (const char *name);
@ -490,7 +540,7 @@ static SANE_Status setModeSP15 (struct fujitsu *scanner, int mode);
static void calculateDerivedValues (struct fujitsu *scanner);
static int makeTempFile (void);
static SANE_Status getHardwareStatus (struct fujitsu *s);
static SANE_Status get_hardware_status (struct fujitsu *s);
static void fujitsu_set_standard_size (SANE_Handle handle);