xbmc: update imx6 patches, move to package 'xbmc'

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2014-08-10 02:51:52 +02:00
parent 4e82b862d9
commit 69e588df7a
6 changed files with 2945 additions and 13213 deletions

View File

@ -0,0 +1,483 @@
From 5f58f7153633ba7bc803fe40580d361dbae96592 Mon Sep 17 00:00:00 2001
From: "Chris \"Koying\" Browet" <cbro@semperpax.com>
Date: Thu, 7 Aug 2014 13:51:15 +0200
Subject: [PATCH 2/4] ADD: [imx] native framebuffer support
---
configure.in | 9 +
xbmc/windowing/egl/EGLNativeTypeIMX.cpp | 321 ++++++++++++++++++++++++++++++++
xbmc/windowing/egl/EGLNativeTypeIMX.h | 60 ++++++
xbmc/windowing/egl/EGLWrapper.cpp | 11 +-
xbmc/windowing/egl/Makefile.in | 4 +
5 files changed, 402 insertions(+), 3 deletions(-)
create mode 100644 xbmc/windowing/egl/EGLNativeTypeIMX.cpp
create mode 100644 xbmc/windowing/egl/EGLNativeTypeIMX.h
diff --git a/configure.in b/configure.in
index c8a9ce2..a505582 100644
--- a/configure.in
+++ b/configure.in
@@ -985,6 +985,15 @@ else
AC_MSG_RESULT($wayland_disabled)
fi
+# i.MX6
+AC_MSG_CHECKING([for i.MX framebuffer support])
+AC_CHECK_HEADER([linux/mxcfb.h], have_imxfb=yes,have_imxfb=no)
+AC_MSG_RESULT($have_imxfb)
+if test "x$have_imxfb" = "xyes"; then
+ AC_DEFINE([HAS_IMXFB], [1], [Whether i.MX framebuffer support is enabled.])
+ AC_SUBST([USE_IMXFB], 1)
+fi
+
# Checks for platforms libraries.
if test "$use_gles" = "yes"; then
use_gl="no"
diff --git a/xbmc/windowing/egl/EGLNativeTypeIMX.cpp b/xbmc/windowing/egl/EGLNativeTypeIMX.cpp
new file mode 100644
index 0000000..3dc64a3
--- /dev/null
+++ b/xbmc/windowing/egl/EGLNativeTypeIMX.cpp
@@ -0,0 +1,321 @@
+/*
+ * Copyright (C) 2011-2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <linux/mxcfb.h>
+#include "system.h"
+#include <EGL/egl.h>
+
+#include "EGLNativeTypeIMX.h"
+#include <math.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include "utils/log.h"
+#include "utils/RegExp.h"
+#include "utils/StringUtils.h"
+#include "utils/Environment.h"
+#include "guilib/gui3d.h"
+#include "windowing/WindowingFactory.h"
+#include "cores/AudioEngine/AEFactory.h"
+#include <fstream>
+
+CEGLNativeTypeIMX::CEGLNativeTypeIMX()
+ : m_display(NULL)
+ , m_window(NULL)
+{
+}
+
+CEGLNativeTypeIMX::~CEGLNativeTypeIMX()
+{
+}
+
+bool CEGLNativeTypeIMX::CheckCompatibility()
+{
+ std::ifstream file("/sys/class/graphics/fb0/fsl_disp_dev_property");
+ return file;
+}
+
+void CEGLNativeTypeIMX::Initialize()
+{
+ int fd;
+
+ fd = open("/dev/fb0",O_RDWR);
+ if (fd < 0)
+ {
+ CLog::Log(LOGERROR, "%s - Error while opening /dev/fb0.\n", __FUNCTION__);
+ return;
+ }
+
+ // Unblank the fb
+ if (ioctl(fd, FBIOBLANK, 0) < 0)
+ {
+ CLog::Log(LOGERROR, "%s - Error while unblanking fb0.\n", __FUNCTION__);
+ }
+
+ close(fd);
+
+ // Check if we can change the framebuffer resolution
+ fd = open("/sys/class/graphics/fb0/mode", O_RDWR);
+ if (fd >= 0)
+ {
+ CLog::Log(LOGNOTICE, "%s - graphics sysfs is writable", __FUNCTION__);
+ m_readonly = false;
+ }
+ else
+ {
+ CLog::Log(LOGNOTICE, "%s - graphics sysfs is read-only", __FUNCTION__);
+ m_readonly = true;
+ }
+ close(fd);
+
+ return;
+}
+
+void CEGLNativeTypeIMX::Destroy()
+{
+ struct fb_fix_screeninfo fixed_info;
+ void *fb_buffer;
+ int fd;
+
+ fd = open("/dev/fb0",O_RDWR);
+ if (fd < 0)
+ {
+ CLog::Log(LOGERROR, "%s - Error while opening /dev/fb0.\n", __FUNCTION__);
+ return;
+ }
+
+ ioctl( fd, FBIOGET_FSCREENINFO, &fixed_info);
+ // Black fb0
+ fb_buffer = mmap(NULL, fixed_info.smem_len, PROT_WRITE, MAP_SHARED, fd, 0);
+ if (fb_buffer == MAP_FAILED)
+ {
+ CLog::Log(LOGERROR, "%s - fb mmap failed %s.\n", __FUNCTION__, strerror(errno));
+ }
+ else
+ {
+ memset(fb_buffer, 0x0, fixed_info.smem_len);
+ munmap(fb_buffer, fixed_info.smem_len);
+ }
+
+ close(fd);
+
+ return;
+}
+
+bool CEGLNativeTypeIMX::CreateNativeDisplay()
+{
+ // Force double-buffering
+ CEnvironment::setenv("FB_MULTI_BUFFER", "2", 0);
+
+ // EGL will be rendered on fb0
+ m_display = fbGetDisplayByIndex(0);
+ m_nativeDisplay = &m_display;
+ return true;
+}
+
+bool CEGLNativeTypeIMX::CreateNativeWindow()
+{
+ m_window = fbCreateWindow(m_display, 0, 0, 0, 0);
+ m_nativeWindow = &m_window;
+ return true;
+}
+
+bool CEGLNativeTypeIMX::GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const
+{
+ if (!nativeDisplay)
+ return false;
+ if (!m_nativeDisplay)
+ return false;
+ *nativeDisplay = (XBNativeDisplayType*)m_nativeDisplay;
+ return true;
+}
+
+bool CEGLNativeTypeIMX::GetNativeWindow(XBNativeWindowType **nativeWindow) const
+{
+ if (!nativeWindow)
+ return false;
+ if (!m_nativeWindow || !m_window)
+ return false;
+ *nativeWindow = (XBNativeWindowType*)m_nativeWindow;
+ return true;
+}
+
+bool CEGLNativeTypeIMX::DestroyNativeDisplay()
+{
+ if (m_display)
+ fbDestroyDisplay(m_display);
+ m_display = NULL;
+ return true;
+}
+
+bool CEGLNativeTypeIMX::DestroyNativeWindow()
+{
+ if (m_window)
+ fbDestroyWindow(m_window);
+ m_window = NULL;
+ return true;
+}
+
+bool CEGLNativeTypeIMX::GetNativeResolution(RESOLUTION_INFO *res) const
+{
+ std::string mode;
+ get_sysfs_str("/sys/class/graphics/fb0/mode", mode);
+ return ModeToResolution(mode, res);
+}
+
+bool CEGLNativeTypeIMX::SetNativeResolution(const RESOLUTION_INFO &res)
+{
+ if (m_readonly)
+ return false;
+
+ std::string mode;
+ get_sysfs_str("/sys/class/graphics/fb0/mode", mode);
+ if (res.strId == mode)
+ return false;
+
+ DestroyNativeWindow();
+ DestroyNativeDisplay();
+
+ set_sysfs_str("/sys/class/graphics/fb0/mode", res.strId);
+
+ CreateNativeDisplay();
+
+ CLog::Log(LOGDEBUG, "%s: %s",__FUNCTION__, res.strId.c_str());
+
+ // Reset AE
+ CAEFactory::DeviceChange();
+
+ return true;
+}
+
+bool CEGLNativeTypeIMX::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions)
+{
+ if (m_readonly)
+ return false;
+
+ std::string valstr;
+ get_sysfs_str("/sys/class/graphics/fb0/modes", valstr);
+ std::vector<CStdString> probe_str;
+ StringUtils::SplitString(valstr, "\n", probe_str);
+
+ resolutions.clear();
+ RESOLUTION_INFO res;
+ for (size_t i = 0; i < probe_str.size(); i++)
+ {
+ if(!StringUtils::StartsWith(probe_str[i], "S:"))
+ continue;
+ if(ModeToResolution(probe_str[i], &res))
+ resolutions.push_back(res);
+ }
+ return resolutions.size() > 0;
+}
+
+bool CEGLNativeTypeIMX::GetPreferredResolution(RESOLUTION_INFO *res) const
+{
+ return GetNativeResolution(res);
+}
+
+bool CEGLNativeTypeIMX::ShowWindow(bool show)
+{
+ // Force vsync by default
+ eglSwapInterval(g_Windowing.GetEGLDisplay(), 1);
+ EGLint result = eglGetError();
+ if(result != EGL_SUCCESS)
+ CLog::Log(LOGERROR, "EGL error in %s: %x",__FUNCTION__, result);
+
+ return false;
+}
+
+int CEGLNativeTypeIMX::get_sysfs_str(std::string path, std::string& valstr) const
+{
+ int len;
+ char buf[256] = {0};
+
+ int fd = open(path.c_str(), O_RDONLY);
+ if (fd >= 0)
+ {
+ while ((len = read(fd, buf, 255)) > 0)
+ valstr.append(buf, len);
+ close(fd);
+ }
+ else
+ {
+ CLog::Log(LOGERROR, "%s: error reading %s",__FUNCTION__, path.c_str());
+ valstr = "fail";
+ return -1;
+ }
+ return 0;
+}
+
+int CEGLNativeTypeIMX::set_sysfs_str(std::string path, std::string val) const
+{
+ int fd = open(path.c_str(), O_WRONLY);
+ if (fd >= 0)
+ {
+ val += '\n';
+ write(fd, val.c_str(), val.size());
+ close(fd);
+ return 0;
+ }
+ CLog::Log(LOGERROR, "%s: error writing %s",__FUNCTION__, path.c_str());
+ return -1;
+}
+
+bool CEGLNativeTypeIMX::ModeToResolution(std::string mode, RESOLUTION_INFO *res) const
+{
+ if (!res)
+ return false;
+
+ res->iWidth = 0;
+ res->iHeight= 0;
+
+ if(mode.empty())
+ return false;
+
+ std::string fromMode = StringUtils::Mid(mode, 2);
+ StringUtils::Trim(fromMode);
+
+ CRegExp split(true);
+ split.RegComp("([0-9]+)x([0-9]+)([pi])-([0-9]+)");
+ if (split.RegFind(fromMode) < 0)
+ return false;
+
+ int w = atoi(split.GetMatch(1).c_str());
+ int h = atoi(split.GetMatch(2).c_str());
+ std::string p = split.GetMatch(3);
+ int r = atoi(split.GetMatch(4).c_str());
+
+ res->iWidth = w;
+ res->iHeight= h;
+ res->iScreenWidth = w;
+ res->iScreenHeight= h;
+ res->fRefreshRate = r;
+ res->dwFlags = p[0] == 'p' ? D3DPRESENTFLAG_PROGRESSIVE : D3DPRESENTFLAG_INTERLACED;
+
+ res->iScreen = 0;
+ res->bFullScreen = true;
+ res->iSubtitles = (int)(0.965 * res->iHeight);
+ res->fPixelRatio = 1.0f;
+ res->strMode = StringUtils::Format("%dx%d @ %.2f%s - Full Screen", res->iScreenWidth, res->iScreenHeight, res->fRefreshRate,
+ res->dwFlags & D3DPRESENTFLAG_INTERLACED ? "i" : "");
+ res->strId = mode;
+
+ return res->iWidth > 0 && res->iHeight> 0;
+}
+
diff --git a/xbmc/windowing/egl/EGLNativeTypeIMX.h b/xbmc/windowing/egl/EGLNativeTypeIMX.h
new file mode 100644
index 0000000..df7b3b7
--- /dev/null
+++ b/xbmc/windowing/egl/EGLNativeTypeIMX.h
@@ -0,0 +1,60 @@
+#pragma once
+
+/*
+ * Copyright (C) 2011-2013 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#include <linux/fb.h>
+#include "EGLNativeType.h"
+#include "EGL/eglvivante.h"
+
+class CEGLNativeTypeIMX : public CEGLNativeType
+{
+public:
+ CEGLNativeTypeIMX();
+ virtual ~CEGLNativeTypeIMX();
+ virtual std::string GetNativeName() const { return "iMX"; }
+ virtual bool CheckCompatibility();
+ virtual void Initialize();
+ virtual void Destroy();
+ virtual int GetQuirks() { return EGL_QUIRK_NONE; }
+
+ virtual bool CreateNativeDisplay();
+ virtual bool CreateNativeWindow();
+ virtual bool GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const;
+ virtual bool GetNativeWindow(XBNativeWindowType **nativeWindow) const;
+
+ virtual bool DestroyNativeWindow();
+ virtual bool DestroyNativeDisplay();
+
+ virtual bool GetNativeResolution(RESOLUTION_INFO *res) const;
+ virtual bool SetNativeResolution(const RESOLUTION_INFO &res);
+ virtual bool ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions);
+ virtual bool GetPreferredResolution(RESOLUTION_INFO *res) const;
+
+ virtual bool ShowWindow(bool show);
+
+protected:
+ bool m_readonly;
+ int get_sysfs_str(std::string path, std::string& valstr) const;
+ int set_sysfs_str(std::string path, std::string val) const;
+ bool ModeToResolution(std::string mode, RESOLUTION_INFO *res) const;
+
+ EGLNativeDisplayType m_display;
+ EGLNativeWindowType m_window;
+};
diff --git a/xbmc/windowing/egl/EGLWrapper.cpp b/xbmc/windowing/egl/EGLWrapper.cpp
index 045cdfc..4d74be5 100644
--- a/xbmc/windowing/egl/EGLWrapper.cpp
+++ b/xbmc/windowing/egl/EGLWrapper.cpp
@@ -17,16 +17,17 @@
* <http://www.gnu.org/licenses/>.
*
*/
-
#include "system.h"
#ifdef HAS_EGL
-
#include "utils/log.h"
#include "EGLNativeTypeAndroid.h"
#include "EGLNativeTypeAmlogic.h"
#include "EGLNativeTypeRaspberryPI.h"
#include "EGLNativeTypeWayland.h"
+#ifdef HAS_IMXVPU
+#include "EGLNativeTypeIMX.h"
+#endif
#include "EGLWrapper.h"
#define CheckError() m_result = eglGetError(); if(m_result != EGL_SUCCESS) CLog::Log(LOGERROR, "EGL error in %s: %x",__FUNCTION__, m_result);
@@ -83,7 +84,11 @@ bool CEGLWrapper::Initialize(const std::string &implementation)
if ((nativeGuess = CreateEGLNativeType<CEGLNativeTypeWayland>(implementation)) ||
(nativeGuess = CreateEGLNativeType<CEGLNativeTypeAndroid>(implementation)) ||
(nativeGuess = CreateEGLNativeType<CEGLNativeTypeAmlogic>(implementation)) ||
- (nativeGuess = CreateEGLNativeType<CEGLNativeTypeRaspberryPI>(implementation)))
+ (nativeGuess = CreateEGLNativeType<CEGLNativeTypeRaspberryPI>(implementation))
+#ifdef HAS_IMXFB
+ || (nativeGuess = CreateEGLNativeType<CEGLNativeTypeIMX>(implementation))
+#endif
+ )
{
m_nativeTypes = nativeGuess;
diff --git a/xbmc/windowing/egl/Makefile.in b/xbmc/windowing/egl/Makefile.in
index f800b7f..ec84c1d 100644
--- a/xbmc/windowing/egl/Makefile.in
+++ b/xbmc/windowing/egl/Makefile.in
@@ -24,6 +24,10 @@ SRCS+= wayland/Callback.cpp \
wayland/XBMCSurface.cpp
endif
+ifeq (@USE_IMXFB@,1)
+SRCS+= EGLNativeTypeIMX.cpp
+endif
+
LIB = windowing_egl.a
include ../../../Makefile.include
--
1.9.3

View File

@ -0,0 +1,27 @@
From 01c1e0d01e418f2b07828c1eaaaa1a6ab5e82a4e Mon Sep 17 00:00:00 2001
From: Stephan Raue <stephan@openelec.tv>
Date: Sun, 10 Aug 2014 01:48:04 +0200
Subject: [PATCH 3/4] [imx] squashme: fix build after
https://github.com/xbmc-imx6/xbmc/commit/74f3f02
---
xbmc/windowing/egl/EGLNativeTypeIMX.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/xbmc/windowing/egl/EGLNativeTypeIMX.cpp b/xbmc/windowing/egl/EGLNativeTypeIMX.cpp
index 3dc64a3..b1f2783 100644
--- a/xbmc/windowing/egl/EGLNativeTypeIMX.cpp
+++ b/xbmc/windowing/egl/EGLNativeTypeIMX.cpp
@@ -211,8 +211,7 @@ bool CEGLNativeTypeIMX::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutio
std::string valstr;
get_sysfs_str("/sys/class/graphics/fb0/modes", valstr);
- std::vector<CStdString> probe_str;
- StringUtils::SplitString(valstr, "\n", probe_str);
+ std::vector<std::string> probe_str = StringUtils::Split(valstr, "\n");
resolutions.clear();
RESOLUTION_INFO res;
--
1.9.3

View File

@ -0,0 +1,69 @@
From e062d1adba00d0503a46937eb0957ba6405af36b Mon Sep 17 00:00:00 2001
From: wolfgar <stephan.rafin@laposte.net>
Date: Fri, 31 Jan 2014 14:43:24 +0100
Subject: [PATCH 4/4] ADD: [imx] add Freescale imx audio support
---
xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
index 8dee4bc..871ecc0 100644
--- a/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
+++ b/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
@@ -1079,12 +1079,17 @@ void CAESinkALSA::EnumerateDevicesEx(AEDeviceInfoList &list, bool force)
snd_config_t *config;
snd_config_copy(&config, snd_config);
+#ifndef HAS_IMXFB
/* Always enumerate the default device.
* Note: If "default" is a stereo device, EnumerateDevice()
* will automatically add "@" instead to enable surroundXX mangling.
* We don't want to do that if "default" can handle multichannel
* itself (e.g. in case of a pulseaudio server). */
+
+ /* For IMX6, we do not enurate default device as it will be grabbed
+ * as one of the sysdefault devices... */
EnumerateDevice(list, "default", "", config);
+#endif
void **hints;
@@ -1136,7 +1141,10 @@ void CAESinkALSA::EnumerateDevicesEx(AEDeviceInfoList &list, bool force)
* "plughw", "dsnoop"). */
else if (baseName != "default"
+#ifndef HAS_IMXFB
+ /* For wandboard all devices are prefixed by sysdefault so do not ignore them */
&& baseName != "sysdefault"
+#endif
&& baseName != "surround40"
&& baseName != "surround41"
&& baseName != "surround50"
@@ -1245,6 +1253,23 @@ void CAESinkALSA::EnumerateDevicesEx(AEDeviceInfoList &list, bool force)
AEDeviceType CAESinkALSA::AEDeviceTypeFromName(const std::string &name)
{
+#ifdef HAS_IMXFB
+ std::size_t found;
+
+ /* Hack : Check for specific wandboard sound device names */
+ found = name.find("imxspdif");
+ if (found!=std::string::npos)
+ return AE_DEVTYPE_IEC958;
+
+ found = name.find("imxhdmisoc");
+ if (found!=std::string::npos)
+ return AE_DEVTYPE_HDMI;
+
+ found = name.find("sgtl5000audio");
+ if (found!=std::string::npos)
+ return AE_DEVTYPE_PCM;
+#endif
+
if (name.substr(0, 4) == "hdmi")
return AE_DEVTYPE_HDMI;
else if (name.substr(0, 6) == "iec958" || name.substr(0, 5) == "spdif")
--
1.9.3

View File

@ -1,13 +0,0 @@
diff -Naur xbmc-master-14-dae6f76/xbmc/windowing/egl/EGLNativeTypeIMX.cpp xbmc-master-14-dae6f76.patch/xbmc/windowing/egl/EGLNativeTypeIMX.cpp
--- xbmc-master-14-dae6f76/xbmc/windowing/egl/EGLNativeTypeIMX.cpp 2014-07-11 04:38:24.091279024 +0200
+++ xbmc-master-14-dae6f76.patch/xbmc/windowing/egl/EGLNativeTypeIMX.cpp 2014-07-11 04:48:46.630581643 +0200
@@ -211,8 +211,7 @@
std::string valstr;
get_sysfs_str("/sys/class/graphics/fb0/modes", valstr);
- std::vector<CStdString> probe_str;
- StringUtils::SplitString(valstr, "\n", probe_str);
+ std::vector<std::string> probe_str = StringUtils::Split(valstr, "\n");
resolutions.clear();
RESOLUTION_INFO res;