plugged = atomic_read(&ctx->plugged);
- if (hdmi_reg_read(ctx, HDMI_MODE_SEL) & HDMI_DVI_MODE_EN) {
- /* If HDMI operates in DVI mode,
- * for audio purposes it is the same as nothing plugged.
- * Unfortunately, hotplug interrupt is received multiple times,
- * and HDMI_DVI_MODE_EN is set only in the last one.
- * So, we have already reported that HDMI audio was plugged.
- * So, update ctx, report now that it was unplugged and return.
- */
- atomic_set(&ctx->plugged, 0);
- if (plugged && ctx->plugin.jack_cb)
- ctx->plugin.jack_cb(false);
- return;
- }
-
if (plugged) {
+ if (hdmi_reg_read(ctx, HDMI_MODE_SEL) & HDMI_DVI_MODE_EN) {
+ /* If HDMI operates in DVI mode,
+ * for audio purposes it is the same as nothing plugged.
+ * So, change the "ctx->plugged" state to unplugged.
+ * Also, simulate unplugging for jack_cb, as this
+ * takes care of swapping HDMI with DVI when suspended.
+ */
+ atomic_set(&ctx->plugged, 0);
+ if (ctx->plugin.jack_cb)
+ ctx->plugin.jack_cb(false);
+ return;
+ }
+
hdmi_audio_control(ctx, false);
hdmi_conf_init(ctx);
hdmi_audio_init(ctx);