void CEGLNativeTypeBoxee::Initialize() { gdl_init(); int enable = 1; gdl_rectangle_t srcRect, dstRect; gdl_display_info_t display_info; gdl_get_display_info(GDL_DISPLAY_ID_0, &display_info); dstRect.origin.x = 0; dstRect.origin.y = 0; dstRect.width = display_info.tvmode.width; dstRect.height = display_info.tvmode.height; srcRect.origin.x = 0; srcRect.origin.y = 0; srcRect.width = display_info.tvmode.width; srcRect.height = display_info.tvmode.height; gdl_port_set_attr(GDL_PD_ID_HDMI, GDL_PD_ATTR_ID_POWER, &enable); gdl_plane_reset(GDL_GRAPHICS_PLANE); gdl_plane_config_begin(GDL_GRAPHICS_PLANE); gdl_plane_set_uint(GDL_PLANE_SRC_COLOR_SPACE, GDL_COLOR_SPACE_RGB); gdl_plane_set_uint(GDL_PLANE_PIXEL_FORMAT, GDL_PF_ARGB_32); gdl_plane_set_rect(GDL_PLANE_DST_RECT, &dstRect); gdl_plane_set_rect(GDL_PLANE_SRC_RECT, &srcRect); gdl_plane_config_end(GDL_FALSE); return; }
bool CEGLNativeTypeBoxee::GetNativeResolution(RESOLUTION_INFO *res) const { #if defined(TARGET_BOXEE) gdl_display_info_t display_info; gdl_get_display_info(GDL_DISPLAY_ID_0, &display_info); tvmode_to_RESOLUTION_INFO(display_info.tvmode, res); CLog::Log(LOGNOTICE,"Current resolution: %s\n",res->strMode.c_str()); return true; #else return false; #endif }
static CoglBool _cogl_winsys_renderer_connect (CoglRenderer *renderer, CoglError **error) { CoglRendererEGL *egl_renderer; CoglRendererGDL *gdl_renderer; gdl_ret_t rc = GDL_SUCCESS; gdl_display_info_t gdl_display_info; renderer->winsys = g_slice_new0 (CoglRendererEGL); egl_renderer = renderer->winsys; gdl_renderer = g_slice_new0 (CoglRendererGDL); egl_renderer->platform = gdl_renderer; egl_renderer->platform_vtable = &_cogl_winsys_egl_vtable; egl_renderer->edpy = eglGetDisplay (EGL_DEFAULT_DISPLAY); if (!_cogl_winsys_egl_renderer_connect_common (renderer, error)) goto error; /* Check we can talk to the GDL library */ rc = gdl_init (NULL); if (rc != GDL_SUCCESS) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_INIT, "GDL initialize failed. %s", gdl_get_error_string (rc)); goto error; } rc = gdl_get_display_info (GDL_DISPLAY_ID_0, &gdl_display_info); if (rc != GDL_SUCCESS) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_INIT, "GDL failed to get display information: %s", gdl_get_error_string (rc)); gdl_close (); goto error; } gdl_close (); return TRUE; error: _cogl_winsys_renderer_disconnect (renderer); return FALSE; }
static CoglBool gdl_plane_init (CoglDisplay *display, CoglError **error) { CoglBool ret = TRUE; gdl_color_space_t colorSpace = GDL_COLOR_SPACE_RGB; gdl_pixel_format_t pixfmt = GDL_PF_ARGB_32; gdl_rectangle_t dstRect; gdl_display_info_t display_info; gdl_ret_t rc = GDL_SUCCESS; if (!display->gdl_plane) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT, "No GDL plane specified with " "cogl_gdl_display_set_plane"); return FALSE; } rc = gdl_init (NULL); if (rc != GDL_SUCCESS) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT, "GDL initialize failed. %s", gdl_get_error_string (rc)); return FALSE; } rc = gdl_get_display_info (GDL_DISPLAY_ID_0, &display_info); if (rc != GDL_SUCCESS) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT, "GDL failed to get display infomation: %s", gdl_get_error_string (rc)); gdl_close (); return FALSE; } dstRect.origin.x = 0; dstRect.origin.y = 0; dstRect.width = display_info.tvmode.width; dstRect.height = display_info.tvmode.height; /* Configure the plane attribute. */ rc = gdl_plane_reset (display->gdl_plane); if (rc == GDL_SUCCESS) rc = gdl_plane_config_begin (display->gdl_plane); if (rc == GDL_SUCCESS) rc = gdl_plane_set_attr (GDL_PLANE_SRC_COLOR_SPACE, &colorSpace); if (rc == GDL_SUCCESS) rc = gdl_plane_set_attr (GDL_PLANE_PIXEL_FORMAT, &pixfmt); if (rc == GDL_SUCCESS) rc = gdl_plane_set_attr (GDL_PLANE_DST_RECT, &dstRect); if (rc == GDL_SUCCESS) rc = gdl_plane_set_uint (GDL_PLANE_NUM_GFX_SURFACES, 3); if (rc == GDL_SUCCESS) rc = gdl_plane_config_end (GDL_FALSE); else gdl_plane_config_end (GDL_TRUE); if (rc != GDL_SUCCESS) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT, "GDL configuration failed: %s.", gdl_get_error_string (rc)); ret = FALSE; } gdl_close (); return ret; }
/*!*********************************************************************** @Function OsInitOS @description Saves instance handle and creates main window In this function, we save the instance handle in a global variable and create and display the main program window. *************************************************************************/ bool PVRShellInit::OsInitOS() { #if defined(USE_GDL_PLANE) gdl_display_info_t di; gdl_get_display_info(GDL_DISPLAY_ID_0, &di); m_Plane = GDL_PLANE_ID_UPP_C; gdl_pixel_format_t pixelFormat = GDL_PF_ARGB_32; // Change the colour bpp default to 32 bits per pixel to match the GDL pixel format m_pShell->m_pShellData->nColorBPP = 32; gdl_color_space_t colorSpace = GDL_COLOR_SPACE_RGB; gdl_rectangle_t srcRect, dstRect; gdl_ret_t rc = GDL_SUCCESS; rc = gdl_plane_config_begin(m_Plane); if(rc != GDL_SUCCESS) { m_pShell->PVRShellOutputDebug("Failed to begin config of GDL plane. (Error code 0x%x)\n", rc); return false; } if(m_pShell->m_pShellData->bFullScreen) dstRect.origin.x = dstRect.origin.y = 0; else { dstRect.origin.x = m_pShell->m_pShellData->nShellPosX; dstRect.origin.y = m_pShell->m_pShellData->nShellPosY; } srcRect.origin.x = srcRect.origin.y = 0; srcRect.width = m_pShell->m_pShellData->nShellDimX; srcRect.height = m_pShell->m_pShellData->nShellDimY; bool bUpscaling = false; if(m_pShell->m_pShellData->bFullScreen) { dstRect.width = di.tvmode.width; bUpscaling = true; } else dstRect.width = srcRect.width; if(m_pShell->m_pShellData->bFullScreen) { dstRect.height = di.tvmode.height; bUpscaling = true; } else dstRect.height = srcRect.height; rc = gdl_plane_set_uint(GDL_PLANE_SCALE, bUpscaling ? GDL_TRUE : GDL_FALSE); if(rc != GDL_SUCCESS) { m_pShell->PVRShellOutputDebug("Failed to set upscale of GDL plane. (Error code 0x%x)\n", rc); return false; } rc = gdl_plane_set_attr(GDL_PLANE_SRC_COLOR_SPACE, &colorSpace); if(rc != GDL_SUCCESS) { m_pShell->PVRShellOutputDebug("Failed to set color space of GDL plane. (Error code 0x%x)\n", rc); return false; } rc = gdl_plane_set_attr(GDL_PLANE_PIXEL_FORMAT, &pixelFormat); if(rc != GDL_SUCCESS) { m_pShell->PVRShellOutputDebug("Failed to set pixel format of GDL plane. (Error code 0x%x)\n", rc); return false; } rc = gdl_plane_set_attr(GDL_PLANE_DST_RECT, &dstRect); if(rc != GDL_SUCCESS) { m_pShell->PVRShellOutputDebug("Failed to set dst rect of GDL plane. (Error code 0x%x)\n", rc); return false; } rc = gdl_plane_set_attr(GDL_PLANE_SRC_RECT, &srcRect); if(rc != GDL_SUCCESS) { m_pShell->PVRShellOutputDebug("Failed to set src rect of GDL plane. (Error code 0x%x)\n", rc); return false; } rc = gdl_plane_config_end(GDL_FALSE); if(rc != GDL_SUCCESS) { gdl_plane_config_end(GDL_TRUE); m_pShell->PVRShellOutputDebug("Failed to end config of GDL plane. (Error code 0x%x)\n", rc); return false; } #endif return true; }
/*!*********************************************************************** @Function OsInit @description Initialisation for OS-specific code. *************************************************************************/ void PVRShellInit::OsInit() { bcm_host_init(); // In case we're in the background ignore SIGTTIN and SIGTTOU signal( SIGTTIN, SIG_IGN ); signal( SIGTTOU, SIG_IGN ); remote_fd = 0; m_pShell->m_pShellData->bFullScreen= true; // linux overrides default to use fullscreen m_ui32NativeDisplay = 0; // Keyboard handling if((devfd=open(CONNAME, O_RDWR|O_NDELAY)) <= 0) { m_pShell->PVRShellOutputDebug("Can't open tty (%s)\n",CONNAME); } else { tcgetattr(devfd,&termio_orig); tcgetattr(devfd,&termio); cfmakeraw(&termio); termio.c_oflag |= OPOST | ONLCR; // Turn back on cr-lf expansion on output termio.c_cc[VMIN]=1; termio.c_cc[VTIME]=0; if(tcsetattr(devfd,TCSANOW,&termio) == -1) { m_pShell->PVRShellOutputDebug("Can't set tty attributes for %s\n",CONNAME); } } // Keypad handling. if ((keypad_fd = open(KEYPAD_INPUT, O_RDONLY | O_NDELAY)) <= 0) { m_pShell->PVRShellOutputDebug("Can't open keypad input device (%s)\n",KEYPAD_INPUT); } #if defined(PVRSHELL_OMAP3_TS_SUPPORT) /************************************************* * Touchscreen code * NOTE: For the init code to work, these variables have to be set prior to the app launch. * * export TSLIB_TSDEVICE=/dev/input/event1 * export TSLIB_CONFFILE=/etc/ts.conf * export TSLIB_CALIBFILE=/etc/pointercal * export TSLIB_CONSOLEDEVICE=/dev/tty * export TSLIB_FBDEVICE=/dev/fb0 *************************************************/ ts = ts_open(TOUCHSCREEN_INPUT, 1); if (!ts) { m_pShell->PVRShellOutputDebug("Can't open the touchscreen input device\n"); } else if (ts_config(ts)) { m_pShell->PVRShellOutputDebug("Can't open the touchscreen input device\n"); } #endif // Remote Control handling #if defined(PVRSHELL_INTEL_CE_PIC24_REMOTE) g_usRemoteLastKey = 0x0; pic_if.Init(REMOTE); #else if((remote_fd = open(REMOTE, O_RDONLY|O_NDELAY)) <= 0) { m_pShell->PVRShellOutputDebug("Can't open remote control input device (%s)\n",REMOTE); } else { tcgetattr(remote_fd, &remios_orig); remios.c_cflag = B9600 | CRTSCTS | CS8 | CLOCAL | CREAD; remios.c_iflag = IGNPAR | ICRNL; remios.c_oflag = 0; remios.c_lflag = 0; remios.c_cc[VMIN] = 1; remios.c_cc[VTIME]= 0; tcflush(remote_fd, TCIFLUSH); tcsetattr(remote_fd, TCSANOW, &remios); } #endif // Construct the binary path for GetReadPath() and GetWritePath() // Get PID (Process ID) pid_t ourPid = getpid(); char *pszExePath, pszSrcLink[64]; int len = 64; int res; sprintf(pszSrcLink, "/proc/%d/exe", ourPid); pszExePath = 0; do { len *= 2; delete[] pszExePath; pszExePath = new char[len]; res = readlink(pszSrcLink, pszExePath, len); if(res < 0) { m_pShell->PVRShellOutputDebug("Warning Readlink %s failed. The application name, read path and write path have not been set.\n", pszExePath); break; } } while(res >= len); if(res >= 0) { pszExePath[res] = '\0'; // Null-terminate readlink's result SetReadPath(pszExePath); SetWritePath(pszExePath); SetAppName(pszExePath); } delete[] pszExePath; /* Get rid of the blinking cursor on a screen. It's an equivalent of: <CODE> echo -n -e "\033[?25l" > /dev/tty0 </CODE> if you do the above command then you can undo it with: <CODE> echo -n -e "\033[?25h" > /dev/tty0 </CODE> */ FILE *tty = 0; tty = fopen("/dev/tty0", "w"); if (tty != 0) { const char txt[] = { 27 /* the ESCAPE ASCII character */ , '[' , '?' , '2' , '5' , 'l' , 0 }; fprintf(tty, "%s", txt); fclose(tty); } gettimeofday(&m_StartTime,NULL); #if defined(USE_GDL_PLANE) gdl_init(0); // Set the width and height to fill the screen gdl_display_info_t di; gdl_get_display_info(GDL_DISPLAY_ID_0, &di); m_pShell->m_pShellData->nShellDimX = di.tvmode.width; m_pShell->m_pShellData->nShellDimY = di.tvmode.height; #endif }