162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
262306a36Sopenharmony_ci/*****************************************************************************/
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci/*
562306a36Sopenharmony_ci *	usbdevice_fs.h  --  USB device file system.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci *	Copyright (C) 2000
862306a36Sopenharmony_ci *          Thomas Sailer (sailer@ife.ee.ethz.ch)
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci *	This program is free software; you can redistribute it and/or modify
1162306a36Sopenharmony_ci *	it under the terms of the GNU General Public License as published by
1262306a36Sopenharmony_ci *	the Free Software Foundation; either version 2 of the License, or
1362306a36Sopenharmony_ci *	(at your option) any later version.
1462306a36Sopenharmony_ci *
1562306a36Sopenharmony_ci *	This program is distributed in the hope that it will be useful,
1662306a36Sopenharmony_ci *	but WITHOUT ANY WARRANTY; without even the implied warranty of
1762306a36Sopenharmony_ci *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1862306a36Sopenharmony_ci *	GNU General Public License for more details.
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci *	You should have received a copy of the GNU General Public License
2162306a36Sopenharmony_ci *	along with this program; if not, write to the Free Software
2262306a36Sopenharmony_ci *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci *  History:
2562306a36Sopenharmony_ci *   0.1  04.01.2000  Created
2662306a36Sopenharmony_ci */
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/*****************************************************************************/
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci#ifndef _UAPI_LINUX_USBDEVICE_FS_H
3162306a36Sopenharmony_ci#define _UAPI_LINUX_USBDEVICE_FS_H
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#include <linux/types.h>
3462306a36Sopenharmony_ci#include <linux/magic.h>
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci/* --------------------------------------------------------------------- */
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci/* usbdevfs ioctl codes */
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_cistruct usbdevfs_ctrltransfer {
4162306a36Sopenharmony_ci	__u8 bRequestType;
4262306a36Sopenharmony_ci	__u8 bRequest;
4362306a36Sopenharmony_ci	__u16 wValue;
4462306a36Sopenharmony_ci	__u16 wIndex;
4562306a36Sopenharmony_ci	__u16 wLength;
4662306a36Sopenharmony_ci	__u32 timeout;  /* in milliseconds */
4762306a36Sopenharmony_ci 	void __user *data;
4862306a36Sopenharmony_ci};
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_cistruct usbdevfs_bulktransfer {
5162306a36Sopenharmony_ci	unsigned int ep;
5262306a36Sopenharmony_ci	unsigned int len;
5362306a36Sopenharmony_ci	unsigned int timeout; /* in milliseconds */
5462306a36Sopenharmony_ci	void __user *data;
5562306a36Sopenharmony_ci};
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_cistruct usbdevfs_setinterface {
5862306a36Sopenharmony_ci	unsigned int interface;
5962306a36Sopenharmony_ci	unsigned int altsetting;
6062306a36Sopenharmony_ci};
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_cistruct usbdevfs_disconnectsignal {
6362306a36Sopenharmony_ci	unsigned int signr;
6462306a36Sopenharmony_ci	void __user *context;
6562306a36Sopenharmony_ci};
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#define USBDEVFS_MAXDRIVERNAME 255
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_cistruct usbdevfs_getdriver {
7062306a36Sopenharmony_ci	unsigned int interface;
7162306a36Sopenharmony_ci	char driver[USBDEVFS_MAXDRIVERNAME + 1];
7262306a36Sopenharmony_ci};
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_cistruct usbdevfs_connectinfo {
7562306a36Sopenharmony_ci	unsigned int devnum;
7662306a36Sopenharmony_ci	unsigned char slow;
7762306a36Sopenharmony_ci};
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_cistruct usbdevfs_conninfo_ex {
8062306a36Sopenharmony_ci	__u32 size;		/* Size of the structure from the kernel's */
8162306a36Sopenharmony_ci				/* point of view. Can be used by userspace */
8262306a36Sopenharmony_ci				/* to determine how much data can be       */
8362306a36Sopenharmony_ci				/* used/trusted.                           */
8462306a36Sopenharmony_ci	__u32 busnum;           /* USB bus number, as enumerated by the    */
8562306a36Sopenharmony_ci				/* kernel, the device is connected to.     */
8662306a36Sopenharmony_ci	__u32 devnum;           /* Device address on the bus.              */
8762306a36Sopenharmony_ci	__u32 speed;		/* USB_SPEED_* constants from ch9.h        */
8862306a36Sopenharmony_ci	__u8 num_ports;		/* Number of ports the device is connected */
8962306a36Sopenharmony_ci				/* to on the way to the root hub. It may   */
9062306a36Sopenharmony_ci				/* be bigger than size of 'ports' array so */
9162306a36Sopenharmony_ci				/* userspace can detect overflows.         */
9262306a36Sopenharmony_ci	__u8 ports[7];		/* List of ports on the way from the root  */
9362306a36Sopenharmony_ci				/* hub to the device. Current limit in     */
9462306a36Sopenharmony_ci				/* USB specification is 7 tiers (root hub, */
9562306a36Sopenharmony_ci				/* 5 intermediate hubs, device), which     */
9662306a36Sopenharmony_ci				/* gives at most 6 port entries.           */
9762306a36Sopenharmony_ci};
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#define USBDEVFS_URB_SHORT_NOT_OK	0x01
10062306a36Sopenharmony_ci#define USBDEVFS_URB_ISO_ASAP		0x02
10162306a36Sopenharmony_ci#define USBDEVFS_URB_BULK_CONTINUATION	0x04
10262306a36Sopenharmony_ci#define USBDEVFS_URB_NO_FSBR		0x20	/* Not used */
10362306a36Sopenharmony_ci#define USBDEVFS_URB_ZERO_PACKET	0x40
10462306a36Sopenharmony_ci#define USBDEVFS_URB_NO_INTERRUPT	0x80
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci#define USBDEVFS_URB_TYPE_ISO		   0
10762306a36Sopenharmony_ci#define USBDEVFS_URB_TYPE_INTERRUPT	   1
10862306a36Sopenharmony_ci#define USBDEVFS_URB_TYPE_CONTROL	   2
10962306a36Sopenharmony_ci#define USBDEVFS_URB_TYPE_BULK		   3
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_cistruct usbdevfs_iso_packet_desc {
11262306a36Sopenharmony_ci	unsigned int length;
11362306a36Sopenharmony_ci	unsigned int actual_length;
11462306a36Sopenharmony_ci	unsigned int status;
11562306a36Sopenharmony_ci};
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_cistruct usbdevfs_urb {
11862306a36Sopenharmony_ci	unsigned char type;
11962306a36Sopenharmony_ci	unsigned char endpoint;
12062306a36Sopenharmony_ci	int status;
12162306a36Sopenharmony_ci	unsigned int flags;
12262306a36Sopenharmony_ci	void __user *buffer;
12362306a36Sopenharmony_ci	int buffer_length;
12462306a36Sopenharmony_ci	int actual_length;
12562306a36Sopenharmony_ci	int start_frame;
12662306a36Sopenharmony_ci	union {
12762306a36Sopenharmony_ci		int number_of_packets;	/* Only used for isoc urbs */
12862306a36Sopenharmony_ci		unsigned int stream_id;	/* Only used with bulk streams */
12962306a36Sopenharmony_ci	};
13062306a36Sopenharmony_ci	int error_count;
13162306a36Sopenharmony_ci	unsigned int signr;	/* signal to be sent on completion,
13262306a36Sopenharmony_ci				  or 0 if none should be sent. */
13362306a36Sopenharmony_ci	void __user *usercontext;
13462306a36Sopenharmony_ci	struct usbdevfs_iso_packet_desc iso_frame_desc[];
13562306a36Sopenharmony_ci};
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci/* ioctls for talking directly to drivers */
13862306a36Sopenharmony_cistruct usbdevfs_ioctl {
13962306a36Sopenharmony_ci	int	ifno;		/* interface 0..N ; negative numbers reserved */
14062306a36Sopenharmony_ci	int	ioctl_code;	/* MUST encode size + direction of data so the
14162306a36Sopenharmony_ci				 * macros in <asm/ioctl.h> give correct values */
14262306a36Sopenharmony_ci	void __user *data;	/* param buffer (in, or out) */
14362306a36Sopenharmony_ci};
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci/* You can do most things with hubs just through control messages,
14662306a36Sopenharmony_ci * except find out what device connects to what port. */
14762306a36Sopenharmony_cistruct usbdevfs_hub_portinfo {
14862306a36Sopenharmony_ci	char nports;		/* number of downstream ports in this hub */
14962306a36Sopenharmony_ci	char port [127];	/* e.g. port 3 connects to device 27 */
15062306a36Sopenharmony_ci};
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci/* System and bus capability flags */
15362306a36Sopenharmony_ci#define USBDEVFS_CAP_ZERO_PACKET		0x01
15462306a36Sopenharmony_ci#define USBDEVFS_CAP_BULK_CONTINUATION		0x02
15562306a36Sopenharmony_ci#define USBDEVFS_CAP_NO_PACKET_SIZE_LIM		0x04
15662306a36Sopenharmony_ci#define USBDEVFS_CAP_BULK_SCATTER_GATHER	0x08
15762306a36Sopenharmony_ci#define USBDEVFS_CAP_REAP_AFTER_DISCONNECT	0x10
15862306a36Sopenharmony_ci#define USBDEVFS_CAP_MMAP			0x20
15962306a36Sopenharmony_ci#define USBDEVFS_CAP_DROP_PRIVILEGES		0x40
16062306a36Sopenharmony_ci#define USBDEVFS_CAP_CONNINFO_EX		0x80
16162306a36Sopenharmony_ci#define USBDEVFS_CAP_SUSPEND			0x100
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci/* USBDEVFS_DISCONNECT_CLAIM flags & struct */
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci/* disconnect-and-claim if the driver matches the driver field */
16662306a36Sopenharmony_ci#define USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER	0x01
16762306a36Sopenharmony_ci/* disconnect-and-claim except when the driver matches the driver field */
16862306a36Sopenharmony_ci#define USBDEVFS_DISCONNECT_CLAIM_EXCEPT_DRIVER	0x02
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_cistruct usbdevfs_disconnect_claim {
17162306a36Sopenharmony_ci	unsigned int interface;
17262306a36Sopenharmony_ci	unsigned int flags;
17362306a36Sopenharmony_ci	char driver[USBDEVFS_MAXDRIVERNAME + 1];
17462306a36Sopenharmony_ci};
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_cistruct usbdevfs_streams {
17762306a36Sopenharmony_ci	unsigned int num_streams; /* Not used by USBDEVFS_FREE_STREAMS */
17862306a36Sopenharmony_ci	unsigned int num_eps;
17962306a36Sopenharmony_ci	unsigned char eps[];
18062306a36Sopenharmony_ci};
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci/*
18362306a36Sopenharmony_ci * USB_SPEED_* values returned by USBDEVFS_GET_SPEED are defined in
18462306a36Sopenharmony_ci * linux/usb/ch9.h
18562306a36Sopenharmony_ci */
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ci#define USBDEVFS_CONTROL           _IOWR('U', 0, struct usbdevfs_ctrltransfer)
18862306a36Sopenharmony_ci#define USBDEVFS_CONTROL32           _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
18962306a36Sopenharmony_ci#define USBDEVFS_BULK              _IOWR('U', 2, struct usbdevfs_bulktransfer)
19062306a36Sopenharmony_ci#define USBDEVFS_BULK32              _IOWR('U', 2, struct usbdevfs_bulktransfer32)
19162306a36Sopenharmony_ci#define USBDEVFS_RESETEP           _IOR('U', 3, unsigned int)
19262306a36Sopenharmony_ci#define USBDEVFS_SETINTERFACE      _IOR('U', 4, struct usbdevfs_setinterface)
19362306a36Sopenharmony_ci#define USBDEVFS_SETCONFIGURATION  _IOR('U', 5, unsigned int)
19462306a36Sopenharmony_ci#define USBDEVFS_GETDRIVER         _IOW('U', 8, struct usbdevfs_getdriver)
19562306a36Sopenharmony_ci#define USBDEVFS_SUBMITURB         _IOR('U', 10, struct usbdevfs_urb)
19662306a36Sopenharmony_ci#define USBDEVFS_SUBMITURB32       _IOR('U', 10, struct usbdevfs_urb32)
19762306a36Sopenharmony_ci#define USBDEVFS_DISCARDURB        _IO('U', 11)
19862306a36Sopenharmony_ci#define USBDEVFS_REAPURB           _IOW('U', 12, void *)
19962306a36Sopenharmony_ci#define USBDEVFS_REAPURB32         _IOW('U', 12, __u32)
20062306a36Sopenharmony_ci#define USBDEVFS_REAPURBNDELAY     _IOW('U', 13, void *)
20162306a36Sopenharmony_ci#define USBDEVFS_REAPURBNDELAY32   _IOW('U', 13, __u32)
20262306a36Sopenharmony_ci#define USBDEVFS_DISCSIGNAL        _IOR('U', 14, struct usbdevfs_disconnectsignal)
20362306a36Sopenharmony_ci#define USBDEVFS_DISCSIGNAL32      _IOR('U', 14, struct usbdevfs_disconnectsignal32)
20462306a36Sopenharmony_ci#define USBDEVFS_CLAIMINTERFACE    _IOR('U', 15, unsigned int)
20562306a36Sopenharmony_ci#define USBDEVFS_RELEASEINTERFACE  _IOR('U', 16, unsigned int)
20662306a36Sopenharmony_ci#define USBDEVFS_CONNECTINFO       _IOW('U', 17, struct usbdevfs_connectinfo)
20762306a36Sopenharmony_ci#define USBDEVFS_IOCTL             _IOWR('U', 18, struct usbdevfs_ioctl)
20862306a36Sopenharmony_ci#define USBDEVFS_IOCTL32           _IOWR('U', 18, struct usbdevfs_ioctl32)
20962306a36Sopenharmony_ci#define USBDEVFS_HUB_PORTINFO      _IOR('U', 19, struct usbdevfs_hub_portinfo)
21062306a36Sopenharmony_ci#define USBDEVFS_RESET             _IO('U', 20)
21162306a36Sopenharmony_ci#define USBDEVFS_CLEAR_HALT        _IOR('U', 21, unsigned int)
21262306a36Sopenharmony_ci#define USBDEVFS_DISCONNECT        _IO('U', 22)
21362306a36Sopenharmony_ci#define USBDEVFS_CONNECT           _IO('U', 23)
21462306a36Sopenharmony_ci#define USBDEVFS_CLAIM_PORT        _IOR('U', 24, unsigned int)
21562306a36Sopenharmony_ci#define USBDEVFS_RELEASE_PORT      _IOR('U', 25, unsigned int)
21662306a36Sopenharmony_ci#define USBDEVFS_GET_CAPABILITIES  _IOR('U', 26, __u32)
21762306a36Sopenharmony_ci#define USBDEVFS_DISCONNECT_CLAIM  _IOR('U', 27, struct usbdevfs_disconnect_claim)
21862306a36Sopenharmony_ci#define USBDEVFS_ALLOC_STREAMS     _IOR('U', 28, struct usbdevfs_streams)
21962306a36Sopenharmony_ci#define USBDEVFS_FREE_STREAMS      _IOR('U', 29, struct usbdevfs_streams)
22062306a36Sopenharmony_ci#define USBDEVFS_DROP_PRIVILEGES   _IOW('U', 30, __u32)
22162306a36Sopenharmony_ci#define USBDEVFS_GET_SPEED         _IO('U', 31)
22262306a36Sopenharmony_ci/*
22362306a36Sopenharmony_ci * Returns struct usbdevfs_conninfo_ex; length is variable to allow
22462306a36Sopenharmony_ci * extending size of the data returned.
22562306a36Sopenharmony_ci */
22662306a36Sopenharmony_ci#define USBDEVFS_CONNINFO_EX(len)  _IOC(_IOC_READ, 'U', 32, len)
22762306a36Sopenharmony_ci#define USBDEVFS_FORBID_SUSPEND    _IO('U', 33)
22862306a36Sopenharmony_ci#define USBDEVFS_ALLOW_SUSPEND     _IO('U', 34)
22962306a36Sopenharmony_ci#define USBDEVFS_WAIT_FOR_RESUME   _IO('U', 35)
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci#endif /* _UAPI_LINUX_USBDEVICE_FS_H */
232