From nobody Fri Dec 19 00:16:47 2025 Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) (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 92D651E9B14 for ; Thu, 10 Apr 2025 03:24:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.234 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744255450; cv=none; b=QPjWMIYc1sb4yLgBYx8Uctmk7tUrX3WsFXgptVeMuYvQwRccorkuVJxaQ9jVCFjTPqePzB0ys2JoviAnCYoH2NMyDeIeAnRHsDhpy6S6ZjdYRdMHW5f5f+kHT4bPjjjST8vdSGBeJ0yGKXVPNxtr3NAO5eHxY8wzOTiFj9p70lw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744255450; c=relaxed/simple; bh=4gLD2iSfTNiIrGQ1C0EITHBwoEyxmBlxJRt1Xgh8Du0=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=NVYKhYZb4sT/vsojIia5LDnwhh3zEYMsO9z7k7qav4beHk+Ke441QGtEQRJSTgX+NZ1Ny64b28bLO9t/epm50ybOIDBvS6K8KFQ4C/+I/ROh6MXqcDtcfZAEqQbejOIVexYekABPN1urC95G8pyntqXJazp/9CxeX2ao2Blg4d8= 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=mBHWduw4; arc=none smtp.client-ip=198.47.23.234 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="mBHWduw4" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 53A3NbOG1154658 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Apr 2025 22:23:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1744255417; bh=pxMt1M41FUy9blO34h2KKUXfMYsagOUCTDq2/DW2oAo=; h=From:To:CC:Subject:Date; b=mBHWduw4djUAwhiRzyzGUcFptdE9Ybevtl3e/bXQZMiMq/Yen2xGxIrf5dc/GWP2U MTDlEgzMS7pMygL9aa0rr13ut3ZwOmnKLh7bSX8N9du6i0EGx9FYPL3e0rw3l6REd6 E2+//Yl7vLlLQNDXsN/qj5jzaMJzxRoMqEV3lBBs= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 53A3NbAO127993 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 9 Apr 2025 22:23:37 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 9 Apr 2025 22:23:37 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE113.ent.ti.com (10.64.6.34) 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, 9 Apr 2025 22:23:37 -0500 Received: from LT5CG31242FY.dhcp.ti.com ([10.250.163.204]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 53A3NWG7022629; Wed, 9 Apr 2025 22:23:33 -0500 From: Shenghao Ding To: CC: , , <13564923607@139.com>, <13916275206@139.com>, , , , , , Shenghao Ding Subject: [PATCH v2] ALSA: hda/tas2781: Create a common header for both spi and i2c tas2781 hda driver Date: Thu, 10 Apr 2025 11:23:28 +0800 Message-ID: <20250410032328.1361-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. Signed-off-by: Shenghao Ding --- 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