Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15309000
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类: 嵌入式

2011-01-26 13:20:50

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驱动才能创建,代码如下:
  1. #include <linux/module.h>
  2. #include <linux/init.h>
  3. #include <linux/gpio.h>
  4. #include <linux/rfkill.h>
  5. #include <linux/platform_device.h>

  6. static int rfkill_set_power(void *data, bool blocked);
  7. static struct platform_device *rfkill_pdev;
  8. static struct rfkill *rfkill; /* for driver only */
  9. static struct rfkill_ops rfkill_ops = {
  10.     .set_block = rfkill_set_power,
  11. };

  12. static int rfkill_set_power(void *data, bool blocked)
  13. {
  14.     printk("rfkill to %d\n", blocked);
  15.     return 0;
  16. }

  17. static int __init rfkill_init(void)
  18. {
  19.     int ret = 0;

  20.     rfkill_pdev = platform_device_alloc("rfkill-dummy", -1);
  21.     if (unlikely(!rfkill_pdev))
  22.         return -ENOMEM;
  23.     ret = platform_device_add(rfkill_pdev);
  24.     if (ret) {
  25.         platform_device_put(rfkill_pdev);
  26.         return ret;
  27.     }

  28.     rfkill = rfkill_alloc(rfkill_pdev->name, &rfkill_pdev->dev,
  29.                 RFKILL_TYPE_BLUETOOTH, &rfkill_ops, NULL);

  30.     if (unlikely(!rfkill))
  31.         return -ENOMEM;

  32.     ret = rfkill_register(rfkill);

  33.     if (unlikely(ret)) {
  34.         rfkill_destroy(rfkill);
  35.     }

  36.     return ret;
  37. }

  38. static void __exit rfkill_exit(void)
  39. {
  40.     if (likely(rfkill_pdev))
  41.         platform_device_unregister(rfkill_pdev);

  42.     if (likely(rfkill)) {
  43.         rfkill_unregister(rfkill);
  44.         rfkill_destroy(rfkill);
  45.     }
  46. }

  47. module_init(rfkill_init);
  48. module_exit(rfkill_exit);

  49. MODULE_DESCRIPTION("rfkill-dummy driver");
  50. MODULE_AUTHOR("Luther gliethttp ");
  51. MODULE_LICENSE("GPL");
编译命令为:
make -C ~/kernel M=`pwd` modules
之后需要
insmod rfkill_dummy.ko
chmod 777 /sys/class/rfkill/rfkill0/state
然后UI即可正常enable
阅读(10260) | 评论(2) | 转发(1) |
给主人留下些什么吧!~~