Revert "Realtek/rtkbt: remove ACL over HCI support."
authorNolen Johnson <johnsonnolen@gmail.com>
Mon, 10 Jun 2024 19:47:22 +0000 (15:47 -0400)
committerNolen Johnson <johnsonnolen@gmail.com>
Mon, 10 Jun 2024 19:47:44 +0000 (15:47 -0400)
This reverts commit efac17d339cc6e11a6fc54f61f9b823c9d776fb5.

Reason: Broken.
Change-Id: Icf1bc4193b38c43a6db8f6149b20255157001bd3

rtkbt/code/libbt-vendor/include/rtk_btsnoop_net.h
rtkbt/code/libbt-vendor/src/hci_h5.c
rtkbt/code/libbt-vendor/src/rtk_btsnoop_net.c
rtkbt/code/libbt-vendor/src/userial_vendor.c

index 1bb6a4261c97d6fddab1cab03ebac00fd5430c39..8fa21d4b111c7103856b5902aaf9932889d775bb 100755 (executable)
@@ -49,7 +49,7 @@
 
 void rtk_btsnoop_open(void);
 void rtk_btsnoop_close(void);
-void rtk_btsnoop_capture(const HC_BT_HDR *p_buf);
+void rtk_btsnoop_capture(const HC_BT_HDR *p_buf, bool is_rcvd);
 
 void rtk_btsnoop_net_open();
 void rtk_btsnoop_net_close();
index d838edc5200e5adffd83c8e3ec6f83b0eb2a1b65..fc59163a259d5e91201e61eab9499439416520bd 100755 (executable)
@@ -1501,10 +1501,20 @@ static uint8_t h5_complete_rx_pkt(tHCI_H5_CB *h5)
     //H5LogMsg("h5_complete_rx_pkt, pkt_type = %d", pkt_type);
     switch (pkt_type)
     {
+        case HCI_ACLDATA_PKT:
+            pass_up = 1;
+            eventtype = MSG_HC_TO_STACK_HCI_ACL;
+        break;
+
         case HCI_EVENT_PKT:
             pass_up = 1;
             eventtype = MSG_HC_TO_STACK_HCI_EVT;
             break;
+
+        case HCI_SCODATA_PKT:
+            pass_up = 1;
+            eventtype = MSG_HC_TO_STACK_HCI_SCO;
+            break;
         case HCI_COMMAND_PKT:
             pass_up = 1;
             eventtype = MSG_HC_TO_STACK_HCI_ERR;
index 0dea18a12a07066199ab3592939e2eedb2052244..27edcd7dad155c11b175fb0c0853d4368d75b18d 100755 (executable)
@@ -180,7 +180,7 @@ static void rtk_btsnoop_write_packet(serial_data_type_t type, const uint8_t *pac
     pthread_mutex_unlock(&btsnoop_log_lock);
 }
 
-void rtk_btsnoop_capture(const HC_BT_HDR *p_buf) {
+void rtk_btsnoop_capture(const HC_BT_HDR *p_buf, bool is_rcvd) {
   const uint8_t *p = (const uint8_t *)(p_buf + 1) + p_buf->offset;
 
   if (hci_btsnoop_fd == -1)
@@ -192,6 +192,14 @@ void rtk_btsnoop_capture(const HC_BT_HDR *p_buf) {
     else
       rtk_btsnoop_write_packet(HCI_EVENT_PKT, p, false);
       break;
+    case MSG_HC_TO_STACK_HCI_ACL:
+    case MSG_STACK_TO_HC_HCI_ACL:
+      rtk_btsnoop_write_packet(HCI_ACLDATA_PKT, p, is_rcvd);
+      break;
+    case MSG_HC_TO_STACK_HCI_SCO:
+    case MSG_STACK_TO_HC_HCI_SCO:
+      rtk_btsnoop_write_packet(HCI_SCODATA_PKT, p, is_rcvd);
+      break;
     case MSG_STACK_TO_HC_HCI_CMD:
       if(((rtkbt_h5logfilter & 1) == 0) || (*p != 0x94) || (*(p + 1) != 0xfc))
       rtk_btsnoop_write_packet(HCI_COMMAND_PKT, p, true);
index a801aabf08663a08a4d7ab788a498e85996829a0..16cbe9966ca38ff6a33f66f24ea666c7dc8e71f8 100755 (executable)
@@ -855,7 +855,8 @@ static int userial_coex_recv_data_handler(unsigned char * recv_buffer, int total
     unsigned char * p_data = recv_buffer;
     int length = total_length;
     HC_BT_HDR * p_buf;
-    uint16_t len;
+    uint8_t boundary_flag;
+    uint16_t len, handle, acl_length, l2cap_length;
     switch (coex_packet_recv_state) {
         case RTKBT_PACKET_IDLE:
             coex_packet_bytes_need = 1;
@@ -951,11 +952,26 @@ static int userial_coex_recv_data_handler(unsigned char * recv_buffer, int total
                     if(rtk_parse_manager)
                         rtk_parse_manager->rtk_parse_internal_event_intercept(coex_resvered_buffer);
                 break;
+
+                case DATA_TYPE_ACL:
+                    p_buf->event = MSG_HC_TO_STACK_HCI_ACL;
+                    handle =  *(uint16_t *)coex_resvered_buffer;
+                    acl_length = *(uint16_t *)&coex_resvered_buffer[2];
+                    l2cap_length = *(uint16_t *)&coex_resvered_buffer[4];
+                    boundary_flag = RTK_GET_BOUNDARY_FLAG(handle);
+                    if(rtk_parse_manager)
+                        rtk_parse_manager->rtk_parse_l2cap_data(coex_resvered_buffer, 0);
+                break;
+
+                case DATA_TYPE_SCO:
+                    p_buf->event = MSG_HC_TO_STACK_HCI_SCO;
+                break;
+
                 default:
                     p_buf->event = MSG_HC_TO_STACK_HCI_ERR;
                 break;
             }
-            rtk_btsnoop_capture(p_buf);
+            rtk_btsnoop_capture(p_buf, true);
         }
         break;
 
@@ -978,7 +994,8 @@ static void userial_coex_send_data_handler(unsigned char * send_buffer, int tota
     type = send_buffer[0];
     int length = total_length;
     HC_BT_HDR * p_buf;
-    uint16_t len;
+    uint8_t boundary_flag;
+    uint16_t len, handle, acl_length, l2cap_length;
 
     len = BT_HC_HDR_SIZE + (length - 1);
     uint8_t packet[len];
@@ -994,12 +1011,27 @@ static void userial_coex_send_data_handler(unsigned char * send_buffer, int tota
             if(rtk_parse_manager)
                 rtk_parse_manager->rtk_parse_command(&send_buffer[1]);
         break;
+
+        case DATA_TYPE_ACL:
+            p_buf->event = MSG_STACK_TO_HC_HCI_ACL;
+            handle =  *(uint16_t *)&send_buffer[1];
+            acl_length = *(uint16_t *)&send_buffer[3];
+            l2cap_length = *(uint16_t *)&send_buffer[5];
+            boundary_flag = RTK_GET_BOUNDARY_FLAG(handle);
+            if(rtk_parse_manager)
+                rtk_parse_manager->rtk_parse_l2cap_data(&send_buffer[1], 1);
+
+        break;
+
+        case DATA_TYPE_SCO:
+            p_buf->event = MSG_STACK_TO_HC_HCI_SCO;
+        break;
         default:
             p_buf->event = 0;
             ALOGE("%s invalid data type: %d", __func__, type);
         break;
     }
-    rtk_btsnoop_capture(p_buf);
+    rtk_btsnoop_capture(p_buf, false);
 }
 
 static void userial_coex_handler(void *context)