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);