Commit b9bacf27 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: x86: Implement jack control

This patch implements a jack interface for notifying HDMI/DP
connection.  PA listens to this, so it can handle the monitor
connection more gracefully.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 9f1bc2c4
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/initval.h> #include <sound/initval.h>
#include <sound/control.h> #include <sound/control.h>
#include <sound/jack.h>
#include <drm/drm_edid.h> #include <drm/drm_edid.h>
#include <drm/intel_lpe_audio.h> #include <drm/intel_lpe_audio.h>
#include "intel_hdmi_audio.h" #include "intel_hdmi_audio.h"
...@@ -1382,6 +1383,8 @@ static void had_process_hot_plug(struct snd_intelhad *intelhaddata) ...@@ -1382,6 +1383,8 @@ static void had_process_hot_plug(struct snd_intelhad *intelhaddata)
} }
had_build_channel_allocation_map(intelhaddata); had_build_channel_allocation_map(intelhaddata);
snd_jack_report(intelhaddata->jack, SND_JACK_AVOUT);
} }
/* process hot unplug, called from wq with mutex locked */ /* process hot unplug, called from wq with mutex locked */
...@@ -1414,6 +1417,7 @@ static void had_process_hot_unplug(struct snd_intelhad *intelhaddata) ...@@ -1414,6 +1417,7 @@ static void had_process_hot_unplug(struct snd_intelhad *intelhaddata)
snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
out: out:
snd_jack_report(intelhaddata->jack, 0);
if (substream) if (substream)
had_substream_put(intelhaddata); had_substream_put(intelhaddata);
kfree(intelhaddata->chmap->chmap); kfree(intelhaddata->chmap->chmap);
...@@ -1608,6 +1612,21 @@ static void had_audio_wq(struct work_struct *work) ...@@ -1608,6 +1612,21 @@ static void had_audio_wq(struct work_struct *work)
pm_runtime_put(ctx->dev); pm_runtime_put(ctx->dev);
} }
/*
* Jack interface
*/
static int had_create_jack(struct snd_intelhad *ctx)
{
int err;
err = snd_jack_new(ctx->card, "HDMI/DP", SND_JACK_AVOUT, &ctx->jack,
true, false);
if (err < 0)
return err;
ctx->jack->private_data = ctx;
return 0;
}
/* /*
* PM callbacks * PM callbacks
*/ */
...@@ -1780,6 +1799,10 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev) ...@@ -1780,6 +1799,10 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
if (ret < 0) if (ret < 0)
goto err; goto err;
ret = had_create_jack(ctx);
if (ret < 0)
goto err;
ret = snd_card_register(card); ret = snd_card_register(card);
if (ret) if (ret)
goto err; goto err;
......
...@@ -130,6 +130,7 @@ struct snd_intelhad { ...@@ -130,6 +130,7 @@ struct snd_intelhad {
struct work_struct hdmi_audio_wq; struct work_struct hdmi_audio_wq;
struct mutex mutex; /* for protecting chmap and eld */ struct mutex mutex; /* for protecting chmap and eld */
bool need_reset; bool need_reset;
struct snd_jack *jack;
}; };
#endif /* _INTEL_HDMI_AUDIO_ */ #endif /* _INTEL_HDMI_AUDIO_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment