From patchwork Sun Dec 24 19:29:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Geoffrey D. Bennett" X-Patchwork-Id: 13504422 Received: from m.b4.vu (m.b4.vu [203.16.231.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CAA8D30E for ; Sun, 24 Dec 2023 19:29:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=b4.vu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=b4.vu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=b4.vu header.i=@b4.vu header.b="eRmUCfTF" Received: by m.b4.vu (Postfix, from userid 1000) id 9E2E0604B9CB; Mon, 25 Dec 2023 05:59:14 +1030 (ACDT) DKIM-Filter: OpenDKIM Filter v2.11.0 m.b4.vu 9E2E0604B9CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=b4.vu; s=m1; t=1703446154; bh=AOH0L5pnCAa8PxWf1PuI2dpJVX3q5VQRkjTAe5+4AnE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eRmUCfTFv28QU4DKB7WBg8TyfSSGlFHSQEFa+VUZQtmpm3+qUt+U2XawiRvv3R/Cc p5ResCpj1B5BJLScLzmOz7T8APF1NnhIEhF8ctvWO9PJBr+BXxbCP0Cui3/iI0HMIl mkMUY0jUND6lvy7SM5fE0nSqw44TxAIgIenWMrLEtWUKn8UR6h3WpUn5HruD2dCHZA tpouHX0f4skv8AUe6OroItLFRQ1KbWh7Uh+XSJEMIP1BitTeoeepl4qXyxP9GpP/v7 W8qJufwfHgsy+kw9UxFLr+VoSJyELugvQ5jRRSgmj+8CDG7rSLVZ5gx7vhspRnnurM kULVmb4CdTWgA== Date: Mon, 25 Dec 2023 05:59:14 +1030 From: "Geoffrey D. Bennett" To: Takashi Iwai Cc: Takashi Iwai , alsa-devel@alsa-project.org, linux-sound@vger.kernel.org Subject: [PATCH 16/23] ALSA: scarlett2: Split dim_mute_update from vol_updated Message-ID: References: Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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 --- sound/usb/mixer_scarlett2.c | 63 ++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/sound/usb/mixer_scarlett2.c b/sound/usb/mixer_scarlett2.c index b3f76476ce52..1393b7da436d 100644 --- a/sound/usb/mixer_scarlett2.c +++ b/sound/usb/mixer_scarlett2.c @@ -628,6 +628,7 @@ struct scarlett2_data { u16 scarlett2_seq; u8 sync_updated; u8 vol_updated; + u8 dim_mute_updated; u8 input_other_updated; u8 monitor_other_updated; u8 mux_updated; @@ -2222,7 +2223,6 @@ static int scarlett2_update_volumes(struct usb_mixer_interface *mixer) const struct scarlett2_device_info *info = private->info; s16 vol; int err, i; - int mute; private->vol_updated = 0; @@ -2238,22 +2238,9 @@ static int scarlett2_update_volumes(struct usb_mixer_interface *mixer) private->master_vol = clamp(vol + SCARLETT2_VOLUME_BIAS, 0, SCARLETT2_VOLUME_BIAS); - err = scarlett2_usb_get_config( - mixer, SCARLETT2_CONFIG_DIM_MUTE, - SCARLETT2_DIM_MUTE_COUNT, private->dim_mute); - if (err < 0) - return err; - - for (i = 0; i < SCARLETT2_DIM_MUTE_COUNT; i++) - private->dim_mute[i] = !!private->dim_mute[i]; - - mute = private->dim_mute[SCARLETT2_BUTTON_MUTE]; - for (i = 0; i < private->num_line_out; i++) - if (private->vol_sw_hw_switch[i]) { + if (private->vol_sw_hw_switch[i]) private->vol[i] = private->master_vol; - private->mute_switch[i] = mute; - } return 0; } @@ -2401,6 +2388,36 @@ static const struct snd_kcontrol_new scarlett2_line_out_volume_ctl = { /*** Mute Switch Controls ***/ +static int scarlett2_update_dim_mute(struct usb_mixer_interface *mixer) +{ + struct scarlett2_data *private = mixer->private_data; + const struct scarlett2_device_info *info = private->info; + int err, i; + u8 mute; + + private->dim_mute_updated = 0; + + if (!info->line_out_hw_vol) + return 0; + + err = scarlett2_usb_get_config( + mixer, SCARLETT2_CONFIG_DIM_MUTE, + SCARLETT2_DIM_MUTE_COUNT, private->dim_mute); + if (err < 0) + return err; + + for (i = 0; i < SCARLETT2_DIM_MUTE_COUNT; i++) + private->dim_mute[i] = !!private->dim_mute[i]; + + mute = private->dim_mute[SCARLETT2_BUTTON_MUTE]; + + for (i = 0; i < private->num_line_out; i++) + if (private->vol_sw_hw_switch[i]) + private->mute_switch[i] = mute; + + return 0; +} + static int scarlett2_mute_ctl_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *ucontrol) { @@ -2417,8 +2434,8 @@ static int scarlett2_mute_ctl_get(struct snd_kcontrol *kctl, goto unlock; } - if (private->vol_updated) { - err = scarlett2_update_volumes(mixer); + if (private->dim_mute_updated) { + err = scarlett2_update_dim_mute(mixer); if (err < 0) goto unlock; } @@ -3575,8 +3592,8 @@ static int scarlett2_dim_mute_ctl_get(struct snd_kcontrol *kctl, goto unlock; } - if (private->vol_updated) { - err = scarlett2_update_volumes(mixer); + if (private->dim_mute_updated) { + err = scarlett2_update_dim_mute(mixer); if (err < 0) goto unlock; } @@ -4582,6 +4599,10 @@ static int scarlett2_read_configs(struct usb_mixer_interface *mixer) if (err < 0) return err; + err = scarlett2_update_dim_mute(mixer); + if (err < 0) + return err; + for (i = 0; i < private->num_mix_out; i++) { err = scarlett2_usb_get_mix(mixer, i); if (err < 0) @@ -4633,11 +4654,11 @@ static void scarlett2_notify_dim_mute(struct usb_mixer_interface *mixer) const struct scarlett2_device_info *info = private->info; int i; - private->vol_updated = 1; - if (!info->line_out_hw_vol) return; + private->dim_mute_updated = 1; + for (i = 0; i < SCARLETT2_DIM_MUTE_COUNT; i++) snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &private->dim_mute_ctls[i]->id);