Commit Graph

172 Commits

Author SHA1 Message Date
Marvin ef73de30ec us144mkii: fix moderate bugs - capture robustness, ghost pointer, MIDI cleanup
BUG-09: Buffer partial 64-byte frame remainders across URB completions
to prevent silent data loss when USB bulk transfers return incomplete
chunks. Adds remainder and combined buffers to tascam_card struct.

BUG-10: Distinguish transient USB errors (-EOVERFLOW, -ENOENT, -EPIPE)
from fatal ones in capture completion. Resubmit URB on transient errors
instead of dropping it, preventing capture stream death on transient
USB bandwidth contention or controller glitches.

BUG-11: Return playback_frames_consumed from pointer callback during
ghost playback instead of always returning 0, providing correct
semantics when the callback is queried indirectly.

BUG-12: Unanchor MIDI output URB before returning on error path in
tascam_midi_out_complete to prevent the URB from remaining stuck in
the anchor's pending list.
2026-04-22 20:22:26 -03:00
Marvin f6c59c4f9f Fix significant bugs: probe abort, license mismatch, pause flags, work handler race
- BUG-05: Abort probe with -EIO if device rate initialization fails
  instead of registering a non-functional card.
- BUG-06: Remove SNDRV_PCM_INFO_PAUSE and SNDRV_PCM_INFO_RESUME from
  both capture and playback hw info since true pause is not implemented.
- BUG-07: Change MODULE_LICENSE to 'GPL v2' to match SPDX identifier.
- BUG-08: Hold tascam->lock when reading substream pointers in
  stop_pcm_work_handler to prevent use-after-free on concurrent close.
2026-04-22 19:31:11 -03:00
Marvin 57cbd3d53f Fix critical bugs: MIDI byte order, trigger error handling, playback race condition
- BUG-01: Fix MIDI output packet format - header 0xE0 must be at index 0
  per spec, not index 8. Shift payload to indices 1-8.
- BUG-02: Skip header byte (index 0) when parsing incoming MIDI packets
  so ALSA does not receive spurious Active Sensing events.
- BUG-03: Check return values of submit_urbs in playback trigger;
  report -EIO to ALSA if URB submission fails.
- BUG-04: Cache runtime->dma_area and buffer size under spinlock before
  releasing it, eliminating race condition on concurrent close/hw_params.
2026-04-22 19:26:32 -03:00
Marvin 4c9ff01806 Fix all critical, high, and medium audit issues
Critical fixes:
- Add error_free_urbs cleanup path in tascam_alloc_urbs() to prevent memory leaks on partial URB allocation failure
- Fix tascam_create_midi() with individual cleanup for each failed allocation step

High fixes:
- Check usb_set_interface() return values in probe and resume, log errors with dev_warn()
- Validate handshake_result after retry loop exhaustion; return -EIO if all retries fail
- Stop capture_substream in tascam_stop_pcm_work_handler() to prevent use-after-free during disconnect
- Re-prepare URB descriptors on ghost-to-real takeover to ensure correct sizes
- Add NULL checks before usb_free_coherent() calls in tascam_free_urbs()

Medium fixes:
- Move us144mkii_maybe_start_stream() call after successful URB submission in tascam_midi_open() to prevent stream_refs race condition
- Add cancel_work_sync() calls in probe error path (free_card label)
- Add clarifying comments for error handling flow and ghost-to-real takeover mechanism
- Increment stream_refs only after successful URB submission in maybe_start_stream()

Low fixes:
- Add NULL checks for urb->transfer_buffer in playback_urb_complete() and feedback_urb_complete()
2026-04-21 16:43:31 -03:00
Marvin 3e1e602910 Add boot delay and handshake retry logic
- Add 100ms delay before device initialization to allow USB power stabilization
- Implement retry logic (3 attempts) for initial handshake with 50ms between retries
- Warn on each failed handshake attempt

This addresses enumeration failures during system boot where the US-200
needs additional time to become ready after USB bus power-up.
2026-03-16 08:18:49 -03:00
Marvin b0f6666867 Update README: add fork notice and remove upstream status paragraphs 2026-03-15 17:02:55 -03:00
Marvin 7af9b97e67 Fix compilation: use asm/unaligned.h instead of linux/unaligned.h
The unaligned access functions (get_unaligned_le64, put_unaligned_le32)
are now in asm-generic/unaligned.h and must be included via <asm/unaligned.h>
in newer kernel versions.
2026-03-15 16:49:14 -03:00
Marvin f54d5f0118 Remove archived notice and fork invitation 2026-03-15 15:15:43 -03:00
Marvin 9f4559f746 Update compile instructions to use Gitea repository 2026-03-15 15:14:24 -03:00
Marvin 996d446700 Update README.md to document US-200 support
- Add US-200 to supported devices list alongside US-144MKII
- Update project title and descriptions to mention US-200
- Clarify installation instructions for both device types
2026-03-15 15:13:49 -03:00
Marvin 71662b10e4 Add US-200 support with backward compatibility
- Add USB_PID_TASCAM_US200 (0x8034) product ID constant
- Introduce MODE_VAL_STREAM_START_US200 (0x0032) for device-specific stream mode
- Parameterize us144mkii_configure_device_for_rate() to accept stream_mode value
- Extend model naming logic to display "US-200" for US-200 devices
- Add US-200 to USB device ID table for automatic recognition
2026-03-15 15:09:18 -03:00
Serif 58ae1534f0 Update README.md 2026-01-20 13:13:53 +01:00
Serif 746f9d4ba4
Update README.md 2026-01-20 09:04:26 +01:00
Šerif Rami 8299661b7b codebase refactor & cleanup
- MIDI working without active audio streaming
- overall refactor and cleanup
- card & devices naming fixes
2026-01-19 17:34:06 +01:00
Šerif Rami 6a39e6fd6d driver safety & efficiency improvements
- implement MIDI input batching for reduced ALSA core overhead
- minimize playback spinlock scope by moving memcpy outside the lock
- optimize capture bit-transposition using 8x8 Butterfly algorithm
- use put_unaligned_le32 for safe capture DMA writes
- add defensive checks for stream validity in URB completion handlers
2026-01-19 14:57:47 +01:00
Šerif Rami 2f53fd05bc fix recording while using different playback device 2026-01-19 12:21:42 +01:00
Serif 7f10e1254e edit AUR arch package instructions 2026-01-17 02:54:46 +01:00
Šerif Rami dd9e2f8b81 efficiency & stability improvements 2026-01-11 20:51:30 +01:00
Serif 6951cf48af
Update README to include US-144 audio interface 2026-01-09 16:49:07 +01:00
Šerif Rami 7bfd0b58e9 Update README.md 2026-01-09 16:38:31 +01:00
Šerif Rami c150f968c6 new build script 2026-01-09 16:24:28 +01:00
Šerif Rami e12821f31c frame size fixes 2026-01-07 13:46:09 +01:00
Šerif Rami c379dc65c1 improvements 2026-01-06 20:01:07 +01:00
Šerif Rami 7716f17b21 kernel safety fixes 2025-12-05 23:29:07 +01:00
Šerif Rami d199e9ccaf more fixes & formatting 2025-12-02 16:18:33 +01:00
Serif 2eba5f83c4
Merge pull request #11 from serifpersia/refactor-patch
ALSA: us144mkii: Refactor for improved low-latency performance
2025-12-01 09:59:05 +01:00
Šerif Rami cceb012fe3 ALSA: us144mkii: Refactor for improved low-latency performance
Refactor the TASCAM US-144MKII driver to improve performance and
stability for low-latency audio applications.

The key changes include:
- Improved stream and URB management for more reliable audio streaming.
- Reworked synchronization logic to prevent race conditions.
2025-12-01 09:55:14 +01:00
Šerif Rami 557c55d56b style: Fix checkpatch.pl issues and add Kdocs
Fixed all coding style issues reported by checkpatch.pl.
This includes:
- Trailing statements on new lines.
- Added missing blank lines after declarations.
- Corrected indentation of switch/case statements and labels.
- Added comments for memory barriers.
- Removed unnecessary braces.

Added Kdocs to all public functions and data structures to
improve code documentation.
2025-12-01 09:49:35 +01:00
Šerif Rami 63053cac3f important performance, stability & safety fixes 2025-12-01 09:17:25 +01:00
Šerif Rami d05f560d71 Complete driver refactor 2025-12-01 00:39:35 +01:00
Šerif Rami f5a9550048 raw driver for jack use 2025-11-29 12:51:35 +01:00
Šerif Rami b013e2e0f8 revert back to stable 2025-11-28 11:59:40 +01:00
Serif 89af7a67e3
Replace usb_unlink_anchored_urbs with usb_kill_anchored_urbs 2025-11-27 11:04:03 +01:00
Serif fd32af5022 Improve stream management and synchronization 2025-11-17 10:46:43 +01:00
serifpersia 0cd2e5d732 Merge branch 'main' of https://github.com/serifpersia/us144mkii 2025-11-15 14:01:35 +01:00
serifpersia 48ffc84846 fix capture in non jack use 2025-11-15 14:54:51 +01:00
serifpersia a5f095d871 fix capture in non jack use 2025-11-15 12:49:41 +01:00
Šerif Rami 8b92eb2724 removed test programs 2025-10-14 17:59:00 +02:00
Šerif Rami 88d48174eb performance optimizations 2025-10-14 17:52:09 +02:00
Serif 4f08a0fb56
Update README.md 2025-09-12 15:44:17 +02:00
Serif aefc02d715
Update README.md 2025-09-12 07:58:37 +02:00
Serif 44a15c5df1
Update README.md 2025-09-01 10:58:46 +02:00
Serif ce1980db9d
Update README.md 2025-09-01 10:51:39 +02:00
Šerif Rami 44acef812f removed hwdep experiments 2025-08-25 21:25:58 +02:00
Šerif Rami a244746c21 remove unused driver version define 2025-08-24 18:48:31 +02:00
Šerif Rami 62ff3910c7 new test programs for debugging and use 2025-08-24 17:10:12 +02:00
Šerif Rami 1670d814ab minor handshake and midi fixes 2025-08-23 18:32:16 +02:00
Šerif Rami 7bfaef6c36 midi deref bug fixes 2025-08-19 20:48:29 +02:00
Šerif Rami 8f5cb8b21c control panel gui appimage build script fixes 2025-08-19 18:49:28 +02:00
Šerif Rami b630201c4d intel linux kernel auto report bot ALSA fix 2025-08-19 11:14:40 +02:00