aboutsummaryrefslogtreecommitdiffhomepage
path: root/drivers
diff options
context:
space:
mode:
authorGravatar nick <nick@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-12-31 16:08:32 +0000
committerGravatar nick <nick@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-12-31 16:08:32 +0000
commit0ba7fe9753b26388e85f02b72047183a062d0df1 (patch)
tree327450edb30a5a3f7946998b1d2c59ee2997862c /drivers
parent1dc3a24e9f626fc424bb968cf32b1938f50dd944 (diff)
Added support of BRIGHTNESS, SATURATION, CONTRAST, HUE on Radeons
Thanks to GATOS's guys! Great work! Happy new year! git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3922 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'drivers')
-rw-r--r--drivers/radeon/README12
-rw-r--r--drivers/radeon/radeon_vid.c187
2 files changed, 195 insertions, 4 deletions
diff --git a/drivers/radeon/README b/drivers/radeon/README
index 5cfaaa3314..6746f14901 100644
--- a/drivers/radeon/README
+++ b/drivers/radeon/README
@@ -65,9 +65,15 @@ cat /dev/radeon_vid
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
diff --git a/drivers/radeon/radeon_vid.c b/drivers/radeon/radeon_vid.c
index 8009c99a9e..19f28983de 100644
--- a/drivers/radeon/radeon_vid.c
+++ b/drivers/radeon/radeon_vid.c
@@ -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 @@ static int swap_fourcc __initdata = 0;
#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 @@ static void radeon_vid_dump_regs( void )
}
#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 @@ static int __init radeon_vid_config_card(void)
#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 @@ static void radeon_param_buff_fill( void )
#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 @@ static ssize_t radeon_vid_read(struct file *file, char *buf, size_t count, loff_
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 @@ static ssize_t radeon_vid_write(struct file *file, const char *buf, size_t count
(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)
{