Bluetooth: Add support for Read Local Supported Codecs V2
Use V2 version of read local supported command is controller supports snoop: > HCI Event: Command Complete (0x0e) plen 20 Read Local Supported Codecs V2 (0x04|0x000d) ncmd 1 Status: Success (0x00) Number of supported codecs: 7 Codec: u-law log (0x00) Logical Transport Type: 0x02 Codec supported over BR/EDR SCO and eSCO Codec: A-law log (0x01) Logical Transport Type: 0x02 Codec supported over BR/EDR SCO and eSCO Codec: CVSD (0x02) Logical Transport Type: 0x02 Codec supported over BR/EDR SCO and eSCO Codec: Transparent (0x03) Logical Transport Type: 0x02 Codec supported over BR/EDR SCO and eSCO Codec: Linear PCM (0x04) Logical Transport Type: 0x02 Codec supported over BR/EDR SCO and eSCO Codec: Reserved (0x08) Logical Transport Type: 0x03 Codec supported over BR/EDR ACL Codec supported over BR/EDR SCO and eSCO Codec: mSBC (0x05) Logical Transport Type: 0x03 Codec supported over BR/EDR ACL Codec supported over BR/EDR SCO and eSCO Number of vendor codecs: 0 ...... < HCI Command: Read Local Suppor.. (0x04|0x000e) plen 7 Codec: mSBC (0x05) Logical Transport Type: 0x00 Direction: Input (Host to Controller) (0x00) > HCI Event: Command Complete (0x0e) plen 12 Read Local Supported Codec Capabilities (0x04|0x000e) ncmd 1 Status: Success (0x00) Number of codec capabilities: 1 Capabilities #0: 00 00 11 15 02 33 Signed-off-by: Kiran K <kiran.k@intel.com> Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com> Signed-off-by: Srivatsa Ravishankar <ravishankar.srivatsa@intel.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
8961987f3f
commit
9ae664028a
|
@ -1338,6 +1338,35 @@ struct hci_rp_read_local_pairing_opts {
|
|||
__u8 max_key_size;
|
||||
} __packed;
|
||||
|
||||
#define HCI_OP_READ_LOCAL_CODECS_V2 0x100d
|
||||
struct hci_std_codec_v2 {
|
||||
__u8 id;
|
||||
__u8 transport;
|
||||
} __packed;
|
||||
|
||||
struct hci_std_codecs_v2 {
|
||||
__u8 num;
|
||||
struct hci_std_codec_v2 codec[];
|
||||
} __packed;
|
||||
|
||||
struct hci_vnd_codec_v2 {
|
||||
__u8 id;
|
||||
__le16 cid;
|
||||
__le16 vid;
|
||||
__u8 transport;
|
||||
} __packed;
|
||||
|
||||
struct hci_vnd_codecs_v2 {
|
||||
__u8 num;
|
||||
struct hci_vnd_codec_v2 codec[];
|
||||
} __packed;
|
||||
|
||||
struct hci_rp_read_local_supported_codecs_v2 {
|
||||
__u8 status;
|
||||
struct hci_std_codecs_v2 std_codecs;
|
||||
struct hci_vnd_codecs_v2 vendor_codecs;
|
||||
} __packed;
|
||||
|
||||
#define HCI_OP_READ_LOCAL_CODEC_CAPS 0x100e
|
||||
struct hci_op_read_local_codec_caps {
|
||||
__u8 id;
|
||||
|
|
|
@ -170,3 +170,69 @@ void hci_read_supported_codecs(struct hci_dev *hdev)
|
|||
error:
|
||||
kfree_skb(skb);
|
||||
}
|
||||
|
||||
void hci_read_supported_codecs_v2(struct hci_dev *hdev)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
struct hci_rp_read_local_supported_codecs_v2 *rp;
|
||||
struct hci_std_codecs_v2 *std_codecs;
|
||||
struct hci_vnd_codecs_v2 *vnd_codecs;
|
||||
struct hci_op_read_local_codec_caps caps;
|
||||
__u8 i;
|
||||
|
||||
skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_CODECS_V2, 0, NULL,
|
||||
HCI_CMD_TIMEOUT);
|
||||
|
||||
if (IS_ERR(skb)) {
|
||||
bt_dev_err(hdev, "Failed to read local supported codecs (%ld)",
|
||||
PTR_ERR(skb));
|
||||
return;
|
||||
}
|
||||
|
||||
if (skb->len < sizeof(*rp))
|
||||
goto error;
|
||||
|
||||
rp = (void *)skb->data;
|
||||
|
||||
if (rp->status)
|
||||
goto error;
|
||||
|
||||
skb_pull(skb, sizeof(rp->status));
|
||||
|
||||
std_codecs = (void *)skb->data;
|
||||
|
||||
/* check for payload data length before accessing */
|
||||
if (skb->len < flex_array_size(std_codecs, codec, std_codecs->num)
|
||||
+ sizeof(std_codecs->num))
|
||||
goto error;
|
||||
|
||||
memset(&caps, 0, sizeof(caps));
|
||||
|
||||
for (i = 0; i < std_codecs->num; i++) {
|
||||
caps.id = std_codecs->codec[i].id;
|
||||
hci_read_codec_capabilities(hdev, std_codecs->codec[i].transport,
|
||||
&caps);
|
||||
}
|
||||
|
||||
skb_pull(skb, flex_array_size(std_codecs, codec, std_codecs->num)
|
||||
+ sizeof(std_codecs->num));
|
||||
|
||||
vnd_codecs = (void *)skb->data;
|
||||
|
||||
/* check for payload data length before accessing */
|
||||
if (skb->len <
|
||||
flex_array_size(vnd_codecs, codec, vnd_codecs->num)
|
||||
+ sizeof(vnd_codecs->num))
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < vnd_codecs->num; i++) {
|
||||
caps.id = 0xFF;
|
||||
caps.cid = vnd_codecs->codec[i].cid;
|
||||
caps.vid = vnd_codecs->codec[i].vid;
|
||||
hci_read_codec_capabilities(hdev, vnd_codecs->codec[i].transport,
|
||||
&caps);
|
||||
}
|
||||
|
||||
error:
|
||||
kfree_skb(skb);
|
||||
}
|
||||
|
|
|
@ -3,4 +3,5 @@
|
|||
/* Copyright (C) 2014 Intel Corporation */
|
||||
|
||||
void hci_read_supported_codecs(struct hci_dev *hdev);
|
||||
void hci_read_supported_codecs_v2(struct hci_dev *hdev);
|
||||
void hci_codec_list_clear(struct list_head *codec_list);
|
||||
|
|
|
@ -935,7 +935,9 @@ static int __hci_init(struct hci_dev *hdev)
|
|||
return err;
|
||||
|
||||
/* Read local codec list if the HCI command is supported */
|
||||
if (hdev->commands[29] & 0x20)
|
||||
if (hdev->commands[45] & 0x04)
|
||||
hci_read_supported_codecs_v2(hdev);
|
||||
else if (hdev->commands[29] & 0x20)
|
||||
hci_read_supported_codecs(hdev);
|
||||
|
||||
/* This function is only called when the controller is actually in
|
||||
|
|
Loading…
Reference in New Issue