[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220526093658.GQ38351@ediswmail.ad.cirrus.com>
Date: Thu, 26 May 2022 09:36:58 +0000
From: Charles Keepax <ckeepax@...nsource.cirrus.com>
To: Vitaly Rodionov <vitalyr@...nsource.cirrus.com>
CC: Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
Mark Brown <broonie@...nel.org>, <alsa-devel@...a-project.org>,
<patches@...nsource.cirrus.com>, <linux-kernel@...r.kernel.org>,
Stefan Binding <sbinding@...nsource.cirrus.com>
Subject: Re: [PATCH v4 02/17] ALSA: hda: hda_cs_dsp_ctl: Add apis to write
the controls directly
On Wed, May 25, 2022 at 02:16:23PM +0100, Vitaly Rodionov wrote:
> 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>
> ---
>
> Changes since v2:
> - No change
>
> sound/pci/hda/hda_cs_dsp_ctl.c | 52 ++++++++++++++++++++++++++++++++++
> sound/pci/hda/hda_cs_dsp_ctl.h | 4 +++
> 2 files changed, 56 insertions(+)
>
> diff --git a/sound/pci/hda/hda_cs_dsp_ctl.c b/sound/pci/hda/hda_cs_dsp_ctl.c
> index 46df48ff2ae1..3b837d000a00 100644
> --- a/sound/pci/hda/hda_cs_dsp_ctl.c
> +++ b/sound/pci/hda/hda_cs_dsp_ctl.c
> @@ -237,6 +237,58 @@ 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, void *buf, size_t len)
> +{
> + struct cs_dsp_coeff_ctl *cs_ctl;
> + struct hda_cs_dsp_coeff_ctl *ctl;
> + struct snd_kcontrol *kctl;
> + int ret;
> +
> + cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg);
> + if (!cs_ctl)
> + return -EINVAL;
> +
> + ctl = cs_ctl->priv;
> +
> + if (len > cs_ctl->len)
> + return -EINVAL;
Is it just me or are these length check unnecessary? I realise
they are also in the wm_adsp code you are copying, but it looks
to me like they are redundant in both cases, cs_dsp_coeff_*_ctrl
appears to do a length check itself.
> +
> + 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;
> +
> + list_for_each_entry(kctl, &ctl->card->controls, list)
> + if (!strncmp(kctl->id.name, ctl->name, sizeof(kctl->id.name))) {
> + snd_ctl_notify(ctl->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
> + return 0;
> + }
> +
> + dev_warn(dsp->dev, "Cannot find Control for %s\n", name);
> +
> + 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;
> +
> + if (len > cs_ctl->len)
> + return -EINVAL;
ditto.
Thanks,
Charles
Powered by blists - more mailing lists