summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNiranjan H Y <niranjan.hy@ti.com>2026-04-01 18:51:45 +0530
committerMark Brown <broonie@kernel.org>2026-04-03 15:12:38 +0100
commitba2a0e81d4d71c3bbc61c420b6fac5abaeddd77d (patch)
tree086086953c27ae7012405e2b86fd85c91a258e7f /include
parent04cc47624a33a6b56c62bfd65ad6b2d1c42e17c4 (diff)
ASoC: SDCA: Export Q7.8 volume control helpers
Export the Q7.8 volume control helpers to allow reuse by other ASoC drivers. These functions handle 16-bit signed Q7.8 fixed-point format values for volume controls. Changes include: - Rename q78_get_volsw to sdca_asoc_q78_get_volsw - Rename q78_put_volsw to sdca_asoc_q78_put_volsw - Add a convenience macro SDCA_SINGLE_Q78_TLV and SDCA_DOUBLE_Q78_TLV for creating mixer controls This allows other ASoC drivers to easily implement controls using the Q7.8 fixed-point format without duplicating code. Signed-off-by: Niranjan H Y <niranjan.hy@ti.com> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://patch.msgid.link/20260401132148.2367-1-niranjan.hy@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/sound/sdca_asoc.h43
1 files changed, 42 insertions, 1 deletions
diff --git a/include/sound/sdca_asoc.h b/include/sound/sdca_asoc.h
index aa9124f932189..46a61a52decc5 100644
--- a/include/sound/sdca_asoc.h
+++ b/include/sound/sdca_asoc.h
@@ -13,6 +13,8 @@
struct device;
struct regmap;
struct sdca_function_data;
+struct snd_ctl_elem_value;
+struct snd_kcontrol;
struct snd_kcontrol_new;
struct snd_pcm_hw_params;
struct snd_pcm_substream;
@@ -23,6 +25,42 @@ struct snd_soc_dai_ops;
struct snd_soc_dapm_route;
struct snd_soc_dapm_widget;
+/* convenient macro to handle the mono volume in 7.8 fixed format representation */
+#define SDCA_SINGLE_Q78_TLV(xname, xreg, xmin, xmax, xstep, tlv_array) \
+{ \
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+ .name = (xname), \
+ .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE, \
+ .tlv.p = (tlv_array), \
+ .info = snd_soc_info_volsw, \
+ .get = sdca_asoc_q78_get_volsw, \
+ .put = sdca_asoc_q78_put_volsw, \
+ .private_value = (unsigned long)&(struct soc_mixer_control) { \
+ .reg = (xreg), .rreg = (xreg), \
+ .min = (xmin), .max = (xmax), \
+ .shift = (xstep), .rshift = (xstep), \
+ .sign_bit = 15 \
+ } \
+}
+
+/* convenient macro for stereo volume in 7.8 fixed format with separate registers for L/R */
+#define SDCA_DOUBLE_Q78_TLV(xname, xreg_l, xreg_r, xmin, xmax, xstep, tlv_array) \
+{ \
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+ .name = (xname), \
+ .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE, \
+ .tlv.p = (tlv_array), \
+ .info = snd_soc_info_volsw, \
+ .get = sdca_asoc_q78_get_volsw, \
+ .put = sdca_asoc_q78_put_volsw, \
+ .private_value = (unsigned long)&(struct soc_mixer_control) { \
+ .reg = (xreg_l), .rreg = (xreg_r), \
+ .min = (xmin), .max = (xmax), \
+ .shift = (xstep), .rshift = (xstep), \
+ .sign_bit = 15 \
+ } \
+}
+
int sdca_asoc_count_component(struct device *dev, struct sdca_function_data *function,
int *num_widgets, int *num_routes, int *num_controls,
int *num_dais);
@@ -57,5 +95,8 @@ int sdca_asoc_hw_params(struct device *dev, struct regmap *regmap,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai);
-
+int sdca_asoc_q78_put_volsw(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol);
+int sdca_asoc_q78_get_volsw(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol);
#endif // __SDCA_ASOC_H__