rfkill.h 3.6 KB

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