android中bt_enable下set_bluetooth_power设置rfkill打开radio
如果kernel==>Networking support==>RF switch subsystem support没有打开的话
system/bluetooth/bluedroid/bluetooth.c
bt_enable==>
set_bluetooth_power就必须注释掉
否则从UI/settings里将无法启动蓝牙[luther.gliethttp]
但是我本地试验还是不能在UI打开BT,
1. logcat发现
W/bluedroid( 744): open(/sys/class/rfkill/rfkill0/type) failed: No such
file or directory (2)
2. shell中不见rfkill0等设备
/data/glx # ls /sys/class/rfkill/
/data/glx #
3. 内核注册设备的位置为(但是调用他的hci_uart_set_proto函数为什么没有执行呢)
hci_register_dev ==> hdev->rfkill = rfkill_alloc(hdev->name, &hdev->dev,
RFKILL_TYPE_BLUETOOTH, &hci_rfkill_ops, hdev);
所以你还需要一个dummy驱动才能创建,代码如下:
- #include <linux/module.h>
-
#include <linux/init.h>
-
#include <linux/gpio.h>
-
#include <linux/rfkill.h>
-
#include <linux/platform_device.h>
-
-
static int rfkill_set_power(void *data, bool blocked);
-
static struct platform_device *rfkill_pdev;
-
static struct rfkill *rfkill; /* for driver only */
-
static struct rfkill_ops rfkill_ops = {
-
.set_block = rfkill_set_power,
-
};
-
-
static int rfkill_set_power(void *data, bool blocked)
-
{
-
printk("rfkill to %d\n", blocked);
-
return 0;
-
}
-
-
static int __init rfkill_init(void)
-
{
-
int ret = 0;
-
-
rfkill_pdev = platform_device_alloc("rfkill-dummy", -1);
-
if (unlikely(!rfkill_pdev))
-
return -ENOMEM;
-
ret = platform_device_add(rfkill_pdev);
-
if (ret) {
-
platform_device_put(rfkill_pdev);
-
return ret;
-
}
-
-
rfkill = rfkill_alloc(rfkill_pdev->name, &rfkill_pdev->dev,
-
RFKILL_TYPE_BLUETOOTH, &rfkill_ops, NULL);
-
-
if (unlikely(!rfkill))
-
return -ENOMEM;
-
-
ret = rfkill_register(rfkill);
-
-
if (unlikely(ret)) {
-
rfkill_destroy(rfkill);
-
}
-
-
return ret;
-
}
-
-
static void __exit rfkill_exit(void)
-
{
-
if (likely(rfkill_pdev))
-
platform_device_unregister(rfkill_pdev);
-
-
if (likely(rfkill)) {
-
rfkill_unregister(rfkill);
-
rfkill_destroy(rfkill);
-
}
-
}
-
-
module_init(rfkill_init);
-
module_exit(rfkill_exit);
-
-
MODULE_DESCRIPTION("rfkill-dummy driver");
-
MODULE_AUTHOR("Luther gliethttp ");
-
MODULE_LICENSE("GPL");
编译命令为:
make -C ~/kernel M=`pwd` modules
之后需要
insmod rfkill_dummy.ko
chmod 777 /sys/class/rfkill/rfkill0/state
然后UI即可正常enable
阅读(10402) | 评论(2) | 转发(1) |