Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+8 -24
+8 -23
sound/x86/intel_hdmi_audio.c
··· 1024 1024 dev_err(intelhaddata->dev, "Unable to clear UNDERRUN bits\n"); 1025 1025 } 1026 1026 1027 - /* Perform some reset procedure but only when need_reset is set; 1027 + /* Perform some reset procedure after stopping the stream; 1028 1028 * this is called from prepare or hw_free callbacks once after trigger STOP 1029 1029 * or underrun has been processed in order to settle down the h/w state. 1030 1030 */ 1031 - static void had_do_reset(struct snd_intelhad *intelhaddata) 1031 + static int had_pcm_sync_stop(struct snd_pcm_substream *substream) 1032 1032 { 1033 - if (!intelhaddata->need_reset || !intelhaddata->connected) 1034 - return; 1033 + struct snd_intelhad *intelhaddata = snd_pcm_substream_chip(substream); 1034 + 1035 + if (!intelhaddata->connected) 1036 + return 0; 1035 1037 1036 1038 /* Reset buffer pointers */ 1037 1039 had_reset_audio(intelhaddata); 1038 1040 wait_clear_underrun_bit(intelhaddata); 1039 - intelhaddata->need_reset = false; 1041 + return 0; 1040 1042 } 1041 1043 1042 1044 /* called from irq handler */ ··· 1052 1050 snd_pcm_stop_xrun(substream); 1053 1051 had_substream_put(intelhaddata); 1054 1052 } 1055 - intelhaddata->need_reset = true; 1056 1053 } 1057 1054 1058 1055 /* ··· 1143 1142 } 1144 1143 1145 1144 /* 1146 - * ALSA PCM hw_free callback 1147 - */ 1148 - static int had_pcm_hw_free(struct snd_pcm_substream *substream) 1149 - { 1150 - struct snd_intelhad *intelhaddata; 1151 - 1152 - intelhaddata = snd_pcm_substream_chip(substream); 1153 - had_do_reset(intelhaddata); 1154 - 1155 - return 0; 1156 - } 1157 - 1158 - /* 1159 1145 * ALSA PCM trigger callback 1160 1146 */ 1161 1147 static int had_pcm_trigger(struct snd_pcm_substream *substream, int cmd) ··· 1166 1178 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1167 1179 /* Disable Audio */ 1168 1180 had_enable_audio(intelhaddata, false); 1169 - intelhaddata->need_reset = true; 1170 1181 break; 1171 1182 1172 1183 default: ··· 1196 1209 (int)snd_pcm_lib_buffer_bytes(substream)); 1197 1210 dev_dbg(intelhaddata->dev, "rate=%d\n", runtime->rate); 1198 1211 dev_dbg(intelhaddata->dev, "channels=%d\n", runtime->channels); 1199 - 1200 - had_do_reset(intelhaddata); 1201 1212 1202 1213 /* Get N value in KHz */ 1203 1214 disp_samp_freq = intelhaddata->tmds_clock_speed; ··· 1272 1287 .open = had_pcm_open, 1273 1288 .close = had_pcm_close, 1274 1289 .hw_params = had_pcm_hw_params, 1275 - .hw_free = had_pcm_hw_free, 1276 1290 .prepare = had_pcm_prepare, 1277 1291 .trigger = had_pcm_trigger, 1292 + .sync_stop = had_pcm_sync_stop, 1278 1293 .pointer = had_pcm_pointer, 1279 1294 .mmap = had_pcm_mmap, 1280 1295 };
-1
sound/x86/intel_hdmi_audio.h
··· 127 127 union aud_cfg aud_config; /* AUD_CONFIG reg value cache */ 128 128 struct work_struct hdmi_audio_wq; 129 129 struct mutex mutex; /* for protecting chmap and eld */ 130 - bool need_reset; 131 130 struct snd_jack *jack; 132 131 }; 133 132