Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #ifndef __USBHID_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #define __USBHID_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *  Copyright (c) 1999 Andreas Gal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *  Copyright (c) 2000-2001 Vojtech Pavlik
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  *  Copyright (c) 2006 Jiri Kosina
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /*  API provided by hid-core.c for USB HID drivers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) void usbhid_init_reports(struct hid_device *hid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct usb_interface *usbhid_find_interface(int minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /* iofl flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define HID_CTRL_RUNNING	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define HID_OUT_RUNNING		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define HID_IN_RUNNING		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define HID_RESET_PENDING	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define HID_SUSPENDED		5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define HID_CLEAR_HALT		6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define HID_DISCONNECTED	7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define HID_STARTED		8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define HID_KEYS_PRESSED	10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define HID_NO_BANDWIDTH	11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define HID_RESUME_RUNNING	12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)  * The device is opened, meaning there is a client that is interested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)  * in data coming from the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define HID_OPENED		13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)  * We are polling input endpoint by [re]submitting IN URB, because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)  * either HID device is opened or ALWAYS POLL quirk is set for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)  * device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define HID_IN_POLLING		14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)  * USB-specific HID struct, to be pointed to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)  * from struct hid_device->driver_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct usbhid_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	struct hid_device *hid;						/* pointer to corresponding HID dev */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	struct usb_interface *intf;                                     /* USB interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	int ifnum;                                                      /* USB interface number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	unsigned int bufsize;                                           /* URB buffer size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	struct urb *urbin;                                              /* Input URB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	char *inbuf;                                                    /* Input buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	dma_addr_t inbuf_dma;                                           /* Input buffer dma */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	struct urb *urbctrl;                                            /* Control URB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	struct usb_ctrlrequest *cr;                                     /* Control request struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE];  		/* Control fifo */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	unsigned char ctrlhead, ctrltail;                               /* Control fifo head & tail */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	char *ctrlbuf;                                                  /* Control buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	dma_addr_t ctrlbuf_dma;                                         /* Control buffer dma */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	unsigned long last_ctrl;						/* record of last output for timeouts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 	struct urb *urbout;                                             /* Output URB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 	struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE];              /* Output pipe fifo */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 	unsigned char outhead, outtail;                                 /* Output pipe fifo head & tail */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	char *outbuf;                                                   /* Output buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 	dma_addr_t outbuf_dma;                                          /* Output buffer dma */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 	unsigned long last_out;							/* record of last output for timeouts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 	struct mutex mutex;						/* start/stop/open/close */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 	spinlock_t lock;						/* fifo spinlock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 	unsigned long iofl;                                             /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 	struct timer_list io_retry;                                     /* Retry timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 	unsigned long stop_retry;                                       /* Time to give up, in jiffies */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 	unsigned int retry_delay;                                       /* Delay length in ms */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 	struct work_struct reset_work;                                  /* Task context for resets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 	wait_queue_head_t wait;						/* For sleeping */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define	hid_to_usb_dev(hid_dev) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) 	to_usb_device(hid_dev->dev.parent->parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)