kopia lustrzana https://gitlab.com/sane-project/backends
make shading calibration work
- shading calibration is working - scan mode set to deletion - led calibration tune upmerge-requests/1/head
rodzic
86bf317607
commit
42497554ba
|
@ -2992,6 +2992,8 @@ leading to
|
|||
* @param coeff 4000h or 2000h depending on fast scan mode or not (GAIN4 bit)
|
||||
* @param target_bright value of the white target code
|
||||
* @param target_dark value of the black target code
|
||||
* @param deletion is true if scan is done with deletion set, else averaging
|
||||
* is used
|
||||
*/
|
||||
#ifndef UNIT_TESTING
|
||||
static
|
||||
|
@ -3005,9 +3007,10 @@ compute_averaged_planar (Genesys_Device * dev,
|
|||
unsigned int o,
|
||||
unsigned int coeff,
|
||||
unsigned int target_bright,
|
||||
unsigned int target_dark)
|
||||
unsigned int target_dark,
|
||||
SANE_Bool deletion)
|
||||
{
|
||||
unsigned int x, i, j, br, dk, res, avgpixels, val;
|
||||
unsigned int x, i, j, br, dk, res, avgpixels, val, loop;
|
||||
|
||||
DBG (DBG_info, "%s: pixels=%d\n", __FUNCTION__, pixels_per_line);
|
||||
/* initialize result */
|
||||
|
@ -3024,24 +3027,14 @@ compute_averaged_planar (Genesys_Device * dev,
|
|||
|
||||
/* this should be evenly dividable */
|
||||
avgpixels = dev->sensor.optical_res / res;
|
||||
|
||||
/* due to resolution list is directly good to use */
|
||||
/* gl841 and gl847 supports 1/1 1/2 1/3 1/4 1/5 1/6 1/8 1/10 1/12 1/15 averaging */
|
||||
/* XXX STEF XXX
|
||||
if (avgpixels < 1)
|
||||
avgpixels = 1;
|
||||
else if (avgpixels < 6)
|
||||
avgpixels = avgpixels;
|
||||
else if (avgpixels < 8)
|
||||
avgpixels = 6;
|
||||
else if (avgpixels < 10)
|
||||
avgpixels = 8;
|
||||
else if (avgpixels < 12)
|
||||
avgpixels = 10;
|
||||
else if (avgpixels < 15)
|
||||
avgpixels = 12;
|
||||
if(deletion==SANE_TRUE)
|
||||
{
|
||||
loop=1;
|
||||
}
|
||||
else
|
||||
avgpixels = 15; */
|
||||
{
|
||||
loop=avgpixels;
|
||||
}
|
||||
|
||||
DBG (DBG_info, "%s: averaging over %d pixels\n", __FUNCTION__, avgpixels);
|
||||
|
||||
|
@ -3056,7 +3049,7 @@ compute_averaged_planar (Genesys_Device * dev,
|
|||
|
||||
dk = 0;
|
||||
br = 0;
|
||||
for (i = 0; i < avgpixels; i++)
|
||||
for (i = 0; i < loop; i++)
|
||||
{
|
||||
/* dark data */
|
||||
dk += (dev->dark_average_data[(x + i + pixels_per_line * j) * 2]
|
||||
|
@ -3067,8 +3060,8 @@ compute_averaged_planar (Genesys_Device * dev,
|
|||
| (dev-> white_average_data[(x + i + pixels_per_line * j) * 2 + 1] << 8));
|
||||
}
|
||||
|
||||
br /= avgpixels;
|
||||
dk /= avgpixels;
|
||||
br /= i;
|
||||
dk /= i;
|
||||
|
||||
if (br * target_dark > dk * target_bright)
|
||||
val = 0;
|
||||
|
@ -3078,14 +3071,6 @@ compute_averaged_planar (Genesys_Device * dev,
|
|||
else
|
||||
val = (dk * target_bright - br * target_dark) / (target_bright
|
||||
- target_dark);
|
||||
#if 0
|
||||
/*fill all pixels, even if only the last one is relevant */
|
||||
for (i = 0; i < avgpixels; i++)
|
||||
{
|
||||
shading_data[(x + o + i) * 2 * 2 + words_per_color * 2 * j] = val & 0xff;
|
||||
shading_data[(x + o + i) * 2 * 2 + words_per_color * 2 * j + 1] = val >> 8;
|
||||
}
|
||||
#endif
|
||||
shading_data[(x/avgpixels) * 2 * 2 + words_per_color * 2 * j] = val & 0xff;
|
||||
shading_data[(x/avgpixels) * 2 * 2 + words_per_color * 2 * j + 1] = val >> 8;
|
||||
|
||||
|
@ -3096,14 +3081,6 @@ compute_averaged_planar (Genesys_Device * dev,
|
|||
else
|
||||
val = 65535;
|
||||
|
||||
#if 0
|
||||
/*fill all pixels, even if only the last one is relevant */
|
||||
for (i = 0; i < avgpixels; i++)
|
||||
{
|
||||
shading_data[(x + o + i) * 2 * 2 + words_per_color * 2 * j + 2] = val & 0xff;
|
||||
shading_data[(x + o + i) * 2 * 2 + words_per_color * 2 * j + 3] = val >> 8;
|
||||
}
|
||||
#endif
|
||||
shading_data[(x/avgpixels) * 2 * 2 + words_per_color * 2 * j + 2] = val & 0xff;
|
||||
shading_data[(x/avgpixels) * 2 * 2 + words_per_color * 2 * j + 3] = val >> 8;
|
||||
}
|
||||
|
@ -3460,7 +3437,7 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
|
|||
break;
|
||||
case CIS_CANONLIDE100:
|
||||
case CIS_CANONLIDE200:
|
||||
/* we are using SHDAREA */
|
||||
/* we are using SHDAREA, and AVEENB is disabled */
|
||||
words_per_color=pixels_per_line*2;
|
||||
length = words_per_color * 3 * 2;
|
||||
compute_averaged_planar(dev,
|
||||
|
@ -3468,10 +3445,11 @@ genesys_send_shading_coefficient (Genesys_Device * dev)
|
|||
pixels_per_line,
|
||||
words_per_color,
|
||||
3,
|
||||
0,
|
||||
4,
|
||||
coeff,
|
||||
0xfa00,
|
||||
0x0a00);
|
||||
0xea00,
|
||||
0x0a00,
|
||||
SANE_TRUE);
|
||||
break;
|
||||
case CCD_CANONLIDE35:
|
||||
target_bright = 0xfa00;
|
||||
|
|
|
@ -437,7 +437,7 @@ static Genesys_Sensor Sensor[] = {
|
|||
200,
|
||||
{0x00, 0x00, 0x00, 0x00},
|
||||
/* reg 0x10 - 0x15 */
|
||||
{0x03, 0x00, 0x02, 0x00, 0x01, 0x80, /* EXPR/EXPG/EXPB */
|
||||
{0x01, 0xc1, 0x01, 0x26, 0x00, 0xe5, /* EXPR/EXPG/EXPB */
|
||||
/* reg 0x16 - 0x1d 0x19=0x50*/
|
||||
0x10, 0x08, 0x00, 0x50, 0x34, 0x00, 0x02, 0x04 },
|
||||
/* reg 0x52 - 0x5e */
|
||||
|
@ -931,8 +931,8 @@ static Genesys_Model canon_lide_100_model = {
|
|||
GENESYS_GL847,
|
||||
NULL,
|
||||
|
||||
{1200, 600, 300, 150, 100, 80, 0}, /* possible x-resolutions */
|
||||
{1200, 600, 300, 150, 100, 80, 0}, /* possible y-resolutions */
|
||||
{1200, 600, 300, 150, 100, 75, 0}, /* possible x-resolutions */
|
||||
{1200, 600, 300, 150, 100, 75, 0}, /* possible y-resolutions */
|
||||
{16, 8, 0}, /* possible depths in gray mode */
|
||||
{16, 8, 0}, /* possible depths in color mode */
|
||||
|
||||
|
|
|
@ -1470,12 +1470,9 @@ gl847_init_optical_regs_scan (Genesys_Device * dev,
|
|||
{
|
||||
r->value |= REG01_DVDSET;
|
||||
}
|
||||
r->value &= ~REG01_DVDSET; /* XXX STEF XXX */
|
||||
|
||||
/* average looks better than deletion, and we are already set up to
|
||||
use one of the average enabled resolutions */
|
||||
r = sanei_genesys_get_address (reg, REG03);
|
||||
r->value |= REG03_AVEENB;
|
||||
r->value &= ~REG03_AVEENB;
|
||||
if (flags & OPTICAL_FLAG_DISABLE_LAMP)
|
||||
r->value &= ~REG03_LAMPPWR;
|
||||
else
|
||||
|
@ -1834,7 +1831,7 @@ independent of our calculated values:
|
|||
exposure_time = sanei_genesys_exposure_time2 (dev,
|
||||
slope_dpi,
|
||||
scan_step_type,
|
||||
0,
|
||||
dev->sensor.dummy_pixel + 1 + dev->sensor.CCD_start_xoffset,
|
||||
led_exposure,
|
||||
scan_power_mode);
|
||||
|
||||
|
@ -1843,7 +1840,7 @@ independent of our calculated values:
|
|||
exposure_time2 = sanei_genesys_exposure_time2 (dev,
|
||||
slope_dpi,
|
||||
scan_step_type,
|
||||
0,
|
||||
dev->sensor.dummy_pixel + 1 + dev->sensor.CCD_start_xoffset,
|
||||
led_exposure,
|
||||
scan_power_mode + 1);
|
||||
if (exposure_time < exposure_time2)
|
||||
|
@ -2228,7 +2225,7 @@ dummy \ scanned lines
|
|||
exposure_time = sanei_genesys_exposure_time2 (dev,
|
||||
slope_dpi,
|
||||
scan_step_type,
|
||||
0,
|
||||
dev->sensor.dummy_pixel + 1 + dev->sensor.CCD_start_xoffset,
|
||||
led_exposure,
|
||||
scan_power_mode);
|
||||
|
||||
|
@ -2237,7 +2234,7 @@ dummy \ scanned lines
|
|||
exposure_time2 = sanei_genesys_exposure_time2 (dev,
|
||||
slope_dpi,
|
||||
scan_step_type,
|
||||
0,
|
||||
dev->sensor.dummy_pixel + 1 + dev->sensor.CCD_start_xoffset,
|
||||
led_exposure,
|
||||
scan_power_mode + 1);
|
||||
if (exposure_time < exposure_time2)
|
||||
|
@ -2324,10 +2321,7 @@ gl847_set_lamp_power (Genesys_Device * dev,
|
|||
r = sanei_genesys_get_address (regs, 0x10);
|
||||
for (i = 0; i < 6; i++, r++)
|
||||
{
|
||||
if (dev->sensor.regs_0x10_0x1d[i] == 0x00)
|
||||
r->value = 0x01; /*0x00 will not be accepted */
|
||||
else
|
||||
r->value = dev->sensor.regs_0x10_0x1d[i];
|
||||
r->value = dev->sensor.regs_0x10_0x1d[i];
|
||||
}
|
||||
r = sanei_genesys_get_address (regs, 0x19);
|
||||
r->value = 0x50;
|
||||
|
@ -2342,10 +2336,10 @@ gl847_set_lamp_power (Genesys_Device * dev,
|
|||
r = sanei_genesys_get_address (regs, 0x10);
|
||||
for (i = 0; i < 6; i++, r++)
|
||||
{
|
||||
r->value = 0x01; /* 0x0101 is as off as possible */
|
||||
r->value = 0x00;
|
||||
}
|
||||
r = sanei_genesys_get_address (regs, 0x19);
|
||||
r->value = 0x50;
|
||||
r->value = 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3730,12 +3724,10 @@ gl847_led_calibration (Genesys_Device * dev)
|
|||
dev->sensor.regs_0x10_0x1d[4] = (expb >> 8) & 0xff;
|
||||
dev->sensor.regs_0x10_0x1d[5] = expb & 0xff;
|
||||
|
||||
r = &(dev->calib_reg[reg_0x10]);
|
||||
for (i = 0; i < 6; i++, r++)
|
||||
{
|
||||
r = sanei_genesys_get_address (dev->calib_reg, 0x10+i);
|
||||
r->value = dev->sensor.regs_0x10_0x1d[i];
|
||||
RIE (sanei_genesys_write_register
|
||||
(dev, 0x10 + i, dev->sensor.regs_0x10_0x1d[i]));
|
||||
}
|
||||
|
||||
RIE (gl847_bulk_write_register
|
||||
|
@ -3747,7 +3739,7 @@ gl847_led_calibration (Genesys_Device * dev)
|
|||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
snprintf (fn, 20, "led_%d.pnm", turn);
|
||||
snprintf (fn, 20, "led_%02d.pnm", turn);
|
||||
sanei_genesys_write_pnm_file (fn,
|
||||
line, depth, channels, num_pixels, 1);
|
||||
}
|
||||
|
@ -3799,7 +3791,7 @@ gl847_led_calibration (Genesys_Device * dev)
|
|||
avge = (expr + expg + expb) / 3;
|
||||
|
||||
/* don't overflow max exposure */
|
||||
if (avge > 2712)
|
||||
if (avge > 3000)
|
||||
{
|
||||
expr = (expr * 2000) / avge;
|
||||
expg = (expg * 2000) / avge;
|
||||
|
|
Ładowanie…
Reference in New Issue