netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] Bluetooth: ISO: Support SCM_TIMESTAMPING for ISO TS
@ 2025-07-04  5:36 Yang Li via B4 Relay
  2025-07-04  8:49 ` Bastien Nocera
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Yang Li via B4 Relay @ 2025-07-04  5:36 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman
  Cc: linux-bluetooth, netdev, linux-kernel, Yang Li

From: Yang Li <yang.li@amlogic.com>

User-space applications (e.g., PipeWire) depend on
ISO-formatted timestamps for precise audio sync.

Signed-off-by: Yang Li <yang.li@amlogic.com>
---
Changes in v3:
- Change to use hwtimestamp
- Link to v2: https://lore.kernel.org/r/20250702-iso_ts-v2-1-723d199c8068@amlogic.com

Changes in v2:
- Support SOCK_RCVTSTAMPNS via CMSG for ISO sockets
- Link to v1: https://lore.kernel.org/r/20250429-iso_ts-v1-1-e586f30de6cb@amlogic.com
---
 net/bluetooth/iso.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
index fc22782cbeeb..67ff355167d8 100644
--- a/net/bluetooth/iso.c
+++ b/net/bluetooth/iso.c
@@ -2301,13 +2301,21 @@ void iso_recv(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
 		if (ts) {
 			struct hci_iso_ts_data_hdr *hdr;
 
-			/* TODO: add timestamp to the packet? */
 			hdr = skb_pull_data(skb, HCI_ISO_TS_DATA_HDR_SIZE);
 			if (!hdr) {
 				BT_ERR("Frame is too short (len %d)", skb->len);
 				goto drop;
 			}
 
+			/* The ISO ts is based on the controller’s clock domain,
+			 * so hardware timestamping (hwtimestamp) must be used.
+			 * Ref: Documentation/networking/timestamping.rst,
+			 * chapter 3.1 Hardware Timestamping.
+ 			 */
+			struct skb_shared_hwtstamps *hwts = skb_hwtstamps(skb);
+			if (hwts)
+				hwts->hwtstamp = us_to_ktime(le32_to_cpu(hdr->ts));
+
 			len = __le16_to_cpu(hdr->slen);
 		} else {
 			struct hci_iso_data_hdr *hdr;

---
base-commit: 3bc46213b81278f3a9df0324768e152de71eb9fe
change-id: 20250421-iso_ts-c82a300ae784

Best regards,
-- 
Yang Li <yang.li@amlogic.com>



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

end of thread, other threads:[~2025-07-08 15:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-04  5:36 [PATCH v3] Bluetooth: ISO: Support SCM_TIMESTAMPING for ISO TS Yang Li via B4 Relay
2025-07-04  8:49 ` Bastien Nocera
2025-07-07  1:35   ` Yang Li
2025-07-05  1:59 ` Jason Xing
2025-07-07  1:52   ` Yang Li
2025-07-05 20:39 ` Pauli Virtanen
2025-07-07  1:48   ` Yang Li
2025-07-07  7:41     ` Pauli Virtanen
2025-07-07  8:18       ` Yang Li
2025-07-08 15:40         ` Pauli Virtanen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).