Beispiel #1
0
void smp8634_free(struct SDL_PrivateVideoData *config)
{
	RMstatus err;
	int i;

	clear_display_options(&dcc_info, &disp_opt);
	for (i=0;i<BUFFER_COUNT;i++) {
		RUAUnMap(config->pRUA, config->descriptor->MappedAddr[i], config->descriptor->LumaSize[i]);
		err = RUAUnLock(config->pRUA, config->descriptor->LumaAddr[i], config->descriptor->LumaSize[i]);
		if (RMFAILED(err)) {
			printf("Error unlocking OSD buffer at 0x%08lX (0x%08lX bytes)\n", \
				config->descriptor->LumaAddr[i], config->descriptor->LumaSize[i]);
			return;
		}
	}
	
	gfxUnInit(config->descriptor);
	DCCCloseVideoSource(config->descriptor->OSDSource);

	if (config->pDCC){
		err = DCCClose(config->pDCC);
		if (RMFAILED(err))
			fprintf(stderr, "Cannot close DCC %d\n", err); 
	}

	if (config->pRUA){
		err = RUADestroyInstance(config->pRUA);
		if (RMFAILED(err))
			fprintf(stderr, "Cannot destroy RUA instance %d\n", err);
	}

	DEB(fprintf(stderr,"end freeOSD\n"));
}
Beispiel #2
0
int smp8634_init(struct SDL_PrivateVideoData *config)
{
	RMstatus status = RM_OK;
	char *argv[] = {"", "-r", "1080i59"};
	int index = 1;
	struct em86xx_descriptor *osd;

	init_display_options  ( &disp_opt  );
	init_video_options    ( &video_opt );
	init_playback_options ( &play_opt  );
	disp_opt.dh_info = &dh_info;
	parse_display_cmdline(3, argv, &index, &disp_opt);

	osd = (struct em86xx_descriptor *)malloc(sizeof(struct em86xx_descriptor));
	config->descriptor = osd;
	memset(osd, 0, sizeof(struct em86xx_descriptor));

	status = RUACreateInstance(&config->pRUA, play_opt.chip_num);
	if (RMFAILED(status)){
		fprintf(stderr, "Error creating RUA instance! %d\n", status);
		return 0;
	}
	status = DCCOpen(config->pRUA, &config->pDCC);
	if (RMFAILED(status)) {
		fprintf(stderr, "Error Opening DCC! %d\n", status);
		return 0;
	}
	status = DCCInitChainEx(config->pDCC, disp_opt.init_mode);
	if (RMFAILED(status)) {
		fprintf(stderr, "Cannot initialize microcode %d\n", status);
		return 0;
	} 

	dcc_info.pRUA  = config->pRUA;
	dcc_info.pDCC  = config->pDCC;
	dcc_info.route = DCCRoute_Main;

	status = apply_display_options(&dcc_info, &disp_opt);
	if (RMFAILED(status)) {
		fprintf(stderr, "Cannot set display opions %s\n", RMstatusToString(status));
		return 0;
	}

	/* Init the default osd descriptor */
	osd->pRUA = config->pRUA;
	osd->pDCC = config->pDCC;

	create_gfx(osd);

	return 1;
}
Beispiel #3
0
void RMNOTIFY_implementation(void *cookie, RMstatus status, const RMascii *filename, RMint32 line, const RMascii *text,...)
{
	va_list ap;
	
	if (RMFAILED(status)) {
		sprintf((char *)str, (char *)"[%s:%ld] ERROR (%s) : ", filename, line, RMstatusToString(status));
	} else {
		sprintf((char *)str, (char *)"[%s:%ld] ", filename, line);
	}
	
	va_start(ap, text);
	vsprintf((char *)str+strlen(str), (const char *)text, ap); 
	va_end(ap);
	
	OutputDebugString(str);
}
Beispiel #4
0
void RMNOTIFY_implementation(void *cookie, RMstatus status, const RMascii *filename, RMint32 line, const RMascii *text,...)
{
	va_list ap;
	
	if (RMFAILED(status)) {
		snprintf((char *)str, RMDBG_MAX_STRING, "%s[%s:%ld] ERROR(%s): ", SET_ERROR, (char *)filename, line, RMstatusToString(status));
	} else {
		snprintf((char *)str, RMDBG_MAX_STRING, "[%s:%ld] ", (char *)filename, line);
	}
	
	va_start(ap, text);
	vsnprintf((char *)str+strlen(str), RMDBG_MAX_STRING, text, ap); 
	va_end(ap);
	
	snprintf((char *)str+strlen(str), RMDBG_MAX_STRING, "%s", SET_STD);
	
	print_timestamp(ERRORMSG);
	fprintf(ERRORMSG, str);
	fflush(ERRORMSG);
}
Beispiel #5
0
/* unInitialize gfx */
static RMstatus gfxUnInit(struct em86xx_descriptor *osd)
{
	RMuint32 close_profile = 0;
	RMstatus status;

	if (osd->gfx == 0xFF) return RM_ERROR;
	status = RUASetProperty(osd->pRUA, osd->gfx, RMGFXEnginePropertyID_Close, &close_profile, sizeof(close_profile), 0);
	if (RMFAILED(status)){
		printf("Error cannot close gfx engine\n");
	}
	if (osd->gfx_profile.CachedAddress > 0){
		RUAFree(osd->pRUA, osd->gfx_profile.CachedAddress);
		osd->gfx_profile.CachedAddress = 0;
	}
	if (osd->gfx_profile.UncachedAddress > 0) {
		RUAFree(osd->pRUA, osd->gfx_profile.UncachedAddress);
		osd->gfx_profile.UncachedAddress = 0;
	}

	return RM_OK;
}
Beispiel #6
0
static RMstatus init_scaler(struct em86xx_descriptor *osd, RMuint32 osd_scaler)
{
	RMbool enable = TRUE;
	struct EMhwlibDisplayWindow window;
	enum EMhwlibMixerSourceState state;
	RMuint32 canvas_alpha = 0x80;
	struct RUAEvent e;
	RMuint32 index;
	RMstatus err;

	window.X      = 2048;
	window.Y      = 2048;
	window.Width  = 4096;
	window.Height = 4096;
	
	window.XPositionMode = EMhwlibDisplayWindowPositionMode_FrontEdgeToCenter;
	window.YPositionMode = EMhwlibDisplayWindowPositionMode_FrontEdgeToCenter;
	window.XMode         = EMhwlibDisplayWindowValueMode_Relative;
	window.YMode         = EMhwlibDisplayWindowValueMode_Relative;
	window.WidthMode     = EMhwlibDisplayWindowValueMode_Relative;
	window.HeightMode    = EMhwlibDisplayWindowValueMode_Relative;
	
	while ((err = RUASetProperty(osd->pRUA, osd->mixer, RMGenericPropertyID_MixerSourceWindow, \
			&(window), sizeof(window), 0)) == RM_PENDING);
	if (RMFAILED(err)) {
		RMDBGLOG((ENABLE, "Cannot set scaler output window %d\n", err));
		return err;
	}

	state = EMhwlibMixerSourceState_Master;
	while((err =  RUASetProperty(osd->pRUA, osd->mixer, 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(osd->pRUA, osd->mixer, RMGenericPropertyID_Validate, NULL, 0, 0)) == RM_PENDING);
	if (RMFAILED(err)) {
		RMDBGLOG((ENABLE, "Cannot Validate mixer\n"));
		return err;
	}
       
	while( (err = RUASetProperty(osd->pRUA, osd_scaler, RMGenericPropertyID_Alpha0, \
			&(canvas_alpha), sizeof(canvas_alpha), 0)) == RM_PENDING);
	if (RMFAILED(err)) {
		RMDBGLOG((ENABLE, "Cannot set the alpha value on the scaler\n"));
	}

	while ((err = RUASetProperty(osd->pRUA, osd_scaler, RMGenericPropertyID_Enable, \
			&enable, sizeof(enable), 0)) == RM_PENDING);
	if (RMFAILED(err)) {
		fprintf(stderr, "Cannot validate scaler input window %d\n", err);
		return err;
	}

	if (osd_scaler != DispVideoPlane) {
		window.X      = 0;
		window.Y      = 0;
		window.Width  = 4096;
		window.Height = 4096;
		window.XPositionMode = EMhwlibDisplayWindowPositionMode_FrontEdgeToBorder;
		window.YPositionMode = EMhwlibDisplayWindowPositionMode_FrontEdgeToBorder;
		window.XMode         = EMhwlibDisplayWindowValueMode_Relative;
		window.YMode         = EMhwlibDisplayWindowValueMode_Relative;
		window.WidthMode     = EMhwlibDisplayWindowValueMode_Relative;
		window.HeightMode    = EMhwlibDisplayWindowValueMode_Relative;
		while ((err = RUASetProperty(osd->pRUA, osd_scaler, RMGenericPropertyID_ScalerInputWindow, \
				&window, sizeof(window), 0)) == RM_PENDING);
		if (RMFAILED(err)) {
			fprintf(stderr, "Cannot validate scaler input window %d\n", err);
			return err;
		}
	}
	
	err = DCCSetSurfaceSource(osd->pDCC, osd_scaler, osd->OSDSource);
	if (RMFAILED(err)) {
		fprintf(stderr, "Cannot set the surface source %d\n", err);
		return RM_ERROR;
	}
	
	err = DCCEnableVideoSource(osd->OSDSource, TRUE);
	if (RMFAILED(err)){
		fprintf(stderr,"Error enabling OSD buffer : %d\n",err);
		return err;
	}

	while ((err = RUASetProperty(osd->pRUA, osd_scaler, RMGenericPropertyID_Validate, NULL, 0, 0)) == RM_PENDING);
	if (RMFAILED(err)) {
		fprintf(stderr, "Cannot validate scaler input window %d\n", err);
		return err;
	}
	
	e.ModuleID = EMHWLIB_MODULE(DisplayBlock, 0);
	e.Mask = EMHWLIB_DISPLAY_EVENT_ID(osd_scaler);
	err = RUAWaitForMultipleEvents(osd->pRUA, &e, 1, 1000000, &index);
	if (err == RM_ERROR) {
		fprintf(stderr, "cannot wait for the scaler to refresh\n");
		return err;
	}
	
	return RM_OK;
}
Beispiel #7
0
/* initialize gfx */
static RMstatus create_gfx(struct em86xx_descriptor *osd)
{
	struct RUA *pRua = osd->pRUA;
	RMuint32 gfx_count;
	struct GFXEngine_DRAMSize_in_type  dramSizeIn;
	struct GFXEngine_DRAMSize_out_type dramSizeOut;
	RMint32 i;
	RMstatus status;
	enum EMhwlibMixerSourceState state;

	/* the mixer should not modify the GFX scaler's config */
	osd->gfx  = 0xFF;

	osd->mixer  = EMHWLIB_MODULE(DispMainMixer, 0);
	osd->scaler = EMHWLIB_MODULE(DispOSDScaler, 0);
//	osd->scaler = EMHWLIB_MODULE(DispGFXMultiScaler, 0);

	status = DCCSetSurfaceSource(osd->pDCC, osd->scaler, NULL);
	if (RMFAILED(status)){
		fprintf(stderr,"Error setting OSD surface source\n");
		return status;
	}
	status = RUAExchangeProperty(osd->pRUA, osd->mixer,
					RMGenericPropertyID_MixerSourceIndex, 
					&osd->scaler, sizeof(osd->scaler), &i, sizeof(i));
	if (RMFAILED(status)) {
		printf("Cannot get scaler index\n");
		return status;
	}

	osd->mixer = EMHWLIB_TARGET_MODULE(osd->mixer, 0 , i);
	state = EMhwlibMixerSourceState_Slave;

	while((status = RUASetProperty(osd->pRUA, osd->mixer, RMGenericPropertyID_MixerSourceState, 
			&state, sizeof(state), 0))==RM_PENDING);
	if (RMFAILED(status)) {
		printf("Cannot set scaler's state on mixer\n");
		return status;
	}

	while ((status = RUASetProperty(osd->pRUA, osd->mixer, RMGenericPropertyID_Validate, NULL, 0, 0)) == RM_PENDING);
	if (RMFAILED(status)) {
		fprintf(stderr, "Cannot validate mixer\n");
		return status;
	}

	do{
		status = RUAGetProperty(osd->pRUA, osd->mixer, RMGenericPropertyID_MixerSourceState, &state, sizeof(state));
		if(RMFAILED(status)){
			printf("error getting source state %s\n", RMstatusToString(status));
		}
		/* 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(osd->mixer);

			status = RUAWaitForMultipleEvents(osd->pRUA, &evt, 1, TIMEOUT_US, NULL);
			if(RMFAILED(status)){
				printf("wait for display update event completion failed, %s\n", 
					RMstatusToString(status));
			}
		}
	}while(state != EMhwlibMixerSourceState_Slave);

	/* set OSD last. so it it cleared when DCCCloseVideoSource */
	create_osd_buf(osd);
	init_scaler(osd, DispOSDScaler);

	/* init the gfx_engine */
	dramSizeIn.CommandFIFOCount = 10;
	status = RUAExchangeProperty(pRua, EMHWLIB_MODULE(GFXEngine,0), RMGFXEnginePropertyID_DRAMSize,
				  &dramSizeIn, sizeof(dramSizeIn), &dramSizeOut, sizeof(dramSizeOut));
	if (RMFAILED(status)) {
		printf("Error getting dram size for gfx engine\n");
		return RM_ERROR;
	}
	
	osd->gfx_profile.Priority         = 1;
	osd->gfx_profile.CommandFIFOCount = dramSizeIn.CommandFIFOCount;
	osd->gfx_profile.CachedSize       = dramSizeOut.CachedSize;
	osd->gfx_profile.UncachedSize     = dramSizeOut.UncachedSize;
	if (osd->gfx_profile.CachedSize > 0)
		osd->gfx_profile.CachedAddress = RUAMalloc(pRua, 0, RUA_DRAM_CACHED, osd->gfx_profile.CachedSize);
	else
		osd->gfx_profile.CachedAddress = 0;

	osd->gfx_profile.UncachedSize = dramSizeOut.UncachedSize;
	if (osd->gfx_profile.UncachedSize > 0)
		osd->gfx_profile.UncachedAddress = RUAMalloc(pRua, 0, RUA_DRAM_UNCACHED, osd->gfx_profile.UncachedSize);
	else
		osd->gfx_profile.UncachedAddress = 0;

	osd->gfx = GFXEngine;

	status = RUAExchangeProperty(pRua, EMHWLIB_MODULE(Enumerator,0),  RMEnumeratorPropertyID_CategoryIDToNumberOfInstances, 
				  &osd->gfx, sizeof(osd->gfx), &gfx_count, sizeof(gfx_count));
	if (RMFAILED(status)) {
		printf("Error getting gfx engine count\n");
		return RM_ERROR;
	}
	
	for (i = 0 ; i< (RMint32) gfx_count ; i++) {
		osd->gfx = EMHWLIB_MODULE(GFXEngine, i);
		status = RUASetProperty(pRua, osd->gfx, RMGFXEnginePropertyID_Open, &osd->gfx_profile, sizeof(osd->gfx_profile), 0);
		if (status == RM_OK) 
			break;
	}

	if (i == (RMint32) gfx_count) {
		printf("Cannot open a gfx engine [0..%lu[\n", gfx_count);
		return RM_ERROR;
	}

	printf("%s is OK\n", __FUNCTION__);

	return RM_OK;
}
Beispiel #8
0
static RMstatus create_osd_buf(struct em86xx_descriptor *posd)
{
	int i;
	RMstatus status;
	struct DisplayBlock_SurfaceInfo_out_type surfInfo;

	posd->osd_profile.ColorSpace         = EMhwlibColorSpace_RGB_0_255;
	posd->osd_profile.SamplingMode       = EMhwlibSamplingMode_444;
	posd->osd_profile.ColorMode          = EMhwlibColorMode_TrueColor;
	posd->osd_profile.ColorFormat        = EMhwlibColorFormat_32BPP;
	posd->osd_profile.PixelAspectRatio.X = 1;
	posd->osd_profile.PixelAspectRatio.Y = 1;
	posd->osd_profile.Width              = DEFAULT_OSD_WIDTH;
	posd->osd_profile.Height             = DEFAULT_OSD_HEIGHT;

        status = DCCOpenMultiplePictureOSDVideoSource(posd->pDCC, &posd->osd_profile, BUFFER_COUNT, 
			&posd->OSDSource, dcc_info.pStcSource );
        if (RMFAILED(status)) {
                fprintf(stderr, "Cannot open OSD decoder %d\n", status);
		return status;
        }
        
	status = DCCClearOSDVideoSource(posd->OSDSource);
	if (RMFAILED(status)) {
		printf("Cannot clear osd surface %d\n", status);
		return status;
	}

	for (i=0; i<BUFFER_COUNT; i++) {
	        status = DCCGetOSDPictureInfo(posd->OSDSource, i, &posd->pic_addr[i], 
				&posd->LumaAddr[i], &posd->LumaSize[i], &posd->ChromaAddr[i], &posd->ChromaSize[i]);
	        if (RMFAILED(status)) {
        	        fprintf(stderr, "Cannot get osd buffer [%d] info %d\n", i, status);
			return status;
        	}
                status = RUALock(posd->pRUA, posd->LumaAddr[i], posd->LumaSize[i]);
                if (RMFAILED(status)) {
                        printf("Error locking OSD buffer at 0x%08lX (0x%08lX bytes)\n", \
                                posd->LumaAddr[i], posd->LumaSize[i]);
                        return 0;
                }
                posd->MappedAddr[i] = RUAMap(posd->pRUA, posd->LumaAddr[i], posd->LumaSize[i]);
                if (posd->MappedAddr[i] == NULL) {
                        printf("Error mapping OSD buffer at 0x%08lX (0x%08lX bytes)\n", \
				posd->LumaAddr[i], posd->LumaSize[i]);
                        return 0;
                }
       
	       	printf("pic_addr[%d]=0x%x, LumaAddr[%d]=0x%x, MappedAddr[%d]=0x%x, LumaSize[%d]=0x%x\n", 
				i, posd->pic_addr[i], 
				i, posd->LumaAddr[i],
				i, posd->MappedAddr[i],
				i, posd->LumaSize[i]);
	}
	DCCInsertPictureInMultiplePictureOSDVideoSource(posd->OSDSource, 0, 0);

        status = DCCGetOSDSurfaceInfo(posd->pDCC, posd->OSDSource, NULL, &posd->osd_surface, NULL);
        if (RMFAILED(status)) {
                fprintf(stderr, "Cannot get surface address %d\n", status);
		return status;
        }

	status = RUAExchangeProperty(posd->pRUA, DisplayBlock, RMDisplayBlockPropertyID_SurfaceInfo,
			&(posd->osd_surface), sizeof(posd->osd_surface), &surfInfo, sizeof(surfInfo));
	if (RMFAILED(status)) {
		RMDBGLOG((ENABLE, "Cannot get surface infos\n" ));
		return status;
	}

	posd->osd_profile.ColorMode    = surfInfo.ColorMode;
	posd->osd_profile.ColorFormat  = surfInfo.ColorFormat;
	posd->osd_profile.SamplingMode = surfInfo.SamplingMode;
	posd->osd_profile.ColorSpace   = surfInfo.ColorSpace;

	return RM_OK;
}