From 63eb51a02807d1423d979558ac9b3a49a028b649 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Thu, 23 Feb 2012 23:25:11 +0100 Subject: [PATCH] spark: disable HDMI before switching mode in cVideo::SetVideoSystem this seems to greatly improve reliability - it looks like there is a locking problem somewhere in the framebuffer driver :-( --- libspark/video.cpp | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/libspark/video.cpp b/libspark/video.cpp index 32df61a..fa32ae4 100644 --- a/libspark/video.cpp +++ b/libspark/video.cpp @@ -30,10 +30,12 @@ #include #include +#include #include "video_lib.h" #define VIDEO_DEVICE "/dev/dvb/adapter0/video0" #include "lt_debug.h" #define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args) +#define lt_debug_c(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, NULL, args) #define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args) #define fop(cmd, args...) ({ \ @@ -96,6 +98,39 @@ static unsigned int proc_get_hex(const char *path) return ret; } +static int hdmi_out(bool enable) +{ + struct stmfbio_output_configuration out; + int ret = -1; + int fb = open("/dev/fb0", O_RDWR); + if (fb < 0) + { + lt_debug_c("%s: can't open /dev/fb/0 (%m)\n", __func__); + return -1; + } + out.outputid = STMFBIO_OUTPUTID_MAIN; + if (ioctl(fb, STMFBIO_GET_OUTPUT_CONFIG, &out) < 0) + { + lt_debug_c("%s: STMFBIO_GET_OUTPUT_CONFIG (%m)\n", __func__); + goto out; + } + out.caps = STMFBIO_OUTPUT_CAPS_HDMI_CONFIG; + out.activate = STMFBIO_ACTIVATE_IMMEDIATE; + out.analogue_config = 0; + if (enable) + out.hdmi_config &= ~STMFBIO_OUTPUT_HDMI_DISABLED; + else + out.hdmi_config |= STMFBIO_OUTPUT_HDMI_DISABLED; + + ret = ioctl(fb, STMFBIO_SET_OUTPUT_CONFIG, &out); + if (ret < 0) + _lt_debug(TRIPLE_DEBUG_VIDEO, NULL, "%s: STMFBIO_SET_OUTPUT_CONFIG (%m)\n", __func__); +out: + close(fb); + return ret; +} + + cVideo::cVideo(int, void *, void *) { lt_debug("%s\n", __FUNCTION__); @@ -232,9 +267,11 @@ int cVideo::SetVideoSystem(int video_system, bool remember) lt_info("%s: video_system (%d) > VIDEO_STD_MAX (%d)\n", video_system, VIDEO_STD_MAX); return -1; } - if (proc_put("/proc/stb/video/videomode", modes[video_system],strlen(modes[video_system])) < 0) - return -1; - return 0; + hdmi_out(false); + int ret = proc_put("/proc/stb/video/videomode", modes[video_system],strlen(modes[video_system])); + hdmi_out(true); + + return ret; } int cVideo::getPlayState(void)