2023-09-28 11:08:45

by wangweidong.a

[permalink] [raw]
Subject: [PATCH V6 00/10] ASoC: codecs: Add aw87390 amplifier driver

From: Weidong Wang <[email protected]>

The awinic aw87390 is a new high efficiency, low noise,
constant large volume, 6th Smart K audio amplifier.

Add a DT schema for describing awinic aw87390 audio amplifiers.
They are controlled using I2C.

Modify some code for aw88261 and aw88395

v5 -> v6: Adjust the order and context of the patch
Use "len-1" as a loop judgment modifier
Use return 0 instead of return ret at the end of a function
Use dev_dbg instead of dev_info
Use struct_size to calculate the structure size
Remove the space before the exclamation mark

Weidong Wang (10):
ASoC: dt-bindings: awinic,aw88395: Add properties for multiple PA
support
ASoC: dt-bindings: Add schema for "awinic,aw87390"
ASoC: codecs: Remove the "fade-enable property"
ASoC: codecs: Rename "sound-channel" to "awinic,audio-channel"
ASoC: codecs: Modify the transmission method of parameters
ASoC: codecs: Modify i2c driver name
ASoC: codecs: Add code for bin parsing compatible with aw87390
ASoC: codecs: Rename "sync-flag" to "awinic,sync-flag"
ASoC: codecs: Modify the transmission mode of function parameters
ASoC: codecs: Add aw87390 amplifier driver

.../bindings/sound/awinic,aw87390.yaml | 58 +++
.../bindings/sound/awinic,aw88395.yaml | 16 +
sound/soc/codecs/Kconfig | 15 +-
sound/soc/codecs/Makefile | 2 +
sound/soc/codecs/aw87390.c | 463 ++++++++++++++++++
sound/soc/codecs/aw87390.h | 85 ++++
sound/soc/codecs/aw88261.c | 27 +-
sound/soc/codecs/aw88261.h | 4 +-
sound/soc/codecs/aw88395/aw88395.c | 9 +-
sound/soc/codecs/aw88395/aw88395.h | 2 +-
sound/soc/codecs/aw88395/aw88395_device.c | 47 +-
sound/soc/codecs/aw88395/aw88395_device.h | 6 +-
sound/soc/codecs/aw88395/aw88395_lib.c | 25 +-
sound/soc/codecs/aw88395/aw88395_reg.h | 1 +
14 files changed, 686 insertions(+), 74 deletions(-)
create mode 100644 Documentation/devicetree/bindings/sound/awinic,aw87390.yaml
create mode 100644 sound/soc/codecs/aw87390.c
create mode 100644 sound/soc/codecs/aw87390.h


base-commit: 633b47cb009d09dc8f4ba9cdb3a0ca138809c7c7
--
2.41.0


2023-09-28 11:27:59

by wangweidong.a

[permalink] [raw]
Subject: [PATCH V6 07/10] ASoC: codecs: Add code for bin parsing compatible with aw87390

From: Weidong Wang <[email protected]>

Add aw87390 compatible code to the aw88395_lib.c file
so that it can parse aw87390's bin file

Signed-off-by: Weidong Wang <[email protected]>
---
sound/soc/codecs/aw88395/aw88395_lib.c | 25 +++++++++++++++----------
sound/soc/codecs/aw88395/aw88395_reg.h | 1 +
2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/aw88395/aw88395_lib.c b/sound/soc/codecs/aw88395/aw88395_lib.c
index 87dd0ccade4c..a0a429ca9768 100644
--- a/sound/soc/codecs/aw88395/aw88395_lib.c
+++ b/sound/soc/codecs/aw88395/aw88395_lib.c
@@ -456,10 +456,12 @@ static int aw_dev_parse_reg_bin_with_hdr(struct aw_device *aw_dev,
goto parse_bin_failed;
}

- if (aw_bin->header_info[0].valid_data_len % 4) {
- dev_err(aw_dev->dev, "bin data len get error!");
- ret = -EINVAL;
- goto parse_bin_failed;
+ if (aw_dev->chip_id == AW88261_CHIP_ID) {
+ if (aw_bin->header_info[0].valid_data_len % 4) {
+ dev_err(aw_dev->dev, "bin data len get error!");
+ ret = -EINVAL;
+ goto parse_bin_failed;
+ }
}

prof_desc->sec_desc[AW88395_DATA_TYPE_REG].data =
@@ -581,9 +583,9 @@ static int aw_dev_parse_dev_default_type(struct aw_device *aw_dev,
}

static int aw88261_dev_cfg_get_valid_prof(struct aw_device *aw_dev,
- struct aw_all_prof_info all_prof_info)
+ struct aw_all_prof_info *all_prof_info)
{
- struct aw_prof_desc *prof_desc = all_prof_info.prof_desc;
+ struct aw_prof_desc *prof_desc = all_prof_info->prof_desc;
struct aw_prof_info *prof_info = &aw_dev->prof_info;
int num = 0;
int i;
@@ -623,9 +625,9 @@ static int aw88261_dev_cfg_get_valid_prof(struct aw_device *aw_dev,
}

static int aw88395_dev_cfg_get_valid_prof(struct aw_device *aw_dev,
- struct aw_all_prof_info all_prof_info)
+ struct aw_all_prof_info *all_prof_info)
{
- struct aw_prof_desc *prof_desc = all_prof_info.prof_desc;
+ struct aw_prof_desc *prof_desc = all_prof_info->prof_desc;
struct aw_prof_info *prof_info = &aw_dev->prof_info;
struct aw_sec_data_desc *sec_desc;
int num = 0;
@@ -703,12 +705,13 @@ static int aw_dev_load_cfg_by_hdr(struct aw_device *aw_dev,

switch (aw_dev->chip_id) {
case AW88395_CHIP_ID:
- ret = aw88395_dev_cfg_get_valid_prof(aw_dev, *all_prof_info);
+ ret = aw88395_dev_cfg_get_valid_prof(aw_dev, all_prof_info);
if (ret < 0)
goto exit;
break;
case AW88261_CHIP_ID:
- ret = aw88261_dev_cfg_get_valid_prof(aw_dev, *all_prof_info);
+ case AW87390_CHIP_ID:
+ ret = aw88261_dev_cfg_get_valid_prof(aw_dev, all_prof_info);
if (ret < 0)
goto exit;
break;
@@ -801,6 +804,7 @@ static int aw_get_dev_scene_count_v1(struct aw_device *aw_dev, struct aw_contain
ret = 0;
break;
case AW88261_CHIP_ID:
+ case AW87390_CHIP_ID:
for (i = 0; i < cfg_hdr->ddt_num; ++i) {
if (((cfg_dde[i].data_type == ACF_SEC_TYPE_REG) ||
(cfg_dde[i].data_type == ACF_SEC_TYPE_HDR_REG)) &&
@@ -841,6 +845,7 @@ static int aw_get_default_scene_count_v1(struct aw_device *aw_dev,
ret = 0;
break;
case AW88261_CHIP_ID:
+ case AW87390_CHIP_ID:
for (i = 0; i < cfg_hdr->ddt_num; ++i) {
if (((cfg_dde[i].data_type == ACF_SEC_TYPE_REG) ||
(cfg_dde[i].data_type == ACF_SEC_TYPE_HDR_REG)) &&
diff --git a/sound/soc/codecs/aw88395/aw88395_reg.h b/sound/soc/codecs/aw88395/aw88395_reg.h
index e7a7c02efaf3..d0a273387313 100644
--- a/sound/soc/codecs/aw88395/aw88395_reg.h
+++ b/sound/soc/codecs/aw88395/aw88395_reg.h
@@ -97,6 +97,7 @@
enum aw88395_id {
AW88395_CHIP_ID = 0x2049,
AW88261_CHIP_ID = 0x2113,
+ AW87390_CHIP_ID = 0x76,
};

#define AW88395_REG_MAX (0x7D)
--
2.41.0

2023-09-28 11:28:06

by wangweidong.a

[permalink] [raw]
Subject: [PATCH V6 08/10] ASoC: codecs: Rename "sync-flag" to "awinic,sync-flag"

From: Weidong Wang <[email protected]>

Rename "sync-flag" to "awinic,sync-flag", this is to be
consistent with the "awinic,aw88395.yaml" file

Signed-off-by: Weidong Wang <[email protected]>
---
sound/soc/codecs/aw88261.c | 4 +---
sound/soc/codecs/aw88261.h | 2 +-
2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/aw88261.c b/sound/soc/codecs/aw88261.c
index 7df641592330..61179e235fbf 100644
--- a/sound/soc/codecs/aw88261.c
+++ b/sound/soc/codecs/aw88261.c
@@ -1187,13 +1187,11 @@ static void aw88261_parse_channel_dt(struct aw88261 *aw88261)
struct aw_device *aw_dev = aw88261->aw_pa;
struct device_node *np = aw_dev->dev->of_node;
u32 channel_value = AW88261_DEV_DEFAULT_CH;
- u32 sync_enable = false;

of_property_read_u32(np, "awinic,audio-channel", &channel_value);
- of_property_read_u32(np, "sync-flag", &sync_enable);
+ aw88261->phase_sync = of_property_read_bool(np, "awinic,sync-flag");

aw_dev->channel = channel_value;
- aw88261->phase_sync = sync_enable;
}

static int aw88261_init(struct aw88261 **aw88261, struct i2c_client *i2c, struct regmap *regmap)
diff --git a/sound/soc/codecs/aw88261.h b/sound/soc/codecs/aw88261.h
index bd0841fa9b77..734d0f93ced9 100644
--- a/sound/soc/codecs/aw88261.h
+++ b/sound/soc/codecs/aw88261.h
@@ -453,7 +453,7 @@ struct aw88261 {
unsigned int mute_st;
unsigned int amppd_st;

- unsigned char phase_sync;
+ bool phase_sync;
};

#endif
--
2.41.0

2023-09-28 11:55:22

by wangweidong.a

[permalink] [raw]
Subject: [PATCH V6 04/10] ASoC: codecs: Rename "sound-channel" to "awinic,audio-channel"

From: Weidong Wang <[email protected]>

Rename "sound-channel" to "awinic,audio-channel",
this is to be consistent with the "awinic,aw88395.yaml" file

Signed-off-by: Weidong Wang <[email protected]>
---
sound/soc/codecs/aw88261.c | 2 +-
sound/soc/codecs/aw88395/aw88395_device.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/aw88261.c b/sound/soc/codecs/aw88261.c
index a697b5006b45..7df641592330 100644
--- a/sound/soc/codecs/aw88261.c
+++ b/sound/soc/codecs/aw88261.c
@@ -1189,7 +1189,7 @@ static void aw88261_parse_channel_dt(struct aw88261 *aw88261)
u32 channel_value = AW88261_DEV_DEFAULT_CH;
u32 sync_enable = false;

- of_property_read_u32(np, "sound-channel", &channel_value);
+ of_property_read_u32(np, "awinic,audio-channel", &channel_value);
of_property_read_u32(np, "sync-flag", &sync_enable);

aw_dev->channel = channel_value;
diff --git a/sound/soc/codecs/aw88395/aw88395_device.c b/sound/soc/codecs/aw88395/aw88395_device.c
index 25b32cdceeec..5ca4172cb788 100644
--- a/sound/soc/codecs/aw88395/aw88395_device.c
+++ b/sound/soc/codecs/aw88395/aw88395_device.c
@@ -1584,15 +1584,15 @@ static void aw88395_parse_channel_dt(struct aw_device *aw_dev)
u32 channel_value;
int ret;

- ret = of_property_read_u32(np, "sound-channel", &channel_value);
+ ret = of_property_read_u32(np, "awinic,audio-channel", &channel_value);
if (ret) {
dev_dbg(aw_dev->dev,
- "read sound-channel failed,use default 0");
+ "read audio-channel failed,use default 0");
aw_dev->channel = AW88395_DEV_DEFAULT_CH;
return;
}

- dev_dbg(aw_dev->dev, "read sound-channel value is: %d",
+ dev_dbg(aw_dev->dev, "read audio-channel value is: %d",
channel_value);
aw_dev->channel = channel_value;
}
--
2.41.0

2023-09-28 11:56:03

by wangweidong.a

[permalink] [raw]
Subject: [PATCH V6 09/10] ASoC: codecs: Modify the transmission mode of function parameters

From: Weidong Wang <[email protected]>

Change the transmission mode of the "aw88261_dev_get_prof_name"
function parameter

Signed-off-by: Weidong Wang <[email protected]>
---
sound/soc/codecs/aw88261.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/aw88261.c b/sound/soc/codecs/aw88261.c
index 61179e235fbf..45eaf931a69c 100644
--- a/sound/soc/codecs/aw88261.c
+++ b/sound/soc/codecs/aw88261.c
@@ -477,7 +477,7 @@ static int aw88261_dev_reg_update(struct aw88261 *aw88261,
return ret;
}

-static char *aw88261_dev_get_prof_name(struct aw_device *aw_dev, int index)
+static int aw88261_dev_get_prof_name(struct aw_device *aw_dev, int index, char **prof_name)
{
struct aw_prof_info *prof_info = &aw_dev->prof_info;
struct aw_prof_desc *prof_desc;
@@ -485,12 +485,14 @@ static char *aw88261_dev_get_prof_name(struct aw_device *aw_dev, int index)
if ((index >= aw_dev->prof_info.count) || (index < 0)) {
dev_err(aw_dev->dev, "index[%d] overflow count[%d]",
index, aw_dev->prof_info.count);
- return NULL;
+ return -EINVAL;
}

prof_desc = &aw_dev->prof_info.prof_desc[index];

- return prof_info->prof_name_list[prof_desc->id];
+ *prof_name = prof_info->prof_name_list[prof_desc->id];
+
+ return 0;
}

static int aw88261_dev_get_prof_data(struct aw_device *aw_dev, int index,
@@ -515,8 +517,8 @@ static int aw88261_dev_fw_update(struct aw88261 *aw88261)
char *prof_name;
int ret;

- prof_name = aw88261_dev_get_prof_name(aw_dev, aw_dev->prof_index);
- if (!prof_name) {
+ ret = aw88261_dev_get_prof_name(aw_dev, aw_dev->prof_index, &prof_name);
+ if (ret) {
dev_err(aw_dev->dev, "get prof name failed");
return -EINVAL;
}
@@ -818,9 +820,8 @@ static int aw88261_profile_info(struct snd_kcontrol *kcontrol,
{
struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
struct aw88261 *aw88261 = snd_soc_component_get_drvdata(codec);
- const char *prof_name;
- char *name;
- int count;
+ char *prof_name, *name;
+ int count, ret;

uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
@@ -839,8 +840,8 @@ static int aw88261_profile_info(struct snd_kcontrol *kcontrol,
name = uinfo->value.enumerated.name;
count = uinfo->value.enumerated.item;

- prof_name = aw88261_dev_get_prof_name(aw88261->aw_pa, count);
- if (!prof_name) {
+ ret = aw88261_dev_get_prof_name(aw88261->aw_pa, count, &prof_name);
+ if (ret) {
strscpy(uinfo->value.enumerated.name, "null",
strlen("null") + 1);
return 0;
--
2.41.0

2023-09-28 15:26:56

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH V6 00/10] ASoC: codecs: Add aw87390 amplifier driver

On Thu, 28 Sep 2023 18:57:17 +0800, [email protected] wrote:
> The awinic aw87390 is a new high efficiency, low noise,
> constant large volume, 6th Smart K audio amplifier.
>
> Add a DT schema for describing awinic aw87390 audio amplifiers.
> They are controlled using I2C.
>
> Modify some code for aw88261 and aw88395
>
> [...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[01/10] ASoC: dt-bindings: awinic,aw88395: Add properties for multiple PA support
commit: b99d8d8adfda1f9220dd2ee9bdb96ba02dc62bd7
[02/10] ASoC: dt-bindings: Add schema for "awinic,aw87390"
commit: 457b6587c112e162d3bec871c7b93359168d5c0a
[03/10] ASoC: codecs: Remove the "fade-enable property"
commit: 085370aa8c880da7014d0d8f93343fc1d21104b8
[04/10] ASoC: codecs: Rename "sound-channel" to "awinic,audio-channel"
commit: 74ff4f22d81e97b5c2505cee2ff743fc9249d9e2
[05/10] ASoC: codecs: Modify the transmission method of parameters
commit: e83219c94abb4ad977f6b2b8be7d466ef0c2248f
[06/10] ASoC: codecs: Modify i2c driver name
commit: 6a4c3ce3f06cee1c25420cae8634269021ef8504
[07/10] ASoC: codecs: Add code for bin parsing compatible with aw87390
commit: b116c832c9e84843c64eed087271e29b3bc6c1b8
[08/10] ASoC: codecs: Rename "sync-flag" to "awinic,sync-flag"
commit: c786770ed8a53836490f6157f40ef83c7149ee75
[09/10] ASoC: codecs: Modify the transmission mode of function parameters
commit: f83287a72551833a6fe2fc96f334b26e6eba77e8
[10/10] ASoC: codecs: Add aw87390 amplifier driver
commit: 37b4346ed8681660ae60de4facc3d499d8e5cf2a

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark