xref: /freebsd/share/man/man4/hidraw.4 (revision 229381deb270e8e240d20b572c63234a61cbd977)
194773907SVladimir Kondratyev.\" $NetBSD: uhid.4,v 1.13 2001/12/29 14:41:59 augustss Exp $
294773907SVladimir Kondratyev.\"
394773907SVladimir Kondratyev.\" Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
494773907SVladimir Kondratyev.\" All rights reserved.
594773907SVladimir Kondratyev.\"
694773907SVladimir Kondratyev.\" This code is derived from software contributed to The NetBSD Foundation
794773907SVladimir Kondratyev.\" by Lennart Augustsson.
894773907SVladimir Kondratyev.\"
994773907SVladimir Kondratyev.\" Redistribution and use in source and binary forms, with or without
1094773907SVladimir Kondratyev.\" modification, are permitted provided that the following conditions
1194773907SVladimir Kondratyev.\" are met:
1294773907SVladimir Kondratyev.\" 1. Redistributions of source code must retain the above copyright
1394773907SVladimir Kondratyev.\"    notice, this list of conditions and the following disclaimer.
1494773907SVladimir Kondratyev.\" 2. Redistributions in binary form must reproduce the above copyright
1594773907SVladimir Kondratyev.\"    notice, this list of conditions and the following disclaimer in the
1694773907SVladimir Kondratyev.\"    documentation and/or other materials provided with the distribution.
1794773907SVladimir Kondratyev.\"
1894773907SVladimir Kondratyev.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1994773907SVladimir Kondratyev.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2094773907SVladimir Kondratyev.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2194773907SVladimir Kondratyev.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2294773907SVladimir Kondratyev.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2394773907SVladimir Kondratyev.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2494773907SVladimir Kondratyev.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2594773907SVladimir Kondratyev.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2694773907SVladimir Kondratyev.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2794773907SVladimir Kondratyev.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2894773907SVladimir Kondratyev.\" POSSIBILITY OF SUCH DAMAGE.
2994773907SVladimir Kondratyev.\"
30f1d955beSVladimir Kondratyev.Dd August 6, 2023
3194773907SVladimir Kondratyev.Dt HIDRAW 4
3294773907SVladimir Kondratyev.Os
3394773907SVladimir Kondratyev.Sh NAME
3494773907SVladimir Kondratyev.Nm hidraw
3594773907SVladimir Kondratyev.Nd Raw Access to HID devices
3694773907SVladimir Kondratyev.Sh SYNOPSIS
3794773907SVladimir KondratyevTo compile this driver into the kernel,
3894773907SVladimir Kondratyevplace the following line in your
3994773907SVladimir Kondratyevkernel configuration file:
4094773907SVladimir Kondratyev.Bd -ragged -offset indent
4194773907SVladimir Kondratyev.Cd "device hidraw"
4294773907SVladimir Kondratyev.Cd "device hid"
4394773907SVladimir Kondratyev.Cd "device hidbus"
4494773907SVladimir Kondratyev.Ed
4594773907SVladimir Kondratyev.Pp
4694773907SVladimir KondratyevAlternatively, to load the driver as a
4794773907SVladimir Kondratyevmodule at boot time, place the following line in
4894773907SVladimir Kondratyev.Xr loader.conf 5 :
4994773907SVladimir Kondratyev.Bd -literal -offset indent
5094773907SVladimir Kondratyevhidraw_load="YES"
5194773907SVladimir Kondratyev.Ed
5294773907SVladimir Kondratyev.Sh DESCRIPTION
5394773907SVladimir KondratyevThe
5494773907SVladimir Kondratyev.Nm
5594773907SVladimir Kondratyevdriver provides a raw interface to Human Interface Devices (HIDs).
5694773907SVladimir KondratyevThe reports are sent to and received from the device unmodified.
5794773907SVladimir Kondratyev.Pp
5894773907SVladimir KondratyevThe device handles 2 sets of
5994773907SVladimir Kondratyev.Xr ioctl 2
6094773907SVladimir Kondratyevcalls:
6194773907SVladimir Kondratyev.Pp
6294773907SVladimir Kondratyev.Fx
6394773907SVladimir Kondratyev.Xr uhid 4
6494773907SVladimir Kondratyev\-compatible calls:
6594773907SVladimir Kondratyev.Bl -tag -width indent
6612f5f114SVladimir Kondratyev.It Dv HIDRAW_GET_REPORT_ID Pq Vt int
6794773907SVladimir KondratyevGet the report identifier used by this HID report.
6812f5f114SVladimir Kondratyev.It Dv HIDRAW_GET_REPORT_DESC Pq Vt "struct hidraw_gen_descriptor"
6994773907SVladimir KondratyevGet the HID report descriptor.
7094773907SVladimir KondratyevCopies a maximum of
7194773907SVladimir Kondratyev.Va hgd_maxlen
7294773907SVladimir Kondratyevbytes of the report descriptor data into the memory
7394773907SVladimir Kondratyevspecified by
7494773907SVladimir Kondratyev.Va hgd_data .
7594773907SVladimir KondratyevUpon return
7694773907SVladimir Kondratyev.Va hgd_actlen
7794773907SVladimir Kondratyevis set to the number of bytes copied.
7894773907SVladimir KondratyevUsing
7994773907SVladimir Kondratyevthis descriptor the exact layout and meaning of data to/from
8094773907SVladimir Kondratyevthe device can be found.
8194773907SVladimir KondratyevThe report descriptor is delivered
8294773907SVladimir Kondratyevwithout any processing.
8394773907SVladimir Kondratyev.Bd -literal
8494773907SVladimir Kondratyevstruct hidraw_gen_descriptor {
8594773907SVladimir Kondratyev	void   *hgd_data;
8694773907SVladimir Kondratyev	uint16_t hgd_maxlen;
8794773907SVladimir Kondratyev	uint16_t hgd_actlen;
8894773907SVladimir Kondratyev	uint8_t	hgd_report_type;
8994773907SVladimir Kondratyev	...
9094773907SVladimir Kondratyev};
9194773907SVladimir Kondratyev.Ed
9212f5f114SVladimir Kondratyev.It Dv HIDRAW_SET_IMMED Pq Vt int
9394773907SVladimir KondratyevSets the device in a mode where each
9494773907SVladimir Kondratyev.Xr read 2
9594773907SVladimir Kondratyevwill return the current value of the input report.
9694773907SVladimir KondratyevNormally
9794773907SVladimir Kondratyeva
9894773907SVladimir Kondratyev.Xr read 2
9994773907SVladimir Kondratyevwill only return the data that the device reports on its
10094773907SVladimir Kondratyevinterrupt pipe.
10194773907SVladimir KondratyevThis call may fail if the device does not support
10294773907SVladimir Kondratyevthis feature.
10312f5f114SVladimir Kondratyev.It Dv HIDRAW_GET_REPORT Pq Vt "struct hidraw_gen_descriptor"
10494773907SVladimir KondratyevGet a report from the device without waiting for data on
10594773907SVladimir Kondratyevthe interrupt pipe.
10694773907SVladimir KondratyevCopies a maximum of
10794773907SVladimir Kondratyev.Va hgd_maxlen
10894773907SVladimir Kondratyevbytes of the report data into the memory specified by
10994773907SVladimir Kondratyev.Va hgd_data .
11094773907SVladimir KondratyevUpon return
11194773907SVladimir Kondratyev.Va hgd_actlen
11294773907SVladimir Kondratyevis set to the number of bytes copied.
11394773907SVladimir KondratyevThe
11494773907SVladimir Kondratyev.Va hgd_report_type
11594773907SVladimir Kondratyevfield indicates which report is requested.
11694773907SVladimir KondratyevIt should be
11794773907SVladimir Kondratyev.Dv HID_INPUT_REPORT ,
11894773907SVladimir Kondratyev.Dv HID_OUTPUT_REPORT ,
11994773907SVladimir Kondratyevor
12094773907SVladimir Kondratyev.Dv HID_FEATURE_REPORT .
12194773907SVladimir KondratyevOn a device which uses numbered reports, the first byte of the returned data
12294773907SVladimir Kondratyevis the report number.
12394773907SVladimir KondratyevThe report data begins from the second byte.
12494773907SVladimir KondratyevFor devices which do not use numbered reports, the report data begins at the
12594773907SVladimir Kondratyevfirst byte.
12694773907SVladimir KondratyevThis call may fail if the device does not support this feature.
12712f5f114SVladimir Kondratyev.It Dv HIDRAW_SET_REPORT Pq Vt "struct hidraw_gen_descriptor"
12894773907SVladimir KondratyevSet a report in the device.
12994773907SVladimir KondratyevThe
13094773907SVladimir Kondratyev.Va hgd_report_type
13194773907SVladimir Kondratyevfield indicates which report is to be set.
13294773907SVladimir KondratyevIt should be
13394773907SVladimir Kondratyev.Dv HID_INPUT_REPORT ,
13494773907SVladimir Kondratyev.Dv HID_OUTPUT_REPORT ,
13594773907SVladimir Kondratyevor
13694773907SVladimir Kondratyev.Dv HID_FEATURE_REPORT .
13794773907SVladimir KondratyevThe value of the report is specified by the
13894773907SVladimir Kondratyev.Va hgd_data
13994773907SVladimir Kondratyevand the
14094773907SVladimir Kondratyev.Va hgd_maxlen
14194773907SVladimir Kondratyevfields.
14294773907SVladimir KondratyevOn a device which uses numbered reports, the first byte of data to be sent is
14394773907SVladimir Kondratyevthe report number.
14494773907SVladimir KondratyevThe report data begins from the second byte.
14594773907SVladimir KondratyevFor devices which do not use numbered reports, the report data begins at the
14694773907SVladimir Kondratyevfirst byte.
14794773907SVladimir KondratyevThis call may fail if the device does not support this feature.
148f1d955beSVladimir Kondratyev.It Dv HIDRAW_GET_DEVICEINFO Pq Vt "struct hidraw_device_info"
149f1d955beSVladimir KondratyevReturns information about the device, like vendor ID and product ID.
150f1d955beSVladimir KondratyevThis call will not issue any hardware transfers.
15194773907SVladimir Kondratyev.El
15294773907SVladimir Kondratyev.Pp
15394773907SVladimir KondratyevLinux
15494773907SVladimir Kondratyev.Nm
15594773907SVladimir Kondratyev\-compatible calls:
15694773907SVladimir Kondratyev.Bl -tag -width indent
15794773907SVladimir Kondratyev.It Dv HIDIOCGRDESCSIZE Pq Vt int
15894773907SVladimir KondratyevGet the HID report descriptor size.
15994773907SVladimir KondratyevReturns the size of the device report descriptor to use with
16094773907SVladimir Kondratyev.Dv HIDIOCGRDESC
16194773907SVladimir Kondratyev.Xr ioctl 2 .
16294773907SVladimir Kondratyev.It Dv HIDIOCGRDESC Pq Vt "struct hidraw_report_descriptor"
16394773907SVladimir KondratyevGet the HID report descriptor.
16494773907SVladimir KondratyevCopies a maximum of
16594773907SVladimir Kondratyev.Va size
16694773907SVladimir Kondratyevbytes of the report descriptor data into the memory
16794773907SVladimir Kondratyevspecified by
16894773907SVladimir Kondratyev.Va value .
16994773907SVladimir Kondratyev.Bd -literal
17094773907SVladimir Kondratyevstruct hidraw_report_descriptor {
17194773907SVladimir Kondratyev	uint32_t	size;
17294773907SVladimir Kondratyev	uint8_t		value[HID_MAX_DESCRIPTOR_SIZE];
17394773907SVladimir Kondratyev};
17494773907SVladimir Kondratyev.Ed
17594773907SVladimir Kondratyev.It Dv HIDIOCGRAWINFO Pq Vt "struct hidraw_devinfo"
17694773907SVladimir KondratyevGet structure containing the bus type, the vendor ID (VID), and product ID
17768445e34SChristian Brueffer(PID) of the device.
17868445e34SChristian BruefferThe bus type can be one of:
17994773907SVladimir Kondratyev.Dv BUS_USB
18094773907SVladimir Kondratyevor
18194773907SVladimir Kondratyev.Dv BUS_I2C
18294773907SVladimir Kondratyevwhich are defined in dev/evdev/input.h.
18394773907SVladimir Kondratyev.Bd -literal
18494773907SVladimir Kondratyevstruct hidraw_devinfo {
18594773907SVladimir Kondratyev	uint32_t	bustype;
18694773907SVladimir Kondratyev	int16_t		vendor;
18794773907SVladimir Kondratyev	int16_t		product;
18894773907SVladimir Kondratyev};
18994773907SVladimir Kondratyev.Ed
19094773907SVladimir Kondratyev.It Dv HIDIOCGRAWNAME(len) Pq Vt "char[] buf"
19194773907SVladimir KondratyevGet device description.
19294773907SVladimir KondratyevCopies a maximum of
19394773907SVladimir Kondratyev.Va len
19494773907SVladimir Kondratyevbytes of the device description previously set with
19594773907SVladimir Kondratyev.Xr device_set_desc 9
19694773907SVladimir Kondratyevprocedure into the memory
19794773907SVladimir Kondratyevspecified by
19894773907SVladimir Kondratyev.Va buf .
19994773907SVladimir Kondratyev.It Dv HIDIOCGRAWPHYS(len) Pq Vt "char[] buf"
20094773907SVladimir KondratyevGet the newbus path to the device.
201*229381deSGraham Percival.\"For Bluetooth devices, it returns the hardware (MAC) address of the device.
20294773907SVladimir KondratyevCopies a maximum of
20394773907SVladimir Kondratyev.Va len
20494773907SVladimir Kondratyevbytes of the newbus device path
20594773907SVladimir Kondratyevinto the memory
20694773907SVladimir Kondratyevspecified by
20794773907SVladimir Kondratyev.Va buf .
20894773907SVladimir Kondratyev.It Dv HIDIOCGFEATURE(len) Pq Vt "void[] buf"
20994773907SVladimir KondratyevGet a feature report from the device.
21094773907SVladimir KondratyevCopies a maximum of
21194773907SVladimir Kondratyev.Va len
21294773907SVladimir Kondratyevbytes of the feature report data into the memory specified by
21394773907SVladimir Kondratyev.Va buf .
21494773907SVladimir KondratyevThe first byte of the supplied buffer should be set to the report
21594773907SVladimir Kondratyevnumber of the requested report.
21694773907SVladimir KondratyevFor devices which do not use numbered reports, set the first byte to 0.
21794773907SVladimir KondratyevThe report will be returned starting at the first byte of the buffer
21894773907SVladimir Kondratyev(ie: the report number is not returned).
21994773907SVladimir KondratyevThis call may fail if the device does not support this feature.
22094773907SVladimir Kondratyev.It Dv HIDIOCSFEATURE(len) Pq Vt "void[] buf"
22194773907SVladimir KondratyevSet a feature Report in the device.
22294773907SVladimir KondratyevThe value of the report is specified by the
22394773907SVladimir Kondratyev.Va buf
22494773907SVladimir Kondratyevand the
22594773907SVladimir Kondratyev.Va len
22694773907SVladimir Kondratyevparameters.
22794773907SVladimir KondratyevSet the first byte of the supplied buffer to the report number.
22894773907SVladimir KondratyevFor devices which do not use numbered reports, set the first byte to 0.
22994773907SVladimir KondratyevThe report data begins in the second byte.
23094773907SVladimir KondratyevMake sure to set len accordingly, to one more than the length of the report
23194773907SVladimir Kondratyev(to account for the report number).
23294773907SVladimir KondratyevThis call may fail if the device does not support this feature.
23394773907SVladimir Kondratyev.El
23494773907SVladimir Kondratyev.Pp
23594773907SVladimir KondratyevUse
23694773907SVladimir Kondratyev.Xr read 2
23794773907SVladimir Kondratyevto get data from the device.
23894773907SVladimir KondratyevData should be read in chunks of the
23994773907SVladimir Kondratyevsize prescribed by the report descriptor.
24094773907SVladimir KondratyevOn a device which uses numbered reports, the first byte of the returned data
24194773907SVladimir Kondratyevis the report number.
24294773907SVladimir KondratyevThe report data begins from the second byte.
24394773907SVladimir KondratyevFor devices which do not use numbered reports, the report data begins at the
24494773907SVladimir Kondratyevfirst byte.
24594773907SVladimir Kondratyev.Pp
24694773907SVladimir KondratyevUse
24794773907SVladimir Kondratyev.Xr write 2
24894773907SVladimir Kondratyevto send data to the device.
24994773907SVladimir KondratyevData should be written in chunks of the
25094773907SVladimir Kondratyevsize prescribed by the report descriptor.
25194773907SVladimir KondratyevThe first byte of the buffer passed to
25294773907SVladimir Kondratyev.Xr write 2
25394773907SVladimir Kondratyevshould be set to the report number.
25494773907SVladimir KondratyevIf the device does not use numbered reports, there are 2 operation modes:
25594773907SVladimir Kondratyev.Nm
25694773907SVladimir Kondratyevmode and
25794773907SVladimir Kondratyev.Xr uhid 4
25894773907SVladimir Kondratyevmode.
25994773907SVladimir KondratyevIn the
26094773907SVladimir Kondratyev.Nm
26194773907SVladimir Kondratyevmode, the first byte should be set to 0 and the report data itself should
26294773907SVladimir Kondratyevbegin at the second byte.
26394773907SVladimir KondratyevIn the
26494773907SVladimir Kondratyev.Xr uhid 4
26594773907SVladimir Kondratyevmode, the report data should begin at the first byte.
26694773907SVladimir KondratyevThe modes can be switched with issuing one of
26794773907SVladimir Kondratyev.Dv HIDIOCGRDESC
26894773907SVladimir Kondratyevor
26994773907SVladimir Kondratyev.Dv HID_GET_REPORT_DESC
27094773907SVladimir Kondratyev.Xr ioctl 2
27194773907SVladimir Kondratyevaccordingly.
27294773907SVladimir KondratyevDefault mode is
27394773907SVladimir Kondratyev.Nm .
27494773907SVladimir Kondratyev.Sh SYSCTL VARIABLES
27594773907SVladimir KondratyevThe following variables are available as both
27694773907SVladimir Kondratyev.Xr sysctl 8
27794773907SVladimir Kondratyevvariables and
27894773907SVladimir Kondratyev.Xr loader 8
27994773907SVladimir Kondratyevtunables:
28094773907SVladimir Kondratyev.Bl -tag -width indent
28194773907SVladimir Kondratyev.It Va hw.hid.hidraw.debug
28294773907SVladimir KondratyevDebug output level, where 0 is debugging disabled and larger values increase
28394773907SVladimir Kondratyevdebug message verbosity.
28494773907SVladimir KondratyevDefault is 0.
28594773907SVladimir Kondratyev.El
28694773907SVladimir Kondratyev.Sh FILES
28794773907SVladimir Kondratyev.Bl -tag -width ".Pa /dev/hidraw?"
28894773907SVladimir Kondratyev.It Pa /dev/hidraw?
28994773907SVladimir Kondratyev.El
29094773907SVladimir Kondratyev.Sh SEE ALSO
29194773907SVladimir Kondratyev.Xr usbhidctl 1 ,
29294773907SVladimir Kondratyev.Xr hid 4 ,
29394773907SVladimir Kondratyev.Xr hidbus 4 ,
29494773907SVladimir Kondratyev.Xr uhid 4
29594773907SVladimir Kondratyev.Sh HISTORY
29694773907SVladimir KondratyevThe
29794773907SVladimir Kondratyev.Xr uhid 4
29894773907SVladimir Kondratyevdriver
29994773907SVladimir Kondratyevappeared in
30094773907SVladimir Kondratyev.Nx 1.4 .
30194773907SVladimir Kondratyev.Nm
30294773907SVladimir Kondratyevprotocol support was added in
30394773907SVladimir Kondratyev.Fx 13
30494773907SVladimir Kondratyevby
30594773907SVladimir Kondratyev.An Vladimir Kondratyev Aq Mt wulf@FreeBSD.org .
30694773907SVladimir KondratyevThis manual page was adopted from
30794773907SVladimir Kondratyev.Nx
30894773907SVladimir Kondratyevby
30994773907SVladimir Kondratyev.An Tom Rhodes Aq Mt trhodes@FreeBSD.org
31094773907SVladimir Kondratyevin April 2002.
311