--- kernel-source-2.6.16.old/drivers/video/omap/lcd_lph8923.c 2006-06-20 16:02:01.000000000 +0200 +++ kernel-source-2.6.16/drivers/video/omap/lcd_lph8923.c 2006-10-17 12:53:39.000000000 +0200 @@ -20,6 +20,14 @@ #define LPH8923_VER_NON_BUGGY 3 +#define BACKLIGHT_USE_TABLE + + +#ifdef BACKLIGHT_USE_TABLE +unsigned char bklight_table[] = {3,25,33,42,50,76,93,110,127}; +#define BACKLIGHT_TABLE_SIZE 9 +#endif + static struct { int enabled; int version; @@ -32,6 +40,10 @@ unsigned long hw_guard_wait; /* max guard time in jiffies */ struct omapfb_device *fbdev; struct spi_device *spi; +#ifdef BACKLIGHT_USE_TABLE + unsigned char bklight_table_src[BACKLIGHT_TABLE_SIZE]; + unsigned char bklight_table_dst[BACKLIGHT_TABLE_SIZE]; +#endif } lph8923; static struct lcd_panel lph8923_panel; @@ -259,7 +271,11 @@ static int lph8923_panel_init(struct omapfb_device *fbdev) { lph8923.fbdev = fbdev; - +#ifdef BACKLIGHT_USE_TABLE + /* initialize translation table */ + memcpy(lph8923.bklight_table_src,bklight_table,BACKLIGHT_TABLE_SIZE); + memcpy(lph8923.bklight_table_dst,bklight_table,BACKLIGHT_TABLE_SIZE); +#endif lph8923_detect(); lph8923.enabled = lph8923_enabled(); @@ -272,20 +288,68 @@ static int lph8923_panel_set_bklight_level(unsigned int level) { - 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 = lph8923.saved_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=lph8923.bklight_table_src[srclevel-1]; + } +// + for (i=0;i