[Openchrome-users] xgamma enabled
Gonzalo A. de la Vega
gadelavega
Wed Dec 6 06:35:13 PST 2006
Adapted from VIA's. It should bail out for 8bpp.
On 12/6/06, Thomas Hellstr?m <thomas at tungstengraphics.com> wrote:
>
> Gonzalo A. de la Vega wrote:
>
> > I did it again... maybe it's the hangover... here is the right patch.
> > This one is the right one... I double checked. I did the previous one
> > offline, against a 1 day old backup... I won't do it again, it's a
> > promise!!!
> >
> >
> Thanks,
> No problem. BTW, is this code an adaptation from VIA's drivers or from
> Luc's unichrome driver?
> Just for the record?
>
> Everyone else reading, can we have this patch tried on some different
> hardware and bit-depths?
>
>
> /Thomas
>
> >------------------------------------------------------------------------
> >
> >Index: unichrome/via_driver.c
> >===================================================================
> >--- unichrome/via_driver.c (revision 247)
> >+++ unichrome/via_driver.c (working copy)
> >@@ -81,6 +81,9 @@
> > static Bool VIAMapFB(ScrnInfoPtr pScrn);
> > static void VIAUnmapMem(ScrnInfoPtr pScrn);
> >
> >+static void VIALoadRgbLut(ScrnInfoPtr pScrn, LOCO *colors);
> >+static int VIAChangeGamma(int myNum, Gamma gamma);
> >+
> > DriverRec VIA =
> > {
> > VIA_VERSION,
> >@@ -2056,9 +2059,10 @@
> >
> > DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIALoadPalette\n"));
> >
> >- if (pScrn->bitsPerPixel != 8)
> >+ if (pScrn->bitsPerPixel != 8)
> > return;
> >
> >+
> > SR1A = hwp->readSeq(hwp, 0x1A);
> > SR1B = hwp->readSeq(hwp, 0x1B);
> > CR67 = hwp->readCrtc(hwp, 0x67);
> >@@ -2078,6 +2082,7 @@
> > hwp->writeDacData(hwp, colors[index].green);
> > hwp->writeDacData(hwp, colors[index].blue);
> > }
> >+ DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIALoadPalette: palete
> loaded\n"));
> >
> > if (pVia->IsSecondary) {
> > hwp->writeSeq(hwp, 0x1A, SR1A);
> >@@ -2098,6 +2103,110 @@
> > }
> >
> > /*
> >+ * Loads the color table in LOCO *colors to use it as a LUT for the DAC.
> >+ * The LUT values go from 0 to 255, and the lowest index should be the
> >+ * lowest value for a positive image (with proper colors).
> >+ */
> >+
> >+static void VIALoadRgbLut(ScrnInfoPtr pScrn, LOCO *colors) {
> >+ VIAPtr pVia = VIAPTR(pScrn);
> >+ vgaHWPtr hwp = VGAHWPTR(pScrn);
> >+
> >+ int i, SR1A;
> >+
> >+ DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIALoadRgbLut\n"));
> >+ /* 8 bpp mode can't adjust gamma */
> >+ if (pScrn->bitsPerPixel == 8)
> >+ return;
> >+
> >+ /* Enable Gamma */
> >+ switch (pVia->Chipset)
> >+ {
> >+ case VIA_CLE266:
> >+ case VIA_KM400:
> >+ ViaSeqMask(hwp, 0x16, 0x80, 0x80);
> >+ break;
> >+
> >+ /* For K8M800 or later chipsets: */
> >+ default:
> >+ ViaCrtcMask(hwp, 0x33, 0x80, 0x80);
> >+ break;
> >+ }
> >+ SR1A = hwp->readSeq(hwp, 0x1A);
> >+ ViaSeqMask(hwp, 0x1A, 0x0, 0x01);
> >+
> >+ hwp->writeDacWriteAddr(hwp, 0);
> >+ for (i = 0; i < 256; i++)
> >+ {
> >+ hwp->writeDacData(hwp, colors[i].red);
> >+ hwp->writeDacData(hwp, colors[i].green);
> >+ hwp->writeDacData(hwp, colors[i].blue);
> >+ }
> >+
> >+ /* Fill IGA1,IGA2 Gamma table simultanous.*/
> >+ if (!((pVia->Chipset == VIA_CLE266) && (pVia->ChipRev < 15)))
> >+ {
> >+ ViaSeqMask(hwp, 0x1A, 0x01, 0x01);
> >+ ViaCrtcMask(hwp, 0x6A, 0x02, 0x02);
> >+ /* We should set the format of IGA2's LUT to 8-BITs, because we
> use 8-BITs LUT except VT3123Ax. */
> >+ /* This register added in VT3314 or later chipsets. */
> >+ switch(pVia->Chipset)
> >+ {
> >+ case VIA_CLE266:
> >+ case VIA_KM400:
> >+ case VIA_K8M800:
> >+ case VIA_PM800:
> >+ /* No need to set. */
> >+ break;
> >+
> >+ default:
> >+ ViaCrtcMask(hwp, 0x6A, 0x20, 0x20);
> >+ break;
> >+ }
> >+
> >+ hwp->writeDacWriteAddr(hwp, 0);
> >+ for (i = 0; i < 256; i++)
> >+ {
> >+ hwp->writeDacData(hwp, colors[i].red);
> >+ hwp->writeDacData(hwp, colors[i].green);
> >+ hwp->writeDacData(hwp, colors[i].blue);
> >+ }
> >+ }
> >+
> >+ hwp->writeSeq(hwp, 0x1A, SR1A);
> >+ return;
> >+}
> >+
> >+int VIAChangeGamma(int myNum, Gamma gamma)
> >+{
> >+ LOCO *colors;
> >+ colors=malloc(256*3*sizeof(unsigned short));
> >+ int cindex;
> >+
> >+ ScrnInfoPtr pScrn = xf86Screens[myNum];
> >+
> >+ if (gamma.red < GAMMA_MIN || gamma.red > GAMMA_MAX ||
> >+ gamma.green < GAMMA_MIN || gamma.green > GAMMA_MAX ||
> >+ gamma.blue < GAMMA_MIN || gamma.blue > GAMMA_MAX)
> >+ return BadValue;
> >+
> >+ pScrn->gamma.red = gamma.red;
> >+ pScrn->gamma.green = gamma.green;
> >+ pScrn->gamma.blue = gamma.blue;
> >+
> >+ for(cindex=0;cindex<256;cindex++) {
> >+ colors[cindex].red=(unsigned
> short)(255*powf((float)cindex/255,1/pScrn->gamma.red));
> >+ colors[cindex].green=(unsigned
> short)(255*powf((float)cindex/255,1/pScrn->gamma.green));
> >+ colors[cindex].blue=(unsigned
> short)(255*powf((float)cindex/255,1/pScrn->gamma.blue));
> >+
> >+ }
> >+
> >+ VIALoadRgbLut(pScrn, colors);
> >+ return Success;
> >+}
> >+
> >+
> >+/*
> > *
> > */
> > static Bool
> >@@ -2233,7 +2342,7 @@
> > pVia->CloseScreen = pScreen->CloseScreen;
> > pScreen->SaveScreen = VIASaveScreen;
> > pScreen->CloseScreen = VIACloseScreen;
> >-
> >+ pScrn->ChangeGamma = VIAChangeGamma;
> > xf86DPMSInit(pScreen, VIADPMS, 0);
> > DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- DPMS set up\n"));
> >
> >Index: unichrome/via_swov.c
> >===================================================================
> >--- unichrome/via_swov.c (revision 247)
> >+++ unichrome/via_swov.c (working copy)
> >@@ -730,7 +730,7 @@
> >
> > if (reset) {
> > saturation = 10000;
> >- brightness = 5000;
> >+ brightness = 2000;
> > contrast = 10000;
> > }
> >
> >
> >
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wiki.openchrome.org/pipermail/openchrome-users/attachments/20061206/5c90dac5/attachment.html
More information about the Openchrome-users
mailing list