[Openchrome-users] Another try with xgamma (was: xgamma enabled)

Luc Verhaegen libv
Fri Dec 8 17:17:21 PST 2006


On Fri, Dec 08, 2006 at 08:48:20PM -0300, Gonzalo A. de la Vega wrote:
> 	boundary="----=_Part_72812_9435886.1165621700410"
> 
> ------=_Part_72812_9435886.1165621700410
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
> 
> I rewrote the code, adapted from both VIA's and Luc's code. The code is now
> called from the VIALoadPalette() function, which is invoked by
> xf86HandleColormap(). Here's the question: the colormap handler is being
> called with 6 RGB significative bits. This makes the display look dim, 7
> bits is ok with my laptop's LCD (this is what I'm using), and 8 bits looks
> good on CRT (this is what Luc uses). So most displays may look somewhat
> dark.
> 
> Again, works fine on K8M800 24 and 16bpp.
> 
> Gonzalo
> 
> 
> Index: unichrome/via_driver.c
> ===================================================================
> --- unichrome/via_driver.c	(revision 257)
> +++ unichrome/via_driver.c	(working copy)
> @@ -81,6 +81,8 @@
>  static Bool VIAMapFB(ScrnInfoPtr pScrn);
>  static void VIAUnmapMem(ScrnInfoPtr pScrn);
>  
> +static void VIALoadRgbLut(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual);
> +
>  DriverRec VIA =
>  {
>      VIA_VERSION,
> @@ -2063,6 +2065,49 @@
>          xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pVia->FBBase, pVia->videoRambytes);
>  }
>  
> +static void
> +VIALoadRgbLut(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual)
> +{
> +    VIAPtr pVia = VIAPTR(pScrn);
> +    vgaHWPtr hwp = VGAHWPTR(pScrn);
> +
> +    int i, j, SR1A, index;
> +
> +    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIALoadRgbLut\n"));
> +
> +    hwp->enablePalette(hwp);
> +    hwp->writeDacMask(hwp, 0xFF);
> +    switch (pScrn->bitsPerPixel) {
> +	case 16:
> +  	    for (i = 0; i < numColors; i++) {
> +	        index = indices[i];
> +	        hwp->writeDacWriteAddr(hwp, index * 4);
> +
> +	        for (j = 0; j < 4; j++) {
> +		    hwp->writeDacData(hwp, colors[index/2].red);
> +		    hwp->writeDacData(hwp, colors[index].green);
> +		    hwp->writeDacData(hwp, colors[index/2].blue);
> +	        }
> +	    }
> +	    break;
> +	case 8:
> +	case 24:
> +	case 32:
> +	    for (i = 0; i < numColors; i++) {
> +	        index = indices[i];
> +	        hwp->writeDacWriteAddr(hwp, index);
> +
> +	        hwp->writeDacData(hwp, colors[index].red);
> +	        hwp->writeDacData(hwp, colors[index].green);
> +	        hwp->writeDacData(hwp, colors[index].blue);
> +	    }
> +	    break;
> +	}   
> +	hwp->disablePalette(hwp);
> +    	return;
> +    
> +}
> +

Hum.

>  /*
>   *
>   */
> @@ -2077,9 +2122,36 @@
>  
>      DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIALoadPalette\n"));
>  
> -    if (pScrn->bitsPerPixel != 8)
> -	return;
> +    if (pScrn->bitsPerPixel != 8) {
> +	switch(pVia->Chipset) {
> +	    case VIA_CLE266:
> +	    case VIA_KM400:
> +		ViaSeqMask(hwp, 0x16, 0x80, 0x80);
> +		break;
> +	    default:
> +		ViaCrtcMask(hwp, 0x33, 0x00, 0x80);
> +		break;
> +	}
>  
> +	ViaSeqMask(hwp, 0x1A, 0x00, 0x01);
> +	VIALoadRgbLut(pScrn, numColors, indices, colors, pVisual);
> +        if (!((pVia->Chipset == VIA_CLE266) && (pVia->ChipRev < 15)))
> +        {
> +            ViaSeqMask(hwp, 0x1A, 0x01, 0x01);
> +	    ViaCrtcMask(hwp, 0x6A, 0x02, 0x02);
> +	    switch(pVia->Chipset) {
> +	        case VIA_CLE266:
> +	        case VIA_KM400:
> +		    ViaSeqMask(hwp, 0x6A, 0x20, 0x20);
> +		    break;
> +	        default:
> +		    break;
> +		}
> +	    VIALoadRgbLut(pScrn, numColors, indices, colors, pVisual);
> +	}
> +        return;
> +    }
> +
>      SR1A = hwp->readSeq(hwp, 0x1A);
>      SR1B = hwp->readSeq(hwp, 0x1B);
>      CR67 = hwp->readCrtc(hwp, 0x67);
> @@ -2244,7 +2316,7 @@
>          return FALSE;
>      DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- Def Color map set up\n"));
>  
> -    if (!xf86HandleColormaps(pScreen, 256, 6, VIALoadPalette, NULL,
> +    if (!xf86HandleColormaps(pScreen, 256, 7, VIALoadPalette, NULL,
>                               CMAP_RELOAD_ON_MODE_SWITCH
>                               | CMAP_PALETTED_TRUECOLOR))
>          return FALSE;

Luc Verhaegen.




More information about the Openchrome-users mailing list