diff options
Diffstat (limited to 'drivers/video/tegra/dc/dc.c')
-rw-r--r-- | drivers/video/tegra/dc/dc.c | 61 |
1 files changed, 56 insertions, 5 deletions
diff --git a/drivers/video/tegra/dc/dc.c b/drivers/video/tegra/dc/dc.c index 67fb904bbedf..935f18bc8cfd 100644 --- a/drivers/video/tegra/dc/dc.c +++ b/drivers/video/tegra/dc/dc.c @@ -33,6 +33,7 @@ #include <linux/debugfs.h> #include <linux/seq_file.h> #include <linux/backlight.h> +#include <linux/gpio.h> #include <video/tegrafb.h> #include <drm/drm_fixed.h> #ifdef CONFIG_SWITCH @@ -65,6 +66,20 @@ #endif static int no_vsync; +static struct fb_videomode tegra_dc_hdmi_fallback_mode = { + .refresh = 60, + .xres = 640, + .yres = 480, + .pixclock = KHZ2PICOS(25200), + .hsync_len = 96, /* h_sync_width */ + .vsync_len = 2, /* v_sync_width */ + .left_margin = 48, /* h_back_porch */ + .upper_margin = 33, /* v_back_porch */ + .right_margin = 16, /* h_front_porch */ + .lower_margin = 10, /* v_front_porch */ + .vmode = 0, + .sync = 0, +}; static void _tegra_dc_controller_disable(struct tegra_dc *dc); @@ -621,6 +636,20 @@ bool tegra_dc_get_connected(struct tegra_dc *dc) } EXPORT_SYMBOL(tegra_dc_get_connected); +bool tegra_dc_hpd(struct tegra_dc *dc) +{ + int sense; + int level; + + level = gpio_get_value(dc->out->hotplug_gpio); + + sense = dc->out->flags & TEGRA_DC_OUT_HOTPLUG_MASK; + + return (sense == TEGRA_DC_OUT_HOTPLUG_HIGH && level) || + (sense == TEGRA_DC_OUT_HOTPLUG_LOW && !level); +} +EXPORT_SYMBOL(tegra_dc_hpd); + static u32 blend_topwin(u32 flags) { if (flags & TEGRA_WIN_FLAG_BLEND_COVERAGE) @@ -2637,10 +2666,35 @@ static bool _tegra_dc_controller_reset_enable(struct tegra_dc *dc) } #endif +static int _tegra_dc_set_default_videomode(struct tegra_dc *dc) +{ + return tegra_dc_set_fb_mode(dc, &tegra_dc_hdmi_fallback_mode, 0); +} + static bool _tegra_dc_enable(struct tegra_dc *dc) { - if (dc->mode.pclk == 0) - return false; + if (dc->mode.pclk == 0) { + switch (dc->out->type) { + case TEGRA_DC_OUT_HDMI: + /* DC enable called but no videomode is loaded. + Check if HDMI is connected, then set fallback mdoe */ + if (tegra_dc_hpd(dc)) { + if (_tegra_dc_set_default_videomode(dc)) + return false; + } else + return false; + + break; + + /* Do nothing for other outputs for now */ + case TEGRA_DC_OUT_RGB: + + case TEGRA_DC_OUT_DSI: + + default: + return false; + } + } if (!dc->out) return false; @@ -2955,9 +3009,6 @@ static int tegra_dc_probe(struct nvhost_device *ndev, */ dc->emc_clk_rate = 0; - if (dc->pdata->flags & TEGRA_DC_FLAG_ENABLED) - dc->enabled = true; - mutex_init(&dc->lock); mutex_init(&dc->one_shot_lock); init_completion(&dc->frame_end_complete); |