213 Commits

Author SHA1 Message Date
Antoine Sidem 6e7de5a554 Fix wrong latency assignment in audio.c (#25)
* aaudio: fix wrong latency assignment

Due to (likely) copy-pasted code between input and output stream initialisation, the input stream latency was assigned to the output stream structure.

Input and output latency values are actually different, for example on my machine:
```
Latencies for device Digital Mic: in=40 out=42
Latencies for device Codec Output: in=6 out=41
Latencies for device Speaker: in=8 out=19
Latencies for device Bridge Loopback: in=13 out=30
Latencies for device Codec Input: in=47 out=0
```

This may or may not also fix the following, previously common error message: (e.g.)  `aaudio aaudio: invalid position: , pos = 53211761056, buffer size = 16640, period size = 1`. At least, it hasn't appeared since I applied this change. 

Also corrects typos in macro names and an error message.

* aaudio: apply typo corrections of 8d8e0f7 to audio.h
2026-02-26 01:47:32 -06:00
Aun-Ali Zaidi bbdfac953c Merge pull request #24 from craigds/fix-vhci-port-change-notification 2026-02-21 11:26:46 -06:00
Craig de Stigter acbc6d5cec Merge pull request #1 from AdityaGarg8/coldboot
Requested changes
2026-02-20 16:28:34 +13:00
Aditya Garg b6dd8fdab1 Ensure hcd is not NULL before triggering rescan 2026-02-15 20:22:24 +05:30
Aditya Garg 12dd8f92cc Use correct port status change command
Signed-off-by: Aditya Garg <gargaditya08@live.com>
2026-02-15 19:54:45 +05:30
Aditya Garg e9f7bf9148 Don't hardcode 16 ports
Signed-off-by: Aditya Garg <gargaditya08@live.com>
2026-02-15 19:31:34 +05:30
Craig de Stigter da8e6a32d9 vhci: fix hub status bitmap and address review feedback
- Fix hub_status_data() bitmap: port N is stored in bit N via set_bit(),
  so copy the bitmask directly instead of shifting by 1. The previous
  shift mapped port status changes to incorrect bit positions.
- Handle >15 ports by returning a 3rd byte when needed.
- Use pr_info_ratelimited() for event 0x12 logging to avoid potential
  log spam.

Signed-off-by: Craig de Stigter <craig@destigter.nz>
2026-02-14 14:33:46 +13:00
Craig de Stigter e39a7daa8c vhci: handle port status change events from T2 chip
The T2 chip sends event 0x12 on the system event queue when a port's
status changes (e.g. a device finishes initializing). The driver was
silently ignoring this event, and hub_status_data() was hardcoded to
return 0 ("no changes"). Together, these meant that any T2 USB device
not ready during the initial hub scan was never discovered.

This caused intermittent failures where devices such as the FaceTime
camera, Touch Bar, and iBridge network interface would not appear after
boot or resume from suspend/hibernate — depending on a race between the
T2's device initialization and the initial USB hub scan.

Fix this by:
 - Adding a port_change_pending bitmask to struct bce_vhci
 - Handling event 0x12 in handle_system_event() to flag the affected
   port and call usb_hcd_poll_rh_status() to wake the USB framework
 - Implementing hub_status_data() properly to report pending port
   changes via the standard USB hub status bitmap

Tested on MacBookPro15,1 (2018 15" MBP) with kernel 6.18.4-1-t2-plucky.
All 7 VHCI devices now appear reliably at boot and survive
suspend/resume cycles.

Signed-off-by: Craig de Stigter <craig@destigter.nz>
2026-02-14 14:13:00 +13:00
Aun-Ali Zaidi 4882e1b7dc Merge pull request #19 from AdityaGarg8/aur
Fix camera freeze
2025-10-25 13:38:36 -05:00
mnural 47d63cbf1d Fix freezing on turning off camera
Detailed logs and reason behind can be seen here:
https://github.com/t2linux/T2-Debian-and-Ubuntu-Kernel/issues/130#issuecomment-2799130835
2025-10-26 00:04:15 +05:30
Aun-Ali Zaidi 25fd17a2df Merge pull request #22 from AdityaGarg8/6.18-fix
Fix compile errors on 6.18
2025-10-25 13:20:48 -05:00
Aditya Garg d727daf56b Fix compile errors on 6.18 2025-10-25 13:36:49 +05:30
Aditya Garg 41c7d20f0c Fix sparse errors
apple_bce.h was using #pragma once, which is not acceptable by sparse
2025-06-19 12:19:02 -05:00
Aditya Garg 4b0dd258e5 Add patch and module.symvers.cmd to gitignore 2025-06-19 12:19:02 -05:00
Aditya Garg c4c7356dba Fix compile for versions > 6.15
del_timer_sync was renamed to timer_delete_sync in 6.1, and starting from 6.15, the older name was completely removed.
2025-05-08 06:28:43 -05:00
Aditya Garg 639c39ace9 Fix sparse errors
apple_bce.h was using #pragma once, which is not acceptable by sparse
2025-04-14 16:26:49 +05:30
Aditya Garg 418f3af003 Add patch and module.symvers.cmd to gitignore 2025-04-13 11:08:25 +05:30
Aditya Garg 5571a6ca60 Fix build on kernel versions < 6.8
The following error was shown if compiled on kernel versions < 6.8

```
make -C /lib/modules/5.15.0-131-generic/build M=/var/lib/dkms/apple-bce/0.2/build modules
make[1]: Entering directory '/usr/src/linux-headers-5.15.0-131-generic'
  CC [M]  /var/lib/dkms/apple-bce/0.2/build/apple_bce.o
  CC [M]  /var/lib/dkms/apple-bce/0.2/build/mailbox.o
  CC [M]  /var/lib/dkms/apple-bce/0.2/build/queue.o
  CC [M]  /var/lib/dkms/apple-bce/0.2/build/queue_dma.o
  CC [M]  /var/lib/dkms/apple-bce/0.2/build/vhci/vhci.o
  CC [M]  /var/lib/dkms/apple-bce/0.2/build/vhci/queue.o
  CC [M]  /var/lib/dkms/apple-bce/0.2/build/vhci/transfer.o
  CC [M]  /var/lib/dkms/apple-bce/0.2/build/audio/audio.o
  CC [M]  /var/lib/dkms/apple-bce/0.2/build/audio/protocol.o
  CC [M]  /var/lib/dkms/apple-bce/0.2/build/audio/protocol_bce.o
  CC [M]  /var/lib/dkms/apple-bce/0.2/build/audio/pcm.o
/var/lib/dkms/apple-bce/0.2/build/vhci/vhci.c:717:27: error: initialization of ‘int ()(struct usb_hcd, struct usb_device )’ from incompatible pointer type ‘int ()(struct usb_hcd , struct usb_device, unsigned int)’ [-Werror=incompatible-pointer-types]
  717 |         .address_device = bce_vhci_address_device,
      |                           ^~~~~~~
/var/lib/dkms/apple-bce/0.2/build/vhci/vhci.c:717:27: note: (near initialization for ‘bce_vhci_driver.address_device’)
cc1: some warnings being treated as errors
make[2]:  [scripts/Makefile.build:297: /var/lib/dkms/apple-bce/0.2/build/vhci/vhci.o] Error 1
make[2]:  Waiting for unfinished jobs....
make[1]:  [Makefile:1910: /var/lib/dkms/apple-bce/0.2/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.0-131-generic'
make:  [Makefile:22: all] Error 2
```
2025-02-20 03:05:16 -06:00
Orlando Chamberlain 490d2cd3e4 bce: add pci modalias
Note that if the audio part of the module is split out into another module, a similar change will be needed for the separated audio module.
2024-07-10 11:36:57 -05:00
Aditya Garg 7df923b3c8 Fix -Wmissing-prototypes error 2024-05-01 11:00:03 -05:00
Kerem Karabay 7f9a4b1f20 vhci: fix crash on USB device configuration change
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
2024-05-01 11:00:03 -05:00
Aditya Garg 83116fc3e8 Add support for kernel 6.4 (#10)
* Add support for kernel 6.4

* Delete dkms.conf
2023-07-29 00:40:57 -05:00
Aun-Ali Zaidi 7f90a5f604 Merge pull request #9 from kekrby/audio-improvements
aaudio: set the card driver name to AppleT2x{channel count} instead of AppleT2 so that audio configuration files of Macs with different channel counts can coexist together
2023-03-02 18:47:58 -08:00
Aun-Ali Zaidi 6e8d499237 Merge pull request #8 from Redecorating/less_logging
change many info logs to debug
2023-03-02 18:45:27 -08:00
kekrby 4cd61e4f88 aaudio: set the card driver name to AppleT2x{channel count} instead of AppleT2 so that audio configuration files of Macs with different channel counts can coexist together 2022-09-29 20:20:09 +03:00