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