- finished ECP support for 1220P/2000P

- added low level communication for 610P
	- added scanner detection for 610P
	- misc doc updates
merge-requests/1/head
Stéphane Voltz 2004-03-09 06:12:27 +00:00
rodzic 389b608312
commit e973af58e8
7 zmienionych plików z 2282 dodań i 1453 usunięć

Wyświetl plik

@ -1,3 +1,10 @@
2004-03-09 Stéphane Voltz <svoltz@wanadoo.fr>
* backend/umax_pp_low.c backend/umax_pp_low.h backend/umax_pp_mid.c
doc/sane-umax_pp.man doc/descriptions/umax_pp.desc tools/umax_pp.c:
finished ECP support for 1220P/2000P. Added scanner detection and
low-level communication for 610P.
2004-03-08 Henning Meier-Geinitz <henning@meier-geinitz.de> 2004-03-08 Henning Meier-Geinitz <henning@meier-geinitz.de>
* tools/check-usb-scanner.c: GL841 max packet size can be 512 * tools/check-usb-scanner.c: GL841 max packet size can be 512
@ -86,7 +93,6 @@
* backend/umax_pp_low.h backend/umax_pp_low.c backend/umax_pp.conf * backend/umax_pp_low.h backend/umax_pp_low.c backend/umax_pp.conf
backend/umax_pp.c tools/umax_pp.c: added initial ECP support for backend/umax_pp.c tools/umax_pp.c: added initial ECP support for
scanner, laid groundwork for 610P support. scanner, laid groundwork for 610P support.
* backend/mustek_pp_ccd300.c: forgot parameters to wait_bank_change
2004-02-14 Henning Meier-Geinitz <henning@meier-geinitz.de> 2004-02-14 Henning Meier-Geinitz <henning@meier-geinitz.de>

Plik diff jest za duży Load Diff

Wyświetl plik

@ -46,7 +46,7 @@
/*****************************************************************************/ /*****************************************************************************/
/* set port to 'idle state' and get iopl */ /* set port to 'idle state' and get iopl */
/*****************************************************************************/ /*****************************************************************************/
extern int sanei_umax_pp_InitPort (int port, char *name); extern int sanei_umax_pp_initPort (int port, char *name);
@ -54,14 +54,14 @@ extern int sanei_umax_pp_InitPort (int port, char *name);
extern int sanei_umax_pp_ProbeScanner (int recover); extern int sanei_umax_pp_probeScanner (int recover);
extern int sanei_umax_pp_InitScanner (int recover); extern int sanei_umax_pp_initScanner (int recover);
extern int sanei_umax_pp_InitTransport (int recover); extern int sanei_umax_pp_initTransport (int recover);
extern int sanei_umax_pp_ReleaseScanner (void); extern int sanei_umax_pp_releaseScanner (void);
extern int sanei_umax_pp_EndSession (void); extern int sanei_umax_pp_endSession (void);
extern int sanei_umax_pp_InitCancel (void); extern int sanei_umax_pp_initCancel (void);
extern int sanei_umax_pp_Cancel (void); extern int sanei_umax_pp_cancel (void);
extern int sanei_umax_pp_CheckModel (void); extern int sanei_umax_pp_checkModel (void);
extern int sanei_umax_pp_getauto (void); extern int sanei_umax_pp_getauto (void);
extern int sanei_umax_pp_UTA (void); extern int sanei_umax_pp_UTA (void);
extern void sanei_umax_pp_setauto (int mode); extern void sanei_umax_pp_setauto (int mode);
@ -89,24 +89,24 @@ extern void sanei_umax_pp_setauto (int mode);
#define MOTOR_BIT 0x40 #define MOTOR_BIT 0x40
#define UMAX_PP_PARPORT_PS2 0x01 #define UMAX_PP_PARPORT_PS2 0x01
#define UMAX_PP_PARPORT_EPP 0x02 #define UMAX_PP_PARPORT_BYTE 0x02
#define UMAX_PP_PARPORT_EPP_HALF 0x04 #define UMAX_PP_PARPORT_EPP 0x04
#define UMAX_PP_PARPORT_ECP 0x08 #define UMAX_PP_PARPORT_ECP 0x08
#endif #endif
extern int sanei_umax_pp_Scan (int x, int y, int width, int height, int dpi, extern int sanei_umax_pp_scan (int x, int y, int width, int height, int dpi,
int color, int brightness, int contrast); int color, int brightness, int contrast);
extern int sanei_umax_pp_Move (int distance, int precision, extern int sanei_umax_pp_move (int distance, int precision,
unsigned char *buffer); unsigned char *buffer);
extern int sanei_umax_pp_SetLamp (int on); extern int sanei_umax_pp_setLamp (int on);
extern int sanei_umax_pp_CompletionWait (void); extern int sanei_umax_pp_completionWait (void);
extern int sanei_umax_pp_CommitScan (void); extern int sanei_umax_pp_commitScan (void);
extern int sanei_umax_pp_Park (void); extern int sanei_umax_pp_park (void);
extern int sanei_umax_pp_ParkWait (void); extern int sanei_umax_pp_parkWait (void);
extern int sanei_umax_pp_ReadBlock (long len, int window, int dpi, int last, extern int sanei_umax_pp_readBlock (long len, int window, int dpi, int last,
unsigned char *buffer); unsigned char *buffer);
extern int sanei_umax_pp_StartScan (int x, int y, int width, int height, extern int sanei_umax_pp_startScan (int x, int y, int width, int height,
int dpi, int color, int brightness, int dpi, int color, int brightness,
int contrast, int *rbpp, int *rtw, int contrast, int *rbpp, int *rtw,
int *rth); int *rth);
@ -117,12 +117,13 @@ extern void sanei_umax_pp_setparport (int fd);
extern int sanei_umax_pp_getparport (void); extern int sanei_umax_pp_getparport (void);
extern void sanei_umax_pp_setastra (int mod); extern void sanei_umax_pp_setastra (int mod);
extern int sanei_umax_pp_getastra (void); extern int sanei_umax_pp_getastra (void);
extern int sanei_umax_pp_ScannerStatus (void); extern int sanei_umax_pp_scannerStatus (void);
extern int sanei_umax_pp_ReleaseScanner (void); extern int sanei_umax_pp_releaseScanner (void);
extern int sanei_umax_pp_EndSession (void); extern int sanei_umax_pp_endSession (void);
extern int sanei_umax_pp_ProbeScanner (int recover); extern int sanei_umax_pp_probeScanner (int recover);
extern char **sanei_parport_find_port (void); extern char **sanei_parport_find_port (void);
extern char **sanei_parport_find_device (void); extern char **sanei_parport_find_device (void);
extern int sanei_umax_pp_CmdSync (int cmd); extern int sanei_umax_pp_cmdSync (int cmd);
extern void sanei_umax_pp_gamma (int *red, int *green, int *blue);

Wyświetl plik

@ -153,7 +153,7 @@ sanei_umax_pp_model (int port, int *model)
*/ */
do do
{ {
rc = sanei_umax_pp_InitTransport (recover); rc = sanei_umax_pp_initTransport (recover);
} }
while (rc == 2); while (rc == 2);
@ -164,7 +164,7 @@ sanei_umax_pp_model (int port, int *model)
} }
if (rc != 1) if (rc != 1)
{ {
DBG (0, "sanei_umax_pp_InitTransport() failed (%s:%d)\n", __FILE__, DBG (0, "sanei_umax_pp_initTransport() failed (%s:%d)\n", __FILE__,
__LINE__); __LINE__);
unlock_parport (); unlock_parport ();
return (UMAX1220P_TRANSPORT_FAILED); return (UMAX1220P_TRANSPORT_FAILED);
@ -173,13 +173,13 @@ sanei_umax_pp_model (int port, int *model)
/* check model only, and if only none given in conf file */ /* check model only, and if only none given in conf file */
if (!sanei_umax_pp_getastra ()) if (!sanei_umax_pp_getastra ())
{ {
rc = sanei_umax_pp_CheckModel (); rc = sanei_umax_pp_checkModel ();
} }
else else
{ {
rc = sanei_umax_pp_getastra (); rc = sanei_umax_pp_getastra ();
} }
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
unlock_parport (); unlock_parport ();
if (rc < 610) if (rc < 610)
{ {
@ -210,19 +210,19 @@ sanei_umax_pp_attach (int port, char *name)
} }
sanei_umax_pp_setport (port); sanei_umax_pp_setport (port);
if (sanei_umax_pp_InitPort (port, name) != 1) if (sanei_umax_pp_initPort (port, name) != 1)
return (UMAX1220P_PROBE_FAILED); return (UMAX1220P_PROBE_FAILED);
/* init port locks the port, so we flag that */ /* init port locks the port, so we flag that */
locked = 1; locked = 1;
if (sanei_umax_pp_ProbeScanner (recover) != 1) if (sanei_umax_pp_probeScanner (recover) != 1)
{ {
if (recover) if (recover)
{ {
sanei_umax_pp_InitTransport (recover); sanei_umax_pp_initTransport (recover);
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
if (sanei_umax_pp_ProbeScanner (recover) != 1) if (sanei_umax_pp_probeScanner (recover) != 1)
{ {
DBG (0, "Recover failed ....\n"); DBG (0, "Recover failed ....\n");
unlock_parport (); unlock_parport ();
@ -235,7 +235,7 @@ sanei_umax_pp_attach (int port, char *name)
return (UMAX1220P_PROBE_FAILED); return (UMAX1220P_PROBE_FAILED);
} }
} }
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
unlock_parport (); unlock_parport ();
@ -267,7 +267,7 @@ sanei_umax_pp_open (int port, char *name)
*/ */
do do
{ {
rc = sanei_umax_pp_InitTransport (recover); rc = sanei_umax_pp_initTransport (recover);
} }
while (rc == 2); while (rc == 2);
@ -280,17 +280,17 @@ sanei_umax_pp_open (int port, char *name)
if (rc != 1) if (rc != 1)
{ {
DBG (0, "sanei_umax_pp_InitTransport() failed (%s:%d)\n", __FILE__, DBG (0, "sanei_umax_pp_initTransport() failed (%s:%d)\n", __FILE__,
__LINE__); __LINE__);
unlock_parport (); unlock_parport ();
return (UMAX1220P_TRANSPORT_FAILED); return (UMAX1220P_TRANSPORT_FAILED);
} }
/* init scanner */ /* init scanner */
if (sanei_umax_pp_InitScanner (recover) == 0) if (sanei_umax_pp_initScanner (recover) == 0)
{ {
DBG (0, "sanei_umax_pp_InitScanner() failed (%s:%d)\n", __FILE__, DBG (0, "sanei_umax_pp_initScanner() failed (%s:%d)\n", __FILE__,
__LINE__); __LINE__);
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
unlock_parport (); unlock_parport ();
return (UMAX1220P_SCANNER_FAILED); return (UMAX1220P_SCANNER_FAILED);
} }
@ -308,19 +308,19 @@ sanei_umax_pp_cancel (void)
if (lock_parport () == UMAX1220P_BUSY) if (lock_parport () == UMAX1220P_BUSY)
return (UMAX1220P_BUSY); return (UMAX1220P_BUSY);
/* maybe bus reset here if exists */ /* maybe EPAT reset here if exists */
sanei_umax_pp_CmdSync (0xC2); sanei_umax_pp_cmdSync (0xC2);
sanei_umax_pp_CmdSync (0x00); sanei_umax_pp_cmdSync (0x00);
sanei_umax_pp_CmdSync (0x00); sanei_umax_pp_cmdSync (0x00);
if (sanei_umax_pp_Park () == 0) if (sanei_umax_pp_park () == 0)
{ {
DBG (0, "Park failed !!! (%s:%d)\n", __FILE__, __LINE__); DBG (0, "Park failed !!! (%s:%d)\n", __FILE__, __LINE__);
unlock_parport (); unlock_parport ();
return (UMAX1220P_PARK_FAILED); return (UMAX1220P_PARK_FAILED);
} }
/* EndSession() cancels any pending command */ /* endSession() cancels any pending command */
/* such as parking ...., so we only return */ /* such as parking ...., so we only return */
sanei_umax_pp_ReleaseScanner (); sanei_umax_pp_releaseScanner ();
unlock_parport (); unlock_parport ();
return (UMAX1220P_OK); return (UMAX1220P_OK);
} }
@ -339,7 +339,7 @@ sanei_umax_pp_start (int x, int y, int width, int height, int dpi, int color,
if (lock_parport () == UMAX1220P_BUSY) if (lock_parport () == UMAX1220P_BUSY)
return (UMAX1220P_BUSY); return (UMAX1220P_BUSY);
/* end session isn't done by cancel any more */ /* end session isn't done by cancel any more */
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
if (autoset) if (autoset)
sanei_umax_pp_setauto (1); sanei_umax_pp_setauto (1);
@ -359,11 +359,11 @@ sanei_umax_pp_start (int x, int y, int width, int height, int dpi, int color,
break; break;
} }
if (sanei_umax_pp_StartScan if (sanei_umax_pp_startScan
(x + 144, y, width, height, dpi, col, brightness, contrast, rbpp, rtw, (x + 144, y, width, height, dpi, col, brightness, contrast, rbpp, rtw,
rth) != 1) rth) != 1)
{ {
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
unlock_parport (); unlock_parport ();
return (UMAX1220P_START_FAILED); return (UMAX1220P_START_FAILED);
} }
@ -378,9 +378,9 @@ sanei_umax_pp_read (long len, int window, int dpi, int last,
DBG (3, "sanei_umax_pp_read\n"); DBG (3, "sanei_umax_pp_read\n");
if (lock_parport () == UMAX1220P_BUSY) if (lock_parport () == UMAX1220P_BUSY)
return (UMAX1220P_BUSY); return (UMAX1220P_BUSY);
if (sanei_umax_pp_ReadBlock (len, window, dpi, last, buffer) == 0) if (sanei_umax_pp_readBlock (len, window, dpi, last, buffer) == 0)
{ {
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
return (UMAX1220P_READ_FAILED); return (UMAX1220P_READ_FAILED);
} }
unlock_parport (); unlock_parport ();
@ -397,7 +397,7 @@ sanei_umax_pp_lamp (int on)
if (lock_parport () == UMAX1220P_BUSY) if (lock_parport () == UMAX1220P_BUSY)
return (UMAX1220P_BUSY); return (UMAX1220P_BUSY);
if (sanei_umax_pp_SetLamp (on) == 0) if (sanei_umax_pp_setLamp (on) == 0)
{ {
DBG (0, "Setting lamp state failed!\n"); DBG (0, "Setting lamp state failed!\n");
} }
@ -418,8 +418,8 @@ sanei_umax_pp_status (void)
if (lock_parport () == UMAX1220P_BUSY) if (lock_parport () == UMAX1220P_BUSY)
return (UMAX1220P_BUSY); return (UMAX1220P_BUSY);
/* check if head is at home */ /* check if head is at home */
sanei_umax_pp_CmdSync (0x40); sanei_umax_pp_cmdSync (0x40);
status = sanei_umax_pp_ScannerStatus (); status = sanei_umax_pp_scannerStatus ();
if ((status & MOTOR_BIT) == 0x00) if ((status & MOTOR_BIT) == 0x00)
{ {
unlock_parport (); unlock_parport ();
@ -440,7 +440,7 @@ sanei_umax_pp_close ()
DBG (3, "sanei_umax_pp_close\n"); DBG (3, "sanei_umax_pp_close\n");
lock_parport (); lock_parport ();
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
unlock_parport (); unlock_parport ();
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H

Wyświetl plik

@ -22,31 +22,35 @@
:mfg "UMAX" ; name a manufacturer :mfg "UMAX" ; name a manufacturer
:url "http://www.umax.com.tw/" :url "http://www.umax.com.tw/"
; These scanners are known to have the same ASIC. What scanners work ; These scanners are known to have the same ASIC family.
; isn't actually known. Also the interfaces are only guessed
:model "Astra 1220P" :model "Astra 1220P"
:interface "Parport (EPP)" :interface "Parport (EPP/ECP)"
:status :good :status :good
:model "Astra 2000P" :model "Astra 2000P"
:interface "Parport (EPP)" :interface "Parport (EPP/ECP)"
:status :good :status :good
:model "Astra 1600P" :model "Astra 1600P"
:interface "Parport (EPP)" :interface "Parport (EPP)"
:status :good :status :good
:model "Astra 610P" :model "Astra 600P"
:interface "Parport (EPP)" :interface "Parport (sPP/ECP)"
:status :unsupported :status :unsupported
:comment "don't work due to lack of hardware to test" :comment "untested, but should be close to 610P"
:model "Astra 610P"
:interface "Parport (SPP/ECP)"
:status :minimal
:comment "work in progress"
:mfg "Hewlett-Packard" :mfg "Hewlett-Packard"
:model "Scanjet 3200C" :model "Scanjet 3200C"
:interface "Parport (EPP)" :interface "Parport (EPP/ECP)"
:status :good :status :good
:comment "works (relabelled 1220P and 2000P)" :comment "works (relabelled 1220P and 2000P)"

Wyświetl plik

@ -14,6 +14,8 @@ Model:
.br .br
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
.br .br
Astra 610P
.br
Astra 1220P Astra 1220P
.br .br
HP3200C HP3200C
@ -33,11 +35,13 @@ There isn't software way to recognize them properly. Under windows, model is
set by the driver installed, regardless of the hardware. set by the driver installed, regardless of the hardware.
.PP .PP
.TP .TP
.B EPP MODE ONLY .B EPP/ECP MODES ONLY
The current version of the backend use only EPP mode to communicate with the The current version of the backend uses only EPP or ECP mode to communicate
scanner. PS/2 and SPP mode aren't implemented. It is recommended that you set with the scanner. PS/2 and SPP mode aren't implemented. It is recommended that
your parallel port to EPP in BIOS with the current version of this backend. you set your parallel port to EPP in BIOS with the current version of this
ECPEPP will only work if you use a 2.4 kernel with ppdev character device support. backend. You can leave it to ECP or ECP+EPP, but in this case you may not use
ppdev but only direct hardware access if you have to use ECP. ECPEPP will only
work if you use a 2.4 or 2.6 kernel with ppdev character device support.
.PP .PP
This backend does support parport sharing only This backend does support parport sharing only
.I .I
@ -172,7 +176,7 @@ Option
.B astra .B astra
allows you to change the model of your scanner. Current auto detection is based allows you to change the model of your scanner. Current auto detection is based
on side effects on scanning when using 1220P command set on other models, so on side effects on scanning when using 1220P command set on other models, so
it may fail on unkown hardware combination. Valid values are 1220, 1600 it may fail on unkown hardware combination. Valid values are 610, 1220, 1600
and 2000. It is usefull only when autodetection fails to detect properly and 2000. It is usefull only when autodetection fails to detect properly
your scanner model. If your scanner work properly but is reported wrongly, your scanner model. If your scanner work properly but is reported wrongly,
let it be that way. let it be that way.
@ -185,7 +189,7 @@ Option
.B buffer .B buffer
allows you to change the size of the scan buffer. The size must be specified in allows you to change the size of the scan buffer. The size must be specified in
bytes. The default value is 2 megabytes. Decreasing this value will improve the bytes. The default value is 2 megabytes. Decreasing this value will improve the
smoothness of the updates of progress status in the frontend, but will stall the smoothness of progress bar in the frontend, but will stall the
scan more often. scan more often.
.PP .PP

Wyświetl plik

@ -89,7 +89,7 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected color mode value\n"); fprintf (stderr, "expected color mode value\n");
return (0); return 0;
} }
color = 0; color = 0;
i++; i++;
@ -106,7 +106,7 @@ main (int argc, char **argv)
{ {
fprintf (stderr, "unexpected color mode value <%s>\n", argv[i]); fprintf (stderr, "unexpected color mode value <%s>\n", argv[i]);
fprintf (stderr, "Must be RGB, RGB12, BW, or BW12\n"); fprintf (stderr, "Must be RGB, RGB12, BW, or BW12\n");
return (0); return 0;
} }
} }
@ -117,13 +117,13 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected x value\n"); fprintf (stderr, "expected x value\n");
return (0); return 0;
} }
x = atoi (argv[i + 1]); x = atoi (argv[i + 1]);
if (x < 0 || x > 5100) if (x < 0 || x > 5100)
{ {
fprintf (stderr, "x must be between 0 and 5099\n"); fprintf (stderr, "x must be between 0 and 5099\n");
return (0); return 0;
} }
i++; i++;
found = 1; found = 1;
@ -135,13 +135,13 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected y value\n"); fprintf (stderr, "expected y value\n");
return (0); return 0;
} }
y = atoi (argv[i + 1]); y = atoi (argv[i + 1]);
if (y < 0 || y > 7000) if (y < 0 || y > 7000)
{ {
fprintf (stderr, "y must be between 0 and 7000\n"); fprintf (stderr, "y must be between 0 and 7000\n");
return (0); return 0;
} }
i++; i++;
found = 1; found = 1;
@ -153,19 +153,19 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected width value\n"); fprintf (stderr, "expected width value\n");
return (0); return 0;
} }
width = atoi (argv[i + 1]); width = atoi (argv[i + 1]);
if ((width < 1) || (width > 5100)) if ((width < 1) || (width > 5100))
{ {
fprintf (stderr, "width must be between 1 and 5100\n"); fprintf (stderr, "width must be between 1 and 5100\n");
return (0); return 0;
} }
if (x + width > 5100) if (x + width > 5100)
{ {
fprintf (stderr, fprintf (stderr,
"Right side of scan area exceed physical limits (x+witdh>5100)\n"); "Right side of scan area exceed physical limits (x+witdh>5100)\n");
return (0); return 0;
} }
i++; i++;
found = 1; found = 1;
@ -178,19 +178,19 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected height value\n"); fprintf (stderr, "expected height value\n");
return (0); return 0;
} }
height = atoi (argv[i + 1]); height = atoi (argv[i + 1]);
if ((height < 1) || (height > 7000)) if ((height < 1) || (height > 7000))
{ {
fprintf (stderr, "height must be between 1 and 7000\n"); fprintf (stderr, "height must be between 1 and 7000\n");
return (0); return 0;
} }
if (y + height > 7100) if (y + height > 7100)
{ {
fprintf (stderr, fprintf (stderr,
"Bottom side of scan area exceed physical limits (y+height>7100)\n"); "Bottom side of scan area exceed physical limits (y+height>7100)\n");
return (0); return 0;
} }
i++; i++;
found = 1; found = 1;
@ -202,7 +202,7 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected trace value\n"); fprintf (stderr, "expected trace value\n");
return (0); return 0;
} }
trace = atoi (argv[i + 1]); trace = atoi (argv[i + 1]);
i++; i++;
@ -229,13 +229,13 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected dpi value\n"); fprintf (stderr, "expected dpi value\n");
return (0); return 0;
} }
dpi = atoi (argv[i + 1]); dpi = atoi (argv[i + 1]);
if ((dpi < 75) || (dpi > 1200)) if ((dpi < 75) || (dpi > 1200))
{ {
fprintf (stderr, "dpi value has to be between 75 and 1200\n"); fprintf (stderr, "dpi value has to be between 75 and 1200\n");
return (0); return 0;
} }
if ((dpi != 75) if ((dpi != 75)
&& (dpi != 150) && (dpi != 150)
@ -243,19 +243,20 @@ main (int argc, char **argv)
{ {
fprintf (stderr, fprintf (stderr,
"dpi value has to be 75, 150, 300, 600 or 1200\n"); "dpi value has to be 75, 150, 300, 600 or 1200\n");
return (0); return 0;
} }
i++; i++;
found = 1; found = 1;
} }
if ((strcmp (argv[i], "-g") == 0) || (strcmp (argv[i], "--brightness") == 0)) if ((strcmp (argv[i], "-g") == 0)
|| (strcmp (argv[i], "--brightness") == 0))
{ {
if (i == (argc - 1)) if (i == (argc - 1))
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected hex brightness value ( ex: A59 )\n"); fprintf (stderr, "expected hex brightness value ( ex: A59 )\n");
return (0); return 0;
} }
i++; i++;
found = 1; found = 1;
@ -263,7 +264,7 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected hex brightness value ( ex: A59 )\n"); fprintf (stderr, "expected hex brightness value ( ex: A59 )\n");
return (0); return 0;
} }
brightness = strtol (argv[i], NULL, 16); brightness = strtol (argv[i], NULL, 16);
sanei_umax_pp_setauto (0); sanei_umax_pp_setauto (0);
@ -276,7 +277,7 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected hex contrast value ( ex: A59 )\n"); fprintf (stderr, "expected hex contrast value ( ex: A59 )\n");
return (0); return 0;
} }
i++; i++;
found = 1; found = 1;
@ -284,7 +285,7 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected hex contrast value ( ex: A59 )\n"); fprintf (stderr, "expected hex contrast value ( ex: A59 )\n");
return (0); return 0;
} }
contrast = strtol (argv[i], NULL, 16); contrast = strtol (argv[i], NULL, 16);
} }
@ -296,7 +297,7 @@ main (int argc, char **argv)
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, fprintf (stderr,
"expected device name ( ex: /dev/parport0 )\n"); "expected device name ( ex: /dev/parport0 )\n");
return (0); return 0;
} }
i++; i++;
found = 1; found = 1;
@ -308,7 +309,7 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected hex io port value ( ex: 3BC )\n"); fprintf (stderr, "expected hex io port value ( ex: 3BC )\n");
return (0); return 0;
} }
i++; i++;
found = 1; found = 1;
@ -316,7 +317,7 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected hex io port value ( ex: 378 )\n"); fprintf (stderr, "expected hex io port value ( ex: 378 )\n");
return (0); return 0;
} }
port = strtol (argv[i], NULL, 16); port = strtol (argv[i], NULL, 16);
} }
@ -328,7 +329,7 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "expected lamp value\n"); fprintf (stderr, "expected lamp value\n");
return (0); return 0;
} }
lamp = atoi (argv[i + 1]); lamp = atoi (argv[i + 1]);
i++; i++;
@ -339,7 +340,7 @@ main (int argc, char **argv)
{ {
Usage (argv[0]); Usage (argv[0]);
fprintf (stderr, "unexpected argument <%s>\n", argv[i]); fprintf (stderr, "unexpected argument <%s>\n", argv[i]);
return (0); return 0;
} }
/* next arg */ /* next arg */
@ -360,10 +361,10 @@ main (int argc, char **argv)
/* enable I/O */ /* enable I/O */
/* parport_claim */ /* parport_claim */
if (sanei_umax_pp_InitPort (port, name) != 1) if (sanei_umax_pp_initPort (port, name) != 1)
{ {
fprintf (stderr, "failed to gain direct acces to port 0x%X!\n", port); fprintf (stderr, "failed to gain direct acces to port 0x%X!\n", port);
return (0); return 0;
} }
if (trace) if (trace)
{ {
@ -381,65 +382,77 @@ main (int argc, char **argv)
if ((!scan) && (lamp < 0) && (!probe)) if ((!scan) && (lamp < 0) && (!probe))
scan = 1; scan = 1;
/* lamp on/off */
if (lamp >= 0)
{
/* init transport layer */
if (sanei_umax_pp_InitTransport (recover) != 1)
{
printf ("InitTransport() failed (%s:%d)\n", __FILE__, __LINE__);
return (0);
}
if (sanei_umax_pp_SetLamp (lamp) == 0)
{
fprintf (stderr, "Setting lamp state failed!\n");
return (0);
}
}
/* probe scanner */ /* probe scanner */
if (probe) if ((probe) || (lamp >= 0))
{ {
printf ("Probing scanner ....\n"); printf ("Probing scanner ....\n");
if (sanei_umax_pp_ProbeScanner (recover) != 1) if (sanei_umax_pp_probeScanner (recover) != 1)
{ {
if (recover) if (recover)
{ {
sanei_umax_pp_InitTransport (recover); sanei_umax_pp_initTransport (recover);
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
if (sanei_umax_pp_ProbeScanner (recover) != 1) if (sanei_umax_pp_probeScanner (recover) != 1)
{ {
printf ("Recover failed ....\n"); printf ("Recover failed ....\n");
return (0); return 0;
} }
printf ("Recover done !\n"); printf ("Recover done !\n");
} }
else else
return (0); return 0;
} }
/* could be written better .... but it is only test */ /* could be written better .... but it is only test */
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
/* init transport layer */ /* init transport layer */
if (sanei_umax_pp_InitTransport (0) != 1) if (sanei_umax_pp_initTransport (0) != 1)
{ {
printf ("InitTransport() failed (%s:%d)\n", __FILE__, __LINE__); printf ("initTransport() failed (%s:%d)\n", __FILE__, __LINE__);
return (0); return 0;
} }
i = sanei_umax_pp_CheckModel (); i = sanei_umax_pp_checkModel ();
if (i < 610) if (i < 600)
{ {
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
printf ("CheckModel() failed (%s:%d)\n", __FILE__, __LINE__); printf ("checkModel() failed (%s:%d)\n", __FILE__, __LINE__);
return (0); return 0;
} }
if (trace) if (trace)
printf ("UMAX Astra %dP detected \n", i); printf ("UMAX Astra %dP detected \n", i);
/* free scanner if a scan is planned */ /* free scanner if a scan is planned */
if (scan) if (scan)
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
}
/* lamp on/off: must come after probing (610p handling) */
if (lamp >= 0)
{
/* init transport layer */
if (trace)
printf ("Tryning to set lamp %s\n", lamp ? "on" : "off");
if (sanei_umax_pp_initTransport (recover) != 1)
{
printf ("initTransport() failed (%s:%d)\n", __FILE__, __LINE__);
return 0;
}
else
{
if (trace)
printf ("initTransport passed...\n");
}
if (sanei_umax_pp_setLamp (lamp) == 0)
{
fprintf (stderr, "Setting lamp state failed!\n");
return 0;
}
else
{
if (trace)
printf ("sanei_umax_pp_setLamp passed...\n");
}
} }
/* scan */ /* scan */
@ -452,43 +465,43 @@ main (int argc, char **argv)
*/ */
do do
{ {
i = sanei_umax_pp_InitTransport (recover); i = sanei_umax_pp_initTransport (recover);
} }
while (i == 2); while (i == 2);
if (i != 1) if (i != 1)
{ {
printf ("InitTransport() failed (%s:%d)\n", __FILE__, __LINE__); printf ("initTransport() failed (%s:%d)\n", __FILE__, __LINE__);
return (0); return 0;
} }
/*i = sanei_umax_pp_CheckModel (); /*i = sanei_umax_pp_checkModel ();
if (i < 610) if (i < 610)
{ {
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
printf ("CheckModel() failed (%s:%d)\n", __FILE__, __LINE__); printf ("checkModel() failed (%s:%d)\n", __FILE__, __LINE__);
return (0); return 0;
} }
if (trace) if (trace)
printf ("UMAX Astra %dP detected \n", i); */ printf ("UMAX Astra %dP detected \n", i); */
/* init scanner */ /* init scanner */
if (sanei_umax_pp_InitScanner (recover) == 0) if (sanei_umax_pp_initScanner (recover) == 0)
{ {
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
return (0); return 0;
} }
/* scan */ /* scan */
if (sanei_umax_pp_Scan if (sanei_umax_pp_scan
(x, y, width, height, dpi, color, brightness, contrast) != 1) (x, y, width, height, dpi, color, brightness, contrast) != 1)
{ {
sanei_umax_pp_ReleaseScanner (); sanei_umax_pp_releaseScanner ();
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
return (0); return 0;
} }
/* wait for head parking */ /* wait for head parking */
sanei_umax_pp_ParkWait (); sanei_umax_pp_parkWait ();
sanei_umax_pp_ReleaseScanner (); sanei_umax_pp_releaseScanner ();
} }
sanei_umax_pp_EndSession (); sanei_umax_pp_endSession ();
return (1); return 1;
} }