From e1f9664106039a4ab21f8d724f0f00d2013d2577 Mon Sep 17 00:00:00 2001 From: Jonathan Bravo Lopez Date: Wed, 13 Feb 2008 06:35:26 +0000 Subject: [PATCH] Added support for a new scanner: HP ScanJet G2710 Minor changes --- ChangeLog | 7 ++ backend/hp3900.c | 2 +- backend/hp3900.conf.in | 3 + backend/hp3900_config.c | 28 +++++++- backend/hp3900_debug.c | 1 + backend/hp3900_rts8822.c | 131 ++++++++++++++++++----------------- backend/hp3900_sane.c | 18 +++-- backend/hp3900_types.c | 7 +- backend/hp3900_usb.c | 2 +- doc/descriptions/hp3900.desc | 8 ++- doc/sane-hp3900.man | 3 +- 11 files changed, 133 insertions(+), 77 deletions(-) diff --git a/ChangeLog b/ChangeLog index b12c82792..6ba48d5dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-02-13 Jonathan Bravo Lopez + * backend/hp3900.c, backend/hp3900_debug.c, backend/hp3900_rts8822.c, + backend/hp3900_usb.c, backend/hp3900_sane.c, backend/hp3900_types.c, + backend/hp3900_config.c, backend/hp3900.conf.in, /doc/sane-hp3900.man, + doc/descriptions/hp3900.desc: Minor changes and added support for + HP ScanJet G2710 scanner. + 2008-02-10 m. allan noah * configure configure.in: Changed version to 1.0.19-cvs. Enabled diff --git a/backend/hp3900.c b/backend/hp3900.c index be3eebcd4..46ec673a8 100644 --- a/backend/hp3900.c +++ b/backend/hp3900.c @@ -43,7 +43,7 @@ /* Backend info */ #define BACKEND_NAME hp3900 -#define BACKEND_VRSN "0.11" +#define BACKEND_VRSN "0.12" #define BACKEND_AUTHOR "Jonathan Bravo Lopez (JKD)" #define BACKEND_EMAIL "jkdsoft@gmail.com" #define BACKEND_URL "http://jkdsoftware.dyndns.org" diff --git a/backend/hp3900.conf.in b/backend/hp3900.conf.in index 37323c5f3..d24e036b4 100644 --- a/backend/hp3900.conf.in +++ b/backend/hp3900.conf.in @@ -14,6 +14,9 @@ usb 0x03f0 0x2405 # HP Scanjet 4370 usb 0x03f0 0x4105 +# HP Scanjet G2710 +usb 0x03f0 0x2805 + # HP Scanjet G3010 usb 0x03f0 0x4205 diff --git a/backend/hp3900_config.c b/backend/hp3900_config.c index 427638614..5bb55fc13 100644 --- a/backend/hp3900_config.c +++ b/backend/hp3900_config.c @@ -371,6 +371,7 @@ static SANE_Int cfg_device_get(SANE_Int product, SANE_Int vendor) { 0x4a5, 0x2211, BQ5550 }, /* BenQ 5550 */ { 0x6dc, 0x0020, UA4900 }, /* UMAX Astra 4900 */ { 0x3f0, 0x2605, HP3800 }, /* HP Scanjet 3800 */ + { 0x3f0, 0x2805, HPG2710}, /* HP Scanjet G2710 */ { 0x3f0, 0x2305, HP3970 }, /* HP Scanjet 3970c */ { 0x3f0, 0x2405, HP4070 }, /* HP Scanjet 4070 Photosmart */ { 0x3f0, 0x4105, HP4370 }, /* HP Scanjet 4370 */ @@ -405,6 +406,7 @@ static SANE_Int cfg_chipset_model_get(SANE_Int device) { /*device , chipset */ { HP3800 , RTS8822BL_03A }, + { HPG2710, RTS8822BL_03A }, { BQ5550 , RTS8823L_01E }, { UA4900 , RTS8822L_01H }, { HP3970 , RTS8822L_01H }, @@ -488,6 +490,7 @@ static SANE_Int cfg_buttons_get(struct st_buttons *reg) { BQ5550 , {3 , {0x01, 0x02, 0x08, -1, -1, -1}}}, { UA4900 , {4 , {0x04, 0x08, 0x02, 0x01, -1, -1}}}, { HP3800 , {3 , {0x01, 0x02, 0x04, -1, -1, -1}}}, + { HPG2710, {3 , {0x01, 0x02, 0x04, -1, -1, -1}}}, { HP3970 , {4 , {0x04, 0x08, 0x02, 0x01, -1, -1}}}, { HP4070 , {4 , {0x04, 0x08, 0x02, 0x01, -1, -1}}}, { HP4370 , {4 , {0x04, 0x08, 0x02, 0x01, -1, -1}}}, @@ -531,6 +534,7 @@ static SANE_Int cfg_sscg_get(SANE_Int *enable, SANE_Int *mode, SANE_Int *clock) { BQ5550, {1 , 1, 1}}, { UA4900, {1 , 1, 0}}, { HP3800, {1 , 1, 0}}, + {HPG2710, {1 , 1, 0}}, { HP3970, {1 , 1, 0}}, { HP4070, {1 , 1, 0}}, { HP4370, {1 , 1, 0}}, @@ -580,6 +584,7 @@ static SANE_Int cfg_motor_get(struct st_motorcfg *reg) { BQ5550, {MT_OUTPUTSTATE, 1200, 30, 800, 1, 0, 0, TRUE}}, { UA4900, {MT_OUTPUTSTATE, 2400, 30, 800, 1, 0, 0, TRUE}}, { HP3800, {MT_OUTPUTSTATE, 1200, 30, 800, 1, 0, 0, TRUE}}, + {HPG2710, {MT_OUTPUTSTATE, 1200, 30, 800, 1, 0, 0, TRUE}}, { HP3970, {MT_OUTPUTSTATE, 2400, 30, 800, 1, 0, 0, TRUE}}, { HP4070, {MT_OUTPUTSTATE, 2400, 30, 800, 1, 0, 0, TRUE}}, { HP4370, {MT_OUTPUTSTATE, 2400, 30, 800, 1, 0, 0, TRUE}}, @@ -627,6 +632,7 @@ static SANE_Int cfg_sensor_get(struct st_sensorcfg *reg) { BQ5550, {CCD_SENSOR, -1, 1200 , {CL_BLUE, CL_GREEN, CL_RED }, {CL_GREEN, 0}, {CL_BLUE, CL_GREEN, CL_RED }, 24 , 4 }}, { UA4900, {CIS_SENSOR, SNYS575, 2400 , {CL_RED , CL_GREEN, CL_BLUE}, {CL_RED , 0}, {CL_RED , CL_GREEN, CL_BLUE}, 24 , 0 }}, { HP3800, {CCD_SENSOR, TCD2905, 2400 , {CL_RED , CL_GREEN, CL_BLUE}, {CL_RED , 0}, {CL_RED , CL_GREEN, CL_BLUE}, 64 , 8 }}, + {HPG2710, {CCD_SENSOR, TCD2905, 2400 , {CL_RED , CL_GREEN, CL_BLUE}, {CL_RED , 0}, {CL_RED , CL_GREEN, CL_BLUE}, 64 , 8 }}, { HP3970, {CCD_SENSOR, TCD2952, 2400 , {CL_RED , CL_GREEN, CL_BLUE}, {CL_RED , 0}, {CL_RED , CL_GREEN, CL_BLUE}, 24 , 4 }}, { HP4070, {CCD_SENSOR, TCD2952, 2400 , {CL_RED , CL_GREEN, CL_BLUE}, {CL_RED , 0}, {CL_RED , CL_GREEN, CL_BLUE}, 24 , 4 }}, { HP4370, {CCD_SENSOR, TCD2958, 4800 , {CL_RED , CL_GREEN, CL_BLUE}, {CL_RED , 0}, {CL_RED , CL_GREEN, CL_BLUE}, 128 , 6 }}, @@ -734,6 +740,7 @@ static void cfg_refvoltages_get(SANE_Int sensortype, SANE_Byte *vrts, SANE_Byte switch(RTS_Debug->dev_model) { case HP3800: + case HPG2710: hp3800_refvoltages(RTS_Debug->usbtype, sensortype, vrts, vrms, vrbs); break; default: @@ -948,6 +955,7 @@ static void cfg_offset_get(SANE_Int sensortype, SANE_Int resolution, SANE_Int sc break; case HP3800: + case HPG2710: hp3800_offset(resolution, scantype, left, width); break; @@ -981,6 +989,7 @@ static SANE_Int cfg_constrains_get(struct st_constrains *constrain) /* , {{left, width, top, height}, {left, width, top, height}, {left, width, top, height}}}, */ { BQ5550 , {{ 0, 220, 0, 300}, { 88, 42, 0, 83}, { 88, 42, 0, 83}}}, { HP3800 , {{ 0, 220, 0, 300}, { 89, 45, 0, 85}, { 89, 45, 0, 100}}}, + {HPG2710 , {{ 0, 220, 0, 300}, { 89, 45, 0, 85}, { 89, 45, 0, 100}}}, { HP3970 , {{ 0, 220, 0, 300}, { 88, 42, 0, 83}, { 88, 42, 0, 83}}}, { HP4070 , {{ 0, 220, 0, 300}, { 58, 99, 0, 197}, { 58, 99, 0, 197}}}, { HP4370 , {{ 0, 220, 0, 300}, { 90, 45, 0, 85}, { 90, 45, 0, 100}}}, @@ -1063,6 +1072,7 @@ static void cfg_autoref_get(struct st_autoref *reg) { BQ5550 , {REF_NONE , -40, -40, 600 , 40}}, { UA4900 , {REF_NONE , -40, -40, 600 , 40}}, { HP3800 , {REF_TAKEFROMSCANNER, 88, 624, 600 , 40}}, + {HPG2710 , {REF_TAKEFROMSCANNER, 88, 624, 600 , 40}}, { HP3970 , {REF_TAKEFROMSCANNER, 88, 717, 600 , 40}}, { HP4070 , {REF_TAKEFROMSCANNER, 88, 717, 600 , 40}}, { HP4370 , {REF_TAKEFROMSCANNER, 88, 717, 600 , 40}}, @@ -1229,6 +1239,7 @@ static SANE_Int cfg_effectivepixel_get(SANE_Int sensortype, SANE_Int resolution) break; case HP3800: + case HPG2710: rst = hp3800_effectivepixel(resolution); break; @@ -1441,6 +1452,7 @@ static SANE_Int cfg_gainoffset_get(SANE_Int sensortype, struct st_gain_offset *r break; case HP3800: + case HPG2710: rst = hp3800_gainoffset(RTS_Debug->usbtype, reg); break; @@ -1614,6 +1626,7 @@ static SANE_Int cfg_checkstable_get(SANE_Int lamp, struct st_checkstable *check) break; case HP3800: + case HPG2710: rst = hp3800_checkstable(lamp, check); break; @@ -1775,6 +1788,7 @@ static SANE_Int cfg_fixedpwm_get(SANE_Int sensortype, SANE_Int scantype) break; case HP3800: + case HPG2710: rst = hp3800_fixedpwm(scantype, RTS_Debug->usbtype); break; @@ -1798,6 +1812,7 @@ static void cfg_vrefs_get(SANE_Int sensortype, SANE_Int res, SANE_Int *ser, SANE switch(RTS_Debug->dev_model) { case HP3800: + case HPG2710: hp3800_vrefs(res, ser, ler); break; @@ -1969,6 +1984,7 @@ static SANE_Int cfg_motormove_get(SANE_Int sensortype, SANE_Int item, struct st_ rst = bq5550_motormove(item, reg); break; case HP3800: + case HPG2710: rst = hp3800_motormove(item, reg); break; @@ -2098,6 +2114,7 @@ static SANE_Int cfg_scanmode_get(SANE_Int sensortype, SANE_Int sm, struct st_sca break; case HP3800: + case HPG2710: rst = hp3800_scanmodes(RTS_Debug->usbtype, sm, mymode); break; @@ -2384,7 +2401,7 @@ static SANE_Int hp4370_scanmodes(SANE_Int usb, SANE_Int sm, struct st_scanmode * {USB20, {ST_NEG , CM_COLOR , 150, 0x04 , 3 , PIXEL_RATE, 0x04 , 14879, 256 , STT_HALF, 0x00 , { 4959, 9919, 0}, { 4959, 4959, 14879}, 0 , 1 , 1 , 0x01 , 0x01, 0x10, 0x02 , 0x02 , 0x00 }}, {USB20, {ST_NEG , CM_GRAY , 4800, 0x0D , -1 , LINE_RATE , 0x05 , 60599, 256 , STT_FULL, 0x00 , {30299, 30299, 30299}, {30299, 30299, 30299}, 0 , 1 , 1 , 0x01 , 0x01, 0x10, 0x02 , 0x02 , 0x00 }}, - {USB20, {ST_NEG , CM_GRAY , 2400, 0x06 , -1 , LINE_RATE , 0x05 , 145799, 256 , STT_FULL, 0x00 , {48599, 97199, 0}, {48599, 48599, 145799}, 0 , 1 , -1 , 0x01 , 0x01, 0x10, 0x02 , 0x02 , 0x00 }}, + {USB20, {ST_NEG , CM_GRAY , 2400, 0x06 , -1 , LINE_RATE , 0x05 ,145799, 256 , STT_FULL, 0x00 , {48599, 97199, 0}, {48599, 48599, 145799}, 0 , 1 , -1 , 0x01 , 0x01, 0x10, 0x02 , 0x02 , 0x00 }}, {USB20, {ST_NEG , CM_GRAY , 1200, 0x07 , -1 , LINE_RATE , 0x05 , 89999, 256 , STT_FULL, 0x00 , {29999, 59999, 0}, {29999, 29999, 89999}, 0 , 1 , 1 , 0x01 , 0x01, 0x10, 0x02 , 0x02 , 0x00 }}, {USB20, {ST_NEG , CM_GRAY , 600, 0x08 , -1 , LINE_RATE , 0x05 , 45999, 256 , STT_HALF, 0x00 , {15333, 30666, 0}, {15333, 15333, 45999}, 0 , 1 , 1 , 0x01 , 0x01, 0x10, 0x02 , 0x02 , 0x00 }}, {USB20, {ST_NEG , CM_GRAY , 300, 0x09 , -1 , LINE_RATE , 0x04 , 14879, 256 , STT_HALF, 0x00 , { 4959, 9919, 0}, { 4959, 4959, 14879}, 0 , 1 , 1 , 0x01 , 0x01, 0x10, 0x02 , 0x02 , 0x00 }}, @@ -3127,6 +3144,7 @@ static void cfg_wrefs_get(SANE_Int sensortype, SANE_Int depth, SANE_Int res, SAN break; case HP3800: + case HPG2710: hp3800_wrefs(res, scantype, red, green, blue); break; @@ -3499,6 +3517,7 @@ static void cfg_shading_cut_get(SANE_Int sensortype, SANE_Int depth, SANE_Int re break; case HP3800: + case HPG2710: hp3800_shading_cut(res, scantype, red, green, blue); break; @@ -3731,6 +3750,7 @@ static SANE_Int cfg_timing_get(SANE_Int sensortype, SANE_Int tm, struct st_timin break; case HP3800: + case HPG2710: rst = hp3800_timing_get(tm, reg); break; @@ -4127,6 +4147,7 @@ static SANE_Int *cfg_motorcurve_get() break; case HP3800: + case HPG2710: rst = hp3800_motor(); break; @@ -4517,6 +4538,7 @@ static int fc_calibreflective(int option, int defvalue) switch(RTS_Debug->dev_model) { case UA4900: rst = ua4900_calibreflective(option, defvalue); break; + case HPG2710: case HP3800: rst = hp3800_calibreflective(option, defvalue); break; case HPG3010: case HP4370: rst = hp4370_calibreflective(option, defvalue); break; @@ -4900,6 +4922,7 @@ static int fc_calibtransparent(int option, int defvalue) switch(RTS_Debug->dev_model) { case UA4900: rst = ua4900_calibtransparent(option, defvalue); break; + case HPG2710: case HP3800: rst = hp3800_calibtransparent(option, defvalue); break; case HPG3010: case HP4370: rst = hp4370_calibtransparent(option, defvalue); break; @@ -5286,6 +5309,7 @@ static int fc_calibnegative(int option, int defvalue) switch(RTS_Debug->dev_model) { case UA4900: rst = ua4900_calibnegative(option, defvalue); break; + case HPG2710: case HP3800: rst = hp3800_calibnegative(option, defvalue); break; case HPG3010: case HP4370: rst = hp4370_calibnegative(option, defvalue); break; @@ -5725,6 +5749,7 @@ static int srt_sec_get(int file, int section, int option, int defvalue) case SCAN_PARAM: switch(RTS_Debug->dev_model) { + case HPG2710: case HP3800: rst = srt_hp3800_scanparam_get(option, defvalue); break; case HPG3010: case HP4370: rst = srt_hp4370_scanparam_get(file, option, defvalue); break; @@ -5740,6 +5765,7 @@ static int srt_sec_get(int file, int section, int option, int defvalue) case PLATFORM: switch(RTS_Debug->dev_model) { + case HPG2710: case HP3800: rst = srt_hp3800_platform_get(option, defvalue); break; case UA4900: rst = srt_ua4900_platform_get(option, defvalue); break; case HPG3010: diff --git a/backend/hp3900_debug.c b/backend/hp3900_debug.c index cdd054380..b173f174e 100644 --- a/backend/hp3900_debug.c +++ b/backend/hp3900_debug.c @@ -729,6 +729,7 @@ dbg_autoref (struct st_scanparams *scancfg, SANE_Byte * pattern, } #ifdef developing + static void dbg_buffer (SANE_Int level, char *title, SANE_Byte * buffer, SANE_Int size, SANE_Int start) diff --git a/backend/hp3900_rts8822.c b/backend/hp3900_rts8822.c index ff1045b45..88755ad90 100644 --- a/backend/hp3900_rts8822.c +++ b/backend/hp3900_rts8822.c @@ -613,7 +613,6 @@ RTS_Scanner_Init (struct st_device *dev) SANE_Int rst; DBG (DBG_FNC, "> RTS_Scanner_Init:\n"); - DBG (DBG_FNC, "> Backend version: %s\n", BACKEND_VRSN); rst = ERROR; @@ -986,7 +985,6 @@ RTS_Sensor_Type (USB_Handle usb_handle) SANE_Int a, b, c; SANE_Byte rst; - char *strccd[] = { "CCD", "CIS" }; DBG (DBG_FNC, "+ RTS_Sensor_Type:\n"); @@ -1010,8 +1008,8 @@ RTS_Sensor_Type (USB_Handle usb_handle) rst = ((_B1 (c) & 1) == 0) ? CCD_SENSOR : CIS_SENSOR; - a = (rst == CCD_SENSOR) ? 0 : 1; - DBG (DBG_FNC, "- RTS_Sensor_Type: %s\n", strccd[a]); + DBG (DBG_FNC, "- RTS_Sensor_Type: %s\n", + (rst == CCD_SENSOR) ? "CCD" : "CIS"); return rst; } @@ -3704,8 +3702,8 @@ Init_Registers (struct st_device *dev) dev->init_regs[0x600] &= 0xfb; dev->init_regs[0x1d8] |= 0x08; - v160c = 0x04; - v1610 = 0x80000; + v160c_block_size = 0x04; + mem_total = 0x80000; /* check and setup installed ram */ RTS_DMA_CheckType (dev, dev->init_regs); @@ -3809,7 +3807,9 @@ RTS_WaitScanEnd (struct st_device *dev, SANE_Int msecs) long ticks = GetTickCount () + msecs; rst = OK; while (((data & 0x80) != 0) && (ticks > GetTickCount ()) && (rst == OK)) - rst = Read_Byte (dev->usb_handle, 0xe800, &data); + { + rst = Read_Byte (dev->usb_handle, 0xe800, &data); + } } DBG (DBG_FNC, "- RTS_WaitScanEnd: Ending with rst=%i\n", rst); @@ -7781,7 +7781,7 @@ Scan_Read_BufferA (struct st_device *dev, SANE_Int buffer_size, SANE_Int arg2, opStatus = Reading_Wait (dev, rd->Channels_per_dot, rd->Channel_size, iAmount, - &rd->Bytes_Available, 90, sc); + &rd->Bytes_Available, 10, sc); /* If something fails, perhaps we can read some bytes... */ if (opStatus != OK) @@ -7916,8 +7916,9 @@ static SANE_Int Get_Scanner_Buffer_Size (struct st_device *dev, SANE_Byte channels_per_dot, SANE_Int channel_size) { + /* returns the ammount of bytes in scanner's buffer ready to be read */ + SANE_Int rst; - SANE_Int myAmount; DBG (DBG_FNC, "+ Get_Scanner_Buffer_Size(channels_per_dot=%i, channel_size=%i):\n", @@ -7925,22 +7926,25 @@ Get_Scanner_Buffer_Size (struct st_device *dev, SANE_Byte channels_per_dot, rst = 0; - if (channels_per_dot < 1) + if (channel_size > 0) { - if (Read_Byte (dev->usb_handle, 0xe812, &channels_per_dot) == OK) - channels_per_dot = _B0 (channels_per_dot >> 6); + SANE_Int myAmount; - if (channels_per_dot == 0) - channels_per_dot++; - } + if (channels_per_dot < 1) + { + /* read channels per dot from registers */ + if (Read_Byte (dev->usb_handle, 0xe812, &channels_per_dot) == OK) + channels_per_dot = _B0 (channels_per_dot >> 6); - if (Read_Integer (dev->usb_handle, 0xef16, &myAmount) == OK) - { - if (channel_size > 0) + if (channels_per_dot == 0) + channels_per_dot++; + } + + if (Read_Integer (dev->usb_handle, 0xef16, &myAmount) == OK) rst = ((channels_per_dot * 32) / channel_size) * myAmount; } - DBG (DBG_FNC, "- Get_Scanner_Buffer_Size: %i\n", rst); + DBG (DBG_FNC, "- Get_Scanner_Buffer_Size: %i bytes\n", rst); return rst; } @@ -7949,16 +7953,17 @@ static SANE_Int Lamp_Warmup (struct st_device *dev, SANE_Byte * Regs, SANE_Int lamp) { SANE_Int rst = OK; - SANE_Byte flb_lamp, tma_lamp; DBG (DBG_FNC, "+ Lamp_Warmup(*Regs, lamp=%i)\n", lamp); if (Regs != NULL) { + SANE_Byte flb_lamp, tma_lamp; SANE_Int overdrivetime; Lamp_GetStatus (dev, &flb_lamp, &tma_lamp); + /* ensure that selected lamp is switched on */ if (lamp == FLB_LAMP) { overdrivetime = RTS_Debug->overdrive_flb; @@ -7972,6 +7977,7 @@ Lamp_Warmup (struct st_device *dev, SANE_Byte * Regs, SANE_Int lamp) } else { + /* is tma device attached to scanner ? */ if (RTS_isTmaAttached (dev) == TRUE) { overdrivetime = RTS_Debug->overdrive_ta; @@ -7987,7 +7993,8 @@ Lamp_Warmup (struct st_device *dev, SANE_Byte * Regs, SANE_Int lamp) rst = ERROR; } - /**/ if (rst == OK) + /* perform warmup process */ + if (rst == OK) { if (waitforpwm == TRUE) Lamp_OverDrive (dev, overdrivetime, lamp); @@ -8100,16 +8107,10 @@ Scan_Start (struct st_device *dev) /* No need find ref */ /*57d9 */ - if (scan.scantype == ST_NORMAL) - { - Lamp_Warmup (dev, Regs, FLB_LAMP); - } - else - { - /*5836 */ - if (Lamp_Warmup (dev, Regs, TMA_LAMP) == ERROR) - return ERROR; - } + if (Lamp_Warmup + (dev, Regs, + (scan.scantype == ST_NORMAL) ? FLB_LAMP : TMA_LAMP) == ERROR) + return ERROR; /*5895 */ Refs_Set (dev, Regs, &scancfg, FALSE); @@ -8127,10 +8128,7 @@ Scan_Start (struct st_device *dev) if (v14b4 == 0) { /*590a */ - if (scan.scantype == ST_NORMAL) - lamp = FLB_LAMP; - else - lamp = TMA_LAMP; + lamp = (scan.scantype == ST_NORMAL) ? FLB_LAMP : TMA_LAMP; } else lamp = 0; /* preview */ @@ -8874,9 +8872,9 @@ RTS_Setup_Shading (SANE_Byte * Regs, struct st_scanparams *scancfg, if ((Regs != NULL) && (hwdcfg != NULL)) { - SANE_Int dots_count, myvalue, myvalue2, mydata, resolution_ratio, + SANE_Int dots_count, myvalue, myvalue2, mem_available, resolution_ratio, sensor_line_distance; - SANE_Int table_size; + SANE_Int channels, table_size; resolution_ratio = Regs[0x0c0] & 0x1f; @@ -8907,7 +8905,7 @@ RTS_Setup_Shading (SANE_Byte * Regs, struct st_scanparams *scancfg, to some buffer related to shading correction */ Regs[0x1ba] = 0x00; - table_size = (v160c + table_size - 1) / v160c; + table_size = (table_size + v160c_block_size - 1) / v160c_block_size; table_size = ((table_size + 15) / 16) + 16; Regs[0x1bf] &= 0xfe; @@ -8922,56 +8920,59 @@ RTS_Setup_Shading (SANE_Byte * Regs, struct st_scanparams *scancfg, data_wide_bitset (&Regs[0x1c0], 0xfffff, table_size * 3); - mydata = v1610 - ((table_size * 3) * 16); - - dots_count = bytes_per_line; - + mem_available = mem_total - ((table_size * 3) * 16); sensor_line_distance = Regs[0x14a] & 0x3f; /* select case channels_per_dot */ - switch ((data_lsb_get (&Regs[0x12], 1) >> 6)) + channels = data_lsb_get (&Regs[0x12], 1) >> 6; + + switch (channels) { case 3: /* 3 channels per dot */ /* 528d */ dots_count = bytes_per_line / 3; /* 882 */ myvalue = - (((sensor_line_distance + 1) * dots_count) + v160c - 1) / v160c; + (((sensor_line_distance + 1) * dots_count) + v160c_block_size - + 1) / v160c_block_size; myvalue2 = myvalue; - mydata = (mydata - (myvalue * 3) + 2) / 3; + mem_available = (mem_available - (myvalue * 3) + 2) / 3; - myvalue += (data_lsb_get (&Regs[0x1c0], 3) & 0x0fffff) * 8; - myvalue = (((myvalue * 2) + mydata) >> 4) + 1; + myvalue += (table_size * 3) * 8; + myvalue = ((myvalue * 2) + mem_available); - data_bitset (&Regs[0x1c2], 0xf0, _B2 (myvalue)); /* 4 higher bits xxxx---- */ - data_wide_bitset (&Regs[0x1c3], 0xffff, myvalue); /* 16 lower bits */ + data_bitset (&Regs[0x1c2], 0xf0, _B2 ((myvalue / 16) + 1)); /* 4 higher bits xxxx---- */ + data_wide_bitset (&Regs[0x1c3], 0xffff, (myvalue / 16) + 1); /* 16 lower bits */ - myvalue = (((myvalue << 4) + myvalue2 + mydata) >> 4) + 1; - data_wide_bitset (&Regs[0x1c5], 0xfffff, myvalue); + myvalue = myvalue + myvalue2 + mem_available; + data_wide_bitset (&Regs[0x1c5], 0xfffff, (myvalue / 16) + 1); break; case 2: /* 2 channels per dot */ dots_count = bytes_per_line / 2; myvalue = - (((sensor_line_distance + 1) * dots_count) + v160c - 1) / v160c; - mydata = ((mydata - myvalue) + 1) / 2; - myvalue += - (((data_lsb_get (&Regs[0x1c0], 3) & 0x0fffff) + mydata) / 16) + 1; + (((sensor_line_distance + 1) * dots_count) + v160c_block_size - + 1) / v160c_block_size; + mem_available = ((mem_available - myvalue) + 1) / 2; + myvalue += (((table_size * 3) + mem_available) / 16) + 1; data_bitset (&Regs[0x1c2], 0xf0, _B2 (myvalue)); /* 4 higher bits xxxx---- */ data_wide_bitset (&Regs[0x1c3], 0xffff, myvalue); /* 16 lower bits */ break; + default: + dots_count = bytes_per_line; + break; } Regs[0x01c7] &= 0x0f; - Regs[0x01c8] = _B0 ((v1610 - 1) / 16); - Regs[0x01c9] = _B1 ((v1610 - 1) / 16); - Regs[0x01c7] |= (_B2 ((v1610 - 1) / 16) & 0x0f) << 4; + Regs[0x01c8] = _B0 ((mem_total - 1) / 16); + Regs[0x01c9] = _B1 ((mem_total - 1) / 16); + Regs[0x01c7] |= (_B2 ((mem_total - 1) / 16) & 0x0f) << 4; - mydata -= (v160c + dots_count - 1) / v160c; - mydata /= 16; + mem_available -= (dots_count + v160c_block_size - 1) / v160c_block_size; + mem_available /= 16; Regs[0x0712] &= 0x0f; - Regs[0x0710] = _B0 (mydata); - Regs[0x0711] = _B1 (mydata); - Regs[0x0712] |= _B0 (_B2 (mydata) << 4); /*xxxx---- */ + Regs[0x0710] = _B0 (mem_available); + Regs[0x0711] = _B1 (mem_available); + Regs[0x0712] |= _B0 (_B2 (mem_available) << 4); /*xxxx---- */ Regs[0x0713] = 0x00; Regs[0x0714] = 0x10; @@ -10834,7 +10835,9 @@ Lamp_OverDrive (struct st_device *dev, SANE_Int itime, SANE_Int lamp) DBG (DBG_VRB, "- Lamp Warmup process. Please wait...\n"); while (GetTickCount () <= ticks) - usleep (1000 * 200); + { + usleep (1000 * 200); + } } else DBG (DBG_FNC, " -> warmup disabled\n"); diff --git a/backend/hp3900_sane.c b/backend/hp3900_sane.c index 2aa3f85dd..c26c0d9c3 100644 --- a/backend/hp3900_sane.c +++ b/backend/hp3900_sane.c @@ -283,6 +283,7 @@ bknd_resolutions (TScanner * scanner, SANE_Int model) } break; + case HPG2710: case HP3800: { /* 1200 and 2400 dpi are disabled until problems are solved */ @@ -345,7 +346,7 @@ bknd_models (TScanner * scanner) /* at this moment all devices use the same list */ SANE_String_Const mymodel[] = { "HP3800", "HP3970", "HP4070", "HP4370", "UA4900", "HPG3010", -"BQ5550", 0 }; +"BQ5550", "HPG2710", 0 }; /* allocate space to save list */ model = (SANE_String_Const *) malloc (sizeof (mymodel)); @@ -636,9 +637,9 @@ set_ScannerModel (SANE_Int proposed, SANE_Int product, SANE_Int vendor) /* This function will set the device behaviour */ SANE_Int current = Device_get (product, vendor); - char *sdevname[8] = + char *sdevname[9] = { "Unknown", "HP3970", "HP4070", "HP4370", "UA4900", "HP3800", "HPG3010", -"BQ5550" }; +"BQ5550", "HPG2710" }; DBG (DBG_FNC, "> set_ScannerModel(proposed=%i, product=%04x, vendor=%04x)\n", @@ -981,6 +982,8 @@ Get_Model (SANE_String model) if (strcmp (model, "HP3800") == 0) rst = HP3800; + else if (strcmp (model, "HPG2710") == 0) + rst = HPG2710; else if (strcmp (model, "HP3970") == 0) rst = HP3970; else if (strcmp (model, "HP4070") == 0) @@ -1505,7 +1508,7 @@ options_init (TScanner * scanner) pDesc->title = SANE_I18N ("Emulate Grayscale"); pDesc->desc = SANE_I18N - ("If enabled, image will be scanned in color mode and then converted to grayscale by software. This may improve image quality in some circumstances."); + ("If enabled, image will be scanned in color mode and then converted to grayscale by software. This uses to improve image quality in some circumstances."); pDesc->type = SANE_TYPE_BOOL; pDesc->unit = SANE_UNIT_NONE; pDesc->size = sizeof (SANE_Word); @@ -1643,7 +1646,7 @@ options_init (TScanner * scanner) pDesc->title = strdup (title); pDesc->desc = SANE_I18N - ("This option reflects a front panel scanner button"); + ("This option reflects a front pannel scanner button"); pDesc->type = SANE_TYPE_BOOL; pDesc->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; @@ -1712,6 +1715,10 @@ attach_one_device (SANE_String_Const devname) sModel.pszVendor = (char *) strdup ("Hewlett-Packard"); sModel.pszName = (char *) strdup ("Scanjet 3800"); break; + case HPG2710: + sModel.pszVendor = (char *) strdup ("Hewlett-Packard"); + sModel.pszName = (char *) strdup ("Scanjet G2710"); + break; case HP3970: sModel.pszVendor = (char *) strdup ("Hewlett-Packard"); sModel.pszName = (char *) strdup ("Scanjet 3970"); @@ -1795,6 +1802,7 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { /* By default */ sanei_usb_attach_matching_devices ("usb 0x03f0 0x2605", attach_one_device); /* HP3800 */ + sanei_usb_attach_matching_devices ("usb 0x03f0 0x2805", attach_one_device); /* HPG2710 */ sanei_usb_attach_matching_devices ("usb 0x03f0 0x2305", attach_one_device); /* HP3970 */ sanei_usb_attach_matching_devices ("usb 0x03f0 0x2405", attach_one_device); /* HP4070 */ sanei_usb_attach_matching_devices ("usb 0x03f0 0x4105", attach_one_device); /* HP4370 */ diff --git a/backend/hp3900_types.c b/backend/hp3900_types.c index 2632b3fc6..f09070395 100644 --- a/backend/hp3900_types.c +++ b/backend/hp3900_types.c @@ -41,7 +41,7 @@ */ /* devices */ -#define DEVSCOUNT 0x07 /* Number of scanners supported by this backend */ +#define DEVSCOUNT 0x08 /* Number of scanners supported by this backend */ #define HP3970 0x00 /* rts8822l-01H HP Scanjet 3970 */ #define HP4070 0x01 /* rts8822l-01H HP Scanjet 4070 */ @@ -50,6 +50,7 @@ #define HP3800 0x04 /* rts8822bl-03A HP Scanjet 3800 */ #define HPG3010 0x05 /* rts8822l-02A HP Scanjet G3010 */ #define BQ5550 0x06 /* rts8823l-01E BenQ 5550 */ +#define HPG2710 0x07 /* rts8822bl-03A HP Scanjet G2710 */ /* chipset models */ #define RTS8822L_01H 0x00 @@ -692,8 +693,8 @@ SANE_Int v14b4 = 0; SANE_Byte *v1600 = NULL; /* tabla */ SANE_Byte *v1604 = NULL; /* tabla */ SANE_Byte *v1608 = NULL; /* tabla */ -SANE_Byte v160c; -SANE_Int v1610; +SANE_Byte v160c_block_size; +SANE_Int mem_total; SANE_Byte v1619; SANE_Int v15f8; diff --git a/backend/hp3900_usb.c b/backend/hp3900_usb.c index dba317fc7..440c9635a 100644 --- a/backend/hp3900_usb.c +++ b/backend/hp3900_usb.c @@ -331,7 +331,7 @@ Read_Bulk (USB_Handle usb_handle, SANE_Byte * buffer, size_t size) if (buffer != NULL) { dataline_count++; - DBG (DBG_CTL, "%06i BLK DI: Buffer length = %lu bytes\n", + DBG (DBG_CTL, "%06i BLK DI: Buffer length = %lu. bytes\n", dataline_count, (u_long) size); #ifdef STANDALONE diff --git a/doc/descriptions/hp3900.desc b/doc/descriptions/hp3900.desc index a5eece60c..7571394cd 100644 --- a/doc/descriptions/hp3900.desc +++ b/doc/descriptions/hp3900.desc @@ -10,7 +10,7 @@ ; See doc/descriptions.txt for details. :backend "hp3900" -:version "0.10" +:version "0.12" :new :yes :manpage "sane-hp3900" :url "http://sourceforge.net/projects/hp3900-series/" @@ -43,6 +43,12 @@ :status :basic :comment "Works with resolutions lower than 1200dpi" +:model "ScanJet G2710" +:interface "USB" +:usbid "0x03f0" "0x2805" +:status :basic +:comment "Similar to hp scanjet 3800" + :model "ScanJet G3010" :interface "USB" :usbid "0x03f0" "0x4205" diff --git a/doc/sane-hp3900.man b/doc/sane-hp3900.man index 7a61038c6..f6340abfd 100644 --- a/doc/sane-hp3900.man +++ b/doc/sane-hp3900.man @@ -1,4 +1,4 @@ -.TH sane-hp3900 5 "01 January 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" +.TH sane-hp3900 5 "13 February 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane-hp3900 .SH NAME sane-hp3900 \- SANE backend for RTS8822 chipset based scanners @@ -17,6 +17,7 @@ HP ScanJet 3800 RTS8822BL-03A HP ScanJet 3970 RTS8822L-01H HP ScanJet 4070 Photosmart RTS8822L-01H HP ScanJet 4370 RTS8822L-02A +HP ScanJet G2710 RTS8822BL-03A HP ScanJet G3010 RTS8822L-02A UMAX Astra 4900/4950 RTS8822L-01H * BenQ 5550 RTS8823L-01E *