Permalink
Browse files

[rbp] added raspberrypi EGL support plus a pseudo 3D mode for 3D output

  • Loading branch information...
huceke committed Aug 10, 2012
1 parent 14a4011 commit b0f57b850b5b51710f84e94e94a5125d82017580
@@ -17,7 +17,7 @@ CONFIGURE=cp -f $(CONFIG_SUB) $(CONFIG_GUESS) build-aux/ ;\
--enable-neon --enable-gles --enable-debug \
--disable-sdl --disable-x11 --disable-xrandr \
--disable-optical-drive --disable-joystick --disable-optimizations \
- --enable-shared-lib --disable-alsa
+ --enable-shared-lib --enable-alsa
all: $(SOURCE)/libxbmc.so
@@ -29,6 +29,7 @@
#include "utils/log.h"
#include "utils/MathUtils.h"
#include "settings/AdvancedSettings.h"
+#include "cores/VideoRenderers/RenderFlags.h"
CBaseRenderer::CBaseRenderer()
@@ -189,30 +190,84 @@ void CBaseRenderer::FindResolutionFromFpsMatch(float fps, float& weight)
RESOLUTION CBaseRenderer::FindClosestResolution(float fps, float multiplier, RESOLUTION current, float& weight)
{
+ RESOLUTION_INFO &curr = g_settings.m_ResInfo[current];
+
+ int iWidth = curr.iWidth;
+ int iHeight = curr.iHeight;
+ float fRefreshRate = fps;
+
+ /*
+ * For 3D modes the following is assumed :
+ *
+ * fps is fps * 2 : 25 fps -> 50 fps
+ *
+ * side-by-side :
+ *
+ * width is width / 2 : 1920 -> 960
+ *
+ * tob-bottom :
+ *
+ * height is height / 2 : 1080 -> 540
+ *
+ */
+
+ if(m_iFlags & CONF_FLAGS_FORMAT_SBS)
+ {
+ iWidth /= 2;
+ fRefreshRate *= 2;
+ }
+ else if(m_iFlags & CONF_FLAGS_FORMAT_TB)
+ {
+ iHeight /= 2;
+ fRefreshRate *= 2;
+ }
+
+ float last_diff = fRefreshRate;
+
// Find closest refresh rate
for (size_t i = (int)RES_DESKTOP; i < g_settings.m_ResInfo.size(); i++)
{
- RESOLUTION_INFO &curr = g_settings.m_ResInfo[current];
RESOLUTION_INFO &info = g_settings.m_ResInfo[i];
//discard resolutions that are not the same width and height
//or have a too low refreshrate
- if (info.iWidth != curr.iWidth
- || info.iHeight != curr.iHeight
+ if (info.iWidth != iWidth
+ || info.iHeight != iHeight
|| info.iScreen != curr.iScreen
- || info.fRefreshRate < (fps * multiplier / 1.001) - 0.001)
+ || info.fRefreshRate < (fRefreshRate * multiplier / 1.001) - 0.001)
continue;
- int c_weight = MathUtils::round_int(RefreshWeight(curr.fRefreshRate, fps * multiplier) * 1000.0);
- int i_weight = MathUtils::round_int(RefreshWeight(info.fRefreshRate, fps * multiplier) * 1000.0);
+ // For 3D choose the closest refresh rate
+ if(m_iFlags & CONF_FLAGS_FORMAT_SBS || m_iFlags & CONF_FLAGS_FORMAT_TB)
+ {
+ float diff = (info.fRefreshRate - fRefreshRate);
+ if(diff < 0)
+ diff *= -1.0f;
- // Closer the better, prefer higher refresh rate if the same
- if ((i_weight < c_weight)
- || (i_weight == c_weight && info.fRefreshRate > curr.fRefreshRate))
- current = (RESOLUTION)i;
+ if(diff < last_diff)
+ {
+ last_diff = diff;
+ current = (RESOLUTION)i;
+ }
+ }
+ else
+ {
+ //discard resolutions that are not the same width and height
+ int c_weight = MathUtils::round_int(RefreshWeight(curr.fRefreshRate, fRefreshRate * multiplier) * 1000.0);
+ int i_weight = MathUtils::round_int(RefreshWeight(info.fRefreshRate, fRefreshRate * multiplier) * 1000.0);
+
+ // Closer the better, prefer higher refresh rate if the same
+ if ((i_weight < c_weight)
+ || (i_weight == c_weight && info.fRefreshRate > curr.fRefreshRate))
+ current = (RESOLUTION)i;
+ }
}
- weight = RefreshWeight(g_settings.m_ResInfo[current].fRefreshRate, fps * multiplier);
+ // For 3D overwrite weight
+ if(m_iFlags & CONF_FLAGS_FORMAT_SBS || m_iFlags & CONF_FLAGS_FORMAT_TB)
+ weight = 0;
+ else
+ weight = RefreshWeight(g_settings.m_ResInfo[current].fRefreshRate, fRefreshRate * multiplier);
return current;
}
@@ -418,6 +473,11 @@ void CBaseRenderer::CalcNormalDisplayRect(float offsetX, float offsetY, float sc
//***************************************************************************************
void CBaseRenderer::CalculateFrameAspectRatio(unsigned int desired_width, unsigned int desired_height)
{
+ if(m_iFlags & CONF_FLAGS_FORMAT_SBS)
+ desired_width /= 2;
+ else if(m_iFlags & CONF_FLAGS_FORMAT_TB)
+ desired_height /= 2;
+
m_sourceFrameRatio = (float)desired_width / desired_height;
// Check whether mplayer has decided that the size of the video file should be changed
@@ -496,6 +556,10 @@ void CBaseRenderer::SetViewMode(int viewMode)
RESOLUTION res = GetResolution();
float screenWidth = (float)(g_settings.m_ResInfo[res].Overscan.right - g_settings.m_ResInfo[res].Overscan.left);
float screenHeight = (float)(g_settings.m_ResInfo[res].Overscan.bottom - g_settings.m_ResInfo[res].Overscan.top);
+ if(m_iFlags & CONF_FLAGS_FORMAT_SBS)
+ screenWidth /= 2;
+ else if(m_iFlags & CONF_FLAGS_FORMAT_TB)
+ screenHeight /= 2;
// and the source frame ratio
float sourceFrameRatio = GetAspectRatio();
@@ -116,6 +116,9 @@ class CBaseRenderer
CRect m_oldDestRect; // destrect of the previous frame
CRect m_sourceRect;
+ // rendering flags
+ unsigned m_iFlags;
+
const void* m_RenderUpdateCallBackCtx;
RenderUpdateCallBackFn m_RenderUpdateCallBackFn;
};
@@ -205,7 +205,6 @@ class CLinuxRendererGLES : public CBaseRenderer
bool m_bValidated;
std::vector<ERenderFormat> m_formats;
bool m_bImageReady;
- unsigned m_iFlags;
ERenderFormat m_format;
GLenum m_textureTarget;
unsigned short m_renderMethod;
@@ -70,4 +70,8 @@
#define CONF_FLAGS_TRC_GAMMA22 0x0800
#define CONF_FLAGS_TRC_GAMMA28 0x0c00
+/* defines 3d modes */
+#define CONF_FLAGS_FORMAT_SBS 0x001000
+#define CONF_FLAGS_FORMAT_TB 0x002000
+
#endif
@@ -417,6 +417,18 @@ void CGraphicContext::ResetOverscan(RESOLUTION res, OVERSCAN &overscan)
overscan.right = 1920;
overscan.bottom = 1080;
break;
+ case RES_HDTV_720pSBS:
+ overscan.right = 640;
+ overscan.bottom = 720;
+ break;
+ case RES_HDTV_720pTB:
+ overscan.right = 1280;
+ overscan.bottom = 360;
+ break;
+ case RES_HDTV_1080pSBS:
+ overscan.right = 960;
+ overscan.bottom = 1080;
+ break;
case RES_HDTV_720p:
overscan.right = 1280;
overscan.bottom = 720;
@@ -458,6 +470,38 @@ void CGraphicContext::ResetScreenParameters(RESOLUTION res)
g_settings.m_ResInfo[res].fPixelRatio = 1.0f;
g_settings.m_ResInfo[res].strMode ="1080i 16:9";
break;
+ case RES_HDTV_720pSBS:
+ g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 720);
+ g_settings.m_ResInfo[res].iWidth = 640;
+ g_settings.m_ResInfo[res].iHeight = 720;
+ g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DSBS;
+ g_settings.m_ResInfo[res].fPixelRatio = 1.0f;
+ g_settings.m_ResInfo[res].strMode = "720pSBS 16:9";
+ break;
+ case RES_HDTV_720pTB:
+ g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 360);
+ g_settings.m_ResInfo[res].iWidth = 1280;
+ g_settings.m_ResInfo[res].iHeight = 360;
+ g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DTB;
+ g_settings.m_ResInfo[res].fPixelRatio = 1.0f;
+ g_settings.m_ResInfo[res].strMode = "720pTB 16:9";
+ break;
+ case RES_HDTV_1080pSBS:
+ g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 1080);
+ g_settings.m_ResInfo[res].iWidth = 960;
+ g_settings.m_ResInfo[res].iHeight = 1080;
+ g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DSBS;
+ g_settings.m_ResInfo[res].fPixelRatio = 1.0f;
+ g_settings.m_ResInfo[res].strMode = "1080pSBS 16:9";
+ break;
+ case RES_HDTV_1080pTB:
+ g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 540);
+ g_settings.m_ResInfo[res].iWidth = 1920;
+ g_settings.m_ResInfo[res].iHeight = 540;
+ g_settings.m_ResInfo[res].dwFlags = D3DPRESENTFLAG_PROGRESSIVE | D3DPRESENTFLAG_WIDESCREEN | D3DPRESENTFLAG_MODE3DTB;
+ g_settings.m_ResInfo[res].fPixelRatio = 1.0f;
+ g_settings.m_ResInfo[res].strMode = "1080pTB 16:9";
+ break;
case RES_HDTV_720p:
g_settings.m_ResInfo[res].iSubtitles = (int)(0.965 * 720);
g_settings.m_ResInfo[res].iWidth = 1280;
View
@@ -34,19 +34,23 @@ typedef int DisplayMode;
enum RESOLUTION {
RES_INVALID = -1,
RES_HDTV_1080i = 0,
- RES_HDTV_720p = 1,
- RES_HDTV_480p_4x3 = 2,
- RES_HDTV_480p_16x9 = 3,
- RES_NTSC_4x3 = 4,
- RES_NTSC_16x9 = 5,
- RES_PAL_4x3 = 6,
- RES_PAL_16x9 = 7,
- RES_PAL60_4x3 = 8,
- RES_PAL60_16x9 = 9,
- RES_AUTORES = 10,
- RES_WINDOW = 11,
- RES_DESKTOP = 12, // Desktop resolution for primary screen
- RES_CUSTOM = 12 + 1, // Desktop resolution for screen #2
+ RES_HDTV_720pSBS = 1,
+ RES_HDTV_720pTB = 2,
+ RES_HDTV_1080pSBS = 3,
+ RES_HDTV_1080pTB = 4,
+ RES_HDTV_720p = 5,
+ RES_HDTV_480p_4x3 = 6,
+ RES_HDTV_480p_16x9 = 7,
+ RES_NTSC_4x3 = 8,
+ RES_NTSC_16x9 = 9,
+ RES_PAL_4x3 = 10,
+ RES_PAL_16x9 = 11,
+ RES_PAL60_4x3 = 12,
+ RES_PAL60_16x9 = 13,
+ RES_AUTORES = 14,
+ RES_WINDOW = 15,
+ RES_DESKTOP = 16, // Desktop resolution for primary screen
+ RES_CUSTOM = 17 + 1, // Desktop resolution for screen #2
// ...
// 12 + N - 1 // Desktop resolution for screen N
// 12 + N // First additional resolution, in a N screen configuration.
View
@@ -32,9 +32,11 @@
#define GAMMA_RAMP_FLAG D3DSGR_CALIBRATE
-#define D3DPRESENTFLAG_INTERLACED 1
-#define D3DPRESENTFLAG_WIDESCREEN 2
-#define D3DPRESENTFLAG_PROGRESSIVE 4
+#define D3DPRESENTFLAG_INTERLACED 1
+#define D3DPRESENTFLAG_WIDESCREEN 2
+#define D3DPRESENTFLAG_PROGRESSIVE 4
+#define D3DPRESENTFLAG_MODE3DSBS 8
+#define D3DPRESENTFLAG_MODE3DTB 16
#define D3DFMT_LIN_A8R8G8B8 D3DFMT_A8R8G8B8
#define D3DFMT_LIN_X8R8G8B8 D3DFMT_X8R8G8B8
@@ -44,6 +44,7 @@ class CLinuxInputDevice
XBMC_Event ReadEvent();
private:
+ void SetupKeyboardAutoRepeat(int fd);
XBMCKey TranslateKey(unsigned short code);
bool KeyEvent(const struct input_event& levt, XBMC_Event& devt);
bool RelEvent(const struct input_event& levt, XBMC_Event& devt);
@@ -418,6 +418,10 @@ int CBuiltins::Execute(const CStdString& execString)
else if (parameter.Equals("ntsc")) res = RES_NTSC_4x3;
else if (parameter.Equals("ntsc16x9")) res = RES_NTSC_16x9;
else if (parameter.Equals("720p")) res = RES_HDTV_720p;
+ else if (parameter.Equals("720pSBS")) res = RES_HDTV_720pSBS;
+ else if (parameter.Equals("720pTB")) res = RES_HDTV_720pTB;
+ else if (parameter.Equals("1080pSBS")) res = RES_HDTV_1080pSBS;
+ else if (parameter.Equals("1080pTB")) res = RES_HDTV_1080pTB;
else if (parameter.Equals("1080i")) res = RES_HDTV_1080i;
if (g_graphicsContext.IsValidResolution(res))
{
@@ -139,7 +139,11 @@ bool CRenderSystemGLES::ResetRenderSystem(int width, int height, bool fullScreen
g_matrices.MatrixMode(MM_PROJECTION);
g_matrices.LoadIdentity();
+#ifdef TARGET_RASPBERRY_PI
+ g_matrices.Ortho(0.0f, width-1, height-1, 0.0f, +1.0f, 1.0f);
+#else
g_matrices.Ortho(0.0f, width-1, height-1, 0.0f, -1.0f, 1.0f);
+#endif
g_matrices.MatrixMode(MM_MODELVIEW);
g_matrices.LoadIdentity();
@@ -3,6 +3,7 @@ INCLUDES=-I.
SRCS = WinSystemGLES.cpp
SRCS+= WinEGLPlatformGeneric.cpp
SRCS+= WinEGLPlatformAndroid.cpp
+SRCS+= WinEGLPlatformRaspberryPI.cpp
LIB = windowing_egl.a
@@ -24,7 +24,11 @@
#include "system.h"
-#if defined(TARGET_ANDROID)
+#if defined(TARGET_RASPBERRY_PI)
+ #include "xbmc/windowing/egl/WinEGLPlatformRaspberryPI.h"
+ class CWinEGLPlatformRaspberryPI;
+ #define CWinEGLPlatform CWinEGLPlatformRaspberryPI
+#elif defined(TARGET_ANDROID)
#include "xbmc/windowing/egl/WinEGLPlatformAndroid.h"
class CWinEGLPlatformAndroid;
#define CWinEGLPlatform CWinEGLPlatformAndroid
@@ -36,4 +40,4 @@
#endif
-#endif
+#endif
@@ -19,6 +19,10 @@
*
*/
+#include "system.h"
+
+#if defined(TARGET_ANDROID)
+
#include <unistd.h>
#include <string.h>
#include <stdio.h>
@@ -69,3 +73,5 @@ EGLNativeWindowType CWinEGLPlatformAndroid::getNativeWindow()
{
return (EGLNativeWindowType)CXBMCApp::GetNativeWindow();
}
+
+#endif
Oops, something went wrong.

0 comments on commit b0f57b8

Please sign in to comment.