From nobody Wed Oct 1 23:35:33 2025 Received: from out198-15.us.a.mail.aliyun.com (out198-15.us.a.mail.aliyun.com [47.90.198.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59F2038DEC; Fri, 26 Sep 2025 10:21:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.90.198.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758882065; cv=none; b=NjkEfGbAPVYI9UV5m5YWvBK4cb9d9aNXD0H3sW2W8bAzPT4B8B/Spp9ScGyeEDpdz6Ht0EIePcw/zCYN7Y3ThWR3/3kMOUNAfbGG8goLXCQ8D6Po0eLLI5oD+9SsGxowz7n3myYW/MRKy2WRsysC5Wwnj6oQsidlRBRyNgfIJ+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758882065; c=relaxed/simple; bh=ycdqKx049ec96ztt5legE1xGnQlokmuCPb4oXnPK5kc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cKSs3GPbw7dcB1C/W21F91MDPjiLrFWa3yAoaQzP/YmMjCG/Jwy+nCeGWvX4yNmHH50bTA1Yh5BmKOZQdqkUJXBP9vepSPNdajssa6+xk5Z8z/QyyyLlEJhZ9OFP4kTHUlXYAKGXzvoafTHfqZP7KT5qK7hdJTlD8OHGG7Ry+EQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=awinic.com; spf=pass smtp.mailfrom=awinic.com; dkim=pass (2048-bit key) header.d=awinic.com header.i=@awinic.com header.b=DBzefck1; arc=none smtp.client-ip=47.90.198.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=awinic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=awinic.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=awinic.com header.i=@awinic.com header.b="DBzefck1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=awinic.com; s=default; t=1758882049; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=N3NMHu79bWTQmAi1Ox9IMsWEADEFAdTNFM0K+1AfHXg=; b=DBzefck14B0vxV0FiCBMC6jm5lDgoVD9JXe+eg7wyYNH+FTc8IvqbewdJhyyBPLQfQPz3VYn8xlpSlv1mghw5G48/ffq3UPkbeZx2hJQcsKn0KG6SabSqXockdvAfQ3TVOYfSTBXonLzoUWpDNHu5s8M+CXyhV1ZU5Z9/hoPrkpoGx6O0+eOi5y/iP/rddjpWOn4bT439ekabBrVh5Kt472+hQEWcNGimSirDytmarzPHOyyI7qdd4hn/OP+uf7dQUOjmzAY5m35q4dx1pwXWEoqMkHo0WdIcIWxQ5JnZMnFn9pO1bkog0e1qQUXYG301hmmvCItIzrvu2EdS0DXNw== Received: from ubuntu-VirtualBox..(mailfrom:wangweidong.a@awinic.com fp:SMTPD_---.ensjOzf_1758882046 cluster:ay29) by smtp.aliyun-inc.com; Fri, 26 Sep 2025 18:20:47 +0800 From: wangweidong.a@awinic.com To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, wangweidong.a@awinic.com, cy_huang@richtek.com, ivprusov@salutedevices.com, zhoubinbin@loongson.cn, zhangyi@everest-semi.com, jack.yu@realtek.com, shenghao-ding@ti.com, rf@opensource.cirrus.com, git@apitzsch.eu, nuno.sa@analog.com, colin.i.king@gmail.com, thorsten.blum@linux.dev, yesanishhere@gmail.com, ebiggers@google.com, ardb@kernel.org, zhujun2@cmss.chinamobile.com, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org Subject: [PATCH V1 3/7] ASoC: codecs: Rework the aw87390 driver Date: Fri, 26 Sep 2025 18:20:33 +0800 Message-ID: <20250926102037.27697-4-wangweidong.a@awinic.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250926102037.27697-1-wangweidong.a@awinic.com> References: <20250926102037.27697-1-wangweidong.a@awinic.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Weidong Wang Modify the interface for calling the aw87380 driver to adapt it for aw-common-device.c and aw-common-firmware.c Signed-off-by: Weidong Wang --- sound/soc/codecs/aw87390.c | 118 ++++++------------------------------- sound/soc/codecs/aw87390.h | 16 ----- 2 files changed, 18 insertions(+), 116 deletions(-) diff --git a/sound/soc/codecs/aw87390.c b/sound/soc/codecs/aw87390.c index ef6f64856988..4ed7045a3844 100644 --- a/sound/soc/codecs/aw87390.c +++ b/sound/soc/codecs/aw87390.c @@ -12,8 +12,14 @@ #include #include #include "aw87390.h" -#include "aw88395/aw88395_data_type.h" -#include "aw88395/aw88395_device.h" +#include "aw-common-device.h" +#include "aw-common-firmware.h" + +struct aw87390 { + struct aw_device *aw_pa; + struct mutex lock; + struct regmap *regmap; +}; =20 static const struct regmap_config aw87390_remap_config =3D { .val_bits =3D 8, @@ -47,38 +53,6 @@ static int aw87390_dev_reg_update(struct aw_device *aw_d= ev, return 0; } =20 -static int aw87390_dev_get_prof_name(struct aw_device *aw_dev, int index, = char **prof_name) -{ - struct aw_prof_info *prof_info =3D &aw_dev->prof_info; - struct aw_prof_desc *prof_desc; - - if ((index >=3D aw_dev->prof_info.count) || (index < 0)) { - dev_err(aw_dev->dev, "index[%d] overflow count[%d]\n", - index, aw_dev->prof_info.count); - return -EINVAL; - } - - prof_desc =3D &aw_dev->prof_info.prof_desc[index]; - - *prof_name =3D prof_info->prof_name_list[prof_desc->id]; - - return 0; -} - -static int aw87390_dev_get_prof_data(struct aw_device *aw_dev, int index, - struct aw_prof_desc **prof_desc) -{ - if ((index >=3D aw_dev->prof_info.count) || (index < 0)) { - dev_err(aw_dev->dev, "%s: index[%d] overflow count[%d]\n", - __func__, index, aw_dev->prof_info.count); - return -EINVAL; - } - - *prof_desc =3D &aw_dev->prof_info.prof_desc[index]; - - return 0; -} - static int aw87390_dev_fw_update(struct aw_device *aw_dev) { struct aw_prof_desc *prof_index_desc; @@ -86,7 +60,7 @@ static int aw87390_dev_fw_update(struct aw_device *aw_dev) char *prof_name; int ret; =20 - ret =3D aw87390_dev_get_prof_name(aw_dev, aw_dev->prof_index, &prof_name); + ret =3D aw_dev_get_prof_name(aw_dev, aw_dev->prof_index, &prof_name); if (ret) { dev_err(aw_dev->dev, "get prof name failed\n"); return -EINVAL; @@ -94,7 +68,7 @@ static int aw87390_dev_fw_update(struct aw_device *aw_dev) =20 dev_dbg(aw_dev->dev, "start update %s", prof_name); =20 - ret =3D aw87390_dev_get_prof_data(aw_dev, aw_dev->prof_index, &prof_index= _desc); + ret =3D aw_dev_get_prof_data(aw_dev, aw_dev->prof_index, &prof_index_desc= ); if (ret) { dev_err(aw_dev->dev, "aw87390_dev_get_prof_data failed\n"); return ret; @@ -102,8 +76,8 @@ static int aw87390_dev_fw_update(struct aw_device *aw_de= v) =20 /* update reg */ sec_desc =3D prof_index_desc->sec_desc; - ret =3D aw87390_dev_reg_update(aw_dev, sec_desc[AW88395_DATA_TYPE_REG].da= ta, - sec_desc[AW88395_DATA_TYPE_REG].len); + ret =3D aw87390_dev_reg_update(aw_dev, sec_desc[AW_DATA_TYPE_REG].data, + sec_desc[AW_DATA_TYPE_REG].len); if (ret) { dev_err(aw_dev->dev, "update reg failed\n"); return ret; @@ -159,19 +133,6 @@ static int aw87390_power_on(struct aw_device *aw_dev) return 0; } =20 -static int aw87390_dev_set_profile_index(struct aw_device *aw_dev, int ind= ex) -{ - if ((index >=3D aw_dev->prof_info.count) || (index < 0)) - return -EINVAL; - - if (aw_dev->prof_index =3D=3D index) - return -EPERM; - - aw_dev->prof_index =3D index; - - return 0; -} - static int aw87390_profile_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { @@ -196,7 +157,7 @@ static int aw87390_profile_info(struct snd_kcontrol *kc= ontrol, =20 count =3D uinfo->value.enumerated.item; =20 - ret =3D aw87390_dev_get_prof_name(aw87390->aw_pa, count, &prof_name); + ret =3D aw_dev_get_prof_name(aw87390->aw_pa, count, &prof_name); if (ret) { strscpy(uinfo->value.enumerated.name, "null"); return 0; @@ -226,7 +187,7 @@ static int aw87390_profile_set(struct snd_kcontrol *kco= ntrol, int ret; =20 mutex_lock(&aw87390->lock); - ret =3D aw87390_dev_set_profile_index(aw87390->aw_pa, ucontrol->value.int= eger.value[0]); + ret =3D aw_dev_set_profile_index(aw87390->aw_pa, ucontrol->value.integer.= value[0]); if (ret) { dev_dbg(codec->dev, "profile index does not change\n"); mutex_unlock(&aw87390->lock); @@ -244,53 +205,10 @@ static int aw87390_profile_set(struct snd_kcontrol *k= control, } =20 static const struct snd_kcontrol_new aw87390_controls[] =3D { - AW87390_PROFILE_EXT("AW87390 Profile Set", aw87390_profile_info, + AW_PROFILE_EXT("AW87390 Profile Set", aw87390_profile_info, aw87390_profile_get, aw87390_profile_set), }; =20 -static int aw87390_request_firmware_file(struct aw87390 *aw87390) -{ - const struct firmware *cont =3D NULL; - int ret; - - aw87390->aw_pa->fw_status =3D AW87390_DEV_FW_FAILED; - - ret =3D request_firmware(&cont, AW87390_ACF_FILE, aw87390->aw_pa->dev); - if (ret) - return dev_err_probe(aw87390->aw_pa->dev, ret, - "load [%s] failed!\n", AW87390_ACF_FILE); - - dev_dbg(aw87390->aw_pa->dev, "loaded %s - size: %zu\n", - AW87390_ACF_FILE, cont ? cont->size : 0); - - aw87390->aw_cfg =3D devm_kzalloc(aw87390->aw_pa->dev, - struct_size(aw87390->aw_cfg, data, cont->size), GFP_KERNEL); - if (!aw87390->aw_cfg) { - release_firmware(cont); - return -ENOMEM; - } - - aw87390->aw_cfg->len =3D cont->size; - memcpy(aw87390->aw_cfg->data, cont->data, cont->size); - release_firmware(cont); - - ret =3D aw88395_dev_load_acf_check(aw87390->aw_pa, aw87390->aw_cfg); - if (ret) { - dev_err(aw87390->aw_pa->dev, "load [%s] failed!\n", AW87390_ACF_FILE); - return ret; - } - - mutex_lock(&aw87390->lock); - - ret =3D aw88395_dev_cfg_load(aw87390->aw_pa, aw87390->aw_cfg); - if (ret) - dev_err(aw87390->aw_pa->dev, "aw_dev acf parse failed\n"); - - mutex_unlock(&aw87390->lock); - - return ret; -} - static int aw87390_drv_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -331,10 +249,10 @@ static int aw87390_codec_probe(struct snd_soc_compone= nt *component) struct aw87390 *aw87390 =3D snd_soc_component_get_drvdata(component); int ret; =20 - ret =3D aw87390_request_firmware_file(aw87390); + ret =3D aw_dev_request_firmware_file(aw87390->aw_pa, AW87390_ACF_FILE); if (ret) return dev_err_probe(aw87390->aw_pa->dev, ret, - "aw87390_request_firmware_file failed\n"); + "aw_request_firmware_file failed\n"); =20 return 0; } @@ -392,7 +310,7 @@ static int aw87390_init(struct aw87390 **aw87390, struc= t i2c_client *i2c, struct aw_dev->acf =3D NULL; aw_dev->prof_info.prof_desc =3D NULL; aw_dev->prof_info.count =3D 0; - aw_dev->prof_info.prof_type =3D AW88395_DEV_NONE_TYPE_ID; + aw_dev->prof_info.prof_type =3D AW_DEV_NONE_TYPE_ID; aw_dev->channel =3D AW87390_DEV_DEFAULT_CH; aw_dev->fw_status =3D AW87390_DEV_FW_FAILED; aw_dev->prof_index =3D AW87390_INIT_PROFILE; diff --git a/sound/soc/codecs/aw87390.h b/sound/soc/codecs/aw87390.h index d0d049e65991..6023d4d5a0f9 100644 --- a/sound/soc/codecs/aw87390.h +++ b/sound/soc/codecs/aw87390.h @@ -52,15 +52,6 @@ #define AW87390_I2C_NAME "aw87390" #define AW87390_ACF_FILE "aw87390_acf.bin" =20 -#define AW87390_PROFILE_EXT(xname, profile_info, profile_get, profile_set)= \ -{ \ - .iface =3D SNDRV_CTL_ELEM_IFACE_MIXER, \ - .name =3D xname, \ - .info =3D profile_info, \ - .get =3D profile_get, \ - .put =3D profile_set, \ -} - enum aw87390_id { AW87390_CHIP_ID =3D 0x76, }; @@ -75,11 +66,4 @@ enum { AW87390_DEV_PW_ON, }; =20 -struct aw87390 { - struct aw_device *aw_pa; - struct mutex lock; - struct regmap *regmap; - struct aw_container *aw_cfg; -}; - #endif --=20 2.47.0