rfkill.txt 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. rfkill - RF switch subsystem support
  2. ====================================
  3. 1 Implementation details
  4. 2 Driver support
  5. 3 Userspace support
  6. ===============================================================================
  7. 1: Implementation details
  8. The rfkill switch subsystem offers support for keys often found on laptops
  9. to enable wireless devices like WiFi and Bluetooth.
  10. This is done by providing the user 3 possibilities:
  11. 1 - The rfkill system handles all events; userspace is not aware of events.
  12. 2 - The rfkill system handles all events; userspace is informed about the events.
  13. 3 - The rfkill system does not handle events; userspace handles all events.
  14. The buttons to enable and disable the wireless radios are important in
  15. situations where the user is for example using his laptop on a location where
  16. wireless radios _must_ be disabled (e.g. airplanes).
  17. Because of this requirement, userspace support for the keys should not be
  18. made mandatory. Because userspace might want to perform some additional smarter
  19. tasks when the key is pressed, rfkill still provides userspace the possibility
  20. to take over the task to handle the key events.
  21. The system inside the kernel has been split into 2 separate sections:
  22. 1 - RFKILL
  23. 2 - RFKILL_INPUT
  24. The first option enables rfkill support and will make sure userspace will
  25. be notified of any events through the input device. It also creates several
  26. sysfs entries which can be used by userspace. See section "Userspace support".
  27. The second option provides an rfkill input handler. This handler will
  28. listen to all rfkill key events and will toggle the radio accordingly.
  29. With this option enabled userspace could either do nothing or simply
  30. perform monitoring tasks.
  31. ====================================
  32. 2: Driver support
  33. To build a driver with rfkill subsystem support, the driver should
  34. depend on the Kconfig symbol RFKILL; it should _not_ depend on
  35. RKFILL_INPUT.
  36. Unless key events trigger an interrupt to which the driver listens, polling
  37. will be required to determine the key state changes. For this the input
  38. layer providers the input-polldev handler.
  39. A driver should implement a few steps to correctly make use of the
  40. rfkill subsystem. First for non-polling drivers:
  41. - rfkill_allocate()
  42. - input_allocate_device()
  43. - rfkill_register()
  44. - input_register_device()
  45. For polling drivers:
  46. - rfkill_allocate()
  47. - input_allocate_polled_device()
  48. - rfkill_register()
  49. - input_register_polled_device()
  50. When a key event has been detected, the correct event should be
  51. sent over the input device which has been registered by the driver.
  52. ====================================
  53. 3: Userspace support
  54. For each key an input device will be created which will send out the correct
  55. key event when the rfkill key has been pressed.
  56. The following sysfs entries will be created:
  57. name: Name assigned by driver to this key (interface or driver name).
  58. type: Name of the key type ("wlan", "bluetooth", etc).
  59. state: Current state of the key. 1: On, 0: Off.
  60. claim: 1: Userspace handles events, 0: Kernel handles events
  61. Both the "state" and "claim" entries are also writable. For the "state" entry
  62. this means that when 1 or 0 is written all radios, not yet in the requested
  63. state, will be will be toggled accordingly.
  64. For the "claim" entry writing 1 to it means that the kernel no longer handles
  65. key events even though RFKILL_INPUT input was enabled. When "claim" has been
  66. set to 0, userspace should make sure that it listens for the input events or
  67. check the sysfs "state" entry regularly to correctly perform the required
  68. tasks when the rkfill key is pressed.