Lines Matching full:h5
18 * H4/H5 specific initialization
413 /**********************h5 releated*************************/
844 * @param h5 realtek h5 struct
847 static RT_U16 h5_get_crc(rtk_hw_cfg_t * h5) in h5_get_crc() argument
850 RT_U8 *data = h5->rx_skb->data + h5->rx_skb->data_len - 2; in h5_get_crc()
853 // return get_unaligned_be16(&h5->rx_skb->data[h5->rx_skb->data_len - 2]); in h5_get_crc()
869 * Slip ecode one byte in h5 proto, as follows:
910 * Decode one byte in h5 proto, as follows:
917 * @param h5 realtek h5 struct
920 static void h5_unslip_one_byte(rtk_hw_cfg_t * h5, unsigned char byte) in h5_unslip_one_byte() argument
925 if (H5_ESCSTATE_NOESC == h5->rx_esc_state) { in h5_unslip_one_byte()
927 h5->rx_esc_state = H5_ESCSTATE_ESC; in h5_unslip_one_byte()
929 memcpy(skb_put(h5->rx_skb, 1), &byte, 1); in h5_unslip_one_byte()
931 if ((h5->rx_skb->data[0] & 0x40) != 0 in h5_unslip_one_byte()
932 && h5->rx_state != H5_W4_CRC) { in h5_unslip_one_byte()
933 h5_crc_update(&h5->message_crc, byte); in h5_unslip_one_byte()
935 h5->rx_count--; in h5_unslip_one_byte()
937 } else if (H5_ESCSTATE_ESC == h5->rx_esc_state) { in h5_unslip_one_byte()
940 memcpy(skb_put(h5->rx_skb, 1), &c0, 1); in h5_unslip_one_byte()
941 if ((h5->rx_skb->data[0] & 0x40) != 0 in h5_unslip_one_byte()
942 && h5->rx_state != H5_W4_CRC) in h5_unslip_one_byte()
943 h5_crc_update(&h5->message_crc, 0xc0); in h5_unslip_one_byte()
944 h5->rx_esc_state = H5_ESCSTATE_NOESC; in h5_unslip_one_byte()
945 h5->rx_count--; in h5_unslip_one_byte()
949 memcpy(skb_put(h5->rx_skb, 1), &db, 1); in h5_unslip_one_byte()
950 if ((h5->rx_skb->data[0] & 0x40) != 0 in h5_unslip_one_byte()
951 && h5->rx_state != H5_W4_CRC) in h5_unslip_one_byte()
952 h5_crc_update(&h5->message_crc, 0xdb); in h5_unslip_one_byte()
953 h5->rx_esc_state = H5_ESCSTATE_NOESC; in h5_unslip_one_byte()
954 h5->rx_count--; in h5_unslip_one_byte()
958 memcpy(skb_put(h5->rx_skb, 1), &oof1, 1); in h5_unslip_one_byte()
959 if ((h5->rx_skb->data[0] & 0x40) != 0 in h5_unslip_one_byte()
960 && h5->rx_state != H5_W4_CRC) in h5_unslip_one_byte()
961 h5_crc_update(&h5->message_crc, oof1); in h5_unslip_one_byte()
962 h5->rx_esc_state = H5_ESCSTATE_NOESC; in h5_unslip_one_byte()
963 h5->rx_count--; in h5_unslip_one_byte()
967 memcpy(skb_put(h5->rx_skb, 1), &oof2, 1); in h5_unslip_one_byte()
968 if ((h5->rx_skb->data[0] & 0x40) != 0 in h5_unslip_one_byte()
969 && h5->rx_state != H5_W4_CRC) in h5_unslip_one_byte()
970 h5_crc_update(&h5->message_crc, oof2); in h5_unslip_one_byte()
971 h5->rx_esc_state = H5_ESCSTATE_NOESC; in h5_unslip_one_byte()
972 h5->rx_count--; in h5_unslip_one_byte()
977 skb_free(h5->rx_skb); in h5_unslip_one_byte()
978 h5->rx_skb = NULL; in h5_unslip_one_byte()
979 h5->rx_state = H5_W4_PKT_DELIMITER; in h5_unslip_one_byte()
980 h5->rx_count = 0; in h5_unslip_one_byte()
987 * Prepare h5 packet, packet format as follow:
997 * @param h5 realtek h5 struct
1001 * @return socket buff after prepare in h5 proto
1003 static struct sk_buff *h5_prepare_pkt(rtk_hw_cfg_t * h5, RT_U8 * data, in h5_prepare_pkt() argument
1029 // Max len of packet: (original len +4(h5 hdr) +2(crc))*2 in h5_prepare_pkt()
1041 hdr[0] = h5->rxseq_txack << 3; in h5_prepare_pkt()
1042 h5->is_txack_req = 0; in h5_prepare_pkt()
1044 //RS_DBG("We request packet no(%u) to card", h5->rxseq_txack); in h5_prepare_pkt()
1045 //RS_DBG("Sending packet with seqno %u and wait %u", h5->msgq_txseq, h5->rxseq_txack); in h5_prepare_pkt()
1048 hdr[0] |= 0x80 + h5->msgq_txseq; in h5_prepare_pkt()
1049 //RS_DBG("Sending packet with seqno(%u)", h5->msgq_txseq); in h5_prepare_pkt()
1050 ++(h5->msgq_txseq); in h5_prepare_pkt()
1051 h5->msgq_txseq = (h5->msgq_txseq) & 0x07; in h5_prepare_pkt()
1054 if (h5->use_crc) in h5_prepare_pkt()
1063 // Put h5 header */ in h5_prepare_pkt()
1067 if (h5->use_crc) in h5_prepare_pkt()
1075 if (h5->use_crc) in h5_prepare_pkt()
1080 if (h5->use_crc) { in h5_prepare_pkt()
1093 * @param h5 realtek h5 struct
1095 static void h5_remove_acked_pkt(rtk_hw_cfg_t * h5) in h5_remove_acked_pkt() argument
1101 seqno = h5->msgq_txseq; in h5_remove_acked_pkt()
1102 //pkts_to_be_removed = GetListLength(h5->unacked); in h5_remove_acked_pkt()
1105 if (h5->rxack == seqno) in h5_remove_acked_pkt()
1112 if (h5->rxack != seqno) { in h5_remove_acked_pkt()
1115 //skb_queue_walk_safe(&h5->unack, skb, tmp) // remove ack'ed packet from h5->unack queue in h5_remove_acked_pkt()
1120 //__skb_unlink(skb, &h5->unack); in h5_remove_acked_pkt()
1124 // if (skb_queue_empty(&h5->unack)) in h5_remove_acked_pkt()
1125 // del_timer(&h5->th5); in h5_remove_acked_pkt()
1126 // spin_unlock_irqrestore(&h5->unack.lock, flags); in h5_remove_acked_pkt()
1323 * after rx data is parsed, and we got a rx frame saved in h5->rx_skb,
1328 * 3. reset h5->rx_state, set rx_skb to null.
1330 * @param h5 realtek h5 struct
1333 static void h5_complete_rx_pkt(rtk_hw_cfg_t * h5) in h5_complete_rx_pkt() argument
1338 h5_hdr = (uint8_t *) (h5->rx_skb->data); in h5_complete_rx_pkt()
1340 RS_DBG("Received reliable seqno %u from card", h5->rxseq_txack); in h5_complete_rx_pkt()
1341 h5->rxseq_txack = H5_HDR_SEQ(h5_hdr) + 1; in h5_complete_rx_pkt()
1342 h5->rxseq_txack %= 8; in h5_complete_rx_pkt()
1343 h5->is_txack_req = 1; in h5_complete_rx_pkt()
1346 h5->rxack = H5_HDR_ACK(h5_hdr); in h5_complete_rx_pkt()
1362 h5_remove_acked_pkt(h5); in h5_complete_rx_pkt()
1365 skb_pull(h5->rx_skb, H5_HDR_SIZE); in h5_complete_rx_pkt()
1366 hci_recv_frame(h5->rx_skb); in h5_complete_rx_pkt()
1368 skb_free(h5->rx_skb); in h5_complete_rx_pkt()
1371 h5->rx_state = H5_W4_PKT_DELIMITER; in h5_complete_rx_pkt()
1372 h5->rx_skb = NULL; in h5_complete_rx_pkt()
1376 * Parse the receive data in h5 proto.
1378 * @param h5 realtek h5 struct
1383 static int h5_recv(rtk_hw_cfg_t * h5, void *data, int count) in h5_recv() argument
1386 //RS_DBG("count %d rx_state %d rx_count %ld", count, h5->rx_state, h5->rx_count); in h5_recv()
1390 if (h5->rx_count) { in h5_recv()
1392 RS_ERR("short h5 packet"); in h5_recv()
1393 skb_free(h5->rx_skb); in h5_recv()
1394 h5->rx_state = H5_W4_PKT_START; in h5_recv()
1395 h5->rx_count = 0; in h5_recv()
1397 h5_unslip_one_byte(h5, *ptr); in h5_recv()
1404 switch (h5->rx_state) { in h5_recv()
1408 (h5->rx_skb->data[0] + h5->rx_skb->data[1] + in h5_recv()
1409 h5->rx_skb->data[2])) != h5->rx_skb->data[3]) { in h5_recv()
1410 RS_ERR("h5 hdr checksum error!!!"); in h5_recv()
1411 skb_free(h5->rx_skb); in h5_recv()
1412 h5->rx_state = H5_W4_PKT_DELIMITER; in h5_recv()
1413 h5->rx_count = 0; in h5_recv()
1417 /* reliable pkt & h5->hdr->SeqNumber != h5->Rxseq_txack */ in h5_recv()
1418 if (h5->rx_skb->data[0] & 0x80 in h5_recv()
1419 && (h5->rx_skb->data[0] & 0x07) != in h5_recv()
1420 h5->rxseq_txack) { in h5_recv()
1423 h5->rx_skb->data[0] & 0x07, in h5_recv()
1424 h5->rxseq_txack); in h5_recv()
1425 h5->is_txack_req = 1; in h5_recv()
1427 skb_free(h5->rx_skb); in h5_recv()
1428 h5->rx_state = H5_W4_PKT_DELIMITER; in h5_recv()
1429 h5->rx_count = 0; in h5_recv()
1434 h5->rx_skb->data[0] & 0x07; in h5_recv()
1438 h5->rx_state = H5_W4_DATA; in h5_recv()
1439 h5->rx_count = in h5_recv()
1440 (h5->rx_skb->data[1] >> 4) + in h5_recv()
1441 (h5->rx_skb->data[2] << 4); in h5_recv()
1446 if (h5->rx_skb->data[0] & 0x40) { in h5_recv()
1447 h5->rx_state = H5_W4_CRC; in h5_recv()
1448 h5->rx_count = 2; in h5_recv()
1450 h5_complete_rx_pkt(h5); in h5_recv()
1456 if (bit_rev16(h5->message_crc) != h5_get_crc(h5)) { in h5_recv()
1459 bit_rev16(h5->message_crc), in h5_recv()
1460 h5_get_crc(h5)); in h5_recv()
1461 skb_free(h5->rx_skb); in h5_recv()
1462 h5->rx_state = H5_W4_PKT_DELIMITER; in h5_recv()
1463 h5->rx_count = 0; in h5_recv()
1466 skb_trim(h5->rx_skb, h5->rx_skb->data_len - 2); in h5_recv()
1467 h5_complete_rx_pkt(h5); in h5_recv()
1473 h5->rx_state = H5_W4_PKT_START; in h5_recv()
1491 h5->rx_state = H5_W4_HDR; in h5_recv()
1492 h5->rx_count = 4; in h5_recv()
1493 h5->rx_esc_state = H5_ESCSTATE_NOESC; in h5_recv()
1494 H5_CRC_INIT(h5->message_crc); in h5_recv()
1497 // Allocate packet. Max len of a H5 pkt= in h5_recv()
1499 h5->rx_skb = skb_alloc(0x1005); in h5_recv()
1500 if (!h5->rx_skb) { in h5_recv()
1501 h5->rx_state = H5_W4_PKT_DELIMITER; in h5_recv()
1502 h5->rx_count = 0; in h5_recv()
1539 * Retry to sync when timeout in h5 proto, max retry times is 10.
1575 RS_ERR("H5 sync timed out\n"); in h5_tsync_sig_alarm()
1580 * Retry to config when timeout in h5 proto, max retry times is 10.
1614 RS_ERR("H5 config timed out\n"); in h5_tconf_sig_alarm()
1619 * Retry to init when timeout in h5 proto, max retry times is 10.
1647 RS_ERR("H5 init process timed out"); in h5_tinit_sig_alarm()
1652 * Retry to download patch when timeout in h5 proto, max retry times is 10.
1675 RS_ERR("H5 patch timed out\n"); in h5_tpatch_sig_alarm()
1680 * Download patch using hci. For h5 proto, not recv reply for 2s will timeout.
2396 * Realtek change speed with h5 proto. Using vendor specified command packet to achieve this.
2458 * Init realtek Bluetooth h5 proto. h5 proto is added by realtek in the right kernel.
2459 * Generally there are two steps: h5 sync and h5 config
2488 /* h5 sync */ in rtk_init_h5()
2493 RS_ERR("H5 Read Sync Response Failed"); in rtk_init_h5()
2512 /* h5 config */ in rtk_init_h5()
2518 RS_ERR("H5 Read Config Response Failed"); in rtk_init_h5()
2536 RS_DBG("H5 init finished\n"); in rtk_init_h5()
3384 RS_INFO("H5 IC"); in rtk_config()