Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: hda/tas2781: Create a common header for both spi and i2c tas2781 hda driver

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>

authored by

Shenghao Ding and committed by
Takashi Iwai
813e311e bbf9d313

+48 -60
+44
sound/pci/hda/tas2781_hda.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only 2 + * 3 + * HDA audio driver for Texas Instruments TAS2781 smart amp 4 + * 5 + * Copyright (C) 2025 Texas Instruments, Inc. 6 + */ 7 + #ifndef __TAS2781_HDA_H__ 8 + #define __TAS2781_HDA_H__ 9 + 10 + #include <sound/asound.h> 11 + 12 + /* 13 + * No standard control callbacks for SNDRV_CTL_ELEM_IFACE_CARD 14 + * Define two controls, one is Volume control callbacks, the other is 15 + * flag setting control callbacks. 16 + */ 17 + 18 + /* Volume control callbacks for tas2781 */ 19 + #define ACARD_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \ 20 + xhandler_get, xhandler_put, tlv_array) { \ 21 + .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = (xname), \ 22 + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ 23 + SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 24 + .tlv.p = (tlv_array), \ 25 + .info = snd_soc_info_volsw, \ 26 + .get = xhandler_get, .put = xhandler_put, \ 27 + .private_value = (unsigned long)&(struct soc_mixer_control) { \ 28 + .reg = xreg, .rreg = xreg, \ 29 + .shift = xshift, .rshift = xshift,\ 30 + .min = xmin, .max = xmax, .invert = xinvert, \ 31 + } \ 32 + } 33 + 34 + /* Flag control callbacks for tas2781 */ 35 + #define ACARD_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) { \ 36 + .iface = SNDRV_CTL_ELEM_IFACE_CARD, \ 37 + .name = xname, \ 38 + .info = snd_ctl_boolean_mono_info, \ 39 + .get = xhandler_get, \ 40 + .put = xhandler_put, \ 41 + .private_value = xdata, \ 42 + } 43 + 44 + #endif
+2 -27
sound/pci/hda/tas2781_hda_i2c.c
··· 2 2 // 3 3 // TAS2781 HDA I2C driver 4 4 // 5 - // Copyright 2023 - 2024 Texas Instruments, Inc. 5 + // Copyright 2023 - 2025 Texas Instruments, Inc. 6 6 // 7 7 // Author: Shenghao Ding <shenghao-ding@ti.com> 8 8 // Current maintainer: Baojun Xu <baojun.xu@ti.com> ··· 30 30 #include "hda_component.h" 31 31 #include "hda_jack.h" 32 32 #include "hda_generic.h" 33 + #include "tas2781_hda.h" 33 34 34 35 #define TASDEVICE_SPEAKER_CALIBRATION_SIZE 20 35 - 36 - /* No standard control callbacks for SNDRV_CTL_ELEM_IFACE_CARD 37 - * Define two controls, one is Volume control callbacks, the other is 38 - * flag setting control callbacks. 39 - */ 40 - 41 - /* Volume control callbacks for tas2781 */ 42 - #define ACARD_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \ 43 - xhandler_get, xhandler_put, tlv_array) \ 44 - { .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = (xname),\ 45 - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ 46 - SNDRV_CTL_ELEM_ACCESS_READWRITE,\ 47 - .tlv.p = (tlv_array), \ 48 - .info = snd_soc_info_volsw, \ 49 - .get = xhandler_get, .put = xhandler_put, \ 50 - .private_value = (unsigned long)&(struct soc_mixer_control) \ 51 - {.reg = xreg, .rreg = xreg, .shift = xshift, \ 52 - .rshift = xshift, .min = xmin, .max = xmax, \ 53 - .invert = xinvert} } 54 - 55 - /* Flag control callbacks for tas2781 */ 56 - #define ACARD_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \ 57 - { .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = xname, \ 58 - .info = snd_ctl_boolean_mono_info, \ 59 - .get = xhandler_get, .put = xhandler_put, \ 60 - .private_value = xdata } 61 36 62 37 enum calib_data { 63 38 R0_VAL = 0,
+2 -33
sound/pci/hda/tas2781_hda_spi.c
··· 2 2 // 3 3 // TAS2781 HDA SPI driver 4 4 // 5 - // Copyright 2024 Texas Instruments, Inc. 5 + // Copyright 2024 - 2025 Texas Instruments, Inc. 6 6 // 7 7 // Author: Baojun Xu <baojun.xu@ti.com> 8 8 ··· 38 38 #include "hda_component.h" 39 39 #include "hda_jack.h" 40 40 #include "hda_generic.h" 41 - 42 - /* 43 - * No standard control callbacks for SNDRV_CTL_ELEM_IFACE_CARD 44 - * Define two controls, one is Volume control callbacks, the other is 45 - * flag setting control callbacks. 46 - */ 47 - 48 - /* Volume control callbacks for tas2781 */ 49 - #define ACARD_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \ 50 - xhandler_get, xhandler_put, tlv_array) { \ 51 - .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = (xname), \ 52 - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ 53 - SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 54 - .tlv.p = (tlv_array), \ 55 - .info = snd_soc_info_volsw, \ 56 - .get = xhandler_get, .put = xhandler_put, \ 57 - .private_value = (unsigned long)&(struct soc_mixer_control) { \ 58 - .reg = xreg, .rreg = xreg, \ 59 - .shift = xshift, .rshift = xshift,\ 60 - .min = xmin, .max = xmax, .invert = xinvert, \ 61 - } \ 62 - } 63 - 64 - /* Flag control callbacks for tas2781 */ 65 - #define ACARD_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) { \ 66 - .iface = SNDRV_CTL_ELEM_IFACE_CARD, \ 67 - .name = xname, \ 68 - .info = snd_ctl_boolean_mono_info, \ 69 - .get = xhandler_get, \ 70 - .put = xhandler_put, \ 71 - .private_value = xdata, \ 72 - } 41 + #include "tas2781_hda.h" 73 42 74 43 struct tas2781_hda { 75 44 struct tasdevice_priv *priv;