4949#include "btbcm.h"
5050#include "hci_uart.h"
5151
52+ #ifdef BTCOEX
53+ #include "rtk_coex.h"
54+ #endif
55+
5256#define VERSION "2.3"
5357
5458static const struct hci_uart_proto * hup [HCI_UART_MAX_PROTO ];
@@ -130,7 +134,7 @@ int hci_uart_tx_wakeup(struct hci_uart *hu)
130134
131135 BT_DBG ("" );
132136
133- schedule_work ( & hu -> write_work );
137+ schedule_work_on ( 0 , & hu -> write_work );
134138
135139 return 0 ;
136140}
@@ -142,11 +146,6 @@ static void hci_uart_write_work(struct work_struct *work)
142146 struct hci_dev * hdev = hu -> hdev ;
143147 struct sk_buff * skb ;
144148
145- if (!test_bit (HCI_UART_PROTO_READY , & hu -> flags )) {
146- clear_bit (HCI_UART_SENDING , & hu -> tx_state );
147- return ;
148- }
149-
150149 /* REVISIT: should we cope with bad skbs or ->write() returning
151150 * and error value ?
152151 */
@@ -212,6 +211,10 @@ static int hci_uart_open(struct hci_dev *hdev)
212211{
213212 BT_DBG ("%s %p" , hdev -> name , hdev );
214213
214+ #ifdef BTCOEX
215+ rtk_btcoex_open (hdev );
216+ #endif
217+
215218 /* Nothing to do for UART driver */
216219 return 0 ;
217220}
@@ -245,6 +248,11 @@ static int hci_uart_close(struct hci_dev *hdev)
245248
246249 hci_uart_flush (hdev );
247250 hdev -> flush = NULL ;
251+
252+ #ifdef BTCOEX
253+ rtk_btcoex_close ();
254+ #endif
255+
248256 return 0 ;
249257}
250258
@@ -255,8 +263,12 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
255263
256264 BT_DBG ("%s: type %d len %d" , hdev -> name , bt_cb (skb )-> pkt_type , skb -> len );
257265
258- if (!test_bit (HCI_UART_PROTO_READY , & hu -> flags ))
259- return - EUNATCH ;
266+ #ifdef BTCOEX
267+ if (bt_cb (skb )-> pkt_type == HCI_COMMAND_PKT )
268+ rtk_btcoex_parse_cmd (skb -> data , skb -> len );
269+ if (bt_cb (skb )-> pkt_type == HCI_ACLDATA_PKT )
270+ rtk_btcoex_parse_l2cap_data_tx (skb -> data , skb -> len );
271+ #endif
260272
261273 hu -> proto -> enqueue (hu , skb );
262274
@@ -512,9 +524,9 @@ static void hci_uart_tty_close(struct tty_struct *tty)
512524 if (hdev )
513525 hci_uart_close (hdev );
514526
515- if (test_and_clear_bit (HCI_UART_PROTO_READY , & hu -> flags )) {
516- cancel_work_sync (& hu -> write_work );
527+ cancel_work_sync (& hu -> write_work );
517528
529+ if (test_and_clear_bit (HCI_UART_PROTO_READY , & hu -> flags )) {
518530 if (hdev ) {
519531 if (test_bit (HCI_UART_REGISTERED , & hu -> flags ))
520532 hci_unregister_dev (hdev );
@@ -644,6 +656,10 @@ static int hci_uart_register_dev(struct hci_uart *hu)
644656
645657 set_bit (HCI_UART_REGISTERED , & hu -> flags );
646658
659+ #ifdef BTCOEX
660+ rtk_btcoex_probe (hdev );
661+ #endif
662+
647663 return 0 ;
648664}
649665
@@ -661,15 +677,15 @@ static int hci_uart_set_proto(struct hci_uart *hu, int id)
661677 return err ;
662678
663679 hu -> proto = p ;
680+ set_bit (HCI_UART_PROTO_READY , & hu -> flags );
664681
665682 err = hci_uart_register_dev (hu );
666683 if (err ) {
684+ clear_bit (HCI_UART_PROTO_READY , & hu -> flags );
667685 p -> close (hu );
668686 return err ;
669687 }
670688
671- set_bit (HCI_UART_PROTO_READY , & hu -> flags );
672-
673689 return 0 ;
674690}
675691
@@ -830,6 +846,10 @@ static int __init hci_uart_init(void)
830846 qca_init ();
831847#endif
832848
849+ #ifdef BTCOEX
850+ rtk_btcoex_init ();
851+ #endif
852+
833853 return 0 ;
834854}
835855
@@ -866,6 +886,11 @@ static void __exit hci_uart_exit(void)
866886 err = tty_unregister_ldisc (N_HCI );
867887 if (err )
868888 BT_ERR ("Can't unregister HCI line discipline (%d)" , err );
889+
890+ #ifdef BTCOEX
891+ rtk_btcoex_exit ();
892+ #endif
893+
869894}
870895
871896module_init (hci_uart_init );
0 commit comments