fix: improve Bluetooth reliability

This commit is contained in:
daniel committed 2026-07-31 18:42:48 +02:00
1 parent 4627ac92fd
commit 18122136dd
20 files changed
+1870 -587

No files matched your search

+32
View File
@@ -988,6 +988,38 @@ namespace Drivers::USB::Xhci {
SendCommand(deqTrb);
}
// -------------------------------------------------------------------------
// ResetBulkOutEndpoint - clear a halted bulk OUT endpoint
// -------------------------------------------------------------------------
void ResetBulkOutEndpoint(uint8_t slotId) {
if (slotId == 0 || slotId > MAX_SLOTS || !g_devices[slotId].Active) return;
UsbDeviceInfo& dev = g_devices[slotId];
if (dev.BulkOutEpNum == 0 || !dev.BulkOutRing) return;
uint8_t dci = dev.BulkOutEpNum * 2;
TRB resetTrb = {};
resetTrb.Control = (TRB_RESET_ENDPOINT << TRB_TYPE_SHIFT)
| ((uint32_t)slotId << 24)
| ((uint32_t)dci << 16);
SendCommand(resetTrb);
// Skip the errored TRB and everything queued behind it. The class
// driver releases the corresponding DMA slots before it sends again.
uint64_t newDeq = dev.BulkOutRingPhys
+ (uint64_t)dev.BulkOutRingEnqueue * sizeof(TRB);
if (dev.BulkOutRingCCS) newDeq |= 1; // DCS bit
TRB deqTrb = {};
deqTrb.Parameter0 = (uint32_t)(newDeq & 0xFFFFFFFF);
deqTrb.Parameter1 = (uint32_t)(newDeq >> 32);
deqTrb.Control = (TRB_SET_TR_DEQUEUE << TRB_TYPE_SHIFT)
| ((uint32_t)slotId << 24)
| ((uint32_t)dci << 16);
SendCommand(deqTrb);
}
// -------------------------------------------------------------------------
// QueueBulkInTransfer
// -------------------------------------------------------------------------