📄 play_gfx.c
字号:
blend_grad_param.Src2X = 3*(osd_profile->Width/5); blend_grad_param.Src2Y = (osd_profile->Height/5); blend_grad_param.DstX =3*(osd_profile->Width/5); blend_grad_param.DstY = (osd_profile->Height/5); blend_grad_param.Width = osd_profile->Width/5; blend_grad_param.Height = (osd_profile->Height/5); blend_grad_param.SaturateAlpha = 0; SEND_GFX_COMMAND(dcc_info->pRUA, gfx, RMGFXEnginePropertyID_BlendGradient, &blend_grad_param, sizeof(blend_grad_param)); } gfx_waitkey(dcc_info, disp_opt);#endif /* raster operations */ { struct GFXEngine_RasterBlendRectangles_type raster_blend_param;#ifdef RMFEATURE_HAS_GRAPHACC_GRADIENTS struct GFXEngine_LinearGradientSurface_type lin_gradient; struct GFXEngine_RasterBlendGradient_type raster_grad_param; /* XOR with a solid color */ lin_gradient.Width = 0; lin_gradient.Height = 0; lin_gradient.Color0 = 0x0; lin_gradient.Color1 = 0x0; SEND_GFX_COMMAND(dcc_info->pRUA, gfx, RMGFXEnginePropertyID_LinearGradientSurface, &lin_gradient, sizeof(lin_gradient)); raster_grad_param.Src2X = 2*(osd_profile->Width/5); raster_grad_param.Src2Y = (osd_profile->Height/5); raster_grad_param.DstX = 2*(osd_profile->Width/5); raster_grad_param.DstY = (osd_profile->Height/5); raster_grad_param.Width = osd_profile->Width/5; raster_grad_param.Height = osd_profile->Height/5; raster_grad_param.RasterOp = 0x3c; SEND_GFX_COMMAND(dcc_info->pRUA, gfx, RMGFXEnginePropertyID_RasterBlendGradient, &raster_grad_param, sizeof(raster_grad_param)); gfx_waitkey(dcc_info, disp_opt);#endif /* XOR between two bitmaps */ raster_blend_param.Src1X = 2*(osd_profile->Width/5); raster_blend_param.Src1Y = 3*(osd_profile->Height/5); raster_blend_param.Src2X = (osd_profile->Width/5); raster_blend_param.Src2Y = 2*(osd_profile->Height/5); raster_blend_param.Width = osd_profile->Width/5; raster_blend_param.Height = osd_profile->Height/5; raster_blend_param.DstX = 2*(osd_profile->Width/5); raster_blend_param.DstY = 3*(osd_profile->Height/5); raster_blend_param.RasterOp = 0x3c; SEND_GFX_COMMAND(dcc_info->pRUA, gfx, RMGFXEnginePropertyID_RasterBlendRectangles, &raster_blend_param, sizeof(raster_blend_param)); } gfx_waitkey(dcc_info, disp_opt); /* draw some text */ { Rtk86Handle handle; RMTrtk rtk; RtkPoint position; RtkProp prop; RtkRect outputRect; RMnonAscii *naname; handle.pOSDSource = dcc_info->pOSDSource[0]; handle.pRUA = dcc_info->pRUA; rtk = RMFRTKOpen(&handle); prop.fgColor = 0xff2020ff; prop.bgColor = 0x0; position.x = 64; position.y = 20; prop.scale = 24; naname = RMnonAsciiFromAscii("font.psf"); RMFRTKLoadFontFile(rtk, naname); RMFreeNonAscii(naname); RMFRTKDrawString(rtk, "Bitmap fonts OK", &position, &prop, &outputRect); prop.fgColor = 0xffff20ff; prop.bgColor = 0x0; position.x = 64; position.y = 64; prop.scale = 24; naname = RMnonAsciiFromAscii("Vera.ttf"); RMFRTKLoadFontFile(rtk, naname); RMFreeNonAscii(naname); RMFRTKDrawString(rtk, "Vectorial fonts OK", &position, &prop, &outputRect); RMFRTKClose(rtk); }//*/ /* wait for all commands to be finished */ { struct RUAEvent evt; RMbool empty_queue = FALSE; evt.ModuleID = gfx; evt.Mask = RUAEVENT_COMMANDCOMPLETION; while(!empty_queue){ RUAGetProperty(dcc_info->pRUA, gfx, RMGFXEnginePropertyID_CommandQueueEmpty, &empty_queue, sizeof(empty_queue)); /* the following lines could be removed if you don't care about a continuous polling */ if(!empty_queue) { while( RUAWaitForMultipleEvents(dcc_info->pRUA, &evt, 1, TIMEOUT_US, NULL)!=RM_OK){ RMDBGLOG((ENABLE, "Waiting for a command to finish\n")); } } } } /* close the gfx accelerator */ { RMuint32 close_profile = 0; err = RUASetProperty(dcc_info->pRUA, gfx, RMGFXEnginePropertyID_Close, &close_profile, sizeof(close_profile), 0); if (RMFAILED(err)) fprintf(stderr, "Cannot close de gfx accelerator\n"); if(dram_buf != 0) RUAFree(dcc_info->pRUA, dram_buf); if(gfx_profile.CachedAddress) RUAFree(dcc_info->pRUA, gfx_profile.CachedAddress); if(gfx_profile.UncachedAddress) RUAFree(dcc_info->pRUA, gfx_profile.UncachedAddress); }//*/ dram_buf = 0; return 0;}static inline RMuint32 get_image_size(struct DCCOSDProfile *imageProfile){ RMuint32 bits_per_pixel = 0; switch (imageProfile->ColorMode){ case EMhwlibColorMode_TrueColor: case EMhwlibColorMode_TrueColorWithKey: switch (imageProfile->ColorFormat) { case EMhwlibColorFormat_24BPP_565: case EMhwlibColorFormat_24BPP: bits_per_pixel = 24; break; case EMhwlibColorFormat_32BPP_4444: case EMhwlibColorFormat_32BPP: bits_per_pixel = 32; break; case EMhwlibColorFormat_16BPP_565: case EMhwlibColorFormat_16BPP_1555: case EMhwlibColorFormat_16BPP_4444: bits_per_pixel = 16; break; } break; case EMhwlibColorMode_LUT_1BPP: bits_per_pixel = 1; break; case EMhwlibColorMode_LUT_2BPP: bits_per_pixel = 2; break; case EMhwlibColorMode_LUT_4BPP: bits_per_pixel = 4; break; case EMhwlibColorMode_LUT_8BPP: bits_per_pixel = 8; break; default: break; } return (imageProfile->Width * imageProfile->Height * bits_per_pixel + 7)/8; }static inline RMstatus get_image_profile(struct RUA *pRUA ,struct DCCVideoSource *imageSource, struct DCCOSDProfile *imageProfile, RMuint32 *osd_addr){ RMstatus err; RMuint32 surfAddr, picAddr; struct DisplayBlock_SurfaceInfo_out_type surfInfo; struct DisplayBlock_PictureInfo_out_type picInfo; /* get the physical address of the pixel buffer */ err = DCCGetOSDPictureInfo(imageSource, 0, &picAddr, NULL, NULL, NULL, NULL); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot get surface address\n" )); return err; } err = DCCGetOSDSurfaceInfo(NULL, imageSource, NULL, &surfAddr, NULL); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot get surface address\n" )); return err; } err = RUAExchangeProperty(pRUA, DisplayBlock, RMDisplayBlockPropertyID_SurfaceInfo, &(surfAddr), sizeof(surfAddr), &surfInfo, sizeof(surfInfo)); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot get surface infos\n" )); return err; } RMDBGLOG((ENABLE, "picture at 0x%08lx\n", picAddr)); err = RUAExchangeProperty(pRUA, DisplayBlock, RMDisplayBlockPropertyID_PictureInfo, &(picAddr), sizeof(picAddr), &picInfo, sizeof(picInfo)); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot get picture infos\n" )); return err; } *osd_addr = picInfo.LumaAddress; imageProfile->Width = picInfo.Width; imageProfile->Height = picInfo.Height; imageProfile->ColorMode = surfInfo.ColorMode; imageProfile->ColorFormat = surfInfo.ColorFormat; imageProfile->SamplingMode = surfInfo.SamplingMode; imageProfile->ColorSpace = surfInfo.ColorSpace; return RM_OK; }int main(int argc, char *argv[]){ struct DCC *pDCC = NULL; struct RUA *pRUA = NULL; RMuint32 osd_addr = 0; RMstatus err; struct DCCOSDProfile osd_profile={0,}; RMuint32 mixer = 0, scaler, src_index, mixer_src; struct display_context disp_info; struct dh_context dh_info = {0,}; init_display_options(&disp_opt); init_video_options(&video_opt); init_playback_options(&play_opt); disp_opt.dh_info = &dh_info; parse_cmdline(argc, argv); dcc_info.route = disp_opt.route; err = RUACreateInstance(&pRUA, play_opt.chip_num); if (RMFAILED(err)) { fprintf(stderr, "Error creating RUA instance! %d\n", err); return -1; } err = DCCOpen(pRUA, &pDCC); if (RMFAILED(err)) { fprintf(stderr, "Error Opening DCC! %d\n", err); return err; }/* err = DCCSetMemoryManager(pDCC, 1); *//* if (RMFAILED(err)) { *//* fprintf(stderr, "Error setting memory manager %d\n", err); *//* return err; *//* } */ err = DCCInitChainEx(pDCC, disp_opt.init_mode); if (RMFAILED(err)) { fprintf(stderr, "Cannot initialize microcode %d\n", err); return err; } dcc_info.pRUA = pRUA; dcc_info.pDCC = pDCC; dcc_info.disp_info = &disp_info; dcc_info.dh_info = &dh_info; err = apply_playback_options(&dcc_info, &play_opt); if (RMFAILED(err)) { fprintf(stderr, "Cannot set playback options %d\n", err); return err; } set_default_out_window(&(dcc_info.disp_info->out_window)); set_default_out_window(&(dcc_info.disp_info->osd_window[0])); dcc_info.disp_info->active_window = &(dcc_info.disp_info->osd_window[0]); disp_opt.osd_pictures[0].enable = TRUE; disp_opt.osd_pictures[0].filename = filename; err = apply_display_options(&dcc_info, &disp_opt); if (RMFAILED(err)) { fprintf(stderr, "Cannot set display options %d\n", err); return err; } get_image_profile(dcc_info.pRUA, dcc_info.pOSDSource[0], &osd_profile, &osd_addr); if ((osd_profile.Width < 256) || (osd_profile.Height<256)){ fprintf(stderr, "Image should be 256x256 or bigger and true color\n"); goto cleanup; } switch (dcc_info.route) { case DCCRoute_Main: mixer = EMHWLIB_MODULE(DispMainMixer, 0); break; case DCCRoute_Secondary: mixer = EMHWLIB_MODULE(DispVCRMixer, 0); break; case DCCRoute_ColorBars: return RM_OK; default: return RM_ERROR; } /* the mixer should not modify the GFX scaler's config */ { enum EMhwlibMixerSourceState state; scaler= EMHWLIB_MODULE(DispGFXMultiScaler,0); /* set a NULL surface, this will force a full register update when next surface is set */ err = DCCSetSurfaceSource(dcc_info.pDCC, scaler, NULL); if (RMFAILED(err)) { fprintf(stderr, "Cannot unset gfx scaler's surface\n"); return -1; } err = RUAExchangeProperty(dcc_info.pRUA, mixer, RMGenericPropertyID_MixerSourceIndex, &scaler, sizeof(scaler), &src_index, sizeof(src_index)); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot get scaler index\n")); return err; } mixer_src = EMHWLIB_TARGET_MODULE(mixer, 0 , src_index ); state = EMhwlibMixerSourceState_Slave; while((err = RUASetProperty(dcc_info.pRUA, mixer_src, RMGenericPropertyID_MixerSourceState, &state, sizeof(state), 0))==RM_PENDING); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot set scaler's state on mixer\n")); return err; } while ((err = RUASetProperty(dcc_info.pRUA, mixer, RMGenericPropertyID_Validate, NULL, 0, 0)) == RM_PENDING); if (RMFAILED(err)) { fprintf(stderr, "Cannot validate mixer\n"); return err; } do{ err = RUAGetProperty(dcc_info.pRUA, mixer_src, RMGenericPropertyID_MixerSourceState, &state, sizeof(state)); if(RMFAILED(err)){ RMDBGLOG((ENABLE, "error getting source state %s\n", RMstatusToString(err))); } /* this is just to avoid busy loops, can be substituted by a sleep function or removed */ if(state != EMhwlibMixerSourceState_Slave){ struct RUAEvent evt; evt.ModuleID = EMHWLIB_MODULE(DisplayBlock, 0); evt.Mask = EMHWLIB_DISPLAY_EVENT_ID(mixer); err = RUAWaitForMultipleEvents(dcc_info.pRUA, &evt, 1, TIMEOUT_US, NULL); if(RMFAILED(err)){ RMDBGLOG((ENABLE, "wait for display update event completion failed, %s\n", RMstatusToString(err))); } } }while(state != EMhwlibMixerSourceState_Slave); } gfx_test(&dcc_info, &disp_opt, osd_addr, &osd_profile); fprintf( stdout, "gfx test done\n"); gfx_waitkey(&dcc_info, &disp_opt); cleanup: clear_display_options(&dcc_info, &disp_opt); err = DCCClose(pDCC); if (RMFAILED(err)) { fprintf(stderr, "Cannot close DCC %d\n", err); return -1; } err = RUADestroyInstance(pRUA); if (RMFAILED(err)) { fprintf(stderr, "Cannot destroy RUA instance %d\n", err); return -1; } return 0; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -