alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Cc: Mark Brown <broonie@kernel.org>, Pavel Machek <pavel@ucw.cz>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Lee Jones <lee.jones@linaro.org>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	alsa-devel@alsa-project.org, linux-omap@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@collabora.com, Dan Williams <dcbw@redhat.com>
Subject: Re: omap4-droid4: voice call support was Re: [PATCHv5,5/5] ARM: dts: omap4-droid4: add soundcard
Date: Wed, 28 Mar 2018 18:45:07 -0700	[thread overview]
Message-ID: <20180329014507.GM5700@atomide.com> (raw)
In-Reply-To: <20180328140219.f6667up5evrrafkv@earth.universe>

Hi,

* Sebastian Reichel <sebastian.reichel@collabora.co.uk> [180328 14:03]:
> Hi,
> 
> On Wed, Mar 28, 2018 at 10:29:10AM +0800, Mark Brown wrote:
> > On Wed, Mar 28, 2018 at 12:22:37AM +0200, Sebastian Reichel wrote:
> > > On Tue, Mar 27, 2018 at 08:14:41PM +0800, Mark Brown wrote:
> > 
> > > > No, this is exactly the sort of use case with multiple DAIs that the
> > > > graph card is intended to enable over the old simple-card.
> > 
> > > +----------+         +-------------+
> > > | OMAP4    |         | CPCAP       |
> > > |          |         |             |
> > > | [McBSP2] | <-----> | [HiFi DAI]  |
> > > |          |         |             |
> > > | [McBSP3] | <--+--> | [Voice DAI] |
> > > |          |    |    |             |
> > > +----------+    |    +-------------+
> > >                 |
> > > +----------+    |    +-------------+
> > > | MDM6600  |    |    | WL1285      |
> > > |          |    |    |             |
> > > |    [DAI] | <--+--> | [DAI]       |
> > > |          |         |             |
> > > +----------+         +-------------+
> > 
> > > Legend:
> > >     OMAP4   = SoC running Linux
> > >     CPCAP   = Audio codec
> > >     MDM6600 = Baseband
> > >     WL1285  = Bluetooth
> > 
> > > Re-reading the audio-graph-card binding document I still don't see
> > > how the network (OMAP.McBSP3, CPCAP.Voice, MDM6600, WL1285) is
> > > supposed to look like. It seems to expect point-to-point DAI
> > > connections.
> > 
> > Ugh, a TDM mux?
> 
> Yes, at least that's how I understood Motorola's code.

Hmm is there some active component doing the muxing then?
Maybe the "AT+CMUT=0" part below?

> > That's really unusual and not particularly supported yet, you'd
> > need to extend the graph card to do it.  It's where things should
> > end up for a generic card though.
> 
> Motorola's driver provided the following modes:
> 
> OMAP4 <-> CPCAP      (voice recording)
> MDM6600 <-> CPCAP    (voice call, CPU not involved)
> OMAP4 <-> WL1285     (bluetooth HFP/HSP)
> MDM6600 <-> WL1285   (bluetooth voice call)
> 
> In case of the last two variants, the bus clock is provided by
> CPCAP, so it needs to be enabled for any audio stream. I suppose
> the codec <-> codec as part of TDM is out of scope for the graph
> card and we need a Droid 4 specific card driver?

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.

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?

Meanwhile, I can try to make voice calls more reproducable with
qmi or MM for example instead of just n_gsm.. And then I'll try
to fix my n_gsm pile of hacks for posting..

Cheers,

Tony

8< --------------------------
>From tony Mon Sep 17 00:00:00 2001
From: Tony Lindgren <tony@atomide.com>
Date: Wed, 28 Mar 2018 08:29:38 -0700
Subject: [PATCH] NOT FOR MERGING: Quick hack for droid 4 mdm6600 voice
 call

Here's quick hack to allow making a voice call on mdm6600 based on
diffing the cpcap registers in Android. The patch just keeps overwriting
the cpcap values every second so it's nowhere near usable for merging,
just a test patch.

Looks like the cpcap register changes during a speaker phone audio call are:

@@ -510,17 +510,17 @@
 07f4: 0000
 07f8: 0000
 07fc: 0000
-0800: 0065
-0804: 0000
-0808: 0040
+0800: 0025     # CPCAP_REG_VAUDIOC     VAUDIO Control
+0804: 60cf     # CPCAP_REG_CC          Codec Control, moto cpcap.c:1337 sets 0x0093?
+0808: ae0a     # CPCAP_REG_CDI         Codec Digital Interface
 080c: 0000
 0810: 0004
-0814: 0804
-0818: 079c
-081c: 0000
-0820: 0924
-0824: 0000
-0828: 0000
+0814: 0cc0     # CPCAP_REG_TXI         TX Inputs, moto cpcap.c:1340 sets 0x0CC6?
+0818: 0610     # CPCAP_REG_TXMP        TX MIC PGA's, moto cpcap.c:1343 sets 0x0273?
+081c: 0006     # CPCAP_REG_RXOA        RX Output Amplifiers
+0820: 0b2c     # CPCAP_REG_RXVC        RX Volume Control
+0824: 0606     # CPCAP_REG_RXCOA       RX Codec to Output Amps
+0828: 0600     # CPCAP_REG_RXSDOA      RX Stereo DAC to Output Amps
 082c: 0400
 0830: 0000
 0834: 0030

I wonder if mdm6600 is the i2s master during the voice call?

Then using the n_gsm ts 27.010 uart mux, I dial:

./ngsm-rw 1 "AT+CFUN=1"		# connect to network
U0001+CFUN:OK
./ngsm-rw 2 "AT+CMUT=0"		# unmute speaker over ch2, do this over qmi?
U0001+CMUT:OK
./ngsm-rw 1 "ATD#123"		# dial number
U0001D:OK

And I do hear a voice talking over the speakerphone :) Sorry have not tested the
mic yet..

FYI, the ngsm-rw script I use is just:

#!/bin/sh

if [ "${1}" == "" ]; then
        echo "Usage: $0 port command"
        exit 1
fi

port=${1}
command=${2}

exec 3<>/dev/gsmtty${port}
printf "U0001%s\r\0" ${command} >&3
read result <&3
exec 3>&-
exec 3<&-

echo ${result}

My n_gsm patches are not quite ready yet sorry.. But meanwhile hopefully this
can be somehow also done using qmi. At least "AT+CMUT=0" fails over ttyUSB4.
---
 sound/soc/codecs/cpcap.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c
--- a/sound/soc/codecs/cpcap.c
+++ b/sound/soc/codecs/cpcap.c
@@ -251,6 +251,8 @@ struct cpcap_audio {
 	int codec_clk_id;
 	int codec_freq;
 	int codec_format;
+
+	struct delayed_work work;
 };
 
 static int cpcap_st_workaround(struct snd_soc_dapm_widget *w,
@@ -1500,6 +1502,57 @@ static int cpcap_audio_reset(struct snd_soc_component *component,
 	return 0;
 }
 
+static void cpcap_soc_work(struct work_struct *work)
+{
+	struct cpcap_audio *cpcap = container_of(work,
+						 struct cpcap_audio,
+						 work.work);
+	struct device *dev = cpcap->component->dev;
+	int error;
+
+	dev_info(dev, "Somebody do a proper driver please %s\n", __func__);
+
+	error = regmap_update_bits(cpcap->regmap, CPCAP_REG_VAUDIOC,
+				   0xffff, 0x0025);
+	if (error)
+		goto out;
+	error = regmap_update_bits(cpcap->regmap, CPCAP_REG_CC,
+				   0xffff, 0x60cf);
+	if (error)
+		goto out;
+	error = regmap_update_bits(cpcap->regmap, CPCAP_REG_CDI,
+				   0xffff, 0xae0a);
+	if (error)
+		goto out;
+	error = regmap_update_bits(cpcap->regmap, CPCAP_REG_TXI,
+				   0xffff, 0x0cc0);
+	if (error)
+		goto out;
+	error = regmap_update_bits(cpcap->regmap, CPCAP_REG_TXMP,
+				   0xffff, 0x0610);
+	if (error)
+		goto out;
+	error = regmap_update_bits(cpcap->regmap, CPCAP_REG_RXOA,
+				   0xffff, 0x0006);
+	if (error)
+		goto out;
+	error = regmap_update_bits(cpcap->regmap, CPCAP_REG_RXVC,
+				   0xffff, 0x0b2c);
+	if (error)
+		goto out;
+	error = regmap_update_bits(cpcap->regmap, CPCAP_REG_RXCOA,
+				   0xffff, 0x0606);
+	if (error)
+		goto out;
+	error = regmap_update_bits(cpcap->regmap, CPCAP_REG_RXSDOA,
+				   0xffff, 0x0600);
+	if (error)
+		goto out;
+
+out:
+	schedule_delayed_work(&cpcap->work, msecs_to_jiffies(1000));
+}
+
 static int cpcap_soc_probe(struct snd_soc_component *component)
 {
 	struct cpcap_audio *cpcap;
@@ -1520,11 +1573,26 @@ static int cpcap_soc_probe(struct snd_soc_component *component)
 	if (err)
 		return err;
 
-	return cpcap_audio_reset(component, false);
+	err = cpcap_audio_reset(component, false);
+	if (err)
+		return err;
+
+	INIT_DELAYED_WORK(&cpcap->work, cpcap_soc_work);
+	schedule_delayed_work(&cpcap->work, msecs_to_jiffies(1000));
+
+	return 0;
+}
+
+static void cpcap_soc_remove(struct snd_soc_component *component)
+{
+	struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component);
+
+	cancel_delayed_work_sync(&cpcap->work);
 }
 
 static struct snd_soc_component_driver soc_codec_dev_cpcap = {
 	.probe			= cpcap_soc_probe,
+	.remove			= cpcap_soc_remove,
 	.controls		= cpcap_snd_controls,
 	.num_controls		= ARRAY_SIZE(cpcap_snd_controls),
 	.dapm_widgets		= cpcap_dapm_widgets,
-- 
2.16.3

  reply	other threads:[~2018-03-29  1:45 UTC|newest]

Thread overview: 111+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 20:02 [PATCHv5 0/5] Motorola Droid 4 Audio Support Sebastian Reichel
2018-02-23 20:02 ` [PATCHv5 1/5] dt-bindings: mfd: motorola-cpcap: document audio-codec Sebastian Reichel
2018-02-26 10:08   ` Mark Brown
2018-03-02 19:07   ` Rob Herring
2018-03-07 16:30   ` Lee Jones
2018-02-23 20:02 ` [PATCHv5 2/5] ASoC: codec: cpcap: new codec Sebastian Reichel
2018-02-26  1:36   ` [alsa-devel] " kbuild test robot
2018-02-27 11:03   ` Mark Brown
2018-02-28 11:06   ` Applied "ASoC: cpcap: new codec" to the asoc tree Mark Brown
2018-02-23 20:02 ` [PATCHv5 3/5] mfd: motorola-cpcap: Add audio-codec support Sebastian Reichel
2018-03-07 16:32   ` Lee Jones
2018-03-08  9:46     ` Sebastian Reichel
2018-03-08  9:53       ` Lee Jones
2018-03-08 10:27         ` Sebastian Reichel
2018-03-08 10:48           ` Lee Jones
2018-03-08 11:25             ` Mark Brown
2018-03-09  8:34               ` Lee Jones
2018-03-09 11:19                 ` Sebastian Reichel
2018-03-09 12:40                 ` Mark Brown
2018-03-09 15:11                   ` Tony Lindgren
2018-03-09 16:48                     ` Sebastian Reichel
2018-03-08 12:54             ` Sebastian Reichel
2018-03-08 17:07       ` Tony Lindgren
2018-03-09 11:29         ` Sebastian Reichel
2018-03-12  9:08           ` Lee Jones
2018-02-23 20:02 ` [PATCHv5 4/5] ARM: dts: motorola-cpcap-mapphone: add audio-codec Sebastian Reichel
2018-02-23 20:02 ` [PATCHv5 5/5] ARM: dts: omap4-droid4: add soundcard Sebastian Reichel
2018-03-22 20:48   ` [PATCHv5, " Pavel Machek
2018-03-22 23:48     ` [PATCHv5,5/5] " Sebastian Reichel
2018-03-23 10:09       ` [PATCHv5, 5/5] " Pavel Machek
2018-03-23 10:30         ` Sebastian Reichel
2018-03-23 11:06           ` Pavel Machek
2018-03-23 11:08           ` Pavel Machek
2018-03-23 14:09           ` [PATCHv5,5/5] " Pavel Machek
2018-03-23 14:11           ` [PATCHv5, 5/5] " Pavel Machek
2018-03-26 14:16           ` omap4-droid4: voice call support was Re: [PATCHv5,5/5] " Pavel Machek
2018-03-26 15:58             ` Sebastian Reichel
2018-03-26 20:31               ` Pavel Machek
2018-03-26 23:10                 ` Sebastian Reichel
2018-03-27 20:41                   ` omap4-droid4: voice call support was Re: [PATCHv5, 5/5] " Pavel Machek
2018-03-27 20:51                     ` omap4-droid4: voice call support was Re: [PATCHv5,5/5] " Tony Lindgren
2018-03-27 12:14               ` omap4-droid4: voice call support was Re: [PATCHv5, 5/5] " Mark Brown
2018-03-27 22:22                 ` Sebastian Reichel
2018-03-28  2:29                   ` Mark Brown
2018-03-28 14:02                     ` Sebastian Reichel
2018-03-29  1:45                       ` Tony Lindgren [this message]
2018-03-29 13:36                         ` omap4-droid4: voice call support was Re: [PATCHv5,5/5] " Sebastian Reichel
2018-03-29 13:59                           ` Tony Lindgren
2018-03-29 15:46                             ` Sebastian Reichel
2018-03-29 16:06                               ` Tony Lindgren
2018-03-30 10:57                                 ` omap4-droid4: voice call support was Re: [PATCHv5, 5/5] " Sebastian Reichel
2018-03-30 22:31                                 ` omap4-droid4: voice call support was Re: [PATCHv5,5/5] " Pavel Machek
2018-03-29 16:37                               ` Pavel Machek
2018-03-29 16:41                                 ` Tony Lindgren
2018-03-29 18:40                                   ` omap4-droid4: voice call support was Re: [PATCHv5, 5/5] " Pavel Machek
2018-03-29 21:56                                     ` omap4-droid4: voice call support was Re: [PATCHv5,5/5] " Tony Lindgren
2018-03-30 10:37                                       ` Pavel Machek
2018-03-30 13:07                                         ` Merlijn Wajer
2018-03-30 15:22                                           ` Tony Lindgren
2018-03-30 15:25                                             ` omap4-droid4: voice call support was Re: [PATCHv5, 5/5] " Michael Nazzareno Trimarchi
2018-03-30 15:44                                               ` Tony Lindgren
2018-03-30 17:46                                                 ` [alsa-devel] " Tony Lindgren
2018-03-30 15:34                                             ` Pavel Machek
2018-03-30 17:50                                           ` omap4-droid4: voice call support was Re: [PATCHv5,5/5] " Pavel Machek
2018-03-30 18:01                                             ` omap4-droid4: voice call support was Re: [PATCHv5, 5/5] " Pavel Machek
2018-03-30 20:46                                               ` omap4-droid4: voice call support was Re: [PATCHv5,5/5] " Pavel Machek
2018-03-29 14:09                         ` Pavel Machek
2018-03-29 14:21                           ` Tony Lindgren
2018-03-29 16:08                         ` omap4-droid4: voice call support was Re: [PATCHv5, 5/5] " Pavel Machek
2018-03-29 16:34                           ` Tony Lindgren
2018-03-29 18:05                             ` Pavel Machek
2018-03-29 21:58                               ` Tony Lindgren
2018-04-01 23:17                                 ` Tony Lindgren
2018-03-31 14:55                         ` call/normal switch was Re: omap4-droid4: voice call support was Pavel Machek
2018-03-31 18:19                           ` Tony Lindgren
2018-03-31 19:19                             ` Pavel Machek
2018-03-31 19:46                               ` Pavel Machek
2018-03-31 19:55                                 ` Pavel Machek
2018-03-31 23:43                                   ` Tony Lindgren
2018-04-01  6:48                                     ` Pavel Machek
2018-04-01 13:18                                     ` Pavel Machek
2018-04-01 15:36                                       ` Tony Lindgren
2018-04-01 17:30                                         ` Tony Lindgren
2018-04-02 15:50                                           ` Dan Williams
2018-04-02 15:57                                             ` Tony Lindgren
2018-04-03 15:04                                               ` Tony Lindgren
2018-04-03 15:50                                                 ` Pavel Machek
2018-04-03 19:44                                                   ` Tony Lindgren
2018-04-06 12:04                                                     ` Pavel Machek
2018-04-06 12:23                                                       ` Merlijn Wajer
2018-04-06 12:45                                                         ` Pavel Machek
2018-04-06 22:02                                                         ` Pavel Machek
2018-04-07  8:10                                                         ` simultaneous voice/data works (was Re: call/normal switch was Re: omap4-droid4: voice call support was) Pavel Machek
2018-04-07 12:22                                                           ` Pavel Machek
2018-04-08  2:44                                                             ` Dan Williams
2018-04-08  7:41                                                               ` Pavel Machek
2018-04-09  3:15                                                                 ` Dan Williams
2018-04-09 14:08                                                               ` Tony Lindgren
2018-04-09 15:53                                                                 ` Dan Williams
2018-04-09 20:21                                                                 ` Pavel Machek
2018-04-10 10:58                                                                 ` Pavel Machek
2018-04-10 13:50                                                                   ` Tony Lindgren
2018-04-11 11:43                                                                     ` Pavel Machek
2018-04-03 22:11                                         ` call/normal switch was Re: omap4-droid4: voice call support was Pavel Machek
2018-03-31 19:46                               ` Tony Lindgren
2018-04-02 15:06                       ` omap4-droid4: voice call support was Re: [PATCHv5, 5/5] ARM: dts: omap4-droid4: add soundcard Mark Brown
2018-03-28  9:00               ` omap4-droid4: voice call support was Re: [PATCHv5,5/5] " Pavel Machek
2018-03-28  9:36                 ` omap4-droid4: voice call support was Re: [PATCHv5, 5/5] " Pavel Machek
2018-04-03  8:52       ` [PATCHv5,5/5] " Pavel Machek
2018-02-23 22:24 ` [PATCHv5 0/5] Motorola Droid 4 Audio Support Tony Lindgren
2018-03-02 20:57   ` Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180329014507.GM5700@atomide.com \
    --to=tony@atomide.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=dcbw@redhat.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@collabora.com \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=sebastian.reichel@collabora.co.uk \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).