[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220622074653.179078-3-vitalyr@opensource.cirrus.com>
Date: Wed, 22 Jun 2022 08:46:41 +0100
From: Vitaly Rodionov <vitalyr@...nsource.cirrus.com>
To: Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
Mark Brown <broonie@...nel.org>
CC: <alsa-devel@...a-project.org>, <patches@...nsource.cirrus.com>,
<linux-kernel@...r.kernel.org>,
Stefan Binding <sbinding@...nsource.cirrus.com>
Subject: [PATCH v7 02/14] ALSA: hda: hda_cs_dsp_ctl: Add apis to write the controls directly
From: Stefan Binding <sbinding@...nsource.cirrus.com>
DSP controls are exposed as ALSA controls, however,
some of these controls are required to be accessed by
the driver. Add apis which allow read/write of these
controls. The write api will also notify the ALSA control
on value change.
Signed-off-by: Stefan Binding <sbinding@...nsource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@...nsource.cirrus.com>
---
sound/pci/hda/hda_cs_dsp_ctl.c | 39 ++++++++++++++++++++++++++++++++++
sound/pci/hda/hda_cs_dsp_ctl.h | 4 ++++
2 files changed, 43 insertions(+)
diff --git a/sound/pci/hda/hda_cs_dsp_ctl.c b/sound/pci/hda/hda_cs_dsp_ctl.c
index 0f4f02e0a538..91e37cb916dd 100644
--- a/sound/pci/hda/hda_cs_dsp_ctl.c
+++ b/sound/pci/hda/hda_cs_dsp_ctl.c
@@ -202,6 +202,45 @@ void hda_cs_dsp_control_remove(struct cs_dsp_coeff_ctl *cs_ctl)
}
EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_control_remove, SND_HDA_CS_DSP_CONTROLS);
+int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type,
+ unsigned int alg, const void *buf, size_t len)
+{
+ struct cs_dsp_coeff_ctl *cs_ctl;
+ struct hda_cs_dsp_coeff_ctl *ctl;
+ int ret;
+
+ cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg);
+ if (!cs_ctl)
+ return -EINVAL;
+
+ ctl = cs_ctl->priv;
+
+ ret = cs_dsp_coeff_write_ctrl(cs_ctl, 0, buf, len);
+ if (ret)
+ return ret;
+
+ if (cs_ctl->flags & WMFW_CTL_FLAG_SYS)
+ return 0;
+
+ snd_ctl_notify(ctl->card, SNDRV_CTL_EVENT_MASK_VALUE, &ctl->kctl->id);
+
+ return 0;
+}
+EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_write_ctl, SND_HDA_CS_DSP_CONTROLS);
+
+int hda_cs_dsp_read_ctl(struct cs_dsp *dsp, const char *name, int type,
+ unsigned int alg, void *buf, size_t len)
+{
+ struct cs_dsp_coeff_ctl *cs_ctl;
+
+ cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg);
+ if (!cs_ctl)
+ return -EINVAL;
+
+ return cs_dsp_coeff_read_ctrl(cs_ctl, 0, buf, len);
+}
+EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_read_ctl, SND_HDA_CS_DSP_CONTROLS);
+
MODULE_DESCRIPTION("CS_DSP ALSA Control HDA Library");
MODULE_AUTHOR("Stefan Binding, <sbinding@...nsource.cirrus.com>");
MODULE_LICENSE("GPL");
diff --git a/sound/pci/hda/hda_cs_dsp_ctl.h b/sound/pci/hda/hda_cs_dsp_ctl.h
index 1c6d0fc9a2cc..c65bfd6878fd 100644
--- a/sound/pci/hda/hda_cs_dsp_ctl.h
+++ b/sound/pci/hda/hda_cs_dsp_ctl.h
@@ -29,5 +29,9 @@ struct hda_cs_dsp_ctl_info {
int hda_cs_dsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl, struct hda_cs_dsp_ctl_info *info);
void hda_cs_dsp_control_remove(struct cs_dsp_coeff_ctl *cs_ctl);
+int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type,
+ unsigned int alg, const void *buf, size_t len);
+int hda_cs_dsp_read_ctl(struct cs_dsp *dsp, const char *name, int type,
+ unsigned int alg, void *buf, size_t len);
#endif /*__HDA_CS_DSP_CTL_H__*/
--
2.34.1
Powered by blists - more mailing lists