On 01/14/05 21:02, David Belohrad wrote:
2) when using 'mplayer -vo directfb' the picture is over whole screen, but the colors are completely distorted (seems like
red is missing)

I guess VIA has changed the internal of CLE266 a bit, but hasn't changed its revision number to reflect it (hwrev is always 0x03). The color distortion can be corrected by tunning V1_ColorSpaceReg_1 and _2. Attached is my patch to deal with it. See if it helps.


Selwyn
--- DirectFB/gfxdrivers/cle266/uc_overlay.c.orig	2004-02-23 16:58:13.000000000 +0800
+++ DirectFB/gfxdrivers/cle266/uc_overlay.c	2004-10-26 19:59:20.805485103 +0800
@@ -13,6 +13,9 @@
 #include "mmio.h"
 
 #include <core/system.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 
 // Forward declaration
 static DFBResult
@@ -20,7 +23,10 @@
               void      *driver_data,
               void      *layer_data,
               void      *region_data);
-
+static int pci_config_in8( unsigned int bus,
+                           unsigned int slot,
+                           unsigned int func,
+                           __u8 reg );
 
 static int uc_ovl_datasize()
 {
@@ -135,6 +141,7 @@
     UcDriverData*  ucdrv = (UcDriverData*) driver_data;
     UcOverlayData* ucovl = (UcOverlayData*) layer_data;
     volatile __u8* vio = ucdrv->hwregs;
+    char sixty_six = 0;
 
     ucovl->v1.isenabled = false;
 
@@ -143,7 +150,8 @@
     VIDEO_OUT(vio, V_FIFO_CONTROL, UC_MAP_V1_FIFO_CONTROL(16,12,8));
     //  VIDEO_OUT(vio, ALPHA_V3_FIFO_CONTROL, 0x0407181f);
 
-    if (ucovl->hwrev == 0x10) {
+    sixty_six = pci_config_in8(1, 0, 0, 0x06) & 0x20 ? 1 : 0;
+    if (ucovl->hwrev == 0x10 || sixty_six) {
         VIDEO_OUT(vio, V1_ColorSpaceReg_1, ColorSpaceValue_1_3123C0);
         VIDEO_OUT(vio, V1_ColorSpaceReg_2, ColorSpaceValue_2_3123C0);
     }
@@ -308,3 +316,34 @@
     SetInputField:      uc_ovl_set_input_field,
     SetColorAdjustment: uc_ovl_set_adjustment
 };
+
+/** Read PCI configuration register 'reg' for device at {bus,slot,func}. */
+static int pci_config_in8( unsigned int bus,
+                           unsigned int slot,
+                           unsigned int func,
+                           __u8 reg )
+{
+    char  filename[512];
+    int   fd;
+    int   val;
+
+    val = 0;
+
+    snprintf( filename, 512, "/proc/bus/pci/%02x/%02x.%x", bus, slot, func );
+
+    fd = open( filename, O_RDONLY );
+    if (fd < 0) {
+        ERRORMSG( "DirectFB/cle266: Error opening `%s'!\n", filename );
+        return -1;
+    }
+
+    if (lseek( fd, reg, SEEK_SET ) == reg) {
+        if (read( fd, &val, 1 ) == 1) {
+            close( fd );
+            return val;
+        }
+    }
+
+    close( fd );
+    return -1;
+}

Reply via email to