2023-06-01 15:58:17

by Richard Fitzgerald

[permalink] [raw]
Subject: [PATCH v4 00/12] ALSA: hda: Adding support for CS35L56 on HDA systems

This set of patches adds support for using the CS35L56 boosted smart
amplifier on HDA systems. In these systems the CS35L56 audio is
routed through a HDA-to-I2S bridge codec.

This doesn't include the changes to the Realtek driver to actually hook
up the CS35L56 driver, because we don't yet have the QUIRK IDs to
associate it with. But we want to publish the driver now so that it is
available for bringing up hardware with the CS35L56.

The first 9 patches are moving code out of the ASoC driver and into the
shared library so that it can be shared with the HDA driver.

Patch #10 fixes missing #includes in the HDA headers so that the CS35L56
driver doesn't have to #include headers that it doesn't use.

Finally, #11 and #12 actually add the support for CS35L56 on HDA.

CHANGES SINCE V3
Patch 01:
- Fix double-free of IRQ caused by passing wrong cookie to devm_irq_free()
Patch 12:
- Fix memory leak of struct firmware object and firmware name strings.
- Find and open firmware files before taking the irq_lock mutex and pm_runtime.
- Don't bother executing the firmware loading code if no firmware files were
found.

Richard Fitzgerald (4):
ASoC: cs35l56: Move runtime suspend/resume to shared library
ASoC: cs35l56: Move cs_dsp init into shared library
ASoC: cs35l56: Move part of cs35l56_init() to shared library
ALSA: hda: Fix missing header dependencies

Simon Trimmer (8):
ASoC: cs35l56: Move shared data into a common data structure
ASoC: cs35l56: Make cs35l56_system_reset() code more generic
ASoC: cs35l56: Convert utility functions to use common data structure
ASoC: cs35l56: Move utility functions to shared file
ASoC: cs35l56: Make common function for control port wait
ASoC: cs35l56: Make a common function to shutdown the DSP
ALSA: hda: Add mute_hook to hda_component
ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier

include/sound/cs35l56.h | 29 +-
sound/pci/hda/Kconfig | 31 +
sound/pci/hda/Makefile | 6 +
sound/pci/hda/cs35l56_hda.c | 1010 +++++++++++++++++++++++++++++
sound/pci/hda/cs35l56_hda.h | 48 ++
sound/pci/hda/cs35l56_hda_i2c.c | 69 ++
sound/pci/hda/cs35l56_hda_spi.c | 68 ++
sound/pci/hda/hda_auto_parser.h | 2 +
sound/pci/hda/hda_component.h | 1 +
sound/pci/hda/hda_generic.h | 3 +
sound/soc/codecs/cs35l56-i2c.c | 14 +-
sound/soc/codecs/cs35l56-sdw.c | 72 +-
sound/soc/codecs/cs35l56-shared.c | 459 ++++++++++++-
sound/soc/codecs/cs35l56-spi.c | 10 +-
sound/soc/codecs/cs35l56.c | 648 ++++--------------
sound/soc/codecs/cs35l56.h | 15 +-
16 files changed, 1893 insertions(+), 592 deletions(-)
create mode 100644 sound/pci/hda/cs35l56_hda.c
create mode 100644 sound/pci/hda/cs35l56_hda.h
create mode 100644 sound/pci/hda/cs35l56_hda_i2c.c
create mode 100644 sound/pci/hda/cs35l56_hda_spi.c

--
2.30.2



2023-06-01 16:00:22

by Richard Fitzgerald

[permalink] [raw]
Subject: [PATCH v4 02/12] ASoC: cs35l56: Make cs35l56_system_reset() code more generic

From: Simon Trimmer <[email protected]>

The function can be more easily reused in HDA if the tracking of whether
a soft reset is being performed and whether the device is connected to a
SoundWire bus is moved out of the function.

Signed-off-by: Simon Trimmer <[email protected]>
Signed-off-by: Richard Fitzgerald <[email protected]>
Acked-by: Mark Brown <[email protected]>
---
sound/soc/codecs/cs35l56.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c
index 7acd0492ecdd..983b0c005b37 100644
--- a/sound/soc/codecs/cs35l56.c
+++ b/sound/soc/codecs/cs35l56.c
@@ -802,10 +802,8 @@ static const struct reg_sequence cs35l56_system_reset_seq[] = {
REG_SEQ0(CS35L56_DSP_VIRTUAL1_MBOX_1, CS35L56_MBOX_CMD_SYSTEM_RESET),
};

-static void cs35l56_system_reset(struct cs35l56_private *cs35l56)
+static void cs35l56_system_reset(struct cs35l56_private *cs35l56, bool is_soundwire)
{
- cs35l56->soft_resetting = true;
-
/*
* Must enter cache-only first so there can't be any more register
* accesses other than the controlled system reset sequence below.
@@ -816,7 +814,7 @@ static void cs35l56_system_reset(struct cs35l56_private *cs35l56)
ARRAY_SIZE(cs35l56_system_reset_seq));

/* On SoundWire the registers won't be accessible until it re-enumerates. */
- if (cs35l56->sdw_peripheral)
+ if (is_soundwire)
return;

usleep_range(CS35L56_CONTROL_PORT_READY_US, CS35L56_CONTROL_PORT_READY_US + 400);
@@ -883,7 +881,8 @@ static void cs35l56_patch(struct cs35l56_private *cs35l56)

init_completion(&cs35l56->init_completion);

- cs35l56_system_reset(cs35l56);
+ cs35l56->soft_resetting = true;
+ cs35l56_system_reset(cs35l56, !!cs35l56->sdw_peripheral);

if (cs35l56->sdw_peripheral) {
/*
@@ -1547,7 +1546,8 @@ int cs35l56_init(struct cs35l56_private *cs35l56)

if (!cs35l56->base.reset_gpio) {
dev_dbg(cs35l56->base.dev, "No reset gpio: using soft reset\n");
- cs35l56_system_reset(cs35l56);
+ cs35l56->soft_resetting = true;
+ cs35l56_system_reset(cs35l56, !!cs35l56->sdw_peripheral);
if (cs35l56->sdw_peripheral) {
/* Keep alive while we wait for re-enumeration */
pm_runtime_get_noresume(cs35l56->base.dev);
--
2.30.2


2023-06-05 07:52:55

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH v4 00/12] ALSA: hda: Adding support for CS35L56 on HDA systems

On Thu, 01 Jun 2023 17:47:19 +0200,
Richard Fitzgerald wrote:
>
> This set of patches adds support for using the CS35L56 boosted smart
> amplifier on HDA systems. In these systems the CS35L56 audio is
> routed through a HDA-to-I2S bridge codec.
>
> This doesn't include the changes to the Realtek driver to actually hook
> up the CS35L56 driver, because we don't yet have the QUIRK IDs to
> associate it with. But we want to publish the driver now so that it is
> available for bringing up hardware with the CS35L56.
>
> The first 9 patches are moving code out of the ASoC driver and into the
> shared library so that it can be shared with the HDA driver.
>
> Patch #10 fixes missing #includes in the HDA headers so that the CS35L56
> driver doesn't have to #include headers that it doesn't use.
>
> Finally, #11 and #12 actually add the support for CS35L56 on HDA.
>
> CHANGES SINCE V3
> Patch 01:
> - Fix double-free of IRQ caused by passing wrong cookie to devm_irq_free()
> Patch 12:
> - Fix memory leak of struct firmware object and firmware name strings.
> - Find and open firmware files before taking the irq_lock mutex and pm_runtime.
> - Don't bother executing the firmware loading code if no firmware files were
> found.
>
> Richard Fitzgerald (4):
> ASoC: cs35l56: Move runtime suspend/resume to shared library
> ASoC: cs35l56: Move cs_dsp init into shared library
> ASoC: cs35l56: Move part of cs35l56_init() to shared library
> ALSA: hda: Fix missing header dependencies
>
> Simon Trimmer (8):
> ASoC: cs35l56: Move shared data into a common data structure
> ASoC: cs35l56: Make cs35l56_system_reset() code more generic
> ASoC: cs35l56: Convert utility functions to use common data structure
> ASoC: cs35l56: Move utility functions to shared file
> ASoC: cs35l56: Make common function for control port wait
> ASoC: cs35l56: Make a common function to shutdown the DSP
> ALSA: hda: Add mute_hook to hda_component
> ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier

It'd be likely easier to merge all those via ASoC tree, I suppose, as
some patches seem to have prerequisite in the recent ASoC changes.
So, Mark, could you take those through yours?

Feel free to put my ack:

Reviewed-by: Takashi Iwai <[email protected]>


thanks,

Takashi

2023-06-05 07:55:46

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH v4 00/12] ALSA: hda: Adding support for CS35L56 on HDA systems

On Mon, 05 Jun 2023 09:45:59 +0200,
Takashi Iwai wrote:
>
> On Thu, 01 Jun 2023 17:47:19 +0200,
> Richard Fitzgerald wrote:
> >
> > This set of patches adds support for using the CS35L56 boosted smart
> > amplifier on HDA systems. In these systems the CS35L56 audio is
> > routed through a HDA-to-I2S bridge codec.
> >
> > This doesn't include the changes to the Realtek driver to actually hook
> > up the CS35L56 driver, because we don't yet have the QUIRK IDs to
> > associate it with. But we want to publish the driver now so that it is
> > available for bringing up hardware with the CS35L56.
> >
> > The first 9 patches are moving code out of the ASoC driver and into the
> > shared library so that it can be shared with the HDA driver.
> >
> > Patch #10 fixes missing #includes in the HDA headers so that the CS35L56
> > driver doesn't have to #include headers that it doesn't use.
> >
> > Finally, #11 and #12 actually add the support for CS35L56 on HDA.
> >
> > CHANGES SINCE V3
> > Patch 01:
> > - Fix double-free of IRQ caused by passing wrong cookie to devm_irq_free()
> > Patch 12:
> > - Fix memory leak of struct firmware object and firmware name strings.
> > - Find and open firmware files before taking the irq_lock mutex and pm_runtime.
> > - Don't bother executing the firmware loading code if no firmware files were
> > found.
> >
> > Richard Fitzgerald (4):
> > ASoC: cs35l56: Move runtime suspend/resume to shared library
> > ASoC: cs35l56: Move cs_dsp init into shared library
> > ASoC: cs35l56: Move part of cs35l56_init() to shared library
> > ALSA: hda: Fix missing header dependencies
> >
> > Simon Trimmer (8):
> > ASoC: cs35l56: Move shared data into a common data structure
> > ASoC: cs35l56: Make cs35l56_system_reset() code more generic
> > ASoC: cs35l56: Convert utility functions to use common data structure
> > ASoC: cs35l56: Move utility functions to shared file
> > ASoC: cs35l56: Make common function for control port wait
> > ASoC: cs35l56: Make a common function to shutdown the DSP
> > ALSA: hda: Add mute_hook to hda_component
> > ALSA: hda/cs35l56: Add driver for Cirrus Logic CS35L56 amplifier
>
> It'd be likely easier to merge all those via ASoC tree, I suppose, as
> some patches seem to have prerequisite in the recent ASoC changes.
> So, Mark, could you take those through yours?
>
> Feel free to put my ack:
>
> Reviewed-by: Takashi Iwai <[email protected]>

Oh, and after you merge them, please send a PR to sound.git tree,
too. This will make our lives easier, as there will be other
conflicting changes for HD-audio component for TAS codecs, too.


thanks,

Takashi