📄 dactron.h
字号:
#define MODULE#define __KERNEL__#include <linux/fs.h>#include <linux/usb.h>#include <linux/slab.h>#include <linux/init.h>#include <linux/errno.h>#include <linux/delay.h>#include <linux/sched.h>#include <linux/ioctl.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/devfs_fs_kernel.h>#include <asm/uaccess.h>#define DACT_MAX_MNR 16#define DACT_BASE_MNR 144#define IS_EP_BULK(ep) ((ep).bmAttributes == USB_ENDPOINT_XFER_BULK ? 1 : 0)#define IS_EP_BULK_IN(ep) (IS_EP_BULK(ep) && ((ep).bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)#define IS_EP_BULK_OUT(ep) (IS_EP_BULK(ep) && ((ep).bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT)#define IS_EP_INTR(ep) ((ep).bmAttributes == USB_ENDPOINT_XFER_INT ? 1 : 0)#define USB_DACT_MINOR(X) MINOR((X)->i_rdev) - DACT_BASE_MNR#define IBUF_SIZE 32768#define OBUF_SIZE 4096#define RD_NAK_TIMEOUT (10*HZ) /* Default number of X seconds to wait */#define RD_EXPIRE 12 /* Number of attempts to wait X seconds */extern devfs_handle_t usb_devfs_handle_dactron;static DECLARE_MUTEX (dactron_mutex); /* Initializes to unlocked */struct usb_device;struct usb_dactron_data{ struct usb_device *dact_dev; devfs_handle_t devfs; unsigned int ifnum; kdev_t dact_minor; unsigned char button; char isopen; char present; char *obuf, *ibuf; char bulk_in_ep[3]; char bulk_out_ep[3]; wait_queue_head_t rd_wait_q; struct semaphore sem; unsigned int rd_nak_timeout;};static struct usb_dactron_data *p_table[ DACT_MAX_MNR ] = { NULL, /* ... */ };static struct usb_device_id dactron_device_ids[] = { { USB_DEVICE( 0x547, 0x2131 )}, { USB_DEVICE( 0x547, 0x9999 )}, { },};#define CPUCS_REG 0x7F92#define MAX_INTEL_HEX_RECORD_LENGTH 16/* read vendor and product IDs from the dactron */#define DACTRON_IOCTL_VENDOR _IOR('U', 0x20, int)#define DACTRON_IOCTL_PRODUCT _IOR('U', 0x21, int)/* send/recv a control message to the dactron */#define DACTRON_IOCTL_CTRLMSG _IOWR('U', 0x22, devrequest )typedef struct _INTEL_HEX_RECORD{ unsigned char Length; unsigned short Address; unsigned char Type; unsigned char Data[MAX_INTEL_HEX_RECORD_LENGTH];} INTEL_HEX_RECORD, *PINTEL_HEX_RECORD;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -