1 /****************************************************************************** 2 * 3 * Copyright (C) 2009-2018 Realtek Corporation. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 /****************************************************************************** 19 * 20 * Module Name: 21 * rtk_parse.h 22 * 23 * Abstract: 24 * Contains wifi-bt coex functions implemented by bluedroid stack 25 * 26 * Major Change History: 27 * When Who What 28 * --------------------------------------------------------------- 29 * 2015-12-15 lamparten modified 30 * 2014-10-23 kyle_xu modified 31 * 32 * Notes: 33 * This is designed for wifi-bt Coex in Android 6.0. 34 * 35 ******************************************************************************/ 36 37 #ifndef RTK_PARSE_H 38 #define RTK_PARSE_H 39 40 #pragma once 41 42 #include <stdlib.h> 43 #include "bt_vendor_rtk.h" 44 45 /****************************************************************************** 46 ** Constants & Macros 47 ******************************************************************************/ 48 #define HOST_PROFILE_INFO 49 #define RTKPARSE_NO_INTR(fn) \ 50 do { \ 51 } while ((fn) == -1 && errno == EINTR) 52 /****************************************************************************** 53 ** Type definitions 54 ******************************************************************************/; 55 #define BD_ADDR_LEN 6 /* Device address length */ 56 typedef struct BD_ADDR {unsigned char x[BD_ADDR_LEN];} BD_ADDR; /* Device address */ 57 typedef void (*tINT_CMD_CBACK)(void *p_mem); 58 59 /****************************************************************************** 60 ** Extern variables and functions 61 ******************************************************************************/ 62 63 void set_coex_log_onoff(long int coex_log_onoff); 64 65 /****************************************************************************** 66 ** Functions 67 ******************************************************************************/ 68 typedef struct rtk_parse_manager_t { 69 void (*rtk_parse_internal_event_intercept)(uint8_t *p); 70 71 void (*rtk_parse_l2cap_data)(uint8_t *p, uint8_t direction); 72 73 void (*rtk_parse_init)(void); 74 75 void (*rtk_parse_cleanup)(void); 76 77 void (*rtk_parse_command)(uint8_t *p); 78 79 void (*rtk_add_le_profile)(BD_ADDR bdaddr, uint16_t handle, uint8_t profile_map); 80 81 void (*rtk_delete_le_profile)(BD_ADDR bdaddr, uint16_t handle, uint8_t profile_map); 82 83 void (*rtk_add_le_data_count)(uint8_t data_type); 84 85 void (*rtk_set_bt_on)(uint8_t bt_on); 86 } rtk_parse_manager_t; 87 88 rtk_parse_manager_t *rtk_parse_manager_get_interface(void); 89 90 #ifdef __LITTLE_ENDIAN 91 struct sbc_frame_hdr { 92 uint8_t syncword : 8; /* Sync word */ 93 uint8_t subbands : 1; /* Subbands */ 94 uint8_t allocation_method : 1; /* Allocation method */ 95 uint8_t channel_mode : 2; /* Channel mode */ 96 uint8_t blocks : 2; /* Blocks */ 97 uint8_t sampling_frequency : 2; /* Sampling frequency */ 98 uint8_t bitpool : 8; /* Bitpool */ 99 uint8_t crc_check : 8; /* CRC check */ 100 } __attribute__((packed)); 101 102 /* NOTE: The code is copied from pa. 103 * only the bit field in 8-bit is affected by endian, not the 16-bit or 32-bit. 104 * why? 105 */ 106 struct rtp_header { 107 unsigned cc : 4; 108 unsigned x : 1; 109 unsigned p : 1; 110 unsigned v : 2; 111 112 unsigned pt : 7; 113 unsigned m : 1; 114 115 uint16_t sequence_number; 116 uint32_t timestamp; 117 uint32_t ssrc; 118 uint32_t csrc[0]; 119 } __attribute__((packed)); 120 121 #else 122 /* big endian */ 123 struct sbc_frame_hdr { 124 uint8_t syncword : 8; /* Sync word */ 125 uint8_t sampling_frequency : 2; /* Sampling frequency */ 126 uint8_t blocks : 2; /* Blocks */ 127 uint8_t channel_mode : 2; /* Channel mode */ 128 uint8_t allocation_method : 1; /* Allocation method */ 129 uint8_t subbands : 1; /* Subbands */ 130 uint8_t bitpool : 8; /* Bitpool */ 131 uint8_t crc_check : 8; /* CRC check */ 132 } __attribute__((packed)); 133 134 struct rtp_header { 135 unsigned v : 2; 136 unsigned p : 1; 137 unsigned x : 1; 138 unsigned cc : 4; 139 140 unsigned m : 1; 141 unsigned pt : 7; 142 143 uint16_t sequence_number; 144 uint32_t timestamp; 145 uint32_t ssrc; 146 uint32_t csrc[0]; 147 } __attribute__((packed)); 148 #endif /* __LITTLE_ENDIAN */ 149 150 void hw_process_event(HC_BT_HDR *p_buf); 151 void rtk_vendor_cmd_to_fw(uint16_t opcode, uint8_t parameter_len, uint8_t *parameter, tINT_CMD_CBACK p_cback); 152 153 #endif /* RTK_PARSE_H */ 154