xref: /linux/sound/pci/hda/tas2781_hda.h (revision a9e6060bb2a6cae6d43a98ec0794844ad01273d3)
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 /* Flag of calibration registers address. */
13 #define TASDEV_UEFI_CALI_REG_ADDR_FLG	BIT(7)
14 #define TASDEVICE_CALIBRATION_DATA_NAME	L"CALI_DATA"
15 #define TASDEV_CALIB_N			5
16 
17 /*
18  * No standard control callbacks for SNDRV_CTL_ELEM_IFACE_CARD
19  * Define two controls, one is Volume control callbacks, the other is
20  * flag setting control callbacks.
21  */
22 
23 /* Volume control callbacks for tas2781 */
24 #define ACARD_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \
25 	xhandler_get, xhandler_put, tlv_array) { \
26 	.iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = (xname), \
27 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
28 		SNDRV_CTL_ELEM_ACCESS_READWRITE, \
29 	.tlv.p = (tlv_array), \
30 	.info = snd_soc_info_volsw, \
31 	.get = xhandler_get, .put = xhandler_put, \
32 	.private_value = (unsigned long)&(struct soc_mixer_control) { \
33 		.reg = xreg, .rreg = xreg, \
34 		.shift = xshift, .rshift = xshift,\
35 		.min = xmin, .max = xmax, .invert = xinvert, \
36 	} \
37 }
38 
39 /* Flag control callbacks for tas2781 */
40 #define ACARD_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) { \
41 	.iface = SNDRV_CTL_ELEM_IFACE_CARD, \
42 	.name = xname, \
43 	.info = snd_ctl_boolean_mono_info, \
44 	.get = xhandler_get, \
45 	.put = xhandler_put, \
46 	.private_value = xdata, \
47 }
48 
49 enum device_catlog_id {
50 	DELL = 0,
51 	HP,
52 	LENOVO,
53 	OTHERS
54 };
55 
56 struct tas2781_hda {
57 	struct device *dev;
58 	struct tasdevice_priv *priv;
59 	struct snd_kcontrol *dsp_prog_ctl;
60 	struct snd_kcontrol *dsp_conf_ctl;
61 	struct snd_kcontrol *prof_ctl;
62 	enum device_catlog_id catlog_id;
63 	void *hda_priv;
64 };
65 
66 extern const efi_guid_t tasdev_fct_efi_guid[];
67 
68 int tas2781_save_calibration(struct tas2781_hda *p);
69 void tas2781_hda_remove(struct device *dev,
70 	const struct component_ops *ops);
71 int tasdevice_info_profile(struct snd_kcontrol *kctl,
72 	struct snd_ctl_elem_info *uctl);
73 int tasdevice_info_programs(struct snd_kcontrol *kctl,
74 	struct snd_ctl_elem_info *uctl);
75 int tasdevice_info_config(struct snd_kcontrol *kctl,
76 	struct snd_ctl_elem_info *uctl);
77 int tasdevice_set_profile_id(struct snd_kcontrol *kctl,
78 	struct snd_ctl_elem_value *uctl);
79 int tasdevice_get_profile_id(struct snd_kcontrol *kctl,
80 	struct snd_ctl_elem_value *uctl);
81 int tasdevice_program_get(struct snd_kcontrol *kctl,
82 	struct snd_ctl_elem_value *uctl);
83 int tasdevice_program_put(struct snd_kcontrol *kctl,
84 	struct snd_ctl_elem_value *uctl);
85 int tasdevice_config_put(struct snd_kcontrol *kctl,
86 	struct snd_ctl_elem_value *uctl);
87 int tasdevice_config_get(struct snd_kcontrol *kctl,
88 	struct snd_ctl_elem_value *uctl);
89 
90 #endif
91