[Mplayer-cvslog] CVS: main/vidix/drivers mga_vid.c,1.13,1.14
Alex Beregszaszi
alex at mplayerhq.hu
Sat Jun 29 13:40:41 CEST 2002
Update of /cvsroot/mplayer/main/vidix/drivers
In directory mail:/var/tmp.root/cvs-serv29869
Modified Files:
mga_vid.c
Log Message:
equalizer (brightness/contrast) support
Index: mga_vid.c
===================================================================
RCS file: /cvsroot/mplayer/main/vidix/drivers/mga_vid.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- mga_vid.c 2 Feb 2002 18:28:55 -0000 1.13
+++ mga_vid.c 29 Jun 2002 11:40:28 -0000 1.14
@@ -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 @@
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 @@
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 @@
}
-
//Disable contrast and brightness control
regs.besglobctl |= (1<<5) + (1<<7);
regs.beslumactl = (0x7f << 16) + (0x80<<0);
@@ -1443,46 +1434,49 @@
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);
+ regs.beslumactl = luma+0x80;
- writel(beslumactl,mga_mmio_base + BESLUMACTL);
- return 0;
+ 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
More information about the MPlayer-cvslog
mailing list