All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 3/4] ASoC: amd: acp: Add machine driver that enables sound for systems with a ES8336 codec
@ 2023-03-23  1:56 ` 沈一超
  0 siblings, 0 replies; 32+ messages in thread
From: 沈一超 @ 2023-03-23  1:56 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, perex, posteuca, tiwai,
	yangxiaohua, 沈一超,
	Zhu Ning

> > Regarding playing the speaker and headphone simultaneously, is not
> > something I took into account. Is this even a valid usecase? The intel driver
> > for es8336 doesn't seem to support it.
>
> Yes, for example consider a critical notification - the system
> may wish to ensure it is audible even if the user has taken off
> their headphones for some reason.

In practice the speaker and the headphone are conflicting devices, see
https://github.com/alsa-project/alsa-ucm-conf/blob/master/ucm2/Intel/sof-essx8336/HiFi.conf

There is no such situation, and the system doesn't produce sound from speaker
when headphones are plugged in. The user may manually open speaker using
amixer sset 'Speaker' on or pavucontrol.

The GPIO thing on Huawei Intel platform is too complicated, they use two GPIOs
for headphone and speaker, and the headphone GPIO is inverted, which means low
means on and high means off. Luckily there should be only one hardware config
for the AMD acp3x platform GPIO and you may just choose the correct one.

^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [PATCH 3/4] ASoC: amd: acp: Add machine driver that enables sound for systems with a ES8336 codec
@ 2023-08-18  7:58 Zhu Ning
  0 siblings, 0 replies; 32+ messages in thread
From: Zhu Ning @ 2023-08-18  7:58 UTC (permalink / raw)
  To: posteuca
  Cc: alsa-devel, broonie, lgirdwood, linux-kernel, perex, tiwai,
	yangxiaohua, Ning Zhu, Zhu Ning

> > This is saying that the machine driver should disable jack detection
> > over suspend and restart it during resume.  The machine driver should
> > suspend before the rest of the card which should mean that the CODEC
> > gets powered off then.  The core can't tell if jack detection is
> > supposed to work over suspend, it is a standard wake event on systems
> > like phones, but it sounds like on this system the power gets removed
> > from the device so that can't work.
> >
>
> Sorry, I don't understand what you are trying to say here. My intention
> is to find a way to have sound working when suspending/resuming
> with jack inserted by not fudging the jack in the machine driver but
> fixing it in the CODEC.
>
> > I don't understand why that would be expected to help?  The main effect
> > of keeping the bias on all the time would be to consume more power.
>
> I don't fully understand the whole bias thing (I did try hard to
> understand it from the code), but in this specific instance it helps for
> suspending the CODEC. If idle_bias_on is true then idle_bias_off will be
> false, that would mean that during suspend (with jack inserted)
> in snd_soc_suspend() in switch (snd_soc_dapm_get_bias_level(dapm))
> the flow goes in case SND_SOC_BIAS_STANDBY and since dapm->idle_bias_off
> is false it doesn't break from the case but falls through to
> SND_SOC_BIAS_OFF case which in turn calls the CODEC component's suspend
> callback.
>
> The reason the sound stops working with jack inserted is that the CODEC
> suspend callback never gets called. It only gets called when the jack
> is not inserted.

Hi Postevca, I just reproduced the bug on my side. You are right that
when jack inserted,
the codec driver will never enter  SND_SOC_BIAS_OFF or suspend or resume. This
makes sense because the codec needs micbias power to detect button. Problem is
that  ALSA or dapm thought the codec power is on during suspend, but
the system power
is turned off and the registers are reset. The system power is
controlled by EC and neither
dapm or codec driver can do anything about it. The system power is
just turned off.

Disabling the jack detection before suspend is ok because the system
stops working during
suspend anyway. Maybe a detailed comment is needed to explain why?

^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [PATCH 3/4] ASoC: amd: acp: Add machine driver that enables sound for systems with a ES8336 codec
@ 2023-03-24  1:54 ` Zhu Ning
  0 siblings, 0 replies; 32+ messages in thread
From: Zhu Ning @ 2023-03-24  1:54 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, perex, posteuca, tiwai,
	yangxiaohua, Ning Zhu, Zhu Ning

> > The GPIO thing on Huawei Intel platform is too complicated, they use two GPIOs
> > for headphone and speaker, and the headphone GPIO is inverted, which means low
> > means on and high means off. Luckily there should be only one hardware config
> > for the AMD acp3x platform GPIO and you may just choose the correct one.
>
> There being two different GPIOs sounds like it just allows the headphone
> and speaker to be controlled separately - that seems more flexible, not
> a problem?

Yes it's called multi stream in Windows. However, extra GPIO causes
more confusion
in the driver.

> > There is no such situation, and the system doesn't produce sound from speaker
> > when headphones are plugged in. The user may manually open speaker using
> > amixer sset 'Speaker' on or pavucontrol.
>
> Again, you're describing a specific configuration - someone might want
> to do something different.

Hi Marian Postevca you may want to separate the GPIO control by adding Headphone
Power SND_SOC_DAPM_SUPPLY. You may also want to change the gpio
handling function
in the acp3x_es83xx_jack_events function.

static const struct snd_soc_dapm_widget acp3x_es83xx_widgets[] = {
        SND_SOC_DAPM_SPK("Speaker", NULL),
        SND_SOC_DAPM_HP("Headphone", NULL),
        SND_SOC_DAPM_MIC("Headset Mic", NULL),
        SND_SOC_DAPM_MIC("Internal Mic", NULL),

+       SND_SOC_DAPM_SUPPLY("Headphone Power", SND_SOC_NOPM, 0, 0,
+                           acp3x_es83xx_headphone_power_event,
+                           SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
        SND_SOC_DAPM_SUPPLY("Speaker Power", SND_SOC_NOPM, 0, 0,
                            acp3x_es83xx_speaker_power_event,
                            SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
};

static const struct snd_soc_dapm_route acp3x_es83xx_audio_map[] = {
        {"Headphone", NULL, "HPOL"},
        {"Headphone", NULL, "HPOR"},
+       {"Headphone", NULL, "Headphone Power"},

        {"Speaker", NULL, "HPOL"},
        {"Speaker", NULL, "HPOR"},
        {"Speaker", NULL, "Speaker Power"},
};

+static int acp3x_es83xx_headphone_power_event(struct snd_soc_dapm_widget *w,
+                                           struct snd_kcontrol
*kcontrol, int event)
+{
+       struct acp3x_es83xx_private *priv = get_mach_priv(w->dapm->card);
+
+       dev_dbg(priv->codec_dev, "speaker power event: %d\n", event);
+       if (SND_SOC_DAPM_EVENT_ON(event))
+               gpiod_set_value_cansleep(priv->gpio_headphone, true);
+       else
+               gpiod_set_value_cansleep(priv->gpio_headphone, false);
+
+       return 0;
+}
+
+static int acp3x_es83xx_speaker_power_event(struct snd_soc_dapm_widget *w,
+                                           struct snd_kcontrol
*kcontrol, int event)
+{
+       struct acp3x_es83xx_private *priv = get_mach_priv(w->dapm->card);
+
+       dev_dbg(priv->codec_dev, "speaker power event: %d\n", event);
+       if (SND_SOC_DAPM_EVENT_ON(event))
+               gpiod_set_value_cansleep(priv->gpio_speakers, true);
+       else
+               gpiod_set_value_cansleep(priv->gpio_speakers, false);
+
+       return 0;
+}

^ permalink raw reply	[flat|nested] 32+ messages in thread
* [PATCH 0/4] ASoC: amd: acp: Add sound support for a line of HUAWEI laptops
@ 2023-03-20 20:35 Marian Postevca
  2023-03-20 20:35 ` [PATCH 3/4] ASoC: amd: acp: Add machine driver that enables sound for systems with a ES8336 codec Marian Postevca
  0 siblings, 1 reply; 32+ messages in thread
From: Marian Postevca @ 2023-03-20 20:35 UTC (permalink / raw)
  To: Takashi Iwai, Mark Brown, Liam Girdwood, Jaroslav Kysela
  Cc: linux-kernel, alsa-devel, Marian Postevca

This series adds support for a line of HUAWEI laptops with
AMD CPUs that connect using the ACP3x module to a ES8336 codec.

The codec driver must be extended to support the S32 LE format
and the MCLK div by 2 option. MCLK div by 2 is needed for one specific
SKU which uses a 48Mhz MCLK which seems to be too high of a frequency
for the codec and must be divided by 2.

The acp legacy driver must also be extended by using callbacks so that
the more complicated handling for this specific codec can be moved
outside the more generic ACP code.

The last patch tries to avoid anoying pop sounds when the speaker/headphones
are enabled/disabled by delaying the handling of the GPIOs and using a mutex
to avoid race conditions between the speaker power event callback and the
trigger callback.

Marian Postevca (4):
  ASoC: es8316: Enable support for S32 LE format and MCLK div by 2
  ASoC: amd: acp: Add support for splitting the codec specific code from
    the ACP driver
  ASoC: amd: acp: Add machine driver that enables sound for systems with
    a ES8336 codec
  ASoC: amd: acp: Improve support for speaker power events

 sound/soc/amd/acp-config.c                    |  70 ++
 sound/soc/amd/acp/Makefile                    |   2 +-
 sound/soc/amd/acp/acp-legacy-mach.c           | 105 ++-
 sound/soc/amd/acp/acp-mach-common.c           |   8 +
 sound/soc/amd/acp/acp-mach.h                  |  67 ++
 sound/soc/amd/acp/acp-renoir.c                |   4 +
 sound/soc/amd/acp/acp3x-es83xx/acp3x-es83xx.c | 615 ++++++++++++++++++
 sound/soc/amd/acp/acp3x-es83xx/acp3x-es83xx.h |  12 +
 sound/soc/codecs/es8316.c                     |  21 +-
 sound/soc/codecs/es8316.h                     |   3 +
 10 files changed, 886 insertions(+), 21 deletions(-)
 create mode 100644 sound/soc/amd/acp/acp3x-es83xx/acp3x-es83xx.c
 create mode 100644 sound/soc/amd/acp/acp3x-es83xx/acp3x-es83xx.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2023-08-21 14:09 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-23  1:56 [PATCH 3/4] ASoC: amd: acp: Add machine driver that enables sound for systems with a ES8336 codec 沈一超
2023-03-23  1:56 ` 沈一超
2023-03-23 13:54 ` Mark Brown
2023-03-23 13:54   ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2023-08-18  7:58 Zhu Ning
2023-03-24  1:54 Zhu Ning
2023-03-24  1:54 ` Zhu Ning
2023-03-29 14:01 ` Mark Brown
2023-03-29 14:01   ` Mark Brown
2023-03-20 20:35 [PATCH 0/4] ASoC: amd: acp: Add sound support for a line of HUAWEI laptops Marian Postevca
2023-03-20 20:35 ` [PATCH 3/4] ASoC: amd: acp: Add machine driver that enables sound for systems with a ES8336 codec Marian Postevca
2023-03-20 20:54   ` Mark Brown
2023-03-20 20:54     ` Mark Brown
2023-03-21 22:17     ` Marian Postevca
2023-03-21 22:17       ` Marian Postevca
2023-03-22  1:58       ` Pierre-Louis Bossart
2023-03-22 13:07       ` Mark Brown
2023-03-22 13:07         ` Mark Brown
2023-03-22 20:48         ` Marian Postevca
2023-03-22 20:48           ` Marian Postevca
2023-03-22 21:27           ` Mark Brown
2023-03-22 21:27             ` Mark Brown
2023-03-27 21:20             ` Marian Postevca
2023-03-27 21:20               ` Marian Postevca
2023-03-29 13:52               ` Mark Brown
2023-03-29 13:52                 ` Mark Brown
2023-08-17 21:09                 ` Marian Postevca
2023-08-17 21:47                   ` Mark Brown
2023-08-17 22:20                     ` Marian Postevca
2023-08-18 12:52                       ` Mark Brown
2023-08-20  9:32                         ` Marian Postevca
2023-08-21 14:09                           ` Mark Brown
2023-03-21  0:54   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.