mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 13:11:40 +00:00
ASoC: wm_adsp: Switch to using wm_coeff_read_ctrl for compressed buffers
When parsing a compressed buffer from the firmware the driver currently open codes reading the firmware coefficient containing the buffer description. Improve this slightly by using the coefficient read functions already provided by the wm_adsp driver. It is worth noting this change requires the running variable to be set before wm_adsp_buffer_init is called, however this is safe, since its all still under the power lock and nothing in the compressed code gates itself on running. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210913160057.103842-4-simont@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
6477960755
commit
04ae085967
@ -3277,14 +3277,14 @@ int wm_adsp_event(struct snd_soc_dapm_widget *w,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dsp->running = true;
|
||||||
|
|
||||||
if (wm_adsp_fw[dsp->fw].num_caps != 0) {
|
if (wm_adsp_fw[dsp->fw].num_caps != 0) {
|
||||||
ret = wm_adsp_buffer_init(dsp);
|
ret = wm_adsp_buffer_init(dsp);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
dsp->running = true;
|
|
||||||
|
|
||||||
mutex_unlock(&dsp->pwr_lock);
|
mutex_unlock(&dsp->pwr_lock);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3869,26 +3869,21 @@ static int wm_adsp_buffer_parse_coeff(struct wm_coeff_ctl *ctl)
|
|||||||
{
|
{
|
||||||
struct wm_adsp_host_buf_coeff_v1 coeff_v1;
|
struct wm_adsp_host_buf_coeff_v1 coeff_v1;
|
||||||
struct wm_adsp_compr_buf *buf;
|
struct wm_adsp_compr_buf *buf;
|
||||||
unsigned int reg, version;
|
unsigned int version;
|
||||||
__be32 bufp;
|
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
ret = wm_coeff_base_reg(ctl, ®);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
for (i = 0; i < 5; ++i) {
|
for (i = 0; i < 5; ++i) {
|
||||||
ret = regmap_raw_read(ctl->dsp->regmap, reg, &bufp, sizeof(bufp));
|
ret = wm_coeff_read_ctrl(ctl, &coeff_v1, sizeof(coeff_v1));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (bufp)
|
if (coeff_v1.host_buf_ptr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
usleep_range(1000, 2000);
|
usleep_range(1000, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bufp) {
|
if (!coeff_v1.host_buf_ptr) {
|
||||||
adsp_err(ctl->dsp, "Failed to acquire host buffer\n");
|
adsp_err(ctl->dsp, "Failed to acquire host buffer\n");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -3898,7 +3893,7 @@ static int wm_adsp_buffer_parse_coeff(struct wm_coeff_ctl *ctl)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
buf->host_buf_mem_type = ctl->alg_region.type;
|
buf->host_buf_mem_type = ctl->alg_region.type;
|
||||||
buf->host_buf_ptr = be32_to_cpu(bufp);
|
buf->host_buf_ptr = be32_to_cpu(coeff_v1.host_buf_ptr);
|
||||||
|
|
||||||
ret = wm_adsp_buffer_populate(buf);
|
ret = wm_adsp_buffer_populate(buf);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -3913,11 +3908,6 @@ static int wm_adsp_buffer_parse_coeff(struct wm_coeff_ctl *ctl)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = regmap_raw_read(ctl->dsp->regmap, reg, &coeff_v1,
|
|
||||||
sizeof(coeff_v1));
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
version = be32_to_cpu(coeff_v1.versions) & HOST_BUF_COEFF_COMPAT_VER_MASK;
|
version = be32_to_cpu(coeff_v1.versions) & HOST_BUF_COEFF_COMPAT_VER_MASK;
|
||||||
version >>= HOST_BUF_COEFF_COMPAT_VER_SHIFT;
|
version >>= HOST_BUF_COEFF_COMPAT_VER_SHIFT;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user