From 92abed78cc010a077738b576ffdc36fd29a3c859 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Wed, 8 Aug 2007 07:57:34 +0000 Subject: [PATCH] iPod greyscale LCD driver: Slight speedup and correct greylevels for other targets than 1st/2nd gen. * Code cleanup. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14240 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/ipod/lcd-gray.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/firmware/target/arm/ipod/lcd-gray.c b/firmware/target/arm/ipod/lcd-gray.c index a7b0112967..9a229a4725 100644 --- a/firmware/target/arm/ipod/lcd-gray.c +++ b/firmware/target/arm/ipod/lcd-gray.c @@ -30,27 +30,20 @@ #include "system.h" -/* check if number of useconds has past */ -static inline bool timer_check(int clock_start, int usecs) -{ - return ((int)(USEC_TIMER - clock_start)) >= usecs; -} - /*** hardware configuration ***/ #if CONFIG_CPU == PP5002 -#define IPOD_LCD_BASE 0xc0001000 -#define IPOD_LCD_BUSY_MASK 0x80000000 +#define IPOD_LCD_BASE 0xc0001000 #else /* PP502x */ -#define IPOD_LCD_BASE 0x70003000 -#define IPOD_LCD_BUSY_MASK 0x00008000 +#define IPOD_LCD_BASE 0x70003000 #endif -/* LCD command codes for HD66753 */ - +#define LCD_BUSY_MASK 0x00008000 #define LCD_CMD 0x08 #define LCD_DATA 0x10 +/* LCD command codes for HD66753 */ + #define R_START_OSC 0x00 #define R_DRV_OUTPUT_CONTROL 0x01 #define R_DRV_WAVEFORM_CONTROL 0x02 @@ -89,11 +82,10 @@ static const unsigned char dibits[16] ICONST_ATTR = { /* wait for LCD with timeout */ static inline void lcd_wait_write(void) { - int start = USEC_TIMER; + long timeout = USEC_TIMER + 1000; /* 1 ms */ - do { - if ((inl(IPOD_LCD_BASE) & 0x8000) == 0) break; - } while (timer_check(start, 1000) == 0); + while ((inl(IPOD_LCD_BASE) & LCD_BUSY_MASK) + && TIME_BEFORE(USEC_TIMER, timeout)); } @@ -199,9 +191,9 @@ void lcd_set_backlight_inversion(bool yesno) void lcd_set_invert_display(bool yesno) { if (yesno) - lcd_cmd_and_data(R_DISPLAY_CONTROL, 0x0023); + lcd_cmd_and_data(R_DISPLAY_CONTROL, 0x0017); else - lcd_cmd_and_data(R_DISPLAY_CONTROL, 0x0009); + lcd_cmd_and_data(R_DISPLAY_CONTROL, 0x0015); } #endif