linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Tony Lindgren <tony@atomide.com>
Cc: Sebastian Reichel <sebastian.reichel@collabora.co.uk>,
	Mark Brown <broonie@kernel.org>,
	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: call/normal switch was Re: omap4-droid4: voice call support was
Date: Sat, 31 Mar 2018 16:55:32 +0200	[thread overview]
Message-ID: <20180331145531.GA10404@amd> (raw)
In-Reply-To: <20180329014507.GM5700@atomide.com>

[-- Attachment #1: Type: text/plain, Size: 6289 bytes --]

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.
> 
> 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 {
 };
 
 static const struct cpcap_reg_info cpcap_default_regs[] = {
-	{ 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[] = {
 	"Off", "Mic 2", "Ext Left"
 };
 
+static const char * const cpcap_mode_texts[] = {
+	"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_texts);
 static SOC_ENUM_SINGLE_DECL(cpcap_emu_r_mux_enum, 0, 8, cpcap_out_mux_texts);
 
+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_kcontrol *kcontrol,
 	return 0;
 }
 
+static int mode;
+
+static int cpcap_mode_get_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 soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+	int err;
+
+	ucontrol->value.enumerated.item[0] = mode;
+
+	return 0;
+}
+
+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:
+
+		err = regmap_update_bits(cpcap->regmap, CPCAP_REG_VAUDIOC,
+					 0xffff, 0x0025);	// OK
+		if (err)
+			goto out;
+		err = regmap_update_bits(cpcap->regmap, CPCAP_REG_CC,
+					 0xffff, 0x60cf);	// OK
+		if (err)
+			goto out;
+		err = regmap_update_bits(cpcap->regmap, CPCAP_REG_CDI,
+					 0xffff, 0xae0a);	// OK
+		if (err)
+			goto out;
+		err = regmap_update_bits(cpcap->regmap, CPCAP_REG_TXI,
+					 0xffff, 0x0cc0);
+		if (err)
+			goto out;
+		
+		mask = 1 << CPCAP_BIT_PGA_CDC_EN | 0x200;
+		err = regmap_update_bits(cpcap->regmap, CPCAP_REG_RXCOA,
+				   mask, mask);
+		if (err)
+			printk("error #3\n");
+
+		mask = 1 << CPCAP_BIT_A2_LDSP_L_EN | 1 << CPCAP_BIT_A2_LDSP_R_EN;
+		err = regmap_update_bits(cpcap->regmap, CPCAP_REG_RXOA,
+				   mask, mask);
+		if (err)
+			printk("error #2\n");
+		
+		err = regmap_update_bits(cpcap->regmap, 0x814,
+				   0x0400, 0x0400);
+		if (err)
+			printk("error #1\n");
+		
+	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_mux =
 	SOC_DAPM_ENUM_EXT("Earpiece", cpcap_earpiece_mux_enum,
 			  cpcap_output_mux_get_enum, cpcap_output_mux_put_enum);
 
+static const struct snd_kcontrol_new cpcap_mode =
+	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[] = {
 	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_widgets[] = {
 	SND_SOC_DAPM_MUX("EMU Left Playback Route", SND_SOC_NOPM, 0, 0,
 		&cpcap_emu_left_mux),
 
+
+	SND_SOC_DAPM_MUX("Mode", SND_SOC_NOPM, 0, 0,
+		&cpcap_mode),
+	
 	/* 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[] = {
 	{"Microphone 1 PGA", NULL, "VAUDIO"},
 	{"Microphone 2 PGA", NULL, "VAUDIO"},
 
+	/* FIXME */
+	{"Mode", NULL, "Voice TX"},
+
 	/* Stream -> AIF */
 	{"HiFi RX", NULL, "HiFi Playback"},
 	{"Voice RX", NULL, "Voice Playback"},



-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  parent reply	other threads:[~2018-03-31 14:55 UTC|newest]

Thread overview: 110+ 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,5/5] " Pavel Machek
2018-03-22 23:48     ` Sebastian Reichel
2018-03-23 10:09       ` 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           ` Pavel Machek
2018-03-23 14:11           ` Pavel Machek
2018-03-26 14:16           ` omap4-droid4: voice call support was " 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                   ` Pavel Machek
2018-03-27 20:51                     ` Tony Lindgren
2018-03-27 12:14               ` 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
2018-03-29 13:36                         ` 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                                 ` Sebastian Reichel
2018-03-30 22:31                                 ` Pavel Machek
2018-03-29 16:37                               ` Pavel Machek
2018-03-29 16:41                                 ` Tony Lindgren
2018-03-29 18:40                                   ` Pavel Machek
2018-03-29 21:56                                     ` 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:34                                             ` Pavel Machek
     [not found]                                             ` <CAOf5uwnF8qTqX9O6s226=Nd4FbGjGev4LDonovgoXtoEH9QdVA@mail.gmail.com>
2018-03-30 15:44                                               ` [alsa-devel] omap4-droid4: voice call support was Re: [PATCHv5, 5/5] " Tony Lindgren
2018-03-30 17:46                                                 ` Tony Lindgren
2018-03-30 17:50                                           ` omap4-droid4: voice call support was Re: [PATCHv5,5/5] " Pavel Machek
2018-03-30 18:01                                             ` Pavel Machek
2018-03-30 20:46                                               ` Pavel Machek
2018-03-29 14:09                         ` Pavel Machek
2018-03-29 14:21                           ` Tony Lindgren
2018-03-29 16:08                         ` 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                         ` Pavel Machek [this message]
2018-03-31 18:19                           ` call/normal switch was Re: omap4-droid4: voice call support was 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               ` Pavel Machek
2018-03-28  9:36                 ` Pavel Machek
2018-04-03  8:52       ` 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=20180331145531.GA10404@amd \
    --to=pavel@ucw.cz \
    --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=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=sebastian.reichel@collabora.co.uk \
    --cc=tiwai@suse.com \
    --cc=tony@atomide.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).