diff mbox series

[v4,09/14] Bluetooth: Handle MSFT avdtp open event

Message ID 20211119082027.12809-9-kiran.k@intel.com
State New
Headers show
Series [v4,01/14] Bluetooth: Refactor code to read supported codecs in getsockopt | expand

Commit Message

K, Kiran Nov. 19, 2021, 8:20 a.m. UTC
Handle MSFT avdtp open event

Signed-off-by: Kiran K <kiran.k@intel.com>
Reviewed-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Reviewed-by: Srivatsa Ravishankar <ravishankar.srivatsa@intel.com>
---
 net/bluetooth/hci_event.c |  4 +++
 net/bluetooth/msft.c      | 57 ++++++++++++++++++++++++++++++++++++++-
 net/bluetooth/msft.h      |  3 +++
 3 files changed, 63 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index efc5458b1345..70ee07e8f27e 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3812,6 +3812,10 @@  static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb,
 		hci_cc_le_read_transmit_power(hdev, skb);
 		break;
 
+	case MSFT_OP_AVDTP:
+		msft_cc_avdtp(hdev, skb);
+		break;
+
 	default:
 		BT_DBG("%s opcode 0x%4.4x", hdev->name, *opcode);
 		break;
diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index 60ed08d65a06..5953127b3521 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -99,7 +99,6 @@  struct msft_data {
 	__u8 filter_enabled;
 };
 
-#define MSFT_OP_AVDTP			0xfc1e
 struct msft_cp_avdtp {
 	__u8	sub_opcode;
 	__u8	len;
@@ -121,6 +120,13 @@  struct msft_cp_avdtp_open {
 	__u8	caps[0];
 } __packed;
 
+struct msft_rp_avdtp_open {
+	__u8    status;
+	__u8    sub_opcode;
+	__le16  avdtp_handle;
+	__u8    audio_intf_param_cnt;
+} __packed;
+
 static int __msft_add_monitor_pattern(struct hci_dev *hdev,
 				      struct adv_monitor *monitor);
 static int __msft_remove_monitor(struct hci_dev *hdev,
@@ -916,3 +922,52 @@  int msft_avdtp_cmd(struct hci_dev *hdev, struct l2cap_chan *chan,
 fail:
 	return err;
 }
+
+static void msft_cc_avdtp_open(struct hci_dev *hdev, struct sk_buff *skb)
+{
+	struct msft_rp_avdtp_open *rp;
+	struct msft_cp_avdtp_open *sent;
+	struct hci_conn *hconn;
+
+	if (skb->len < sizeof(*rp))
+		return;
+
+	rp = (void *)skb->data;
+
+	sent = hci_sent_cmd_data(hdev, MSFT_OP_AVDTP);
+
+	hconn = hci_conn_hash_lookup_handle(hdev, le16_to_cpu(sent->handle));
+
+	if (!hconn)
+		return;
+
+	/* wake up the task waiting on avdtp handle */
+}
+
+void msft_cc_avdtp(struct hci_dev *hdev, struct sk_buff *skb)
+{
+	void *sent;
+	__u8 status;
+
+	if (skb->len < 2)
+		return;
+
+	status = skb->data[0];
+
+	bt_dev_dbg(hdev, "status 0x%2.2x", status);
+
+	sent = hci_sent_cmd_data(hdev, MSFT_OP_AVDTP);
+	if (!sent)
+		return;
+
+	switch (skb->data[1]) {
+	case MSFT_OP_AVDTP_OPEN:
+		msft_cc_avdtp_open(hdev, skb);
+		break;
+
+	default:
+		bt_dev_err(hdev, "Invalid MSFT sub opcode 0x%2.2x",
+			   skb->data[1]);
+		break;
+	}
+}
diff --git a/net/bluetooth/msft.h b/net/bluetooth/msft.h
index 7628c87e6358..ba26c43431dc 100644
--- a/net/bluetooth/msft.h
+++ b/net/bluetooth/msft.h
@@ -10,6 +10,8 @@ 
 #define MSFT_FEATURE_MASK_CURVE_VALIDITY		BIT(4)
 #define MSFT_FEATURE_MASK_CONCURRENT_ADV_MONITOR	BIT(5)
 
+#define MSFT_OP_AVDTP		0xfc1e
+
 #if IS_ENABLED(CONFIG_BT_MSFTEXT)
 
 bool msft_monitor_supported(struct hci_dev *hdev);
@@ -80,3 +82,4 @@  static inline bool msft_curve_validity(struct hci_dev *hdev)
 
 int msft_avdtp_cmd(struct hci_dev *hdev, struct l2cap_chan *chan,
 		   sockptr_t optval, int optlen);
+void msft_cc_avdtp(struct hci_dev *hdev, struct sk_buff *skb);