From patchwork Wed Jul 14 15:30:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 476809 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp676678jao; Wed, 14 Jul 2021 08:31:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwowKPm3H72Rh25aQyhut4EmfE1BIm0+adi4bFmHnH5kad0Iy9RvrEeOGKWZMGoRmzJqOKi X-Received: by 2002:a05:6e02:550:: with SMTP id i16mr7039359ils.207.1626276683074; Wed, 14 Jul 2021 08:31:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626276683; cv=none; d=google.com; s=arc-20160816; b=B915H9dmdAoVGt+O1jpBLamKrcJG0GKkabJlVjmeS91jnl0vGUZT+AsdmjYkgXv00a MCMZLlnBmkv15QjF/7tkgSukhjROrYJSjgX6ZWTUjwIQHUNXSuvVM1AJot1vEnbceTEz IGOQF+U2gyQIH3H754nRmRvhPo/Z+VwfsZZ6B/81TalgpF4XagzZPGA7kVdeVNvt2fvC sEhcpQXd7hpEnbu8Y9J+XHQS4lkxH4gOTkmrVjEaB14pIw2RuGLbQ0ViaQPjzHNxrIaE lrg1fnvJN2lT60Z7690gl42hFA4zjCCI2CGcKMs6ePpRAUAG19ERxpGA+W12S7+ApwqR uQQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/OyLLqXUZS1RpS+YuJ/yD57hTXnorkIuGBmzsYS7+c4=; b=O4BJ8aOCwBMSuiBMwleOwxvRfSFOyQsWiYbTHUYwbYNzjH37EIMF3AoPh6kF5Aj3tj KZq2B6G3Ra2aKilgNcTlVjqxJtfq0w7sHJR22WawJSYtCeseGNBqM3aTd9zvjSb4MEle HpM/yoKxPFfv12MCZbaYnnMO7vpD6Jak60MceYZs6ZJOq07arZl5bxDczM+WO+d4RbwR yAbaevihnmr3yJN8UPjc1IAHxmLb+7Clf7/8NJzYUqaKgs9Gc+/WQiPhmefEwYhnQJ8l 3JdwJrcYXuaaIoA0ycStiwPuoueWpbZdnhgbKz7sEMBzZknS2/Ngaa0jJMAfSiHQIJo9 cXww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I9awJWJ0; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si2936383jao.12.2021.07.14.08.31.22; Wed, 14 Jul 2021 08:31:23 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I9awJWJ0; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239853AbhGNPeM (ORCPT + 7 others); Wed, 14 Jul 2021 11:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239811AbhGNPeK (ORCPT ); Wed, 14 Jul 2021 11:34:10 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBE62C061762 for ; Wed, 14 Jul 2021 08:31:18 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id b14-20020a1c1b0e0000b02901fc3a62af78so4172306wmb.3 for ; Wed, 14 Jul 2021 08:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/OyLLqXUZS1RpS+YuJ/yD57hTXnorkIuGBmzsYS7+c4=; b=I9awJWJ0TeowLx8ez7hQQZ/8uuMucKaiP0yybxoMUtTzmz+q9AuGACZsNk4a1dv1vn 3zsplkFV6BR0AaOQKcx+YX73pjEwcEboTLS2zlV1drc9hjq15nfUlPo8y60oKguSMZn1 ffeEPFk0EekBEpfBL0jXzkhgvuXrXN30/ZXkeu1LZry0im3i3gOGtxFC4dcUttgzwq9j 5cWwAbbiXdgSbwUrZNLpef0zckbyjC77iqz2aLQG62TWbEyPNlqVIEQtzPs/vELhVeDa 8ebT5xlk91pGSlnmm0z81JflnM7bgGD/Vl9kB8gnaKpmsyw92587tFyKWXyCLVVY+hyp rGNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/OyLLqXUZS1RpS+YuJ/yD57hTXnorkIuGBmzsYS7+c4=; b=PA0GqC6guOn3vMKSoQw93+CK1ik1VShkAEUoSuFVIaSDN5BvaWFzfOx21CyhUgP5vT rSEzcW6A3M3MJPDVetz2kKnPG9/Os7hKWHl6hGJZqLFvwAqHAIWFwiGWk++j7k80Etm1 9NA43cAYJ8U1gYUiIPGhWa8B3J44MshBXHAn4w0Yf6iTFnwF/uDRkOTg4dAtHnqmlqKI ztFR0ONRIDT3lKWXIBW/LnL4PG0XhfUojEPjFWnDibRj/zGMPkG1+aYszQh5uQifsb8a 60cUEEBQja3auaEWdbOtD+H/FN9M0lKAHgOGj7d9fQ2gN9X/vqRKoUyIWNlTjRFx2wBk C8SQ== X-Gm-Message-State: AOAM533Dw/ZIrWfVl4u1PDalWMM5cEnUZnSYEPsB6eBzfvDn+H1nHqor 0RH+AAUXt05V8HZi0jHksgWR9w== X-Received: by 2002:a1c:9dd6:: with SMTP id g205mr12006785wme.82.1626276677494; Wed, 14 Jul 2021 08:31:17 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id y6sm2465174wma.48.2021.07.14.08.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 08:31:16 -0700 (PDT) From: Srinivas Kandagatla To: bjorn.andersson@linaro.org, broonie@kernel.org, robh@kernel.org Cc: plai@codeaurora.org, tiwai@suse.de, devicetree@vger.kernel.org, perex@perex.cz, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, bgoswami@codeaurora.org, Srinivas Kandagatla Subject: [PATCH v2 15/16] ASoC: qcom: audioreach: topology add dapm pga support Date: Wed, 14 Jul 2021 16:30:38 +0100 Message-Id: <20210714153039.28373-16-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210714153039.28373-1-srinivas.kandagatla@linaro.org> References: <20210714153039.28373-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/audioreach/topology.c | 62 +++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/sound/soc/qcom/audioreach/topology.c b/sound/soc/qcom/audioreach/topology.c index 8080243a47ef..14ecb115e63e 100644 --- a/sound/soc/qcom/audioreach/topology.c +++ b/sound/soc/qcom/audioreach/topology.c @@ -706,6 +706,25 @@ static int audioreach_widget_load_mixer(struct snd_soc_component *component, return 0; } +static int audioreach_widget_load_pga(struct snd_soc_component *component, + int index, struct snd_soc_dapm_widget *w, + struct snd_soc_tplg_dapm_widget *tplg_w) +{ + struct audioreach_module *mod; + struct snd_soc_dobj *dobj; + int ret; + + ret = audioreach_widget_load_module_common(component, index, w, tplg_w); + if (ret) + return ret; + + dobj = &w->dobj; + mod = dobj->private; + mod->gain = VOL_CTRL_DEFAULT_GAIN; + + return 0; +} + static int audioreach_widget_ready(struct snd_soc_component *component, int index, struct snd_soc_dapm_widget *w, struct snd_soc_tplg_dapm_widget *tplg_w) @@ -725,8 +744,9 @@ static int audioreach_widget_ready(struct snd_soc_component *component, break; case snd_soc_dapm_mixer: return audioreach_widget_load_mixer(component, index, w, tplg_w); - case snd_soc_dapm_dai_link: case snd_soc_dapm_pga: + return audioreach_widget_load_pga(component, index, w, tplg_w); + case snd_soc_dapm_dai_link: case snd_soc_dapm_scheduler: case snd_soc_dapm_out_drv: default: @@ -898,6 +918,40 @@ static int audioreach_put_audio_mixer(struct snd_kcontrol *kcontrol, return 0; } +static int audioreach_get_vol_ctrl_audio_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *dw = snd_soc_dapm_kcontrol_widget(kcontrol); + struct audioreach_module *mod = dw->dobj.private; + + /* Check if the graph is active or not */ + ucontrol->value.integer.value[0] = mod->gain; + + return 0; +} + +static int audioreach_put_vol_ctrl_audio_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *dw = snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *c = snd_soc_dapm_to_component(dapm); + struct audioreach_module *mod = dw->dobj.private; + struct q6apm *apm = dev_get_drvdata(c->dev); + int vol = ucontrol->value.integer.value[0]; + + /* Check if the graph is active or not */ + if (dw->power) { + audioreach_gain_set_vol_ctrl(apm, mod, vol); + mod->gain = vol; + return 1; + } + + dev_err(apm->dev, "Unable to set volume as graph is not active\n"); + return 0; + +} + static int audioreach_control_load_mix(struct snd_soc_component *scomp, struct snd_ar_control *scontrol, struct snd_kcontrol_new *kc, @@ -948,6 +1002,10 @@ static int audioreach_control_load(struct snd_soc_component *scomp, int index, dobj = &sm->dobj; ret = audioreach_control_load_mix(scomp, scontrol, kc, hdr); break; + case SND_SOC_AR_TPLG_VOL_CTL: + sm = (struct soc_mixer_control *)kc->private_value; + dobj = &sm->dobj; + break; default: dev_warn(scomp->dev, "control type not supported %d:%d:%d\n", hdr->ops.get, hdr->ops.put, hdr->ops.info); @@ -972,6 +1030,8 @@ static int audioreach_control_unload(struct snd_soc_component *scomp, static const struct snd_soc_tplg_kcontrol_ops audioreach_io_ops[] = { {SND_SOC_AR_TPLG_FE_BE_GRAPH_CTL_MIX, audioreach_get_audio_mixer, audioreach_put_audio_mixer, snd_soc_info_volsw}, + {SND_SOC_AR_TPLG_VOL_CTL, audioreach_get_vol_ctrl_audio_mixer, + audioreach_put_vol_ctrl_audio_mixer, snd_soc_info_volsw}, }; static struct snd_soc_tplg_ops audioreach_tplg_ops = {