Re: [PATCH 1/8] ASoC: aw88399: extract shared device library
From: Mark Brown
Date: Tue Jul 21 2026 - 13:04:26 EST
On Tue, Jul 21, 2026 at 06:21:04PM +0300, Ilpo Järvinen wrote:
> On Fri, 17 Jul 2026, Marco Giunta wrote:
>
> > Extract the device-level functions from aw88399.c into a new shared
> > library module (aw88399-lib.c) with a shared header at
> > include/sound/aw88399.h, following the pattern established by CS35L41
> > (cs35l41-lib.c / include/sound/cs35l41.h) for chips that need both
> > ASoC and HDA drivers.
> >
> > The shared header at include/sound/aw88399.h contains the register
> > definitions, bit-field masks, hardware constants, device enums, the
> > struct aw88399 definition, and the library function declarations.
> > The ASoC-private header at sound/soc/codecs/aw88399.h is reduced to
> > ASoC-specific definitions (PCM formats/rates, ALSA kcontrol helpers,
> > calibration constants) and includes the shared header.
> >
> > The library contains the chip initialization, firmware loading,
> > playback start/stop sequences, and all their internal dependencies
> > (PLL checks, DSP management, volume control, calibration, CRC
> > verification, etc.). The ASoC codec driver retains the ALSA controls,
> > DAPM widgets, codec probe/remove, calibration service, and I2C bus
> > driver registration.
> >
> > A new Kconfig symbol SND_SOC_AW88399_LIB is introduced.
> > SND_SOC_AW88399 (the existing ASoC codec) selects it, ensuring no
> > change for current users. The HDA side codec driver (introduced
> > later in this series) selects the library without pulling in the
> > full ASoC codec module. This avoids a build-time dependency on the
> > full ASoC driver and follows the established pattern used by CS35L41
> > (SND_SOC_CS35L41_LIB) for chips with both ASoC and HDA drivers.
> >
> > Some library functions (DSP control, volume setting, mute,
> > calibration updates, profile management, and status helpers) are
> > used internally by the library's start/stop sequences but are also
> > called directly by the ASoC driver's remaining code.
> > These are exported from the library so the ASoC module can access them.
> >
> > This is a pure code movement with no functional changes. The moved
> > functions are identical to their originals in aw88399.c.
> >
> > Tested-by: Nadim Kobeissi <nadim@symbolic.software>
> > Tested-by: Xia Yun'an <imitoy@xxxxxxxxxx>
> > Tested-by: Munzir Taha <munzirtaha@xxxxxxxxx>
> > Signed-off-by: Marco Giunta <marco_giunta@xxxxxxxxxx>
> > ---
> > include/sound/aw88399.h | 618 ++++++++++++++
> > sound/soc/codecs/Kconfig | 5 +
> > sound/soc/codecs/Makefile | 2 +
> > sound/soc/codecs/aw88399-lib.c | 1381 ++++++++++++++++++++++++++++++++
> > sound/soc/codecs/aw88399.c | 1349 -------------------------------
> > sound/soc/codecs/aw88399.h | 582 +-------------
> > 6 files changed, 2008 insertions(+), 1929 deletions(-)
> > create mode 100644 include/sound/aw88399.h
> > create mode 100644 sound/soc/codecs/aw88399-lib.c
> >
> > diff --git a/include/sound/aw88399.h b/include/sound/aw88399.h
> > new file mode 100644
> > index 000000000000..3a2153f0ee92
> > --- /dev/null
> > +++ b/include/sound/aw88399.h
> > @@ -0,0 +1,618 @@
> > +/* SPDX-License-Identifier: GPL-2.0-only
> > + *
> > + * linux/sound/aw88399.h -- Platform data for AW88399
> > + *
> > + * Copyright (c) 2023 AWINIC Technology CO., LTD
> > + *
> > + * Author: Weidong Wang <wangweidong.a@xxxxxxxxxx>
> > + */
> > +
> > +#ifndef __SOUND_AW88399_H
> > +#define __SOUND_AW88399_H
> > +
> > +#include <linux/mutex.h>
> > +#include <linux/workqueue.h>
> > +
> > +/* registers list */
> > +#define AW88399_ID_REG (0x00)
> > +#define AW88399_SYSST_REG (0x01)
> > +#define AW88399_SYSINT_REG (0x02)
> > +#define AW88399_SYSINTM_REG (0x03)
> > +#define AW88399_SYSCTRL_REG (0x04)
> > +#define AW88399_SYSCTRL2_REG (0x05)
> > +#define AW88399_I2SCTRL1_REG (0x06)
> > +#define AW88399_I2SCTRL2_REG (0x07)
> > +#define AW88399_I2SCTRL3_REG (0x08)
> > +#define AW88399_DACCFG1_REG (0x09)
> > +#define AW88399_DACCFG2_REG (0x0A)
> > +#define AW88399_DACCFG3_REG (0x0B)
> > +#define AW88399_DACCFG4_REG (0x0C)
> > +#define AW88399_DACCFG5_REG (0x0D)
> > +#define AW88399_DACCFG6_REG (0x0E)
> > +#define AW88399_DACCFG7_REG (0x0F)
> > +#define AW88399_MPDCFG1_REG (0x10)
> > +#define AW88399_MPDCFG2_REG (0x11)
> > +#define AW88399_MPDCFG3_REG (0x12)
> > +#define AW88399_MPDCFG4_REG (0x13)
> > +#define AW88399_PWMCTRL1_REG (0x14)
> > +#define AW88399_PWMCTRL2_REG (0x15)
> > +#define AW88399_PWMCTRL3_REG (0x16)
> > +#define AW88399_I2SCFG1_REG (0x17)
> > +#define AW88399_DBGCTRL_REG (0x18)
> > +#define AW88399_HAGCST_REG (0x20)
> > +#define AW88399_VBAT_REG (0x21)
> > +#define AW88399_TEMP_REG (0x22)
> > +#define AW88399_PVDD_REG (0x23)
> > +#define AW88399_ISNDAT_REG (0x24)
> > +#define AW88399_VSNDAT_REG (0x25)
> > +#define AW88399_I2SINT_REG (0x26)
> > +#define AW88399_I2SCAPCNT_REG (0x27)
> > +#define AW88399_ANASTA1_REG (0x28)
> > +#define AW88399_ANASTA2_REG (0x29)
> > +#define AW88399_ANASTA3_REG (0x2A)
> > +#define AW88399_TESTDET_REG (0x2B)
> > +#define AW88399_DSMCFG1_REG (0x30)
> > +#define AW88399_DSMCFG2_REG (0x31)
> > +#define AW88399_DSMCFG3_REG (0x32)
> > +#define AW88399_DSMCFG4_REG (0x33)
> > +#define AW88399_DSMCFG5_REG (0x34)
> > +#define AW88399_DSMCFG6_REG (0x35)
> > +#define AW88399_DSMCFG7_REG (0x36)
> > +#define AW88399_DSMCFG8_REG (0x37)
> > +#define AW88399_TESTIN_REG (0x38)
> > +#define AW88399_TESTOUT_REG (0x39)
Please delete unneeded context from mails when replying. Doing this
makes it much easier to find your reply in the message, helping ensure
it won't be missed by people scrolling through the irrelevant quoted
material.
Attachment:
signature.asc
Description: PGP signature