Received: by 10.213.65.68 with SMTP id h4csp702744imn; Sat, 31 Mar 2018 07:57:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx493DwYNl1/JSDaE9Uv28ygwq+e0YvBf2ysxw2NM7/KnyUg8vB6xG1T4C6vximMj/lMUgWby X-Received: by 10.98.35.90 with SMTP id j87mr2364129pfj.59.1522508272666; Sat, 31 Mar 2018 07:57:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522508272; cv=none; d=google.com; s=arc-20160816; b=TT7pMyTcl8J09LXzWYO2dr6mc3zBP8HeNhjdD3s1db/yNiPgLukLFYTHgGixslczmX ZoTbSTB78VgqI7drEIOL6D41HOqSJdb7AsgHx3keMzcnrKZ/mz1b515luiGk2pYIDuKM 3u7QE8O6A46uRi7ZVVlWGh1pnLz2mug+6AawdroFluqd8ltvbeuWWaeNjc14t96tI5Wq 4NH3vVg5b7uGLt66OzbyRRc37teib7zcdzmQKVDaGFhpav18bTN2wqEX4ow4mmDVGIul NgSUYyYCCe5a5+KYwlxFKKY/4oeNFnVL1XGktVzVXaOzztcLiXGdmgU5bcBlLa3xPOxr 8JVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=2GAsaGQVIrcOJwIiV6VHMHLssn2zyLEC8OmHrqreGnE=; b=GQPHSTIWaOWdcP77pq5Jhsn/kNkQkHGJC47sU3IozKJNEr6MRzKgzmDx8iiAPPv12U MTTalps1zf0wcjposSUvEWecqeOLEJ79trb9p2pcdFfSFDGH5T85x37IzqH3qclT0rNJ oADNlQJX9AyPadS2P4nBqIyTw//tRDwZLAn1E4La//rXlZwI8u/fKPVkNa27ZtVYJpyO CEQ/W2Kb5+r398G42Lsrq9T2VA5rTP88TU16M7vv7qGsHORpQSJQ0GWSut9qcXNz/z2R PsMmTOkYiYMOg5IeK9EvmSDmCWtTZ4YM6fTFH8lTbTl0/ZqUFuijHOWk5YXKSM3sSE7z mczQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1-v6si6366532plq.431.2018.03.31.07.57.25; Sat, 31 Mar 2018 07:57:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752869AbeCaOzg (ORCPT + 99 others); Sat, 31 Mar 2018 10:55:36 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:47022 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752358AbeCaOze (ORCPT ); Sat, 31 Mar 2018 10:55:34 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 6F01A803E8; Sat, 31 Mar 2018 16:55:32 +0200 (CEST) Date: Sat, 31 Mar 2018 16:55:32 +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: call/normal switch was Re: omap4-droid4: voice call support was Message-ID: <20180331145531.GA10404@amd> References: <20180322234832.o24ut5ahon46mdu4@earth.universe> <20180323100930.GA21644@amd> <20180323103006.alymgb3ywftb4gek@earth.universe> <20180326141638.GB1450@amd> <20180326155828.ttnduivadob4iqmd@earth.universe> <20180327121441.GH29239@sirena.org.uk> <20180327222237.wcx2aqznvdrvbaa5@earth.universe> <20180328022910.GM29239@sirena.org.uk> <20180328140219.f6667up5evrrafkv@earth.universe> <20180329014507.GM5700@atomide.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qDbXVdCdHGoSgWSk" Content-Disposition: inline In-Reply-To: <20180329014507.GM5700@atomide.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --qDbXVdCdHGoSgWSk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > Hmm well I got audio call hacked to work as a proof of concept hack, > see below. Maybe it can be used to verify some of the assumptions > above. >=20 > Then.. To split the work a bit, can you guys maybe try to decode > the cpcap register values and try to do a proper ASoC driver patch? This is not proper patch yet, but it should be a step in that direction... If someone knows how to express cleanly "active support for modem is the same as active audio playback", let me know.... Best regards, Pavel diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c index 3b53bd0..7aaa4db 100644 --- a/sound/soc/codecs/cpcap.c +++ b/sound/soc/codecs/cpcap.c @@ -221,18 +221,18 @@ struct cpcap_reg_info { }; =20 static const struct cpcap_reg_info cpcap_default_regs[] =3D { - { CPCAP_REG_CC, 0xFFFF, 0x0000 }, - { CPCAP_REG_CC, 0xFFFF, 0x0000 }, - { CPCAP_REG_CDI, 0xBFFF, 0x0000 }, + { CPCAP_REG_CC, 0xFFFF, 0x60cf }, + { CPCAP_REG_CDI, 0xBFFF, 0xae0a }, { CPCAP_REG_SDAC, 0x0FFF, 0x0000 }, { CPCAP_REG_SDACDI, 0x3FFF, 0x0000 }, - { CPCAP_REG_TXI, 0x0FDF, 0x0000 }, - { CPCAP_REG_TXMP, 0x0FFF, 0x0400 }, - { CPCAP_REG_RXOA, 0x01FF, 0x0000 }, - { CPCAP_REG_RXVC, 0xFF3C, 0x0000 }, - { CPCAP_REG_RXCOA, 0x07FF, 0x0000 }, - { CPCAP_REG_RXSDOA, 0x1FFF, 0x0000 }, + { CPCAP_REG_TXI, 0x0FFF, 0x0CC0 }, + { CPCAP_REG_TXMP, 0x0FFF, 0x0610 }, + { CPCAP_REG_RXOA, 0x01FF, 0x0006 }, + { CPCAP_REG_RXVC, 0xFF3C, 0x0B2C }, + { CPCAP_REG_RXCOA, 0x07FF, 0x0606 }, + { CPCAP_REG_RXSDOA, 0x1FFF, 0x0600 }, { CPCAP_REG_RXEPOA, 0x7FFF, 0x0000 }, + { CPCAP_REG_VAUDIOC, 0xFFFF, 0x0025 }, { CPCAP_REG_A2LA, BIT(CPCAP_BIT_A2_FREE_RUN), BIT(CPCAP_BIT_A2_FREE_RUN) }, }; @@ -330,6 +330,11 @@ static const char * const cpcap_in_left_mux_texts[] = =3D { "Off", "Mic 2", "Ext Left" }; =20 +static const char * const cpcap_mode_texts[] =3D { + "Normal", "Call" +}; + + /* * input muxes use unusual register layout, so that we need to use custom * getter/setter methods @@ -354,6 +359,8 @@ static SOC_ENUM_SINGLE_DECL(cpcap_hs_l_mux_enum, 0, 6, = cpcap_out_mux_texts); static SOC_ENUM_SINGLE_DECL(cpcap_emu_l_mux_enum, 0, 7, cpcap_out_mux_text= s); static SOC_ENUM_SINGLE_DECL(cpcap_emu_r_mux_enum, 0, 8, cpcap_out_mux_text= s); =20 +static SOC_ENUM_SINGLE_DECL(cpcap_mode_enum, 0, 9, cpcap_mode_texts); + static int cpcap_output_mux_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -442,6 +449,86 @@ static int cpcap_output_mux_put_enum(struct snd_kcontr= ol *kcontrol, return 0; } =20 +static int mode; + +static int cpcap_mode_get_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec =3D snd_soc_dapm_kcontrol_codec(kcontrol); + struct cpcap_audio *cpcap =3D snd_soc_codec_get_drvdata(codec); + struct soc_enum *e =3D (struct soc_enum *)kcontrol->private_value; + int err; + + ucontrol->value.enumerated.item[0] =3D mode; + + return 0; +} + +static int cpcap_mode_put_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec =3D snd_soc_dapm_kcontrol_codec(kcontrol); + struct cpcap_audio *cpcap =3D snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm =3D + snd_soc_dapm_kcontrol_dapm(kcontrol); + struct soc_enum *e =3D (struct soc_enum *)kcontrol->private_value; + unsigned int muxval =3D ucontrol->value.enumerated.item[0]; + unsigned int mask =3D BIT(e->shift_l); + int err; + + printk("Requested mode %d\n", muxval); + + mode =3D muxval; + + switch (muxval) { + case 1: + + err =3D regmap_update_bits(cpcap->regmap, CPCAP_REG_VAUDIOC, + 0xffff, 0x0025); // OK + if (err) + goto out; + err =3D regmap_update_bits(cpcap->regmap, CPCAP_REG_CC, + 0xffff, 0x60cf); // OK + if (err) + goto out; + err =3D regmap_update_bits(cpcap->regmap, CPCAP_REG_CDI, + 0xffff, 0xae0a); // OK + if (err) + goto out; + err =3D regmap_update_bits(cpcap->regmap, CPCAP_REG_TXI, + 0xffff, 0x0cc0); + if (err) + goto out; + =09 + mask =3D 1 << CPCAP_BIT_PGA_CDC_EN | 0x200; + err =3D regmap_update_bits(cpcap->regmap, CPCAP_REG_RXCOA, + mask, mask); + if (err) + printk("error #3\n"); + + mask =3D 1 << CPCAP_BIT_A2_LDSP_L_EN | 1 << CPCAP_BIT_A2_LDSP_R_EN; + err =3D regmap_update_bits(cpcap->regmap, CPCAP_REG_RXOA, + mask, mask); + if (err) + printk("error #2\n"); + =09 + err =3D regmap_update_bits(cpcap->regmap, 0x814, + 0x0400, 0x0400); + if (err) + printk("error #1\n"); + =09 + default: + break; + } + + // FIXME +// snd_soc_dapm_mux_update_power(dapm, kcontrol, muxval, e, NULL); + + return 0; +out: printk("Something failed\n"); + return -EINVAL; +} + static int cpcap_input_right_mux_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -630,6 +717,11 @@ static const struct snd_kcontrol_new cpcap_earpiece_mu= x =3D SOC_DAPM_ENUM_EXT("Earpiece", cpcap_earpiece_mux_enum, cpcap_output_mux_get_enum, cpcap_output_mux_put_enum); =20 +static const struct snd_kcontrol_new cpcap_mode =3D + SOC_DAPM_ENUM_EXT("Mode", cpcap_mode_enum, + cpcap_mode_get_enum, cpcap_mode_put_enum); + + static const struct snd_kcontrol_new cpcap_hifi_mono_mixer_controls[] =3D { SOC_DAPM_SINGLE("HiFi Mono Playback Switch", CPCAP_REG_RXSDOA, CPCAP_BIT_MONO_DAC1, 1, 0), @@ -771,6 +863,10 @@ static const struct snd_soc_dapm_widget cpcap_dapm_wid= gets[] =3D { SND_SOC_DAPM_MUX("EMU Left Playback Route", SND_SOC_NOPM, 0, 0, &cpcap_emu_left_mux), =20 + + SND_SOC_DAPM_MUX("Mode", SND_SOC_NOPM, 0, 0, + &cpcap_mode), +=09 /* Output Amplifier */ SND_SOC_DAPM_PGA("Earpiece PGA", CPCAP_REG_RXOA, CPCAP_BIT_A1_EAR_EN, 0, NULL, 0), @@ -816,6 +912,9 @@ static const struct snd_soc_dapm_route intercon[] =3D { {"Microphone 1 PGA", NULL, "VAUDIO"}, {"Microphone 2 PGA", NULL, "VAUDIO"}, =20 + /* FIXME */ + {"Mode", NULL, "Voice TX"}, + /* Stream -> AIF */ {"HiFi RX", NULL, "HiFi Playback"}, {"Voice RX", NULL, "Voice Playback"}, --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --qDbXVdCdHGoSgWSk Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlq/oWMACgkQMOfwapXb+vKrEgCffQ5gAH4mNGSZevLA0Oc4iEIX xioAnRYG8nJuNbNQN/W7BSdThzKP7yny =MoyO -----END PGP SIGNATURE----- --qDbXVdCdHGoSgWSk--