wip(mic): BT-side mic capture infrastructure + host-side diag
In-progress work on DualSense microphone capture over BT. Mic-add tap itself is disabled (was decoding standard input bytes as Opus and producing INT16_MIN garbage on the USB IN endpoint) but everything around it is wired and ready to re-enable once we identify the actual mic transport. Firmware: - src/audio.cpp: Opus decoder on core0, mic_fifo queue, audio_loop mic-in path with decode + mono->stereo + tud_audio_write. Decoder init in audio_init() (creates 48kHz mono OpusDecoder). - src/audio.h: exports mic_add_queue() + per-frame diagnostic accessors (audio_mic_frames, last_decoded, last_want, last_wrote, last_toc). - src/main.cpp on_bt_data(): BT-side instrumentation — counts every INTERRUPT input report, tracks min/max length, OR mask of byte[2], most recent non-0x31 report ID, hex prefix of last 0x31/other/any frame, full content of the longest 0x31 frame seen. Mic-tap call itself stubbed behind `if (false)` pending the real detector. - src/state_mgr.cpp: state_init_data byte 6 (VolumeMic) 0xFF→0x40 (was out of range), byte 9 (MuteControl) 0x0F→0x00 (clear all PowerSave bits — AudioPowerSave was muting DSP). - src/cmd.cpp: two new vendor feature reports — 0xFD returns 32-byte diagnostic state (counters + prefixes), 0xFE returns the longest 0x31 frame in full (up to 80 bytes). Both queryable via /dev/hidraw on Linux from the host script. - src/oled.cpp: Diagnostics screen shows TOC + decode result + USB wrote/want bytes for live BT-side visibility. Host-side: - scripts/mic_diag.sh: subcommands `status`, `capture [secs]`, `watch`, `bt-trace`. The bt-trace subcommand reads the 0xFD feature report via hidraw ioctl, decodes counters + recent prefixes, computes per-second rates. Drastically cuts iteration time — no OLED relay or per-test flash cycle needed. Findings to date: - Upstream/mic's mic-flag bit ((data[2] >> 1) & 1) does NOT match this DS5 firmware; bit 1 of byte[2] is NEVER set. Bit 0 is the standard input report type indicator, not a mic tag — confirmed by stick-bytes appearing as our supposed "Opus prefix". - DS5 sends both report ID 0x01 and 0x31 over BT; the longest frame is a standard 79-byte 0x31 input report with sticks/IMU/touchpad but no audio bytes appended. - Conclusion in progress: the DS5 firmware on this controller is not currently streaming mic over BT at all, even with AllowAudioControl=1, VolumeMic=0x40, AudioPowerSave=0, MicMute=0. Next investigation step: compare against a USB-mode DS5 to see what a real mic stream looks like at the UAC1 layer. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
2209f9b8c7
commit
72f163ca50
+10
@@ -21,5 +21,15 @@ uint8_t audio_peak_haptic(); // 0..255, decays on read
|
||||
// Byte-flow counters for the Diagnostics screen + web emulator.
|
||||
uint32_t audio_usb_frames();
|
||||
uint32_t audio_bt_packets();
|
||||
uint32_t audio_mic_frames(); // count of mic Opus frames decoded + written
|
||||
int32_t audio_mic_last_decoded(); // last opus_decode return — neg = error, 480 = OK
|
||||
uint16_t audio_mic_last_want(); // bytes asked of tud_audio_write
|
||||
uint16_t audio_mic_last_wrote(); // bytes TinyUSB FIFO actually accepted
|
||||
uint8_t audio_mic_last_toc(); // first byte of last Opus packet (frame config)
|
||||
|
||||
// Called from on_bt_data() in main.cpp when the DS5 sends a mic-tagged
|
||||
// 0x31 input report. Buffer must point at MIC_OPUS_SIZE (71) bytes of
|
||||
// Opus payload.
|
||||
void mic_add_queue(const uint8_t *data);
|
||||
|
||||
#endif //DS5_BRIDGE_AUDIO_H
|
||||
Reference in New Issue
Block a user