diff options
Diffstat (limited to 'sound/soc/codecs/wm_adsp.c')
-rw-r--r-- | sound/soc/codecs/wm_adsp.c | 113 |
1 files changed, 65 insertions, 48 deletions
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 66e32f5..82b0927 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -605,13 +605,13 @@ static const struct { }; static void wm_adsp2_init_debugfs(struct wm_adsp *dsp, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct dentry *root = NULL; char *root_name; int i; - if (!codec->component.debugfs_root) { + if (!component->debugfs_root) { adsp_err(dsp, "No codec debugfs root\n"); goto err; } @@ -621,7 +621,7 @@ static void wm_adsp2_init_debugfs(struct wm_adsp *dsp, goto err; snprintf(root_name, PAGE_SIZE, "dsp%d", dsp->num); - root = debugfs_create_dir(root_name, codec->component.debugfs_root); + root = debugfs_create_dir(root_name, component->debugfs_root); kfree(root_name); if (!root) @@ -662,7 +662,7 @@ static void wm_adsp2_cleanup_debugfs(struct wm_adsp *dsp) } #else static inline void wm_adsp2_init_debugfs(struct wm_adsp *dsp, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { } @@ -688,9 +688,9 @@ static inline void wm_adsp_debugfs_clear(struct wm_adsp *dsp) static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); + struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = dsp[e->shift_l].fw; @@ -700,9 +700,9 @@ static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol, static int wm_adsp_fw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); + struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); int ret = 0; if (ucontrol->value.enumerated.item[0] == dsp[e->shift_l].fw) @@ -1204,16 +1204,18 @@ static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) kcontrol->put = wm_coeff_put_acked; break; default: - kcontrol->get = wm_coeff_get; - kcontrol->put = wm_coeff_put; - - ctl->bytes_ext.max = ctl->len; - ctl->bytes_ext.get = wm_coeff_tlv_get; - ctl->bytes_ext.put = wm_coeff_tlv_put; + if (kcontrol->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { + ctl->bytes_ext.max = ctl->len; + ctl->bytes_ext.get = wm_coeff_tlv_get; + ctl->bytes_ext.put = wm_coeff_tlv_put; + } else { + kcontrol->get = wm_coeff_get; + kcontrol->put = wm_coeff_put; + } break; } - ret = snd_soc_add_codec_controls(dsp->codec, kcontrol, 1); + ret = snd_soc_add_component_controls(dsp->component, kcontrol, 1); if (ret < 0) goto err_kcontrol; @@ -1237,9 +1239,16 @@ static int wm_coeff_init_control_caches(struct wm_adsp *dsp) if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) continue; - ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len); - if (ret < 0) - return ret; + /* + * For readable controls populate the cache from the DSP memory. + * For non-readable controls the cache was zero-filled when + * created so we don't need to do anything. + */ + if (!ctl->flags || (ctl->flags & WMFW_CTL_FLAG_READABLE)) { + ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len); + if (ret < 0) + return ret; + } } return 0; @@ -2396,14 +2405,14 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm_adsp *dsps = snd_soc_component_get_drvdata(component); struct wm_adsp *dsp = &dsps[w->shift]; struct wm_coeff_ctl *ctl; int ret; unsigned int val; - dsp->codec = codec; + dsp->component = component; mutex_lock(&dsp->pwr_lock); @@ -2633,8 +2642,8 @@ static void wm_adsp2_set_dspclk(struct wm_adsp *dsp, unsigned int freq) int wm_adsp2_preloader_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = dsp->preloaded; @@ -2645,9 +2654,9 @@ EXPORT_SYMBOL_GPL(wm_adsp2_preloader_get); int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; char preload[32]; @@ -2683,8 +2692,8 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event, unsigned int freq) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm_adsp *dsps = snd_soc_component_get_drvdata(component); struct wm_adsp *dsp = &dsps[w->shift]; struct wm_coeff_ctl *ctl; @@ -2726,8 +2735,8 @@ EXPORT_SYMBOL_GPL(wm_adsp2_early_event); int wm_adsp2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm_adsp *dsps = snd_soc_component_get_drvdata(component); struct wm_adsp *dsp = &dsps[w->shift]; int ret; @@ -2841,31 +2850,31 @@ err: } EXPORT_SYMBOL_GPL(wm_adsp2_event); -int wm_adsp2_codec_probe(struct wm_adsp *dsp, struct snd_soc_codec *codec) +int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); char preload[32]; snprintf(preload, ARRAY_SIZE(preload), "DSP%d Preload", dsp->num); snd_soc_dapm_disable_pin(dapm, preload); - wm_adsp2_init_debugfs(dsp, codec); + wm_adsp2_init_debugfs(dsp, component); - dsp->codec = codec; + dsp->component = component; - return snd_soc_add_codec_controls(codec, + return snd_soc_add_component_controls(component, &wm_adsp_fw_controls[dsp->num - 1], 1); } -EXPORT_SYMBOL_GPL(wm_adsp2_codec_probe); +EXPORT_SYMBOL_GPL(wm_adsp2_component_probe); -int wm_adsp2_codec_remove(struct wm_adsp *dsp, struct snd_soc_codec *codec) +int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *component) { wm_adsp2_cleanup_debugfs(dsp); return 0; } -EXPORT_SYMBOL_GPL(wm_adsp2_codec_remove); +EXPORT_SYMBOL_GPL(wm_adsp2_component_remove); int wm_adsp2_init(struct wm_adsp *dsp) { @@ -3251,6 +3260,13 @@ static int wm_adsp_buffer_populate(struct wm_adsp_compr_buf *buf) return 0; } +static void wm_adsp_buffer_clear(struct wm_adsp_compr_buf *buf) +{ + buf->irq_count = 0xFFFFFFFF; + buf->read_index = -1; + buf->avail = 0; +} + static int wm_adsp_buffer_init(struct wm_adsp *dsp) { struct wm_adsp_compr_buf *buf; @@ -3261,8 +3277,8 @@ static int wm_adsp_buffer_init(struct wm_adsp *dsp) return -ENOMEM; buf->dsp = dsp; - buf->read_index = -1; - buf->irq_count = 0xFFFFFFFF; + + wm_adsp_buffer_clear(buf); ret = wm_adsp_buffer_locate(buf); if (ret < 0) { @@ -3320,16 +3336,17 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd) switch (cmd) { case SNDRV_PCM_TRIGGER_START: - if (wm_adsp_compr_attached(compr)) - break; - - ret = wm_adsp_compr_attach(compr); - if (ret < 0) { - adsp_err(dsp, "Failed to link buffer and stream: %d\n", - ret); - break; + if (!wm_adsp_compr_attached(compr)) { + ret = wm_adsp_compr_attach(compr); + if (ret < 0) { + adsp_err(dsp, "Failed to link buffer and stream: %d\n", + ret); + break; + } } + wm_adsp_buffer_clear(compr->buf); + /* Trigger the IRQ at one fragment of data */ ret = wm_adsp_buffer_write(compr->buf, HOST_BUFFER_FIELD(high_water_mark), |