From d35e4a072f85e45e94d8da832a93b09309e2078d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Voltz?= Date: Sun, 16 Oct 2011 18:53:24 +0200 Subject: [PATCH] GL843 progress, working 1200 and 2400 dpi modes - shading is working using SHDAREA --- backend/genesys_gl843.c | 51 ++++++++++++++++++++++++++++++++++++++--- backend/genesys_gl843.h | 2 +- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/backend/genesys_gl843.c b/backend/genesys_gl843.c index da29a9667..2e95f7643 100644 --- a/backend/genesys_gl843.c +++ b/backend/genesys_gl843.c @@ -687,6 +687,7 @@ gl843_init_registers (Genesys_Device * dev) SETREG (0x03, 0x1d); SETREG (0x05, 0x08); SETREG (0x06, 0xd0); /* SCANMOD=110, PWRBIT and no GAIN4 */ + SETREG (0x06, 0xd8); /* SCANMOD=110, PWRBIT and GAIN4 */ SETREG (0x0a, 0x18); SETREG (0x0b, 0x69); SETREG (0x6b, 0xf4); @@ -1185,6 +1186,14 @@ gl843_init_optical_regs_scan (Genesys_Device * dev, { r->value |= REG01_DVDSET; } + if(dpihw>600) + { + r->value |= REG01_SHDAREA; + } + else + { + r->value &= ~REG01_SHDAREA; + } r = sanei_genesys_get_address (reg, REG03); r->value &= ~REG03_AVEENB; @@ -2643,6 +2652,7 @@ gl843_init_regs_for_shading (Genesys_Device * dev) { SANE_Status status; int move, resolution, dpihw, factor; + uint16_t strpixel; DBGSTART; @@ -2687,6 +2697,8 @@ gl843_init_regs_for_shading (Genesys_Device * dev) } dev->scanhead_position_in_steps += dev->calib_lines + move; + sanei_genesys_get_double(dev->calib_reg,REG_STRPIXEL,&strpixel); + DBG (DBG_info, "%s: STRPIXEL=%d\n", __FUNCTION__, strpixel); status = gl843_bulk_write_register (dev, dev->calib_reg, GENESYS_GL843_MAX_REGS); if (status != SANE_STATUS_GOOD) @@ -4089,8 +4101,41 @@ gl843_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) uint8_t *final_data; uint8_t *buffer; int i,count,offset; + unsigned int tgtime; + unsigned int cksel; + Genesys_Register_Set *r; + uint16_t dpiset, strpixel, startx, factor; DBGSTART; + + offset=0; + r = sanei_genesys_get_address (dev->reg, REG01); + if(r->value & REG01_SHDAREA) + { + /* recompute STRPIXEL used shading calibration so we can + * compute offset within data for SHDAREA case */ + r = sanei_genesys_get_address (dev->reg, REG18); + cksel= (r->value & REG18_CKSEL)+1; + sanei_genesys_get_double(dev->reg,REG_DPISET,&strpixel); + tgtime=1; + sanei_genesys_get_double(dev->reg,REG_DPISET,&dpiset); + factor=dev->sensor.optical_res/sanei_genesys_compute_dpihw(dev,dpiset); + if (dev->model->ccd_type == CCD_G4050 && dpiset>2400) + { + tgtime=2; + } + + /* start coordinate in optical dpi coordinates */ + startx = ((dev->sensor.dummy_pixel * tgtime)/cksel)/factor; + + /* current scan coordinates */ + sanei_genesys_get_double(dev->reg,REG_STRPIXEL,&strpixel); + strpixel*=tgtime; + + /* 16 bit words, 2 words per color, 3 color channels */ + offset=(strpixel-startx)*2*2*3; + DBG (DBG_info, "%s: STRPIXEL=%d, startx=%d\n", __FUNCTION__, strpixel,startx); + } /* compute and allocate size for final data */ final_size = (size / 252) * 256 + 512; @@ -4098,17 +4143,17 @@ gl843_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) final_data = (uint8_t *) malloc (final_size); if(final_data==NULL) { - DBG (DBG_error, "%s: failed to allocate memory for shding data\n", __FUNCTION__); + DBG (DBG_error, "%s: failed to allocate memory for shading data\n", __FUNCTION__); return SANE_STATUS_NO_MEM; } + memset(final_data,0x00,final_size); /* copy regular shading data to the expected layout */ buffer = final_data; count = 0; - offset = 0; /* loop over calibration data */ - for (i = offset; i < size-offset; i++) + for (i = offset; i < size; i++) { buffer[count] = data[i]; count++; diff --git a/backend/genesys_gl843.h b/backend/genesys_gl843.h index 19db2f658..79b404a3e 100644 --- a/backend/genesys_gl843.h +++ b/backend/genesys_gl843.h @@ -605,7 +605,7 @@ static Sensor_Profile sensors[]={ {0x0c, 0x0f, 0x00, 0x03, 0x06, 0x09, 0x6b, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x23}, }, - {CCD_G4050 , 600, 8016, 0x0001ff, 0x03ffff, 0x03ffff, 5168, 0, 0x2a, 0, 0, 0, 0x00, 0x00, 0x02, 0x00, 0x03, + {CCD_G4050 , 600, 8016, 0x0001ff, 0x03ffff, 0x03ffff, 5168, 0, 0x2a, 0, 0, 0, 0x00, 0x00, 0x02, 0x00, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x0c, 0x00, 0x2a, 0x30, 0x00, 0x00, 0x08} , {0x0b, 0x0e, 0x11, 0x02, 0x05, 0x08, 0x63, 0x00, 0x40, 0x00, 0x00, 0x00, 0x63}, },