Bluetooth: HFP HF: SCO: Add esco supported pkt type

From the response of read_local_supported_feaatures check if local
device supports eSCO packet type and update it to bt_dev.
Also added sco field in bt_dev

Change-Id: If85b3d24d327a6243318fad89a07375a8253f89b
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
This commit is contained in:
Sathish Narasimman 2017-02-13 11:47:11 +05:30 committed by Johan Hedberg
commit 5490c80383
3 changed files with 71 additions and 0 deletions

View file

@ -167,6 +167,15 @@ struct bt_hci_cmd_hdr {
#define BT_FEAT_HOST_SSP(feat) BT_FEAT_TEST(feat, 1, 0, 0)
#define BT_FEAT_SC(feat) BT_FEAT_TEST(feat, 2, 1, 0)
#define BT_FEAT_LMP_ESCO_CAPABLE(feat) BT_FEAT_TEST(feat, 0, 3, 7)
#define BT_FEAT_HV2_PKT(feat) BT_FEAT_TEST(feat, 0, 1, 4)
#define BT_FEAT_HV3_PKT(feat) BT_FEAT_TEST(feat, 0, 1, 5)
#define BT_FEAT_EV4_PKT(feat) BT_FEAT_TEST(feat, 0, 4, 0)
#define BT_FEAT_EV5_PKT(feat) BT_FEAT_TEST(feat, 0, 4, 1)
#define BT_FEAT_2EV3_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 5)
#define BT_FEAT_3EV3_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 6)
#define BT_FEAT_3SLOT_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 7)
/* LE features */
#define BT_LE_FEAT_BIT_ENC 0
#define BT_LE_FEAT_BIT_CONN_PARAM_REQ 1
@ -225,6 +234,23 @@ struct bt_hci_cmd_hdr {
#define BT_GAP_INIT_CONN_INT_MIN 0x0018 /* 30 ms */
#define BT_GAP_INIT_CONN_INT_MAX 0x0028 /* 50 ms */
/* SCO packet types */
#define HCI_PKT_TYPE_HV1 0x0020
#define HCI_PKT_TYPE_HV2 0x0040
#define HCI_PKT_TYPE_HV3 0x0080
/* eSCO packet types */
#define HCI_PKT_TYPE_ESCO_HV1 0x0001
#define HCI_PKT_TYPE_ESCO_HV2 0x0002
#define HCI_PKT_TYPE_ESCO_HV3 0x0004
#define HCI_PKT_TYPE_ESCO_EV3 0x0008
#define HCI_PKT_TYPE_ESCO_EV4 0x0010
#define HCI_PKT_TYPE_ESCO_EV5 0x0020
#define HCI_PKT_TYPE_ESCO_2EV3 0x0040
#define HCI_PKT_TYPE_ESCO_3EV3 0x0080
#define HCI_PKT_TYPE_ESCO_2EV5 0x0100
#define HCI_PKT_TYPE_ESCO_3EV5 0x0200
/* HCI BR/EDR link types */
#define BT_HCI_SCO 0x00
#define BT_HCI_ACL 0x01

View file

@ -3117,6 +3117,43 @@ static int read_ext_features(void)
return 0;
}
void device_supported_pkt_type(void)
{
/* Device supported features and sco packet types */
if (BT_FEAT_HV2_PKT(bt_dev.features)) {
bt_dev.esco.pkt_type |= (HCI_PKT_TYPE_ESCO_HV2);
}
if (BT_FEAT_HV3_PKT(bt_dev.features)) {
bt_dev.esco.pkt_type |= (HCI_PKT_TYPE_ESCO_HV3);
}
if (BT_FEAT_LMP_ESCO_CAPABLE(bt_dev.features)) {
bt_dev.esco.pkt_type |= (HCI_PKT_TYPE_ESCO_EV3);
}
if (BT_FEAT_EV4_PKT(bt_dev.features)) {
bt_dev.esco.pkt_type |= (HCI_PKT_TYPE_ESCO_EV4);
}
if (BT_FEAT_EV5_PKT(bt_dev.features)) {
bt_dev.esco.pkt_type |= (HCI_PKT_TYPE_ESCO_EV5);
}
if (BT_FEAT_2EV3_PKT(bt_dev.features)) {
bt_dev.esco.pkt_type |= (HCI_PKT_TYPE_ESCO_2EV3);
}
if (BT_FEAT_3EV3_PKT(bt_dev.features)) {
bt_dev.esco.pkt_type |= (HCI_PKT_TYPE_ESCO_3EV3);
}
if (BT_FEAT_3SLOT_PKT(bt_dev.features)) {
bt_dev.esco.pkt_type |= (HCI_PKT_TYPE_ESCO_2EV5 |
HCI_PKT_TYPE_ESCO_3EV5);
}
}
static int br_init(void)
{
struct net_buf *buf;
@ -3133,6 +3170,9 @@ static int br_init(void)
}
}
/* Add local supported packet types to bt_dev */
device_supported_pkt_type();
/* Get BR/EDR buffer size */
err = bt_hci_cmd_send_sync(BT_HCI_OP_READ_BUFFER_SIZE, NULL, &buf);
if (err) {

View file

@ -60,6 +60,10 @@ struct bt_dev_le {
};
#if defined(CONFIG_BLUETOOTH_BREDR)
struct bt_dev_esco {
uint16_t pkt_type;
};
struct bt_dev_br {
/* Max controller's acceptable ACL packet length */
uint16_t mtu;
@ -98,6 +102,7 @@ struct bt_dev {
#if defined(CONFIG_BLUETOOTH_BREDR)
/* BR/EDR controller specific features */
struct bt_dev_br br;
struct bt_dev_esco esco;
#endif
/* Number of commands controller can accept */