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: 10321825 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 253C1602C8 for ; Tue, 3 Apr 2018 22:11:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14E9528D0A for ; Tue, 3 Apr 2018 22:11:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0965A28D1B; Tue, 3 Apr 2018 22:11:31 +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=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_TVD_MIME_EPI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9428C28D0A for ; Tue, 3 Apr 2018 22:11:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753356AbeDCWLQ (ORCPT ); Tue, 3 Apr 2018 18:11:16 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:46482 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753289AbeDCWLP (ORCPT ); Tue, 3 Apr 2018 18:11:15 -0400 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 Cc: Sebastian Reichel , Mark Brown , Liam Girdwood , Rob Herring , Lee Jones , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-omap@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Dan Williams Subject: Re: call/normal switch was Re: omap4-droid4: voice call support was 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 Content-Disposition: inline In-Reply-To: <20180401153631.GA5700@atomide.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.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;