diff options
author | Keith Packard <keithp@neko.keithp.com> | 2006-05-09 13:51:25 -0700 |
---|---|---|
committer | Keith Packard <keithp@neko.keithp.com> | 2006-05-09 13:57:23 -0700 |
commit | f2967a2f5f47b636b2445fa69dbc3ec79e065c90 (patch) | |
tree | 9fa20a590caa5434a70732a249893b9c52a79582 | |
parent | 99b0e53244aa49f4e7461a1c96aba69453b3516f (diff) |
Video overlay gamma bounds checking must be done bytewise.
Also, pend bound computations to register writes to allow
updates to individual values that are 'out of spec' so
the client can update multiple values.
(cherry picked from 190f9ad0606e96e684e0b028d576d822dc9aa3cf commit)
-rw-r--r-- | src/i830_video.c | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/src/i830_video.c b/src/i830_video.c index 0ae68607..a608a7e3 100644 --- a/src/i830_video.c +++ b/src/i830_video.c @@ -592,18 +592,53 @@ I830SetOneLineModeRatio(ScrnInfoPtr pScrn) pPriv->oneLineMode = FALSE; } +static CARD32 I830BoundGammaElt (CARD32 elt, CARD32 eltPrev) +{ + elt &= 0xff; + eltPrev &= 0xff; + if (elt < eltPrev) + elt = eltPrev; + else if ((elt - eltPrev) > 0x7e) + elt = eltPrev + 0x7e; + return elt; +} + +static CARD32 I830BoundGamma (CARD32 gamma, CARD32 gammaPrev) +{ + return (I830BoundGammaElt (gamma >> 24, gammaPrev >> 24) << 24 | + I830BoundGammaElt (gamma >> 16, gammaPrev >> 16) << 16 | + I830BoundGammaElt (gamma >> 8, gammaPrev >> 8) << 8 | + I830BoundGammaElt (gamma , gammaPrev )); +} + static void I830UpdateGamma(ScrnInfoPtr pScrn) { I830Ptr pI830 = I830PTR(pScrn); I830PortPrivPtr pPriv = pI830->adaptor->pPortPrivates[0].ptr; - - OUTREG(OGAMC5, pPriv->gamma5); - OUTREG(OGAMC4, pPriv->gamma4); - OUTREG(OGAMC3, pPriv->gamma3); - OUTREG(OGAMC2, pPriv->gamma2); - OUTREG(OGAMC1, pPriv->gamma1); - OUTREG(OGAMC0, pPriv->gamma0); + CARD32 gamma0 = pPriv->gamma0; + CARD32 gamma1 = pPriv->gamma1; + CARD32 gamma2 = pPriv->gamma2; + CARD32 gamma3 = pPriv->gamma3; + CARD32 gamma4 = pPriv->gamma4; + CARD32 gamma5 = pPriv->gamma5; + + ErrorF ("Original gamma: 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n", + gamma0, gamma1, gamma2, gamma3, gamma4, gamma5); + gamma1 = I830BoundGamma (gamma1, gamma0); + gamma2 = I830BoundGamma (gamma2, gamma1); + gamma3 = I830BoundGamma (gamma3, gamma2); + gamma4 = I830BoundGamma (gamma4, gamma3); + gamma5 = I830BoundGamma (gamma5, gamma4); + ErrorF ("Bounded gamma: 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n", + gamma0, gamma1, gamma2, gamma3, gamma4, gamma5); + + OUTREG(OGAMC5, gamma5); + OUTREG(OGAMC4, gamma4); + OUTREG(OGAMC3, gamma3); + OUTREG(OGAMC2, gamma2); + OUTREG(OGAMC1, gamma1); + OUTREG(OGAMC0, gamma0); } static XF86VideoAdaptorPtr @@ -849,28 +884,16 @@ I830SetPortAttribute(ScrnInfoPtr pScrn, #endif } else if (attribute == xvGamma0 && (IS_I9XX(pI830))) { pPriv->gamma0 = value; - if (pPriv->gamma1 - pPriv->gamma0 > 0x7d) - pPriv->gamma1 = pPriv->gamma0 + 0x7d; } else if (attribute == xvGamma1 && (IS_I9XX(pI830))) { pPriv->gamma1 = value; - if (pPriv->gamma1 - pPriv->gamma0 > 0x7d) - pPriv->gamma0 = pPriv->gamma1 - 0x7d; } else if (attribute == xvGamma2 && (IS_I9XX(pI830))) { pPriv->gamma2 = value; - if (pPriv->gamma3 - pPriv->gamma2 > 0x7d) - pPriv->gamma3 = pPriv->gamma2 + 0x7d; } else if (attribute == xvGamma3 && (IS_I9XX(pI830))) { pPriv->gamma3 = value; - if (pPriv->gamma3 - pPriv->gamma2 > 0x7d) - pPriv->gamma2 = pPriv->gamma3 - 0x7d; } else if (attribute == xvGamma4 && (IS_I9XX(pI830))) { pPriv->gamma4 = value; - if (pPriv->gamma5 - pPriv->gamma4 > 0x7d) - pPriv->gamma5 = pPriv->gamma4 + 0x7d; } else if (attribute == xvGamma5 && (IS_I9XX(pI830))) { pPriv->gamma5 = value; - if (pPriv->gamma5 - pPriv->gamma4 > 0x7d) - pPriv->gamma4 = pPriv->gamma5 - 0x7d; } else if (attribute == xvColorKey) { pPriv->colorKey = value; switch (pScrn->depth) { |