All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/3] btdev: pass sent SCO data to bthost
@ 2025-03-05 15:58 Pauli Virtanen
  2025-03-05 15:58 ` [PATCH BlueZ 2/3] bthost: add hooks receiving SCO connections and data Pauli Virtanen
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Pauli Virtanen @ 2025-03-05 15:58 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

Actually send SCO data to the linked connection, if any.
---
 emulator/btdev.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index ec52c5242..c44b52c49 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -2807,6 +2807,10 @@ static int cmd_enhanced_setup_sync_conn_complete(struct btdev *dev,
 done:
 	send_event(dev, BT_HCI_EVT_SYNC_CONN_COMPLETE, &cc, sizeof(cc));
 
+	if (conn)
+		send_event(conn->link->dev, BT_HCI_EVT_SYNC_CONN_COMPLETE,
+							&cc, sizeof(cc));
+
 	return 0;
 }
 
@@ -2853,6 +2857,10 @@ static int cmd_setup_sync_conn_complete(struct btdev *dev, const void *data,
 done:
 	send_event(dev, BT_HCI_EVT_SYNC_CONN_COMPLETE, &cc, sizeof(cc));
 
+	if (conn)
+		send_event(conn->link->dev, BT_HCI_EVT_SYNC_CONN_COMPLETE,
+							&cc, sizeof(cc));
+
 	return 0;
 }
 
@@ -7655,6 +7663,33 @@ static void send_acl(struct btdev *dev, const void *data, uint16_t len)
 	send_packet(conn->link->dev, iov, 3);
 }
 
+static void send_sco(struct btdev *dev, const void *data, uint16_t len)
+{
+	struct bt_hci_sco_hdr hdr;
+	struct iovec iov[2];
+	struct btdev_conn *conn;
+	uint8_t pkt_type = BT_H4_SCO_PKT;
+
+	/* Packet type */
+	iov[0].iov_base = &pkt_type;
+	iov[0].iov_len = sizeof(pkt_type);
+
+	iov[1].iov_base = (void *) (data);
+	iov[1].iov_len = len;
+
+	memcpy(&hdr, data, sizeof(hdr));
+
+	conn = queue_find(dev->conns, match_handle,
+					UINT_TO_PTR(acl_handle(hdr.handle)));
+	if (!conn)
+		return;
+
+	/* TODO: flow control */
+
+	if (conn->link)
+		send_packet(conn->link->dev, iov, 2);
+}
+
 static void send_iso(struct btdev *dev, const void *data, uint16_t len)
 {
 	struct bt_hci_acl_hdr *hdr;
@@ -7702,6 +7737,9 @@ void btdev_receive_h4(struct btdev *btdev, const void *data, uint16_t len)
 	case BT_H4_ACL_PKT:
 		send_acl(btdev, data + 1, len - 1);
 		break;
+	case BT_H4_SCO_PKT:
+		send_sco(btdev, data + 1, len - 1);
+		break;
 	case BT_H4_ISO_PKT:
 		send_iso(btdev, data + 1, len - 1);
 		break;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-03-11 15:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-05 15:58 [PATCH BlueZ 1/3] btdev: pass sent SCO data to bthost Pauli Virtanen
2025-03-05 15:58 ` [PATCH BlueZ 2/3] bthost: add hooks receiving SCO connections and data Pauli Virtanen
2025-03-05 15:58 ` [PATCH BlueZ 3/3] sco-tester: check sent SCO data is received at bthost Pauli Virtanen
2025-03-05 18:58   ` Luiz Augusto von Dentz
2025-03-06 19:37     ` Pauli Virtanen
2025-03-06 20:32       ` Luiz Augusto von Dentz
2025-03-05 17:22 ` [BlueZ,1/3] btdev: pass sent SCO data to bthost bluez.test.bot
2025-03-05 18:28 ` [PATCH BlueZ 1/3] " Luiz Augusto von Dentz
2025-03-11 15:50 ` patchwork-bot+bluetooth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.