diff options
author | alex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-06-29 11:40:28 +0000 |
---|---|---|
committer | alex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-06-29 11:40:28 +0000 |
commit | 1f901e5d6e34652703d638f498e7257b27efe01c (patch) | |
tree | 032b6eac285efc65fe1304004ba4ed82f3bbfd78 | |
parent | abd0478ed03e1cc91b7e9521b3704060f169be74 (diff) |
equalizer (brightness/contrast) support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6601 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | vidix/drivers/mga_vid.c | 80 |
1 files changed, 37 insertions, 43 deletions
diff --git a/vidix/drivers/mga_vid.c b/vidix/drivers/mga_vid.c index a5442bd0fc..439e2e03ef 100644 --- a/vidix/drivers/mga_vid.c +++ b/vidix/drivers/mga_vid.c @@ -6,14 +6,12 @@ YUY2 support (see config.format) added by A'rpi/ESP-team double buffering added by A'rpi/ESP-team - Brightness/contrast support by Nick Kurshev + Brightness/contrast support by Nick Kurshev/Dariush Pietrzak (eyck) and me TODO: * fix doublebuffering for vidix * fix memory size detection (current reading pci userconfig isn't working as requested - returns the max avail. ram on arch?) - * fix/complete brightness/contrast handling (Nick) - MGA users: please test this! (#define MGA_EQUALIZER) * translate all non-english comments to english */ @@ -46,8 +44,6 @@ #define MGA_VSYNC_POS 2 -#undef MGA_EQUALIZER - #undef MGA_PCICONFIG_MEMDETECT #define MGA_DEFAULT_FRAMES 1 @@ -122,11 +118,7 @@ static vidix_capability_t mga_cap = 4, 4, -1, - FLAG_UPSCALER | FLAG_DOWNSCALER -#ifdef MGA_EQUALIZER - | FLAG_EQUALIZER -#endif - , + FLAG_UPSCALER | FLAG_DOWNSCALER | FLAG_EQUALIZER, VENDOR_MATROX, -1, /* will be set in vixProbe */ { 0, 0, 0, 0} @@ -734,7 +726,7 @@ int vixConfigPlayback(vidix_playback_t *config) config->dest.pitch.y=32; config->dest.pitch.u=config->dest.pitch.v=16; - printf("[mga] Setting up a %dx%d+%d+%d video window (src %dx%d) format %X\n", + printf("[mga] Setting up a %dx%d-%dx%d video window (src %dx%d) format %X\n", dw, dh, x, y, sw, sh, config->fourcc); if ((sw < 4) || (sh < 4) || (dw < 4) || (dh < 4)) @@ -852,7 +844,6 @@ int vixConfigPlayback(vidix_playback_t *config) } - //Disable contrast and brightness control regs.besglobctl |= (1<<5) + (1<<7); regs.beslumactl = (0x7f << 16) + (0x80<<0); @@ -1443,46 +1434,49 @@ int vixSetGrKeys(const vidix_grkey_t *grkey) return(0); } -#ifdef MGA_EQUALIZER -static vidix_video_eq_t equal = +int vixPlaybackSetEq( const vidix_video_eq_t * eq) { - VEQ_CAP_BRIGHTNESS | VEQ_CAP_CONTRAST, - 0, 0, 0, 0, 0, 0, 0, 0 }; -int vixPlaybackSetEq( const vidix_video_eq_t * eq) -{ - uint32_t beslumactl; - int brightness,contrast; + uint32_t luma = 0; + float factor = 256.0 / 2000; - /* contrast and brightness control isn't supported with G200, - don't enable c/b control and set values, just return error -- alex */ + /* contrast and brightness control isn't supported on G200 - alex */ if (!is_g400) { if (mga_verbose > 1) printf("[mga] equalizer isn't supported with G200\n"); - return ENOSYS; + return(ENOTSUP); } + + if (eq->cap & VEQ_CAP_BRIGHTNESS) + luma += ((int)(eq->brightness * factor) << 16); + if (eq->cap & VEQ_CAP_CONTRAST) + luma += ((int)(eq->contrast * factor) & 0xFFFF); - if(eq->cap & VEQ_CAP_BRIGHTNESS) equal.brightness = eq->brightness; - if(eq->cap & VEQ_CAP_CONTRAST) equal.contrast = eq->contrast; - equal.flags = eq->flags; - - //Enable contrast and brightness control - writel(readl(mga_mmio_base + BESGLOBCTL) & ~((1<<5) + (1<<7)),mga_mmio_base + BESGLOBCTL); - brightness = (equal.brightness * 128) / 1000; - if(brightness < -128) brightness = -128; - if(brightness > 127) brightness = 127; - contrast = ((equal.contrast + 1000) * 128) / 1000; - if(contrast < 0) contrast = 0; - if(contrast > 255) contrast = 255; - beslumactl = ((brightness & 0xff) << 16) | (contrast & 0xff); - - writel(beslumactl,mga_mmio_base + BESLUMACTL); - return 0; + regs.beslumactl = luma+0x80; + + writel(regs.beslumactl,mga_mmio_base + BESLUMACTL); + return(0); } -int vixPlaybackGetEq( vidix_video_eq_t * eq) +int vixPlaybackGetEq( vidix_video_eq_t * eq) { - memcpy(eq,&equal,sizeof(vidix_video_eq_t)); - return 0; + uint32_t luma; + float factor = 2000.0 / 256; + + /* contrast and brightness control isn't supported on G200 - alex */ + if (!is_g400) + { + if (mga_verbose > 1) + printf("[mga] equalizer isn't supported with G200\n"); + return(ENOTSUP); + } + + regs.beslumactl = readl(mga_mmio_base + BESLUMACTL); + luma = regs.beslumactl-0x80; + + eq->brightness = (luma >> 16) * factor; + eq->contrast = (luma & 0xFFFF) * factor; + eq->cap = VEQ_CAP_BRIGHTNESS | VEQ_CAP_CONTRAST; + + return(0); } -#endif |