sanei: Reuse sanei_directio in sanei_ab306

merge-requests/521/head
Thierry HUCHARD 2021-12-15 22:36:56 +02:00 zatwierdzone przez Povilas Kanapickas
rodzic db83d55495
commit 79e470cf9a
2 zmienionych plików z 9 dodań i 34 usunięć

Wyświetl plik

@ -1243,6 +1243,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?

Wyświetl plik

@ -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;
}
}