[PARPORT] Re: parport documentation!


Tim Waugh (tim@cyberelk.demon.co.uk)
Sat, 1 May 1999 23:08:57 +0100 (GMT)


Wait, there's more. ;-)

PARPORT interface documentation
-------------------------------

Described here are the following functions:

Global functions:
  parport_register_driver
  parport_unregister_driver
  parport_enumerate
  parport_register_device
  parport_unregister_device
  parport_claim
  parport_claim_or_block
  parport_release
  parport_yield
  parport_yield_blocking
  parport_wait_peripheral
  parport_wait_event
  parport_negotiate (*)
  parport_read (*)
  parport_write (*)
  parport_open (*)
  parport_close (*)
  parport_device_id (*)
  parport_device_coords (*)
  parport_device_num (*)
  parport_find_device (*)
  parport_find_class (*)
  parport_set_timeout (*)

Port functions (can be overridden by low-level drivers):
  SPP:
    port->ops->read_data
    port->ops->write_data
    port->ops->read_status
    port->ops->write_status
    port->ops->read_control
    port->ops->write_control
    port->ops->frob_control
    port->ops->enable_irq
    port->ops->disable_irq

  EPP:
    port->ops->epp_write_data
    port->ops->epp_read_data
    port->ops->epp_write_addr
    port->ops->epp_read_addr

  ECP:
    port->ops->read_econtrol (?)
    port->ops->write_econtrol (?)
    port->ops->frob_econtrol (?)
    port->ops->ecp_write_data
    port->ops->ecp_read_data
    port->ops->ecp_write_addr

  Other:
    port->ops->nibble_read_data (*)
    port->ops->byte_read_data (*)
    port->ops->compat_write_data (*)
    port->ops->change_mode
    port->ops->get_fifo_residue
    port->ops->fudge (*)

(*) - no documentation yet
(?) - is this actually needed?

The parport subsystem comprises 'parport' (the core port-sharing
code), and a variety of low-level drivers that actually do the port
accesses. Each low-level driver handles a particular style of port
(PC, Amiga, and so on).

The parport interface to the device driver author can be broken down
into global functions and port functions.

The global functions are mostly for communicating between the device
driver and the parport subsystem: acquiring a list of available ports,
claiming a port for exclusive use, and so on. They also include
'generic' functions for doing standard things that will work on any
IEEE 1284-capable architecture.

The port functions are provided by the low-level drivers, although the
core parport module provides generic 'defaults' for some routines.
The port functions can be split into three groups: SPP, EPP, and ECP.

SPP (Standard Parallel Port) functions modify so-called 'SPP'
registers: data, status, and control. The hardware may not actually
have registers exactly like that, but the PC does and this interface is
modelled after common PC implementations.

EPP (Enhanced Parallel Port) functions are provided for reading and
writing in IEEE 1284 EPP mode. This is again modelled after common
implementations, where writing to a particular port initiates an EPP
write cycle (and actually halts the processor for the duration!), and
a timeout bit is set if the peripheral didn't respond in a timely
fashion.

ECP (Extended Capabilities Port) functions are used for IEEE 1284 ECP
mode. A common implementation for this uses a FIFO. Consequently,
read/write functions for ECP are for blocks of data, and they return
the number of bytes read or written; there are also functions for
ensuring data is not lost when the FIFO has data that the peripheral
is not willing to accept. It is also common for ECP-aware chipsets to
have a special control register for ECP (called ECR, extended
control), and functions are provided for manipulating it. (Should they
be?)

Hardware assistance for EPP and/or ECP transfers may or may not be
available, and if it is available it may or may not be used. If
hardware is not used, the transfer will be software-driven. In order
to cope with peripherals that only tenuously support IEEE 1284, a
low-level driver specific function is provided, for altering 'fudge
factors'.

GLOBAL FUNCTIONS
----------------

parport_register_driver - register a device driver with parport
-----------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_driver {
        const char *name;
        void (*attach) (struct parport *);
        void (*detach) (struct parport *);
        struct parport_driver *next;
};
int parport_register_driver (struct parport_driver *driver);

DESCRIPTION

In order to be notified about parallel ports when they are detected,
parport_register_driver should be called. Your driver will
immediately be notified of all ports that have already been detected,
and of each new port as low-level drivers are loaded.

A 'struct parport_driver' contains the textual name of your driver,
a pointer to a function to handle new ports, and a pointer to a
function to handle ports going away due to a low-level driver
unloading. Ports will only be detached if they are not being used
(i.e. there are no devices registered on them).

The visible parts of the 'struct parport *' argument given to
attach/detach are:

struct parport
{
        struct parport *next; /* next parport in list */
        struct parport *prev; /* previous parport in list */
        const char *name; /* port's name */
        unsigned int modes; /* bitfield of supported modes */
        struct parport_device_info probe_info; /* IEEE1284 info */
        int number; /* parport index */
        struct parport_operations *ops;
        ...
};

There are other members of the structure, but they should not be
touched. Supported modes (these may be bitwise-ored together in
'modes') are:

  PARPORT_MODE_PCSPP
  PARPORT_MODE_PCPS2
  PARPORT_MODE_PCEPP
  PARPORT_MODE_PCECP
  PARPORT_MODE_PCECPEPP
  PARPORT_MODE_PCECR (this just means an ECR is present)
  PARPORT_MODE_PCECPPS2

RETURN VALUE

Zero on success, otherwise an error code.

ERRORS

None. (Can it fail? Why return int?)

EXAMPLE

static void lp_attach (struct parport *port)
{
        ...
        private = kmalloc (...);
        dev[count++] = parport_register_device (...);
        ...
}

static void lp_detach (struct parport *port)
{
        ...
}

static struct parport_driver lp_driver = {
        "lp",
        lp_attach,
        lp_detach,
        NULL /* always put NULL here */
};

int lp_init (void)
{
        ...
        if (parport_register_driver (&lp_driver)) {
                /* Failed; nothing we can do. */
                return -EIO;
        }
        ...
}

SEE ALSO

parport_unregister_driver, parport_register_device, parport_enumerate

parport_unregister_driver - tell parport to forget about this driver
-------------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_driver {
        const char *name;
        void (*attach) (struct parport *);
        void (*detach) (struct parport *);
        struct parport_driver *next;
};
void parport_unregister_driver (struct parport_driver *driver);

DESCRIPTION

This tells parport not to notify the device driver of new ports or of
ports going away. Registered devices belonging to that driver are NOT
unregistered: parport_unregister_device must be used for each one.

EXAMPLE

void cleanup_module (void)
{
        ...
        /* Stop notifications. */
        parport_unregister_driver (&lp_driver);

        /* Unregister devices. */
        for (i = 0; i < NUM_DEVS; i++)
                parport_unregister_device (dev[i]);
        ...
}

SEE ALSO

parport_register_driver, parport_enumerate

parport_enumerate - retrieve a list of parallel ports (DEPRECATED)
-----------------

SYNOPSIS

#include <linux/parport.h>

struct parport *parport_enumerate (void);

DESCRIPTION

Retrieve the first of a list of valid parallel ports for this machine.
Successive parallel ports can be found using the 'struct parport
*next' element of the 'struct parport *' that is returned. If 'next'
is NULL, there are no more parallel ports in the list. The number of
ports in the list will not exceed PARPORT_MAX.

The returned structure contains the following fields (and others not
pictured):

struct parport
{
        struct parport *next; /* next parport in list */
        struct parport *prev; /* previous parport in list */
        const char *name; /* port's name */
        unsigned int modes; /* bitfield of supported modes */
        struct parport_device_info probe_info; /* IEEE1284 info */
        int number; /* parport index */
        ...
};

RETURN VALUE

A 'struct parport *' describing a valid parallel port for the machine,
or NULL if there are none.

ERRORS

This function can return NULL to indicate that there are no parallel
ports to use.

EXAMPLE

int detect_device (void)
{
        struct parport *port;

        for (port = parport_enumerate ();
             port != NULL;
             port = port->next) {
                /* Try to detect a device on the port... */
                ...
             }
        }

        ...
}

NOTES

parport_enumerate is deprecated; parport_register_driver should be
used instead.

SEE ALSO

parport_register_driver, parport_unregister_driver

parport_register_device - register to use a port
-----------------------

SYNOPSIS

#include <linux/parport.h>

typedef int (*preempt_func) (void *handle);
typedef void (*wakeup_func) (void *handle);
typedef int (*irq_func) (int irq, void *handle, struct pt_regs *);

struct pardevice *parport_register_device(struct parport *port,
                                          const char *name,
                                          preempt_func preempt,
                                          wakeup_func wakeup,
                                          irq_func irq,
                                          int flags,
                                          void *handle);

DESCRIPTION

Use this function to register your device driver on a parallel port
('port'). Once you have done that, you will be able to use
parport_claim and parport_release in order to use the port.

This function will register three callbacks into your driver:
'preempt', 'wakeup' and 'irq'. Each of these may be NULL in order to
indicate that you do not want a callback.

When the 'preempt' function is called, it is because another driver
wishes to use the parallel port. The 'preempt' function should return
non-zero if the parallel port cannot be released yet -- if zero is
returned, the port is lost to another driver and the port must be
re-claimed before use.

The 'wakeup' function is called once another driver has released the
port and no other driver has yet claimed it. You can claim the
parallel port from within the 'wakeup' function (in which case the
claim is guaranteed to succeed), or choose not to if you don't need it
now.

If an interrupt occurs on the parallel port your driver has claimed,
the 'irq' function will be called. (Write something about shared
interrupts here.)

The 'handle' is a pointer to driver-specific data, and is passed to
the callback functions.

'flags' may be a bitwise combination of the following flags:

        Flag Meaning
  PARPORT_DEV_EXCL The device cannot share the parallel port at all.
                    Use this only when absolutely necessary.

The typedefs are not actually defined -- they are only shown in order
to make the function prototype more readable.

The visible parts of the returned 'struct pardevice' are:

struct pardevice {
        struct parport *port; /* Associated port */
        void *private; /* Device driver's 'handle' */
        ...
};

RETURN VALUE

A 'struct pardevice *': a handle to the registered parallel port
device that can be used for parport_claim, parport_release, etc.

ERRORS

A return value of NULL indicates that there was a problem registering
a device on that port.

EXAMPLE

static int preempt (void *handle)
{
        if (busy_right_now)
                return 1;

        must_reclaim_port = 1;
        return 0;
}

static void wakeup (void *handle)
{
        struct toaster *private = handle;
        struct pardevice *dev = private->dev;
        if (!dev) return; /* avoid races */

        if (want_port)
                parport_claim (dev);
}

static int toaster_detect (struct toaster *private, struct parport *port)
{
        private->dev = parport_register_device (port, "toaster", preempt,
                                                wakeup, NULL, 0,
                                                private);
        if (!private->dev)
                /* Couldn't register with parport. */
                return -EIO;

        must_reclaim_port = 0;
        busy_right_now = 1;
        parport_claim_or_block (private->dev);
        ...
        /* Don't need the port while the toaster warms up. */
        busy_right_now = 0;
        ...
        busy_right_now = 1;
        if (must_reclaim_port) {
                parport_claim_or_block (private->dev);
                must_reclaim_port = 0;
        }
        ...
}

SEE ALSO

parport_unregister_device, parport_claim

parport_unregister_device - finish using a port
-------------------------

SYNPOPSIS

#include <linux/parport.h>

void parport_unregister_device (struct pardevice *dev);

DESCRIPTION

This function is the opposite of parport_register_device. After using
parport_unregister_device, 'dev' is no longer a valid device handle.

You should not unregister a device that is currently claimed, although
if you do it will be released automatically.

EXAMPLE

        ...
        kfree (dev->private); /* before we lose the pointer */
        parport_unregister_device (dev);
        ...

SEE ALSO

parport_unregister_driver

parport_claim, parport_claim_or_block - claim the parallel port for a device
-------------------------------------

SYNOPSIS

#include <linux/parport.h>

int parport_claim (struct pardevice *dev);
int parport_claim_or_block (struct pardevice *dev);

DESCRIPTION

These functions attempt to gain control of the parallel port on which
'dev' is registered. 'parport_claim' does not block, but
'parport_claim_or_block' may do.

You should not try to claim a port that you have already claimed.

RETURN VALUE

A return value of zero indicates that the port was successfully
claimed, and the caller now has possession of the parallel port.

If 'parport_claim_or_block' blocks before returning successfully, the
return value is positive.

ERRORS

  -EAGAIN The port is unavailable at the moment, but another attempt
           to claim it may succeed.

SEE ALSO

parport_release

parport_release - release the parallel port
---------------

SYNOPSIS

#include <linux/parport.h>

void parport_release (struct pardevice *dev);

DESCRIPTION

Once a parallel port device has been claimed, it can be released using
'parport_release'. It cannot fail, but you should not release a
device that you do not have possession of.

Prior to calling parport_release or parport_yield, the port _must_ be
in SPP or PS2 mode: if you have called change_mode to switch to any
other mode, you must switch back before releasing the port.

EXAMPLE

static size_t write (struct pardevice *dev, const void *buf,
                     size_t len)
{
        ...
        dev->port->ops->change_mode (dev->port, PARPORT_MODE_PCECP);
        written = dev->port->ops->write_ecp_data (dev->port, buf,
                                                  len);

        /* Release the port. */
        switch (dev->port->ops->change_mode (dev->port,
                                             PARPORT_MODE_PCPS2)) {
        case -EBUSY:
                /* Adjust for bytes not transmitted. */
                written -= dev->port->ops->get_fifo_residue (dev->port);
                break;
        }
        parport_release (dev);
        ...
}

SEE ALSO

change_mode, parport_claim, parport_claim_or_block, parport_yield

parport_yield, parport_yield_blocking - temporarily release a parallel port
-------------------------------------

SYNOPSIS

#include <linux/parport.h>

int parport_yield (struct pardevice *dev)
int parport_yield_blocking (struct pardevice *dev);

DESCRIPTION

When a driver has control of a parallel port, it may allow another
driver to temporarily 'borrow' it. 'parport_yield' does not block;
'parport_yield_blocking' may do.

Before yielding the port, it must be left in SPP or PS2 mode. See
parport_release.

RETURN VALUE

A return value of zero indicates that the caller still owns the port
and the call did not block.

A positive return value from 'parport_yield_blocking' indicates that
the caller still owns the port and the call blocked.

A return value of -EAGAIN indicates that the caller no longer owns the
port, and it must be re-claimed before use.

ERRORS

  -EAGAIN Ownership of the parallel port was given away.

SEE ALSO

parport_release

PORT FUNCTIONS
--------------

The functions in the port->ops structure (struct parport_operations)
are provided by the low-level driver responsible for that port.

port->ops->read_data - read the data register
--------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        unsigned char (*read_data) (struct parport *port);
        ...
};

DESCRIPTION

In PARPORT_MODE_PCPS2, this returns the value on the data pins. In
all other modes, the return value is undefined (but may be the last
value written).

SEE ALSO

write_data, read_status, write_control

port->ops->write_data - write the data register
---------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        void (*write_data) (struct parport *port, unsigned char d);
        ...
};

DESCRIPTION

Writes to the data register. May have side-effects (a STROBE pulse,
for instance).

SEE ALSO

read_data, read_status, write_control

port->ops->read_status - read the status register
----------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        unsigned char (*read_status) (struct parport *port);
        ...
};

DESCRIPTION

Reads from the status register. This is a bitmask:

- PARPORT_STATUS_ERROR (printer fault, "nFault")
- PARPORT_STATUS_SELECT (on-line, "Select")
- PARPORT_STATUS_PAPEROUT (no paper, "PError")
- PARPORT_STATUS_ACK (handshake, "nAck")
- PARPORT_STATUS_BUSY (busy, "Busy")

There may be other bits set.

SEE ALSO

read_data, write_data, write_control

port->ops->write_status - write the status register
-----------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        void (*write_status) (struct parport *port, unsigned char s);
        ...
};

DESCRIPTION

Writes to the status register. This may or may not have any effect,
depending on the hardware.

SEE ALSO

read_data, write_data, read_status, write_control

port->ops->read_control - read the control register
-----------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        unsigned char (*read_control) (struct parport *port);
        ...
};

DESCRIPTION

Reads from the control register. Some ports don't allow this, so
there is no guarantee of the return value.

SEE ALSO

read_data, write_data, read_status, write_control

port->ops->write_control - write the control register
------------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        void (*write_status) (struct parport *port, unsigned char s);
        ...
};

DESCRIPTION

Writes to the control register. This is a bitmask:
                          _______
- PARPORT_CONTROL_STROBE (nStrobe)
                          _______
- PARPORT_CONTROL_AUTOFD (nAutoFd)
                        _____
- PARPORT_CONTROL_INIT (nInit)
                          _________
- PARPORT_CONTROL_SELECT (nSelectIn)
- PARPORT_CONTROL_INTEN (parallel port interrupts enabled: this is
  equivalent to enable/disable_irq)
- PARPORT_CONTROL_DIRECTION (if set, data lines are tristated: this is
  equivalent to change_mode (PARPORT_MODE_PCPS2)

SEE ALSO

read_data, write_data, read_status, frob_control

port->ops->frob_control - write control register bits
-----------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        void (*frob_control) (struct parport *port,
                              unsigned char mask,
                              unsigned char val);
        ...
};

DESCRIPTION

This is equivalent to reading from the control register, masking out
the bits in mask, exclusive-or'ing with the bits in val, and writing
the result to the control register.

As some ports don't allow reads from the control port, a software copy
of its contents is maintained, so frob_control is in fact only one
port access.

SEE ALSO

read_data, write_data, read_status, write_control

port->ops->enable_irq - enable interrupt generation
---------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        void (*enable_irq) (struct parport *port);
        ...
};

DESCRIPTION

The parallel port hardware is instructed to generate interrupts at
appropriate moments, although those moments are
architecture-specific. For the PC architecture, interrupts are
commonly generated on the rising edge of nAck.

SEE ALSO

disable_irq

port->ops->disable_irq - disable interrupt generation
----------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        void (*disable_irq) (struct parport *port);
        ...
};

DESCRIPTION

The parallel port hardware is instructed not to generate interrupts.
The interrupt itself is not masked.

SEE ALSO

enable_irq

port->ops->epp_write_data - write EPP data
-------------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        size_t (*epp_write_data) (struct parport *port, const void *buf,
                                  size_t len);
        ...
};

DESCRIPTION

Writes data in EPP mode, and returns the number of bytes written.

SEE ALSO

epp_read_data, epp_write_addr, epp_read_addr

port->ops->epp_read_data - read EPP data
------------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        size_t (*epp_read_data) (struct parport *port, void *buf,
                                 size_t len);
        ...
};

DESCRIPTION

Reads data in EPP mode, and returns the number of bytes read.

SEE ALSO

epp_write_data, epp_write_addr, epp_read_addr

port->ops->epp_write_addr - write EPP address
-------------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        size_t (*epp_write_addr) (struct parport *port,
                                  const void *buf, size_t len);
        ...
};

DESCRIPTION

Writes EPP addresses (8 bits each), and returns the number written.

SEE ALSO

epp_write_data, epp_read_data, epp_read_addr

port->ops->epp_read_addr - read EPP address
------------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        size_t (*epp_read_addr) (struct parport *port, void *buf,
                                 size_t len);
        ...
};

DESCRIPTION

Reads EPP addresses (8 bits each), and returns the number read.

SEE ALSO

epp_write_data, epp_read_data, epp_write_addr

port->ops->read_econtrol - read the extended control register
------------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        unsigned char (*read_econtrol) (struct parport *port);
        ...
};

DESCRIPTION

Read from the extended control register. If the PARPORT_MODE_PCECR
bit is not set in port->modes, the acts of reading from and writing to
the non-existent extended control register are undefined, although the
control register may alias to the extended control register.

If the PARPORT_MODE_PCECR bit is set in port->modes, the ECR looks
like this:

Bits 7:5 Mode
Bit 4 nErrIntrEn: disable interrupt generated on the
                asserting edge of nFault.
Bit 3 dmaEn: enable DMA.
Bit 2 serviceIntr
Bit 1 FIFO full
Bit 0 FIFO empty


port->ops->write_econtrol - write the extended control register
-------------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        unsigned char (*read_econtrol) (struct parport *port);
        ...
};

DESCRIPTION

Reads from the extended control register, if there is one.


port->ops->frob_econtrol - write extended control register bits
------------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        void (*frob_econtrol) (struct parport *port,
                               unsigned char mask,
                               unsigned char val);
        ...
};

DESCRIPTION

Writes bits to the extended control register, if there is one.

SEE ALSO

parport_frob_control

port->ops->ecp_write_data - write a block of ECP data
-------------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        size_t (*ecp_write_data) (struct parport *port,
                                  const void *buf, size_t len);
        ...
};

DESCRIPTION

Writes a block of ECP data.

RETURN VALUE

The number of bytes written. NB. Although written, they may be in a
FIFO, in which case they have not necessarily reached the peripheral
yet.

NOTES

This may use a FIFO, so if change_mode fails you should call
get_fifo_residue.

SEE ALSO

change_mode, get_fifo_residue

port->ops->ecp_read_data - read a block of ECP data
------------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        size_t (*ecp_read_block) (struct parport *port,
                                  void *buf, size_t len);
        ...
};

DESCRIPTION

Reads a block of ECP data.

RETURN VALUE

The number of bytes read. NB. There may be more unread data in a
FIFO. Is there a way of stunning the FIFO to prevent this?

NOTES

This may use a FIFO, so if change_mode fails you should call
get_fifo_residue.

SEE ALSO

change_mode, get_fifo_residue

port->ops->ecp_write_addr - write a block of ECP addresses
-------------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        size_t (*ecp_write_addr) (struct parport *port,
                                  const void *buf, size_t len);
        ...
};

DESCRIPTION

Writes a block of ECP addresses.

RETURN VALUE

The number of bytes written. NB. Although written, they may be in a
FIFO, in which case they have not necessarily reached the peripheral
yet.

NOTES

This may use a FIFO, so if change_mode fails you should call
get_fifo_residue.

SEE ALSO

change_mode, get_fifo_residue

port->ops->change_mode - change to a particular mode
----------------------

SYNOPSIS

#include <linux/parport.h>

struct parport_operations {
        ...
        int (*change_mode) (struct parport *port, int mode);
        ...
};

DESCRIPTION

Some parallel port registers can only be accessed in certain 'modes'.
Chipsets with an ECR (extended control) register have a concept of a
current 'mode', which is encoded in the top three bits of ECR. In
modes where a FIFO may be involved (ECP-related ones), care has to be
taken in order to switch between modes to ensure that data doesn't get
lost. The change_mode function (port->ops->change_mode) does its best
to make sure that no data is lost; it should always be used, in case
there is an ECR register.

Valid modes include:
 - PARPORT_MODE_PCSPP (write_data, read_status, write_control)
 - PARPORT_MODE_PCPS2 (PCSPP + read_data)
 - PARPORT_MODE_PCECP (all ECP functions)
 - PARPORT_MODE_PCEPP (for ECP+EPP?)

To use ecp_write_data etc., the port must be set to mode
PARPORT_MODE_PCECP first.

Before setting the PARPORT_CONTROL_DIRECTION bit in the control
register, the port must be set to mode PARPORT_MODE_PCPS2.

RETURN VALUE

Zero on success, negative on failure.

ERRORS

  -EINVAL Unrecognised mode

  -EBUSY Couldn't change mode without losing data. This normally
                means that the FIFO has data in, and changing mode
                will reset it. Use get_fifo_residue.

SEE ALSO

port->ops->get_fifo_residue

port->ops->get_fifo_residue - find out how many bytes are lost in FIFO
---------------------------

SYNOPSYS

#include <linux/parport.h>

struct parport_operations {
       ...
       int get_fifo_residue (struct parport *port);
       ...
};

DESCRIPTION

If there is no FIFO present, the return value is 0 and there are no
other effects.

Otherwise, transfers are stopped. The FIFO is filled to find out how
many PWords it originally contained, and then reset by setting the
mode to 001. The return value is the number of bytes that were not
transmitted, computed using the number of available PWord slots in the
FIFO and accounting for a potential partial PWord, plus a potential
byte in the transceiver.

RETURNS

The number of bytes not transmitted.

SEE ALSO

change_mode

-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --



This archive was generated by hypermail 2.0b3 on Sat 01 May 1999 - 18:09:40 EDT