From patchwork Tue Feb 16 17:33:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 8330021 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1341A9F399 for ; Tue, 16 Feb 2016 17:37:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F89C20279 for ; Tue, 16 Feb 2016 17:37:22 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id B24C020272 for ; Tue, 16 Feb 2016 17:37:20 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D39BB266705; Tue, 16 Feb 2016 18:37:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id BBEB92665BA; Tue, 16 Feb 2016 18:34:36 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id F32312665BA; Tue, 16 Feb 2016 18:34:34 +0100 (CET) Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by alsa0.perex.cz (Postfix) with ESMTP id A9C322665E0 for ; Tue, 16 Feb 2016 18:33:31 +0100 (CET) Received: by mail-wm0-f54.google.com with SMTP id g62so201988195wme.0 for ; Tue, 16 Feb 2016 09:33:31 -0800 (PST) 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; bh=RpQzsBHAUo0u69f4zjlOpHvn6CENqu5gAJTqx4FQ5/g=; b=RwyGhe+8ONjuk1ZvL8/wso5NLN4pFvi3ZuVuWNOB7xQD9L8mcXLKDn+fhX6khRZyQJ DG9gd4Gf0/dk402UM5O4gOeI1fjbyy11tNzD8YYJY55YoGcxfT+5zyUEq+J895C1prgC 8kvzPxnYPdEDJuWYT8wBADYjcZa41WicCEp+g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RpQzsBHAUo0u69f4zjlOpHvn6CENqu5gAJTqx4FQ5/g=; b=Bv/t3lpJT73fTiP/+ZSQ9Eam+/r9BpZxI2pUUnMmTN7if/nFiR2cVtH+SvcAv3a8wV Y+Pbzn3w+HxJwxNWOMy4NxJUiSwmSqh0QkaHg5YovbuO3QdJDj0VCOiM3atDK5+AU8fs vAk/sIfkDOsHZZMCqOfCoiwwgkVAv32NS6s33aQlKKUOIJ9fq4uhZke7K9Txlh68DZYi y2GG6qK+Qd6NpDNqwl2kDWcJzHD+yTHg2+d8kCjfrtXknBem3qEOginFqVt+NvQcdvOh bIj7zHytfr+KvLw+W/GWm6I/5I58foqwquM/SylOMrj/oNjuIQZC8Lub415omXID6zJ/ 4haw== X-Gm-Message-State: AG10YOSDUX9fk2fgToI7STDeUr3/zo718kTKzCApP9ro+2heYlxy1ThywaKe+1k5PNA4DoSS X-Received: by 10.28.146.8 with SMTP id u8mr19530760wmd.72.1455644011508; Tue, 16 Feb 2016 09:33:31 -0800 (PST) Received: from localhost.localdomain (host-92-17-247-99.as13285.net. [92.17.247.99]) by smtp.gmail.com with ESMTPSA id n131sm21511180wmf.9.2016.02.16.09.33.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Feb 2016 09:33:30 -0800 (PST) From: Srinivas Kandagatla To: alsa-devel@alsa-project.org, Mark Brown Date: Tue, 16 Feb 2016 17:33:28 +0000 Message-Id: <1455644008-1917-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455643880-1611-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1455643880-1611-1-git-send-email-srinivas.kandagatla@linaro.org> Cc: Mark Rutland , kwestfie@codeaurora.org, Pawel Moll , linux-kernel@vger.kernel.org, Patrick Lai , Takashi Iwai , Liam Girdwood , Rob Herring , Srinivas Kandagatla , linux-arm-msm@vger.kernel.org Subject: [alsa-devel] [RFC v1 7/9] ASoC: msm8x16: Add sound mixer controls. X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds basic mixer controls found in the codec. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/msm8x16-wcd.c | 99 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/sound/soc/codecs/msm8x16-wcd.c b/sound/soc/codecs/msm8x16-wcd.c index 4bc8274..4bf3b81 100644 --- a/sound/soc/codecs/msm8x16-wcd.c +++ b/sound/soc/codecs/msm8x16-wcd.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "msm8x16-wcd-registers.h" #include "msm8x16-wcd.h" @@ -49,6 +50,29 @@ struct msm8x16_wcd_chip { bool micbias2_cap_mode; }; +static const char * const msm8x16_wcd_spk_boost_ctrl_text[] = { + "DISABLE", "ENABLE"}; + +/*cut of frequency for high pass filter*/ +static const char * const cf_text[] = { + "MIN_3DB_4Hz", "MIN_3DB_75Hz", "MIN_3DB_150Hz" +}; + +static const struct soc_enum msm8x16_wcd_spk_boost_ctl_enum[] = { + SOC_ENUM_SINGLE_EXT(2, msm8x16_wcd_spk_boost_ctrl_text), +}; +static const struct soc_enum cf_rxmix1_enum = + SOC_ENUM_SINGLE(MSM8X16_WCD_A_CDC_RX1_B4_CTL, 0, 3, cf_text); + +static const struct soc_enum cf_rxmix2_enum = + SOC_ENUM_SINGLE(MSM8X16_WCD_A_CDC_RX2_B4_CTL, 0, 3, cf_text); + +static const struct soc_enum cf_rxmix3_enum = + SOC_ENUM_SINGLE(MSM8X16_WCD_A_CDC_RX3_B4_CTL, 0, 3, cf_text); + +static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0); +static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1); + static int msm8x16_wcd_volatile(struct snd_soc_codec *codec, unsigned int reg) { return msm8x16_wcd_reg_readonly[reg]; @@ -164,6 +188,79 @@ static void msm8x16_wcd_configure_cap(struct snd_soc_codec *codec, } } +static int msm8x16_wcd_spk_boost_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct msm8x16_wcd_chip *msm8x16_wcd = dev_get_drvdata(codec->dev); + + if (msm8x16_wcd->spk_boost_set == false) { + ucontrol->value.integer.value[0] = 0; + } else if (msm8x16_wcd->spk_boost_set == true) { + ucontrol->value.integer.value[0] = 1; + } else { + dev_err(codec->dev, "%s: ERROR: Unsupported Speaker Boost = %d\n", + __func__, msm8x16_wcd->spk_boost_set); + return -EINVAL; + } + + return 0; +} + +static int msm8x16_wcd_spk_boost_set(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct msm8x16_wcd_chip *msm8x16_wcd = snd_soc_codec_get_drvdata(codec); + + switch (ucontrol->value.integer.value[0]) { + case 0: + msm8x16_wcd->spk_boost_set = false; + break; + case 1: + msm8x16_wcd->spk_boost_set = true; + break; + default: + return -EINVAL; + } + return 0; +} + +static const struct snd_kcontrol_new msm8x16_wcd_snd_controls[] = { + + SOC_ENUM_EXT("Speaker Boost", msm8x16_wcd_spk_boost_ctl_enum[0], + msm8x16_wcd_spk_boost_get, msm8x16_wcd_spk_boost_set), + + SOC_SINGLE_TLV("ADC1 Volume", MSM8X16_WCD_A_ANALOG_TX_1_EN, 3, + 8, 0, analog_gain), + SOC_SINGLE_TLV("ADC2 Volume", MSM8X16_WCD_A_ANALOG_TX_2_EN, 3, + 8, 0, analog_gain), + SOC_SINGLE_TLV("ADC3 Volume", MSM8X16_WCD_A_ANALOG_TX_3_EN, 3, + 8, 0, analog_gain), + + SOC_SINGLE_SX_TLV("RX1 Digital Volume", + MSM8X16_WCD_A_CDC_RX1_VOL_CTL_B2_CTL, + 0, -84, 40, digital_gain), + SOC_SINGLE_SX_TLV("RX2 Digital Volume", + MSM8X16_WCD_A_CDC_RX2_VOL_CTL_B2_CTL, + 0, -84, 40, digital_gain), + SOC_SINGLE_SX_TLV("RX3 Digital Volume", + MSM8X16_WCD_A_CDC_RX3_VOL_CTL_B2_CTL, + 0, -84, 40, digital_gain), + + SOC_SINGLE("RX1 HPF Switch", + MSM8X16_WCD_A_CDC_RX1_B5_CTL, 2, 1, 0), + SOC_SINGLE("RX2 HPF Switch", + MSM8X16_WCD_A_CDC_RX2_B5_CTL, 2, 1, 0), + SOC_SINGLE("RX3 HPF Switch", + MSM8X16_WCD_A_CDC_RX3_B5_CTL, 2, 1, 0), + + SOC_ENUM("RX1 HPF cut off", cf_rxmix1_enum), + SOC_ENUM("RX2 HPF cut off", cf_rxmix2_enum), + SOC_ENUM("RX3 HPF cut off", cf_rxmix3_enum), +}; + + static int msm8x16_wcd_codec_parse_dt(struct platform_device *pdev, struct msm8x16_wcd_chip *chip) { @@ -551,6 +648,8 @@ static struct snd_soc_codec_driver msm8x16_wcd_codec = { .reg_cache_size = MSM8X16_WCD_NUM_REGISTERS, .reg_cache_default = msm8x16_wcd_reset_reg_defaults, .reg_word_size = 1, + .controls = msm8x16_wcd_snd_controls, + .num_controls = ARRAY_SIZE(msm8x16_wcd_snd_controls), }; static int msm8x16_wcd_probe(struct platform_device *pdev)