PATCH: Fix XV overlay color attr. (Intel-2.2.1)

Thomas Fritzsche tf at noto.de
Fri May 9 10:32:10 PDT 2008


Hi Guys,

running with my i965 the gnome video player (totem) with overlay XV
support, I notice contrast and saturation is not correct.
I identified this is caused by Register OCLRC0 and OCLRC1 setting. The
"contrast" setting is in 3i,6f and "saturation" is in 3i.7 format.
This is documented in the Register reference documentation section
3.2.13 that company Intel kindly provided.

Bypassing this settings is the value "1.0", but not the average of max
and min value (50%) (as e.g. gnome totem player assumes). As external
programs can not know what this neutral setting is, but just assuming
its 50% I adjusted the scale.

This patch is against 2.2.1 intel driver:
http://linux.pengin.de/intel_xv_attr.diff

I tested successful with my i965 and gnome video player.
(patched Ubuntu 8:10 package:
http://linux.pengin.de/xserver-xorg-video-intel_2.2.1-1ubun.deb)

As the coding is git HEAD seem to have the same issue (except the
initialization is a little better then in 2.2.1), I post this
information here as well, in case it is helpful.

Thanks and regards,
Thomas Fritzsche
===========================
diff -urN xserver-xorg-video-intel-2.2.1_orig/src/i830_video.c
xserver-xorg-video-intel-2.2.1/src/i830_video.c
--- xserver-xorg-video-intel-2.2.1_orig/src/i830_video.c	2008-02-21
06:41:25.000000000 +0900
+++ xserver-xorg-video-intel-2.2.1/src/i830_video.c	2008-05-10
01:31:48.000000000 +0900
@@ -606,7 +606,8 @@
     I830Ptr pI830 = I830PTR(pScrn);
     I830PortPrivPtr pPriv = pI830->adaptor->pPortPrivates[0].ptr;
     I830OverlayRegPtr	overlay = I830OVERLAYREG(pI830);
-
+    int contrast,saturation;
+	
     OVERLAY_DEBUG("I830ResetVideo: base: %p, offset: 0x%lx, obase: %p\n",
 		  pI830->FbBase, pI830->overlay_regs->offset, overlay);
     /*
@@ -623,8 +624,17 @@
     overlay->SWIDTH = 0;
     overlay->SWIDTHSW = 0;
     overlay->SHEIGHT = 0;
-    overlay->OCLRC0 = (pPriv->contrast << 18) | (pPriv->brightness & 0xff);
-    overlay->OCLRC1 = pPriv->saturation;
+
+    if (pPriv->contrast <= 128) contrast = (int) (pPriv->contrast / 2);
+    else contrast = (int) (64  + (pPriv->contrast -127) * (192/127));
+    if (contrast > 255) contrast = 255;
+	
+    if (pPriv->saturation <= 512) saturation = (int) (pPriv->saturation / 4 );
+    else saturation = (int) (128  + (pPriv->saturation-512) * (895/512));	
+    if ( saturation > 1023 ) saturation = 1023;
+	
+    overlay->OCLRC0 = (contrast  << 18) | (pPriv->brightness & 0xff);
+    overlay->OCLRC1 = saturation;
 #if 0
     overlay->AWINPOS = 0;
     overlay->AWINSZ = 0;
@@ -834,8 +844,8 @@
     pPriv->colorKey = pI830->colorKey & ((1 << pScrn->depth) - 1);
     pPriv->videoStatus = 0;
     pPriv->brightness = 0;
-    pPriv->contrast = 64;
-    pPriv->saturation = 128;
+    pPriv->contrast = 128;
+    pPriv->saturation = 512;
     pPriv->current_crtc = NULL;
     pPriv->desired_crtc = NULL;
     pPriv->buf = NULL;
@@ -1031,7 +1041,8 @@
     I830PortPrivPtr pPriv = (I830PortPrivPtr) data;
     I830Ptr pI830 = I830PTR(pScrn);
     I830OverlayRegPtr overlay;
-
+    int contrast,saturation;
+	
     if (pPriv->textured) {
 	/* XXX: Currently the brightness/saturation attributes aren't hooked up.
 	 * However, apps expect them to be there, and the spec seems to let us
@@ -1046,21 +1057,27 @@
 	if ((value < -128) || (value > 127))
 	    return BadValue;
 	pPriv->brightness = value;
-	overlay->OCLRC0 = (pPriv->contrast << 18) | (pPriv->brightness & 0xff);
+	overlay->OCLRC0 = (overlay->OCLRC0 & 0xffffff00) | (pPriv->brightness & 0xff);
 	OVERLAY_DEBUG("BRIGHTNESS\n");
 	i830_overlay_continue (pScrn, FALSE);
     } else if (attribute == xvContrast) {
 	if ((value < 0) || (value > 255))
 	    return BadValue;
-	pPriv->contrast = value;
-	overlay->OCLRC0 = (pPriv->contrast << 18) | (pPriv->brightness & 0xff);
+	if (value <= 128) contrast = (int) (value / 2);
+	else contrast = (int) (64  + (value-127) * (192/127));
+	if (contrast > 255) contrast = 255;
+	pPriv->contrast =  value;
+	overlay->OCLRC0 = (contrast << 18) | (overlay->OCLRC0  & 0xff);
 	OVERLAY_DEBUG("CONTRAST\n");
 	i830_overlay_continue (pScrn, FALSE);
     } else if (attribute == xvSaturation) {
 	if ((value < 0) || (value > 1023))
 	    return BadValue;
 	pPriv->saturation = value;
-	overlay->OCLRC1 = pPriv->saturation;
+	if (value <= 512) saturation = (int) (value / 4 );
+	else saturation = (int) (128  + (value-512) * (895/512));	
+	if ( saturation > 1023 ) saturation = 1023;
+	overlay->OCLRC1 = saturation;
 	i830_overlay_continue (pScrn, FALSE);
     } else if (attribute == xvPipe) {
 	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);



More information about the xorg mailing list