Permalink
Browse files

AML: More accurate resolution switch

  • Loading branch information...
Owersun committed Mar 25, 2016
1 parent d1a23ed commit 4fc2b2d8cb77ef8b6086f7aa56e8d3071b75db2f
Showing with 101 additions and 112 deletions.
  1. +101 −112 xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp
@@ -73,6 +73,7 @@ void CEGLNativeTypeAmlogic::Initialize()
aml_permissions();
FreeScale(false);
}
void CEGLNativeTypeAmlogic::Destroy()
{
SetScreenScale(1, 1, false);
@@ -82,13 +83,15 @@ void CEGLNativeTypeAmlogic::Destroy()
bool CEGLNativeTypeAmlogic::CreateNativeDisplay()
{
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
m_nativeDisplay = EGL_DEFAULT_DISPLAY;
return true;
}
bool CEGLNativeTypeAmlogic::CreateNativeWindow()
{
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
#if defined(_FBDEV_WINDOW_H_)
fbdev_window *nativeWindow = new fbdev_window;
if (!nativeWindow)
@@ -112,6 +115,7 @@ bool CEGLNativeTypeAmlogic::CreateNativeWindow()
bool CEGLNativeTypeAmlogic::GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const
{
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
if (!nativeDisplay)
return false;
*nativeDisplay = (XBNativeDisplayType*) &m_nativeDisplay;
@@ -121,6 +125,7 @@ bool CEGLNativeTypeAmlogic::GetNativeDisplay(XBNativeDisplayType **nativeDisplay
bool CEGLNativeTypeAmlogic::GetNativeWindow(XBNativeWindowType **nativeWindow) const
{
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
if (!nativeWindow)
return false;
*nativeWindow = (XBNativeWindowType*) &m_nativeWindow;
@@ -130,12 +135,14 @@ bool CEGLNativeTypeAmlogic::GetNativeWindow(XBNativeWindowType **nativeWindow) c
bool CEGLNativeTypeAmlogic::DestroyNativeDisplay()
{
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
return true;
}
bool CEGLNativeTypeAmlogic::DestroyNativeWindow()
{
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
#if defined(_FBDEV_WINDOW_H_)
delete (fbdev_window*)m_nativeWindow, m_nativeWindow = NULL;
#endif
@@ -152,6 +159,7 @@ bool CEGLNativeTypeAmlogic::GetNativeResolution(RESOLUTION_INFO *res) const
bool CEGLNativeTypeAmlogic::SetNativeResolution(const RESOLUTION_INFO &res)
{
CLog::Log(LOGNOTICE, "%s::%s to %dx%d@%f", CLASSNAME, __func__, res.iScreenWidth, res.iScreenHeight, res.fRefreshRate);
#if defined(_FBDEV_WINDOW_H_)
if (m_nativeWindow)
{
@@ -161,86 +169,87 @@ bool CEGLNativeTypeAmlogic::SetNativeResolution(const RESOLUTION_INFO &res)
#endif
bool result = false;
switch((int)(res.fRefreshRate))
{
case 23:
switch(res.iScreenHeight)
{
case 1080:
result = SetDisplayResolution("1080p23hz");
break;
case 2160:
result = SetDisplayResolution("2160p23hz");
break;
}
break;
case 24:
switch(res.iScreenHeight)
{
case 1080:
result = SetDisplayResolution("1080p24hz");
break;
case 2160:
result = SetDisplayResolution("2160p24hz");
break;
}
break;
case 25:
case 50:
switch(res.iScreenHeight)
{
case 720:
result = SetDisplayResolution("720p50hz");
break;
case 1080:
if (res.dwFlags & D3DPRESENTFLAG_INTERLACED)
result = SetDisplayResolution("1080i50hz");
else
result = SetDisplayResolution("1080p50hz");
break;
case 2160:
result = SetDisplayResolution("2160p50hz");
break;
}
break;
case 29:
case 59:
switch(res.iScreenHeight)
{
case 720:
result = SetDisplayResolution("720p59hz");
break;
case 1080:
if (res.dwFlags & D3DPRESENTFLAG_INTERLACED)
result = SetDisplayResolution("1080i59hz");
else
result = SetDisplayResolution("1080p59hz");
break;
case 2160:
result = SetDisplayResolution("2160p59hz");
break;
}
break;
case 30:
case 60:
switch(res.iScreenHeight)
{
default:
case 720:
result = SetDisplayResolution("720p");
break;
case 1080:
if (res.dwFlags & D3DPRESENTFLAG_INTERLACED)
result = SetDisplayResolution("1080i");
else
result = SetDisplayResolution("1080p");
break;
case 2160:
result = SetDisplayResolution("2160p60hz");
break;
}
break;
int refreshRate = (int)(res.fRefreshRate);
switch (res.iScreenHeight) {
case 720:
switch(refreshRate) {
case 23:
result = SetDisplayResolution("720p23hz");
break;
case 24:
result = SetDisplayResolution("720p24hz");
break;
case 25:
case 50:
result = SetDisplayResolution("720p50hz");
break;
case 29:
case 59:
result = SetDisplayResolution("720p59hz");
break;
case 30:
case 60:
result = SetDisplayResolution("720p60hz");
break;
}
break;
case 1080:
switch(refreshRate) {
case 23:
result = SetDisplayResolution("1080p23hz");
break;
case 24:
result = SetDisplayResolution("1080p24hz");
break;
case 25:
case 50:
if (res.dwFlags & D3DPRESENTFLAG_INTERLACED)
result = SetDisplayResolution("1080i50hz");
else
result = SetDisplayResolution("1080p50hz");
break;
case 29:
case 59:
if (res.dwFlags & D3DPRESENTFLAG_INTERLACED)
result = SetDisplayResolution("1080i59hz");
else
result = SetDisplayResolution("1080p59hz");
break;
case 30:
case 60:
if (res.dwFlags & D3DPRESENTFLAG_INTERLACED)
result = SetDisplayResolution("1080i60hz");
else
result = SetDisplayResolution("1080p60hz");
break;
}
break;
case 2160:
switch(refreshRate) {
case 23:
result = SetDisplayResolution("2160p23hz");
break;
case 24:
result = SetDisplayResolution("2160p24hz");
break;
case 25:
result = SetDisplayResolution("2160p25hz");
break;
case 29:
result = SetDisplayResolution("2160p29hz");
break;
case 30:
result = SetDisplayResolution("2160p30hz");
break;
case 59:
result = SetDisplayResolution("2160p59hz");
break;
case 60:
result = SetDisplayResolution("2160p60hz");
break;
}
break;
}
DealWithScale(res);
@@ -251,37 +260,10 @@ bool CEGLNativeTypeAmlogic::SetNativeResolution(const RESOLUTION_INFO &res)
bool CEGLNativeTypeAmlogic::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions)
{
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
std::string valstr;
SysfsUtils::GetString("/sys/class/amhdmitx/amhdmitx0/disp_cap", valstr);
std::vector<std::string> probe_str;
probe_str.push_back("720p23hz"); // fake
probe_str.push_back("720p24hz"); // fake
probe_str.push_back("720p25hz"); // fake
probe_str.push_back("720p29hz"); // fake
probe_str.push_back("720p30hz"); // fake
probe_str.push_back("720p50hz"); // real
probe_str.push_back("720p59hz"); // real
probe_str.push_back("720p"); // real
probe_str.push_back("1080p23hz"); // real
probe_str.push_back("1080p24hz"); // real
probe_str.push_back("1080p25hz"); // fake
probe_str.push_back("1080p29hz"); // fake
probe_str.push_back("1080p30hz"); // fake
probe_str.push_back("1080p50hz"); // real
probe_str.push_back("1080p59hz"); // real
probe_str.push_back("1080p"); // real
probe_str.push_back("1080i50hz"); // real
probe_str.push_back("1080i59hz"); // real
probe_str.push_back("1080i"); // real
probe_str.push_back("2160p23hz");
probe_str.push_back("2160p24hz");
probe_str.push_back("2160p25hz");
probe_str.push_back("2160p29hz");
probe_str.push_back("2160p30hz");
probe_str.push_back("2160p50hz");
probe_str.push_back("2160p59hz");
probe_str.push_back("2160p60hz");
std::vector<std::string> probe_str = StringUtils::Split(valstr, "\n");
resolutions.clear();
RESOLUTION_INFO res;
@@ -296,6 +278,7 @@ bool CEGLNativeTypeAmlogic::ProbeResolutions(std::vector<RESOLUTION_INFO> &resol
bool CEGLNativeTypeAmlogic::GetPreferredResolution(RESOLUTION_INFO *res) const
{
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
// check display/mode, it gets defaulted at boot
if (!GetNativeResolution(res))
{
@@ -309,6 +292,7 @@ bool CEGLNativeTypeAmlogic::GetPreferredResolution(RESOLUTION_INFO *res) const
bool CEGLNativeTypeAmlogic::ShowWindow(bool show)
{
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
std::string blank_framebuffer = "/sys/class/graphics/" + m_framebuffer_name + "/blank";
SysfsUtils::SetInt(blank_framebuffer.c_str(), show ? 0 : 1);
return true;
@@ -317,6 +301,7 @@ bool CEGLNativeTypeAmlogic::ShowWindow(bool show)
bool CEGLNativeTypeAmlogic::SetDisplayResolution(const char *resolution)
{
CLog::Log(LOGNOTICE, "%s::%s to %s", CLASSNAME, __func__, resolution);
std::string mode = resolution;
// switch display resolution
SysfsUtils::SetString("/sys/class/display/mode", mode.c_str());
@@ -331,19 +316,23 @@ bool CEGLNativeTypeAmlogic::SetDisplayResolution(const char *resolution)
void CEGLNativeTypeAmlogic::FreeScale(bool state)
{
CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__);
std::string freescale_framebuffer = "/sys/class/graphics/" + m_framebuffer_name + "/free_scale";
SysfsUtils::SetInt(freescale_framebuffer.c_str(), state ? 1 : 0);
}
void CEGLNativeTypeAmlogic::DealWithScale(const RESOLUTION_INFO &res) {
void CEGLNativeTypeAmlogic::DealWithScale(const RESOLUTION_INFO &res)
{
CLog::Log(LOGDEBUG, "%s::%s Interface is %dx%d, screen size is %dx%d", CLASSNAME, __func__, res.iWidth, res.iHeight, res.iScreenWidth, res.iScreenHeight);
if (res.iScreenWidth > res.iWidth && res.iScreenHeight > res.iHeight) {
CLog::Log(LOGDEBUG, "%s::%s Scaling interfaces of size %dx%d to full screen", CLASSNAME, __func__, res.iWidth, res.iHeight);
CLog::Log(LOGNOTICE, "%s::%s Scaling interfaces of size %dx%d to full screen", CLASSNAME, __func__, res.iWidth, res.iHeight);
SetScreenScale(res.iWidth, res.iHeight, true);
}
}
void CEGLNativeTypeAmlogic::SetScreenScale(int width, int height, bool state) {
void CEGLNativeTypeAmlogic::SetScreenScale(int width, int height, bool state)
{
char setting[256] = {};
sprintf(setting, "0 0 %d %d", width - 1 , height - 1);
std::string framebuffer = "/sys/class/graphics/" + m_framebuffer_name;

0 comments on commit 4fc2b2d

Please sign in to comment.