[Mplayer-cvslog] CVS: 0_90/libvo vo_directfb2.c,1.6,1.7

Arpi of Ize arpi at mplayerhq.hu
Mon Mar 10 16:59:07 CET 2003


Update of /cvsroot/mplayer/0_90/libvo
In directory mail:/var/tmp.root/cvs-serv16281

Modified Files:
	vo_directfb2.c 
Log Message:
backport: DFB 0.9.17 support


Index: vo_directfb2.c
===================================================================
RCS file: /cvsroot/mplayer/0_90/libvo/vo_directfb2.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- vo_directfb2.c	29 Dec 2002 18:07:18 -0000	1.6
+++ vo_directfb2.c	10 Mar 2003 15:59:04 -0000	1.7
@@ -217,10 +217,13 @@
    */
 
         DFBCHECK (DirectFBCreate (&dfb));
-        if (DFB_OK != dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)) {
-	    printf("DirectFB: Warning - cannot swith to fullscreen mode");
-	};
 
+#if DIRECTFBVERSION != 917
+        if (DFB_OK != dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)) {
+            printf("DirectFB: Warning - cannot swith to fullscreen mode");
+        };
+#endif
+	
   /*
    * (Get keyboard)
    */
@@ -274,6 +277,9 @@
     	    case IMGFMT_YV12:  return  DSPF_YV12; break;
     	    case IMGFMT_I420:  return  DSPF_I420; break;
 //    	    case IMGFMT_IYUV:  return  DSPF_IYUV; break;
+    	    case IMGFMT_RGB8:  return  DSPF_RGB332; break;
+    	    case IMGFMT_BGR8:  return  DSPF_RGB332; break;
+	
 	    default: return 0;
 	}
 return 0;	
@@ -305,7 +311,7 @@
 	       return DFENUM_OK;
      } else {
         DFBDisplayLayerConfig        dlc;
-	
+
 	if (params->setsize) {
     	    dlc.flags	= DLCONF_WIDTH |DLCONF_HEIGHT;
 	    dlc.width	= params->width;
@@ -316,22 +322,22 @@
 
         dlc.flags       = DLCONF_PIXELFORMAT;
 	dlc.pixelformat = convformat(params->format);
-             
+
 	layer->SetOpacity(layer,0);
+             
 	ret = layer->TestConfiguration(layer,&dlc,NULL);
  
         layer->Release(layer);
 
 	if (verbose) printf("DirectFB: Test format - layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
      
-	if (!ret) {
+	if (ret==DFB_OK) {
 //	    printf("Test OK\n");     
 	    if (params->result) {
 	        if  ((!params->scale) && (desc.caps & DLCAPS_SCREEN_LOCATION)) {
 		    params->scale=1;
 		    params->id=id;
 		    if (verbose) printf("DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
-		    
 		}
 	    } else {
 		params->result=1;
@@ -343,7 +349,7 @@
      };
 
     };
-    
+
     return DFENUM_OK;
 }
 
@@ -475,12 +481,12 @@
 	    params.width=0;
 	    params.height=0;
 	    switch (format) {
-		    case IMGFMT_RGB32: 
-    		    case IMGFMT_BGR32: 
+		    case IMGFMT_RGB32:
+    		    case IMGFMT_BGR32:
 					params.bpp=32;
 					break;
-        	    case IMGFMT_RGB24: 
-		    case IMGFMT_BGR24: 
+        	    case IMGFMT_RGB24:
+		    case IMGFMT_BGR24:
 					params.bpp=24;
 					break;
 		    case IMGFMT_RGB16:
@@ -489,9 +495,9 @@
 	    	    case IMGFMT_BGR15:
 					params.bpp=16;
 					break;
-		    default:		params.bpp=0;		
-					
-	    }			
+		    default:		params.bpp=0;
+
+	    }
 	    if (verbose) printf("DirectFB: Config - videomode change\n");
             DFBCHECK (dfb->EnumVideoModes(dfb,video_modes_callback,&params));
 	    ret=dfb->SetVideoMode(dfb,params.width,params.height,params.bpp);
@@ -524,45 +530,124 @@
 	if (!params.result) {
 	    printf("DirectFB: ConfigError - no suitable layer found\n");
 	    params.id = DLID_PRIMARY;
-	}	
-/*	Uncomment following if you want to use tvout on CRTC2 (requieres patch for DirectFB from Ville Syrjala)
-	params.id=2;
-	params.scale=0;
-	params.result=1;
-*/	
-	if (verbose) printf("DirectFB: Config - layer %i\n",params.id);
-
+	}
 
-// try to setp-up proper configuration
+	if (verbose) printf("DirectFB: Config - layer %i\n",params.id);
 
+	// setup layer
 
         DFBCHECK (dfb->GetDisplayLayer( dfb, params.id, &layer));
+	
+#if DIRECTFBVERSION > 916
+	ret = layer->SetCooperativeLevel (layer, DLSCL_EXCLUSIVE);
 
+        if (DFB_OK != ret) {
+	    DirectFBError("MPlayer - Switch layer to exlusive mode.",ret);
+	    printf("DirectFB: Warning - cannot swith layer to exclusive mode. This could cause\nproblems. You may need to select correct pixel format manually!\n");
+	};
+#endif
+	
 	if (params.scale) {
             if (verbose) printf("DirectFB: Config - set layer config (size)\n");
             dlc.flags       = DLCONF_WIDTH | DLCONF_HEIGHT;
 	    dlc.width       = s_width;
     	    dlc.height      = s_height;
-	    
+
 	    ret = layer->SetConfiguration(layer,&dlc);
-	    
-	    if (ret && (params.scale || verbose)) printf("DirectFB: ConfigError in layer configuration (size)\n");
-	
+
+	    if (ret) {
+		printf("DirectFB: ConfigError in layer configuration (size)\n");
+		DirectFBError("MPlayer - Layer size change.",ret);
+	    };
 	}
 
-        dlc.flags       = DLCONF_PIXELFORMAT;
-	dlc.pixelformat = convformat(params.format);
+        // look if we need to change pixel fromat of layer
+	// and just for sure fetch also all layer propreties
+	dlc.flags       = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_OPTIONS | DLCONF_BUFFERMODE;
+
+	ret = layer->GetConfiguration(layer,&dlc);
+
+	dlc.flags       = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT;
 
-//	printf("DirectFB: Format [%x]\n",dlc.pixelformat);
-             
-        if (verbose) printf("DirectFB: Config - set layer config (format)\n");
-	ret = layer->SetConfiguration(layer,&dlc);
-	
 	if (ret) {
-	    printf("DirectFB: ConfigError in layer configuration (format)\n");
-	    return CONFIG_ERROR;
+	    printf("DirectFB: Warning - could not get layer properties!\n");
+	} else if (verbose) {
+	    printf("DirectFB: Layer reports format:%x\n",dlc.pixelformat);
+	}
+
+	if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) {
+
+    	    dlc.flags       = DLCONF_PIXELFORMAT;
+	    dlc.pixelformat = convformat(params.format);
+
+	    printf("DirectFB: Desired pixelformat: %x\n",dlc.pixelformat);
+
+    	    if (verbose) printf("DirectFB: Config - set layer config (format)\n");
+	    ret = layer->SetConfiguration(layer,&dlc);
+
+	    if (ret) {
+		unsigned int bpp;
+		printf("DirectFB: ConfigError in layer configuration (format, flags=%x)\n",dlc.flags);
+		DirectFBError("MPlayer - layer pixelformat change",ret);
+
+		// ugly fbdev workabout - try to switch pixelformat via videomode change
+		switch (dlc.pixelformat) {
+		    case DSPF_ARGB: 
+		    case DSPF_RGB32: bpp=32;break;
+    		    case DSPF_RGB24: bpp=24;break;
+	            case DSPF_RGB16: bpp=16;break;
+#if DIRECTFBVERSION > 915
+    		    case DSPF_ARGB1555: bpp=15;break;
+#else
+        	    case DSPF_RGB15: bpp=15;break;
+#endif
+		    case DSPF_RGB332 : bpp=8;break;
+		}
+		
+		switch (dlc.pixelformat) {
+		    case DSPF_ARGB:
+		    case DSPF_RGB32:
+    		    case DSPF_RGB24:
+	            case DSPF_RGB16:
+#if DIRECTFBVERSION > 915
+    		    case DSPF_ARGB1555:
+#else
+        	    case DSPF_RGB15:
+#endif
+		    case DSPF_RGB332:
+				    printf("DirectFB: Trying to recover via videomode change (VM).\n");
+				    // get size
+		        	    dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
+				    if (DFB_OK==layer->GetConfiguration(layer,&dlc)) {
+					// try to set videomode
+				        printf("DirectFB: Videomode  %ix%i BPP %i\n",dlc.width,dlc.height,bpp);
+				    	ret = dfb->SetVideoMode(dfb,dlc.width,dlc.height,bpp);
+					if (ret) DirectFBError("MPlayer - VM - pixelformat change",ret);
+
+				    };
+
+				    //get current pixel format
+				    dlc.flags       = DLCONF_PIXELFORMAT;
+	    			    ret = layer->GetConfiguration(layer,&dlc);
+				    if (ret) {
+					DirectFBError("MPlayer - VM - Layer->GetConfiguration",ret);
+					} else {
+				        printf("DirectFB: Layer has now pixelformat [%x]\n",dlc.pixelformat);
+					};
+
+				    // check if we were succesfull
+				    if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) {
+				        printf("DirectFB: Recovery failed!.\n");
+					return CONFIG_ERROR;
+					}
+
+				    break;
+				    
+		    default: return CONFIG_ERROR;	
+			
+		};
+	    };
 	};
-	
 
 // flipping of layer
 



More information about the MPlayer-cvslog mailing list