From patchwork Thu May 12 21:52:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 9086371 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 1D9969F1D3 for ; Thu, 12 May 2016 21:52:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 025E120256 for ; Thu, 12 May 2016 21:52:35 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C035320225 for ; Thu, 12 May 2016 21:52:32 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 14DE9266663; Thu, 12 May 2016 23:52:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAD_ENC_HEADER,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 42641260564; Thu, 12 May 2016 23:52:22 +0200 (CEST) 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 0C69A264F53; Thu, 12 May 2016 23:52:21 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0128.outbound.protection.outlook.com [104.47.0.128]) by alsa0.perex.cz (Postfix) with ESMTP id 8385A26047C for ; Thu, 12 May 2016 23:52:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentiatech.onmicrosoft.com; s=selector1-axentia-se; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Bb/aPlgVr5eeC3EgiCaKcJ2/+UyXbKhSJrrrJwRzU+g=; b=XbgfhhzsjU1XcQf2yrRVcRKbGAKOikZa2CNOcTIrPn2VQnORPID92T0d2VGo8jXvAgpA5x98FMOrzt0uvBT7EsQ91qqa0KMCE/IWClyX87j3EyQ/TLrsIFFS5GQ5nSrFJuzwZnhtDEybtlfyeghHeJTAVIs2lWRLC3NGlb6ZPwY= Authentication-Results: alsa-project.org; dkim=none (message not signed) header.d=none;alsa-project.org; dmarc=none action=none header.from=axentia.se; Received: from [192.168.0.125] (217.210.101.82) by DB5PR02MB1303.eurprd02.prod.outlook.com (10.164.177.149) with Microsoft SMTP Server (TLS) id 15.1.492.11; Thu, 12 May 2016 21:52:12 +0000 To: References: <1463067301-6047-1-git-send-email-peda@axentia.se> From: Peter Rosin Message-ID: <4e38e1c2-217a-ae97-90e6-440820d0ff0a@axentia.se> Date: Thu, 12 May 2016 23:52:06 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <1463067301-6047-1-git-send-email-peda@axentia.se> X-Originating-IP: [217.210.101.82] X-ClientProxiedBy: HE1PR05CA0015.eurprd05.prod.outlook.com (10.162.181.25) To DB5PR02MB1303.eurprd02.prod.outlook.com (10.164.177.149) X-MS-Office365-Filtering-Correlation-Id: c523a4e8-4e38-432f-6471-08d37aafad28 X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1303; 2:wB/SYg+qjR76AxlMU+mF7AXBOZ6TThe6qO5kw1OtGlQBHPyAPoWgruGMCu2Hfm2bnVrNFmL5gmjeZwJhZ/1LnFNuysmwnkCLGATWkFY+gM1qutsWfm+4AAT79iww5+D65YwGwMrby9CAE+DE1hlVqYNxHjDSKsyiOcb8Np0x1jeyd08WbUYV47CJOKISlMn5; 3:NeF0X4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riScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040130)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041072)(6043046); SRVR:DB5PR02MB1303; BCL:0; PCL:0; RULEID:; SRVR:DB5PR02MB1303; X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1303; 4:CVMNXA6HWyKton6xNjrUMdOjNF6eHWEL7rnNObmMJbzEjkO0F7/+53VAuYIjeYanEOXyzQcocVKOb+R+78JEWSwkG37KortIl9UOKgOmxe9LPp7XGK/UqGZcLCf6Qhb2613d/RYBXY5cPS0xzgavxcp7pSQ2cwii0bhtOna7HpIEUt6uf6JirHVNo+z8+PTecGIvEet+haeWzW30DbYZAfCvSs82iSwspubH5sj172Q6SlfAEGoSLDNQji0bZLBb80+PC4L0IOFpV9MmxvzkOMXZZfzexE86Cbq85jeMqs+GfRftiXPFnmc+T8IPXN08Ol2A3OKr6OVnqPvUZ0Et7AOFfoUgrwOP/v0mVX/AKD6/77qKXeqQWRLRKZBAt3lh5LOPf1gwsTsoSr3q17J+X2b4TaOUhg2tw5jeRL9SDaI= X-Forefront-PRVS: 0940A19703 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6049001)(377424004)(24454002)(110136002)(586003)(5008740100001)(33646002)(54356999)(76176999)(4001350100001)(2351001)(5004730100002)(2950100001)(23746002)(50986999)(47776003)(117156001)(66066001)(42186005)(86362001)(575784001)(92566002)(15975445007)(2906002)(19580395003)(19580405001)(31686004)(4326007)(81166006)(189998001)(36756003)(31696002)(65956001)(64126003)(6116002)(3846002)(230700001)(65806001)(74482002)(83506001)(50466002)(77096005)(65826006)(42262002)(309714004); DIR:OUT; SFP:1102; SCL:1; SRVR:DB5PR02MB1303; H:[192.168.0.125]; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; DB5PR02MB1303; 23:FYXtlOIZ7pzAxYVIwdvswS0IkqkpDd5LOoFNy?= =?Windows-1252?Q?cjBvHG1Zk+Peki+ebvj95URK17l9VFcPMUNeTl6m28TImQ7cMtngX1UK?= =?Windows-1252?Q?pm3vOxpRxpgoAVHOwLFoOXxIlTHDZybv2UGItJuJWf8C96igahxoPKfO?= =?Windows-1252?Q?7nbnJ0SsK3aNPxOTRqkz6egygXv9IlL2ppNNjiejatzguDQcMbgk96Hu?= =?Windows-1252?Q?K/Qn+75GgkvVxtuBDb9loIUjaJi1GG8/vLvl35NgZDLV8biD6Of9GAdy?= =?Windows-1252?Q?V/upkjJkliDhYFCctuII8o5+9Eec39qnZlwTMIZi2NoGH6f5ILMfcQdx?= =?Windows-1252?Q?Sq+QYxoQjv8HG93RK5wUJSM6aEuhdKHia05k5U3T3bsAeaavzVpGKaHu?= =?Windows-1252?Q?Ht66n/nJjcZAsHRb6CAm4jBBzwAyWD+qPnWHQN3cEjcfbkszjvDGxemG?= =?Windows-1252?Q?HPVLwPM9sl+sM6EXZQo1z3hKkHzlhf9F4GKfLsHShSvSXcQ71A/T4yXZ?= =?Windows-1252?Q?VxHD96rGFfiRBqvrzBS0+y4ah6+DCGMQ1RxwfahaxFIl9Y6wjSDUthTS?= =?Windows-1252?Q?Wu0bWbH0wWs4MlpVBTsJeLGGsfNHpeijYA/+I/y39fMIh/SI/ibzY/lO?= =?Windows-1252?Q?ZKc3Cqyr5uiHD5TpfwpNTl19zvaxc2GeKDeZFxq3HWOyAV/rtL1DwBcr?= =?Windows-1252?Q?CRXuYSBkCu7gwRcaHwAi9ozxHQaf1MBd3gtClWBVWf57UhO+5J+0/xIX?= =?Windows-1252?Q?i8pFS4PXwDmzuqCcFzi5wOZHeTBxE2HPSwSp3Jn4BQXVGJsmrEyDfT+a?= =?Windows-1252?Q?iH9hNuSkuXk+pezDlkQKXcQ5wCR4Sj6QmcD6bfOVcOoqEd5JHA3mZKt7?= =?Windows-1252?Q?SQ+fBqOQAbASAx4o34IsPmPgutqVU8yhfUazKNnpJrO833q/Ih8L/PVF?= =?Windows-1252?Q?mNP22JdlDU5xQxnl/qd5DQjhZ9AAUiDYXYdWrB13QOljOs0SKVC4+3OU?= =?Windows-1252?Q?XkyWruldzahJPWNvfCCjZxSZ1u0PZsJki6QvZOD3OWEODdKPuJZr3Cd/?= =?Windows-1252?Q?dzOOihe64QUTCIpJBFKxB4ajtQeIWOuG4GGkbdSXVcEmgKWeC1OMPpUV?= =?Windows-1252?Q?NUCyCv98swVVbcu7jOBVHrsk2frJeM7GuLjKajP0v7pKBNLbZidGr3F8?= =?Windows-1252?Q?NuekvMaZ/I3TeiY+ofRXJhLq7CW/5f8FCddSp1TIiPoa2RvTGG7SZ4vR?= =?Windows-1252?Q?CLoDNT45TmEoE3CoqJwfikqOr+UmGPcKKRNHdrdKb8Li4tBaM/b2Xg9u?= =?Windows-1252?Q?TILKJ2rhs0lM4mxfhBmKSks/Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1303; 5:ti4EcaLPqLLrxHVZqLFOEuQm9n5vIXRh2R9zf5MjxdKC1zVB1AnWlb8CubzVkoa1m76U8bZ6jqHvFA2Z84M42D8Ps7QrATqGX+kEVscUxNjTvMaUMHx9WywpmTEaeVfIwlRqZuzWq0UbG88daKDhTQ==; 24:0Hwj7UHkI1gYbbsMDedp3pt7WsGgby32Nml6Azrq5xbcqmXlXfKIBlreGT4DFQzKXXFjDGPanJpfBpewwY8jCNXv20I9D0yGmcjhXn/B35g=; 7:SEVykurFhUAhl9MaPK3JNxHrRg9JSHNKXbAR5Q74jx8aCIE81PuxkNESPndnMkFBQYQ4ftfkLaEiORfKNLlZKQfMgTsLEnthZAfzdprPaukxfmienm8U4MqrZJE9rhC36owWOyBQE9i8jmEM6KeLyHrh09m2JwCZaE9g3OalpP18+WkhtqyRKCqXIMfpAplK SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2016 21:52:12.2030 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR02MB1303 Cc: alsa-devel@alsa-project.org, Takashi Iwai , Liam Girdwood , Mark Brown , Misbah Ullah Khan Subject: Re: [alsa-devel] [PATCH v2] ASoC: MAX9860: new driver 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP [Dropping the DT crowd] On 2016-05-12 17:35, Peter Rosin wrote: > This is a driver for the MAX9860 Mono Audio Voice Codec. > > https://datasheets.maximintegrated.com/en/ds/MAX9860.pdf > > This driver does not support sidetone since the DVST register field is > backwards with the mute near the maximum level instead of the minimum. This is what I have (on top of v2). It kind of works, but as you can see, the mute_value is needed in dapm_set_mixer_path_status which operates on entries in path->sink->kcontrol_news[] which I believe is constant. That kind of defeats the runtime TLV lookup thing storing the value, no? So, I allow setting the mute_value manually instead. I could have created new macros to help create the mixer control, but didn't. Perhaps I should have? I also noted that with this, an "on" sidetone will keep the system up. Ideally the sidetone volsw should only have the power to turn on the DAC and the left ADC when the DAC is "on" for other reasons. At the same time the sidetone needs to turn on the left channel ADC when the DAC is "on", so using DAPM seems like the right thing. Is this an old problem that have been solves elsewhere? If so, how is that handled in other codecs? Cheers, Peter diff --git a/include/sound/soc.h b/include/sound/soc.h index 02b4a215fd75..79b6a2f2a3a9 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1239,6 +1239,7 @@ struct soc_mixer_control { unsigned int sign_bit; unsigned int invert:1; unsigned int autodisable:1; + int mute_value; struct snd_soc_dobj dobj; }; diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index c4464858bf01..765dfdfe0f4a 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -732,6 +732,7 @@ static void dapm_set_mixer_path_status(struct snd_soc_dapm_path *p, int i) unsigned int max = mc->max; unsigned int mask = (1 << fls(max)) - 1; unsigned int invert = mc->invert; + int mute_value = mc->mute_value; unsigned int val; if (reg != SND_SOC_NOPM) { @@ -739,7 +740,7 @@ static void dapm_set_mixer_path_status(struct snd_soc_dapm_path *p, int i) val = (val >> shift) & mask; if (invert) val = max - val; - p->connect = !!val; + p->connect = val != mute_value; } else { p->connect = 0; } @@ -3045,6 +3046,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, int max = mc->max; unsigned int mask = (1 << fls(max)) - 1; unsigned int invert = mc->invert; + int mute_value = mc->mute_value; unsigned int val; int connect, change, reg_change = 0; struct snd_soc_dapm_update update; @@ -3056,7 +3058,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, kcontrol->id.name); val = (ucontrol->value.integer.value[0] & mask); - connect = !!val; + connect = val != mute_value; if (invert) val = max - val; diff --git a/sound/soc/codecs/max9860.c b/sound/soc/codecs/max9860.c index ee30832b0afb..075874be3877 100644 --- a/sound/soc/codecs/max9860.c +++ b/sound/soc/codecs/max9860.c @@ -3,9 +3,6 @@ * * https://datasheets.maximintegrated.com/en/ds/MAX9860.pdf * - * The driver does not support sidetone since the DVST register field is - * backwards with the mute near the maximum level instead of the minimum. - * * Author: Peter Rosin * Copyright 2016 Axentia Technologies * @@ -135,6 +132,10 @@ const struct regmap_config max9860_regmap = { static const DECLARE_TLV_DB_SCALE(dva_tlv, -9100, 100, 1); static const DECLARE_TLV_DB_SCALE(dvg_tlv, 0, 600, 0); static const DECLARE_TLV_DB_SCALE(adc_tlv, -1200, 100, 0); +/* The dvst field has its mute in the wrong end. Sigh. */ +static const DECLARE_TLV_DB_RANGE(dvst_tlv, + 0, MAX9860_DVST_MIN - 1, TLV_DB_SCALE_ITEM(-6000, 200, 0), + MAX9860_DVST_MIN, MAX9860_DVST_MIN, TLV_DB_SCALE_ITEM(0, 0, 1)); static const DECLARE_TLV_DB_RANGE(pam_tlv, 0, MAX9860_PAM_MAX - 1, TLV_DB_SCALE_ITEM(-2000, 2000, 1), MAX9860_PAM_MAX, MAX9860_PAM_MAX, TLV_DB_SCALE_ITEM(3000, 0, 0)); @@ -214,6 +215,21 @@ SOC_ENUM("ADC Filter", avflt_enum), SOC_ENUM("DAC Filter", dvflt_enum), }; +static const struct snd_kcontrol_new max9860_mixer_controls[] = { +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Sidetone Volume", + .info = snd_soc_info_volsw, + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ + | SNDRV_CTL_ELEM_ACCESS_READWRITE, + .tlv.p = dvst_tlv, + .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, + .private_value = ((unsigned long)&(struct soc_mixer_control) { + .reg = MAX9860_DACGAIN, .rreg = MAX9860_DACGAIN, + .shift = MAX9860_DVST_SHIFT, .rshift = MAX9860_DVST_SHIFT, + .max = MAX9860_DVST_MIN, .platform_max = MAX9860_DVST_MIN, + .invert = 1, .autodisable = 0, .mute_value = MAX9860_DVST_MIN + })}, +}; + static const struct snd_soc_dapm_widget max9860_dapm_widgets[] = { SND_SOC_DAPM_INPUT("MICL"), SND_SOC_DAPM_INPUT("MICR"), @@ -224,6 +240,10 @@ SND_SOC_DAPM_ADC("ADCR", NULL, MAX9860_PWRMAN, MAX9860_ADCREN_SHIFT, 0), SND_SOC_DAPM_AIF_OUT("AIFOUTL", "Capture", 0, SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_AIF_OUT("AIFOUTR", "Capture", 1, SND_SOC_NOPM, 0, 0), +SND_SOC_DAPM_MIXER("Mixer", SND_SOC_NOPM, 0, 0, + max9860_mixer_controls, + ARRAY_SIZE(max9860_mixer_controls)), + SND_SOC_DAPM_AIF_IN("AIFINL", "Playback", 0, SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_AIF_IN("AIFINR", "Playback", 1, SND_SOC_NOPM, 0, 0), @@ -244,8 +264,10 @@ static const struct snd_soc_dapm_route max9860_dapm_routes[] = { { "AIFOUTL", NULL, "ADCL" }, { "AIFOUTR", NULL, "ADCR" }, - { "DAC", NULL, "AIFINL" }, - { "DAC", NULL, "AIFINR" }, + { "Mixer", NULL, "AIFINL" }, + { "Mixer", NULL, "AIFINR" }, + { "Mixer", "Sidetone Volume", "ADCL" }, + { "DAC", NULL, "Mixer" }, { "OUT", NULL, "DAC" }, { "Supply", NULL, "AVDD" },