FS#9890 - iPod 5G: LCD sleep, BCM shutdown and bootstrap
Opened by Boris Gjenero (dreamlayers) - Wednesday, 11 February 2009, 02:42 GMT
Last edited by Boris Gjenero (dreamlayers) - Tuesday, 14 April 2009, 03:26 GMT
IMPORTANT: Run "make clean" after patching. If old files are present, changes to the config header won't automatically change the list of features, so lang.* won't be updated and the build will fail.
Here is code which enables LCD sleep on the 5G iPod.
lcd_enable(false) puts the LCD to sleep and powers down the BCM.
lcd_enable(true) bootstraps the BCM and wakes up the LCD
These are used via platform-independent code relating to HAVE_LCD_ENABLE, HAVE_LCD_SLEEP and define HAVE_LCD_SLEEP_SETTING. As a result, in "Settings -> General Settings -> Display -> LCD Settings" there is a new option, "Sleep (After Backlight Off)", which allows you to set when the LCD goes to sleep. The default is 10 seconds.
I have also defined HAVE_LCD_SHUTDOWN and used lcd_enable(false) as lcd_shutdown(). I think putting the LCD to sleep before cutting power might be better than just clearing it.
I think concurrency-related problems won't happen because LCD update calls never yield, lcd_state.display_on blocks them when lcd_enable yields, and lcd_enable is only called from backlight_thread. I'm tempted to wrap the LCD in a mutex but I think that may be unnecessary because other targets don't do that. I guess LCD calls aren't supposed to come from the COP.
Wakeup is not instantaneous because of the BCM initialization procedure. I have shortened some sleeps to speed it up. (It would be faster if the BCM kept running and only the LCD was put to sleep. Any LCD update command then automatically wakes the LCD. That would save less power.) (BTW. It seems the LCD framebuffer is not in BCM memory. The BCM merely uploads data to the LCD, and the LCD can independently keep displaying that image even if the BCM is turned off.)
I have changed the LCD update BCM command from 5 (0xFFFA0005) to 0 (0xFFFF0000). The former only updates a specified rectangle, and the latter updates the whole screen. The rectangle was always set to the whole screen, and this allows bcm_setup_rect to be removed. (For reference, these are words at 0xE0000 for command 5: 0x34, x, y, x + width - 1, y + height - 1, width * height * 2, 0 , 0. I wonder if that 0x34 means the command can also do other things.)
I feel more work is needed in firmware/backlight.c, some of which isn't platform-dependent:
- If sleep is set ot "Always", the LCD sleeps when the fade starts, which is ugly. I tried to fix this but something weird is going on, like the fade-in never finished, maybe because of timer_set_period(0) when bl_dim_current reaches BL_PWM_COUNT.
- Backlight settings changes led to backlight_update_state() calls outside of backlight_thread(). This led to multiple concurrent lcd_enable operations when lcd_enable yields. I replaced those with backlight_on().
- It would be nice if the user could wake the LCD if the backlight is always off and LCD sleep isn't "Always"
- It would be nice if the the backlight on hold settings were extended to "LCD on hold".
It might be possible to power off the LCD instead of just putting it to sleep. It also might be possible to shut off the PCF5060X_D3REGC1 supply. This requires additional research.
Tuesday, 14 April 2009, 03:26 GMT
Reason for closing: Accepted
Additional comments about closing: Accepted in r20076. Tweaks and fixes in r20695 and r20696.