Commit fe0d5b9a authored by Mark Brown's avatar Mark Brown

ASoC: Factor out control notification support

Merge series from Charles Keepax <ckeepax@opensource.cirrus.com>:

This series introduces and uses a helper for notifying control changes
to userspace.
parents 8d7c1a57 95d06196
......@@ -454,6 +454,10 @@ int snd_soc_component_force_enable_pin_unlocked(
struct snd_soc_component *component,
const char *pin);
/* component controls */
int snd_soc_component_notify_control(struct snd_soc_component *component,
const char * const ctl);
/* component driver ops */
int snd_soc_component_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream);
......
......@@ -264,8 +264,6 @@ static irqreturn_t ak4118_irq_handler(int irq, void *data)
struct ak4118_priv *ak4118 = data;
struct snd_soc_component *component = ak4118->component;
struct snd_kcontrol_new *kctl_new;
struct snd_kcontrol *kctl;
struct snd_ctl_elem_id *id;
unsigned int i;
if (!component)
......@@ -273,13 +271,8 @@ static irqreturn_t ak4118_irq_handler(int irq, void *data)
for (i = 0; i < ARRAY_SIZE(ak4118_iec958_controls); i++) {
kctl_new = &ak4118_iec958_controls[i];
kctl = snd_soc_card_get_kcontrol(component->card,
kctl_new->name);
if (!kctl)
continue;
id = &kctl->id;
snd_ctl_notify(component->card->snd_card,
SNDRV_CTL_EVENT_MASK_VALUE, id);
snd_soc_component_notify_control(component, kctl_new->name);
}
return IRQ_HANDLED;
......
......@@ -686,8 +686,6 @@ int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type,
{
struct cs_dsp_coeff_ctl *cs_ctl = cs_dsp_get_ctl(&dsp->cs_dsp, name, type, alg);
struct wm_coeff_ctl *ctl;
struct snd_kcontrol *kcontrol;
char ctl_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
int ret;
ret = cs_dsp_coeff_write_ctrl(cs_ctl, 0, buf, len);
......@@ -699,23 +697,7 @@ int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type,
ctl = cs_ctl->priv;
if (dsp->component->name_prefix)
snprintf(ctl_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s %s",
dsp->component->name_prefix, ctl->name);
else
snprintf(ctl_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s",
ctl->name);
kcontrol = snd_soc_card_get_kcontrol(dsp->component->card, ctl_name);
if (!kcontrol) {
adsp_err(dsp, "Can't find kcontrol %s\n", ctl_name);
return -EINVAL;
}
snd_ctl_notify(dsp->component->card->snd_card,
SNDRV_CTL_EVENT_MASK_VALUE, &kcontrol->id);
return 0;
return snd_soc_component_notify_control(dsp->component, ctl->name);
}
EXPORT_SYMBOL_GPL(wm_adsp_write_ctl);
......
......@@ -236,6 +236,28 @@ int snd_soc_component_force_enable_pin_unlocked(
}
EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked);
int snd_soc_component_notify_control(struct snd_soc_component *component,
const char * const ctl)
{
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
struct snd_kcontrol *kctl;
if (component->name_prefix)
snprintf(name, ARRAY_SIZE(name), "%s %s", component->name_prefix, ctl);
else
snprintf(name, ARRAY_SIZE(name), "%s", ctl);
kctl = snd_soc_card_get_kcontrol(component->card, name);
if (!kctl)
return soc_component_ret(component, -EINVAL);
snd_ctl_notify(component->card->snd_card,
SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_component_notify_control);
/**
* snd_soc_component_set_jack - configure component jack.
* @component: COMPONENTs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment