From nobody Fri Dec 19 00:34:43 2025 Received: from fllvem-ot03.ext.ti.com (fllvem-ot03.ext.ti.com [198.47.19.245]) (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 E2C482DFA2D for ; Wed, 16 Apr 2025 05:19:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.245 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744780751; cv=none; b=qG7iB1G4uK37KYeg3okK1OtwzNedTirrRnUdDGQgq7mm1L1xFKS5e25DYSMXgmG1Ml8MryP1lmjUxZi0QyT5ckPGu2kStRGXGYd+w/lb4UOUHMd22CJHhB9Z02pUhOoKEYWbRfH4DotbpkuyTr7MNKD8niSdyegmqkcrgGAoscw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744780751; c=relaxed/simple; bh=voLwMlG2CHMzwgcA2ppkhIz0XAmf9oe0ROwISvWdzJQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=MS9CPTyBV9gr8d+kLtxxA1X9lrsZxfsVzRi5RGFDtbTO7ibr4jP4CWE/fd27iepVxmCYImLBl3qwKBo/GPZrqHFBZEzDERYLgrm63qS2pw4xQkqdXM0fFb8ArqEwMlR/Chk8ExV5v3Et8P8NQGn8UCw2FSj5jIU1MepRIkW5uVo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=rMo4o2fq; arc=none smtp.client-ip=198.47.19.245 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="rMo4o2fq" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllvem-ot03.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 53G5IlWV2564926 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Apr 2025 00:18:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1744780727; bh=B9SELt7RxbB4eGa/NKNkpRq4PgXGEXrvy95SM69nqtk=; h=From:To:CC:Subject:Date; b=rMo4o2fqJqynuxiJb2q7w+sJS4dFdu000XJC4epibmQfiGplZVc7Aw6AhmZ04LmXw fauGGX71K/wyPZ10I4yno3jsW+x6tubRDhiwyTx2MuLC+4vn6K/mVY65YrG0baJnPq n7D7EFAHwucKLsoknx8nsxbjBALL+EiZHL6jp4DU= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 53G5Ilv1050306 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 16 Apr 2025 00:18:47 -0500 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 16 Apr 2025 00:18:46 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 16 Apr 2025 00:18:46 -0500 Received: from LT5CG31242FY.dhcp.ti.com (lt5cg31242fy.dhcp.ti.com [10.85.14.84]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 53G5Igig016006; Wed, 16 Apr 2025 00:18:43 -0500 From: Shenghao Ding To: CC: , , <13564923607@139.com>, <13916275206@139.com>, , , , , , Shenghao Ding Subject: [PATCH v3] ALSA: hda/tas2781: Create a common header for both spi and i2c tas2781 hda driver Date: Wed, 16 Apr 2025 13:18:38 +0800 Message-ID: <20250416051838.2001-1-shenghao-ding@ti.com> X-Mailer: git-send-email 2.33.0.windows.2 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 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" Move the common macro definition of kcontrols into a common header for code cleanup, and create a common header to store the common declaration for both spi and i2c hda driver. Signed-off-by: Shenghao Ding --- v3: - Add the purpose of this patch. v2: - Follow IWYU principle, add sound/asound.h into the header file. v1: - Revise the year of spi and i2c tas2781 hda drivers. - Create a common header for both spi and i2c tas2781 hda driver to define the common macros and declare the common functions. --- sound/pci/hda/tas2781_hda.h | 44 +++++++++++++++++++++++++++++++++ sound/pci/hda/tas2781_hda_i2c.c | 29 ++-------------------- sound/pci/hda/tas2781_hda_spi.c | 35 ++------------------------ 3 files changed, 48 insertions(+), 60 deletions(-) create mode 100644 sound/pci/hda/tas2781_hda.h diff --git a/sound/pci/hda/tas2781_hda.h b/sound/pci/hda/tas2781_hda.h new file mode 100644 index 000000000000..fc741fac419a --- /dev/null +++ b/sound/pci/hda/tas2781_hda.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0-only + * + * HDA audio driver for Texas Instruments TAS2781 smart amp + * + * Copyright (C) 2025 Texas Instruments, Inc. + */ +#ifndef __TAS2781_HDA_H__ +#define __TAS2781_HDA_H__ + +#include + +/* + * No standard control callbacks for SNDRV_CTL_ELEM_IFACE_CARD + * Define two controls, one is Volume control callbacks, the other is + * flag setting control callbacks. + */ + +/* Volume control callbacks for tas2781 */ +#define ACARD_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinver= t, \ + xhandler_get, xhandler_put, tlv_array) { \ + .iface =3D SNDRV_CTL_ELEM_IFACE_CARD, .name =3D (xname), \ + .access =3D SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ + SNDRV_CTL_ELEM_ACCESS_READWRITE, \ + .tlv.p =3D (tlv_array), \ + .info =3D snd_soc_info_volsw, \ + .get =3D xhandler_get, .put =3D xhandler_put, \ + .private_value =3D (unsigned long)&(struct soc_mixer_control) { \ + .reg =3D xreg, .rreg =3D xreg, \ + .shift =3D xshift, .rshift =3D xshift,\ + .min =3D xmin, .max =3D xmax, .invert =3D xinvert, \ + } \ +} + +/* Flag control callbacks for tas2781 */ +#define ACARD_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) { \ + .iface =3D SNDRV_CTL_ELEM_IFACE_CARD, \ + .name =3D xname, \ + .info =3D snd_ctl_boolean_mono_info, \ + .get =3D xhandler_get, \ + .put =3D xhandler_put, \ + .private_value =3D xdata, \ +} + +#endif diff --git a/sound/pci/hda/tas2781_hda_i2c.c b/sound/pci/hda/tas2781_hda_i2= c.c index 29dc4f500580..9d94ae5fcfe0 100644 --- a/sound/pci/hda/tas2781_hda_i2c.c +++ b/sound/pci/hda/tas2781_hda_i2c.c @@ -2,7 +2,7 @@ // // TAS2781 HDA I2C driver // -// Copyright 2023 - 2024 Texas Instruments, Inc. +// Copyright 2023 - 2025 Texas Instruments, Inc. // // Author: Shenghao Ding // Current maintainer: Baojun Xu @@ -30,35 +30,10 @@ #include "hda_component.h" #include "hda_jack.h" #include "hda_generic.h" +#include "tas2781_hda.h" =20 #define TASDEVICE_SPEAKER_CALIBRATION_SIZE 20 =20 -/* No standard control callbacks for SNDRV_CTL_ELEM_IFACE_CARD - * Define two controls, one is Volume control callbacks, the other is - * flag setting control callbacks. - */ - -/* Volume control callbacks for tas2781 */ -#define ACARD_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinver= t, \ - xhandler_get, xhandler_put, tlv_array) \ -{ .iface =3D SNDRV_CTL_ELEM_IFACE_CARD, .name =3D (xname),\ - .access =3D SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ - SNDRV_CTL_ELEM_ACCESS_READWRITE,\ - .tlv.p =3D (tlv_array), \ - .info =3D snd_soc_info_volsw, \ - .get =3D xhandler_get, .put =3D xhandler_put, \ - .private_value =3D (unsigned long)&(struct soc_mixer_control) \ - {.reg =3D xreg, .rreg =3D xreg, .shift =3D xshift, \ - .rshift =3D xshift, .min =3D xmin, .max =3D xmax, \ - .invert =3D xinvert} } - -/* Flag control callbacks for tas2781 */ -#define ACARD_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \ -{ .iface =3D SNDRV_CTL_ELEM_IFACE_CARD, .name =3D xname, \ - .info =3D snd_ctl_boolean_mono_info, \ - .get =3D xhandler_get, .put =3D xhandler_put, \ - .private_value =3D xdata } - enum calib_data { R0_VAL =3D 0, INV_R0, diff --git a/sound/pci/hda/tas2781_hda_spi.c b/sound/pci/hda/tas2781_hda_sp= i.c index 399f2e4c3b62..c6be2be1b53e 100644 --- a/sound/pci/hda/tas2781_hda_spi.c +++ b/sound/pci/hda/tas2781_hda_spi.c @@ -2,7 +2,7 @@ // // TAS2781 HDA SPI driver // -// Copyright 2024 Texas Instruments, Inc. +// Copyright 2024 - 2025 Texas Instruments, Inc. // // Author: Baojun Xu =20 @@ -38,38 +38,7 @@ #include "hda_component.h" #include "hda_jack.h" #include "hda_generic.h" - -/* - * No standard control callbacks for SNDRV_CTL_ELEM_IFACE_CARD - * Define two controls, one is Volume control callbacks, the other is - * flag setting control callbacks. - */ - -/* Volume control callbacks for tas2781 */ -#define ACARD_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinver= t, \ - xhandler_get, xhandler_put, tlv_array) { \ - .iface =3D SNDRV_CTL_ELEM_IFACE_CARD, .name =3D (xname), \ - .access =3D SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ - SNDRV_CTL_ELEM_ACCESS_READWRITE, \ - .tlv.p =3D (tlv_array), \ - .info =3D snd_soc_info_volsw, \ - .get =3D xhandler_get, .put =3D xhandler_put, \ - .private_value =3D (unsigned long)&(struct soc_mixer_control) { \ - .reg =3D xreg, .rreg =3D xreg, \ - .shift =3D xshift, .rshift =3D xshift,\ - .min =3D xmin, .max =3D xmax, .invert =3D xinvert, \ - } \ -} - -/* Flag control callbacks for tas2781 */ -#define ACARD_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) { \ - .iface =3D SNDRV_CTL_ELEM_IFACE_CARD, \ - .name =3D xname, \ - .info =3D snd_ctl_boolean_mono_info, \ - .get =3D xhandler_get, \ - .put =3D xhandler_put, \ - .private_value =3D xdata, \ -} +#include "tas2781_hda.h" =20 struct tas2781_hda { struct tasdevice_priv *priv; --=20 2.34.1