From patchwork Tue Apr 3 22:11:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 10321821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7155D60532 for ; Tue, 3 Apr 2018 22:11:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5702C28D17 for ; Tue, 3 Apr 2018 22:11:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5585F28D0A; Tue, 3 Apr 2018 22:11:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF5FA28D1A for ; Tue, 3 Apr 2018 22:11:22 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 26250267610; Wed, 4 Apr 2018 00:11:20 +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 268C8267610; Wed, 4 Apr 2018 00:11:18 +0200 (CEST) Received: from atrey.karlin.mff.cuni.cz (atrey.karlin.mff.cuni.cz [195.113.26.193]) by alsa0.perex.cz (Postfix) with ESMTP id 74CB4266CE7 for ; Wed, 4 Apr 2018 00:11:14 +0200 (CEST) Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id CD9BE8043E; Wed, 4 Apr 2018 00:11:13 +0200 (CEST) Date: Wed, 4 Apr 2018 00:11:13 +0200 From: Pavel Machek To: Tony Lindgren Message-ID: <20180403221113.GA9463@amd> References: <20180328140219.f6667up5evrrafkv@earth.universe> <20180329014507.GM5700@atomide.com> <20180331145531.GA10404@amd> <20180331181935.GX5700@atomide.com> <20180331191939.GA8999@amd> <20180331194616.GA19388@amd> <20180331195524.GB19388@amd> <20180331234314.GZ5700@atomide.com> <20180401131852.GA11086@amd> <20180401153631.GA5700@atomide.com> MIME-Version: 1.0 In-Reply-To: <20180401153631.GA5700@atomide.com> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, kernel@collabora.com, Dan Williams , linux-kernel@vger.kernel.org, Takashi Iwai , Liam Girdwood , Rob Herring , Mark Brown , Sebastian Reichel , linux-omap@vger.kernel.org, Lee Jones Subject: Re: [alsa-devel] call/normal switch was Re: omap4-droid4: voice call support was 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 Hi! > > If you had a register dump from android with mics working, preferably > > not in speaker mode, perhaps I could try to figure it out? > > OK here are four diffs against starting the phone app for regular > call, speaker call, and muted versions of them: > > http://muru.com/linux/d4/cpcap/ > > Also, I'm connected over cdma right now, not 3g, but I doubt > that makes a difference for the microphone. Thanks! When I apply register settings directly, I indeed get working "normal" call working. Good. Diff for illustration is below. Clearly needs some improvements. And it shows that alsa mixers are expected to be simple and obvious on D4 -- they just do not work. Current version of phone gui is at https://github.com/pavelmachek/unicsy_demo - ofono interface should be usable - AT commands need a lot more work, and they'll probably never work nicely in this design. They are just a temporary hack. (ouch, and it should be rewritten, in Vala or better Rust...) Pavel commit 06acc26c318558ed6a50b5a22afffeb9abbe7553 Author: Pavel Date: Wed Apr 4 00:04:34 2018 +0200 Add support for "normal" (not handsfree) call. diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c index 7aaa4db..59c02b7 100644 --- a/sound/soc/codecs/cpcap.c +++ b/sound/soc/codecs/cpcap.c @@ -331,7 +331,7 @@ static const char * const cpcap_in_left_mux_texts[] = { }; static const char * const cpcap_mode_texts[] = { - "Normal", "Call" + "Normal", "Handsfree", "Call", }; @@ -464,25 +464,11 @@ static int cpcap_mode_get_enum(struct snd_kcontrol *kcontrol, return 0; } -static int cpcap_mode_put_enum(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) +static int enable_call(struct cpcap_audio *cpcap, int on) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = - snd_soc_dapm_kcontrol_dapm(kcontrol); - struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - unsigned int muxval = ucontrol->value.enumerated.item[0]; - unsigned int mask = BIT(e->shift_l); int err; - - printk("Requested mode %d\n", muxval); - - mode = muxval; - - switch (muxval) { - case 1: - + unsigned long mask; + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_VAUDIOC, 0xffff, 0x0025); // OK if (err) @@ -516,6 +502,56 @@ static int cpcap_mode_put_enum(struct snd_kcontrol *kcontrol, 0x0400, 0x0400); if (err) printk("error #1\n"); + + return 0; +out: + printk("Error!\n"); + return -EIO; +} + +static int cpcap_mode_put_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = + snd_soc_dapm_kcontrol_dapm(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int muxval = ucontrol->value.enumerated.item[0]; + unsigned int mask = BIT(e->shift_l); + int err; + + printk("Requested mode %d\n", muxval); + + mode = muxval; + + switch (muxval) { + case 1: + enable_call(cpcap, 1); + break; + case 2: + enable_call(cpcap, 1); + + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_TXI, + 0xffff, 0x0cc6); + if (err) + goto out; + + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_TXMP, + 0xffff, 0x0673); + if (err) + goto out; + + + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_RXOA, + 0xffff, 0x0001); + if (err) + goto out; + + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_RXCOA, + 0xffff, 0x0601); + if (err) + goto out; default: break;