From nobody Tue Feb 10 09:24:45 2026 Received: from out198-24.us.a.mail.aliyun.com (out198-24.us.a.mail.aliyun.com [47.90.198.24]) (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 E4F9B27FD5B; Fri, 17 Oct 2025 10:27:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.90.198.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760696830; cv=none; b=i7MnB9lB/Kv2iY5TbtlkVb7tKYo/Aj1ixbALL/V5xVL+bpTcDJT+yi+jqab4TWVX9Y/r6xiKQkNyYFmDv7SCoBnb6eaEon3PktdcmjnYJIigTBFbD6jYt+mb268xDcCZCpTqCSDUjZtauGE7wAIlUy4hlEuejaq6ON5rww9k4T4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760696830; c=relaxed/simple; bh=ycdqKx049ec96ztt5legE1xGnQlokmuCPb4oXnPK5kc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rwOAdg+tdBbAP46uKozdbQ4kt/eJZsgN6K5YcO/E+5TrFNbNwB4a3VjIyKQnUE8MEsxE2A6s7uE7pG3uqowv2AUEDcZn4yi7GWHPGcj3yw7GStoxKiaOqY+lDJbLwpV1dajrSq/+f7SRc+8Cr1/gLFGKB7pHNKzRTdg8xYLs/Xo= 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=PJVETTIa; arc=none smtp.client-ip=47.90.198.24 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="PJVETTIa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=awinic.com; s=default; t=1760696814; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=N3NMHu79bWTQmAi1Ox9IMsWEADEFAdTNFM0K+1AfHXg=; b=PJVETTIazzYVXQzHFnF0J7j2OpldDaKeGJ0r3tsfzmqipPhAo0omclyvD+drdVzsIkinXzx8FY3/3sxaiHKt5D+1v5WLx0Qa/nlPvqFdImJqlO6HYefySnlOEmkkx9KUbR8/KedrWPvc7vk7v2bJ+u70qohIbKocHq7z7C6K4xxEeOr5WdsAcRuQjoS78rZ0591luHbvo7n7l2qjVU/2SOuk9970qaUS0Ru0ifLe344tGypvQvG1KShZfaRASaofer2NyV+4TPeYs2diyi9PQXcwUzKtchxHbJkTBFVYFBfWhKAg0WmCIg7eXzXQkF3s+RjKh7xq7U0BYFPppmQCCg== Received: from ubuntu-VirtualBox..(mailfrom:wangweidong.a@awinic.com fp:SMTPD_---.f0sBY58_1760695875 cluster:ay29) by smtp.aliyun-inc.com; Fri, 17 Oct 2025 18:11:16 +0800 From: wangweidong.a@awinic.com To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, arnd@arndb.de, wangweidong.a@awinic.com, srinivas.kandagatla@oss.qualcomm.com, cy_huang@richtek.com, nick.li@foursemi.com, hangyi@everest-semi.com, alexey.klimov@linaro.org, niranjan.hy@ti.com, shenghao-ding@ti.com, linux@treblig.org, rf@opensource.cirrus.com, thorsten.blum@linux.dev, yesanishhere@gmail.com, ardb@kernel.org, ebiggers@google.com, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org Cc: yijiangtao@awinic.com Subject: [PATCH V2 3/7] ASoC: codecs: Rework the aw87390 driver Date: Fri, 17 Oct 2025 18:11:01 +0800 Message-ID: <20251017101106.370742-4-wangweidong.a@awinic.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20251017101106.370742-1-wangweidong.a@awinic.com> References: <20251017101106.370742-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