xref: /OK3568_Linux_fs/kernel/include/uapi/linux/rfkill.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (C) 2006 - 2007 Ivo van Doorn
3*4882a593Smuzhiyun  * Copyright (C) 2007 Dmitry Torokhov
4*4882a593Smuzhiyun  * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Permission to use, copy, modify, and/or distribute this software for any
7*4882a593Smuzhiyun  * purpose with or without fee is hereby granted, provided that the above
8*4882a593Smuzhiyun  * copyright notice and this permission notice appear in all copies.
9*4882a593Smuzhiyun  *
10*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11*4882a593Smuzhiyun  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12*4882a593Smuzhiyun  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13*4882a593Smuzhiyun  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14*4882a593Smuzhiyun  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15*4882a593Smuzhiyun  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16*4882a593Smuzhiyun  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*4882a593Smuzhiyun  */
18*4882a593Smuzhiyun #ifndef _UAPI__RFKILL_H
19*4882a593Smuzhiyun #define _UAPI__RFKILL_H
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun #include <linux/types.h>
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun /* define userspace visible states */
25*4882a593Smuzhiyun #define RFKILL_STATE_SOFT_BLOCKED	0
26*4882a593Smuzhiyun #define RFKILL_STATE_UNBLOCKED		1
27*4882a593Smuzhiyun #define RFKILL_STATE_HARD_BLOCKED	2
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun /**
30*4882a593Smuzhiyun  * enum rfkill_type - type of rfkill switch.
31*4882a593Smuzhiyun  *
32*4882a593Smuzhiyun  * @RFKILL_TYPE_ALL: toggles all switches (requests only - not a switch type)
33*4882a593Smuzhiyun  * @RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device.
34*4882a593Smuzhiyun  * @RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device.
35*4882a593Smuzhiyun  * @RFKILL_TYPE_UWB: switch is on a ultra wideband device.
36*4882a593Smuzhiyun  * @RFKILL_TYPE_WIMAX: switch is on a WiMAX device.
37*4882a593Smuzhiyun  * @RFKILL_TYPE_WWAN: switch is on a wireless WAN device.
38*4882a593Smuzhiyun  * @RFKILL_TYPE_GPS: switch is on a GPS device.
39*4882a593Smuzhiyun  * @RFKILL_TYPE_FM: switch is on a FM radio device.
40*4882a593Smuzhiyun  * @RFKILL_TYPE_NFC: switch is on an NFC device.
41*4882a593Smuzhiyun  * @NUM_RFKILL_TYPES: number of defined rfkill types
42*4882a593Smuzhiyun  */
43*4882a593Smuzhiyun enum rfkill_type {
44*4882a593Smuzhiyun 	RFKILL_TYPE_ALL = 0,
45*4882a593Smuzhiyun 	RFKILL_TYPE_WLAN,
46*4882a593Smuzhiyun 	RFKILL_TYPE_BLUETOOTH,
47*4882a593Smuzhiyun 	RFKILL_TYPE_UWB,
48*4882a593Smuzhiyun 	RFKILL_TYPE_WIMAX,
49*4882a593Smuzhiyun 	RFKILL_TYPE_WWAN,
50*4882a593Smuzhiyun 	RFKILL_TYPE_GPS,
51*4882a593Smuzhiyun 	RFKILL_TYPE_FM,
52*4882a593Smuzhiyun 	RFKILL_TYPE_NFC,
53*4882a593Smuzhiyun 	NUM_RFKILL_TYPES,
54*4882a593Smuzhiyun };
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun /**
57*4882a593Smuzhiyun  * enum rfkill_operation - operation types
58*4882a593Smuzhiyun  * @RFKILL_OP_ADD: a device was added
59*4882a593Smuzhiyun  * @RFKILL_OP_DEL: a device was removed
60*4882a593Smuzhiyun  * @RFKILL_OP_CHANGE: a device's state changed -- userspace changes one device
61*4882a593Smuzhiyun  * @RFKILL_OP_CHANGE_ALL: userspace changes all devices (of a type, or all)
62*4882a593Smuzhiyun  *	into a state, also updating the default state used for devices that
63*4882a593Smuzhiyun  *	are hot-plugged later.
64*4882a593Smuzhiyun  */
65*4882a593Smuzhiyun enum rfkill_operation {
66*4882a593Smuzhiyun 	RFKILL_OP_ADD = 0,
67*4882a593Smuzhiyun 	RFKILL_OP_DEL,
68*4882a593Smuzhiyun 	RFKILL_OP_CHANGE,
69*4882a593Smuzhiyun 	RFKILL_OP_CHANGE_ALL,
70*4882a593Smuzhiyun };
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun /**
73*4882a593Smuzhiyun  * struct rfkill_event - events for userspace on /dev/rfkill
74*4882a593Smuzhiyun  * @idx: index of dev rfkill
75*4882a593Smuzhiyun  * @type: type of the rfkill struct
76*4882a593Smuzhiyun  * @op: operation code
77*4882a593Smuzhiyun  * @hard: hard state (0/1)
78*4882a593Smuzhiyun  * @soft: soft state (0/1)
79*4882a593Smuzhiyun  *
80*4882a593Smuzhiyun  * Structure used for userspace communication on /dev/rfkill,
81*4882a593Smuzhiyun  * used for events from the kernel and control to the kernel.
82*4882a593Smuzhiyun  */
83*4882a593Smuzhiyun struct rfkill_event {
84*4882a593Smuzhiyun 	__u32 idx;
85*4882a593Smuzhiyun 	__u8  type;
86*4882a593Smuzhiyun 	__u8  op;
87*4882a593Smuzhiyun 	__u8  soft, hard;
88*4882a593Smuzhiyun } __attribute__((packed));
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun /*
91*4882a593Smuzhiyun  * We are planning to be backward and forward compatible with changes
92*4882a593Smuzhiyun  * to the event struct, by adding new, optional, members at the end.
93*4882a593Smuzhiyun  * When reading an event (whether the kernel from userspace or vice
94*4882a593Smuzhiyun  * versa) we need to accept anything that's at least as large as the
95*4882a593Smuzhiyun  * version 1 event size, but might be able to accept other sizes in
96*4882a593Smuzhiyun  * the future.
97*4882a593Smuzhiyun  *
98*4882a593Smuzhiyun  * One exception is the kernel -- we already have two event sizes in
99*4882a593Smuzhiyun  * that we've made the 'hard' member optional since our only option
100*4882a593Smuzhiyun  * is to ignore it anyway.
101*4882a593Smuzhiyun  */
102*4882a593Smuzhiyun #define RFKILL_EVENT_SIZE_V1	8
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun /* ioctl for turning off rfkill-input (if present) */
105*4882a593Smuzhiyun #define RFKILL_IOC_MAGIC	'R'
106*4882a593Smuzhiyun #define RFKILL_IOC_NOINPUT	1
107*4882a593Smuzhiyun #define RFKILL_IOCTL_NOINPUT	_IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT)
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun /* and that's all userspace gets */
110*4882a593Smuzhiyun 
111*4882a593Smuzhiyun #endif /* _UAPI__RFKILL_H */
112