Skip to content

Commit 6f40d15

Browse files
Yang LiVudentz
authored andcommitted
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>
1 parent e96d705 commit 6f40d15

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

net/bluetooth/iso.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2289,6 +2289,7 @@ static void iso_disconn_cfm(struct hci_conn *hcon, __u8 reason)
22892289
void iso_recv(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
22902290
{
22912291
struct iso_conn *conn = hcon->iso_data;
2292+
struct skb_shared_hwtstamps *hwts;
22922293
__u16 pb, ts, len, sn;
22932294

22942295
if (!conn)
@@ -2312,13 +2313,16 @@ void iso_recv(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
23122313
if (ts) {
23132314
struct hci_iso_ts_data_hdr *hdr;
23142315

2315-
/* TODO: add timestamp to the packet? */
23162316
hdr = skb_pull_data(skb, HCI_ISO_TS_DATA_HDR_SIZE);
23172317
if (!hdr) {
23182318
BT_ERR("Frame is too short (len %d)", skb->len);
23192319
goto drop;
23202320
}
23212321

2322+
/* Record the timestamp to skb*/
2323+
hwts = skb_hwtstamps(skb);
2324+
hwts->hwtstamp = us_to_ktime(le32_to_cpu(hdr->ts));
2325+
23222326
sn = __le16_to_cpu(hdr->sn);
23232327
len = __le16_to_cpu(hdr->slen);
23242328
} else {

0 commit comments

Comments
 (0)