]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ALSA: hda/tas2781: Create a common header for both spi and i2c tas2781 hda driver
authorShenghao Ding <shenghao-ding@ti.com>
Wed, 16 Apr 2025 05:18:38 +0000 (13:18 +0800)
committerTakashi Iwai <tiwai@suse.de>
Wed, 16 Apr 2025 07:21:56 +0000 (09:21 +0200)
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 <shenghao-ding@ti.com>
Link: https://patch.msgid.link/20250416051838.2001-1-shenghao-ding@ti.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/tas2781_hda.h [new file with mode: 0644]
sound/pci/hda/tas2781_hda_i2c.c
sound/pci/hda/tas2781_hda_spi.c

diff --git a/sound/pci/hda/tas2781_hda.h b/sound/pci/hda/tas2781_hda.h
new file mode 100644 (file)
index 0000000..32d27b2
--- /dev/null
@@ -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 <sound/asound.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, xinvert, \
+       xhandler_get, xhandler_put, tlv_array) { \
+       .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = (xname), \
+       .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
+               SNDRV_CTL_ELEM_ACCESS_READWRITE, \
+       .tlv.p = (tlv_array), \
+       .info = snd_soc_info_volsw, \
+       .get = xhandler_get, .put = xhandler_put, \
+       .private_value = (unsigned long)&(struct soc_mixer_control) { \
+               .reg = xreg, .rreg = xreg, \
+               .shift = xshift, .rshift = xshift,\
+               .min = xmin, .max = xmax, .invert = xinvert, \
+       } \
+}
+
+/* Flag control callbacks for tas2781 */
+#define ACARD_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) { \
+       .iface = SNDRV_CTL_ELEM_IFACE_CARD, \
+       .name = xname, \
+       .info = snd_ctl_boolean_mono_info, \
+       .get = xhandler_get, \
+       .put = xhandler_put, \
+       .private_value = xdata, \
+}
+
+#endif
index 29dc4f500580e4dcded1dc9b3cf6074dcc7834a4..9d94ae5fcfe0ed9ed8bf099f7535cc6771a67801 100644 (file)
@@ -2,7 +2,7 @@
 //
 // TAS2781 HDA I2C driver
 //
-// Copyright 2023 - 2024 Texas Instruments, Inc.
+// Copyright 2023 - 2025 Texas Instruments, Inc.
 //
 // Author: Shenghao Ding <shenghao-ding@ti.com>
 // Current maintainer: Baojun Xu <baojun.xu@ti.com>
 #include "hda_component.h"
 #include "hda_jack.h"
 #include "hda_generic.h"
+#include "tas2781_hda.h"
 
 #define TASDEVICE_SPEAKER_CALIBRATION_SIZE     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, xinvert, \
-       xhandler_get, xhandler_put, tlv_array) \
-{      .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = (xname),\
-       .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
-                SNDRV_CTL_ELEM_ACCESS_READWRITE,\
-       .tlv.p = (tlv_array), \
-       .info = snd_soc_info_volsw, \
-       .get = xhandler_get, .put = xhandler_put, \
-       .private_value = (unsigned long)&(struct soc_mixer_control) \
-               {.reg = xreg, .rreg = xreg, .shift = xshift, \
-                .rshift = xshift, .min = xmin, .max = xmax, \
-                .invert = xinvert} }
-
-/* Flag control callbacks for tas2781 */
-#define ACARD_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
-{      .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = xname, \
-       .info = snd_ctl_boolean_mono_info, \
-       .get = xhandler_get, .put = xhandler_put, \
-       .private_value = xdata }
-
 enum calib_data {
        R0_VAL = 0,
        INV_R0,
index 25175ff4b3aaa55d4abba61fc280904974624594..92be591c6bfee029218b1e5b36e8eb5c5c1ec376 100644 (file)
@@ -2,7 +2,7 @@
 //
 // TAS2781 HDA SPI driver
 //
-// Copyright 2024 Texas Instruments, Inc.
+// Copyright 2024 - 2025 Texas Instruments, Inc.
 //
 // Author: Baojun Xu <baojun.xu@ti.com>
 
 #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, xinvert, \
-       xhandler_get, xhandler_put, tlv_array) { \
-       .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = (xname), \
-       .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
-               SNDRV_CTL_ELEM_ACCESS_READWRITE, \
-       .tlv.p = (tlv_array), \
-       .info = snd_soc_info_volsw, \
-       .get = xhandler_get, .put = xhandler_put, \
-       .private_value = (unsigned long)&(struct soc_mixer_control) { \
-               .reg = xreg, .rreg = xreg, \
-               .shift = xshift, .rshift = xshift,\
-               .min = xmin, .max = xmax, .invert = xinvert, \
-       } \
-}
-
-/* Flag control callbacks for tas2781 */
-#define ACARD_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) { \
-       .iface = SNDRV_CTL_ELEM_IFACE_CARD, \
-       .name = xname, \
-       .info = snd_ctl_boolean_mono_info, \
-       .get = xhandler_get, \
-       .put = xhandler_put, \
-       .private_value = xdata, \
-}
+#include "tas2781_hda.h"
 
 struct tas2781_hda {
        struct tasdevice_priv *priv;