Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: ISO: Support SCM_TIMESTAMPING for ISO TS

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

The ISO ts is based on the controller’s clock domain,
so hardware timestamping (hwtimestamp) must be used.

Ref: Documentation/networking/timestamping.rst,
section 3.1 Hardware Timestamping.

Signed-off-by: Yang Li <yang.li@amlogic.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Yang Li and committed by
Luiz Augusto von Dentz
ef568ae0 7565bc56

+12 -1
+12 -1
net/bluetooth/iso.c
··· 2289 2289 void iso_recv(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) 2290 2290 { 2291 2291 struct iso_conn *conn = hcon->iso_data; 2292 + struct skb_shared_hwtstamps *hwts; 2292 2293 __u16 pb, ts, len, sn; 2293 2294 2294 2295 if (!conn) ··· 2313 2312 if (ts) { 2314 2313 struct hci_iso_ts_data_hdr *hdr; 2315 2314 2316 - /* TODO: add timestamp to the packet? */ 2317 2315 hdr = skb_pull_data(skb, HCI_ISO_TS_DATA_HDR_SIZE); 2318 2316 if (!hdr) { 2319 2317 BT_ERR("Frame is too short (len %d)", skb->len); 2320 2318 goto drop; 2321 2319 } 2320 + 2321 + /* Record the timestamp to skb */ 2322 + hwts = skb_hwtstamps(skb); 2323 + hwts->hwtstamp = us_to_ktime(le32_to_cpu(hdr->ts)); 2322 2324 2323 2325 sn = __le16_to_cpu(hdr->sn); 2324 2326 len = __le16_to_cpu(hdr->slen); ··· 2374 2370 skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), 2375 2371 skb->len); 2376 2372 conn->rx_len = len - skb->len; 2373 + 2374 + /* Copy hw timestamp from skb to rx_skb if present */ 2375 + if (ts) { 2376 + hwts = skb_hwtstamps(conn->rx_skb); 2377 + hwts->hwtstamp = skb_hwtstamps(skb)->hwtstamp; 2378 + } 2379 + 2377 2380 break; 2378 2381 2379 2382 case ISO_CONT: