Commit graph

82 commits

Author SHA1 Message Date
Geoffrey D. Bennett 762e6af398 ALSA: scarlett2: Increase mixer range to +12dB
The values loaded into the mixer are 16-bit values, with 8192
representing 0dB, going up to a current maximum of 16345 (+6dB). All
supported interfaces have no problem going up to 32612 (+12dB), so
update SCARLETT2_MIXER_MAX_DB and scarlett2_mixer_values[] to allow
for this.

Tested with:
- Scarlett 2nd Gen 6i6, 18i8, 18i20
- Scarlett 3rd Gen 4i4, 8i6, 18i8, 18i20
- Scarlett 4th Gen Solo, 2i2, 4i4
- Clarett+ 2Pre, 4Pre, 8Pre
- Vocaster One and Two

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/Zj+gYT4F2XeKTD93@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-05-12 11:43:11 +02:00
Geoffrey D. Bennett d5ca9ad58e ALSA: scarlett2: Add S/PDIF source selection controls
Add S/PDIF Source/Digital I/O Mode selection controls for the Scarlett
3rd Gen 18i8/18i20 and Clarett 4Pre/8Pre interfaces. These models have
both coax S/PDIF and optical inputs, and the optical inputs are
switchable between being used as S/PDIF and ADAT inputs. The Scarlett
3rd Gen 18i20 also has a "Dual ADAT" mode for 8-channel audio at
88.2/96kHz.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/Zj8zCTjzPsTDENN+@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-05-12 11:41:07 +02:00
Nathan Chancellor 3a56855bb5 ALSA: scarlett2: Zero initialize ret in scarlett2_ag_target_ctl_get()
Clang warns (or errors with CONFIG_WERROR):

  sound/usb/mixer_scarlett2.c:3697:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
   3697 |         if (private->autogain_updated) {
        |             ^~~~~~~~~~~~~~~~~~~~~~~~~
  sound/usb/mixer_scarlett2.c:3707:9: note: uninitialized use occurs here
   3707 |         return err;
        |                ^~~
  sound/usb/mixer_scarlett2.c:3697:2: note: remove the 'if' if its condition is always true
   3697 |         if (private->autogain_updated) {
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  sound/usb/mixer_scarlett2.c:3688:9: note: initialize the variable 'err' to silence this warning
   3688 |         int err;
        |                ^
        |                 = 0
  1 error generated.

Initialize ret to zero to ensure ret is initialized in all paths within
scarlett2_ag_target_ctl_get(), which matches the style of other
functions in this driver.

Fixes: e30ea5340c ("ALSA: scarlett2: Add autogain target controls")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Message-ID: <20240419-alsa-scarlett2-fix-wsometimes-uninitialized-v1-1-e2ace8642e08@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-04-21 19:30:53 +02:00
Geoffrey D. Bennett 5738cf65e8 ALSA: scarlett2: Add Bluetooth volume control for Vocaster Two
The Vocaster Two has a Bluetooth module with a volume control. Add a
corresponding ALSA mixer control.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <b78687f7243142a4466f63c0aee9742b44ee395d.1710264833.git.g@b4.vu>
2024-04-18 08:31:14 +02:00
Geoffrey D. Bennett e30ea5340c ALSA: scarlett2: Add autogain target controls
The Scarlett 4th Gen and Vocaster interfaces allow the autogain target
dBFS value(s) to be configured. Add Mean and Peak Target controls for
4th Gen, and a Hot Target control for Vocaster.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <33d7f6dc965ab09522361ec99745a0685e4b8272.1710264833.git.g@b4.vu>
2024-04-18 08:31:14 +02:00
Geoffrey D. Bennett 16a7b277c4 ALSA: scarlett2: Add support for Focusrite Vocaster One and Two
Add Focusrite Vocaster One and Two USB IDs, notification arrays,
config sets, and device info data.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <5fb48555a8db7bb322b25784b165829357cd6e42.1710264833.git.g@b4.vu>
2024-04-18 08:31:14 +02:00
Geoffrey D. Bennett b64678eb4e ALSA: scarlett2: Add DSP controls
Add filter and compressor DSP controls for the Vocaster interfaces.
Mark scarlett2_notify_input_dsp() as __always_unused until it gets
used when the Vocaster callback function array is added.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <a45316f79600b862dae38da24f13def638b06476.1710264833.git.g@b4.vu>
2024-04-18 08:31:14 +02:00
Geoffrey D. Bennett bff5421a2c ALSA: scarlett2: Add input mute controls
Add controls for the input mute switches that the Vocaster interfaces
have. Mark scarlett2_notify_input_mute() as __always_unused until it
gets used when the Vocaster callback function array is added.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <3b384b4e759241bd06f0c223e9f4f00467d88318.1710264833.git.g@b4.vu>
2024-04-18 08:31:14 +02:00
Geoffrey D. Bennett 23715a2176 ALSA: scarlett2: Define autogain status texts per-config-set
The autogain status texts are different for Vocaster vs. Scarlett 4th
Gen, so make them configurable per-config-set.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <b1adcd3dc48117d4ebe16812eeb7f1dbf1ede472.1710264833.git.g@b4.vu>
2024-04-18 08:31:14 +02:00
Geoffrey D. Bennett 87b73d48a5 ALSA: scarlett2: Define the maximum preamp input gain per-config-set
Remove the #define SCARLETT2_MAX_GAIN_DB and replace with a
per-config-set TLV as the Vocaster has a maximum gain of 70dB vs the
4th Gen 69dB.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <ade8e18ce38927ea0224946ec7cfea23ad3793d8.1710264833.git.g@b4.vu>
2024-04-18 08:31:14 +02:00
Geoffrey D. Bennett 1e48ddb7d7 ALSA: scarlett2: Add additional input configuration parameters
The 4th Gen Scarlett interfaces added software-controllable input gain
along with channel select, channel link, auto-gain, and "safe" mode.
Vocaster has software-controllable input gain and auto-gain but not
channel select, channel link, or safe mode.

Add a device info field safe_input_count to indicate how many channels
have a safe mode control, and use the presence of the input select and
input link switch configuration parameters to determine if those
controls should be created.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <167f04a37d0fb23f3077705df835adbc4f2b6a8e.1710264833.git.g@b4.vu>
2024-04-18 08:31:13 +02:00
Geoffrey D. Bennett b1b3b25824 ALSA: scarlett2: Add support for config items with size = 32
Update scarlett2_usb_get_config() to support 32-bit values which are
needed by the upcoming Vocaster support.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <ee35dce0172b2aa3fec8163ab8f35bdc35a141bd.1710264833.git.g@b4.vu>
2024-04-18 08:31:13 +02:00
Geoffrey D. Bennett 7d20f7b4f3 ALSA: scarlett2: Add pbuf field to struct scarlett2_config
scarlett2_usb_set_config() was using size = 0 as a signal to use the
parameter buffer. Replace that with an explicit indication (pbuf = 1),
as the upcoming Vocaster support has a config item written via the
parameter buffer with size = 1 rather than the implicit size of 8.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <50a7d85bb04f9a7f13f667c70a706826c8d3ef93.1710264833.git.g@b4.vu>
2024-04-18 08:31:13 +02:00
Geoffrey D. Bennett 4390095126 ALSA: scarlett2: Rename gen4_write_addr to param_buf_addr
The location pointed to by gen4_write_addr and gen4_write_addr + 1 is
officially known as the parameter buffer. Update the code to match.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <aa36ecb8d3ce67387b5edf6c900f0b8a509241ce.1710264833.git.g@b4.vu>
2024-04-18 08:31:13 +02:00
Geoffrey D. Bennett 5bfb7c2ae4 ALSA: scarlett2: Add support for reading from flash
Add hwdep read op so flash segments can be read.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <800d20a801e8c59c2905c82ecae5676cd4f31429.1710264833.git.g@b4.vu>
2024-04-18 08:31:13 +02:00
Geoffrey D. Bennett 1b65088958 ALSA: scarlett2: Implement handling of the ACK notification
After scarlett2_usb() sends a command, it seems that we should wait
for an ACK before attempting to read the response. Not doing that
didn't seem necessary previously but seems to be causing occasional
issues with 4th Gen devices.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <452d1263c40fa8eba1cfb24e2055e40a84cbc437.1710264833.git.g@b4.vu>
2024-04-18 08:31:13 +02:00
Geoffrey D. Bennett 4074f8d232 ALSA: scarlett2: Move initialisation code lower in the source
So that more forward declarations won't be required when we add
handling of the ACK notification, move the initialisation functions to
after the notification functions.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <0922071cb8be99a2394705de27b917d1e4e46f3f.1710264833.git.g@b4.vu>
2024-04-18 08:31:13 +02:00
Geoffrey D. Bennett 6719cd5e45 ALSA: scarlett2: Fix Scarlett 4th Gen input gain range again
The 4th Gen input preamp gain range is 0dB to +69dB, although the
control values range from 0 to 70. Replace SCARLETT2_MAX_GAIN with
SCARLETT2_MAX_GAIN_VALUE and SCARLETT2_MAX_GAIN_DB, and update the TLV
again.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Fixes: a45cf0a083 ("ALSA: scarlett2: Fix Scarlett 4th Gen input gain range")
Message-ID: <Ze7OMA8ntG7KteGa@m.b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-03-11 13:37:39 +01:00
Geoffrey D. Bennett a45cf0a083 ALSA: scarlett2: Fix Scarlett 4th Gen input gain range
The input gain range TLV was declared as -70dB to 0dB, but the preamp
gain range is actually 0dB to +70dB. Rename SCARLETT2_GAIN_BIAS to
SCARLETT2_MAX_GAIN and update the TLV to fix.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Fixes: 0a995e38dc ("ALSA: scarlett2: Add support for software-controllable input gain")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <9168317b5ac5335943d3f14dbcd1cc2d9b2299d0.1710047969.git.g@b4.vu>
2024-03-11 09:15:34 +01:00
Geoffrey D. Bennett be157c4683 ALSA: scarlett2: Fix Scarlett 4th Gen autogain status values
The meanings of the raw_auto_gain_status values were originally
guessed through experimentation, but the official names have now been
discovered. Update the autogain status control strings accordingly.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Fixes: 0a995e38dc ("ALSA: scarlett2: Add support for software-controllable input gain")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <8bd12a5e7dc714801dd9887c4bc5cb35c384e27c.1710047969.git.g@b4.vu>
2024-03-11 09:15:34 +01:00
Geoffrey D. Bennett 6ef1f08b53 ALSA: scarlett2: Fix Scarlett 4th Gen 4i4 low-voltage detection
The value currently being read to determine the low-voltage state is
actually the front panel state. Fix the code to use the correct offset
for the low-voltage state.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Fixes: d7cfa2fdfc ("ALSA: scarlett2: Add power status control")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Message-ID: <d97b7d87f43b0e54f37e1552394be2f3ae182704.1710047969.git.g@b4.vu>
2024-03-11 09:15:34 +01:00
Takashi Iwai 3787ffdd13 ALSA: scarlett2: Fix yet more -Wformat-truncation warnings
The recent code change introduced a few false-positive compile
warnings with -Wformat-trucation again.  Suppress them by replacing
snprintf() with scnprintf().

Fixes: 0a995e38dc ("ALSA: scarlett2: Add support for software-controllable input gain")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202401062344.AzZCYlpa-lkp@intel.com/
Link: https://lore.kernel.org/r/20240112171000.31855-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-01-15 12:41:14 +01:00
Geoffrey D. Bennett 4a2c8cc164 ALSA: scarlett2: Add PCM Input Switch for Solo Gen 4
When the Direct button on the Solo Gen 4 is held for 3 seconds, the
PCM 1 and 2 inputs are toggled between DSP Outputs 1 and 2, and Mixer
Outputs E and F. This patch adds the corresponding ALSA control.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/8c67c6131c459588ac4edab11e1fbc40a8297328.1703612638.git.g@b4.vu
2023-12-29 15:52:14 +01:00
Geoffrey D. Bennett 4e809a2996 ALSA: scarlett2: Add support for Solo, 2i2, and 4i4 Gen 4
Add new Focusrite Scarlett Gen 4 USB IDs, notification arrays, config
sets, and device info data.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/b33526d3b7a56bb2c86aa4eb2137a415bd23f1ce.1703612638.git.g@b4.vu
2023-12-29 15:52:14 +01:00
Geoffrey D. Bennett 2ecca0df90 ALSA: scarlett2: Add R/O headphone volume control
The Scarlett 4i4 Gen 4 adds a R/O headphone volume control in addition
to a R/O master volume control (which is already supported).

Mark the new scarlett2_notify_volume() function with __always_unused
until it gets used when the Gen 4 notification callback function arrays
are added.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/bd4a76da157f8cc3fbfa02eba96d02bdb86817c5.1703612638.git.g@b4.vu
2023-12-29 15:52:14 +01:00
Geoffrey D. Bennett f6a817e679 ALSA: scarlett2: Add minimum firmware version check
Early firmware for the Scarlett Gen 4 devices has sufficient
differences that it is better to enforce a minimum firmware version
than to try and work around those differences. Add a minimum firmware
version field to the device info struct, and display a message if the
firmware version is too old. Only create the Firmware Version and MSD
(optional) controls in this case.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/5455a7e54bda81556066abd7f761b10e9c5f8a16.1703612638.git.g@b4.vu
2023-12-29 15:52:14 +01:00
Geoffrey D. Bennett 66946398a4 ALSA: scarlett2: Rename DSP mux channels
The DSP mux channels are of type SCARLETT2_PORT_TYPE_MIX so the
ALSA controls would refer to them "Mix X" and "Mixer Input X". This
patch fixes them to be called "DSP X" and "DSP Input X".

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/2d91d0a74d5c7f6179e950bed2c80a4498d16649.1703612638.git.g@b4.vu
2023-12-29 15:52:14 +01:00
Geoffrey D. Bennett 166e1dfb75 ALSA: scarlett2: Add support for DSP mux channels
The DSP mux channels in the Scarlett 4th Gen appear as
SCARLETT2_PORT_TYPE_MIX ports but do not have corresponding mixer
controls. Add a dsp_count option to the device info struct to exclude
those DSP channels from the num_mix_in/num_mix_out counts.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/b78bdb1a7624d55783f5bf0e1ffbfa47a9e9a800.1703612638.git.g@b4.vu
2023-12-29 15:52:13 +01:00
Geoffrey D. Bennett c6c9f0cf9d ALSA: scarlett2: Add support for custom Gen 4 Direct Monitor mixes
The mixes used by Direct Monitor feature on the Scarlett 4th Gen Solo
and 2i2 interfaces are configurable. This patch adds ALSA controls for
the gains which are copied to the mixer when Direct Monitor is
enabled.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/96282a805b45f04560e5923d170745363906b7f3.1703612638.git.g@b4.vu
2023-12-29 15:52:13 +01:00
Geoffrey D. Bennett e8e14270d8 ALSA: scarlett2: Handle Gen 4 Direct Monitor mix updates
When the Direct Monitor feature on the Scarlett 4th Gen Solo and 2i2
interfaces is used, the Mix A and B gains are updated by the
interface. This patch calls snd_ctl_notify() for the ALSA mix controls
when a Direct Monitor notification is received.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/713d032e343e0547212368919bef17d6fa1c9d29.1703612638.git.g@b4.vu
2023-12-29 15:52:13 +01:00
Geoffrey D. Bennett ac19be067a ALSA: scarlett2: Store mix_ctls for Gen 4 Direct Monitor
The Scarlett 4th Gen small interfaces have a software-controllable
mixer like the large 2nd and 3rd Gen interfaces do. Pressing the
"Direct" button on the interface updates the mixer controls, which
this driver hasn't needed to deal with previously.

This commit stores the ALSA mixer controls, and adds a mix_updated
flag so that the controls can be updated when a notification is
received.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/3ba27c60230511b80b0fa75727551ea70f17d829.1703612638.git.g@b4.vu
2023-12-29 15:52:13 +01:00
Geoffrey D. Bennett d7cfa2fdfc ALSA: scarlett2: Add power status control
Add a control to retrieve the power status from the interface
(bus-powered, external-powered, or insufficient power).

Mark the new scarlett2_notify_power_status() function with
__always_unused until it gets used when the Gen 4 notification
callback function arrays are added.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/d9806bc41adc45b1c19749562fec7765ba24351d.1703612638.git.g@b4.vu
2023-12-29 15:52:13 +01:00
Geoffrey D. Bennett 882a2a36c4 ALSA: scarlett2: Disable autogain during phantom power state change
When phantom power is enabled or disabled, the autogain control cannot
be enabled until the interface has signalled that the change is
complete and the input is unmuted. Update those controls to be
read-only during this time.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/f49f7bf9358e1f20713d95d407d8d6a436859877.1703612638.git.g@b4.vu
2023-12-29 15:52:13 +01:00
Geoffrey D. Bennett 0d2e791db4 ALSA: scarlett2: Disable input controls while autogain is running
While the autogain function is running, the other input controls
(select, link, gain, safe, level, air, and phantom) can't be modified.
Update those controls to be read-only during this time.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/ad13bacae77860de8c2d7c89f6ec2a1ee104e65f.1703612638.git.g@b4.vu
2023-12-29 15:52:13 +01:00
Geoffrey D. Bennett a1ed1d6caf ALSA: scarlett2: Minor refactor MSD mode check
Create local variable for storing private data pointer in
snd_scarlett2_controls_create(). It's currently only used for checking
msd_switch, but it will be used again.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/ab50939dca0fdc5fa3493fc8eee3a2fdefffa62d.1703612638.git.g@b4.vu
2023-12-29 15:52:13 +01:00
Geoffrey D. Bennett 0a995e38dc ALSA: scarlett2: Add support for software-controllable input gain
Some devices in the Scarlett Gen 4 series have support for
software-controllable input gain. Along with this comes a channel
select option, an auto-gain feature, "safe" mode, and linking two
channels into a stereo pair.

Mark the new scarlett2_notify_input_*() functions with __always_unused
until they get used when the Gen 4 notification callback function
arrays are added.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/fc39e80bb39863dd1579d342097203942b4f3034.1703612638.git.g@b4.vu
2023-12-29 15:52:13 +01:00
Geoffrey D. Bennett 038216f2bc ALSA: scarlett2: Add support for Air Presence + Drive option
Extend the existing "air" option support from Scarlett Gen 3, which
had two states (off/on), to accommodate Scarlett Gen 4's new state:
Presence + Drive.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/a9ccda7222842a72e4ce7aa258614ff45248bb16.1703612638.git.g@b4.vu
2023-12-29 15:52:13 +01:00
Geoffrey D. Bennett 1b53c11623 ALSA: scarlett2: Allow for controls with a "mute mode"
Gen 2/3 interfaces would only use 0/1 values for input level and
phantom power switch controls. Gen 4 interfaces use the second bit to
indicate that the state should be changed (or is changing), and the
input is to be muted (or is muted) while that happens.

Add a "mute" flag to config items to enable this behaviour for the
level/phantom controls.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/f603cd16079c97fad910087e0302828a289d1c15.1703612638.git.g@b4.vu
2023-12-29 15:52:13 +01:00
Geoffrey D. Bennett 4fa07ff7b6 ALSA: scarlett2: Add support for Gen 4 style parameters
Writing Scarlett Gen 4 parameters differs from Gen 2 and Gen 3:
- the values are written into a shared write location
- the values are only byte-sized
- the read locations now extend beyond 0xFF
- a separate NVRAM save step is no longer required

This patch implements that alternate write style, triggered by setting
the config item size field to zero.

The write address is specified through a new config set field
gen4_write_addr.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/1624e6d8a0c629c3bdfe53825b16e8b589724fc4.1703612638.git.g@b4.vu
2023-12-29 15:52:12 +01:00
Geoffrey D. Bennett dd57b1213a ALSA: scarlett2: Add support for air/phantom control on input 2
The Focusrite Scarlett Gen 4 Solo has Air and Phantom Power controls
on analogue input #2 (the Gen 3 Solo had these controls on analogue
input #1). Add air_input_first and phantom_first device info options
to cater for this.

These options are similar to the level_input_first option that was
added for the Gen 3 Solo, but these new options do not require
adjusting the index of the control.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/19511f18895b8c094985a4a5691fbc1dc028c108.1703612638.git.g@b4.vu
2023-12-29 15:52:12 +01:00
Geoffrey D. Bennett 4dedf7ca92 ALSA: scarlett2: Remove repeated elem->head.mixer references
Use a local variable *mixer rather than repeating elem->header.mixer
in scarlett2_direct_monitor_ctl_get() and scarlett2_meter_ctl_get().

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/b21bacf4056366e10e01077e224d2b4970fdfe31.1703612638.git.g@b4.vu
2023-12-29 15:52:12 +01:00
Geoffrey D. Bennett d3cf557b26 ALSA: scarlett2: Split direct_monitor out from monitor_other
The notification value for monitor_other on the large interfaces is
the same as the notification value for direct_monitor on the 3rd Gen
small interfaces. Add a separate scarlett3a_notifications array and
split out the direct_monitor handling.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/9b56a483e3e9c1447684f18239a88652c1f01445.1703444932.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-12-29 15:41:23 +01:00
Geoffrey D. Bennett d9b63123fb ALSA: scarlett2: Split input_other into level/pad/air/phantom
Gen 2/3 devices have a single notification value for "input other"
changes. Gen 4 has separate notification values for level, pad, air,
and phantom power changes. Therefore, split the input_other_updated
field and the scarlett2_update_input_other() function into the four
components so that they can be handled separately later.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/a1a1d190659d56689792aa20ceeb53a6175171ad.1703444932.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-12-29 15:41:23 +01:00
Geoffrey D. Bennett ad5174608e ALSA: scarlett2: Rename db_scale_scarlett2_gain to volume
db_scale_scarlett2_gain is the TLV for the output volume controls.
Gen 4 has software-controllable input gain controls, so rename this to
db_scale_scarlett2_volume so we can use that name for the inputs.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/d544ec7cc5d5a849da104a5a78b17f61f50657c1.1703444932.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-12-29 15:41:23 +01:00
Geoffrey D. Bennett a1faecfcfe ALSA: scarlett2: Add #define for SCARLETT2_MIX_MAX
Add a #define for SCARLETT2_MIX_MAX (max of mixer inputs * outputs) as
that will be used again soon.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/83cec5ccd75f0db2bd061a76d31a7023d26300c1.1703444932.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-12-29 15:41:23 +01:00
Geoffrey D. Bennett 56275126ac ALSA: scarlett2: Add scarlett2_mixer_value_to_db()
Refactor scarlett2_usb_get_mix(), moving the scarlett2_mixer_values[]
lookup into scarlett2_mixer_value_to_db().

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/7adf869852aba2819fddb850b0ea8df5f7d73931.1703444932.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-12-29 15:41:23 +01:00
Geoffrey D. Bennett 90d8fef837 ALSA: scarlett2: Allow for interfaces without per-channel volume
Currently-supported interfaces with a mixer have per-channel volume
controls, but this changes in Gen 4. Add a check so that the Playback
Volume and associated controls don't get created unless the
SCARLETT2_CONFIG_LINE_OUT_VOLUME config item is present.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/30f68cb311e27f2cc1351cb846218f7248a90263.1703444932.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-12-29 15:41:23 +01:00
Geoffrey D. Bennett c6b3e71e2c ALSA: scarlett2: Remove line_out_hw_vol device info entry
By splitting config set gen2 into gen2a/b (for 6i6/18i8 vs 18i20), and
gen3b into gen3b/c (for 4i4/8i6 vs 18i8/18i20), we can use
scarlett2_has_config_item() instead of the per-device line_out_hw_vol.

As Gen 4 has a master volume control but no SW/HW switches, check for
both SCARLETT2_CONFIG_MASTER_VOLUME and SCARLETT2_CONFIG_SW_HW_SWITCH
as needed, even though for Gen 2 and Gen 3 the former implies the
latter.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/307c4f8d6d2e034f3e386b51d72a39d77c8a9fce.1703444932.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-12-29 15:41:23 +01:00
Geoffrey D. Bennett e79aea579a ALSA: scarlett2: Split dim_mute_update from vol_updated
Scarlett Gen 2 and Gen 3 devices combine volume and dim/mute
notifications. The Scarlett 4i4 Gen 4 has volume change notification
but no dim/mute control so split dim_mute_update out from vol_update.

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/bf63f48bcc68ae739bd9948c8ee2f87ee7af22a2.1703444932.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-12-29 15:41:23 +01:00
Geoffrey D. Bennett 80c7933e74 ALSA: scarlett2: Remove struct scarlett2_usb_volume_status
The struct scarlett2_usb_volume_status matched the config space layout
of a few volume controls that could be read together and were in fixed
locations between Gen 2 and Gen 3 devices.

Gen 4 devices have removed, moved, and new related controls, so this
needs to be cleaned up. By adding SCARLETT2_CONFIG_MASTER_VOLUME (the
only config item that didn't already have its own entry, because it is
read-only), we can remove:
- struct scarlett2_usb_volume_state,
- #define SCARLETT2_USB_VOLUME_STATUS_OFFSET, and
- scarlett2_usb_get_volume_status()
and replace with calls to scarlett2_usb_get_config().

Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://lore.kernel.org/r/2ee88994857246bf89fab8e62ac279f3bcf96192.1703444932.git.g@b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-12-29 15:41:23 +01:00