--- kernel-source-2.6.16-2.6.16.rel.orig/drivers/video/omap/lcd_mipid.c	2006-11-28 14:17:03.000000000 +0100
+++ kernel-source-2.6.16-2.6.16.rel/drivers/video/omap/lcd_mipid.c	2007-04-25 14:46:03.000000000 +0200
@@ -51,6 +51,14 @@
 
 #define to_mipid_device(p)		container_of(p, struct mipid_device, \
 						panel)
+
+#define	BACKLIGHT_USE_TABLE
+
+#ifdef	BACKLIGHT_USE_TABLE
+static unsigned char bklight_table[] = {3,25,33,42,50,76,93,110,127};
+#define BACKLIGHT_TABLE_SIZE	9
+#endif
+
 struct mipid_device {
 	int		enabled;
 	int		model;
@@ -76,6 +84,11 @@
 	unsigned		esd_enabled:1;
 	int			esd_recoveries;	/* number of consecutive
 						   recovery attempts */
+#ifdef        BACKLIGHT_USE_TABLE
+	unsigned char   bklight_table_src[BACKLIGHT_TABLE_SIZE];
+	unsigned char   bklight_table_dst[BACKLIGHT_TABLE_SIZE];
+	signed int      orig_bklight_level;
+#endif
 };
 
 static void mipid_transfer(struct mipid_device *md, int cmd, const u8 *wbuf,
@@ -226,20 +239,72 @@
 {
 	struct mipid_device *md = to_mipid_device(panel);
 
-	if (level > tahvo_get_max_backlight_level())
+	if (level > tahvo_get_max_backlight_level()){
+#ifdef	BACKLIGHT_USE_TABLE
+	/*
+	values greater than valid maximum will change translation table
+	to map srclevel to dstlevel value 0x80|srclevel + (dstlevel<<8) needs to be written
+	if srclevel is 0, current active level is changed
+	*/
+	unsigned int srclevel,dstlevel,i;
+	//level -= 0x80; //1 + tahvo_get_max_backlight_level();
+	srclevel = level & 0x7F;
+	dstlevel = level >> 8;
+	if (dstlevel > tahvo_get_max_backlight_level())
+		return -EINVAL;
+	if (srclevel == 0)
+		srclevel = md->orig_bklight_level; /* zero means change current level */
+// srclevel is used as table index, not direct value to remap
+// remove those 5 lines below to use it as direct value
+	else {
+		if (srclevel>BACKLIGHT_TABLE_SIZE)
+			return -EINVAL;
+		srclevel=md->bklight_table_src[srclevel-1];	
+	}
+//
+	for (i=0;i<BACKLIGHT_TABLE_SIZE;i++){
+		if (srclevel == md->bklight_table_src[i]){
+			/* OK, found matching src level, set destination */
+			md->bklight_table_dst[i] = dstlevel;
+			break;
+		}
+	}
+	if (srclevel != md->orig_bklight_level)
+		return 0; /* not current level */
+		
+	/* we are changing current active level, continue */	
+	level = srclevel;	
+#else
 		return -EINVAL;
+#endif
+	} else
+		md->orig_bklight_level = level;
+#ifdef	BACKLIGHT_USE_TABLE
+	/* try to translate level */
+	{ int i;
+	for (i=0;i<BACKLIGHT_TABLE_SIZE;i++){
+		if (level == md->bklight_table_src[i]){
+			level = md->bklight_table_dst[i];
+			break;
+		}
+	}
+	}
+#endif
 	if (!md->enabled) {
 		md->saved_bklight_level = level;
 		return 0;
 	}
 	tahvo_set_backlight_level(level);
-
 	return 0;
 }
 
 static unsigned int mipid_get_bklight_level(struct lcd_panel *panel)
 {
-	return tahvo_get_backlight_level();
+	struct mipid_device *md = to_mipid_device(panel);
+	if (md->orig_bklight_level>=0)
+		return md->orig_bklight_level; // ok, orig value initialized, return it
+	else
+		return (md->orig_bklight_level=tahvo_get_backlight_level()); // read real value and initialize orig_bklight_level
 }
 
 static unsigned int mipid_get_bklight_max(struct lcd_panel *panel)
@@ -602,6 +667,12 @@
 	struct mipid_device *md = to_mipid_device(panel);
 	int r;
 
+#ifdef        BACKLIGHT_USE_TABLE
+	/* initialize translation table */
+	memcpy(md->bklight_table_src,bklight_table,BACKLIGHT_TABLE_SIZE);
+	memcpy(md->bklight_table_dst,bklight_table,BACKLIGHT_TABLE_SIZE);
+	md->orig_bklight_level=-1;
+#endif
 	md->fbdev = fbdev;
 	mutex_init(&md->mutex);
 
