rfkill.h revision 30692c65c4174412c90e79489e98ab85c1a7412f
130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Copyright (C) 2006 - 2007 Ivo van Doorn 330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Copyright (C) 2007 Dmitry Torokhov 430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> 530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Permission to use, copy, modify, and/or distribute this software for any 730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * purpose with or without fee is hereby granted, provided that the above 830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * copyright notice and this permission notice appear in all copies. 930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 1030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 1830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#ifndef _UAPI__RFKILL_H 1930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define _UAPI__RFKILL_H 2030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 2130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 2230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#include <linux/types.h> 2330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 2430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* define userspace visible states */ 2530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define RFKILL_STATE_SOFT_BLOCKED 0 2630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define RFKILL_STATE_UNBLOCKED 1 2730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define RFKILL_STATE_HARD_BLOCKED 2 2830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 2930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/** 3030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * enum rfkill_type - type of rfkill switch. 3130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 3230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_TYPE_ALL: toggles all switches (requests only - not a switch type) 3330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device. 3430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device. 3530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_TYPE_UWB: switch is on a ultra wideband device. 3630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_TYPE_WIMAX: switch is on a WiMAX device. 3730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_TYPE_WWAN: switch is on a wireless WAN device. 3830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_TYPE_GPS: switch is on a GPS device. 3930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_TYPE_FM: switch is on a FM radio device. 4030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_TYPE_NFC: switch is on an NFC device. 4130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @NUM_RFKILL_TYPES: number of defined rfkill types 4230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 4330692c65c4174412c90e79489e98ab85c1a7412fBen Chengenum rfkill_type { 4430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_TYPE_ALL = 0, 4530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_TYPE_WLAN, 4630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_TYPE_BLUETOOTH, 4730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_TYPE_UWB, 4830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_TYPE_WIMAX, 4930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_TYPE_WWAN, 5030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_TYPE_GPS, 5130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_TYPE_FM, 5230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_TYPE_NFC, 5330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng NUM_RFKILL_TYPES, 5430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 5530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 5630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/** 5730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * enum rfkill_operation - operation types 5830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_OP_ADD: a device was added 5930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_OP_DEL: a device was removed 6030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_OP_CHANGE: a device's state changed -- userspace changes one device 6130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @RFKILL_OP_CHANGE_ALL: userspace changes all devices (of a type, or all) 6230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 6330692c65c4174412c90e79489e98ab85c1a7412fBen Chengenum rfkill_operation { 6430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_OP_ADD = 0, 6530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_OP_DEL, 6630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_OP_CHANGE, 6730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng RFKILL_OP_CHANGE_ALL, 6830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 6930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 7030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/** 7130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * struct rfkill_event - events for userspace on /dev/rfkill 7230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @idx: index of dev rfkill 7330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @type: type of the rfkill struct 7430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @op: operation code 7530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @hard: hard state (0/1) 7630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @soft: soft state (0/1) 7730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 7830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Structure used for userspace communication on /dev/rfkill, 7930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * used for events from the kernel and control to the kernel. 8030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 8130692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct rfkill_event { 8230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u32 idx; 8330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 type; 8430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 op; 8530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 soft, hard; 8630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng} __attribute__((packed)); 8730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 8830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 8930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * We are planning to be backward and forward compatible with changes 9030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * to the event struct, by adding new, optional, members at the end. 9130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * When reading an event (whether the kernel from userspace or vice 9230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * versa) we need to accept anything that's at least as large as the 9330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * version 1 event size, but might be able to accept other sizes in 9430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * the future. 9530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 9630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * One exception is the kernel -- we already have two event sizes in 9730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * that we've made the 'hard' member optional since our only option 9830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * is to ignore it anyway. 9930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 10030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define RFKILL_EVENT_SIZE_V1 8 10130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 10230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* ioctl for turning off rfkill-input (if present) */ 10330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define RFKILL_IOC_MAGIC 'R' 10430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define RFKILL_IOC_NOINPUT 1 10530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define RFKILL_IOCTL_NOINPUT _IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT) 10630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 10730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* and that's all userspace gets */ 10830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 10930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#endif /* _UAPI__RFKILL_H */ 110