[Mplayer-cvslog] CVS: main/drivers/radeon radeon_vid.c,1.36,1.37 README,1.13,1.14
Nick Kurshev
nick at mplayer.dev.hu
Mon Dec 31 17:08:36 CET 2001
Update of /cvsroot/mplayer/main/drivers/radeon
In directory mplayer:/var/tmp.root/cvs-serv9319/main/drivers/radeon
Modified Files:
radeon_vid.c README
Log Message:
Added support of BRIGHTNESS, SATURATION, CONTRAST, HUE on Radeons
Thanks to GATOS's guys! Great work!
Happy new year!
Index: radeon_vid.c
===================================================================
RCS file: /cvsroot/mplayer/main/drivers/radeon/radeon_vid.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- radeon_vid.c 30 Dec 2001 17:28:09 -0000 1.36
+++ radeon_vid.c 31 Dec 2001 16:08:32 -0000 1.37
@@ -17,7 +17,7 @@
* Rage128(pro) stuff of this driver.
*/
-#define RADEON_VID_VERSION "1.1.2"
+#define RADEON_VID_VERSION "1.2.0"
/*
It's entirely possible this major conflicts with something else
@@ -110,6 +110,14 @@
#define RTRACE(...) ((void)0)
#endif
+#if !defined( RAGE128 ) && !defined( AVOID_FPU )
+#define RADEON_FPU 1
+#endif
+
+#ifdef RADEON_FPU
+#include <math.h>
+#endif
+
typedef struct bes_registers_s
{
/* base address of yuv framebuffer */
@@ -457,6 +465,135 @@
}
#endif
+#ifdef RADEON_FPU
+/* Reference color space transform data */
+typedef struct tagREF_TRANSFORM
+{
+ float RefLuma;
+ float RefRCb;
+ float RefRCr;
+ float RefGCb;
+ float RefGCr;
+ float RefBCb;
+ float RefBCr;
+} REF_TRANSFORM;
+
+/* Parameters for ITU-R BT.601 and ITU-R BT.709 colour spaces */
+REF_TRANSFORM trans[2] =
+{
+ {1.1678, 0.0, 1.6007, -0.3929, -0.8154, 2.0232, 0.0}, /* BT.601 */
+ {1.1678, 0.0, 1.7980, -0.2139, -0.5345, 2.1186, 0.0} /* BT.709 */
+};
+/****************************************************************************
+ * SetTransform *
+ * Function: Calculates and sets color space transform from supplied *
+ * reference transform, gamma, brightness, contrast, hue and *
+ * saturation. *
+ * Inputs: bright - brightness *
+ * cont - contrast *
+ * sat - saturation *
+ * hue - hue *
+ * ref - index to the table of refernce transforms *
+ * Outputs: NONE *
+ ****************************************************************************/
+
+static void radeon_set_transform(float bright, float cont, float sat,
+ float hue, unsigned ref)
+{
+ float OvHueSin, OvHueCos;
+ float CAdjLuma, CAdjOff;
+ float CAdjRCb, CAdjRCr;
+ float CAdjGCb, CAdjGCr;
+ float CAdjBCb, CAdjBCr;
+ float OvLuma, OvROff, OvGOff, OvBOff;
+ float OvRCb, OvRCr;
+ float OvGCb, OvGCr;
+ float OvBCb, OvBCr;
+ float Loff = 64.0;
+ float Coff = 512.0f;
+
+ u32 dwOvLuma, dwOvROff, dwOvGOff, dwOvBOff;
+ u32 dwOvRCb, dwOvRCr;
+ u32 dwOvGCb, dwOvGCr;
+ u32 dwOvBCb, dwOvBCr;
+
+ if (ref >= 2) return;
+
+ OvHueSin = sin((double)hue);
+ OvHueCos = cos((double)hue);
+
+ CAdjLuma = cont * trans[ref].RefLuma;
+ CAdjOff = cont * trans[ref].RefLuma * bright * 1023.0;
+
+ CAdjRCb = sat * -OvHueSin * trans[ref].RefRCr;
+ CAdjRCr = sat * OvHueCos * trans[ref].RefRCr;
+ CAdjGCb = sat * (OvHueCos * trans[ref].RefGCb - OvHueSin * trans[ref].RefGCr);
+ CAdjGCr = sat * (OvHueSin * trans[ref].RefGCb + OvHueCos * trans[ref].RefGCr);
+ CAdjBCb = sat * OvHueCos * trans[ref].RefBCb;
+ CAdjBCr = sat * OvHueSin * trans[ref].RefBCb;
+
+#if 0 /* default constants */
+ CAdjLuma = 1.16455078125;
+
+ CAdjRCb = 0.0;
+ CAdjRCr = 1.59619140625;
+ CAdjGCb = -0.39111328125;
+ CAdjGCr = -0.8125;
+ CAdjBCb = 2.01708984375;
+ CAdjBCr = 0;
+#endif
+ OvLuma = CAdjLuma;
+ OvRCb = CAdjRCb;
+ OvRCr = CAdjRCr;
+ OvGCb = CAdjGCb;
+ OvGCr = CAdjGCr;
+ OvBCb = CAdjBCb;
+ OvBCr = CAdjBCr;
+ OvROff = CAdjOff -
+ OvLuma * Loff - (OvRCb + OvRCr) * Coff;
+ OvGOff = CAdjOff -
+ OvLuma * Loff - (OvGCb + OvGCr) * Coff;
+ OvBOff = CAdjOff -
+ OvLuma * Loff - (OvBCb + OvBCr) * Coff;
+#if 0 /* default constants */
+ OvROff = -888.5;
+ OvGOff = 545;
+ OvBOff = -1104;
+#endif
+
+ dwOvROff = ((int)(OvROff * 2.0)) & 0x1fff;
+ dwOvGOff = (int)(OvGOff * 2.0) & 0x1fff;
+ dwOvBOff = (int)(OvBOff * 2.0) & 0x1fff;
+ if(!IsR200)
+ {
+ dwOvLuma =(((int)(OvLuma * 2048.0))&0x7fff)<<17;
+ dwOvRCb = (((int)(OvRCb * 2048.0))&0x7fff)<<1;
+ dwOvRCr = (((int)(OvRCr * 2048.0))&0x7fff)<<17;
+ dwOvGCb = (((int)(OvGCb * 2048.0))&0x7fff)<<1;
+ dwOvGCr = (((int)(OvGCr * 2048.0))&0x7fff)<<17;
+ dwOvBCb = (((int)(OvBCb * 2048.0))&0x7fff)<<1;
+ dwOvBCr = (((int)(OvBCr * 2048.0))&0x7fff)<<17;
+ }
+ else
+ {
+ dwOvLuma = (((int)(OvLuma * 256.0))&0x7ff)<<20;
+ dwOvRCb = (((int)(OvRCb * 256.0))&0x7ff)<<4;
+ dwOvRCr = (((int)(OvRCr * 256.0))&0x7ff)<<20;
+ dwOvGCb = (((int)(OvGCb * 256.0))&0x7ff)<<4;
+ dwOvGCr = (((int)(OvGCr * 256.0))&0x7ff)<<20;
+ dwOvBCb = (((int)(OvBCb * 256.0))&0x7ff)<<4;
+ dwOvBCr = (((int)(OvBCr * 256.0))&0x7ff)<<20;
+ }
+
+ OUTREG(OV0_LIN_TRANS_A, dwOvRCb | dwOvLuma);
+ OUTREG(OV0_LIN_TRANS_B, dwOvROff | dwOvRCr);
+ OUTREG(OV0_LIN_TRANS_C, dwOvGCb | dwOvLuma);
+ OUTREG(OV0_LIN_TRANS_D, dwOvGOff | dwOvGCr);
+ OUTREG(OV0_LIN_TRANS_E, dwOvBCb | dwOvLuma);
+ OUTREG(OV0_LIN_TRANS_F, dwOvBOff | dwOvBCr);
+}
+#endif
+
#ifndef RAGE128
/* Gamma curve definition */
typedef struct
@@ -1073,9 +1210,14 @@
#define PARAM_BRIGHTNESS "brightness="
#define PARAM_SATURATION "saturation="
+#define PARAM_CONTRAST "contrast="
+#define PARAM_HUE "hue="
#define PARAM_DOUBLE_BUFF "double_buff="
#define PARAM_DEINTERLACE "deinterlace="
#define PARAM_DEINTERLACE_PATTERN "deinterlace_pattern="
+#ifdef RADEON_FPU
+static int ovBrightness=0, ovSaturation=0, ovContrast=0, ovHue=0, ov_trans_idx=0;
+#endif
static void radeon_param_buff_fill( void )
{
@@ -1105,6 +1247,13 @@
#ifdef RAGE128
len += sprintf(&radeon_param_buff[len],PARAM_BRIGHTNESS"%i\n",(int)brightness);
len += sprintf(&radeon_param_buff[len],PARAM_SATURATION"%u\n",saturation);
+#else
+#ifdef RADEON_FPU
+ len += sprintf(&radeon_param_buff[len],PARAM_BRIGHTNESS"%i\n",ovBrightness);
+ len += sprintf(&radeon_param_buff[len],PARAM_SATURATION"%i\n",ovSaturation);
+ len += sprintf(&radeon_param_buff[len],PARAM_CONTRAST"%i\n",ovContrast);
+ len += sprintf(&radeon_param_buff[len],PARAM_HUE"%i\n",ovHue);
+#endif
#endif
len += sprintf(&radeon_param_buff[len],PARAM_DEINTERLACE"%s\n",besr.deinterlace_on?"on":"off");
len += sprintf(&radeon_param_buff[len],PARAM_DEINTERLACE_PATTERN"%X\n",besr.deinterlace_pattern);
@@ -1123,6 +1272,11 @@
return size;
}
+#define RTFSaturation(a) (1.0 + ((a)*1.0)/1000.0)
+#define RTFBrightness(a) (((a)*1.0)/2000.0)
+#define RTFContrast(a) (1.0 + ((a)*1.0)/1000.0)
+#define RTFHue(a) (((a)*3.1416)/1000.0)
+
static ssize_t radeon_vid_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
{
#ifdef RAGE128
@@ -1149,6 +1303,37 @@
(saturation << 16));
}
else
+#else
+#ifdef RADEON_FPU
+ if(memcmp(buf,PARAM_BRIGHTNESS,min(count,strlen(PARAM_BRIGHTNESS))) == 0)
+ {
+ ovBrightness=simple_strtol(&buf[strlen(PARAM_BRIGHTNESS)],NULL,10);
+ radeon_set_transform(RTFBrightness(ovBrightness),RTFContrast(ovContrast)
+ ,RTFSaturation(ovSaturation),RTFHue(ovHue),ov_trans_idx);
+ }
+ else
+ if(memcmp(buf,PARAM_SATURATION,min(count,strlen(PARAM_SATURATION))) == 0)
+ {
+ ovSaturation=simple_strtol(&buf[strlen(PARAM_SATURATION)],NULL,10);
+ radeon_set_transform(RTFBrightness(ovBrightness),RTFContrast(ovContrast)
+ ,RTFSaturation(ovSaturation),RTFHue(ovHue),ov_trans_idx);
+ }
+ else
+ if(memcmp(buf,PARAM_CONTRAST,min(count,strlen(PARAM_CONTRAST))) == 0)
+ {
+ ovContrast=simple_strtol(&buf[strlen(PARAM_CONTRAST)],NULL,10);
+ radeon_set_transform(RTFBrightness(ovBrightness),RTFContrast(ovContrast)
+ ,RTFSaturation(ovSaturation),RTFHue(ovHue),ov_trans_idx);
+ }
+ else
+ if(memcmp(buf,PARAM_HUE,min(count,strlen(PARAM_HUE))) == 0)
+ {
+ ovHue=simple_strtol(&buf[strlen(PARAM_HUE)],NULL,10);
+ radeon_set_transform(RTFBrightness(ovBrightness),RTFContrast(ovContrast)
+ ,RTFSaturation(ovSaturation),RTFHue(ovHue),ov_trans_idx);
+ }
+ else
+#endif
#endif
if(memcmp(buf,PARAM_DOUBLE_BUFF,min(count,strlen(PARAM_DOUBLE_BUFF))) == 0)
{
Index: README
===================================================================
RCS file: /cvsroot/mplayer/main/drivers/radeon/README,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- README 12 Dec 2001 15:29:51 -0000 1.13
+++ README 31 Dec 2001 16:08:32 -0000 1.14
@@ -65,9 +65,15 @@
List of parameters:
~~~~~~~~~~~~~~~~~~~
if you have rage128 chip:
-brightness=decval (-64:+63) doesn't work on radeons
-saturation=decval (0:+31) doesn't work on radeons
-endif
+brightness=decval (-64:+63) changes brightness
+saturation=decval (0:+31) changes saturation 0 == grayscaled mode
+else - if you have radeon:
+brightness=decval (-1000:+1000) -1000 == black screen
+saturation=decval (-1000:+1000) -1000 == grayscaled mode
+contrast=decval (-1000:+1000) -1000 == black screen
+hue=decval (-1000:+1000) -1000 == +1000 (full circle)
+ all other values are within this range
+Note: 0 is default value for every parameter on radeons
double_buff=on/off enables/disables double buffering
deinterlace=on/off enables/disables adaprive deinterlacing
More information about the MPlayer-cvslog
mailing list