Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752272AbdCCPia (ORCPT ); Fri, 3 Mar 2017 10:38:30 -0500 Received: from mail-sn1nam01on0101.outbound.protection.outlook.com ([104.47.32.101]:37408 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751722AbdCCPgt (ORCPT ); Fri, 3 Mar 2017 10:36:49 -0500 Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=maximintegrated.com; From: Ryan Lee To: , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH 08/10] Added DAI Sel Mux and minor updates Date: Fri, 3 Mar 2017 23:52:46 +0900 Message-ID: <1488552768-14901-9-git-send-email-ryans.lee@maximintegrated.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488552768-14901-1-git-send-email-ryans.lee@maximintegrated.com> References: <1488552768-14901-1-git-send-email-ryans.lee@maximintegrated.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [222.234.201.146] X-ClientProxiedBy: KL1PR02CA0031.apcprd02.prod.outlook.com (10.165.15.41) To CY4PR11MB1367.namprd11.prod.outlook.com (10.173.16.149) X-MS-Office365-Filtering-Correlation-Id: 451af49d-0ef4-4de8-7a60-08d4624531c9 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081);SRVR:CY4PR11MB1367; X-Microsoft-Exchange-Diagnostics: 1;CY4PR11MB1367;3:xSOW8okRbwJSHYh7PtiWguJiNnzEMWQPj92TKNw06JW225vRvLd6s6V5oA9hcnKvxsnxZVsr5xGsfVSDtQMHQxCBkQsicuO5Xhu/+RpRprzF8JqGM7sCyH091kwNGPQ7Qv6InmIv/F+vS4eo5yvMAVzMkKSuF5gEapf9V9coU1zsix0B++1dihYtDf6Q12WTLNYeAs9DGLJLahvjW2QsevipxxseIZV1XLT70ahBVC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sbMB9FE3kspTXhc0zbJMK5RbYk1CGvekxkLW3ug7ImwCeXb/mwqWlI1tzVm50Wi3tiDrH69yk0wNPaG7KoKmVn3qXtzc2FK+c/bDyitF3TEG0pBiBz2VN9bE9iQDBmQ8SakOhjXxfNgYUaFepPn9tIP+PWSDMQqwGUUStC5IAhUhJdJI229IcTcqLVTdqjLXvSK7QgQfKPaTLNpyef+5qxhJ5OY0/WtAQatMtTmh56whfnT1GPz0L X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(108721460000369); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123555025)(20161123564025)(20161123558025)(20161123562025)(6072148);SRVR:CY4PR11MB1367;BCL:0;PCL:0;RULEID:;SRVR:CY4PR11MB1367; X-Microsoft-Exchange-Diagnostics: 1;CY4PR11MB1367;4:AiJQy60G6UCCpiY+8dsnu8L0PFCh1WCWeBM8QES+HlVUcmifFsMOBuSnDvOfn+OS9lssdJt4PwrapjkEhGYuzd33pa8nrkcnwftFKXVDZwOXaIGe69eYwKztFIfIpewUjhi4zr7YozBT2a0/AO3KDIJ16yDSDktgTXTBqnsS8aTl6B+J5JKpJBIzYjwm65nt0FCIlwCmO25k1vMzjwe/BNhy6+l3oivXUJtyCaYZ6IDTm6Fed7OtVUqoK9idzz3dCXwn1cGBCp/6Sdi3GDS6ArGTA14PoquT42gW82NesjxaNwtkJJyJQP5KOBpYblKdRYFXELrBeMkE+5a6hQNKqFRZyCNaQ98eA6DR+fY1OSCzVjb3viY0470Hew4x7TOsK25ZlMUiRsVAvhi/s7XjW/oUymr4TSVGdFxWKWbBDzD5WgC2ElW2gw4EILrsdHjJG+qQi8tIu0gJsz7Um+3h8MFDUyqFbVzW7hTa+9uNO95vo10tT6pYiyjqXra6NQVdJTCiUFL+neqkxJnzQuRO1yE00SJV8oT7LC5PgtYcePP5nY/XIHP0tRO5I2XsbpCswdR0hFbfVyCnUFOycQAvTK/hEzV+qOL/jnNI8Vj9eXkXs9I6ZnQjeLp54AE6H9wPpQpcTn5A6l563sN1F4ZF4KWS6X0ckfypeceqdB24M2g= X-Forefront-PRVS: 0235CBE7D0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(7916002)(39850400002)(39410400002)(39840400002)(39450400003)(39860400002)(33646002)(86362001)(50986999)(5003940100001)(7416002)(25786008)(76176999)(2201001)(50226002)(189998001)(6512007)(2906002)(6486002)(6506006)(6666003)(53936002)(42186005)(53416004)(3846002)(305945005)(66066001)(6116002)(48376002)(50466002)(92566002)(8676002)(7736002)(47776003)(36756003)(2950100002)(5660300001)(4326008)(38730400002)(81166006)(921003)(1121003)(19627235001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR11MB1367;H:ryan-Lenovo-IdeaPad-Z510.maxim-ic.com;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR11MB1367;23:oCRRnYCLUdKZJz1mL6PxTk1W6vkURUM9IBPs2CN4n?= =?us-ascii?Q?N2xJarGcLdOQ8mAVVITYaAF/lXxrfVjcHS73a4ZYAG1YyEOIgh4YtipphcH9?= =?us-ascii?Q?OIEEPLjs0T3AmAcekwOW5wNnnLvkZN3ncpLRSjCT2CGX9rG6N8c5602X1sO4?= =?us-ascii?Q?a7aYXkGrAZTvdO5rULfI5eSUbgDdKJlCA/Klk4BVSOTK/PjRh3beLVs8lS9e?= =?us-ascii?Q?HRb9ZraFaAjXhzfgDwa2gPCkLlefyvVuBlos/lU3io3jI866QyQlIg2d8/HC?= =?us-ascii?Q?4Xnd0fYWXJ7cC8jzJi5lHyoiHyIjWFEvfK6W0mpoPVQJOEfSKMA7MYOKP6OL?= =?us-ascii?Q?n4O4GmY5XyZq3n/xFGhQsw5N6kAWWG8/svpH1+IalfE1gVy8HfXaTsDBJ4Ik?= =?us-ascii?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Tqq/7hFhffscB35WyE9YTVUAJVmlsGeUoqTsT18mMBErMp0Cbn8/YmKEbNbsmA58r61QwX92NY5Zxxo4vHeclaphfUOyA3q/07dFAUft2bMBFXfMh0kqS69h00a7zEoZ34nVAfrYboJMKcwLZTg9XQnHs4SLlwTtg+Y2oTSWCA5LOwSUWwfTwXsPxrtpSkSswkiZBmya7qBGkekr5B7yLcezLDMf4ncp8bVb0PkR6Kthor24xvtTSgyUMYUW297VezLw8jEpMcLGsqqzyLjsrUlYuSii4JsSXvrWs=;5:i43cRiayKLmuZTJf+TmuHVJT4XlvMwTRNulKii9JUjQlu18hsDbpQtIzipZkeTa27/wsmCjc4dcLe0ryd2N8r0CY5QxQgSlpDkAZiK68fyyavdTkts/O6wiC2omp5tfuEZP+VZaT9JBszlik89F0rIKydop0rfwpdrJr0wua+ds=;24:ECZFOv8JKOMcRTdHiVNtHmDGgKdlCaiW2x6dUFG3yphWV+Bqeo2u5ZH57Ch27vQzQgYZhzWizjxegFVRGZqNrp6z4YaRxU8pBvO2tovfQ1U= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR11MB1367;7:pUiW9JeGtS9cmHNwKCgLujr/cv58wi8t5Ixv1Gm4EXBxbUKZHn+JXn/AhD4PNQVmXGrYTZWUbdPr75UeTYjtj0ynIdx5IDKoONyUPQX334P793B5HXaYRPu6KppCUByz26sikhbuoQf1NM9BJSgEcXgHUmCEhY5qaMXWRuu0xFC8dzi+wRstmZzCfbRg8W460R+16Frb/9usT3i5G8Dh4NeZKiznEM/sGbPsQzyUDjxvnfCF3FzIQ64e7XVmh0hm7wh6OKRMLabnn8BOFLGJmcp4rCe62gS5iUm3evr76Ko4sF4xSsyI8hwBYZx5zzVFRmjQhBp3vXgBWZQV1GHGfQ== X-OriginatorOrg: maximintegrated.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2017 14:54:22.9462 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1367 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4449 Lines: 140 Signed-off-by: Ryan Lee --- 'DAI Sel Mux' was added. 'max98927_volatile_reg' was added to identify volatile register. sound/soc/codecs/max98927.c | 60 +++++++++++++++++++++++++++++++++------------ sound/soc/codecs/max98927.h | 2 -- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index df2f4ff..6eb745bd 100755 --- a/sound/soc/codecs/max98927.c +++ b/sound/soc/codecs/max98927.c @@ -446,11 +446,24 @@ static int max98927_dac_event(struct snd_soc_dapm_widget *w, return 0; } +static const char * const max98927_switch_text[] = { + "Left", "Right", "LeftRight"}; + +static const struct soc_enum dai_sel_enum = + SOC_ENUM_SINGLE(MAX98927_R0025_PCM_TO_SPK_MONOMIX_A, + MAX98927_PCM_TO_SPK_MONOMIX_CFG_SHIFT, + 3, max98927_switch_text); + +static const struct snd_kcontrol_new max98927_dai_controls = + SOC_DAPM_ENUM("DAI Sel", dai_sel_enum); + static const struct snd_soc_dapm_widget max98927_dapm_widgets[] = { SND_SOC_DAPM_AIF_IN("DAI_OUT", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_DAC_E("Amp Enable", "HiFi Playback", MAX98927_R003A_AMP_EN, 0, 0, max98927_dac_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX("DAI Sel Mux", SND_SOC_NOPM, 0, 0, + &max98927_dai_controls), SND_SOC_DAPM_OUTPUT("BE_OUT"), }; @@ -476,12 +489,14 @@ static int max98927_spk_gain_put(struct snd_kcontrol *kcontrol, struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); unsigned int sel = ucontrol->value.integer.value[0]; - if (sel < ((1 << MAX98927_Speaker_Gain_Width) - 1)) { - regmap_update_bits(max98927->regmap, - MAX98927_R003C_SPK_GAIN, - MAX98927_SPK_PCM_GAIN_MASK, sel); - max98927->spk_gain = sel; - } + /* 0x7 is reserved */ + if (sel > 6) + return -EINVAL; + + regmap_update_bits(max98927->regmap, + MAX98927_R003C_SPK_GAIN, + MAX98927_SPK_PCM_GAIN_MASK, sel); + max98927->spk_gain = sel; return 0; } @@ -538,6 +553,15 @@ static int max98927_amp_vol_get(struct snd_kcontrol *kcontrol, MAX98927_AMP_VOL_SHIFT); } +static int max98927_amp_vol_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + return max98927_reg_put(kcontrol, ucontrol, + MAX98927_R0036_AMP_VOL_CTRL, + MAX98927_AMP_VOL_SEL, + MAX98927_AMP_VOL_SHIFT); +} + static int max98927_amp_dsp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -587,14 +611,6 @@ static int max98927_dre_en_get(struct snd_kcontrol *kcontrol, MAX98927_R0039_DRE_CTRL, MAX98927_DRE_CTRL_DRE_EN, 0); } -static int max98927_amp_vol_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - return max98927_reg_put(kcontrol, ucontrol, - MAX98927_R0036_AMP_VOL_CTRL, - MAX98927_AMP_VOL_SEL, - 7); -} static int max98927_spk_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -646,6 +662,15 @@ static bool max98927_readable_register(struct device *dev, unsigned int reg) case MAX98927_R0100_SOFT_RESET: case MAX98927_R01FF_REV_ID: return true; + } + return false; +}; + +static bool max98927_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case MAX98927_R0001_INT_RAW1 ... MAX98927_R0009_INT_FLAG3: + return true; default: return false; } @@ -711,7 +736,11 @@ static const struct snd_kcontrol_new max98927_snd_controls[] = { }; static const struct snd_soc_dapm_route max98927_audio_map[] = { - {"BE_OUT", NULL, "Amp Enable"}, + {"Amp Enable", NULL, "DAI_OUT"}, + {"DAI Sel Mux", "Left", "Amp Enable"}, + {"DAI Sel Mux", "Right", "Amp Enable"}, + {"DAI Sel Mux", "LeftRight", "Amp Enable"}, + {"BE_OUT", NULL, "DAI Sel Mux"}, }; static struct snd_soc_dai_driver max98927_dai[] = { @@ -888,6 +917,7 @@ static const struct regmap_config max98927_regmap = { .reg_defaults = max98927_reg, .num_reg_defaults = ARRAY_SIZE(max98927_reg), .readable_reg = max98927_readable_register, + .volatile_reg = max98927_volatile_reg, .cache_type = REGCACHE_RBTREE, }; diff --git a/sound/soc/codecs/max98927.h b/sound/soc/codecs/max98927.h index 2de8504..e13e18a 100755 --- a/sound/soc/codecs/max98927.h +++ b/sound/soc/codecs/max98927.h @@ -264,6 +264,4 @@ struct max98927_priv { unsigned int master; unsigned int digital_gain; }; -#define MAX98927_Speaker_Gain_Width 3 -#define MAX98927_AMP_VOL_LOCATION_SHIFT 7 #endif -- 2.7.4