Kernel中bluetooth相关的config选项

来源:互联网 发布:8101e网卡驱动 mac 编辑:程序博客网 时间:2024/05/16 05:55

         有了前几篇对bluetooth的初步了解,今天晓东就和大家正式开始bluetooth的代码阅读了。在开写这篇文章之前,晓东也很纠结,究竟该从哪里开始着手写相关的内容。最初的打算是准备从蓝牙的开关开始着手的,这是一条大家很好理解也很容易上手的路线。但后来好好想想,还是放弃了这样的想法,因为,我们的这次的系列文章准备稍微讲得深入一点,协议层是肯定要涉及的,而不是简单的浮在JNI之上去分析。所以,今天我们首先从kernel中的config选项着手,先来分析一下若想使用蓝牙,在kernel中需要选上哪些选项。

         我们在《Android4.0Bluetooth的代码结构》一文中提到,kernel中的代码包含两个部分,一个部分是stack的,一个部分是driver的。stack的位于kernel/net/bluetooth目录下,那么我们就去这个目录下的MakefileKconfig来看一下吧:

menuconfig BTtristate "Bluetooth subsystem support"……      Say Y here to compile Bluetooth support into the kernel or say M to      compile it as module (bluetooth).

毫无疑问,这里我们要把bluetooth编译进kernel,这个是必不可少的了,选择Y,基本上我们是不会把stack相关的内容编译成module模式的。

config BT_L2CAP    bool "L2CAP protocol support"    select CRC16    select CRYPTO    select CRYPTO_BLKCIPHER    select CRYPTO_AES    select CRYPTO_ECB    help      L2CAP (Logical Link Control and Adaptation Protocol) provides      connection oriented and connection-less data transport.  L2CAP      support is required for most Bluetooth applications.

从注释上可以清楚地看到,L2CAP对大多数的蓝牙应用是不可缺少的。事实上也是如此,无论我们是听音乐,传文件,我们都需要在L2CAP链路上建立相应的profile,所以,这里没有什么异议地选上吧。

config BT_SCO    bool "SCO links support"    help      SCO link provides voice transport over Bluetooth.  SCO support is      required for voice applications like Headset and Audio.

SCO链路是用来打电话的,所以一般对手机而言,这里是要选上的,我们这里也同样选上。

source "net/bluetooth/rfcomm/Kconfig"

下面就到了rfcommKconfig选项,

config BT_RFCOMM    tristate "RFCOMM protocol support"    depends on BT && BT_L2CAP    help      RFCOMM provides connection oriented stream transport.  RFCOMM      support is required for Dialup Networking, OBEX and other Bluetooth      applications.

很明显可以看到他是OBEX层的支撑,OBEX是我们文件传输OPP的支撑,所以,要想能够传输文件,rfcomm是不可缺少的,选上吧。

config BT_RFCOMM_TTY    bool "RFCOMM TTY support"    depends on BT_RFCOMM    help      This option enables TTY emulation support for RFCOMM channels.

这个是rfcomm的模拟串口的功能,可以使能,若是实在不想使能应该也没有关系吧。不选应该问题也不大,不过晓东是选上的,多选也没有关系啦。

继续回到上一层的Kconfig文件,source "net/bluetooth/bnep/Kconfig",到了bnep的目录

config BT_BNEP    tristate "BNEP protocol support"    depends on BT && BT_L2CAP    select CRC32    help      BNEP (Bluetooth Network Encapsulation Protocol) is Ethernet      emulation layer on top of Bluetooth.  BNEP is required for      Bluetooth PAN (Personal Area Network).

这里可以看到,这个选项是用来支持PAN的,就是通过蓝牙共享上网,有点类似wifisoft ap(共享热点),Android4.0之后是支持的,所以我们也选上吧。

config BT_BNEP_MC_FILTER    bool "Multicast filter support"    depends on BT_BNEP    help      This option enables the multicast filter support for BNEP.config BT_BNEP_PROTO_FILTER    bool "Protocol filter support"    depends on BT_BNEP    help      This option enables the protocol filter support for BNEP.

这两个是多路filterprotocol filter的支持,这里也选上吧。

继续看bluetooth下的Kconfig文件,source "net/bluetooth/cmtp/Kconfig",这次进入了cmtp目录,我们也去看一下

config BT_CMTP    tristate "CMTP protocol support"    depends on BT && BT_L2CAP && ISDN_CAPI    help      CMTP (CAPI Message Transport Protocol) is a transport layer      for CAPI messages.  CMTP is required for the Bluetooth Common      ISDN Access Profile. 

这个是用来支持CAPI的,我们好像用不到,可以不选。

继续看source "net/bluetooth/hidp/Kconfig"如下:

config BT_HIDP    tristate "HIDP protocol support"    depends on BT && BT_L2CAP && INPUT && HID_SUPPORT    select HID    help      HIDP (Human Interface Device Protocol) is a transport layer      for HID reports.  HIDP is required for the Bluetooth Human      Interface Device Profile.

这个是用来支持HID设备的,比如蓝牙鼠标,蓝牙键盘,毫无疑问若是在平板上,这个是非常重要的,在手机平台的话选不选意义就不大了,晓东会把这里选上的。

最后就是source "drivers/bluetooth/Kconfig",一下子就到drvier下面的Kconfig了,去看看吧:

config BT_HCIBTUSB    tristate "HCI USB driver"    depends on USB……config BT_HCIBTSDIO    tristate "HCI SDIO driver"    depends on MMC……config BT_HCIUART    tristate "HCI UART driver"……

3个就放到一起来看了,是用来表示接口的,有USB,SDIO,UART。晓东这里选择的是UART的接口,一般而言,在手机方案上,uart会多一点,在平板方案上,usb则会多一点。

选择了这个之后,就是各家方案的具体协议的driver了:

config BT_HCIUART_BCSP    bool "BCSP protocol support"    depends on BT_HCIUART

比较多,有H4BCSP什么的,这里就写成一个csrdrvier的选项为例,别的就不写了。一般而言,这里都是厂商自己开发加入的。

config BT_SINGLE_LINK        tristate "Bluetooth single link"        help          This enables the Bluetooth driver for single link.

最后再提一下,single link的选项,好坑啊,晓东当时有一次不小心把这个选上了,发现只能连一个链路,就是比如配对了一个手机,就不能连耳机了。呵呵,所以,这个就不要选了吧。

至此,Kernel中的config选项就介绍完毕了。选上他们,编译内核吧。

 

 


 

原创粉丝点击