Skip to content

Commit

Permalink
ALSA: hda: cs35l41: Check CSPL state after loading firmware
Browse files Browse the repository at this point in the history
CSPL firmware should be in RUNNING or PAUSED state after loading.
If not, the firmware has not been loaded correctly, and we can unload
it and pass the error up.

Signed-off-by: Stefan Binding <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
Stefan Binding authored and tiwai committed Oct 26, 2023
1 parent 33790d1 commit a51d8ba
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sound/pci/hda/cs35l41_hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,7 @@ static int cs35l41_runtime_resume(struct device *dev)

static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41)
{
unsigned int fw_status;
__be32 halo_sts;
int ret;

Expand Down Expand Up @@ -1027,6 +1028,23 @@ static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41)
goto clean_dsp;
}

ret = regmap_read(cs35l41->regmap, CS35L41_DSP_MBOX_2, &fw_status);
if (ret < 0) {
dev_err(cs35l41->dev,
"Failed to read firmware status: %d\n", ret);
goto clean_dsp;
}

switch (fw_status) {
case CSPL_MBOX_STS_RUNNING:
case CSPL_MBOX_STS_PAUSED:
break;
default:
dev_err(cs35l41->dev, "Firmware status is invalid: %u\n",
fw_status);
goto clean_dsp;
}

ret = cs35l41_set_cspl_mbox_cmd(cs35l41->dev, cs35l41->regmap, CSPL_MBOX_CMD_PAUSE);
if (ret) {
dev_err(cs35l41->dev, "Error waiting for DSP to pause: %u\n", ret);
Expand Down

0 comments on commit a51d8ba

Please sign in to comment.