use the new calib_lines field instead of model->shading_lines

merge-requests/1/head
Stphane Voltz 2011-07-06 21:17:13 +02:00
rodzic 5a0c42a357
commit 68074484ff
7 zmienionych plików z 27 dodań i 332 usunięć

Wyświetl plik

@ -1862,7 +1862,7 @@ genesys_dark_shading_calibration (Genesys_Device * dev)
}
/* size is size in bytes for scanarea: bytes_per_line * lines */
size = channels * 2 * pixels_per_line * (dev->model->shading_lines + 1);
size = channels * 2 * pixels_per_line * (dev->calib_lines + 1);
calibration_data = malloc (size);
if (!calibration_data)
@ -1931,14 +1931,14 @@ genesys_dark_shading_calibration (Genesys_Device * dev)
}
genesys_average_data (dev->dark_average_data, calibration_data,
dev->model->shading_lines,
dev->calib_lines,
pixels_per_line * channels);
if (DBG_LEVEL >= DBG_data)
{
sanei_genesys_write_pnm_file ("black_shading.pnm", calibration_data, 16,
channels, pixels_per_line,
dev->model->shading_lines);
dev->calib_lines);
sanei_genesys_write_pnm_file ("black_average.pnm",
dev->dark_average_data, 16, channels,
pixels_per_line, 1);
@ -2061,7 +2061,7 @@ genesys_white_shading_calibration (Genesys_Device * dev)
uint8_t channels;
DBG (DBG_proc, "genesys_white_shading_calibration (lines = %d)\n",
dev->model->shading_lines);
dev->calib_lines);
pixels_per_line = dev->calib_pixels;
channels = dev->calib_channels;
@ -2077,7 +2077,7 @@ genesys_white_shading_calibration (Genesys_Device * dev)
return SANE_STATUS_NO_MEM;
}
size = channels * 2 * pixels_per_line * (dev->model->shading_lines + 1);
size = channels * 2 * pixels_per_line * (dev->calib_lines + 1);
calibration_data = malloc (size);
if (!calibration_data)
@ -2140,10 +2140,10 @@ genesys_white_shading_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("white_shading.pnm", calibration_data, 16,
channels, pixels_per_line,
dev->model->shading_lines);
dev->calib_lines);
genesys_average_data (dev->white_average_data, calibration_data,
dev->model->shading_lines,
dev->calib_lines,
pixels_per_line * channels);
if (DBG_LEVEL >= DBG_data)
@ -2189,7 +2189,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
DBG (DBG_proc, "genesys_black_white_shading_calibration (lines = %d)\n",
dev->model->shading_lines);
dev->calib_lines);
pixels_per_line = dev->calib_pixels;
channels = dev->calib_channels;
@ -2218,7 +2218,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
return SANE_STATUS_NO_MEM;
}
size = channels * 2 * pixels_per_line * dev->model->shading_lines;
size = channels * 2 * pixels_per_line * dev->calib_lines;
calibration_data = malloc (size);
if (!calibration_data)
@ -2279,7 +2279,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file ("black_white_shading.pnm", calibration_data,
16, channels, pixels_per_line,
dev->model->shading_lines);
dev->calib_lines);
average_white = dev->white_average_data;
@ -2290,7 +2290,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
dark = 0xffff;
white = 0;
for (y = 0; y < dev->model->shading_lines; y++)
for (y = 0; y < (int)dev->calib_lines; y++)
{
col = calibration_data[(x + y * pixels_per_line * channels) * 2];
col |=
@ -2314,7 +2314,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev)
white_count = 0;
white_sum = 0;
for (y = 0; y < dev->model->shading_lines; y++)
for (y = 0; y < (int)dev->calib_lines; y++)
{
col = calibration_data[(x + y * pixels_per_line * channels) * 2];
col |=
@ -3836,7 +3836,7 @@ genesys_sheetfed_calibration (Genesys_Device * dev)
* pixel and use it to fill the dark_average
* dev->calib_pixels
(dev->sensor.sensor_pixels * dev->settings.xres) / dev->sensor.optical_res,
dev->model->shading_lines,
dev->calib_lines,
*/
}

Wyświetl plik

@ -2603,6 +2603,7 @@ gl124_init_regs_for_shading (Genesys_Device * dev)
dev->calib_channels = 3;
resolution=gl124_compute_dpihw(dev,dev->settings.xres);
dev->calib_lines = dev->model->shading_lines;
dev->calib_pixels = (dev->sensor.sensor_pixels*resolution)/dev->sensor.optical_res;
dev->calib_resolution = resolution;

Wyświetl plik

@ -3330,6 +3330,7 @@ gl646_init_regs_for_shading (Genesys_Device * dev)
status = setup_for_scan (dev, settings, SANE_TRUE, SANE_FALSE, SANE_FALSE);
/* used when sending shading calibration data */
dev->calib_lines = dev->model->shading_lines;
dev->calib_pixels = settings.pixels;
dev->calib_channels = dev->current_setup.channels;
if (dev->model->is_cis == SANE_FALSE)

Wyświetl plik

@ -794,324 +794,6 @@ gl841_test_motor_flag_bit (SANE_Byte val)
return SANE_FALSE;
}
/*
* dumps register set in a human readable format
* todo : finish all register decoding
*
* adapted to sanei_gl841 but not tested at all
*/
static void
sanei_gl841_print_registers (Genesys_Register_Set * reg)
{
SANE_Int i;
SANE_Byte v;
SANE_Int fastmode = 0;
SANE_Int lperiod;
SANE_Int cpp = 0;
lperiod =
sanei_genesys_read_reg_from_set (reg,
0x38) * 256 +
sanei_genesys_read_reg_from_set (reg, 0x39);
#if 0
fastmode =
(sanei_genesys_read_reg_from_set (reg, 0x01) & REG01_FASTMOD) ? 1 : 0;
#endif
for (i = 0; i < GENESYS_GL841_MAX_REGS; i++)
{
v = reg[i].value;
DBG (DBG_info, "reg 0x%02x: 0x%02x ", reg[i].address, v);
switch (reg[i].address)
{
case 0x01:
DBG (DBG_info, "%s, %s, %s, %s, %s, %s, %s, ", /*%s", */
(v & REG01_CISSET) ? "CIS" : "CCD",
(v & REG01_DOGENB) ? "watchdog on" : "watchdog off",
(v & REG01_DVDSET) ? "shading on" : "shading off",
/*(v & REG01_FASTMOD) ? "fastmode on" : "fastmode off", */
(v & REG01_M16DRAM) ? "data comp on" : "data comp off",
(v & REG01_DRAMSEL) ? "1 MB RAM" : "512 KB RAM",
(v & REG01_SHDAREA) ? "shading=scan area" :
"shading=total line",
(v & REG01_SCAN) ? "enable scan" : "disable scan");
break;
case 0x02:
DBG (DBG_info, "%s, %s, %s, %s, %s, %s, %s, %s",
(v & REG02_NOTHOME) ? "autohome doesn't work" :
"autohome works",
(v & REG02_ACDCDIS) ? "backtrack off" : "backtrack on",
(v & REG02_AGOHOME) ? "autohome on" : "autohome off",
(v & REG02_MTRPWR) ? "motor on" : "motor off",
(v & REG02_FASTFED) ? "2 tables" : "1 table",
(v & REG02_MTRREV) ? "reverse" : "forward",
(v & REG02_HOMENEG) ? "indicate home sensor falling edge" :
"indicate home sensor rising edge",
(v & REG02_LONGCURV) ?
"deceleration curve fast mode is table 5" :
"deceleration curve fast mode is table 4");
break;
case 0x03:
DBG (DBG_info, "%s, %s, %s, %s, %s, lamptime: %d pixels",
(v & REG03_LAMPDOG) ? "lamp sleeping mode on" :
"lamp sleefping mode off",
(v & REG03_AVEENB) ? "dpi average" : "dpi deletion",
(v & REG03_XPASEL) ? "TA lamp" : "flatbed lamp",
(v & REG03_LAMPPWR) ? "lamp on" : "lamp off",
"lamp timer on",
v & REG03_LAMPTIM * (fastmode + 1) * 65536 * lperiod);
break;
case 0x04:
DBG (DBG_info, "%s, %s, AFEMOD: %d, %s, %s",
/*(v & REG04_LINEART) ? "lineart on" : "lineart off", */
"sanei_gl841 manual rev 1.7 is strange here ",
(v & REG04_BITSET) ? "image data 16 bits" :
"image data 8 bits",
((v & REG04_AFEMOD) >> 4),
((v & REG04_FILTER) >> 2 ==
0) ? "color filter" : ((v & REG04_FILTER) >> 2 ==
1) ? "red filter" : ((v &
REG04_FILTER)
>> 2 ==
2) ?
"green filter" : "blue filter",
((v & REG04_FESET) <
2) ? (((v & REG04_FESET) == 0) ? "ESIC type 1" :
"ESIC type 2") : (((v & REG04_FESET) ==
2) ? "ADI type" : "reserved"));
break;
case 0x05:
DBG (DBG_info, "%s, %s, %s, %s, %s, %s",
((v & REG05_DPIHW) >> 6) == 0 ? "opt. sensor dpi: 600" :
((v & REG05_DPIHW) >> 6) ==
1 ? "opt. sensor dpi: 1200 dpi" : ((v & REG05_DPIHW) >>
6) ==
2 ? "opt. sensor dpi: 2400 dpi" :
"opt. sensor dpi: reserved",
"lamp time out",
((v & REG05_MTLLAMP) >> 4) < 2
? (((v & REG05_MTLLAMP) >> 4) == 0
? "1*LAMPTIM" : "2*LAMPTIM")
: ((v & REG05_MTLLAMP) >> 4) == 2
? "4*LAMPTIM" : "reserved",
(v & REG05_GMMENB) ? "gamma correction on" :
"gamma correction off",
"pixes number under each system pixel time: ",
(v & REG05_MTLBASE) < 2
? ((v & REG05_MTLBASE) == 0
? "1" : "2") : (v & REG05_MTLBASE) == 2 ? "3" : "4");
/* I don't now if this works cause in gl646 the unit of
measurement is clocks/pixel and in sanei_gl841 it is
pixel/system pixel time */
{
switch (v & REG05_MTLBASE)
{
case 0:
cpp = 1;
break;
case 1:
cpp = 2;
break;
case 2:
cpp = 3;
break;
case 3:
cpp = 4;
break;
}
}
break;
case 0x06:
DBG (DBG_info, "12 clk/pixel normal for scanning, %s, %s, %s, %s",
((v & REG06_SCANMOD >> 5) > 5) ?
((v & REG06_SCANMOD >> 5) == 4) ?
" 6 clk/pixel fast mode "
: ((v & REG06_SCANMOD >> 5) == 5) ?
" 15 clk/pixel 16 color"
: " 18 clk/pixel 16 color"
:
((v & REG06_SCANMOD >> 5) < 2) ?
((v & REG06_SCANMOD >> 5) == 0) ?
"12 clk/pixel normal for scanning"
: "12 clk/pixel bypass for scanning"
:
" reserved",
(v & REG06_PWRBIT) ? "turn power on" :
"don't turn power on",
(v & REG06_GAIN4) ? "digital shading gain=4 times system" :
"digital shading gain=8 times system",
(v & REG06_OPTEST) ==
0 ? "ASIC test mode: off" : (v & REG06_OPTEST) == 1 ?
"ASIC test mode: simulation, motorgo" :
(v & REG06_OPTEST) == 2 ?
"ASIC test mode: image, pixel count" :
(v & REG06_OPTEST) == 3 ?
"ASIC test mode: image, line count" :
(v & REG06_OPTEST) == 4 ?
"ASIC test mode: simulation, counter + adder" :
(v & REG06_OPTEST) == 5 ?
"ASIC test mode: CCD TG" : "ASIC test mode: reserved");
break;
case 0x07:
DBG (DBG_info, "%s, %s, %s, %s",
(v & REG07_SRAMSEL) ? "DMA access for SRAM" :
"DMA access for DRAM",
(v & REG07_FASTDMA) ? "2 clocks/access" :
"4 clocks/access",
(v & REG07_DMASEL) ? "DMA access for DRAM" :
"MPU access for DRAM",
(v & REG07_DMARDWR) ? "DMA read DRAM" : "DMA write DRAM");
break;
case 0x08:
DBG (DBG_info, "%s, %s, %s, %s, %s, %s, %s",
(v & REG08_DECFLAG) ? "gamma table is decrement type" :
"gamma table is increment type",
(v & REG08_GMMFFR) ?
"red channel Gamma table address FFH is special type"
: " ",
(v & REG08_GMMFFG) ?
"green channel Gamma table address FFH is special type"
: " ",
(v & REG08_GMMFFB) ?
"blue channel Gamma table address FFH is special type"
: " ",
(v & REG08_GMMZR) ?
"red channel Gamma table address 00H is special type"
: " ",
(v & REG08_GMMZG) ?
"green channel Gamma table address 0H is special type"
: " ",
(v & REG08_GMMZB) ?
"blue channel Gamma table address 00H is special type"
: " ");
break;
case 0x09:
DBG (DBG_info, "%s, %s, %s, %s, %s, %s",
((v & REG09_MCNTSET) == 0) ? "pixel count" :
((v & REG09_MCNTSET) == 1) ? "system clock*2" :
((v & REG09_MCNTSET) == 2) ? "system clock*3" :
"system clock*4",
((v & REG09_CLKSET) == 0) ? "24MHz" :
((v & REG09_CLKSET) == 1) ? "30MHz" :
((v & REG09_CLKSET) == 2) ? "40MHz" :
"48MHz",
(v & REG09_BACKSCAN) ?
"backward scan function"
: "forward scan function ",
(v & REG09_ENHANCE) ?
"enhance EPP interfgace speed for USB2.0 "
: "select normal EPP interface speed for USB2.0 ",
(v & REG09_SHORTTG) ?
"enable short CCD SH(TG) period for film scanning"
: " ",
(v & REG09_NWAIT) ?
"delay nWait (H_BUSY) one clock" : " ");
break;
case 0x0a:
DBG (DBG_info, "%s",
(v & REG0A_SRAMBUF) ?
"select external SRAM as the image buffer" :
"select external DRAM as the image buffer");
break;
case 0x0d:
DBG (DBG_info, "scanner command: %s",
(v & REG0D_CLRLNCNT) ? "clear SCANCNT(Reg4b,Reg4c,Reg4d)" :
"don't clear SCANCNT");
break;
case 0x0e:
DBG (DBG_info, "scanner software reset");
break;
case 0x0f:
DBG (DBG_info, "start motor move");
break;
case 0x10:
DBG (DBG_info, "red exposure time hi");
break;
case 0x11:
DBG (DBG_info, "red exposure time lo (total: 0x%x)",
v + 256 * sanei_genesys_read_reg_from_set (reg, 0x10));
break;
case 0x12:
DBG (DBG_info, "green exposure time hi");
break;
case 0x13:
DBG (DBG_info, "green exposure time lo (total: 0x%x)",
v + 256 * sanei_genesys_read_reg_from_set (reg, 0x12));
break;
case 0x14:
DBG (DBG_info, "blue exposure time hi");
break;
case 0x15:
DBG (DBG_info, "blue exposure time lo (total: 0x%x)",
v + 256 * sanei_genesys_read_reg_from_set (reg, 0x14));
break;
case 0x16:
DBG (DBG_info, "%s, %s, %s, %s, %s, %s, %s, %s",
(v & REG16_CTRLHI) ? "CCD CP & RS hi when TG high" :
"CCD CP & RS lo when TG high",
(v & REG16_TOSHIBA) ? "image sensor is TOSHIBA CIS" :
" ",
(v & REG16_TGINV) ? "inverse CCD TG" : "normal CCD TG",
(v & REG16_CK1INV) ? "inverse CCD clock 1" :
"normal CCD clock 1",
(v & REG16_CK2INV) ? "inverse CCD clock 2" :
"normal CCD clock 2",
(v & REG16_CTRLINV) ? "inverse CCD CP & RS" :
"normal CCD CP & RS",
(v & REG16_CKDIS) ? "CCD TG position clock 1/2 signal off"
: "CCD TG position clock 1/2 signal on",
(v & REG16_CTRLDIS) ? "CCD TG position CP & RS signals off"
: "CCD TG position CP & RS signals off");
break;
case 0x17:
DBG (DBG_info, "%s, CCD TG width: %0x",
((v & REG17_TGMODE) >> 6) ==
0x00 ? "CCD TG without dummy line" : ((v & REG17_TGMODE) >>
6) ==
0x01 ? "CCD TG with dummy line" : "CCD TG reserved",
(v & REG17_TGW));
break;
case 0x18:
DBG (DBG_info, "%s, %d time CCD clock speed for dummy line, %s, "
"delay %d system clocks for CCD clock 1/2, %d time CCD clock speed for capture image",
(v & REG18_CNSET) ? "TG and clock canon CIS style" :
"TG and clock non-canon CIS style",
((v & REG18_DCKSEL) >> 5) + 1,
(v & REG18_CKTOGGLE) ?
"half cycle per pixel for CCD clock 1/2" :
"one cycle per pixel for CCD clock 1/2",
((v & REG18_CKDELAY) >> 2), ((v & REG18_CKSEL) + 1));
break;
case 0x19:
DBG (DBG_info, "dummy line exposure time (0x%x pixel times)",
v * 256);
break;
case 0x1a:
DBG (DBG_info, "%s, %s, %s, %s, %s",
(v & REG1A_MANUAL3) ?
"CCD clock3,clock4 manual output"
: "CCD clock3,clock4 automatic output",
(v & REG1A_MANUAL1) ?
"CCD clock1,clock2 manual output"
: "CCD clock1,clock2 automatic output",
(v & REG1A_CK4INV) ?
"reverse CCD Clock4"
: " ",
(v & REG1A_CK3INV) ?
"reverse CCD Clock3"
: " ",
(v & REG1A_LINECLP) ?
"CCD line clamping" : "CCD pixel clamping");
break;
case 0x1b:
DBG (DBG_info, "reserved");
break;
}
DBG (DBG_info, "\n");
}
}
/** copy sensor specific settings */
/* *dev : device infos
*regs : registers to be set
@ -4678,6 +4360,7 @@ gl841_init_regs_for_shading (Genesys_Device * dev)
SCAN_FLAG_USE_OPTICAL_RES
);
dev->calib_lines = dev->model->shading_lines;
dev->calib_pixels = dev->current_setup.pixels;
if (status != SANE_STATUS_GOOD)

Wyświetl plik

@ -2738,6 +2738,7 @@ gl843_init_regs_for_shading (Genesys_Device * dev)
GENESYS_GL843_MAX_REGS * sizeof (Genesys_Register_Set));
dev->calib_channels = 3;
dev->calib_lines = dev->model->shading_lines;
dev->calib_pixels = dev->sensor.sensor_pixels;
resolution=gl843_compute_dpihw(dev,dev->settings.xres);
dev->calib_resolution = resolution;

Wyświetl plik

@ -2480,6 +2480,7 @@ gl847_init_regs_for_shading (Genesys_Device * dev)
GENESYS_GL847_MAX_REGS * sizeof (Genesys_Register_Set));
dev->calib_resolution = sanei_genesys_compute_dpihw(dev,dev->settings.xres);
dev->calib_lines = dev->model->shading_lines;
dev->calib_pixels = (dev->sensor.sensor_pixels*dev->calib_resolution)/dev->sensor.optical_res;
status = gl847_init_scan_regs (dev,

Wyświetl plik

@ -622,7 +622,8 @@ struct Genesys_Device
time_t init_date;
size_t average_size;
size_t calib_pixels;
size_t calib_pixels; /**> number of pixels used during shading calibration */
size_t calib_lines; /**> number of lines used during shading calibration */
size_t calib_channels;
size_t calib_resolution;
uint8_t *white_average_data;
@ -902,6 +903,13 @@ int sanei_genesys_slope_table(uint16_t *slope, int *steps, int dpi, int exposure
extern
int sanei_genesys_get_lowest_ydpi(Genesys_Device *dev);
/**
* reads previously cached calibration data
* from file
*/
extern SANE_Status
sanei_genesys_read_calibration (Genesys_Device * dev);
/*---------------------------------------------------------------------------*/
/* ASIC specific functions declarations */
/*---------------------------------------------------------------------------*/