diff options
author | Eric Anholt <eric@anholt.net> | 2008-03-11 09:59:16 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2008-03-11 11:16:17 -0700 |
commit | 642ba6278876ec945ad687c2b9624e532cd3f629 (patch) | |
tree | 58cb9213f46d794b6c8a67eeb6ae3ede07722e4e /src | |
parent | ecdb5963ef6873ab82998dca6ca5186644666ec8 (diff) |
Add support for brightness control to i915 textured video output.
Diffstat (limited to 'src')
-rw-r--r-- | src/i830_video.c | 32 | ||||
-rw-r--r-- | src/i915_3d.h | 4 | ||||
-rw-r--r-- | src/i915_video.c | 35 |
3 files changed, 57 insertions, 14 deletions
diff --git a/src/i830_video.c b/src/i830_video.c index aa10cac6..2c8f2a97 100644 --- a/src/i830_video.c +++ b/src/i830_video.c @@ -94,6 +94,7 @@ static XF86VideoAdaptorPtr I830SetupImageVideoOverlay(ScreenPtr); static XF86VideoAdaptorPtr I830SetupImageVideoTextured(ScreenPtr); static void I830StopVideo(ScrnInfoPtr, pointer, Bool); static int I830SetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); +static int I830SetPortAttributeTextured(ScrnInfoPtr, Atom, INT32, pointer); static int I830GetPortAttribute(ScrnInfoPtr, Atom, INT32 *, pointer); static void I830QueryBestSize(ScrnInfoPtr, Bool, short, short, short, short, unsigned int *, @@ -940,7 +941,7 @@ I830SetupImageVideoTextured(ScreenPtr pScreen) adapt->GetVideo = NULL; adapt->GetStill = NULL; adapt->StopVideo = I830StopVideo; - adapt->SetPortAttribute = I830SetPortAttribute; + adapt->SetPortAttribute = I830SetPortAttributeTextured; adapt->GetPortAttribute = I830GetPortAttribute; adapt->QueryBestSize = I830QueryBestSize; adapt->PutImage = I830PutImage; @@ -1029,6 +1030,27 @@ I830StopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown) } static int +I830SetPortAttributeTextured(ScrnInfoPtr pScrn, + Atom attribute, INT32 value, pointer data) +{ + I830PortPrivPtr pPriv = (I830PortPrivPtr) data; + + if (attribute == xvBrightness) { + if ((value < -128) || (value > 127)) + return BadValue; + pPriv->brightness = value; + return Success; + } else if (attribute == xvContrast) { + if ((value < 0) || (value > 255)) + return BadValue; + pPriv->contrast = value; + return Success; + } else { + return BadMatch; + } +} + +static int I830SetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, INT32 value, pointer data) { @@ -1036,14 +1058,6 @@ I830SetPortAttribute(ScrnInfoPtr pScrn, I830Ptr pI830 = I830PTR(pScrn); I830OverlayRegPtr overlay; - 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 - * sneak out of actually implementing them for now. - */ - return Success; - } - overlay = I830OVERLAYREG(pI830); if (attribute == xvBrightness) { diff --git a/src/i915_3d.h b/src/i915_3d.h index 10902186..83a14c1f 100644 --- a/src/i915_3d.h +++ b/src/i915_3d.h @@ -61,6 +61,10 @@ #define FS_C1 ((REG_TYPE_CONST << 8) | 1) #define FS_C2 ((REG_TYPE_CONST << 8) | 2) #define FS_C3 ((REG_TYPE_CONST << 8) | 3) +#define FS_C4 ((REG_TYPE_CONST << 8) | 4) +#define FS_C5 ((REG_TYPE_CONST << 8) | 5) +#define FS_C6 ((REG_TYPE_CONST << 8) | 6) +#define FS_C7 ((REG_TYPE_CONST << 8) | 7) /* Sampler regs */ #define FS_S0 ((REG_TYPE_S << 8) | 0) diff --git a/src/i915_video.c b/src/i915_video.c index 00494a7b..dd0e596a 100644 --- a/src/i915_video.c +++ b/src/i915_video.c @@ -132,9 +132,17 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, ADVANCE_LP_RING(); if (!planar) { - FS_LOCALS(3); + FS_LOCALS(10); + + BEGIN_LP_RING(16); + OUT_RING(_3DSTATE_PIXEL_SHADER_CONSTANTS | 4); + OUT_RING(0x0000001); /* constant 0 */ + /* constant 0: brightness/contrast */ + OUT_RING_F(pPriv->brightness / 128.0); + OUT_RING_F(pPriv->contrast / 255.0); + OUT_RING_F(0.0); + OUT_RING_F(0.0); - BEGIN_LP_RING(10); OUT_RING(_3DSTATE_SAMPLER_STATE | 3); OUT_RING(0x00000001); OUT_RING(SS2_COLORSPACE_CONVERSION | @@ -162,17 +170,23 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, ms3 |= (width - 1) << MS3_WIDTH_SHIFT; OUT_RING(ms3); OUT_RING(((video_pitch / 4) - 1) << MS4_PITCH_SHIFT); + ADVANCE_LP_RING(); FS_BEGIN(); i915_fs_dcl(FS_S0); i915_fs_dcl(FS_T0); i915_fs_texld(FS_OC, FS_S0, FS_T0); + if (pPriv->brightness != 0) { + i915_fs_add(FS_OC, + i915_fs_operand_reg(FS_OC), + i915_fs_operand(FS_C0, X, X, X, ZERO)); + } FS_END(); } else { FS_LOCALS(16); - BEGIN_LP_RING(18 + 11 + 11); + BEGIN_LP_RING(22 + 11 + 11); /* For the planar formats, we set up three samplers -- one for each plane, * in a Y8 format. Because I couldn't get the special PLANAR_TO_PACKED * shader setup to work, I did the manual pixel shader: @@ -192,8 +206,8 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, * r3 = (v,v,v,v) * OC = (r,g,b,1) */ - OUT_RING(_3DSTATE_PIXEL_SHADER_CONSTANTS | 16); - OUT_RING(0x000000f); /* constants 0-3 */ + OUT_RING(_3DSTATE_PIXEL_SHADER_CONSTANTS | (22 - 2)); + OUT_RING(0x000001f); /* constants 0-4 */ /* constant 0: normalization offsets */ OUT_RING_F(-0.0625); OUT_RING_F(-0.5); @@ -214,6 +228,11 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, OUT_RING_F(2.017); OUT_RING_F(0.0); OUT_RING_F(0.0); + /* constant 4: brightness/contrast */ + OUT_RING_F(pPriv->brightness / 128.0); + OUT_RING_F(pPriv->contrast / 255.0); + OUT_RING_F(0.0); + OUT_RING_F(0.0); OUT_RING(_3DSTATE_SAMPLER_STATE | 9); OUT_RING(0x00000007); @@ -305,6 +324,12 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, * the source. */ i915_fs_mov_masked(FS_OC, MASK_W, i915_fs_operand_one()); + + if (pPriv->brightness != 0) { + i915_fs_add(FS_OC, + i915_fs_operand_reg(FS_OC), + i915_fs_operand(FS_C4, X, X, X, ZERO)); + } FS_END(); } |