summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@neko.keithp.com>2006-05-09 13:51:25 -0700
committerKeith Packard <keithp@neko.keithp.com>2006-05-13 21:53:06 -0700
commit54f4e09326f584da70569058678bc01a5b770665 (patch)
tree30c2668895b54a6ca36e241cfcbedaa4ed683090
parentab4c2f3bf4b26fdd597ea7b7a726ae77778617b2 (diff)
Video overlay gamma bounds checking must be done bytewise.xf86-video-i810-1_5-branch
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.c61
1 files changed, 42 insertions, 19 deletions
diff --git a/src/i830_video.c b/src/i830_video.c
index b655280d..22d9a1a4 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -590,18 +590,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
@@ -847,28 +882,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) {