[MTK] BT Drive Debug Summary

Source: Internet
Author: User
First in Init. Project.rc inside looking for example to find FM BT WiFi GPS and so on ...
# STP, WMT, GPS, FM and BT Driver
Insmod/system/lib/modules/mtk_stp_core.ko
Insmod/system/lib/modules/mtk_stp_uart.ko
Insmod/system/lib/modules/mtk_hif_sdio.ko
Insmod/system/lib/modules/mtk_stp_wmt.ko
Insmod/system/lib/modules/mtk_stp_gps.ko
Insmod/system/lib/modules/mtk_stp_bt.ko
Insmod/system/lib/modules/mtk_fm_drv.ko
Insmod/system/lib/modules/mtk_fm_priv.ko
Insmod/system/lib/modules/mtk_wmt_wifi.ko
Load driver above:
such as Mtk_ find BT driver Stp_bt.ko related files search MTK_STP_BT
Find dependent files related to makefile
Search results:
obj-$ (CONFIG_MTK_COMBO_BT) + = mtk_stp_bt$ (ext_flag). O
mtk_stp_bt$ (ext_flag)-objs: = LINUX/STP_CHRDEV_BT.O
The result is to rely on the upper Linux directory stp_chrdev_bt.o file to find stp_chrdev_bt.c source files, into the observation is exactly the BT driver code, hehe.
First step Search
BT Drive
/beetle/mediatek/kernel/drivers/combo/common/linux/stp_chrdev_bt.c

-->MKNOD/DEV/STPBT C 192 0; Statically manually created device node-->init.rc a static device node created in this way will find the relevant match when the driver is called.
So when the code creates the main device number, there will be a matching device number-->192
In the driver code stp_chrdev_bt.c
#define BT_DEV_MAJOR 192
static int bt_major = Bt_dev_major; /* Dynamic allocation */
Module_param (bt_major, uint, 0);
static int bt_init (void)
440{
441 dev_t dev = MKDEV (bt_major, 0);//create main device number ....
442 int alloc_ret = 0;
443 int cdev_err = 0;
.............
}
Bt_drv.c
PXA.C---> About UART driver related
MTK.C-----> About UART Driver related
HCI_LDIS.C--->hci_uart_init ();-->hci_bcsp.c-->bcsp_init ();
Hci_bcsp.c-->uart_init ();
Hci_bcsp.c-->main (int argc, char *argv[])
PXA.C--->static int serial_pxa_startup (struct uart_port *port) set interrupt-->static inline irqreturn_t SERIAL_PXA_IRQ ( int IRQ, void *dev_id) interrupt processing-->static inline void receive_chars (struct uart_pxa_port *up, int *status) receive data-->tty_fli P_buffer_push (TTY)--Send to Disc
TTY_BUFFER.C--->static void flush_to_ldisc (struct work_struct *work) writes data to Disc-->tty_ldisc.c-->receive_buf ()-->hci_uart_ldisc.receive_buf= hci_uart_tty_receive;-->hci_ldisc.c-->hci_uart_tty_receive--> Give the data to the HCI layer
{
static void Hci_uart_tty_receive (struct tty_struct *tty, const U8 *data, char *flags, int count)
{
struct Hci_uart *hu = (void *) tty->disc_data;


if (!hu | | TTY! = hu->tty)
Return


if (!test_bit (Hci_uart_proto_set, &hu->flags))
Return


Spin_lock (&hu->rx_lock);
Hu->proto->recv (HU, (void *) data, count);
Hu->hdev->stat.byte_rx + = count;
Spin_unlock (&hu->rx_lock);


Tty_unthrottle (TTY);
}
}
HCI_BCSP.C---> static int bcsp_recv (struct hci_uart *hu, void *data, int count) receives Hci_uart data.
--static void Bcsp_complete_rx_pkt (struct hci_uart *hu)-->hci_core.c-->int hci_recv_frame (struct Sk_buff * Skb

BT Data Flow
1 UART Port to obtain the Bluetooth module data;
2 UART Port pass Ldisc to pass a hci_uart;
3 Hci_uart passed on to the BCSP;
4 BCSP passed to the HCI layer
5 HCI passed to L2CAP layer
5 L2cap layer passed to Rfcomm
From the upper to the drive analysis:

Settings.java (Mbluetoothenabler)--localbluetoothadapter.java-->bluetoothadapter.java--> Ibluetooth.java-->ibluetooth.aidl-->bluetoothservice.java-->bluetoothadapterstatemachine.java--> Bluetoothservice.java

BT Power on
Stp_chrdev_bt.c-->bt_open (struct inode *inode,struct file *file)--

---->WMT_EXP.C-->mtk_wcn_wmt_func_on

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.