CHROMIUM: ALSA: ASoC: Daisy - add HDMI jack.
authorDylan Reid <dgreid@chromium.org>
Tue, 2 Oct 2012 20:51:53 +0000 (13:51 -0700)
committerGerrit <chrome-bot@google.com>
Wed, 3 Oct 2012 14:33:29 +0000 (07:33 -0700)
Add a jack to report HDMI connected status.  This extends the plugin
interface, allowing the machine driver to be notified of hotplug events.
This Jack allows Speakers to be muted when HDMI audio is played.

BUG=chrome-os-partner:14435
TEST=use evtest and watch HDMI jack change.

Change-Id: If06f6fb98652ab1539fccd0da31444ea4dd8986c
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34445

sound/soc/samsung/codec_plugin.h
sound/soc/samsung/daisy_max98095.c
sound/soc/samsung/hdmi_audio.c

index 59d9483..82cb286 100644 (file)
@@ -28,6 +28,7 @@ struct audio_plugin_ops {
 struct audio_codec_plugin {
        struct device *dev;
        struct audio_plugin_ops ops;
+       int (*jack_cb)(int plugged);
 };
 
 #endif /* __SND_SOC_SAMSUNG_PLUGIN_H */
index 57efafb..d6a244d 100644 (file)
@@ -313,6 +313,8 @@ static const struct snd_soc_dapm_widget daisy_dapm_widgets[] = {
        SND_SOC_DAPM_HP("Headphone Jack", NULL),
 };
 
+static struct snd_soc_jack daisy_hdmi_jack;
+
 static int get_hdmi(struct snd_kcontrol *kcontrol,
                                 struct snd_ctl_elem_value *ucontrol)
 {
@@ -368,6 +370,7 @@ static int daisy_init(struct snd_soc_pcm_runtime *rtd)
        struct snd_soc_dapm_context *dapm = &codec->dapm;
        struct snd_soc_card *card = codec->card;
        struct device_node *dn = card->dev->of_node;
+       struct audio_codec_plugin *plugin;
 
        if (dn) {
                enum of_gpio_flags flags;
@@ -401,6 +404,11 @@ static int daisy_init(struct snd_soc_pcm_runtime *rtd)
                                       &daisy_hp_jack_gpio);
        }
 
+       plugin = daisy_dapm_controls[0].private_value;
+       if (plugin)
+               snd_soc_jack_new(codec, "HDMI Jack",
+                                SND_JACK_AVOUT, &daisy_hdmi_jack);
+
        /* Microphone BIAS is needed to power the analog mic.
         * MICBIAS2 is connected to analog mic (MIC3, which is in turn
         * connected to MIC2 via 'External MIC') on Daisy.
@@ -428,6 +436,14 @@ static int daisy_resume_post(struct snd_soc_card *card)
                snd_soc_jack_gpio_detect(&daisy_hp_jack_gpio);
 }
 
+static int daisy_hdmi_jack_report(int plugged)
+{
+       snd_soc_jack_report(&daisy_hdmi_jack,
+                           plugged ? SND_JACK_AVOUT : 0,
+                           SND_JACK_AVOUT);
+       return 0;
+}
+
 static struct snd_soc_dai_link daisy_dai[] = {
        { /* Primary DAI i/f */
                .name = "MAX98095 RX",
@@ -479,6 +495,9 @@ static int plugin_init(struct audio_codec_plugin **pplugin)
                return -EFAULT;
        else
                *pplugin = plugin;
+
+       plugin->jack_cb = daisy_hdmi_jack_report;
+
        return 0;
 }
 
index 9c34aeb..9b2264a 100644 (file)
@@ -437,17 +437,22 @@ static void hdmi_audio_hotplug_func(struct work_struct *work)
 {
        struct hdmi_audio_context *ctx = container_of(work,
                struct hdmi_audio_context, hotplug_work.work);
+       int plugged;
 
        snd_printdd("[%d] %s plugged %d\n",
                        __LINE__, __func__, atomic_read(&ctx->plugged));
 
-       if (atomic_read(&ctx->plugged)) {
+       plugged = atomic_read(&ctx->plugged);
+       if (plugged) {
                hdmi_audio_control(ctx, false);
                hdmi_conf_init(ctx);
                hdmi_audio_init(ctx);
                if (ctx->enabled)
                        hdmi_audio_control(ctx, true);
        }
+
+       if (ctx->plugin.jack_cb)
+               ctx->plugin.jack_cb(plugged);
 }
 
 static irqreturn_t hdmi_audio_irq_handler(int irq, void *arg)