video: tegra: add hdmi switch_dev for hotplug notifications
authorErik Gilling <konkers@android.com>
Mon, 18 Oct 2010 22:38:22 +0000 (15:38 -0700)
committerColin Cross <ccross@android.com>
Fri, 29 Oct 2010 00:53:51 +0000 (17:53 -0700)
Change-Id: I0454179633835d35367bc5c28513319e3aa6a069
Signed-off-by: Erik Gilling <konkers@android.com>
drivers/video/tegra/dc/hdmi.c

index f2179c3a785718d3c48230ed6ad4e5a0d7aa008c..acc3b36ea046977270708a227e1caf6981a9c94e 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/switch.h>
 #include <linux/workqueue.h>
 
 #include <mach/clk.h>
@@ -52,6 +53,8 @@ struct tegra_dc_hdmi_data {
 
        struct clk                      *disp1_clk;
        struct clk                      *disp2_clk;
+
+       struct switch_dev               hpd_switch;
 };
 
 const struct fb_videomode tegra_dc_hdmi_supported_modes[] = {
@@ -434,12 +437,12 @@ static bool tegra_dc_hdmi_detect(struct tegra_dc *dc)
        int err;
 
        if (!tegra_dc_hdmi_hpd(dc))
-               return false;
+               goto fail;
 
        err = tegra_edid_get_monspecs(hdmi->edid, &specs);
        if (err < 0) {
                dev_err(&dc->ndev->dev, "error reading edid\n");
-               return false;
+               goto fail;
        }
 
        /* monitors like to lie about these but they are still useful for
@@ -449,8 +452,13 @@ static bool tegra_dc_hdmi_detect(struct tegra_dc *dc)
        dc->out->v_size = specs.max_y * 1000;
 
        tegra_fb_update_monspecs(dc->fb, &specs, tegra_dc_hdmi_mode_filter);
+       switch_set_state(&hdmi->hpd_switch, 1);
        dev_info(&dc->ndev->dev, "display detected\n");
        return true;
+
+fail:
+       switch_set_state(&hdmi->hpd_switch, 0);
+       return false;
 }
 
 
@@ -562,6 +570,9 @@ static int tegra_dc_hdmi_init(struct tegra_dc *dc)
        hdmi->disp1_clk = disp1_clk;
        hdmi->disp2_clk = disp2_clk;
 
+       hdmi->hpd_switch.name = "hdmi";
+       switch_dev_register(&hdmi->hpd_switch);
+
        dc->out->depth = 24;
 
        tegra_dc_set_outdata(dc, hdmi);
@@ -592,6 +603,7 @@ static void tegra_dc_hdmi_destroy(struct tegra_dc *dc)
 
        free_irq(gpio_to_irq(dc->out->hotplug_gpio), dc);
        cancel_delayed_work_sync(&hdmi->work);
+       switch_dev_unregister(&hdmi->hpd_switch);
        iounmap(hdmi->base);
        release_resource(hdmi->base_res);
        clk_put(hdmi->clk);