1 /* 2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include "stack/include/bt_types.h" 20 #include "stack/include/hcidefs.h" 21 22 /** 23 * Create a bitmask of packet types from the remote feature 24 */ 25 class PeerPacketTypes { 26 public: 27 struct { 28 uint16_t supported{0}; 29 uint16_t unsupported{0}; 30 } acl, sco; 31 PeerPacketTypes(const BD_FEATURES & features)32 PeerPacketTypes(const BD_FEATURES& features) { 33 /* 3 and 5 slot packets? */ 34 if (HCI_3_SLOT_PACKETS_SUPPORTED(features)) 35 acl.supported |= (HCI_PKT_TYPES_MASK_DH3 | HCI_PKT_TYPES_MASK_DM3); 36 37 if (HCI_5_SLOT_PACKETS_SUPPORTED(features)) 38 acl.supported |= HCI_PKT_TYPES_MASK_DH5 | HCI_PKT_TYPES_MASK_DM5; 39 40 /* 2 and 3 MPS support? */ 41 if (!HCI_EDR_ACL_2MPS_SUPPORTED(features)) 42 /* Not supported. Add 'not_supported' mask for all 2MPS packet types */ 43 acl.unsupported |= 44 (HCI_PKT_TYPES_MASK_NO_2_DH1 | HCI_PKT_TYPES_MASK_NO_2_DH3 | 45 HCI_PKT_TYPES_MASK_NO_2_DH5); 46 47 if (!HCI_EDR_ACL_3MPS_SUPPORTED(features)) 48 /* Not supported. Add 'not_supported' mask for all 3MPS packet types */ 49 acl.unsupported |= 50 (HCI_PKT_TYPES_MASK_NO_3_DH1 | HCI_PKT_TYPES_MASK_NO_3_DH3 | 51 HCI_PKT_TYPES_MASK_NO_3_DH5); 52 53 /* EDR 3 and 5 slot support? */ 54 if (HCI_EDR_ACL_2MPS_SUPPORTED(features) || 55 HCI_EDR_ACL_3MPS_SUPPORTED(features)) { 56 if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(features)) 57 /* Not supported. Add 'not_supported' mask for all 3-slot EDR packet 58 * types 59 */ 60 acl.unsupported |= 61 (HCI_PKT_TYPES_MASK_NO_2_DH3 | HCI_PKT_TYPES_MASK_NO_3_DH3); 62 63 if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(features)) 64 /* Not supported. Add 'not_supported' mask for all 5-slot EDR packet 65 * types 66 */ 67 acl.unsupported |= 68 (HCI_PKT_TYPES_MASK_NO_2_DH5 | HCI_PKT_TYPES_MASK_NO_3_DH5); 69 } 70 } 71 }; 72