rfkill.h 3.3 KB

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