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
This commit is contained in:
committed by
Takashi Iwai
parent
1b53c11623
commit
038216f2bc
+36
-10
@@ -647,6 +647,12 @@ struct scarlett2_device_info {
|
|||||||
/* the first input with an air control (0-based) */
|
/* the first input with an air control (0-based) */
|
||||||
u8 air_input_first;
|
u8 air_input_first;
|
||||||
|
|
||||||
|
/* number of additional air options
|
||||||
|
* 0 for air presence only (Gen 3)
|
||||||
|
* 1 for air presence+drive (Gen 4)
|
||||||
|
*/
|
||||||
|
u8 air_option;
|
||||||
|
|
||||||
/* the number of phantom (48V) software switchable controls */
|
/* the number of phantom (48V) software switchable controls */
|
||||||
u8 phantom_count;
|
u8 phantom_count;
|
||||||
|
|
||||||
@@ -3022,7 +3028,7 @@ static int scarlett2_air_ctl_put(struct snd_kcontrol *kctl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
oval = private->air_switch[index];
|
oval = private->air_switch[index];
|
||||||
val = !!ucontrol->value.integer.value[0];
|
val = ucontrol->value.integer.value[0];
|
||||||
|
|
||||||
if (oval == val)
|
if (oval == val)
|
||||||
goto unlock;
|
goto unlock;
|
||||||
@@ -3040,12 +3046,31 @@ unlock:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct snd_kcontrol_new scarlett2_air_ctl = {
|
static int scarlett2_air_with_drive_ctl_info(
|
||||||
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
struct snd_kcontrol *kctl, struct snd_ctl_elem_info *uinfo)
|
||||||
.name = "",
|
{
|
||||||
.info = snd_ctl_boolean_mono_info,
|
static const char *const values[3] = {
|
||||||
.get = scarlett2_air_ctl_get,
|
"Off", "Presence", "Presence + Drive"
|
||||||
.put = scarlett2_air_ctl_put,
|
};
|
||||||
|
|
||||||
|
return snd_ctl_enum_info(uinfo, 1, 3, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct snd_kcontrol_new scarlett2_air_ctl[2] = {
|
||||||
|
{
|
||||||
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
||||||
|
.name = "",
|
||||||
|
.info = snd_ctl_boolean_mono_info,
|
||||||
|
.get = scarlett2_air_ctl_get,
|
||||||
|
.put = scarlett2_air_ctl_put,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
||||||
|
.name = "",
|
||||||
|
.info = scarlett2_air_with_drive_ctl_info,
|
||||||
|
.get = scarlett2_air_ctl_get,
|
||||||
|
.put = scarlett2_air_ctl_put,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*** Phantom Switch Controls ***/
|
/*** Phantom Switch Controls ***/
|
||||||
@@ -3839,9 +3864,10 @@ static int scarlett2_add_line_in_ctls(struct usb_mixer_interface *mixer)
|
|||||||
/* Add input air controls */
|
/* Add input air controls */
|
||||||
for (i = 0; i < info->air_input_count; i++) {
|
for (i = 0; i < info->air_input_count; i++) {
|
||||||
snprintf(s, sizeof(s), fmt, i + 1 + info->air_input_first,
|
snprintf(s, sizeof(s), fmt, i + 1 + info->air_input_first,
|
||||||
"Air", "Switch");
|
"Air", info->air_option ? "Enum" : "Switch");
|
||||||
err = scarlett2_add_new_ctl(mixer, &scarlett2_air_ctl,
|
err = scarlett2_add_new_ctl(
|
||||||
i, 1, s, &private->air_ctls[i]);
|
mixer, &scarlett2_air_ctl[info->air_option],
|
||||||
|
i, 1, s, &private->air_ctls[i]);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user