diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-07-12 11:19:15 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-07-12 13:13:26 +0200 |
commit | 82a60352c2d3ef06815d4ddfd85d5506b5758804 (patch) | |
tree | 4f0750e10a68c4ab411c355394ed8f7f0d579ae0 | |
parent | 3b0f7eeff697b04571a5c6329b7e8fdf8f8c85d9 (diff) |
ALSA: x86: simplify with sync_stop PCM ops
The reset procedure in had_do_reset() is exactly for the recently
introduced PCM sync_stop ops. Replace the call with the new ops and
clean up the unnecessary code and flags.
Link: https://lore.kernel.org/r/20210712091915.28067-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/x86/intel_hdmi_audio.c | 31 | ||||
-rw-r--r-- | sound/x86/intel_hdmi_audio.h | 1 |
2 files changed, 8 insertions, 24 deletions
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c index a34d7d9c2a57..6d87c099d997 100644 --- a/sound/x86/intel_hdmi_audio.c +++ b/sound/x86/intel_hdmi_audio.c @@ -1024,19 +1024,21 @@ static void wait_clear_underrun_bit(struct snd_intelhad *intelhaddata) dev_err(intelhaddata->dev, "Unable to clear UNDERRUN bits\n"); } -/* Perform some reset procedure but only when need_reset is set; +/* Perform some reset procedure after stopping the stream; * this is called from prepare or hw_free callbacks once after trigger STOP * or underrun has been processed in order to settle down the h/w state. */ -static void had_do_reset(struct snd_intelhad *intelhaddata) +static int had_pcm_sync_stop(struct snd_pcm_substream *substream) { - if (!intelhaddata->need_reset || !intelhaddata->connected) - return; + struct snd_intelhad *intelhaddata = snd_pcm_substream_chip(substream); + + if (!intelhaddata->connected) + return 0; /* Reset buffer pointers */ had_reset_audio(intelhaddata); wait_clear_underrun_bit(intelhaddata); - intelhaddata->need_reset = false; + return 0; } /* called from irq handler */ @@ -1050,7 +1052,6 @@ static void had_process_buffer_underrun(struct snd_intelhad *intelhaddata) snd_pcm_stop_xrun(substream); had_substream_put(intelhaddata); } - intelhaddata->need_reset = true; } /* @@ -1142,19 +1143,6 @@ static int had_pcm_hw_params(struct snd_pcm_substream *substream, } /* - * ALSA PCM hw_free callback - */ -static int had_pcm_hw_free(struct snd_pcm_substream *substream) -{ - struct snd_intelhad *intelhaddata; - - intelhaddata = snd_pcm_substream_chip(substream); - had_do_reset(intelhaddata); - - return 0; -} - -/* * ALSA PCM trigger callback */ static int had_pcm_trigger(struct snd_pcm_substream *substream, int cmd) @@ -1178,7 +1166,6 @@ static int had_pcm_trigger(struct snd_pcm_substream *substream, int cmd) case SNDRV_PCM_TRIGGER_PAUSE_PUSH: /* Disable Audio */ had_enable_audio(intelhaddata, false); - intelhaddata->need_reset = true; break; default: @@ -1210,8 +1197,6 @@ static int had_pcm_prepare(struct snd_pcm_substream *substream) dev_dbg(intelhaddata->dev, "rate=%d\n", runtime->rate); dev_dbg(intelhaddata->dev, "channels=%d\n", runtime->channels); - had_do_reset(intelhaddata); - /* Get N value in KHz */ disp_samp_freq = intelhaddata->tmds_clock_speed; @@ -1287,9 +1272,9 @@ static const struct snd_pcm_ops had_pcm_ops = { .open = had_pcm_open, .close = had_pcm_close, .hw_params = had_pcm_hw_params, - .hw_free = had_pcm_hw_free, .prepare = had_pcm_prepare, .trigger = had_pcm_trigger, + .sync_stop = had_pcm_sync_stop, .pointer = had_pcm_pointer, .mmap = had_pcm_mmap, }; diff --git a/sound/x86/intel_hdmi_audio.h b/sound/x86/intel_hdmi_audio.h index bb3853195922..7ce8c2a7d714 100644 --- a/sound/x86/intel_hdmi_audio.h +++ b/sound/x86/intel_hdmi_audio.h @@ -127,7 +127,6 @@ struct snd_intelhad { union aud_cfg aud_config; /* AUD_CONFIG reg value cache */ struct work_struct hdmi_audio_wq; struct mutex mutex; /* for protecting chmap and eld */ - bool need_reset; struct snd_jack *jack; }; |