Skip to contentSkip to conversation

Hardware button support for Wireless cards: radiobtn

RFC PATCH In review Ivo van Doorn 5 participants 17 messages May 25, 2006 – Jun 23, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/2 Hardware button support for Wireless cards: radiobtn

Add radiobtn driver.
This driver creates an iput device for each registered button
and will poll the device frequently to check the latest status of the button. Once the status has changed it will try to enable or disable the radio and send an event to the input device.

drivers/input/misc/Kconfig +9 -0
diff -uprN wireless-dev/drivers/input/misc/Kconfig wireless-dev-radiobtn/drivers/input/misc/Kconfig
@@ -79,4 +79,13 @@ config HP_SDC_RTC
 	  Say Y here if you want to support the built-in real time clock
 	  of the HP SDC controller.
 
+config RADIOBTN
+	tristate "Hardware radio button support"
+	help
+	  Say Y here if you have an integrated WiFi or Bluetooth device
+	  which contains an hardware button for enabling or disabling the radio.
+	  When this driver is used, this driver will make sure the radio will
+	  be correctly enabled and disabled when needed. It will then also
+	  use the created input device to signal user space of this event
+	  which allows userspace to take additional actions.
 endif
drivers/input/misc/Makefile +1 -0
diff -uprN wireless-dev/drivers/input/misc/Makefile wireless-dev-radiobtn/drivers/input/misc/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_INPUT_UINPUT)		+= uinput.o
 obj-$(CONFIG_INPUT_WISTRON_BTNS)	+= wistron_btns.o
 obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_IXP4XX_BEEPER)	+= ixp4xx-beeper.o
+obj-$(CONFIG_RADIOBTN)			+= radiobtn.o
drivers/input/misc/radiobtn.c +158 -0

158 lines not on this page · raw message

include/linux/radiobtn.h +83 -0

83 lines not on this page · raw message

#1 lore raw

Hi,

I made a small update on this patch, only a small compile fix and small bugfix.

The thing I would like to know now, is if the current approach is the desired situation.

- Should only 1 input device be created, or multiple devices?

- Should instead of KEY_RADIO new keys be created (KEY_RADIO_WIFI and KEY_RADIO_BLUETOOTH for example) or should instead input_event be used and instead of "1", other values be passed to indicate the device which has triggered the event?

drivers/input/misc/Kconfig +10 -0
index 4bad588..212caad 100644
@@ -79,4 +79,14 @@ config HP_SDC_RTC
 	  Say Y here if you want to support the built-in real time clock
 	  of the HP SDC controller.
 
+config RADIOBTN
+	tristate "Hardware radio button support"
+	help
+	  Say Y here if you have an integrated WiFi or Bluetooth device
+	  which contains an hardware button for enabling or disabling the radio.
+	  When this driver is used, this driver will make sure the radio will
+	  be correctly enabled and disabled when needed. It will then also
+	  use the created input device to signal user space of this event
+	  which allows userspace to take additional actions.
+
 endif
drivers/input/misc/Makefile +1 -0
index 415c491..9af3d98 100644
@@ -11,3 +11,4 @@ obj-$(CONFIG_INPUT_UINPUT)		+= uinput.o
 obj-$(CONFIG_INPUT_WISTRON_BTNS)	+= wistron_btns.o
 obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_IXP4XX_BEEPER)	+= ixp4xx-beeper.o
+obj-$(CONFIG_RADIOBTN)			+= radiobtn.o
\ No newline at end of file
drivers/input/misc/radiobtn.c new file +163 -0

163 lines not on this page · raw message

include/linux/radiobtn.h new file +84 -0

84 lines not on this page · raw message

#2 lore raw

Ivo van Doorn <[email protected]> :
[...]

Quoted 5 lines
drivers/input/misc/radiobtn.c new file +0 -0
new file mode 100644
index 0000000..8d3b84a

[...]

Quoted 1 line

+void radiobtn_poll(unsigned long data)

static ?

[...]

Quoted 12 lines
drivers/input/misc/radiobtn.c new file +12 -0
+int radiobtn_register_device(struct radio_button *radiobtn)
+{
+	int status;
+
+	/*
+	 * Check if all mandatory fields have been set.
+	 */
+	if (radiobtn->poll_delay == 0 || radiobtn->button_poll == NULL)
+		return -EINVAL;
+
+	/*
+	 * Allocate, initialize and register input device.

drivers/input/misc/radiobtn.c line 100

Quoted 10 lines
drivers/input/misc/radiobtn.c new file +10 -0
+	 */
+	radiobtn->input_dev = input_allocate_device();
+	if (!radiobtn->input_dev) {
+		printk(KERN_ERR "Failed to allocate input device %s.\n",
+			radiobtn->dev_name);
+		return -ENOMEM;
+	}
+
+	radiobtn->input_dev->name = "Radio button";
+	radiobtn->input_dev->phys = strcat("radiobtn/", radiobtn->dev_name);

The first parameter of strcat() must be big enough to contain the whole string.

Signature · 1 line
Ueimor
#3 lore raw
Quoted 11 lines · Francois Romieu

Ivo van Doorn <[email protected]> :
[...]

Quoted 5 lines
drivers/input/misc/radiobtn.c new file +0 -0
new file mode 100644
index 0000000..8d3b84a

[...]

Quoted 1 line

+void radiobtn_poll(unsigned long data)

static ?

Good point. Will fix this immediately.

Quoted 18 lines

[...]

Quoted 17 lines
drivers/input/misc/radiobtn.c new file +17 -0
+int radiobtn_register_device(struct radio_button *radiobtn)
+{
+	int status;
+
+	/*
+	 * Check if all mandatory fields have been set.
+	 */
+	if (radiobtn->poll_delay == 0 || radiobtn->button_poll == NULL)
+		return -EINVAL;
+
+	/*
+	 * Allocate, initialize and register input device.
+	 */
+	radiobtn->input_dev = input_allocate_device();
+	if (!radiobtn->input_dev) {
+		printk(KERN_ERR "Failed to allocate input device %s.\n",
+			radiobtn->dev_name);
Quoted 8 lines

drivers/input/misc/radiobtn.c line 100

Quoted 5 lines
drivers/input/misc/radiobtn.c new file +5 -0
+		return -ENOMEM;
+	}
+
+	radiobtn->input_dev->name = "Radio button";
+	radiobtn->input_dev->phys = strcat("radiobtn/", radiobtn->dev_name);

The first parameter of strcat() must be big enough to contain the whole string.

Will replace it with
sprintf(wrqu->name, "radiobtn/", radiobtn->dev_name);

Thanks.

Ivo

#4 lore raw
Quoted 42 lines · Ivo van Doorn
Quoted 11 lines · Francois Romieu

Ivo van Doorn <[email protected]> :
[...]

Quoted 5 lines
drivers/input/misc/radiobtn.c new file +0 -0
new file mode 100644
index 0000000..8d3b84a

[...]

Quoted 1 line

+void radiobtn_poll(unsigned long data)

static ?

Good point. Will fix this immediately.

Quoted 18 lines

[...]

Quoted 17 lines
drivers/input/misc/radiobtn.c new file +17 -0
+int radiobtn_register_device(struct radio_button *radiobtn)
+{
+	int status;
+
+	/*
+	 * Check if all mandatory fields have been set.
+	 */
+	if (radiobtn->poll_delay == 0 || radiobtn->button_poll == NULL)
+		return -EINVAL;
+
+	/*
+	 * Allocate, initialize and register input device.
+	 */
+	radiobtn->input_dev = input_allocate_device();
+	if (!radiobtn->input_dev) {
+		printk(KERN_ERR "Failed to allocate input device %s.\n",
+			radiobtn->dev_name);
Quoted 8 lines

drivers/input/misc/radiobtn.c line 100

Quoted 5 lines
drivers/input/misc/radiobtn.c new file +5 -0
+		return -ENOMEM;
+	}
+
+	radiobtn->input_dev->name = "Radio button";
+	radiobtn->input_dev->phys = strcat("radiobtn/", radiobtn->dev_name);

The first parameter of strcat() must be big enough to contain the whole string.

Quoted 2 lines

Will replace it with
sprintf(wrqu->name, "radiobtn/", radiobtn->dev_name);

Or actually, I don't think the radiobtn/ won't be actually needed as prefix. The name passed to the radiobtn driver by the driver should be sufficient.

Ivo

#5 lore raw
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

The first parameter of strcat() must be big enough to contain the whole string.

Will replace it with
sprintf(wrqu->name, "radiobtn/", radiobtn->dev_name);

Or actually, I don't think the radiobtn/ won't be actually needed as prefix. The name passed to the radiobtn driver by the driver should be sufficient.

Updated version,

Signed-off-by Ivo van Doorn <[email protected]>

drivers/input/misc/Kconfig +10 -0
index 4bad588..212caad 100644
@@ -79,4 +79,14 @@ config HP_SDC_RTC
 	  Say Y here if you want to support the built-in real time clock
 	  of the HP SDC controller.
 
+config RADIOBTN
+	tristate "Hardware radio button support"
+	help
+	  Say Y here if you have an integrated WiFi or Bluetooth device
+	  which contains an hardware button for enabling or disabling the radio.
+	  When this driver is used, this driver will make sure the radio will
+	  be correctly enabled and disabled when needed. It will then also
+	  use the created input device to signal user space of this event
+	  which allows userspace to take additional actions.
+
 endif
drivers/input/misc/Makefile +1 -0
index 415c491..9af3d98 100644
@@ -11,3 +11,4 @@ obj-$(CONFIG_INPUT_UINPUT)		+= uinput.o
 obj-$(CONFIG_INPUT_WISTRON_BTNS)	+= wistron_btns.o
 obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_IXP4XX_BEEPER)	+= ixp4xx-beeper.o
+obj-$(CONFIG_RADIOBTN)			+= radiobtn.o
\ No newline at end of file
drivers/input/misc/radiobtn.c new file +163 -0

163 lines not on this page · raw message

include/linux/radiobtn.h new file +84 -0

84 lines not on this page · raw message

#6 lore raw

Am Freitag 02 Juni 2006 16:30 schrieb Ivo van Doorn:

Quoted 7 lines
Quoted 3 lines

Or actually, I don't think the radiobtn/ won't be actually needed as prefix. The name passed to the radiobtn driver by the driver should be sufficient.

Updated version,

Signed-off-by Ivo van Doorn <[email protected]>

I don't like the patch in it's current form. Many notebooks have a number of additional keys that need to be queried/polled using the same interface, but just one button is to control the radio, the rest are multimedia keys that just need to be forwarded to userspace. Or maybe a bluetooth key.

Some systems require suspend/resume support, others remember state of the wireless button automatically. For a perfect example, look at drivers/input/misc/wistron_btns.c.

So you should create an "extra laptop buttons" interface. Though it may be hard to assure that this generalization layer between input system and hardware is still a win for the driver developer.

Stefan

#7 lore raw
Quoted 6 lines · Stefan Rompf

Am Freitag 02 Juni 2006 16:30 schrieb Ivo van Doorn:

Quoted 4 lines
Quoted 3 lines

Or actually, I don't think the radiobtn/ won't be actually needed as prefix. The name passed to the radiobtn driver by the driver should be sufficient.

Quoted 8 lines
Quoted 3 lines

Updated version,

Signed-off-by Ivo van Doorn <[email protected]>

I don't like the patch in it's current form. Many notebooks have a number of additional keys that need to be queried/polled using the same interface, but just one button is to control the radio, the rest are multimedia keys that just need to be forwarded to userspace. Or maybe a bluetooth key.

Except for the bluetooth radio key (which should be supported by the radiobtn interface as well) the other buttons have support through already excisting input devices if I am correct. This radiobtn driver is there to poll the device frequently about the radio state only since that is one of the few buttons that is not sending anything to userspace at the moment.

Ivo

#8 lore raw

Am Sonntag 04 Juni 2006 10:02 schrieb Ivo van Doorn:

Quoted 3 lines

Except for the bluetooth radio key (which should be supported by the radiobtn interface as well) the other buttons have support through already excisting input devices if I am correct.

You are wrong for quite a bunch of laptop models. That's why I pointed you to the wistron_btns driver. Alternatively, look at the acerhk driver
(http://www2.informatik.hu-berlin.de/~tauber/acerhk/). Many systems have a number of additional buttons that need to be handled by a special driver, all sent to userspace, and just one of them to trigger the wireless card. Other models just handle the button in ACPI and generate an additional ACPI event.

Looking at the RT2400-driver, I see what you want to accomplish: Take the view of the WLAN card on the hardware controlled button enable/disable and generate events on it. However, in many cases it is another driver (see above) that sets or clears this state, and this should be the instance to send the input event.

Note that I do not have objections against the driver being included in the kernel - it just does not qualify as generic radiobutton support, but I know it's hard to find a good name ;-)

Looking at the code only: There should be an additional non-polling interface for drivers that can generate events on the own.

Stefan

#9 lore raw
Quoted 6 lines · Stefan Rompf

Am Sonntag 04 Juni 2006 10:02 schrieb Ivo van Doorn:

Quoted 3 lines

Except for the bluetooth radio key (which should be supported by the radiobtn interface as well) the other buttons have support through already excisting input devices if I am correct.

Quoted 6 lines

You are wrong for quite a bunch of laptop models. That's why I pointed you to the wistron_btns driver. Alternatively, look at the acerhk driver
(http://www2.informatik.hu-berlin.de/~tauber/acerhk/). Many systems have a number of additional buttons that need to be handled by a special driver, all sent to userspace, and just one of them to trigger the wireless card. Other models just handle the button in ACPI and generate an additional ACPI event.

Ok, indeed a valid point.
Would it be better when the radio_button structure contains a list
of button structures each with its own poll function and current state.
And the radiobtn will loop through the list after each poll_delay time calling all poll functions. That way drivers can specify themselves which buttons need to be polled.

By renaming enable_radio and disable_radio in the radiobtn structure it could be made more generic for sending a certain event to the device and not only an instruction for the radio.

Quoted 9 lines

Looking at the RT2400-driver, I see what you want to accomplish: Take the view of the WLAN card on the hardware controlled button enable/disable and generate events on it. However, in many cases it is another driver (see above) that sets or clears this state, and this should be the instance to send the input event.

Note that I do not have objections against the driver being included in the kernel - it just does not qualify as generic radiobutton support, but I know it's hard to find a good name ;-)

Thats true. :)
Now lets see how this thing can be made a but more generic. ;)

Quoted 2 lines

Looking at the code only: There should be an additional non-polling interface for drivers that can generate events on the own.

Welll if the enable_radio and disable_radio are being renamed to a more generic send_event for sending an event to the driver or something, something similar can be done for the other way around I think, another handler to send an event from driver to radiobtn. But should such an event also trigger a call back to the driver, or should only the input event be triggered?

Ivo

#10 lore raw
In reply to Stefan Rompf
Quoted 17 lines
Quoted 3 lines

Except for the bluetooth radio key (which should be supported by the radiobtn interface as well) the other buttons have support through already excisting input devices if I am correct.

You are wrong for quite a bunch of laptop models. That's why I pointed you to the wistron_btns driver. Alternatively, look at the acerhk driver
(http://www2.informatik.hu-berlin.de/~tauber/acerhk/). Many systems have a number of additional buttons that need to be handled by a special driver, all sent to userspace, and just one of them to trigger the wireless card. Other models just handle the button in ACPI and generate an additional ACPI event.

Looking at the RT2400-driver, I see what you want to accomplish: Take the view of the WLAN card on the hardware controlled button enable/disable and generate events on it. However, in many cases it is another driver (see above) that sets or clears this state, and this should be the instance to send the input event.

Quoted 6 lines

Note that I do not have objections against the driver being included in the kernel - it just does not qualify as generic radiobutton support, but I know it's hard to find a good name ;-)

Looking at the code only: There should be an additional non-polling interface for drivers that can generate events on the own.

Sorry for the late reply, but I have been quite busy with other things lately. I have created an updated patch, that is more generic than the previous. I have also renamed it to "laptopkey".

With this approach more buttons can be registered,
it includes the optional field to report an update of the key status to the driver that registered it, and it supports for non-polling keys.

By default all events will go over the default input device, but a driver can choose to create additional input devices.

Signed-off-by Ivo van Doorn <[email protected]>

---

drivers/input/misc/Kconfig +8 -0
index 4bad588..097ae8c 100644
@@ -79,4 +79,12 @@ config HP_SDC_RTC
 	  Say Y here if you want to support the built-in real time clock
 	  of the HP SDC controller.
 
+config LAPTOPKEY
+	tristate "Laptop keys support"
+	help
+	 Say Y here if you have laptop with additional keys like hardware
+	 wireless or bluetooth radio control, or other (programmable) keys.
+	 This driver will create an input device to which other hardware
+	 drivers can register their keys to.
+
 endif
drivers/input/misc/Makefile +1 -0
index 415c491..e691fab 100644
@@ -11,3 +11,4 @@ obj-$(CONFIG_INPUT_UINPUT)		+= uinput.o
 obj-$(CONFIG_INPUT_WISTRON_BTNS)	+= wistron_btns.o
 obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_IXP4XX_BEEPER)	+= ixp4xx-beeper.o
+obj-$(CONFIG_LAPTOPKEY)			+= laptopkey.o
drivers/input/misc/laptopkey.c new file +231 -0

231 lines not on this page · raw message

include/linux/laptopkey.h new file +131 -0

131 lines not on this page · raw message

#11 lore raw
Quoted 3 lines · Ivo van Doorn

With this approach more buttons can be registered,
it includes the optional field to report an update of the key status to the driver that registered it, and it supports for non-polling keys.

I think this is not specific to networking anymore, so it should go to lkml. Please be sure to Cc: input devices maintainer, Dmitry Torokhov.

Regarding rfkill button, I talked about that with Vojtech Pavlik (Cc:ed) and he suggests this solution:

- driver is responsible for turning on/off radio when the input device is not opened;
- when something opens the input device, it receives input events and gets responsible to turn on/off the radio (by ioctl or putting the network interfaces up/down).

This is of course not possible for all hardware, but it gives the most flexibility while keeping the possibility to switch of the radio without userspace support.

Thanks,

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs
#12 lore raw
Quoted 17 lines · Jiri Benc
Quoted 3 lines · Ivo van Doorn

With this approach more buttons can be registered,
it includes the optional field to report an update of the key status to the driver that registered it, and it supports for non-polling keys.

I think this is not specific to networking anymore, so it should go to lkml. Please be sure to Cc: input devices maintainer, Dmitry Torokhov.

Regarding rfkill button, I talked about that with Vojtech Pavlik (Cc:ed) and he suggests this solution:

- driver is responsible for turning on/off radio when the input device is not opened;
- when something opens the input device, it receives input events and gets responsible to turn on/off the radio (by ioctl or putting the network interfaces up/down).

Quoted 3 lines

This is of course not possible for all hardware, but it gives the most flexibility while keeping the possibility to switch of the radio without userspace support.

Let me elaborate a little bit on the possible implementation:

1) 802.11 card drivers will implement an input device for each card in the system that has a user-controlled RF-Kill button or switch.

2) 802.11 card drivers will implement an interface to enable/disable the radio, be it through a call, ioctl, or whatever, that is accessible from both the kernel and userspace.

3) ACPI buttons drivers, and keyboard drivers will generate KEY_RFKILL on machines where RF-Kill keys are reported using ACPI events or keyboard scancodes.

3) A rfkill.ko input handler module will be implemented, that listens to the SW_RFKILL and KEY_RFKILL events from all devices in the system, and will enable/disable radios on all 802.11 devices in the system.

The above will make the RF-Kill button work under all real scenarios as user expects - it will enable/disable the radio. In the case where a user has an additional PCMCIA card, both the radios will be disabled by presing the RF-Kill button, which is arguably what the user expects. Even BlueTooth or other RF technologies (CDMA, EDGE) can hook into this mechanism.

4) When userspace wants to take over the control over RF-Kill, and start additional services based on that, it can open the input devices to get the state of the buttons/switches, AND it can issue the EVIOCGRAB ioctl() to prevent the rfkill.ko and any other handlers from getting the events.

This allows simple implementation of dbus notifications and NetworkManager-style configuration of network interfaces.

Signature · 2 lines
Vojtech Pavlik
Director SuSE Labs
#13 lore raw

Hi,

Quoted 17 lines
Quoted 17 lines · Ivo van Doorn
Quoted 3 lines

With this approach more buttons can be registered,
it includes the optional field to report an update of the key status to the driver that registered it, and it supports for non-polling keys.

I think this is not specific to networking anymore, so it should go to lkml. Please be sure to Cc: input devices maintainer, Dmitry Torokhov.

Regarding rfkill button, I talked about that with Vojtech Pavlik (Cc:ed) and he suggests this solution:

- driver is responsible for turning on/off radio when the input device is not opened;
- when something opens the input device, it receives input events and gets responsible to turn on/off the radio (by ioctl or putting the network interfaces up/down).

Quoted 8 lines
Quoted 3 lines

This is of course not possible for all hardware, but it gives the most flexibility while keeping the possibility to switch of the radio without userspace support.

Let me elaborate a little bit on the possible implementation:

1) 802.11 card drivers will implement an input device for each card in the system that has a user-controlled RF-Kill button or switch.

So basicly 1 input device for every single wireless driver that implements the RF-Kill button?
Is there any particular reason for not using 1 input device shared by all?

Quoted 3 lines

2) 802.11 card drivers will implement an interface to enable/disable the radio, be it through a call, ioctl, or whatever, that is accessible from both the kernel and userspace.

Userspace could switch off the radio by using the txpower ioctl of ifdown/ifup. Or should an approach call be implemented?

Quoted 3 lines

3) ACPI buttons drivers, and keyboard drivers will generate KEY_RFKILL on machines where RF-Kill keys are reported using ACPI events or keyboard scancodes.

Why both an input and ACPI event?
With ACPI restricted to x86 only, wouldn't a more generic approach be desired?

Quoted 20 lines

3) A rfkill.ko input handler module will be implemented, that listens to the SW_RFKILL and KEY_RFKILL events from all devices in the system, and will enable/disable radios on all 802.11 devices in the system.

The above will make the RF-Kill button work under all real scenarios as user expects - it will enable/disable the radio. In the case where a user has an additional PCMCIA card, both the radios will be disabled by presing the RF-Kill button, which is arguably what the user expects. Even BlueTooth or other RF technologies (CDMA, EDGE) can hook into this mechanism.

4) When userspace wants to take over the control over RF-Kill, and start additional services based on that, it can open the input devices to get the state of the buttons/switches, AND it can issue the EVIOCGRAB ioctl() to prevent the rfkill.ko and any other handlers from getting the events.

This allows simple implementation of dbus notifications and NetworkManager-style configuration of network interfaces.

#16 lore raw
In reply to Jiri Benc
Quoted 7 lines · Jiri Benc
Quoted 3 lines · Ivo van Doorn

With this approach more buttons can be registered,
it includes the optional field to report an update of the key status to the driver that registered it, and it supports for non-polling keys.

I think this is not specific to networking anymore, so it should go to lkml. Please be sure to Cc: input devices maintainer, Dmitry Torokhov.

Thanks, I am currently discussing the driver with developers from button drivers like acerhk and acpi_acer.
If I am sending the driver to the lkml will depend on their reaction and input for the driver. No use sending drivers to lkml when no other driver will want to use it. ;)

Ivo

#14 lore raw
In reply to Ivo van Doorn
Quoted 11 lines · Ivo van Doorn
Quoted 8 lines
Quoted 3 lines

This is of course not possible for all hardware, but it gives the most flexibility while keeping the possibility to switch of the radio without userspace support.

Let me elaborate a little bit on the possible implementation:

1) 802.11 card drivers will implement an input device for each card in the system that has a user-controlled RF-Kill button or switch.

So basicly 1 input device for every single wireless driver that implements the RF-Kill button?

Yes.

Quoted 1 line

Is there any particular reason for not using 1 input device shared by all?

Yes.

In the unlikely case where there are two devices which implement a rfkill button in the system, the input core doesn't have a way how to express the state of these two different buttons with the same meaning (and hence the same code - KEY_RFKILL) in a single input device.

You'd have to assign a range of codes to the shared device, which goes agains the design of the Linux inpu layer.

Anyway, for the most common case, where you have a single RF-Kill key in the whole system, there will not be any difference to using the shared device.

What do you consider the benefits of using a shared input device?

Quoted 6 lines
Quoted 3 lines

2) 802.11 card drivers will implement an interface to enable/disable the radio, be it through a call, ioctl, or whatever, that is accessible from both the kernel and userspace.

Userspace could switch off the radio by using the txpower ioctl of ifdown/ifup. Or should an approach call be implemented?

I'm an input guy, the details of how to disable the radio I'll leave up to you - the WiFi folks on netdev.

You may want to consider that the radio chip usually synthesizes a frequency that it mixes with the incoming signal to frequency-shift it to a low frequency which then can be demodulated. Because of that, even the receiver, when working, can affect devices nearby. This is why FM radio receivers are not allowed on airplanes.

Hardware RF-Kill disables both RX and TX, by stopping the radio chip. Setting TX power to an extremely low value might not be the same.

On the other hand, you may define in the API that setting TX power to zero also disables the receiver.

Quoted 6 lines
Quoted 3 lines

3) ACPI buttons drivers, and keyboard drivers will generate KEY_RFKILL on machines where RF-Kill keys are reported using ACPI events or keyboard scancodes.

Why both an input and ACPI event?
With ACPI restricted to x86 only, wouldn't a more generic approach be desired?

I was talking about the ACPI EC sending us an event. This is how are ACPI buttons implemented in certain notebooks. I definitely don't want to use the acpi events as received by acpid now as the interface. Sorry for the confusion.

Quoted 19 lines
Quoted 19 lines

3) A rfkill.ko input handler module will be implemented, that listens to the SW_RFKILL and KEY_RFKILL events from all devices in the system, and will enable/disable radios on all 802.11 devices in the system.

The above will make the RF-Kill button work under all real scenarios as user expects - it will enable/disable the radio. In the case where a user has an additional PCMCIA card, both the radios will be disabled by presing the RF-Kill button, which is arguably what the user expects. Even BlueTooth or other RF technologies (CDMA, EDGE) can hook into this mechanism.

4) When userspace wants to take over the control over RF-Kill, and start additional services based on that, it can open the input devices to get the state of the buttons/switches, AND it can issue the EVIOCGRAB ioctl() to prevent the rfkill.ko and any other handlers from getting the events.

This allows simple implementation of dbus notifications and NetworkManager-style configuration of network interfaces.

Signature · 2 lines
Vojtech Pavlik
Director SuSE Labs
#15 lore raw
Quoted 14 lines
Quoted 2 lines

So basicly 1 input device for every single wireless driver that implements the RF-Kill button?

Yes.

Quoted 1 line

Is there any particular reason for not using 1 input device shared by all?

Yes.

In the unlikely case where there are two devices which implement a rfkill button in the system, the input core doesn't have a way how to express the state of these two different buttons with the same meaning (and hence the same code - KEY_RFKILL) in a single input device.

Quoted 8 lines

You'd have to assign a range of codes to the shared device, which goes agains the design of the Linux inpu layer.

Anyway, for the most common case, where you have a single RF-Kill key in the whole system, there will not be any difference to using the shared device.

What do you consider the benefits of using a shared input device?

Well it is a matter of preference, especially on how this rfkill.ko would be implemented. When the user has 2 buttons, should all radios (wifi, bluetooth etc) be switched off by pressing each individual key or just 1 key to switch off everything.
But now that I am further thinking about this, (and looking on how my laptop currently works with 1 wifi button and 1 bluetooth button) perhaps multiple input devices would indeed be best. userspace can decide if more interfaces should be attached to the button or not. And this would be the preferred situation.

Quoted 5 lines
Quoted 2 lines

Userspace could switch off the radio by using the txpower ioctl of ifdown/ifup. Or should an approach call be implemented?

I'm an input guy, the details of how to disable the radio I'll leave up to you - the WiFi folks on netdev.

:)

Quoted 11 lines

You may want to consider that the radio chip usually synthesizes a frequency that it mixes with the incoming signal to frequency-shift it to a low frequency which then can be demodulated. Because of that, even the receiver, when working, can affect devices nearby. This is why FM radio receivers are not allowed on airplanes.

Hardware RF-Kill disables both RX and TX, by stopping the radio chip. Setting TX power to an extremely low value might not be the same.

On the other hand, you may define in the API that setting TX power to zero also disables the receiver.

ok, no need for new ioctl calls in that case I believe.
Using the txpower the radio can be switched on and off, without giving a low or 0 as value. But the decision to use ifup and ifdown or iwconfig txpower on/off could be done later, since it can handled in user space.

Quoted 11 lines
Quoted 6 lines
Quoted 3 lines

3) ACPI buttons drivers, and keyboard drivers will generate KEY_RFKILL on machines where RF-Kill keys are reported using ACPI events or keyboard scancodes.

Why both an input and ACPI event?
With ACPI restricted to x86 only, wouldn't a more generic approach be desired?

I was talking about the ACPI EC sending us an event. This is how are ACPI buttons implemented in certain notebooks. I definitely don't want to use the acpi events as received by acpid now as the interface. Sorry for the confusion.

ah ok. :)

Quoted 20 lines
Quoted 19 lines
Quoted 19 lines

3) A rfkill.ko input handler module will be implemented, that listens to the SW_RFKILL and KEY_RFKILL events from all devices in the system, and will enable/disable radios on all 802.11 devices in the system.

The above will make the RF-Kill button work under all real scenarios as user expects - it will enable/disable the radio. In the case where a user has an additional PCMCIA card, both the radios will be disabled by presing the RF-Kill button, which is arguably what the user expects. Even BlueTooth or other RF technologies (CDMA, EDGE) can hook into this mechanism.

4) When userspace wants to take over the control over RF-Kill, and start additional services based on that, it can open the input devices to get the state of the buttons/switches, AND it can issue the EVIOCGRAB ioctl() to prevent the rfkill.ko and any other handlers from getting the events.

This allows simple implementation of dbus notifications and NetworkManager-style configuration of network interfaces.