From 9f9d3dd6e9abae3b4718bfa37a58bcbd2666d1c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0erif=20Rami?= Date: Tue, 12 Aug 2025 15:01:37 +0200 Subject: [PATCH] adhere to ALSA standards --- tascam_controls/src/mainwindow.cpp | 16 ++++++++-------- us144mkii.c | 8 +++++--- us144mkii_controls.c | 10 +++++----- us144mkii_pcm.c | 11 +++++------ 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/tascam_controls/src/mainwindow.cpp b/tascam_controls/src/mainwindow.cpp index 68cb2b6..e165d63 100644 --- a/tascam_controls/src/mainwindow.cpp +++ b/tascam_controls/src/mainwindow.cpp @@ -184,10 +184,10 @@ void MainWindow::initUi() { topLevelLayout->addLayout(leftPanel, 1); topLevelLayout->addLayout(middlePanel, 1); - connect(m_lineOutCombo, &QComboBox::currentIndexChanged, this, [this](int index){ onControlChanged("Line OUTPUTS Source", index, m_lineOutCombo); }); - connect(m_digitalOutCombo, &QComboBox::currentIndexChanged, this, [this](int index){ onControlChanged("Digital OUTPUTS Source", index, m_digitalOutCombo); }); - connect(m_capture12Combo, &QComboBox::currentIndexChanged, this, [this](int index){ onControlChanged("ch1 and ch2 Source", index, m_capture12Combo); }); - connect(m_capture34Combo, &QComboBox::currentIndexChanged, this, [this](int index){ onControlChanged("ch3 and ch4 Source", index, m_capture34Combo); }); + connect(m_lineOutCombo, &QComboBox::currentIndexChanged, this, [this](int index){ onControlChanged("Line Playback Source", index, m_lineOutCombo); }); + connect(m_digitalOutCombo, &QComboBox::currentIndexChanged, this, [this](int index){ onControlChanged("Digital Playback Source", index, m_digitalOutCombo); }); + connect(m_capture12Combo, &QComboBox::currentIndexChanged, this, [this](int index){ onControlChanged("Ch1/2 Capture Source", index, m_capture12Combo); }); + connect(m_capture34Combo, &QComboBox::currentIndexChanged, this, [this](int index){ onControlChanged("Ch3/4 Capture Source", index, m_capture34Combo); }); } void MainWindow::loadDynamicSettings() { @@ -197,10 +197,10 @@ void MainWindow::loadDynamicSettings() { long rate_val = m_alsa.getControlValue("Sample Rate"); m_infoLabels["sample_rate"]->setText(rate_val > 0 ? QString("%1 kHz").arg(rate_val / 1000.0, 0, 'f', 1) : "N/A (inactive)"); - updateCombo(m_lineOutCombo, "Line OUTPUTS Source"); - updateCombo(m_digitalOutCombo, "Digital OUTPUTS Source"); - updateCombo(m_capture12Combo, "ch1 and ch2 Source"); - updateCombo(m_capture34Combo, "ch3 and ch4 Source"); + updateCombo(m_lineOutCombo, "Line Playback Source"); + updateCombo(m_digitalOutCombo, "Digital Playback Source"); + updateCombo(m_capture12Combo, "Ch1/2 Capture Source"); + updateCombo(m_capture34Combo, "Ch3/4 Capture Source"); } void MainWindow::updateCombo(QComboBox* combo, const std::string& controlName) { diff --git a/us144mkii.c b/us144mkii.c index de2abea..e452250 100644 --- a/us144mkii.c +++ b/us144mkii.c @@ -412,21 +412,21 @@ static int tascam_probe(struct usb_interface *intf, struct snd_card *card; struct tascam_card *tascam; int err; - - char *handshake_buf __free(kfree); + char *handshake_buf __free(kfree) = NULL; if (dev->speed != USB_SPEED_HIGH) dev_info( &dev->dev, "Device is connected to a USB 1.1 port, this is not supported.\n"); + /* The device has two interfaces; we drive both from this driver. */ if (intf->cur_altsetting->desc.bInterfaceNumber == 1) { tascam = usb_get_intfdata(usb_ifnum_to_if(dev, 0)); if (tascam) { usb_set_intfdata(intf, tascam); tascam->iface1 = intf; } - return 0; + return 0; /* Let the core handle this interface */ } if (dev_idx >= SNDRV_CARDS) { @@ -443,6 +443,7 @@ static int tascam_probe(struct usb_interface *intf, if (!handshake_buf) return -ENOMEM; + /* Perform vendor-specific handshake */ err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), VENDOR_REQ_MODE_CONTROL, RT_D2H_VENDOR_DEV, MODE_VAL_HANDSHAKE_READ, 0x0000, handshake_buf, 1, @@ -459,6 +460,7 @@ static int tascam_probe(struct usb_interface *intf, return -ENODEV; } + /* Set alternate settings to enable audio/MIDI endpoints */ err = usb_set_interface(dev, 0, 1); if (err < 0) { dev_err(&dev->dev, diff --git a/us144mkii_controls.c b/us144mkii_controls.c index bbc8da5..b6ad1b5 100644 --- a/us144mkii_controls.c +++ b/us144mkii_controls.c @@ -100,7 +100,7 @@ static int tascam_line_out_put(struct snd_kcontrol *kcontrol, */ static const struct snd_kcontrol_new tascam_line_out_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Line OUTPUTS Source", + .name = "Line Playback Source", .info = tascam_playback_source_info, .get = tascam_line_out_get, .put = tascam_line_out_put, @@ -171,7 +171,7 @@ static int tascam_digital_out_put(struct snd_kcontrol *kcontrol, */ static const struct snd_kcontrol_new tascam_digital_out_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Digital OUTPUTS Source", + .name = "Digital Playback Source", .info = tascam_playback_source_info, .get = tascam_digital_out_get, .put = tascam_digital_out_put, @@ -259,7 +259,7 @@ static int tascam_capture_12_put(struct snd_kcontrol *kcontrol, */ static const struct snd_kcontrol_new tascam_capture_12_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "ch1 and ch2 Source", + .name = "Ch1/2 Capture Source", .info = tascam_capture_source_info, .get = tascam_capture_12_get, .put = tascam_capture_12_put, @@ -330,7 +330,7 @@ static int tascam_capture_34_put(struct snd_kcontrol *kcontrol, */ static const struct snd_kcontrol_new tascam_capture_34_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "ch3 and ch4 Source", + .name = "Ch3/4 Capture Source", .info = tascam_capture_source_info, .get = tascam_capture_34_get, .put = tascam_capture_34_put, @@ -373,7 +373,7 @@ static int tascam_samplerate_get(struct snd_kcontrol *kcontrol, { struct tascam_card *tascam = (struct tascam_card *)snd_kcontrol_chip(kcontrol); - u8 *buf __free(kfree); + u8 *buf __free(kfree) = NULL; int err; u32 rate = 0; diff --git a/us144mkii_pcm.c b/us144mkii_pcm.c index 5a066ce..61d776b 100644 --- a/us144mkii_pcm.c +++ b/us144mkii_pcm.c @@ -14,7 +14,7 @@ * adjusts the elements to match a target sum, distributing the difference * as evenly as possible. */ -static void fpoInitPattern(unsigned int size, unsigned int *pattern_array, +static void fpo_init_pattern(unsigned int size, unsigned int *pattern_array, unsigned int initial_value, int target_sum) { int diff, i; @@ -115,12 +115,12 @@ void process_capture_routing_us144mkii(struct tascam_card *tascam, int us144mkii_configure_device_for_rate(struct tascam_card *tascam, int rate) { struct usb_device *dev = tascam->dev; + + u8 *rate_payload_buf __free(kfree) = NULL; u16 rate_vendor_wValue; int err = 0; const u8 *current_payload_src; - u8 *rate_payload_buf __free(kfree); - static const u8 payload_44100[] = { 0x44, 0xac, 0x00 }; static const u8 payload_48000[] = { 0x80, 0xbb, 0x00 }; static const u8 payload_88200[] = { 0x88, 0x58, 0x01 }; @@ -239,7 +239,7 @@ int tascam_pcm_hw_params(struct snd_pcm_substream *substream, for (int i = 0; i < 5; i++) { int target_sum = tascam->fpo.sample_rate_khz - tascam->fpo.feedback_offset + i; - fpoInitPattern(8, tascam->fpo.full_frame_patterns[i], + fpo_init_pattern(8, tascam->fpo.full_frame_patterns[i], initial_value, target_sum); } } @@ -269,8 +269,7 @@ int tascam_pcm_trigger(struct snd_pcm_substream *substream, int cmd) bool do_start = false; bool do_stop = false; - { - guard(spinlock_irqsave)(&tascam->lock); + scoped_guard(spinlock_irqsave, &tascam->lock) { switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: