kopia lustrzana https://gitlab.com/sane-project/backends
Merge branch 'add-sanei-directio' into 'master'
Factoring of umax_pp_low functions concerning sys/io.h See merge request sane-project/backends!521pixma-add-canon-ts-3400-series
commit
2e77ac4052
|
@ -678,6 +678,7 @@ libsane_epson_la_LIBADD = $(COMMON_LIBS) \
|
|||
../sanei/sanei_usb.lo \
|
||||
../sanei/sanei_scsi.lo \
|
||||
../sanei/sanei_pio.lo \
|
||||
../sanei/sanei_directio.lo \
|
||||
$(SCSI_LIBS) $(USB_LIBS) $(RESMGR_LIBS)
|
||||
EXTRA_DIST += epson.conf.in
|
||||
|
||||
|
@ -699,6 +700,7 @@ libsane_epson2_la_LIBADD = $(COMMON_LIBS) \
|
|||
../sanei/sanei_pio.lo \
|
||||
../sanei/sanei_tcp.lo \
|
||||
../sanei/sanei_udp.lo \
|
||||
../sanei/sanei_directio.lo \
|
||||
$(SCSI_LIBS) $(USB_LIBS) $(SOCKET_LIBS) $(MATH_LIB) $(RESMGR_LIBS)
|
||||
EXTRA_DIST += epson2.conf.in
|
||||
|
||||
|
@ -853,6 +855,7 @@ libsane_hp_la_LIBADD = $(COMMON_LIBS) \
|
|||
../sanei/sanei_scsi.lo \
|
||||
../sanei/sanei_pio.lo \
|
||||
../sanei/sanei_thread.lo \
|
||||
../sanei/sanei_directio.lo \
|
||||
$(SCSI_LIBS) $(USB_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS)
|
||||
EXTRA_DIST += hp.conf.in
|
||||
# TODO: These should be moved to ../docs/hp; don't belong here.
|
||||
|
@ -1243,6 +1246,7 @@ libsane_mustek_la_LIBADD = $(COMMON_LIBS) \
|
|||
../sanei/sanei_thread.lo \
|
||||
../sanei/sanei_ab306.lo \
|
||||
../sanei/sanei_pa4s2.lo \
|
||||
../sanei/sanei_directio.lo \
|
||||
$(IEEE1284_LIBS) $(SCSI_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS)
|
||||
EXTRA_DIST += mustek.conf.in
|
||||
# TODO: Why are these distributed but not compiled?
|
||||
|
@ -1261,6 +1265,7 @@ libsane_mustek_pp_la_LIBADD = $(COMMON_LIBS) \
|
|||
../sanei/sanei_config.lo \
|
||||
sane_strstatus.lo \
|
||||
../sanei/sanei_pa4s2.lo \
|
||||
../sanei/sanei_directio.lo \
|
||||
$(MATH_LIB) $(IEEE1284_LIBS)
|
||||
EXTRA_DIST += mustek_pp.conf.in
|
||||
# TODO: Why are these distributed but not compiled?
|
||||
|
@ -1498,7 +1503,16 @@ libplustek_pp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=plustek_pp
|
|||
nodist_libsane_plustek_pp_la_SOURCES = plustek_pp-s.c
|
||||
libsane_plustek_pp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=plustek_pp
|
||||
libsane_plustek_pp_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS)
|
||||
libsane_plustek_pp_la_LIBADD = $(COMMON_LIBS) libplustek_pp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_pp.lo ../sanei/sanei_thread.lo $(MATH_LIB) $(IEEE1284_LIBS) $(SANEI_THREAD_LIBS)
|
||||
libsane_plustek_pp_la_LIBADD = $(COMMON_LIBS) \
|
||||
libplustek_pp.la \
|
||||
../sanei/sanei_init_debug.lo \
|
||||
../sanei/sanei_constrain_value.lo \
|
||||
../sanei/sanei_config.lo \
|
||||
sane_strstatus.lo \
|
||||
../sanei/sanei_pp.lo \
|
||||
../sanei/sanei_thread.lo \
|
||||
../sanei/sanei_directio.lo \
|
||||
$(MATH_LIB) $(IEEE1284_LIBS) $(SANEI_THREAD_LIBS)
|
||||
EXTRA_DIST += plustek_pp.conf.in
|
||||
# TODO: Why are these distributed but not compiled?
|
||||
EXTRA_DIST += plustek-pp_dac.c plustek-pp_dbg.h plustek-pp_detect.c plustek-pp_genericio.c plustek-pp_hwdefs.h plustek-pp_image.c plustek-pp_io.c plustek-pp_map.c plustek-pp_misc.c plustek-pp_models.c plustek-pp_motor.c plustek-pp_p12.c plustek-pp_p12ccd.c plustek-pp_p48xx.c plustek-pp_p9636.c plustek-pp_procfs.c plustek-pp_procs.h plustek-pp_ptdrv.c plustek-pp_scale.c plustek-pp_scan.h plustek-pp_scandata.h plustek-pp_sysdep.h plustek-pp_tpa.c plustek-pp_types.h plustek-pp_wrapper.c
|
||||
|
@ -1528,7 +1542,8 @@ libsane_qcam_la_LIBADD = $(COMMON_LIBS) \
|
|||
../sanei/sanei_constrain_value.lo \
|
||||
../sanei/sanei_config.lo \
|
||||
sane_strstatus.lo \
|
||||
../sanei/sanei_pio.lo
|
||||
../sanei/sanei_pio.lo \
|
||||
../sanei/sanei_directio.lo
|
||||
|
||||
EXTRA_DIST += qcam.conf.in
|
||||
|
||||
|
@ -1903,6 +1918,7 @@ libsane_umax_pp_la_LIBADD = $(COMMON_LIBS) \
|
|||
../sanei/sanei_init_debug.lo \
|
||||
../sanei/sanei_constrain_value.lo \
|
||||
../sanei/sanei_config.lo \
|
||||
../sanei/sanei_directio.lo \
|
||||
sane_strstatus.lo \
|
||||
$(MATH_LIB)
|
||||
EXTRA_DIST += umax_pp.conf.in
|
||||
|
@ -2001,6 +2017,7 @@ PRELOADABLE_BACKENDS_LIBS = \
|
|||
../sanei/sanei_tcp.lo \
|
||||
../sanei/sanei_udp.lo \
|
||||
../sanei/sanei_magic.lo \
|
||||
../sanei/sanei_directio.lo \
|
||||
$(LIBV4L_LIBS) $(MATH_LIB) \
|
||||
$(IEEE1284_LIBS) \
|
||||
$(TIFF_LIBS) \
|
||||
|
@ -2035,6 +2052,7 @@ PRELOADABLE_BACKENDS_DEPS = ../sanei/sanei_config2.lo \
|
|||
../sanei/sanei_tcp.lo \
|
||||
../sanei/sanei_udp.lo \
|
||||
../sanei/sanei_magic.lo \
|
||||
../sanei/sanei_directio.lo \
|
||||
$(SANEI_SANEI_JPEG_LO)
|
||||
endif
|
||||
nodist_libsane_la_SOURCES = dll-s.c
|
||||
|
|
|
@ -55,7 +55,7 @@ addr_name (uint16_t addr)
|
|||
*/
|
||||
|
||||
static uint8_t
|
||||
inb (int fd, uint16_t addr)
|
||||
p5_inb (int fd, uint16_t addr)
|
||||
{
|
||||
#ifdef HAVE_LINUX_PPDEV_H
|
||||
uint8_t val = 0xff;
|
||||
|
@ -84,7 +84,7 @@ inb (int fd, uint16_t addr)
|
|||
rc = read (fd, &val, 1);
|
||||
break;
|
||||
default:
|
||||
DBG (DBG_error, "inb(%s) escaped ppdev\n", addr_name (addr));
|
||||
DBG (DBG_error, "p5_inb(%s) escaped ppdev\n", addr_name (addr));
|
||||
return 0xFF;
|
||||
}
|
||||
if (rc < 0)
|
||||
|
@ -100,7 +100,7 @@ inb (int fd, uint16_t addr)
|
|||
}
|
||||
|
||||
static void
|
||||
outb (int fd, uint16_t addr, uint8_t value)
|
||||
p5_outb (int fd, uint16_t addr, uint8_t value)
|
||||
{
|
||||
#ifdef HAVE_LINUX_PPDEV_H
|
||||
int rc = 0, mode = 0xff;
|
||||
|
@ -134,7 +134,7 @@ outb (int fd, uint16_t addr, uint8_t value)
|
|||
rc = write (fd, &value, 1);
|
||||
break;
|
||||
default:
|
||||
DBG (DBG_error, "outb(%s,0x%02x) escaped ppdev\n", addr_name (addr),
|
||||
DBG (DBG_error, "p5_outb(%s,0x%02x) escaped ppdev\n", addr_name (addr),
|
||||
value);
|
||||
break;
|
||||
}
|
||||
|
@ -157,8 +157,8 @@ write_reg (int fd, uint8_t index, uint8_t value)
|
|||
idx = index & 0x0F;
|
||||
DBG (DBG_io2, "write_reg(REG%X,0x%x)\n", idx, value);
|
||||
idx = idx << 4 | idx;
|
||||
outb (fd, EPPADR, idx);
|
||||
outb (fd, EPPDATA, value);
|
||||
p5_outb (fd, EPPADR, idx);
|
||||
p5_outb (fd, EPPDATA, value);
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
|
@ -169,8 +169,8 @@ read_reg (int fd, uint8_t index)
|
|||
/* both nibbles hold the same value */
|
||||
idx = index & 0x0F;
|
||||
idx = idx << 4 | idx;
|
||||
outb (fd, EPPADR, idx);
|
||||
return inb (fd, EPPDATA);
|
||||
p5_outb (fd, EPPADR, idx);
|
||||
return p5_inb (fd, EPPDATA);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LINUX_PPDEV_H
|
||||
|
@ -311,7 +311,7 @@ memtest (int fd, uint16_t addr)
|
|||
}
|
||||
|
||||
|
||||
#define INB(k,y,z) val=inb(k,y); if(val!=z) { DBG(DBG_error,"expected 0x%02x, got 0x%02x\n",z, val); return SANE_FALSE; }
|
||||
#define P5_INB(k,y,z) val=p5_inb(k,y); if(val!=z) { DBG(DBG_error,"expected 0x%02x, got 0x%02x\n",z, val); return SANE_FALSE; }
|
||||
|
||||
/** @brief connect to scanner
|
||||
* This function sends the connect sequence for the scanner.
|
||||
|
@ -323,66 +323,66 @@ connect (int fd)
|
|||
{
|
||||
uint8_t val;
|
||||
|
||||
inb (fd, CONTROL);
|
||||
outb (fd, CONTROL, 0x04);
|
||||
outb (fd, DATA, 0x02);
|
||||
INB (fd, DATA, 0x02);
|
||||
outb (fd, DATA, 0x03);
|
||||
INB (fd, DATA, 0x03);
|
||||
outb (fd, DATA, 0x03);
|
||||
outb (fd, DATA, 0x83);
|
||||
outb (fd, DATA, 0x03);
|
||||
outb (fd, DATA, 0x83);
|
||||
INB (fd, DATA, 0x83);
|
||||
outb (fd, DATA, 0x82);
|
||||
INB (fd, DATA, 0x82);
|
||||
outb (fd, DATA, 0x02);
|
||||
outb (fd, DATA, 0x82);
|
||||
outb (fd, DATA, 0x02);
|
||||
outb (fd, DATA, 0x82);
|
||||
INB (fd, DATA, 0x82);
|
||||
outb (fd, DATA, 0x82);
|
||||
INB (fd, DATA, 0x82);
|
||||
outb (fd, DATA, 0x02);
|
||||
outb (fd, DATA, 0x82);
|
||||
outb (fd, DATA, 0x02);
|
||||
outb (fd, DATA, 0x82);
|
||||
INB (fd, DATA, 0x82);
|
||||
outb (fd, DATA, 0x83);
|
||||
INB (fd, DATA, 0x83);
|
||||
outb (fd, DATA, 0x03);
|
||||
outb (fd, DATA, 0x83);
|
||||
outb (fd, DATA, 0x03);
|
||||
outb (fd, DATA, 0x83);
|
||||
INB (fd, DATA, 0x83);
|
||||
outb (fd, DATA, 0x82);
|
||||
INB (fd, DATA, 0x82);
|
||||
outb (fd, DATA, 0x02);
|
||||
outb (fd, DATA, 0x82);
|
||||
outb (fd, DATA, 0x02);
|
||||
outb (fd, DATA, 0x82);
|
||||
INB (fd, DATA, 0x82);
|
||||
outb (fd, DATA, 0x83);
|
||||
INB (fd, DATA, 0x83);
|
||||
outb (fd, DATA, 0x03);
|
||||
outb (fd, DATA, 0x83);
|
||||
outb (fd, DATA, 0x03);
|
||||
outb (fd, DATA, 0x83);
|
||||
INB (fd, DATA, 0x83);
|
||||
outb (fd, DATA, 0x83);
|
||||
INB (fd, DATA, 0x83);
|
||||
outb (fd, DATA, 0x03);
|
||||
outb (fd, DATA, 0x83);
|
||||
outb (fd, DATA, 0x03);
|
||||
outb (fd, DATA, 0x83);
|
||||
INB (fd, DATA, 0x83);
|
||||
outb (fd, DATA, 0x82);
|
||||
INB (fd, DATA, 0x82);
|
||||
outb (fd, DATA, 0x02);
|
||||
outb (fd, DATA, 0x82);
|
||||
outb (fd, DATA, 0x02);
|
||||
outb (fd, DATA, 0x82);
|
||||
outb (fd, DATA, 0xFF);
|
||||
p5_inb (fd, CONTROL);
|
||||
p5_outb (fd, CONTROL, 0x04);
|
||||
p5_outb (fd, DATA, 0x02);
|
||||
P5_INB (fd, DATA, 0x02);
|
||||
p5_outb (fd, DATA, 0x03);
|
||||
P5_INB (fd, DATA, 0x03);
|
||||
p5_outb (fd, DATA, 0x03);
|
||||
p5_outb (fd, DATA, 0x83);
|
||||
p5_outb (fd, DATA, 0x03);
|
||||
p5_outb (fd, DATA, 0x83);
|
||||
P5_INB (fd, DATA, 0x83);
|
||||
p5_outb (fd, DATA, 0x82);
|
||||
P5_INB (fd, DATA, 0x82);
|
||||
p5_outb (fd, DATA, 0x02);
|
||||
p5_outb (fd, DATA, 0x82);
|
||||
p5_outb (fd, DATA, 0x02);
|
||||
p5_outb (fd, DATA, 0x82);
|
||||
P5_INB (fd, DATA, 0x82);
|
||||
p5_outb (fd, DATA, 0x82);
|
||||
P5_INB (fd, DATA, 0x82);
|
||||
p5_outb (fd, DATA, 0x02);
|
||||
p5_outb (fd, DATA, 0x82);
|
||||
p5_outb (fd, DATA, 0x02);
|
||||
p5_outb (fd, DATA, 0x82);
|
||||
P5_INB (fd, DATA, 0x82);
|
||||
p5_outb (fd, DATA, 0x83);
|
||||
P5_INB (fd, DATA, 0x83);
|
||||
p5_outb (fd, DATA, 0x03);
|
||||
p5_outb (fd, DATA, 0x83);
|
||||
p5_outb (fd, DATA, 0x03);
|
||||
p5_outb (fd, DATA, 0x83);
|
||||
P5_INB (fd, DATA, 0x83);
|
||||
p5_outb (fd, DATA, 0x82);
|
||||
P5_INB (fd, DATA, 0x82);
|
||||
p5_outb (fd, DATA, 0x02);
|
||||
p5_outb (fd, DATA, 0x82);
|
||||
p5_outb (fd, DATA, 0x02);
|
||||
p5_outb (fd, DATA, 0x82);
|
||||
P5_INB (fd, DATA, 0x82);
|
||||
p5_outb (fd, DATA, 0x83);
|
||||
P5_INB (fd, DATA, 0x83);
|
||||
p5_outb (fd, DATA, 0x03);
|
||||
p5_outb (fd, DATA, 0x83);
|
||||
p5_outb (fd, DATA, 0x03);
|
||||
p5_outb (fd, DATA, 0x83);
|
||||
P5_INB (fd, DATA, 0x83);
|
||||
p5_outb (fd, DATA, 0x83);
|
||||
P5_INB (fd, DATA, 0x83);
|
||||
p5_outb (fd, DATA, 0x03);
|
||||
p5_outb (fd, DATA, 0x83);
|
||||
p5_outb (fd, DATA, 0x03);
|
||||
p5_outb (fd, DATA, 0x83);
|
||||
P5_INB (fd, DATA, 0x83);
|
||||
p5_outb (fd, DATA, 0x82);
|
||||
P5_INB (fd, DATA, 0x82);
|
||||
p5_outb (fd, DATA, 0x02);
|
||||
p5_outb (fd, DATA, 0x82);
|
||||
p5_outb (fd, DATA, 0x02);
|
||||
p5_outb (fd, DATA, 0x82);
|
||||
p5_outb (fd, DATA, 0xFF);
|
||||
DBG (DBG_info, "connect() OK...\n");
|
||||
return SANE_TRUE;
|
||||
}
|
||||
|
@ -392,60 +392,60 @@ disconnect (int fd)
|
|||
{
|
||||
uint8_t val;
|
||||
|
||||
outb (fd, CONTROL, 0x04);
|
||||
outb (fd, DATA, 0x00);
|
||||
INB (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x01);
|
||||
INB (fd, DATA, 0x01);
|
||||
outb (fd, DATA, 0x01);
|
||||
outb (fd, DATA, 0x81);
|
||||
outb (fd, DATA, 0x01);
|
||||
outb (fd, DATA, 0x81);
|
||||
INB (fd, DATA, 0x81);
|
||||
outb (fd, DATA, 0x80);
|
||||
INB (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x80);
|
||||
INB (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x80);
|
||||
INB (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x80);
|
||||
INB (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x81);
|
||||
INB (fd, DATA, 0x81);
|
||||
outb (fd, DATA, 0x01);
|
||||
outb (fd, DATA, 0x81);
|
||||
outb (fd, DATA, 0x01);
|
||||
outb (fd, DATA, 0x81);
|
||||
INB (fd, DATA, 0x81);
|
||||
outb (fd, DATA, 0x80);
|
||||
INB (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x80);
|
||||
INB (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x80);
|
||||
INB (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x80);
|
||||
INB (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x80);
|
||||
outb (fd, DATA, 0x00);
|
||||
outb (fd, DATA, 0x80);
|
||||
inb (fd, CONTROL);
|
||||
outb (fd, CONTROL, 0x0C);
|
||||
p5_outb (fd, CONTROL, 0x04);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
P5_INB (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x01);
|
||||
P5_INB (fd, DATA, 0x01);
|
||||
p5_outb (fd, DATA, 0x01);
|
||||
p5_outb (fd, DATA, 0x81);
|
||||
p5_outb (fd, DATA, 0x01);
|
||||
p5_outb (fd, DATA, 0x81);
|
||||
P5_INB (fd, DATA, 0x81);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
P5_INB (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
P5_INB (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
P5_INB (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
P5_INB (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x81);
|
||||
P5_INB (fd, DATA, 0x81);
|
||||
p5_outb (fd, DATA, 0x01);
|
||||
p5_outb (fd, DATA, 0x81);
|
||||
p5_outb (fd, DATA, 0x01);
|
||||
p5_outb (fd, DATA, 0x81);
|
||||
P5_INB (fd, DATA, 0x81);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
P5_INB (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
P5_INB (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
P5_INB (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
P5_INB (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
p5_outb (fd, DATA, 0x00);
|
||||
p5_outb (fd, DATA, 0x80);
|
||||
p5_inb (fd, CONTROL);
|
||||
p5_outb (fd, CONTROL, 0x0C);
|
||||
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
@ -1018,7 +1018,7 @@ wait_document (int fd, uint8_t detector)
|
|||
write_reg (fd, REG2, 0x90);
|
||||
write_reg (fd, REGF, 0x82);
|
||||
write_reg (fd, REG0, 0x00);
|
||||
val = inb (fd, STATUS) & 0xf8;
|
||||
val = p5_inb (fd, STATUS) & 0xf8;
|
||||
if (val != 0xf8)
|
||||
{
|
||||
DBG (DBG_error, "wait_document: unexpected STATUS value 0x%02x instead of 0xf8", val);
|
||||
|
|
|
@ -959,37 +959,37 @@ _LOC void IOReadScannerImageData( pScanData ps, pUChar pBuf, ULong size )
|
|||
*/
|
||||
_LOC void IOOut( Byte data, UShort port )
|
||||
{
|
||||
DBG( DBG_IOF, "outb(0x%04x, 0x%02x)\n", port, data );
|
||||
outb( data, port );
|
||||
DBG( DBG_IOF, "sanei_outb(0x%04x, 0x%02x)\n", port, data );
|
||||
sanei_outb( port, data );
|
||||
}
|
||||
|
||||
_LOC void IOOutDelayed( Byte data, UShort port )
|
||||
{
|
||||
DBG( DBG_IOF, "outb_p(0x%04x, 0x%02x)\n", port, data );
|
||||
outb_p( data, port );
|
||||
DBG( DBG_IOF, "sanei_outb_p(0x%04x, 0x%02x)\n", port, data );
|
||||
sanei_outb_p( port, data );
|
||||
}
|
||||
|
||||
_LOC Byte IOIn( UShort port )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Byte data = inb( port );
|
||||
Byte data = sani_inb( port );
|
||||
|
||||
DBG( DBG_IOF, "inb(0x%04x) = 0x%02x\n", port, data );
|
||||
DBG( DBG_IOF, "sanei_inb(0x%04x) = 0x%02x\n", port, data );
|
||||
return data;
|
||||
#else
|
||||
return inb( port );
|
||||
return sanei_inb( port );
|
||||
#endif
|
||||
}
|
||||
|
||||
_LOC Byte IOInDelayed( UShort port )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Byte data = inb_p( port );
|
||||
Byte data = sanei_inb_p( port );
|
||||
|
||||
DBG( DBG_IOF, "inb_p(0x%04x) = 0x%02x\n", port, data );
|
||||
DBG( DBG_IOF, "sanei_inb_p(0x%04x) = 0x%02x\n", port, data );
|
||||
return data;
|
||||
#else
|
||||
return inb_p( port );
|
||||
return sanei_inb_p( port );
|
||||
#endif
|
||||
}
|
||||
#endif /* guard __KERNEL__ */
|
||||
|
|
|
@ -320,7 +320,7 @@ static int miscSetFastMode( pScanData ps )
|
|||
|
||||
_OUTB_DATA(ps,0x55);
|
||||
_DO_UDELAY(1);
|
||||
if ((inb(ps->IO.portBase)) != 0x55) /* read data */
|
||||
if ((sanei_inb(ps->IO.portBase)) != 0x55) /* read data */
|
||||
a++;
|
||||
|
||||
_OUTB_DATA(ps,0xAA);
|
||||
|
|
|
@ -191,23 +191,13 @@ static const SANE_Range odd_bw_x_range = { 1, 335, 2 };
|
|||
static const SANE_Range bw_y_range = { 0, 241, 1 };
|
||||
static const SANE_Range odd_bw_y_range = { 1, 242, 1 };
|
||||
|
||||
#if defined(HAVE_SYS_IO_H) || defined(HAVE_ASM_IO_H) || defined (HAVE_SYS_HW_H)
|
||||
#include "../include/sane/sanei_directio.h"
|
||||
|
||||
#ifdef HAVE_SYS_IO_H
|
||||
# include <sys/io.h> /* GNU libc based OS */
|
||||
#elif HAVE_ASM_IO_H
|
||||
# include <asm/io.h> /* older Linux */
|
||||
#elif HAVE_SYS_HW_H
|
||||
# include <sys/hw.h> /* OS/2 */
|
||||
#endif
|
||||
|
||||
#endif /* <sys/io.h> || <asm/io.h> || <sys/hw.h> */
|
||||
|
||||
#define read_lpdata(d) inb ((d)->port)
|
||||
#define read_lpstatus(d) inb ((d)->port + 1)
|
||||
#define read_lpcontrol(d) inb ((d)->port + 2)
|
||||
#define write_lpdata(d,v) outb ((v), (d)->port)
|
||||
#define write_lpcontrol(d,v) outb ((v), (d)->port + 2)
|
||||
#define read_lpdata(d) sanei_inb ((d)->port)
|
||||
#define read_lpstatus(d) sanei_inb ((d)->port + 1)
|
||||
#define read_lpcontrol(d) sanei_inb ((d)->port + 2)
|
||||
#define write_lpdata(d,v) sanei_outb ((d)->port, (v))
|
||||
#define write_lpcontrol(d,v) sanei_outb ((d)->port + 2, (v))
|
||||
|
||||
|
||||
static SANE_Status
|
||||
|
@ -217,7 +207,7 @@ enable_ports (QC_Device * q)
|
|||
if (q->port < 0x278 || q->port > 0x3bc)
|
||||
return SANE_STATUS_INVAL;
|
||||
|
||||
if (ioperm (q->port, 3, 1) < 0)
|
||||
if (sanei_ioperm (q->port, 3, 1) < 0)
|
||||
return SANE_STATUS_INVAL;
|
||||
|
||||
return SANE_STATUS_GOOD;
|
||||
|
@ -226,7 +216,7 @@ enable_ports (QC_Device * q)
|
|||
static SANE_Status
|
||||
disable_ports (QC_Device * q)
|
||||
{
|
||||
if (ioperm (q->port, 3, 0) < 0)
|
||||
if (sanei_ioperm (q->port, 3, 0) < 0)
|
||||
return SANE_STATUS_INVAL;
|
||||
|
||||
return SANE_STATUS_GOOD;
|
||||
|
|
|
@ -53,9 +53,7 @@
|
|||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_IO_H
|
||||
#include <sys/io.h>
|
||||
#endif
|
||||
#include "../include/sane/sanei_directio.h"
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
@ -85,380 +83,6 @@
|
|||
#include <linux/ppdev.h>
|
||||
#endif
|
||||
|
||||
/*************************************************/
|
||||
/* here we define sanei_inb/sanei_outb based on */
|
||||
/* OS dependent inb/outb definitions */
|
||||
/* SANE_INB is defined whenever a valid inb/outb */
|
||||
/* definition has been found */
|
||||
/* once all these work, it might be moved to */
|
||||
/* sanei_pio.c */
|
||||
/*************************************************/
|
||||
|
||||
#ifdef ENABLE_PARPORT_DIRECTIO
|
||||
|
||||
#if (! defined SANE_INB ) && ( defined HAVE_SYS_HW_H ) /* OS/2 EMX case */
|
||||
#define SANE_INB 1
|
||||
static int
|
||||
sanei_ioperm (int start, int length, int enable)
|
||||
{
|
||||
if (enable)
|
||||
return _portaccess (port, port + length - 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
sanei_inb (unsigned int port)
|
||||
{
|
||||
return _inp8 (port) & 0xFF;
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outb (unsigned int port, unsigned char value)
|
||||
{
|
||||
_outp8 (port, value);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_insb (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
_inps8 (port, (unsigned char *) addr, count);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_insl (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
_inps32 (port, (unsigned long *) addr, count);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outsb (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
_outps8 (port, (unsigned char *) addr, count);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outsl (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
_outps32 (port, (unsigned long *) addr, count);
|
||||
}
|
||||
#endif /* OS/2 EMX case */
|
||||
|
||||
|
||||
|
||||
#if (! defined SANE_INB ) && ( defined HAVE_MACHINE_CPUFUNC_H ) /* FreeBSD case */
|
||||
#define SANE_INB 2
|
||||
static int
|
||||
sanei_ioperm (int start, int length, int enable)
|
||||
{
|
||||
#ifdef HAVE_I386_SET_IOPERM
|
||||
return i386_set_ioperm (start, length, enable);
|
||||
#else
|
||||
int fd = 0;
|
||||
|
||||
/* makes compilers happy */
|
||||
start = length + enable;
|
||||
fd = open ("/dev/io", O_RDONLY);
|
||||
if (fd > 0)
|
||||
return 0;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
sanei_inb (unsigned int port)
|
||||
{
|
||||
return inb (port);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outb (unsigned int port, unsigned char value)
|
||||
{
|
||||
outb (port, value);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_insb (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
insb (port, addr, count);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_insl (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
insl (port, addr, count);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outsb (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
outsb (port, addr, count);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outsl (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
outsl (port, addr, count);
|
||||
}
|
||||
#endif /* FreeBSD case */
|
||||
|
||||
|
||||
/* linux GCC on i386 */
|
||||
#if ( ! defined SANE_INB ) && ( defined HAVE_SYS_IO_H ) && ( defined __GNUC__ ) && ( defined __i386__ )
|
||||
#define SANE_INB 3
|
||||
|
||||
static int
|
||||
sanei_ioperm (int start, int length, int enable)
|
||||
{
|
||||
#ifdef HAVE_IOPERM
|
||||
return ioperm (start, length, enable);
|
||||
#else
|
||||
/* linux without ioperm ? hum ... */
|
||||
/* makes compilers happy */
|
||||
start = length + enable;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
sanei_inb (unsigned int port)
|
||||
{
|
||||
return inb (port);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outb (unsigned int port, unsigned char value)
|
||||
{
|
||||
outb (value, port);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_insb (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
insb (port, addr, count);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_insl (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
insl (port, addr, count);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outsb (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
outsb (port, addr, count);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outsl (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
/* oddly, 32 bit I/O are done with outsw instead of the expected outsl */
|
||||
outsw (port, addr, count);
|
||||
}
|
||||
#endif /* linux GCC on i386 */
|
||||
|
||||
|
||||
/* linux GCC non i386 */
|
||||
#if ( ! defined SANE_INB ) && ( defined HAVE_SYS_IO_H ) && ( defined __GNUC__ ) && ( ! defined __i386__ )
|
||||
#define SANE_INB 4
|
||||
static int
|
||||
sanei_ioperm (int start, int length, int enable)
|
||||
{
|
||||
#ifdef HAVE_IOPERM
|
||||
return ioperm (start, length, enable);
|
||||
#else
|
||||
/* linux without ioperm ? hum ... */
|
||||
/* makes compilers happy */
|
||||
start = length + enable;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
sanei_inb (unsigned int port)
|
||||
{
|
||||
return inb (port);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outb (unsigned int port, unsigned char value)
|
||||
{
|
||||
outb (value, port);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_insb (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
addr[i] = sanei_inb (port);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_insl (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < count * 4; i++)
|
||||
addr[i] = sanei_inb (port);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outsb (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
sanei_outb (port, addr[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outsl (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < count * 4; i++)
|
||||
sanei_outb (port, addr[i]);
|
||||
}
|
||||
#endif /* linux GCC non i386 */
|
||||
|
||||
|
||||
/* ICC on i386 */
|
||||
#if ( ! defined SANE_INB ) && ( defined __INTEL_COMPILER ) && ( defined __i386__ )
|
||||
#define SANE_INB 5
|
||||
static int
|
||||
sanei_ioperm (int start, int length, int enable)
|
||||
{
|
||||
#ifdef HAVE_IOPERM
|
||||
return ioperm (start, length, enable);
|
||||
#else
|
||||
/* ICC without ioperm() ... */
|
||||
/* makes compilers happy */
|
||||
start = length + enable;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
static unsigned char
|
||||
sanei_inb (unsigned int port)
|
||||
{
|
||||
unsigned char ret;
|
||||
|
||||
__asm__ __volatile__ ("inb %%dx,%%al":"=a" (ret):"d" ((u_int) port));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outb (unsigned int port, unsigned char value)
|
||||
{
|
||||
__asm__ __volatile__ ("outb %%al,%%dx"::"a" (value), "d" ((u_int) port));
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_insb (unsigned int port, void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__ ("rep ; insb":"=D" (addr), "=c" (count):"d" (port),
|
||||
"0" (addr), "1" (count));
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_insl (unsigned int port, void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__ ("rep ; insl":"=D" (addr), "=c" (count):"d" (port),
|
||||
"0" (addr), "1" (count));
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outsb (unsigned int port, const void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__ ("rep ; outsb":"=S" (addr), "=c" (count):"d" (port),
|
||||
"0" (addr), "1" (count));
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outsl (unsigned int port, const void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__ ("rep ; outsl":"=S" (addr), "=c" (count):"d" (port),
|
||||
"0" (addr), "1" (count));
|
||||
}
|
||||
|
||||
#endif /* ICC on i386 */
|
||||
|
||||
/* direct io requested, but no valid inb/oub */
|
||||
#if ( ! defined SANE_INB) && ( defined ENABLE_PARPORT_DIRECTIO )
|
||||
#warning "ENABLE_PARPORT_DIRECTIO cannot be used du to lack of inb/out definition"
|
||||
#undef ENABLE_PARPORT_DIRECTIO
|
||||
#endif
|
||||
|
||||
#endif /* ENABLE_PARPORT_DIRECTIO */
|
||||
/*
|
||||
* no inb/outb without --enable-parport-directio *
|
||||
*/
|
||||
#ifndef ENABLE_PARPORT_DIRECTIO
|
||||
#define SANE_INB 0
|
||||
static int
|
||||
sanei_ioperm (__sane_unused__ int start, __sane_unused__ int length,
|
||||
__sane_unused__ int enable)
|
||||
{
|
||||
/* returns failure */
|
||||
return -1;
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
sanei_inb (__sane_unused__ unsigned int port)
|
||||
{
|
||||
return 255;
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outb (__sane_unused__ unsigned int port,
|
||||
__sane_unused__ unsigned char value)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_insb (__sane_unused__ unsigned int port,
|
||||
__sane_unused__ unsigned char *addr,
|
||||
__sane_unused__ unsigned long count)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_insl (__sane_unused__ unsigned int port,
|
||||
__sane_unused__ unsigned char *addr,
|
||||
__sane_unused__ unsigned long count)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outsb (__sane_unused__ unsigned int port,
|
||||
__sane_unused__ const unsigned char *addr,
|
||||
__sane_unused__ unsigned long count)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
sanei_outsl (__sane_unused__ unsigned int port,
|
||||
__sane_unused__ const unsigned char *addr,
|
||||
__sane_unused__ unsigned long count)
|
||||
{
|
||||
}
|
||||
#endif /* ENABLE_PARPORT_DIRECTIO is not defined */
|
||||
|
||||
/* we need either direct io or ppdev */
|
||||
#if ! defined ENABLE_PARPORT_DIRECTIO && ! defined HAVE_LINUX_PPDEV_H && ! defined HAVE_DEV_PPBUS_PPI_H
|
||||
#define IO_SUPPORT_MISSING
|
||||
#endif
|
||||
|
||||
|
||||
#include "umax_pp_low.h"
|
||||
|
||||
#ifdef DMALLOC
|
||||
|
|
|
@ -11,8 +11,9 @@ EXTRA_DIST = lalloca.h lassert.h lgetopt.h md5.h font_6x11.h
|
|||
EXTRA_DIST += sane/config.h.in sane/sanei.h sane/sanei_ab306.h \
|
||||
sane/sanei_access.h sane/sanei_auth.h sane/sanei_backend.h \
|
||||
sane/sanei_cderror.h sane/sanei_codec_ascii.h sane/sanei_codec_bin.h \
|
||||
sane/sanei_config.h sane/sanei_debug.h sane/sanei_jinclude.h \
|
||||
sane/sanei_jpeg.h sane/sanei_lm983x.h sane/sanei_net.h sane/sanei_pa4s2.h \
|
||||
sane/sanei_pio.h sane/sanei_pp.h sane/sanei_pv8630.h sane/sanei_scsi.h \
|
||||
sane/sanei_tcp.h sane/sanei_thread.h sane/sanei_udp.h sane/sanei_usb.h \
|
||||
sane/sanei_config.h sane/sanei_debug.h sane/sanei_directio.h \
|
||||
sane/sanei_jinclude.h sane/sanei_jpeg.h sane/sanei_lm983x.h \
|
||||
sane/sanei_net.h sane/sanei_pa4s2.h sane/sanei_pio.h sane/sanei_pp.h \
|
||||
sane/sanei_pv8630.h sane/sanei_scsi.h sane/sanei_tcp.h \
|
||||
sane/sanei_thread.h sane/sanei_udp.h sane/sanei_usb.h \
|
||||
sane/sanei_wire.h sane/sanei_magic.h sane/sanei_ir.h
|
||||
|
|
|
@ -24,14 +24,6 @@
|
|||
# define __func__ "(unknown)"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_HW_H
|
||||
/* OS/2 i/o-port access compatibility macros: */
|
||||
# define inb(p) _inp8 (p)
|
||||
# define outb(v,p) _outp8 ((p),(v))
|
||||
# define ioperm(b,l,o) _portaccess ((b),(b)+(l)-1)
|
||||
# define HAVE_IOPERM 1
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_OS2_H
|
||||
#include <fcntl.h>
|
||||
#ifndef O_NONBLOCK
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
#ifndef __SANEI_DIRECTIO_H__
|
||||
#define __SANEI_DIRECTIO_H__
|
||||
|
||||
#ifdef HAVE_SYS_IO_H
|
||||
#include <sys/io.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_PARPORT_DIRECTIO
|
||||
|
||||
#if (! defined SANE_INB ) && ( defined HAVE_SYS_HW_H ) /* OS/2 EMX case */
|
||||
#define SANE_INB 1
|
||||
#endif /* OS/2 EMX case */
|
||||
|
||||
|
||||
|
||||
#if (! defined SANE_INB ) && ( defined HAVE_MACHINE_CPUFUNC_H ) /* FreeBSD case */
|
||||
#define SANE_INB 2
|
||||
#endif /* FreeBSD case */
|
||||
|
||||
|
||||
/* linux GCC on i386 */
|
||||
#if ( ! defined SANE_INB ) && ( defined HAVE_SYS_IO_H ) && ( defined __GNUC__ ) && ( defined __i386__ )
|
||||
#define SANE_INB 3
|
||||
#endif /* linux GCC on i386 */
|
||||
|
||||
|
||||
/* linux GCC non i386 */
|
||||
#if ( ! defined SANE_INB ) && ( defined HAVE_SYS_IO_H ) && ( defined __GNUC__ ) && ( ! defined __i386__ )
|
||||
#define SANE_INB 4
|
||||
#endif /* linux GCC non i386 */
|
||||
|
||||
|
||||
/* ICC on i386 */
|
||||
#if ( ! defined SANE_INB ) && ( defined __INTEL_COMPILER ) && ( defined __i386__ )
|
||||
#define SANE_INB 5
|
||||
#endif /* ICC on i386 */
|
||||
|
||||
/* direct io requested, but no valid inb/oub */
|
||||
#if ( ! defined SANE_INB) && ( defined ENABLE_PARPORT_DIRECTIO )
|
||||
#warning "ENABLE_PARPORT_DIRECTIO cannot be used du to lack of inb/out definition"
|
||||
#undef ENABLE_PARPORT_DIRECTIO
|
||||
#endif
|
||||
|
||||
#endif /* ENABLE_PARPORT_DIRECTIO */
|
||||
|
||||
/*
|
||||
* no inb/outb without --enable-parport-directio *
|
||||
*/
|
||||
#ifndef ENABLE_PARPORT_DIRECTIO
|
||||
#define SANE_INB 0
|
||||
#endif /* ENABLE_PARPORT_DIRECTIO is not defined */
|
||||
|
||||
/* we need either direct io or ppdev */
|
||||
#if ! defined ENABLE_PARPORT_DIRECTIO && ! defined HAVE_LINUX_PPDEV_H && ! defined HAVE_DEV_PPBUS_PPI_H
|
||||
#define IO_SUPPORT_MISSING
|
||||
#endif
|
||||
|
||||
|
||||
extern int sanei_ioperm (int start, int length, int enable);
|
||||
extern unsigned char sanei_inb (unsigned int port);
|
||||
extern void sanei_outb (unsigned int port, unsigned char value);
|
||||
extern void sanei_insb (unsigned int port, unsigned char *addr,
|
||||
unsigned long count);
|
||||
extern void sanei_insl (unsigned int port, unsigned char *addr,
|
||||
unsigned long count);
|
||||
extern void sanei_outsb (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count);
|
||||
extern void sanei_outsl (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count);
|
||||
|
||||
#endif // __SANEI_DIRECTIO_H__
|
|
@ -9,7 +9,7 @@ AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include \
|
|||
|
||||
noinst_LTLIBRARIES = libsanei.la
|
||||
|
||||
libsanei_la_SOURCES = sanei_ab306.c sanei_constrain_value.c \
|
||||
libsanei_la_SOURCES = sanei_directio.c sanei_ab306.c sanei_constrain_value.c \
|
||||
sanei_init_debug.c sanei_net.c sanei_wire.c sanei_codec_ascii.c \
|
||||
sanei_codec_bin.c sanei_scsi.c sanei_config.c sanei_config2.c \
|
||||
sanei_pio.c sanei_pa4s2.c sanei_auth.c sanei_usb.c sanei_thread.c \
|
||||
|
|
|
@ -47,33 +47,7 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_IO_H
|
||||
# include <sys/io.h> /* use where available (glibc 2.x, for example) */
|
||||
# ifndef SANE_HAVE_SYS_IO_H_WITH_INB_OUTB
|
||||
# define IO_SUPPORT_MISSING
|
||||
# endif
|
||||
#elif HAVE_ASM_IO_H
|
||||
# include <asm/io.h> /* ugly, but backwards compatible */
|
||||
#elif defined (__i386__) && defined (__GNUC__)
|
||||
|
||||
static __inline__ void
|
||||
outb (u_char value, u_long port)
|
||||
{
|
||||
__asm__ __volatile__ ("outb %0,%1" : : "a" (value), "d" ((u_short) port));
|
||||
}
|
||||
|
||||
static __inline__ u_char
|
||||
inb (u_long port)
|
||||
{
|
||||
u_char value;
|
||||
|
||||
__asm__ __volatile__ ("inb %1,%0" : "=a" (value) : "d" ((u_short)port));
|
||||
return value;
|
||||
}
|
||||
|
||||
#else
|
||||
# define IO_SUPPORT_MISSING
|
||||
#endif
|
||||
#include "../include/sane/sanei_directio.h"
|
||||
|
||||
#include "../include/sane/sane.h"
|
||||
#include "../include/sane/sanei.h"
|
||||
|
@ -149,7 +123,7 @@ ab306_outb (Port *p, u_long addr, u_char val)
|
|||
return;
|
||||
}
|
||||
else
|
||||
outb (val, addr);
|
||||
sanei_outb (addr, val);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -166,7 +140,7 @@ ab306_inb (Port *p, u_long addr)
|
|||
return ch;
|
||||
}
|
||||
else
|
||||
return inb (addr);
|
||||
return sanei_inb (addr);
|
||||
}
|
||||
|
||||
/* Send a single command-byte over the AB306N-interface. */
|
||||
|
@ -299,11 +273,11 @@ sanei_ab306_open (const char *dev, int *fdp)
|
|||
byte = wakeup[j];
|
||||
if (j == NELEMS(wakeup) - 1)
|
||||
byte |= i;
|
||||
outb (byte, AB306_CIO);
|
||||
sanei_outb (AB306_CIO, byte);
|
||||
}
|
||||
|
||||
#else /* !defined(__FreeBSD__) */
|
||||
if (ioperm (AB306_CIO, 1, 1) != 0)
|
||||
if (sanei_ioperm (AB306_CIO, 1, 1) != 0)
|
||||
{
|
||||
DBG(1, "sanei_ab306_ioport: using /dev/port access\n");
|
||||
if (port[i].port_fd < 0)
|
||||
|
@ -329,7 +303,7 @@ sanei_ab306_open (const char *dev, int *fdp)
|
|||
byte = wakeup[j];
|
||||
if (j == NELEMS(wakeup) - 1)
|
||||
byte |= i;
|
||||
outb (byte, AB306_CIO);
|
||||
sanei_outb (AB306_CIO, byte);
|
||||
}
|
||||
status = sanei_ab306_get_io_privilege (i);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
@ -373,7 +347,7 @@ sanei_ab306_get_io_privilege (int fd)
|
|||
if (dev_io_fd < 0)
|
||||
return SANE_STATUS_IO_ERROR;
|
||||
#else /* !defined(__FreeBSD__) */
|
||||
if (ioperm (port[fd].base, 3, 1) != 0)
|
||||
if (sanei_ioperm (port[fd].base, 3, 1) != 0)
|
||||
return SANE_STATUS_IO_ERROR;
|
||||
#endif /* !defined(__FreeBSD__) */
|
||||
}
|
||||
|
@ -493,7 +467,7 @@ sanei_ab306_rdata (int fd, int planes, SANE_Byte * buf, int lines, int bpl)
|
|||
/* the pixel-loop: */
|
||||
for (bcnt = 0; bcnt < xmax; bcnt++)
|
||||
{
|
||||
*(u_char *) buf = inb (p->base);
|
||||
*(u_char *) buf = sanei_inb (p->base);
|
||||
++buf;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,367 @@
|
|||
/*************************************************/
|
||||
/* here we define sanei_inb/sanei_outb based on */
|
||||
/* OS dependent inb/outb definitions */
|
||||
/* SANE_INB is defined whenever a valid inb/outb */
|
||||
/* definition has been found */
|
||||
/*************************************************/
|
||||
|
||||
#include "../include/sane/config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "../include/sane/sane.h"
|
||||
#include "../include/sane/sanei.h"
|
||||
#include "../include/sane/sanei_directio.h"
|
||||
|
||||
#ifdef ENABLE_PARPORT_DIRECTIO
|
||||
|
||||
#define TEST_SANE_INB(val) ( SANE_INB == val )
|
||||
|
||||
#if ( TEST_SANE_INB(1) ) /* OS/2 EMX case */
|
||||
int
|
||||
sanei_ioperm (int start, int length, int enable)
|
||||
{
|
||||
if (enable)
|
||||
return _portaccess (port, port + length - 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
sanei_inb (unsigned int port)
|
||||
{
|
||||
return _inp8 (port) & 0xFF;
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outb (unsigned int port, unsigned char value)
|
||||
{
|
||||
_outp8 (port, value);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_insb (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
_inps8 (port, (unsigned char *) addr, count);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_insl (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
_inps32 (port, (unsigned long *) addr, count);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outsb (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
_outps8 (port, (unsigned char *) addr, count);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outsl (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
_outps32 (port, (unsigned long *) addr, count);
|
||||
}
|
||||
#endif /* OS/2 EMX case */
|
||||
|
||||
|
||||
|
||||
#if ( TEST_SANE_INB(2) ) /* FreeBSD case */
|
||||
int
|
||||
sanei_ioperm (int start, int length, int enable)
|
||||
{
|
||||
#ifdef HAVE_I386_SET_IOPERM
|
||||
return i386_set_ioperm (start, length, enable);
|
||||
#else
|
||||
int fd = 0;
|
||||
|
||||
/* makes compilers happy */
|
||||
start = length + enable;
|
||||
fd = open ("/dev/io", O_RDONLY);
|
||||
if (fd > 0)
|
||||
return 0;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned char
|
||||
sanei_inb (unsigned int port)
|
||||
{
|
||||
return inb (port);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outb (unsigned int port, unsigned char value)
|
||||
{
|
||||
outb (port, value);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_insb (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
insb (port, addr, count);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_insl (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
insl (port, addr, count);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outsb (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
outsb (port, addr, count);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outsl (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
outsl (port, addr, count);
|
||||
}
|
||||
#endif /* FreeBSD case */
|
||||
|
||||
|
||||
/* linux GCC on i386 */
|
||||
#if ( TEST_SANE_INB(3) ) /* FreeBSD case */
|
||||
|
||||
int
|
||||
sanei_ioperm (int start, int length, int enable)
|
||||
{
|
||||
#ifdef HAVE_IOPERM
|
||||
return ioperm (start, length, enable);
|
||||
#else
|
||||
/* linux without ioperm ? hum ... */
|
||||
/* makes compilers happy */
|
||||
start = length + enable;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned char
|
||||
sanei_inb (unsigned int port)
|
||||
{
|
||||
return inb (port);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outb (unsigned int port, unsigned char value)
|
||||
{
|
||||
outb (value, port);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_insb (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
insb (port, addr, count);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_insl (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
insl (port, addr, count);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outsb (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
outsb (port, addr, count);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outsl (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
/* oddly, 32 bit I/O are done with outsw instead of the expected outsl */
|
||||
outsw (port, addr, count);
|
||||
}
|
||||
#endif /* linux GCC on i386 */
|
||||
|
||||
|
||||
/* linux GCC non i386 */
|
||||
#if ( TEST_SANE_INB(4) )
|
||||
int
|
||||
sanei_ioperm (int start, int length, int enable)
|
||||
{
|
||||
#ifdef HAVE_IOPERM
|
||||
return ioperm (start, length, enable);
|
||||
#else
|
||||
/* linux without ioperm ? hum ... */
|
||||
/* makes compilers happy */
|
||||
start = length + enable;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned char
|
||||
sanei_inb (unsigned int port)
|
||||
{
|
||||
return inb (port);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outb (unsigned int port, unsigned char value)
|
||||
{
|
||||
outb (value, port);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_insb (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
addr[i] = sanei_inb (port);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_insl (unsigned int port, unsigned char *addr, unsigned long count)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < count * 4; i++)
|
||||
addr[i] = sanei_inb (port);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outsb (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
sanei_outb (port, addr[i]);
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outsl (unsigned int port, const unsigned char *addr,
|
||||
unsigned long count)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < count * 4; i++)
|
||||
sanei_outb (port, addr[i]);
|
||||
}
|
||||
#endif /* linux GCC non i386 */
|
||||
|
||||
|
||||
/* ICC on i386 */
|
||||
#if ( TEST_SANE_INB(5) )
|
||||
int
|
||||
sanei_ioperm (int start, int length, int enable)
|
||||
{
|
||||
#ifdef HAVE_IOPERM
|
||||
return ioperm (start, length, enable);
|
||||
#else
|
||||
/* ICC without ioperm() ... */
|
||||
/* makes compilers happy */
|
||||
start = length + enable;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
unsigned char
|
||||
sanei_inb (unsigned int port)
|
||||
{
|
||||
unsigned char ret;
|
||||
|
||||
__asm__ __volatile__ ("inb %%dx,%%al":"=a" (ret):"d" ((u_int) port));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outb (unsigned int port, unsigned char value)
|
||||
{
|
||||
__asm__ __volatile__ ("outb %%al,%%dx"::"a" (value), "d" ((u_int) port));
|
||||
}
|
||||
|
||||
void
|
||||
sanei_insb (unsigned int port, void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__ ("rep ; insb":"=D" (addr), "=c" (count):"d" (port),
|
||||
"0" (addr), "1" (count));
|
||||
}
|
||||
|
||||
void
|
||||
sanei_insl (unsigned int port, void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__ ("rep ; insl":"=D" (addr), "=c" (count):"d" (port),
|
||||
"0" (addr), "1" (count));
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outsb (unsigned int port, const void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__ ("rep ; outsb":"=S" (addr), "=c" (count):"d" (port),
|
||||
"0" (addr), "1" (count));
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outsl (unsigned int port, const void *addr, unsigned long count)
|
||||
{
|
||||
__asm__ __volatile__ ("rep ; outsl":"=S" (addr), "=c" (count):"d" (port),
|
||||
"0" (addr), "1" (count));
|
||||
}
|
||||
|
||||
#endif /* ICC on i386 */
|
||||
|
||||
#endif /* ENABLE_PARPORT_DIRECTIO */
|
||||
/*
|
||||
* no inb/outb without --enable-parport-directio *
|
||||
*/
|
||||
#ifndef ENABLE_PARPORT_DIRECTIO
|
||||
int
|
||||
sanei_ioperm (__sane_unused__ int start, __sane_unused__ int length,
|
||||
__sane_unused__ int enable)
|
||||
{
|
||||
/* returns failure */
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
sanei_inb (__sane_unused__ unsigned int port)
|
||||
{
|
||||
return 255;
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outb (__sane_unused__ unsigned int port,
|
||||
__sane_unused__ unsigned char value)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sanei_insb (__sane_unused__ unsigned int port,
|
||||
__sane_unused__ unsigned char *addr,
|
||||
__sane_unused__ unsigned long count)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sanei_insl (__sane_unused__ unsigned int port,
|
||||
__sane_unused__ unsigned char *addr,
|
||||
__sane_unused__ unsigned long count)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outsb (__sane_unused__ unsigned int port,
|
||||
__sane_unused__ const unsigned char *addr,
|
||||
__sane_unused__ unsigned long count)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sanei_outsl (__sane_unused__ unsigned int port,
|
||||
__sane_unused__ const unsigned char *addr,
|
||||
__sane_unused__ unsigned long count)
|
||||
{
|
||||
}
|
||||
#endif /* ENABLE_PARPORT_DIRECTIO is not defined */
|
|
@ -66,43 +66,7 @@
|
|||
|
||||
#elif defined(ENABLE_PARPORT_DIRECTIO)
|
||||
|
||||
# if defined(HAVE_SYS_IO_H)
|
||||
# if defined (__ICC) && __ICC >= 700
|
||||
# define __GNUC__ 2
|
||||
# endif
|
||||
# include <sys/io.h>
|
||||
# ifndef SANE_HAVE_SYS_IO_H_WITH_INB_OUTB
|
||||
# define IO_SUPPORT_MISSING
|
||||
# endif
|
||||
# if defined (__ICC) && __ICC >= 700
|
||||
# undef __GNUC__
|
||||
# elif defined(__ICC) && defined(HAVE_ASM_IO_H)
|
||||
# include <asm/io.h>
|
||||
# endif
|
||||
# elif defined(HAVE_ASM_IO_H)
|
||||
# include <asm/io.h> /* ugly, but backwards compatible */
|
||||
# elif defined(HAVE_SYS_HW_H)
|
||||
# include <sys/hw.h>
|
||||
# elif defined(__i386__) && ( defined (__GNUC__) || defined (__ICC) )
|
||||
|
||||
static __inline__ void
|
||||
outb (u_char value, u_long port)
|
||||
{
|
||||
__asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((u_short) port));
|
||||
}
|
||||
|
||||
static __inline__ u_char
|
||||
inb (u_long port)
|
||||
{
|
||||
u_char value;
|
||||
|
||||
__asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((u_short) port));
|
||||
return value;
|
||||
}
|
||||
|
||||
# else
|
||||
# define IO_SUPPORT_MISSING
|
||||
# endif
|
||||
#include "../include/sane/sanei_directio.h"
|
||||
|
||||
#else
|
||||
|
||||
|
@ -519,7 +483,7 @@ pa4s2_open (const char *dev, SANE_Status * status)
|
|||
|
||||
/* TODO: insert FreeBSD compatible code here */
|
||||
|
||||
if (ioperm (port[n].base, 5, 1))
|
||||
if (sanei_ioperm (port[n].base, 5, 1))
|
||||
{
|
||||
|
||||
DBG (1, "pa4s2_open: cannot get io privilege for port 0x%03lx\n",
|
||||
|
@ -571,15 +535,15 @@ static void outbyte3(int fd, u_char val)
|
|||
|
||||
#else
|
||||
|
||||
#define inbyte0(fd) inb(port[fd].base)
|
||||
#define inbyte1(fd) inb(port[fd].base + 1)
|
||||
#define inbyte2(fd) inb(port[fd].base + 2)
|
||||
#define inbyte4(fd) inb(port[fd].base + 4)
|
||||
#define inbyte0(fd) sanei_inb(port[fd].base)
|
||||
#define inbyte1(fd) sanei_inb(port[fd].base + 1)
|
||||
#define inbyte2(fd) sanei_inb(port[fd].base + 2)
|
||||
#define inbyte4(fd) sanei_inb(port[fd].base + 4)
|
||||
|
||||
#define outbyte0(fd,val) outb(val, port[fd].base)
|
||||
#define outbyte1(fd,val) outb(val, port[fd].base + 1)
|
||||
#define outbyte2(fd,val) outb(val, port[fd].base + 2)
|
||||
#define outbyte3(fd,val) outb(val, port[fd].base + 3)
|
||||
#define outbyte0(fd,val) sanei_outb(port[fd].base, val)
|
||||
#define outbyte1(fd,val) sanei_outb(port[fd].base + 1, val)
|
||||
#define outbyte2(fd,val) sanei_outb(port[fd].base + 2, val)
|
||||
#define outbyte3(fd,val) sanei_outb(port[fd].base + 3, val)
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -882,7 +846,7 @@ pa4s2_close (int fd, SANE_Status * status)
|
|||
#if defined(HAVE_LIBIEEE1284)
|
||||
if ((result = ieee1284_close(pplist.portv[fd])) < 0)
|
||||
#else
|
||||
if (ioperm (port[fd].base, 5, 0))
|
||||
if (sanei_ioperm (port[fd].base, 5, 0))
|
||||
#endif
|
||||
{
|
||||
|
||||
|
@ -1427,7 +1391,7 @@ sanei_pa4s2_enable (int fd, int enable)
|
|||
linux 2.2, although they seem to be inherited on linux 2.4),
|
||||
so we should make sure we get the permission */
|
||||
|
||||
if (ioperm (port[fd].base, 5, 1))
|
||||
if (sanei_ioperm (port[fd].base, 5, 1))
|
||||
{
|
||||
DBG (1, "sanei_pa4s2_enable: cannot get io privilege for port"
|
||||
" 0x%03lx\n", port[fd].base);
|
||||
|
@ -1917,7 +1881,7 @@ sanei_pa4s2_open (const char *dev, int *fd)
|
|||
DBG (3, "sanei_pa4s2_open: A4S2 support not compiled\n");
|
||||
DBG (6, "sanei_pa4s2_open: basically, this backend does only compile\n");
|
||||
DBG (6, "sanei_pa4s2_open: on x86 architectures. Furthermore it\n");
|
||||
DBG (6, "sanei_pa4s2_open: needs ioperm() and inb()/outb() calls.\n");
|
||||
DBG (6, "sanei_pa4s2_open: needs sanei_ioperm() and sanei_inb()/sanei_outb() calls.\n");
|
||||
DBG (6, "sanei_pa4s2_open: alternatively it makes use of libieee1284\n");
|
||||
DBG (6, "sanei_pa4s2_open: (which isn't present either)\n");
|
||||
DBG (5, "sanei_pa4s2_open: returning SANE_STATUS_INVAL\n");
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
*/
|
||||
|
||||
#include "../include/sane/config.h"
|
||||
#include "../include/sane/sanei_directio.h"
|
||||
/* pick up compatibility defs */
|
||||
|
||||
#define BACKEND_NAME sanei_pio
|
||||
#include "../include/sane/sanei_backend.h" /* pick up compatibility defs */
|
||||
|
@ -57,42 +59,10 @@
|
|||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_IO_H
|
||||
# include <sys/io.h> /* use where available (glibc 2.x, for example) */
|
||||
# ifndef SANE_HAVE_SYS_IO_H_WITH_INB_OUTB
|
||||
# define IO_SUPPORT_MISSING
|
||||
# endif
|
||||
#elif HAVE_ASM_IO_H
|
||||
# include <asm/io.h> /* ugly, but backwards compatible */
|
||||
#elif HAVE_SYS_HW_H
|
||||
# include <sys/hw.h>
|
||||
#elif defined(__i386__) && defined (__GNUC__)
|
||||
|
||||
static __inline__ void
|
||||
outb (u_char value, u_long port)
|
||||
{
|
||||
__asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((u_short) port));
|
||||
}
|
||||
|
||||
static __inline__ u_char
|
||||
inb (u_long port)
|
||||
{
|
||||
u_char value;
|
||||
|
||||
__asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((u_short) port));
|
||||
return value;
|
||||
}
|
||||
|
||||
#else
|
||||
# define IO_SUPPORT_MISSING
|
||||
#endif
|
||||
|
||||
#include "../include/sane/sane.h"
|
||||
#include "../include/sane/sanei.h"
|
||||
#include "../include/sane/sanei_pio.h"
|
||||
|
||||
#if defined (HAVE_IOPERM) && !defined (IO_SUPPORT_MISSING)
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
|
@ -177,7 +147,7 @@ pio_outb (const Port port, u_char val, u_long addr)
|
|||
{
|
||||
|
||||
if (-1 == port->fd)
|
||||
outb (val, addr);
|
||||
sanei_outb (addr, val);
|
||||
else
|
||||
{
|
||||
if (addr != (u_long)lseek (port->fd, addr, SEEK_SET))
|
||||
|
@ -193,7 +163,7 @@ pio_inb (const Port port, u_char * val, u_long addr)
|
|||
{
|
||||
|
||||
if (-1 == port->fd)
|
||||
*val = inb (addr);
|
||||
*val = sanei_inb (addr);
|
||||
else
|
||||
{
|
||||
if (addr != (u_long)lseek (port->fd, addr, SEEK_SET))
|
||||
|
@ -221,7 +191,7 @@ pio_wait (const Port port, u_char val, u_char mask)
|
|||
for (;;)
|
||||
{
|
||||
++poll_count;
|
||||
stat = inb (port->base + PIO_STAT);
|
||||
stat = sanei_inb (port->base + PIO_STAT);
|
||||
if ((stat & mask) == (val & mask))
|
||||
{
|
||||
DBG (DL60, "got %02x after %ld tries\n", stat, poll_count);
|
||||
|
@ -261,7 +231,7 @@ pio_ctrl (const Port port, u_char val)
|
|||
DBG (DL61, " FDXT %s\n", val & PIO_CTRL_FDXT ? "on" : "off");
|
||||
DBG (DL61, " NSTROBE %s\n", val & PIO_CTRL_NSTROBE ? "on" : "off");
|
||||
|
||||
outb (val, port->base + PIO_CTRL);
|
||||
sanei_outb (port->base + PIO_CTRL, val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -269,7 +239,7 @@ pio_ctrl (const Port port, u_char val)
|
|||
static inline void
|
||||
pio_delay (const Port port)
|
||||
{
|
||||
inb (port->base + PIO_STAT); /* delay */
|
||||
sanei_inb (port->base + PIO_STAT); /* delay */
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -290,8 +260,8 @@ pio_reset (const Port port)
|
|||
|
||||
for (n = PIO_APPLYRESET; --n >= 0;)
|
||||
{
|
||||
outb ((PIO_CTRL_IE | PIO_CTRL_NINIT) ^ PIO_CTRL_NINIT,
|
||||
port->base + PIO_CTRL);
|
||||
sanei_outb (port->base + PIO_CTRL,
|
||||
(PIO_CTRL_IE | PIO_CTRL_NINIT) ^ PIO_CTRL_NINIT);
|
||||
}
|
||||
pio_init (port);
|
||||
|
||||
|
@ -323,7 +293,7 @@ pio_write (const Port port, const u_char * buf, int n)
|
|||
#endif
|
||||
DBG (DL60, "out %02x\n", (int) *buf);
|
||||
|
||||
outb (*buf, port->base + PIO_IOPORT);
|
||||
sanei_outb (port->base + PIO_IOPORT, *buf);
|
||||
|
||||
pio_delay (port);
|
||||
pio_delay (port);
|
||||
|
@ -387,7 +357,7 @@ pio_read (const Port port, u_char * buf, int n)
|
|||
/* busynack */
|
||||
#endif
|
||||
|
||||
*buf = inb (port->base + PIO_IOPORT);
|
||||
*buf = sanei_inb (port->base + PIO_IOPORT);
|
||||
DBG (DL60, "in %02x\n", (int) *buf);
|
||||
DBG (DL40, "end read byte\n");
|
||||
}
|
||||
|
@ -465,7 +435,7 @@ pio_open (const char *dev, SANE_Status * status)
|
|||
port[n].max_time_seconds = 10;
|
||||
port[n].in_use = 1;
|
||||
|
||||
if (ioperm (port[n].base, 3, 1))
|
||||
if (sanei_ioperm (port[n].base, 3, 1))
|
||||
{
|
||||
DBG (1, "sanei_pio_open: cannot get io privilege for port 0x%03lx\n",
|
||||
port[n].base);
|
||||
|
@ -533,73 +503,3 @@ sanei_pio_write (int fd, const u_char * buf, int n)
|
|||
|
||||
return pio_write (&port[fd], buf, n);
|
||||
}
|
||||
|
||||
#else /* !HAVE_IOPERM */
|
||||
|
||||
#ifdef __BEOS__
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
SANE_Status
|
||||
sanei_pio_open (const char *dev, int *fdp)
|
||||
{
|
||||
int fp;
|
||||
|
||||
/* open internal parallel port */
|
||||
fp=open("/dev/parallel/parallel1",O_RDWR);
|
||||
|
||||
*fdp=fp;
|
||||
if(fp<0) return SANE_STATUS_INVAL;
|
||||
return(SANE_STATUS_GOOD);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sanei_pio_close (int fd)
|
||||
{
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
sanei_pio_read (int fd, u_char * buf, int n)
|
||||
{
|
||||
return(read(fd,buf,n));
|
||||
}
|
||||
|
||||
int
|
||||
sanei_pio_write (int fd, const u_char * buf, int n)
|
||||
{
|
||||
return(write(fd,buf,n));
|
||||
}
|
||||
|
||||
#else /* !__BEOS__ */
|
||||
|
||||
SANE_Status
|
||||
sanei_pio_open (const char *dev, int *fdp)
|
||||
{
|
||||
*fdp = -1;
|
||||
return SANE_STATUS_INVAL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sanei_pio_close (int fd)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
sanei_pio_read (int fd, u_char * buf, int n)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
sanei_pio_write (int fd, const u_char * buf, int n)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif /* __BEOS__ */
|
||||
|
||||
#endif /* !HAVE_IOPERM */
|
||||
|
|
|
@ -87,40 +87,7 @@
|
|||
#endif
|
||||
#if defined (ENABLE_PARPORT_DIRECTIO)
|
||||
# undef HAVE_LIBIEEE1284
|
||||
# if defined(HAVE_SYS_IO_H)
|
||||
# if defined (__ICC) && __ICC >= 700
|
||||
# define __GNUC__ 2
|
||||
# endif
|
||||
# include <sys/io.h>
|
||||
# ifndef SANE_HAVE_SYS_IO_H_WITH_INB_OUTB
|
||||
# define IO_SUPPORT_MISSING
|
||||
# endif
|
||||
# if defined (__ICC) && __ICC >= 700
|
||||
# undef __GNUC__
|
||||
# elif defined(__ICC) && defined(HAVE_ASM_IO_H)
|
||||
# include <asm/io.h>
|
||||
# endif
|
||||
# elif defined(HAVE_ASM_IO_H)
|
||||
# include <asm/io.h>
|
||||
# elif defined(HAVE_SYS_HW_H)
|
||||
# include <sys/hw.h>
|
||||
# elif defined(__i386__) && ( defined (__GNUC__) || defined (__ICC) )
|
||||
|
||||
static __inline__ void
|
||||
outb( u_char value, u_long port )
|
||||
{
|
||||
__asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((u_short) port));
|
||||
}
|
||||
|
||||
static __inline__ u_char
|
||||
inb( u_long port )
|
||||
{
|
||||
u_char value;
|
||||
|
||||
__asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((u_short) port));
|
||||
return value;
|
||||
}
|
||||
# endif
|
||||
# include "../include/sane/sanei_directio.h"
|
||||
#elif defined(HAVE_LIBIEEE1284)
|
||||
# include <ieee1284.h>
|
||||
#else
|
||||
|
@ -228,30 +195,26 @@ static inline void outb_addr(int fd, u_char val)
|
|||
|
||||
#else
|
||||
|
||||
#define inb_data(fd) inb(port[fd].base)
|
||||
#define inb_stat(fd) inb(port[fd].base + 1)
|
||||
#define inb_ctrl(fd) inb(port[fd].base + 2)
|
||||
#define inb_eppdata(fd) inb(port[fd].base + 4)
|
||||
#define inb_data(fd) sanei_inb(port[fd].base)
|
||||
#define inb_stat(fd) sanei_inb(port[fd].base + 1)
|
||||
#define inb_ctrl(fd) sanei_inb(port[fd].base + 2)
|
||||
#define inb_eppdata(fd) sanei_inb(port[fd].base + 4)
|
||||
|
||||
#define outb_data(fd,val) outb(val, port[fd].base)
|
||||
#define outb_stat(fd,val) outb(val, port[fd].base + 1)
|
||||
#define outb_ctrl(fd,val) outb(val, port[fd].base + 2)
|
||||
#define outb_addr(fd,val) outb(val, port[fd].base + 3)
|
||||
#define outb_eppdata(fd,val) outb(val, port[fd].base + 4)
|
||||
#define outb_data(fd,val) sanei_outb(port[fd].base, val)
|
||||
#define outb_stat(fd,val) sanei_outb(port[fd].base + 1, val)
|
||||
#define outb_ctrl(fd,val) sanei_outb(port[fd].base + 2, val)
|
||||
#define outb_addr(fd,val) sanei_outb(port[fd].base + 3, val)
|
||||
#define outb_eppdata(fd,val) sanei_outb(port[fd].base + 4, val)
|
||||
|
||||
#ifdef HAVE_IOPL
|
||||
# define _SET_IOPL() iopl(3)
|
||||
# define inbyte400(fd) inb(port[fd].base + 0x400)
|
||||
# define inbyte402(fd) inb(port[fd].base + 0x402)
|
||||
# define outbyte400(fd,val) outb(val, port[fd].base + 0x400)
|
||||
# define outbyte402(fd,val) outb(val, port[fd].base + 0x402)
|
||||
#else
|
||||
# define _SET_IOPL()
|
||||
# define inbyte400(fd)
|
||||
# define inbyte402(fd,val)
|
||||
# define outbyte400(fd,val)
|
||||
# define outbyte402(fd,val)
|
||||
#endif
|
||||
#define inbyte400(fd) sanei_inb(port[fd].base + 0x400)
|
||||
#define inbyte402(fd) sanei_inb(port[fd].base + 0x402)
|
||||
#define outbyte400(fd,val) sanei_outb(port[fd].base + 0x400, val)
|
||||
#define outbyte402(fd,val) sanei_outb(port[fd].base + 0x402, val)
|
||||
#endif
|
||||
|
||||
/* should also be in unistd.h */
|
||||
|
@ -848,7 +811,7 @@ pp_open( const char *dev, SANE_Status * status )
|
|||
|
||||
/* TODO: insert FreeBSD compatible code here */
|
||||
|
||||
if( ioperm( port[i].base, 5, 1 )) {
|
||||
if( sanei_ioperm( port[i].base, 5, 1 )) {
|
||||
DBG( 1, "pp_open: cannot get io privilege for port 0x%03lx\n",
|
||||
port[i].base);
|
||||
|
||||
|
@ -901,7 +864,7 @@ pp_close( int fd, SANE_Status *status )
|
|||
#if defined(HAVE_LIBIEEE1284)
|
||||
if((result = ieee1284_close(pplist.portv[fd])) < 0) {
|
||||
#else
|
||||
if( ioperm( port[fd].base, 5, 0 )) {
|
||||
if( sanei_ioperm( port[fd].base, 5, 0 )) {
|
||||
#endif
|
||||
#if defined(HAVE_LIBIEEE1284)
|
||||
DBG( 1, "pp_close: can't free port '%s' (%s)\n",
|
||||
|
@ -1328,7 +1291,7 @@ sanei_pp_open( const char *dev, int *fd )
|
|||
DBG( 3, "sanei_pp_open: support not compiled\n" );
|
||||
DBG( 6, "sanei_pp_open: basically, this backend does only compile\n" );
|
||||
DBG( 6, "sanei_pp_open: on x86 architectures. Furthermore it\n" );
|
||||
DBG( 6, "sanei_pp_open: needs ioperm() and inb()/outb() calls.\n" );
|
||||
DBG( 6, "sanei_pp_open: needs ioperm() and sanei_inb()/sanei_outb() calls.\n" );
|
||||
DBG( 6, "sanei_pp_open: alternatively it makes use of libieee1284\n" );
|
||||
DBG( 6, "sanei_pp_open: (which isn't present either)\n");
|
||||
return SANE_STATUS_INVAL;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "../include/sane/config.h"
|
||||
#include "../include/sane/sanei.h"
|
||||
#include "../include/sane/sanei_directio.h"
|
||||
|
||||
#define MUSTEK_CONF STRINGIFY(PATH_SANE_CONFIG_DIR) "/mustek.conf"
|
||||
#define PORT_DEV "/dev/port"
|
||||
|
@ -39,28 +40,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_SYS_IO_H
|
||||
# include <sys/io.h> /* use where available (glibc 2.x, for example) */
|
||||
#elif HAVE_ASM_IO_H
|
||||
# include <asm/io.h> /* ugly, but backwards compatible */
|
||||
#elif defined(__i386__) && defined (__GNUC__)
|
||||
|
||||
static __inline__ void
|
||||
outb (u_char value, u_long port)
|
||||
{
|
||||
__asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((u_short) port));
|
||||
}
|
||||
|
||||
static __inline__ u_char
|
||||
inb (u_long port)
|
||||
{
|
||||
u_char value;
|
||||
|
||||
__asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((u_short) port));
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
char *Mustek_Conf = MUSTEK_CONF;
|
||||
|
||||
int allowed_ports[] =
|
||||
|
@ -165,9 +144,9 @@ main (int argc, char **argv)
|
|||
|
||||
fprintf (stderr, "using control port address 0x%03x\n", portaddr);
|
||||
/* try to get I/O permission from the kernel */
|
||||
if (ioperm (portaddr, 1, 1) == 0)
|
||||
if (sanei_ioperm (portaddr, 1, 1) == 0)
|
||||
{
|
||||
outb (0x00, portaddr);
|
||||
sanei_outb (portaddr, 0x00);
|
||||
}
|
||||
/* else try to open /dev/port to access the I/O port */
|
||||
else if ((pfd = open (PORT_DEV, O_RDWR, 0666)) >= 0)
|
||||
|
|
Ładowanie…
Reference in New Issue