us144mkii: minor cleanups - explicit atomic init, capture overflow guard, documentation comments

This commit is contained in:
Marvin 2026-04-22 20:36:35 -03:00
parent ef73de30ec
commit f232c32aee
3 changed files with 16 additions and 0 deletions

View File

@ -218,6 +218,9 @@ static int tascam_probe(struct usb_interface *intf, const struct usb_device_id *
INIT_WORK(&tascam->stop_work, tascam_stop_work_handler);
INIT_WORK(&tascam->stop_pcm_work, tascam_stop_pcm_work_handler);
atomic_set(&tascam->stream_refs, 0);
atomic_set(&tascam->active_urbs, 0);
atomic_set(&tascam->playback_active, 0);
atomic_set(&tascam->capture_active, 0);
strscpy(card->driver, DRIVER_NAME, sizeof(card->driver));
@ -261,6 +264,9 @@ static int tascam_probe(struct usb_interface *intf, const struct usb_device_id *
goto free_card;
}
/* Device firmware needs ~100ms to be ready on cold boot. Without this
* delay, the handshake below fails consistently at boot time and requires
* unplug/replug to work. The msleep is intentional despite adding latency. */
msleep(100);
int handshake_result = -EIO;

View File

@ -184,6 +184,13 @@ void capture_urb_complete(struct urb *urb)
frames = total_available / 64;
new_remainder = total_available % 64;
if (frames > runtime->buffer_size) {
dev_warn(&tascam->dev->dev, "Capture URB returned %d frames, clamping to buffer size %lu\n",
frames, runtime->buffer_size);
new_remainder = (total_available - runtime->buffer_size * 64);
frames = runtime->buffer_size;
}
if (frames > 0) {
spin_lock_irqsave(&tascam->lock, flags);

View File

@ -66,6 +66,9 @@ int us144mkii_configure_device_for_rate(struct tascam_card *tascam, int rate, u1
if (err < 0)
goto out;
/* Note: EP_AUDIO_IN is 0x86 (includes USB_DIR_IN direction bit). The UAC spec
* expects the bare endpoint number (0x06) in wIndex. This device firmware
* tolerates the direction bit, so we keep it as-is rather than risk breakage. */
err = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
RT_H2D_CLASS_EP, UAC_SAMPLING_FREQ_CONTROL,
EP_AUDIO_IN, payload, 3, USB_CTRL_TIMEOUT_MS);