Index: firmware/export/config-ipodmini2g.h =================================================================== --- firmware/export/config-ipodmini2g.h (revision 14403) +++ firmware/export/config-ipodmini2g.h (working copy) @@ -75,6 +75,13 @@ /* We can fade the backlight by using PWM */ #define HAVE_BACKLIGHT_PWM_FADING +#define HAVE_BACKLIGHT_BRIGHTNESS + +/* LCD backlight brightness range and defaults */ +#define MIN_BRIGHTNESS_SETTING 2 /* 2/16 (12.50%) */ +#define MAX_BRIGHTNESS_SETTING 15 /* 15/16 (93.75%) */ +#define DEFAULT_BRIGHTNESS_SETTING 9 /* 9/16 (56.25%) */ + /* Define this if you can detect headphones */ #define HAVE_HEADPHONE_DETECTION Index: firmware/export/config-ipodnano.h =================================================================== --- firmware/export/config-ipodnano.h (revision 14403) +++ firmware/export/config-ipodnano.h (working copy) @@ -73,6 +73,13 @@ /* We can fade the backlight by using PWM */ #define HAVE_BACKLIGHT_PWM_FADING +#define HAVE_BACKLIGHT_BRIGHTNESS + +/* LCD backlight brightness range and defaults */ +#define MIN_BRIGHTNESS_SETTING 2 /* 2/16 (12.50%) */ +#define MAX_BRIGHTNESS_SETTING 15 /* 15/16 (93.75%) */ +#define DEFAULT_BRIGHTNESS_SETTING 9 /* 9/16 (56.25%) */ + /* Define this if you can detect headphones */ #define HAVE_HEADPHONE_DETECTION Index: firmware/export/config-ipodvideo.h =================================================================== --- firmware/export/config-ipodvideo.h (revision 14403) +++ firmware/export/config-ipodvideo.h (working copy) @@ -73,6 +73,13 @@ /* We can fade the backlight by using PWM */ #define HAVE_BACKLIGHT_PWM_FADING +#define HAVE_BACKLIGHT_BRIGHTNESS + +/* LCD backlight brightness range and defaults */ +#define MIN_BRIGHTNESS_SETTING 2 /* 2/16 (12.50%) */ +#define MAX_BRIGHTNESS_SETTING 15 /* 15/16 (93.75%) */ +#define DEFAULT_BRIGHTNESS_SETTING 9 /* 9/16 (56.25%) */ + /* Define this if you can detect headphones */ #define HAVE_HEADPHONE_DETECTION Index: firmware/backlight.c =================================================================== --- firmware/backlight.c (revision 14403) +++ firmware/backlight.c (working copy) @@ -199,6 +199,11 @@ static int fade_out_count = 4; static bool bl_timer_active = false; +#if (MODEL_NUMBER == 4) || (MODEL_NUMBER == 5) || (MODEL_NUMBER == 11) +static int bl_brightness = BL_PWM_COUNT; +static const char bl_brightness_map[16] = + { 1, 1, 2, 4, 7, 11, 16, 22, 29, 37, 45, 54, 64, 75, 87, 100 }; +#endif static int bl_dim_current = 0; static int bl_dim_target = 0; static int bl_pwm_counter = 0; @@ -231,7 +236,12 @@ __backlight_on(); else __backlight_off(); - if (bl_dim_current == bl_dim_target) + #if (MODEL_NUMBER == 4) || (MODEL_NUMBER == 5) || (MODEL_NUMBER == 11) + if ((bl_dim_current == bl_dim_target) && + ((bl_dim_target == BL_PWM_COUNT) || (bl_dim_target == 0))) +#else + if (bl_dim_current == bl_dim_target) +#endif idle = true; } @@ -330,8 +340,13 @@ static void _backlight_on(void) { #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) +#if (MODEL_NUMBER == 4) || (MODEL_NUMBER == 5) || (MODEL_NUMBER == 11) + if ((fade_in_count > 0) || (bl_brightness != BL_PWM_COUNT)) + backlight_dim(bl_brightness); +#else if (fade_in_count > 0) backlight_dim(BL_PWM_COUNT); +#endif else { bl_dim_target = bl_dim_current = BL_PWM_COUNT; @@ -792,7 +807,15 @@ else if (val > MAX_BRIGHTNESS_SETTING) val = MAX_BRIGHTNESS_SETTING; +#if ((MODEL_NUMBER == 4) || (MODEL_NUMBER == 5) || (MODEL_NUMBER == 11)) && \ + defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) + /* set ipod brightness by changing the PWM. + conveniently using the same range (2..15) as iriver, + so we have to map the range to 0..100% */ + bl_brightness = bl_brightness_map[val]; +#else __backlight_set_brightness(val); +#endif } #endif /* HAVE_BACKLIGHT_BRIGHTNESS */