changeset 4483:fb4b914eab8a

framework for settings modifications like in radeon_vid ( /dev/mga_vid can be written to ). Brightness and chroma control.
author eyck
date Sat, 02 Feb 2002 20:49:52 +0000
parents 9c6ab57cfdde
children c150a35fd22b
files drivers/mga_vid.c
diffstat 1 files changed, 38 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/drivers/mga_vid.c	Sat Feb 02 18:28:55 2002 +0000
+++ b/drivers/mga_vid.c	Sat Feb 02 20:49:52 2002 +0000
@@ -88,6 +88,12 @@
 MODULE_LICENSE("GPL");
 #endif
 
+// WARNING - eyck changes
+#define PARAM_BRIGHTNESS "brightness="
+#define PARAM_SATURATION "saturation="
+#define PARAM_BLACKIE "blackie="
+// end eyck
+
 typedef struct bes_registers_s
 {
 	//BES Control
@@ -152,6 +158,11 @@
 	//BES Field 2 weight start
 	uint32_t besv2wght;
 
+
+	//configurable stuff
+	int brightness;
+	int blackie;
+
 } bes_registers_t;
 
 static bes_registers_t regs;
@@ -680,11 +691,16 @@
 	return -1;
 }
 
+	// setting black&white mode 
+	regs.besctl|=(regs.blackie<<20); // TODO: check g200 & g400 (maybe tomorrow)
 
-	//Disable contrast and brightness control
+	//Enable contrast and brightness control
 	regs.besglobctl |= (1<<5) + (1<<7);
-	regs.beslumactl = (0x7f << 16) + (0x80<<0);
-	regs.beslumactl = 0x80<<0;
+	
+	// brightness ; default is 0x7f;
+	regs.beslumactl = (regs.brightness << 16);
+	// contrast:
+	regs.beslumactl|= (0x80<<0);
 
 	//Setup destination window boundaries
 	besleft = x > 0 ? x : 0;
@@ -1304,7 +1320,25 @@
 
 static ssize_t mga_vid_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
 {
-	return -EINVAL;
+	// WARNING: eyck changes
+	if(memcmp(buf,PARAM_BRIGHTNESS,min(count,strlen(PARAM_BRIGHTNESS))) == 0)
+	{
+		short brightness;
+		brightness=simple_strtol(&buf[strlen(PARAM_BRIGHTNESS)],NULL,10);
+		if (brightness>127 || brightness<-128) { brightness=0;} 
+//		printk(KERN_DEBUG "mga_vid: brightness modified ( %d ) \n",brightness);
+		regs.brightness=brightness;
+	} else 
+        if(memcmp(buf,PARAM_BLACKIE,min(count,strlen(PARAM_BLACKIE))) == 0)
+	{
+		short blackie;
+		blackie=simple_strtol(&buf[strlen(PARAM_BLACKIE)],NULL,10);
+//		printk(KERN_DEBUG "mga_vid: shadow mode: ( %d ) \n",blackie);
+		regs.blackie=(blackie>0)?1:0;
+	} else count = -EIO;
+	// TODO: reset settings
+	return count;
+//	return -EINVAL;
 }
 
 static int mga_vid_mmap(struct file *file, struct vm_area_struct *vma)