summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/export/config/sansafuze.h2
-rw-r--r--firmware/export/config/sansafuzev2.h2
-rw-r--r--firmware/target/arm/as3525/lcd-fuze.c62
-rw-r--r--firmware/target/arm/as3525/lcd-fuze.h13
4 files changed, 45 insertions, 34 deletions
diff --git a/firmware/export/config/sansafuze.h b/firmware/export/config/sansafuze.h
index a0ec8ef27c..6c8ba82bc9 100644
--- a/firmware/export/config/sansafuze.h
+++ b/firmware/export/config/sansafuze.h
@@ -59,7 +59,7 @@
59*/ 59*/
60 60
61/* define this if you can flip your LCD */ 61/* define this if you can flip your LCD */
62//#define HAVE_LCD_FLIP 62#define HAVE_LCD_FLIP
63 63
64/* define this if you can invert the colours on your LCD */ 64/* define this if you can invert the colours on your LCD */
65#define HAVE_LCD_INVERT 65#define HAVE_LCD_INVERT
diff --git a/firmware/export/config/sansafuzev2.h b/firmware/export/config/sansafuzev2.h
index d2c49f4e25..f3d8e0860e 100644
--- a/firmware/export/config/sansafuzev2.h
+++ b/firmware/export/config/sansafuzev2.h
@@ -56,7 +56,7 @@
56*/ 56*/
57 57
58/* define this if you can flip your LCD */ 58/* define this if you can flip your LCD */
59//#define HAVE_LCD_FLIP 59#define HAVE_LCD_FLIP
60 60
61/* define this if you can invert the colours on your LCD */ 61/* define this if you can invert the colours on your LCD */
62#define HAVE_LCD_INVERT 62#define HAVE_LCD_INVERT
diff --git a/firmware/target/arm/as3525/lcd-fuze.c b/firmware/target/arm/as3525/lcd-fuze.c
index ef4791e6eb..bb7bc9f49d 100644
--- a/firmware/target/arm/as3525/lcd-fuze.c
+++ b/firmware/target/arm/as3525/lcd-fuze.c
@@ -7,10 +7,9 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2004 by Linus Nielsen Feltzing
10 * Copyright (C) 2008 by Dave Chapman 11 * Copyright (C) 2008 by Dave Chapman
11 * 12 *
12 * LCD driver for the Sansa Fuze - controller unknown
13 *
14 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License 14 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2 15 * as published by the Free Software Foundation; either version 2
@@ -34,13 +33,14 @@
34 HD66789R */ 33 HD66789R */
35static bool display_on = false; /* is the display turned on? */ 34static bool display_on = false; /* is the display turned on? */
36 35
37/* Flip Flag */
38static unsigned short r_entry_mode = R_ENTRY_MODE_HORZ_NORMAL;
39
40/* Reverse Flag */ 36/* Reverse Flag */
41static unsigned short r_disp_control_rev = R_DISP_CONTROL_NORMAL; 37static int r_disp_control_rev = R_DISP_CONTROL_NORMAL;
42 38
43static const int xoffset = 20; 39/* Flip flag */
40static int r_drv_output_control = R_DRV_OUTPUT_CONTROL_NORMAL;
41static int r_gate_scan_pos = R_GATE_SCAN_POS_NORMAL;
42
43static int xoffset = 20;
44 44
45/*** hardware configuration ***/ 45/*** hardware configuration ***/
46 46
@@ -62,15 +62,27 @@ void lcd_set_invert_display(bool yesno)
62} 62}
63 63
64#ifdef HAVE_LCD_FLIP 64#ifdef HAVE_LCD_FLIP
65static bool display_flipped = false;
66
67/* turn the display upside down */ 65/* turn the display upside down */
68void lcd_set_flip(bool yesno) 66void lcd_set_flip(bool yesno)
69{ 67{
70 display_flipped = yesno; 68 if (yesno)
69 {
70 xoffset = 0;
71 r_drv_output_control = R_DRV_OUTPUT_CONTROL_FLIPPED;
72 r_gate_scan_pos = R_GATE_SCAN_POS_FLIPPED;
73 }
74 else
75 {
76 xoffset = 20;
77 r_drv_output_control = R_DRV_OUTPUT_CONTROL_NORMAL;
78 r_gate_scan_pos = R_GATE_SCAN_POS_NORMAL;
79 }
71 80
72 r_entry_mode = yesno ? R_ENTRY_MODE_HORZ_FLIPPED : 81 if (display_on)
73 R_ENTRY_MODE_HORZ_NORMAL; 82 {
83 lcd_write_reg(R_GATE_SCAN_POS, r_gate_scan_pos);
84 lcd_write_reg(R_DRV_OUTPUT_CONTROL, r_drv_output_control);
85 }
74} 86}
75#endif 87#endif
76 88
@@ -89,9 +101,9 @@ void fuze_display_on(void)
89 lcd_write_reg(R_POWER_CONTROL4, 0x60); 101 lcd_write_reg(R_POWER_CONTROL4, 0x60);
90 102
91 lcd_write_reg(R_POWER_CONTROL4, 0x70); 103 lcd_write_reg(R_POWER_CONTROL4, 0x70);
92 lcd_write_reg(R_DRV_OUTPUT_CONTROL, 277); 104 lcd_write_reg(R_DRV_OUTPUT_CONTROL, r_drv_output_control);
93 lcd_write_reg(R_DRV_WAVEFORM_CONTROL, (7<<8)); 105 lcd_write_reg(R_DRV_WAVEFORM_CONTROL, (7<<8));
94 lcd_write_reg(R_ENTRY_MODE, r_entry_mode); 106 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ);
95 lcd_write_reg(R_DISP_CONTROL2, 0x01); 107 lcd_write_reg(R_DISP_CONTROL2, 0x01);
96 lcd_write_reg(R_FRAME_CYCLE_CONTROL, (1<<10)); 108 lcd_write_reg(R_FRAME_CYCLE_CONTROL, (1<<10));
97 lcd_write_reg(R_EXT_DISP_IF_CONTROL, 0); 109 lcd_write_reg(R_EXT_DISP_IF_CONTROL, 0);
@@ -140,6 +152,8 @@ void lcd_enable(bool on)
140 lcd_write_reg(R_POWER_CONTROL4, 112); 152 lcd_write_reg(R_POWER_CONTROL4, 112);
141 lcd_write_reg(R_DISP_CONTROL1, 0x11); 153 lcd_write_reg(R_DISP_CONTROL1, 0x11);
142 lcd_write_reg(R_DISP_CONTROL1, 0x13 | r_disp_control_rev); 154 lcd_write_reg(R_DISP_CONTROL1, 0x13 | r_disp_control_rev);
155 lcd_write_reg(R_DRV_OUTPUT_CONTROL, r_drv_output_control);
156 lcd_write_reg(R_GATE_SCAN_POS, r_gate_scan_pos);
143 display_on = true; 157 display_on = true;
144 lcd_update(); /* Resync display */ 158 lcd_update(); /* Resync display */
145 send_event(LCD_EVENT_ACTIVATION, NULL); 159 send_event(LCD_EVENT_ACTIVATION, NULL);
@@ -173,15 +187,15 @@ static void lcd_window_x(int xmin, int xmax)
173{ 187{
174 xmin += xoffset; 188 xmin += xoffset;
175 xmax += xoffset; 189 xmax += xoffset;
176 lcd_write_reg(R_HORIZ_RAM_ADDR_POS + 2, (xmax << 8) | xmin); 190 lcd_write_reg(0x46, (xmax << 8) | xmin);
177 lcd_write_reg(R_RAM_ADDR_SET - 1, xmin); 191 lcd_write_reg(0x20, xmin);
178} 192}
179 193
180/* Set vertical window addresses */ 194/* Set vertical window addresses */
181static void lcd_window_y(int ymin, int ymax) 195static void lcd_window_y(int ymin, int ymax)
182{ 196{
183 lcd_write_reg(R_VERT_RAM_ADDR_POS + 2, ymax); 197 lcd_write_reg(0x47, ymax);
184 lcd_write_reg(R_VERT_RAM_ADDR_POS + 3, ymin); 198 lcd_write_reg(0x48, ymin);
185 lcd_write_reg(R_RAM_ADDR_SET, ymin); 199 lcd_write_reg(R_RAM_ADDR_SET, ymin);
186} 200}
187 201
@@ -224,13 +238,7 @@ void lcd_blit_yuv(unsigned char * const src[3],
224 yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); 238 yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
225 yuv_src[2] = src[2] + (yuv_src[1] - src[1]); 239 yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
226 240
227#ifdef HAVE_LCD_FLIP 241 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_VIDEO);
228 lcd_write_reg(R_ENTRY_MODE,
229 display_flipped ? R_ENTRY_MODE_VIDEO_FLIPPED : R_ENTRY_MODE_VIDEO_NORMAL
230 );
231#else
232 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_VIDEO_NORMAL);
233#endif
234 242
235 lcd_window_x(x, x + width - 1); 243 lcd_window_x(x, x + width - 1);
236 244
@@ -278,7 +286,7 @@ void lcd_update(void)
278 if (!display_on) 286 if (!display_on)
279 return; 287 return;
280 288
281 lcd_write_reg(R_ENTRY_MODE, r_entry_mode); 289 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ);
282 290
283 lcd_window_x(0, LCD_WIDTH - 1); 291 lcd_window_x(0, LCD_WIDTH - 1);
284 lcd_window_y(0, LCD_HEIGHT - 1); 292 lcd_window_y(0, LCD_HEIGHT - 1);
@@ -316,7 +324,7 @@ void lcd_update_rect(int x, int y, int width, int height)
316 if (y + height > LCD_HEIGHT) 324 if (y + height > LCD_HEIGHT)
317 height = LCD_HEIGHT - y; /* clip bottom */ 325 height = LCD_HEIGHT - y; /* clip bottom */
318 326
319 lcd_write_reg(R_ENTRY_MODE, r_entry_mode); 327 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ);
320 328
321 /* we need to make x and width even to enable 32bit transfers */ 329 /* we need to make x and width even to enable 32bit transfers */
322 width = (width + (x & 1) + 1) & ~1; 330 width = (width + (x & 1) + 1) & ~1;
diff --git a/firmware/target/arm/as3525/lcd-fuze.h b/firmware/target/arm/as3525/lcd-fuze.h
index 00bb960ef1..50bec9b6ea 100644
--- a/firmware/target/arm/as3525/lcd-fuze.h
+++ b/firmware/target/arm/as3525/lcd-fuze.h
@@ -41,16 +41,19 @@
41#define R_HORIZ_RAM_ADDR_POS 0x44 41#define R_HORIZ_RAM_ADDR_POS 0x44
42#define R_VERT_RAM_ADDR_POS 0x45 42#define R_VERT_RAM_ADDR_POS 0x45
43 43
44/* Flip Flag */ 44#define R_ENTRY_MODE_HORZ 0x1030
45#define R_ENTRY_MODE_HORZ_NORMAL 0x1030 45#define R_ENTRY_MODE_VIDEO 0x1038
46#define R_ENTRY_MODE_HORZ_FLIPPED 0x1000
47#define R_ENTRY_MODE_VIDEO_NORMAL 0x1038
48#define R_ENTRY_MODE_VIDEO_FLIPPED 0x1018
49 46
50/* Reverse Flag */ 47/* Reverse Flag */
51#define R_DISP_CONTROL_NORMAL 0x0004 48#define R_DISP_CONTROL_NORMAL 0x0004
52#define R_DISP_CONTROL_REV 0x0000 49#define R_DISP_CONTROL_REV 0x0000
53 50
51#define R_DRV_OUTPUT_CONTROL_NORMAL 0x115
52#define R_DRV_OUTPUT_CONTROL_FLIPPED 0x215
53
54#define R_GATE_SCAN_POS_NORMAL 0
55#define R_GATE_SCAN_POS_FLIPPED 18
56
54void lcd_write_cmd(int16_t cmd); 57void lcd_write_cmd(int16_t cmd);
55void lcd_write_reg(int reg, int value); 58void lcd_write_reg(int reg, int value);
56void fuze_display_on(void); 59void fuze_display_on(void);