diff --git a/backend/umax_pp.c b/backend/umax_pp.c index 5523ce9ab..4665f5af5 100644 --- a/backend/umax_pp.c +++ b/backend/umax_pp.c @@ -189,16 +189,20 @@ attach (const char *devname) return SANE_STATUS_INVAL; /* if the name begins with a slash, it's a device, else it's an addr */ - if ((devname[0] == '/')) + if (devname != NULL) { - strncpy (name, devname, 64); - } - else - { - if ((devname[0] == '0') && ((devname[1] == 'x') || (devname[1] == 'X'))) - prt = strtol (devname + 2, NULL, 16); + if ((devname[0] == '/')) + { + strncpy (name, devname, 64); + } else - prt = atoi (devname); + { + if ((devname[0] == '0') + && ((devname[1] == 'x') || (devname[1] == 'X'))) + prt = strtol (devname + 2, NULL, 16); + else + prt = atoi (devname); + } } @@ -257,8 +261,7 @@ attach (const char *devname) if (ret != UMAX1220P_OK) { - DBG (1, "attach: failed to recognize scanner model on %s\n", - devname); + DBG (1, "attach: failed to recognize scanner model on %s\n", devname); return SANE_STATUS_IO_ERROR; } sprintf (model, "Astra %dP", mdl); @@ -628,7 +631,8 @@ init_options (Umax_PP_Device * dev) -SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) +SANE_Status +sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { char dev_name[512]; const char *cp; @@ -1005,7 +1009,8 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) return SANE_STATUS_GOOD; } -SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) +SANE_Status +sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Umax_PP_Device *dev; Umax_PP_Descriptor *desc; @@ -1035,9 +1040,12 @@ SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) desc = &devlist[i]; - if (devlist[i].ppdevice[0] == '/') + if (devlist[i].ppdevice != NULL) { - name = devlist[i].ppdevice; + if (devlist[i].ppdevice[0] == '/') + { + name = devlist[i].ppdevice; + } } else { @@ -1721,7 +1729,8 @@ sane_control_option (SANE_Handle handle, SANE_Int option, } -SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) +SANE_Status +sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Umax_PP_Device *dev = handle; int dpi, remain; @@ -1876,7 +1885,8 @@ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) } -SANE_Status sane_start (SANE_Handle handle) +SANE_Status +sane_start (SANE_Handle handle) { Umax_PP_Device *dev = handle; int rc, autoset; @@ -2153,7 +2163,8 @@ sane_cancel (SANE_Handle handle) } } -SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) +SANE_Status +sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { DBG (129, "unused arg: handle = %p, non_blocking = %d\n", handle, (int) non_blocking); @@ -2163,10 +2174,11 @@ SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) return SANE_STATUS_UNSUPPORTED; } -SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) +SANE_Status +sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { - DBG (129, "unused arg: handle = %p, fd = %p\n", handle, (void *)fd); + DBG (129, "unused arg: handle = %p, fd = %p\n", handle, (void *) fd); DBG (2, "get_select_fd: not supported\n"); diff --git a/backend/umax_pp_low.c b/backend/umax_pp_low.c index 875beddb0..0d76842ef 100644 --- a/backend/umax_pp_low.c +++ b/backend/umax_pp_low.c @@ -401,7 +401,7 @@ sanei_parport_info (int number, int *addr) int sanei_umax_pp_InitPort (int port, char *name) { - int fd; + int fd, ectr; int found = 0; #if ((defined HAVE_IOPERM)||(defined HAVE_LINUX_PPDEV_H)) int mode; @@ -555,7 +555,7 @@ sanei_umax_pp_InitPort (int port, char *name) if (!found) { - DBG (1, "device %s does not fit ...\n",name); + DBG (1, "device %s does not fit ...\n", name); } else { @@ -621,6 +621,17 @@ sanei_umax_pp_InitPort (int port, char *name) setregid (mode, mode); #endif + /* set up ECPEPP the hard way ... */ + /* frob_econtrol (port, 0xe0, 4 << 5); + unsigned char ectr = inb (ECONTROL (pb)); + outb ((ectr & ~m) ^ v, ECONTROL (pb)); */ + ectr = Inb (ECPCONTROL); + if (ectr != 0xFF) + { + ectr = (ectr & ~(0xE0)) ^ (4 << 5); + Outb (ECPCONTROL, ectr); + } + #endif /* IO_SUPPORT_MISSING */ return (1); @@ -2515,6 +2526,7 @@ SendWord (int *cmd) case 1220: case 1600: case 2000: + default: return (SendWord1220P (cmd)); } return (0); @@ -2589,6 +2601,7 @@ RingScanner (void) usleep (UMAX_PP_PAUSE); status = Inb (STATUS); usleep (UMAX_PP_PAUSE); + /* status = 126 when scanner not connected .... */ if ((status & 0xB8) != 0x18) { DBG (1, "status %d doesn't match! %s:%d\n", status, __FILE__, @@ -3975,6 +3988,7 @@ sanei_umax_pp_InitTransport (int recover) case 1220: case 1600: case 2000: + default: return (InitTransport1220P (recover)); } return (0); @@ -4158,8 +4172,8 @@ Probe610P (int recover) recover = 0; /* quit compiler quiet .. */ /* make sure we won't try 1220/200P later */ - if(!sanei_umax_pp_getastra()) - sanei_umax_pp_setastra (610); + if (!sanei_umax_pp_getastra ()) + sanei_umax_pp_setastra (610); if (!Test610P (0x87)) { DBG (1, "Ring610P(0x87) failed (%s:%d)\n", __FILE__, __LINE__); @@ -4992,7 +5006,7 @@ sanei_umax_pp_ProbeScanner (int recover) __FILE__, __LINE__); if (CmdSetDataBuffer (voidbuf) != 1) { - DBG (0, "Loop %d: CmdSetDataBuffer(voidbuf) failed ! (%s:%d) \n",i, + DBG (0, "Loop %d: CmdSetDataBuffer(voidbuf) failed ! (%s:%d) \n", i, __FILE__, __LINE__); return (0); } @@ -5235,6 +5249,7 @@ Prologue (void) case 1220: case 1600: case 2000: + default: return (connect_epat ()); } return (0); @@ -5252,6 +5267,7 @@ Epilogue (void) case 1220: case 1600: case 2000: + default: return (deconnect_epat ()); } return (0); @@ -6601,8 +6617,8 @@ MoveToOrigin (void) if ((edge <= 30) && (sanei_umax_pp_getastra () != 1600)) { DBG (2, "MoveToOrigin() detected a 1600P"); - if(!sanei_umax_pp_getastra()) - sanei_umax_pp_setastra (1600); + if (!sanei_umax_pp_getastra ()) + sanei_umax_pp_setastra (1600); } edge = EdgePosition (300, 180, buffer); /* rounded to lowest integer, since upping origin might lead */ @@ -7945,7 +7961,7 @@ sanei_umax_pp_CheckModel (void) /* if we have already detected a scanner different from */ /* default type, no need to check again */ - if (sanei_umax_pp_getastra () != 1220) + if (sanei_umax_pp_getastra ()) return sanei_umax_pp_getastra (); /* get scanner status */ @@ -8032,13 +8048,14 @@ sanei_umax_pp_CheckModel (void) /* if data has turned into 0, we have a 2000P */ if (dest[1] == 0x00) { - if(!sanei_umax_pp_getastra()) sanei_umax_pp_setastra (2000); err = 2000; } else { /* detects 1600 by finding black scans */ + /* we defaults to 1220 */ + sanei_umax_pp_setastra (1220); MoveToOrigin (); err = sanei_umax_pp_getastra ();