📄 parport.h
字号:
struct pardevice *cad; /* port owner */ int daisy; /* currently selected daisy addr */ int muxsel; /* currently selected mux port */ struct pardevice *waithead; struct pardevice *waittail; struct parport *next; unsigned int flags; void *sysctl_table; struct parport_device_info probe_info[5]; /* 0-3 + non-IEEE1284.3 */ struct ieee1284_info ieee1284; struct parport_operations *ops; void *private_data; /* for lowlevel driver */ int number; /* port index - the `n' in `parportn' */ spinlock_t pardevice_lock; spinlock_t waitlist_lock; rwlock_t cad_lock; int spintime; atomic_t ref_count;};#define DEFAULT_SPIN_TIME 500 /* us */struct parport_driver { const char *name; void (*attach) (struct parport *); void (*detach) (struct parport *); struct parport_driver *next;};/* parport_register_port registers a new parallel port at the given address (if one does not already exist) and returns a pointer to it. This entails claiming the I/O region, IRQ and DMA. NULL is returned if initialisation fails. */struct parport *parport_register_port(unsigned long base, int irq, int dma, struct parport_operations *ops);/* Once a registered port is ready for high-level drivers to use, the low-level driver that registered it should announce it. This will call the high-level drivers' attach() functions (after things like determining the IEEE 1284.3 topology of the port and collecting DeviceIDs). */void parport_announce_port (struct parport *port);/* Unregister a port. */extern void parport_unregister_port(struct parport *port);/* parport_enumerate returns a pointer to the linked list of all the ports in this machine. DON'T USE THIS. Use parport_register_driver instead. */struct parport *parport_enumerate(void);/* Register a new high-level driver. */extern int parport_register_driver (struct parport_driver *);/* Unregister a high-level driver. */extern void parport_unregister_driver (struct parport_driver *);/* If parport_register_driver doesn't fit your needs, perhaps * parport_find_xxx does. */extern struct parport *parport_find_number (int);extern struct parport *parport_find_base (unsigned long);/* Reference counting for ports. */extern struct parport *parport_get_port (struct parport *);extern void parport_put_port (struct parport *);/* parport_register_device declares that a device is connected to a port, and tells the kernel all it needs to know. - pf is the preemption function (may be NULL for no callback) - kf is the wake-up function (may be NULL for no callback) - irq_func is the interrupt handler (may be NULL for no interrupts) - handle is a user pointer that gets handed to callback functions. */struct pardevice *parport_register_device(struct parport *port, const char *name, int (*pf)(void *), void (*kf)(void *), void (*irq_func)(int, void *, struct pt_regs *), int flags, void *handle);/* parport_unregister unlinks a device from the chain. */extern void parport_unregister_device(struct pardevice *dev);/* parport_claim tries to gain ownership of the port for a particular driver. This may fail (return non-zero) if another driver is busy. If this driver has registered an interrupt handler, it will be enabled. */extern int parport_claim(struct pardevice *dev);/* parport_claim_or_block is the same, but sleeps if the port cannot be claimed. Return value is 1 if it slept, 0 normally and -errno on error. */extern int parport_claim_or_block(struct pardevice *dev);/* parport_release reverses a previous parport_claim. This can never fail, though the effects are undefined (except that they are bad) if you didn't previously own the port. Once you have released the port you should make sure that neither your code nor the hardware on the port tries to initiate any communication without first re-claiming the port. If you mess with the port state (enabling ECP for example) you should clean up before releasing the port. */extern void parport_release(struct pardevice *dev);/** * parport_yield - relinquish a parallel port temporarily * @dev: a device on the parallel port * * This function relinquishes the port if it would be helpful to other * drivers to do so. Afterwards it tries to reclaim the port using * parport_claim(), and the return value is the same as for * parport_claim(). If it fails, the port is left unclaimed and it is * the driver's responsibility to reclaim the port. * * The parport_yield() and parport_yield_blocking() functions are for * marking points in the driver at which other drivers may claim the * port and use their devices. Yielding the port is similar to * releasing it and reclaiming it, but is more efficient because no * action is taken if there are no other devices needing the port. In * fact, nothing is done even if there are other devices waiting but * the current device is still within its "timeslice". The default * timeslice is half a second, but it can be adjusted via the /proc * interface. **/static __inline__ int parport_yield(struct pardevice *dev){ unsigned long int timeslip = (jiffies - dev->time); if ((dev->port->waithead == NULL) || (timeslip < dev->timeslice)) return 0; parport_release(dev); return parport_claim(dev);}/** * parport_yield_blocking - relinquish a parallel port temporarily * @dev: a device on the parallel port * * This function relinquishes the port if it would be helpful to other * drivers to do so. Afterwards it tries to reclaim the port using * parport_claim_or_block(), and the return value is the same as for * parport_claim_or_block(). **/static __inline__ int parport_yield_blocking(struct pardevice *dev){ unsigned long int timeslip = (jiffies - dev->time); if ((dev->port->waithead == NULL) || (timeslip < dev->timeslice)) return 0; parport_release(dev); return parport_claim_or_block(dev);}/* Flags used to identify what a device does. */#define PARPORT_DEV_TRAN 0 /* WARNING !! DEPRECATED !! */#define PARPORT_DEV_LURK (1<<0) /* WARNING !! DEPRECATED !! */#define PARPORT_DEV_EXCL (1<<1) /* Need exclusive access. */#define PARPORT_FLAG_EXCL (1<<1) /* EXCL driver registered. */extern int parport_parse_irqs(int, const char *[], int irqval[]);extern int parport_parse_dmas(int, const char *[], int dmaval[]);/* IEEE1284 functions */extern void parport_ieee1284_interrupt (int, void *, struct pt_regs *);extern int parport_negotiate (struct parport *, int mode);extern ssize_t parport_write (struct parport *, const void *buf, size_t len);extern ssize_t parport_read (struct parport *, void *buf, size_t len);#define PARPORT_INACTIVITY_O_NONBLOCK 1extern long parport_set_timeout (struct pardevice *, long inactivity);extern int parport_wait_event (struct parport *, long timeout);extern int parport_wait_peripheral (struct parport *port, unsigned char mask, unsigned char val);extern int parport_poll_peripheral (struct parport *port, unsigned char mask, unsigned char val, int usec);/* For architectural drivers */extern void parport_ieee1284_wakeup (struct parport *port);extern size_t parport_ieee1284_write_compat (struct parport *, const void *, size_t, int);extern size_t parport_ieee1284_read_nibble (struct parport *, void *, size_t, int);extern size_t parport_ieee1284_read_byte (struct parport *, void *, size_t, int);extern size_t parport_ieee1284_ecp_read_data (struct parport *, void *, size_t, int);extern size_t parport_ieee1284_ecp_write_data (struct parport *, const void *, size_t, int);extern size_t parport_ieee1284_ecp_write_addr (struct parport *, const void *, size_t, int);extern size_t parport_ieee1284_epp_write_data (struct parport *, const void *, size_t, int);extern size_t parport_ieee1284_epp_read_data (struct parport *, void *, size_t, int);extern size_t parport_ieee1284_epp_write_addr (struct parport *, const void *, size_t, int);extern size_t parport_ieee1284_epp_read_addr (struct parport *, void *, size_t, int);/* IEEE1284.3 functions */extern int parport_daisy_init (struct parport *port);extern void parport_daisy_fini (struct parport *port);extern struct pardevice *parport_open (int devnum, const char *name, int (*pf) (void *), void (*kf) (void *), void (*irqf) (int, void *, struct pt_regs *), int flags, void *handle);extern void parport_close (struct pardevice *dev);extern ssize_t parport_device_id (int devnum, char *buffer, size_t len);extern int parport_device_num (int parport, int mux, int daisy);extern int parport_device_coords (int devnum, int *parport, int *mux, int *daisy);extern void parport_daisy_deselect_all (struct parport *port);extern int parport_daisy_select (struct parport *port, int daisy, int mode);/* For finding devices based on their device ID. Example usage: int devnum = -1; while ((devnum = parport_find_class (PARPORT_CLASS_DIGCAM, devnum)) != -1) { struct pardevice *dev = parport_open (devnum, ...); ... }*/extern int parport_find_device (const char *mfg, const char *mdl, int from);extern int parport_find_class (parport_device_class cls, int from);/* Lowlevel drivers _can_ call this support function to handle irqs. */static __inline__ void parport_generic_irq(int irq, struct parport *port, struct pt_regs *regs){ parport_ieee1284_interrupt (irq, port, regs); read_lock(&port->cad_lock); if (port->cad && port->cad->irq_func) port->cad->irq_func(irq, port->cad->private, regs); read_unlock(&port->cad_lock);}/* Prototypes from parport_procfs */extern int parport_proc_register(struct parport *pp);extern int parport_proc_unregister(struct parport *pp);extern int parport_device_proc_register(struct pardevice *device);extern int parport_device_proc_unregister(struct pardevice *device);extern int parport_default_proc_register(void);extern int parport_default_proc_unregister(void);extern void dec_parport_count(void);extern void inc_parport_count(void);/* If PC hardware is the only type supported, we can optimise a bit. */#if (defined(CONFIG_PARPORT_PC) || defined(CONFIG_PARPORT_PC_MODULE)) && !(defined(CONFIG_PARPORT_ARC) || defined(CONFIG_PARPORT_ARC_MODULE)) && !(defined(CONFIG_PARPORT_AMIGA) || defined(CONFIG_PARPORT_AMIGA_MODULE)) && !(defined(CONFIG_PARPORT_MFC3) || defined(CONFIG_PARPORT_MFC3_MODULE)) && !(defined(CONFIG_PARPORT_ATARI) || defined(CONFIG_PARPORT_ATARI_MODULE)) && !(defined(CONFIG_USB_USS720) || defined(CONFIG_USB_USS720_MODULE)) && !(defined(CONFIG_PARPORT_SUNBPP) || defined(CONFIG_PARPORT_SUNBPP_MODULE)) && !defined(CONFIG_PARPORT_OTHER)#undef PARPORT_NEED_GENERIC_OPS#include <linux/parport_pc.h>#define parport_write_data(p,x) parport_pc_write_data(p,x)#define parport_read_data(p) parport_pc_read_data(p)#define parport_write_control(p,x) parport_pc_write_control(p,x)#define parport_read_control(p) parport_pc_read_control(p)#define parport_frob_control(p,m,v) parport_pc_frob_control(p,m,v)#define parport_read_status(p) parport_pc_read_status(p)#define parport_enable_irq(p) parport_pc_enable_irq(p)#define parport_disable_irq(p) parport_pc_disable_irq(p)#define parport_data_forward(p) parport_pc_data_forward(p)#define parport_data_reverse(p) parport_pc_data_reverse(p)#endif#ifdef PARPORT_NEED_GENERIC_OPS/* Generic operations vector through the dispatch table. */#define parport_write_data(p,x) (p)->ops->write_data(p,x)#define parport_read_data(p) (p)->ops->read_data(p)#define parport_write_control(p,x) (p)->ops->write_control(p,x)#define parport_read_control(p) (p)->ops->read_control(p)#define parport_frob_control(p,m,v) (p)->ops->frob_control(p,m,v)#define parport_read_status(p) (p)->ops->read_status(p)#define parport_enable_irq(p) (p)->ops->enable_irq(p)#define parport_disable_irq(p) (p)->ops->disable_irq(p)#define parport_data_forward(p) (p)->ops->data_forward(p)#define parport_data_reverse(p) (p)->ops->data_reverse(p)#endif#endif /* __KERNEL__ */#endif /* _PARPORT_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -