summaryrefslogtreecommitdiff
path: root/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/sandisk/sansa-e200/lcd-e200.c')
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/lcd-e200.c84
1 files changed, 56 insertions, 28 deletions
diff --git a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
index 9f6cf7fc11..07bc72c3c1 100644
--- a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
@@ -23,6 +23,8 @@
23#include "lcd.h" 23#include "lcd.h"
24#include "system.h" 24#include "system.h"
25#include <string.h> 25#include <string.h>
26#include "backlight-target.h"
27#include "pp5024.h"
26 28
27#define LCD_DATA_IN_GPIO GPIOB_INPUT_VAL 29#define LCD_DATA_IN_GPIO GPIOB_INPUT_VAL
28#define LCD_DATA_IN_PIN 6 30#define LCD_DATA_IN_PIN 6
@@ -141,12 +143,12 @@ inline void lcd_init_device(void)
141 outl(((inl(0x70000010) & (0x03ffffff)) | (0x15 << 26)), 0x70000010); 143 outl(((inl(0x70000010) & (0x03ffffff)) | (0x15 << 26)), 0x70000010);
142 outl(((inl(0x70000014) & (0x0fffffff)) | (0x5 << 28)), 0x70000014); 144 outl(((inl(0x70000014) & (0x0fffffff)) | (0x5 << 28)), 0x70000014);
143 outl((inl(0x70000020) & ~(0x3 << 10)), 0x70000020); 145 outl((inl(0x70000020) & ~(0x3 << 10)), 0x70000020);
144 DEV_EN |= (1 << 26); /* Enable controller */ 146 DEV_EN |= DEV_LCD; /* Enable controller */
145 outl(0x6, 0x600060d0); 147 outl(0x6, 0x600060d0);
146 DEV_RS |= (1 << 26); /* Reset controller */ 148 DEV_RS |= DEV_LCD; /* Reset controller */
147 outl((inl(0x70000020) & ~(1 << 14)), 0x70000020); 149 outl((inl(0x70000020) & ~(1 << 14)), 0x70000020);
148 lcd_bus_idle(); 150 lcd_bus_idle();
149 DEV_RS &=~(1 << 26); /* Clear reset */ 151 DEV_RS &=~DEV_LCD; /* Clear reset */
150 udelay(1000); 152 udelay(1000);
151 153
152 LCD_REG_0 = (LCD_REG_0 & (0x00ffffff)) | (0x22 << 24); 154 LCD_REG_0 = (LCD_REG_0 & (0x00ffffff)) | (0x22 << 24);
@@ -247,40 +249,66 @@ inline void lcd_init_device(void)
247 lcd_send_msg(0x70, 34); 249 lcd_send_msg(0x70, 34);
248} 250}
249 251
252void lcd_enable(bool on)
253{
254 if(on)
255 {
256 DEV_EN |= DEV_LCD; /* Enable LCD controller */
257 LCD_REG_6 |= 1; /* Enable DMA */
258 }
259 else
260 {
261 if(DEV_EN & DEV_LCD)
262 {
263 LCD_REG_6 &= ~1; /* Disable DMA */
264 udelay(20000); /* Wait for dma end (assuming 50Hz) */
265 DEV_EN &= ~DEV_LCD; /* Disable LCD controller */
266 }
267 }
268}
269
250inline void lcd_update_rect(int x, int y, int width, int height) 270inline void lcd_update_rect(int x, int y, int width, int height)
251{ 271{
252 (void)x; 272 (void)x;
253 (void)width; 273 (void)width;
254 /* Turn off DMA and wait for the transfer to complete */
255 /* TODO: Work out the proper delay */
256 LCD_REG_6 &= ~1;
257 udelay(1000);
258
259 /* Copy the Rockbox framebuffer to the second framebuffer */
260 /* TODO: Move the second framebuffer into uncached SDRAM */
261 memcpy(((char*)&lcd_driver_framebuffer)+(y * sizeof(fb_data) * LCD_WIDTH),
262 ((char *)&lcd_framebuffer)+(y * sizeof(fb_data) * LCD_WIDTH),
263 ((height * sizeof(fb_data) * LCD_WIDTH)));
264 flush_icache();
265 274
266 /* Restart DMA */ 275 if(__backlight_is_on())
267 LCD_REG_6 |= 1; 276 {
277 /* Turn off DMA and wait for the transfer to complete */
278 /* TODO: Work out the proper delay */
279 LCD_REG_6 &= ~1;
280 udelay(1000);
281
282 /* Copy the Rockbox framebuffer to the second framebuffer */
283 /* TODO: Move the second framebuffer into uncached SDRAM */
284 memcpy(((char*)&lcd_driver_framebuffer)+(y * sizeof(fb_data) * LCD_WIDTH),
285 ((char *)&lcd_framebuffer)+(y * sizeof(fb_data) * LCD_WIDTH),
286 ((height * sizeof(fb_data) * LCD_WIDTH)));
287 flush_icache();
288
289 /* Restart DMA */
290 LCD_REG_6 |= 1;
291 }
268} 292}
269 293
270inline void lcd_update(void) 294inline void lcd_update(void)
271{ 295{
272 /* TODO: It may be faster to swap the addresses of lcd_driver_framebuffer 296 if(__backlight_is_on())
273 * and lcd_framebuffer */ 297 {
274 /* Turn off DMA and wait for the transfer to complete */ 298 /* TODO: It may be faster to swap the addresses of lcd_driver_framebuffer
275 LCD_REG_6 &= ~1; 299 * and lcd_framebuffer */
276 udelay(1000); 300 /* Turn off DMA and wait for the transfer to complete */
277 301 LCD_REG_6 &= ~1;
278 /* Copy the Rockbox framebuffer to the second framebuffer */ 302 udelay(1000);
279 memcpy(lcd_driver_framebuffer, lcd_framebuffer, sizeof(fb_data) * LCD_WIDTH * LCD_HEIGHT); 303
280 flush_icache(); 304 /* Copy the Rockbox framebuffer to the second framebuffer */
281 305 memcpy(lcd_driver_framebuffer, lcd_framebuffer,
282 /* Restart DMA */ 306 sizeof(fb_data) * LCD_WIDTH * LCD_HEIGHT);
283 LCD_REG_6 |= 1; 307 flush_icache();
308
309 /* Restart DMA */
310 LCD_REG_6 |= 1;
311 }
284} 312}
285 313
286 314