static DFBResult InitPVR2D( PVR2DData *pvr2d ) { PVR2DERROR ePVR2DStatus; PVR2DDataShared *shared = pvr2d->shared; pvr2d->nDevices = PVR2DEnumerateDevices(0); pvr2d->pDevInfo = (PVR2DDEVICEINFO *) malloc(pvr2d->nDevices * sizeof(PVR2DDEVICEINFO)); PVR2DEnumerateDevices(pvr2d->pDevInfo); pvr2d->nDeviceNum = pvr2d->pDevInfo[0].ulDevID; ePVR2DStatus = PVR2DCreateDeviceContext (pvr2d->nDeviceNum, &pvr2d->hPVR2DContext, 0); if (ePVR2DStatus) { D_ERROR( "DirectFB/PVR2D: PVR2DCreateDeviceContext() failed! (status %d)\n", ePVR2DStatus ); return DFB_INIT; } ePVR2DStatus = PVR2DGetFrameBuffer( pvr2d->hPVR2DContext, PVR2D_FB_PRIMARY_SURFACE, &pvr2d->pFBMemInfo); if (ePVR2DStatus) { D_ERROR( "DirectFB/PVR2D: PVR2DGetFrameBuffer() failed! (status %d)\n", ePVR2DStatus ); return DFB_INIT; } ePVR2DStatus = PVR2DGetScreenMode(pvr2d->hPVR2DContext, &pvr2d->eDisplayFormat, &pvr2d->lDisplayWidth, &pvr2d->lDisplayHeight, &pvr2d->lStride, &pvr2d->RefreshRate); if (ePVR2DStatus) { D_ERROR( "DirectFB/PVR2D: PVR2DGetScreenMode() failed! (status %d)\n", ePVR2DStatus ); return DFB_INIT; } D_INFO( "DirectFB/PVR2D: Display %ldx%ld, format %d, stride %ld, refresh %d\n", pvr2d->lDisplayWidth, pvr2d->lDisplayHeight, pvr2d->eDisplayFormat, pvr2d->lStride, pvr2d->RefreshRate ); shared->screen_size.w = pvr2d->lDisplayWidth; shared->screen_size.h = pvr2d->lDisplayHeight; return DFB_OK; }
static GstDrawContext * gst_pvrvideosink_get_dcontext (GstPVRVideoSink * pvrvideosink) { GstDrawContext *dcontext = NULL; PVR2DERROR pvr_error; gint refresh_rate; DRI2WSDisplay *displayImpl; WSEGLError glerror; const WSEGLCaps *glcaps; GST_DEBUG_OBJECT (pvrvideosink, "Getting draw context"); dcontext = g_new0 (GstDrawContext, 1); dcontext->x_lock = g_mutex_new (); dcontext->p_blt_info = g_new0 (PVR2D_3DBLT_EXT, 1); if (!dcontext->p_blt_info) goto p_blt_info_alloc_failed; dcontext->p_blt2d_info = g_new0 (PVR2DBLTINFO, 1); GST_LOG_OBJECT (pvrvideosink, "Opening X Display"); dcontext->x_display = XOpenDisplay (NULL); if (dcontext->x_display == NULL) goto fail_open_display; GST_LOG_OBJECT (pvrvideosink, "WSEGL_GetFunctionTablePointer()"); dcontext->wsegl_table = WSEGL_GetFunctionTablePointer (); GST_LOG_OBJECT (pvrvideosink, "pfnWSEGL_IsDisplayValid()"); glerror = dcontext->wsegl_table->pfnWSEGL_IsDisplayValid ( (NativeDisplayType) dcontext->x_display); if (glerror != WSEGL_SUCCESS) goto display_invalid; GST_LOG_OBJECT (pvrvideosink, "pfnWSEGL_InitialiseDisplay()"); glerror = dcontext->wsegl_table->pfnWSEGL_InitialiseDisplay ( (NativeDisplayType) dcontext->x_display, &dcontext->display_handle, &glcaps, &dcontext->glconfig); if (glerror != WSEGL_SUCCESS) goto display_init_failed; displayImpl = (DRI2WSDisplay *) dcontext->display_handle; dcontext->pvr_context = displayImpl->hContext; GST_LOG_OBJECT (pvrvideosink, "PVR2DGetScreenMode()"); pvr_error = PVR2DGetScreenMode (dcontext->pvr_context, &dcontext->display_format, &dcontext->display_width, &dcontext->display_height, &dcontext->stride, &refresh_rate); if (pvr_error != PVR2D_OK) goto screen_mode_failed; GST_DEBUG_OBJECT (pvrvideosink, "Got format:%d, width:%d, height:%d, stride:%d, refresh_rate:%d", dcontext->display_format, dcontext->display_width, dcontext->display_height, dcontext->stride, refresh_rate); dcontext->screen_num = DefaultScreen (dcontext->x_display); dcontext->black = XBlackPixel (dcontext->x_display, dcontext->screen_num); GST_DEBUG_OBJECT (pvrvideosink, "Returning dcontext %p", dcontext); return dcontext; p_blt_info_alloc_failed: { GST_ERROR_OBJECT (pvrvideosink, "Alloc of bltinfo failed"); gst_pvrvideosink_dcontext_free (dcontext); return NULL; } fail_open_display: { GST_ERROR_OBJECT (pvrvideosink, "Failed to open X Display"); gst_pvrvideosink_dcontext_free (dcontext); return NULL; } display_invalid: { GST_ERROR_OBJECT (pvrvideosink, "Display is not valid (glerror:%d)", glerror); gst_pvrvideosink_dcontext_free (dcontext); return NULL; } display_init_failed: { GST_ERROR_OBJECT (pvrvideosink, "Error initializing display (glerror:%d)", glerror); gst_pvrvideosink_dcontext_free (dcontext); return NULL; } screen_mode_failed: { GST_ERROR_OBJECT (pvrvideosink, "Failed to get screen mode. error : %s", gst_pvr2d_error_get_string (pvr_error)); gst_pvrvideosink_dcontext_free (dcontext); return NULL; } }